[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /******/ (() => { // webpackBootstrap 2 /******/ var __webpack_modules__ = ({ 3 4 /***/ 4306: 5 /***/ (function(module, exports) { 6 7 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 8 autosize 4.0.4 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 /***/ 5755: 294 /***/ ((module, exports) => { 295 296 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 297 Copyright (c) 2018 Jed Watson. 298 Licensed under the MIT License (MIT), see 299 http://jedwatson.github.io/classnames 300 */ 301 /* global define */ 302 303 (function () { 304 'use strict'; 305 306 var hasOwn = {}.hasOwnProperty; 307 var nativeCodeString = '[native code]'; 308 309 function classNames() { 310 var classes = []; 311 312 for (var i = 0; i < arguments.length; i++) { 313 var arg = arguments[i]; 314 if (!arg) continue; 315 316 var argType = typeof arg; 317 318 if (argType === 'string' || argType === 'number') { 319 classes.push(arg); 320 } else if (Array.isArray(arg)) { 321 if (arg.length) { 322 var inner = classNames.apply(null, arg); 323 if (inner) { 324 classes.push(inner); 325 } 326 } 327 } else if (argType === 'object') { 328 if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) { 329 classes.push(arg.toString()); 330 continue; 331 } 332 333 for (var key in arg) { 334 if (hasOwn.call(arg, key) && arg[key]) { 335 classes.push(key); 336 } 337 } 338 } 339 } 340 341 return classes.join(' '); 342 } 343 344 if ( true && module.exports) { 345 classNames.default = classNames; 346 module.exports = classNames; 347 } else if (true) { 348 // register as 'classnames', consistent with npm package name 349 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { 350 return classNames; 351 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), 352 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 353 } else {} 354 }()); 355 356 357 /***/ }), 358 359 /***/ 6109: 360 /***/ ((module) => { 361 362 // This code has been refactored for 140 bytes 363 // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js 364 var computedStyle = function (el, prop, getComputedStyle) { 365 getComputedStyle = window.getComputedStyle; 366 367 // In one fell swoop 368 return ( 369 // If we have getComputedStyle 370 getComputedStyle ? 371 // Query it 372 // TODO: From CSS-Query notes, we might need (node, null) for FF 373 getComputedStyle(el) : 374 375 // Otherwise, we are in IE and use currentStyle 376 el.currentStyle 377 )[ 378 // Switch to camelCase for CSSOM 379 // DEV: Grabbed from jQuery 380 // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194 381 // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597 382 prop.replace(/-(\w)/gi, function (word, letter) { 383 return letter.toUpperCase(); 384 }) 385 ]; 386 }; 387 388 module.exports = computedStyle; 389 390 391 /***/ }), 392 393 /***/ 461: 394 /***/ ((module, __unused_webpack_exports, __webpack_require__) => { 395 396 // Load in dependencies 397 var computedStyle = __webpack_require__(6109); 398 399 /** 400 * Calculate the `line-height` of a given node 401 * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM. 402 * @returns {Number} `line-height` of the element in pixels 403 */ 404 function lineHeight(node) { 405 // Grab the line-height via style 406 var lnHeightStr = computedStyle(node, 'line-height'); 407 var lnHeight = parseFloat(lnHeightStr, 10); 408 409 // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em') 410 if (lnHeightStr === lnHeight + '') { 411 // Save the old lineHeight style and update the em unit to the element 412 var _lnHeightStyle = node.style.lineHeight; 413 node.style.lineHeight = lnHeightStr + 'em'; 414 415 // Calculate the em based height 416 lnHeightStr = computedStyle(node, 'line-height'); 417 lnHeight = parseFloat(lnHeightStr, 10); 418 419 // Revert the lineHeight style 420 if (_lnHeightStyle) { 421 node.style.lineHeight = _lnHeightStyle; 422 } else { 423 delete node.style.lineHeight; 424 } 425 } 426 427 // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt) 428 // DEV: `em` units are converted to `pt` in IE6 429 // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length 430 if (lnHeightStr.indexOf('pt') !== -1) { 431 lnHeight *= 4; 432 lnHeight /= 3; 433 // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm) 434 } else if (lnHeightStr.indexOf('mm') !== -1) { 435 lnHeight *= 96; 436 lnHeight /= 25.4; 437 // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm) 438 } else if (lnHeightStr.indexOf('cm') !== -1) { 439 lnHeight *= 96; 440 lnHeight /= 2.54; 441 // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in) 442 } else if (lnHeightStr.indexOf('in') !== -1) { 443 lnHeight *= 96; 444 // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc) 445 } else if (lnHeightStr.indexOf('pc') !== -1) { 446 lnHeight *= 16; 447 } 448 449 // Continue our computation 450 lnHeight = Math.round(lnHeight); 451 452 // If the line-height is "normal", calculate by font-size 453 if (lnHeightStr === 'normal') { 454 // Create a temporary node 455 var nodeName = node.nodeName; 456 var _node = document.createElement(nodeName); 457 _node.innerHTML = ' '; 458 459 // If we have a text area, reset it to only 1 row 460 // https://github.com/twolfson/line-height/issues/4 461 if (nodeName.toUpperCase() === 'TEXTAREA') { 462 _node.setAttribute('rows', '1'); 463 } 464 465 // Set the font-size of the element 466 var fontSizeStr = computedStyle(node, 'font-size'); 467 _node.style.fontSize = fontSizeStr; 468 469 // Remove default padding/border which can affect offset height 470 // https://github.com/twolfson/line-height/issues/4 471 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight 472 _node.style.padding = '0px'; 473 _node.style.border = '0px'; 474 475 // Append it to the body 476 var body = document.body; 477 body.appendChild(_node); 478 479 // Assume the line height of the element is the height 480 var height = _node.offsetHeight; 481 lnHeight = height; 482 483 // Remove our child from the DOM 484 body.removeChild(_node); 485 } 486 487 // Return the calculated height 488 return lnHeight; 489 } 490 491 // Export lineHeight 492 module.exports = lineHeight; 493 494 495 /***/ }), 496 497 /***/ 628: 498 /***/ ((module, __unused_webpack_exports, __webpack_require__) => { 499 500 "use strict"; 501 /** 502 * Copyright (c) 2013-present, Facebook, Inc. 503 * 504 * This source code is licensed under the MIT license found in the 505 * LICENSE file in the root directory of this source tree. 506 */ 507 508 509 510 var ReactPropTypesSecret = __webpack_require__(4067); 511 512 function emptyFunction() {} 513 function emptyFunctionWithReset() {} 514 emptyFunctionWithReset.resetWarningCache = emptyFunction; 515 516 module.exports = function() { 517 function shim(props, propName, componentName, location, propFullName, secret) { 518 if (secret === ReactPropTypesSecret) { 519 // It is still safe when called from React. 520 return; 521 } 522 var err = new Error( 523 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 524 'Use PropTypes.checkPropTypes() to call them. ' + 525 'Read more at http://fb.me/use-check-prop-types' 526 ); 527 err.name = 'Invariant Violation'; 528 throw err; 529 }; 530 shim.isRequired = shim; 531 function getShim() { 532 return shim; 533 }; 534 // Important! 535 // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. 536 var ReactPropTypes = { 537 array: shim, 538 bigint: shim, 539 bool: shim, 540 func: shim, 541 number: shim, 542 object: shim, 543 string: shim, 544 symbol: shim, 545 546 any: shim, 547 arrayOf: getShim, 548 element: shim, 549 elementType: shim, 550 instanceOf: getShim, 551 node: shim, 552 objectOf: getShim, 553 oneOf: getShim, 554 oneOfType: getShim, 555 shape: getShim, 556 exact: getShim, 557 558 checkPropTypes: emptyFunctionWithReset, 559 resetWarningCache: emptyFunction 560 }; 561 562 ReactPropTypes.PropTypes = ReactPropTypes; 563 564 return ReactPropTypes; 565 }; 566 567 568 /***/ }), 569 570 /***/ 5826: 571 /***/ ((module, __unused_webpack_exports, __webpack_require__) => { 572 573 /** 574 * Copyright (c) 2013-present, Facebook, Inc. 575 * 576 * This source code is licensed under the MIT license found in the 577 * LICENSE file in the root directory of this source tree. 578 */ 579 580 if (false) { var throwOnDirectAccess, ReactIs; } else { 581 // By explicitly using `prop-types` you are opting into new production behavior. 582 // http://fb.me/prop-types-in-prod 583 module.exports = __webpack_require__(628)(); 584 } 585 586 587 /***/ }), 588 589 /***/ 4067: 590 /***/ ((module) => { 591 592 "use strict"; 593 /** 594 * Copyright (c) 2013-present, Facebook, Inc. 595 * 596 * This source code is licensed under the MIT license found in the 597 * LICENSE file in the root directory of this source tree. 598 */ 599 600 601 602 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; 603 604 module.exports = ReactPropTypesSecret; 605 606 607 /***/ }), 608 609 /***/ 4462: 610 /***/ (function(__unused_webpack_module, exports, __webpack_require__) { 611 612 "use strict"; 613 614 var __extends = (this && this.__extends) || (function () { 615 var extendStatics = Object.setPrototypeOf || 616 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 617 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 618 return function (d, b) { 619 extendStatics(d, b); 620 function __() { this.constructor = d; } 621 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 622 }; 623 })(); 624 var __assign = (this && this.__assign) || Object.assign || function(t) { 625 for (var s, i = 1, n = arguments.length; i < n; i++) { 626 s = arguments[i]; 627 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) 628 t[p] = s[p]; 629 } 630 return t; 631 }; 632 var __rest = (this && this.__rest) || function (s, e) { 633 var t = {}; 634 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) 635 t[p] = s[p]; 636 if (s != null && typeof Object.getOwnPropertySymbols === "function") 637 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) 638 t[p[i]] = s[p[i]]; 639 return t; 640 }; 641 exports.__esModule = true; 642 var React = __webpack_require__(1609); 643 var PropTypes = __webpack_require__(5826); 644 var autosize = __webpack_require__(4306); 645 var _getLineHeight = __webpack_require__(461); 646 var getLineHeight = _getLineHeight; 647 var RESIZED = "autosize:resized"; 648 /** 649 * A light replacement for built-in textarea component 650 * which automaticaly adjusts its height to match the content 651 */ 652 var TextareaAutosizeClass = /** @class */ (function (_super) { 653 __extends(TextareaAutosizeClass, _super); 654 function TextareaAutosizeClass() { 655 var _this = _super !== null && _super.apply(this, arguments) || this; 656 _this.state = { 657 lineHeight: null 658 }; 659 _this.textarea = null; 660 _this.onResize = function (e) { 661 if (_this.props.onResize) { 662 _this.props.onResize(e); 663 } 664 }; 665 _this.updateLineHeight = function () { 666 if (_this.textarea) { 667 _this.setState({ 668 lineHeight: getLineHeight(_this.textarea) 669 }); 670 } 671 }; 672 _this.onChange = function (e) { 673 var onChange = _this.props.onChange; 674 _this.currentValue = e.currentTarget.value; 675 onChange && onChange(e); 676 }; 677 return _this; 678 } 679 TextareaAutosizeClass.prototype.componentDidMount = function () { 680 var _this = this; 681 var _a = this.props, maxRows = _a.maxRows, async = _a.async; 682 if (typeof maxRows === "number") { 683 this.updateLineHeight(); 684 } 685 if (typeof maxRows === "number" || async) { 686 /* 687 the defer is needed to: 688 - force "autosize" to activate the scrollbar when this.props.maxRows is passed 689 - support StyledComponents (see #71) 690 */ 691 setTimeout(function () { return _this.textarea && autosize(_this.textarea); }); 692 } 693 else { 694 this.textarea && autosize(this.textarea); 695 } 696 if (this.textarea) { 697 this.textarea.addEventListener(RESIZED, this.onResize); 698 } 699 }; 700 TextareaAutosizeClass.prototype.componentWillUnmount = function () { 701 if (this.textarea) { 702 this.textarea.removeEventListener(RESIZED, this.onResize); 703 autosize.destroy(this.textarea); 704 } 705 }; 706 TextareaAutosizeClass.prototype.render = function () { 707 var _this = this; 708 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; 709 var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null; 710 return (React.createElement("textarea", __assign({}, props, { onChange: this.onChange, style: maxHeight ? __assign({}, style, { maxHeight: maxHeight }) : style, ref: function (element) { 711 _this.textarea = element; 712 if (typeof _this.props.innerRef === 'function') { 713 _this.props.innerRef(element); 714 } 715 else if (_this.props.innerRef) { 716 _this.props.innerRef.current = element; 717 } 718 } }), children)); 719 }; 720 TextareaAutosizeClass.prototype.componentDidUpdate = function () { 721 this.textarea && autosize.update(this.textarea); 722 }; 723 TextareaAutosizeClass.defaultProps = { 724 rows: 1, 725 async: false 726 }; 727 TextareaAutosizeClass.propTypes = { 728 rows: PropTypes.number, 729 maxRows: PropTypes.number, 730 onResize: PropTypes.func, 731 innerRef: PropTypes.any, 732 async: PropTypes.bool 733 }; 734 return TextareaAutosizeClass; 735 }(React.Component)); 736 exports.TextareaAutosize = React.forwardRef(function (props, ref) { 737 return React.createElement(TextareaAutosizeClass, __assign({}, props, { innerRef: ref })); 738 }); 739 740 741 /***/ }), 742 743 /***/ 4132: 744 /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 745 746 "use strict"; 747 var __webpack_unused_export__; 748 749 __webpack_unused_export__ = true; 750 var TextareaAutosize_1 = __webpack_require__(4462); 751 exports.A = TextareaAutosize_1.TextareaAutosize; 752 753 754 /***/ }), 755 756 /***/ 9681: 757 /***/ ((module) => { 758 759 var characterMap = { 760 "À": "A", 761 "Á": "A", 762 "Â": "A", 763 "Ã": "A", 764 "Ä": "A", 765 "Å": "A", 766 "Ấ": "A", 767 "Ắ": "A", 768 "Ẳ": "A", 769 "Ẵ": "A", 770 "Ặ": "A", 771 "Æ": "AE", 772 "Ầ": "A", 773 "Ằ": "A", 774 "Ȃ": "A", 775 "Ả": "A", 776 "Ạ": "A", 777 "Ẩ": "A", 778 "Ẫ": "A", 779 "Ậ": "A", 780 "Ç": "C", 781 "Ḉ": "C", 782 "È": "E", 783 "É": "E", 784 "Ê": "E", 785 "Ë": "E", 786 "Ế": "E", 787 "Ḗ": "E", 788 "Ề": "E", 789 "Ḕ": "E", 790 "Ḝ": "E", 791 "Ȇ": "E", 792 "Ẻ": "E", 793 "Ẽ": "E", 794 "Ẹ": "E", 795 "Ể": "E", 796 "Ễ": "E", 797 "Ệ": "E", 798 "Ì": "I", 799 "Í": "I", 800 "Î": "I", 801 "Ï": "I", 802 "Ḯ": "I", 803 "Ȋ": "I", 804 "Ỉ": "I", 805 "Ị": "I", 806 "Ð": "D", 807 "Ñ": "N", 808 "Ò": "O", 809 "Ó": "O", 810 "Ô": "O", 811 "Õ": "O", 812 "Ö": "O", 813 "Ø": "O", 814 "Ố": "O", 815 "Ṍ": "O", 816 "Ṓ": "O", 817 "Ȏ": "O", 818 "Ỏ": "O", 819 "Ọ": "O", 820 "Ổ": "O", 821 "Ỗ": "O", 822 "Ộ": "O", 823 "Ờ": "O", 824 "Ở": "O", 825 "Ỡ": "O", 826 "Ớ": "O", 827 "Ợ": "O", 828 "Ù": "U", 829 "Ú": "U", 830 "Û": "U", 831 "Ü": "U", 832 "Ủ": "U", 833 "Ụ": "U", 834 "Ử": "U", 835 "Ữ": "U", 836 "Ự": "U", 837 "Ý": "Y", 838 "à": "a", 839 "á": "a", 840 "â": "a", 841 "ã": "a", 842 "ä": "a", 843 "å": "a", 844 "ấ": "a", 845 "ắ": "a", 846 "ẳ": "a", 847 "ẵ": "a", 848 "ặ": "a", 849 "æ": "ae", 850 "ầ": "a", 851 "ằ": "a", 852 "ȃ": "a", 853 "ả": "a", 854 "ạ": "a", 855 "ẩ": "a", 856 "ẫ": "a", 857 "ậ": "a", 858 "ç": "c", 859 "ḉ": "c", 860 "è": "e", 861 "é": "e", 862 "ê": "e", 863 "ë": "e", 864 "ế": "e", 865 "ḗ": "e", 866 "ề": "e", 867 "ḕ": "e", 868 "ḝ": "e", 869 "ȇ": "e", 870 "ẻ": "e", 871 "ẽ": "e", 872 "ẹ": "e", 873 "ể": "e", 874 "ễ": "e", 875 "ệ": "e", 876 "ì": "i", 877 "í": "i", 878 "î": "i", 879 "ï": "i", 880 "ḯ": "i", 881 "ȋ": "i", 882 "ỉ": "i", 883 "ị": "i", 884 "ð": "d", 885 "ñ": "n", 886 "ò": "o", 887 "ó": "o", 888 "ô": "o", 889 "õ": "o", 890 "ö": "o", 891 "ø": "o", 892 "ố": "o", 893 "ṍ": "o", 894 "ṓ": "o", 895 "ȏ": "o", 896 "ỏ": "o", 897 "ọ": "o", 898 "ổ": "o", 899 "ỗ": "o", 900 "ộ": "o", 901 "ờ": "o", 902 "ở": "o", 903 "ỡ": "o", 904 "ớ": "o", 905 "ợ": "o", 906 "ù": "u", 907 "ú": "u", 908 "û": "u", 909 "ü": "u", 910 "ủ": "u", 911 "ụ": "u", 912 "ử": "u", 913 "ữ": "u", 914 "ự": "u", 915 "ý": "y", 916 "ÿ": "y", 917 "Ā": "A", 918 "ā": "a", 919 "Ă": "A", 920 "ă": "a", 921 "Ą": "A", 922 "ą": "a", 923 "Ć": "C", 924 "ć": "c", 925 "Ĉ": "C", 926 "ĉ": "c", 927 "Ċ": "C", 928 "ċ": "c", 929 "Č": "C", 930 "č": "c", 931 "C̆": "C", 932 "c̆": "c", 933 "Ď": "D", 934 "ď": "d", 935 "Đ": "D", 936 "đ": "d", 937 "Ē": "E", 938 "ē": "e", 939 "Ĕ": "E", 940 "ĕ": "e", 941 "Ė": "E", 942 "ė": "e", 943 "Ę": "E", 944 "ę": "e", 945 "Ě": "E", 946 "ě": "e", 947 "Ĝ": "G", 948 "Ǵ": "G", 949 "ĝ": "g", 950 "ǵ": "g", 951 "Ğ": "G", 952 "ğ": "g", 953 "Ġ": "G", 954 "ġ": "g", 955 "Ģ": "G", 956 "ģ": "g", 957 "Ĥ": "H", 958 "ĥ": "h", 959 "Ħ": "H", 960 "ħ": "h", 961 "Ḫ": "H", 962 "ḫ": "h", 963 "Ĩ": "I", 964 "ĩ": "i", 965 "Ī": "I", 966 "ī": "i", 967 "Ĭ": "I", 968 "ĭ": "i", 969 "Į": "I", 970 "į": "i", 971 "İ": "I", 972 "ı": "i", 973 "IJ": "IJ", 974 "ij": "ij", 975 "Ĵ": "J", 976 "ĵ": "j", 977 "Ķ": "K", 978 "ķ": "k", 979 "Ḱ": "K", 980 "ḱ": "k", 981 "K̆": "K", 982 "k̆": "k", 983 "Ĺ": "L", 984 "ĺ": "l", 985 "Ļ": "L", 986 "ļ": "l", 987 "Ľ": "L", 988 "ľ": "l", 989 "Ŀ": "L", 990 "ŀ": "l", 991 "Ł": "l", 992 "ł": "l", 993 "Ḿ": "M", 994 "ḿ": "m", 995 "M̆": "M", 996 "m̆": "m", 997 "Ń": "N", 998 "ń": "n", 999 "Ņ": "N", 1000 "ņ": "n", 1001 "Ň": "N", 1002 "ň": "n", 1003 "ʼn": "n", 1004 "N̆": "N", 1005 "n̆": "n", 1006 "Ō": "O", 1007 "ō": "o", 1008 "Ŏ": "O", 1009 "ŏ": "o", 1010 "Ő": "O", 1011 "ő": "o", 1012 "Œ": "OE", 1013 "œ": "oe", 1014 "P̆": "P", 1015 "p̆": "p", 1016 "Ŕ": "R", 1017 "ŕ": "r", 1018 "Ŗ": "R", 1019 "ŗ": "r", 1020 "Ř": "R", 1021 "ř": "r", 1022 "R̆": "R", 1023 "r̆": "r", 1024 "Ȓ": "R", 1025 "ȓ": "r", 1026 "Ś": "S", 1027 "ś": "s", 1028 "Ŝ": "S", 1029 "ŝ": "s", 1030 "Ş": "S", 1031 "Ș": "S", 1032 "ș": "s", 1033 "ş": "s", 1034 "Š": "S", 1035 "š": "s", 1036 "Ţ": "T", 1037 "ţ": "t", 1038 "ț": "t", 1039 "Ț": "T", 1040 "Ť": "T", 1041 "ť": "t", 1042 "Ŧ": "T", 1043 "ŧ": "t", 1044 "T̆": "T", 1045 "t̆": "t", 1046 "Ũ": "U", 1047 "ũ": "u", 1048 "Ū": "U", 1049 "ū": "u", 1050 "Ŭ": "U", 1051 "ŭ": "u", 1052 "Ů": "U", 1053 "ů": "u", 1054 "Ű": "U", 1055 "ű": "u", 1056 "Ų": "U", 1057 "ų": "u", 1058 "Ȗ": "U", 1059 "ȗ": "u", 1060 "V̆": "V", 1061 "v̆": "v", 1062 "Ŵ": "W", 1063 "ŵ": "w", 1064 "Ẃ": "W", 1065 "ẃ": "w", 1066 "X̆": "X", 1067 "x̆": "x", 1068 "Ŷ": "Y", 1069 "ŷ": "y", 1070 "Ÿ": "Y", 1071 "Y̆": "Y", 1072 "y̆": "y", 1073 "Ź": "Z", 1074 "ź": "z", 1075 "Ż": "Z", 1076 "ż": "z", 1077 "Ž": "Z", 1078 "ž": "z", 1079 "ſ": "s", 1080 "ƒ": "f", 1081 "Ơ": "O", 1082 "ơ": "o", 1083 "Ư": "U", 1084 "ư": "u", 1085 "Ǎ": "A", 1086 "ǎ": "a", 1087 "Ǐ": "I", 1088 "ǐ": "i", 1089 "Ǒ": "O", 1090 "ǒ": "o", 1091 "Ǔ": "U", 1092 "ǔ": "u", 1093 "Ǖ": "U", 1094 "ǖ": "u", 1095 "Ǘ": "U", 1096 "ǘ": "u", 1097 "Ǚ": "U", 1098 "ǚ": "u", 1099 "Ǜ": "U", 1100 "ǜ": "u", 1101 "Ứ": "U", 1102 "ứ": "u", 1103 "Ṹ": "U", 1104 "ṹ": "u", 1105 "Ǻ": "A", 1106 "ǻ": "a", 1107 "Ǽ": "AE", 1108 "ǽ": "ae", 1109 "Ǿ": "O", 1110 "ǿ": "o", 1111 "Þ": "TH", 1112 "þ": "th", 1113 "Ṕ": "P", 1114 "ṕ": "p", 1115 "Ṥ": "S", 1116 "ṥ": "s", 1117 "X́": "X", 1118 "x́": "x", 1119 "Ѓ": "Г", 1120 "ѓ": "г", 1121 "Ќ": "К", 1122 "ќ": "к", 1123 "A̋": "A", 1124 "a̋": "a", 1125 "E̋": "E", 1126 "e̋": "e", 1127 "I̋": "I", 1128 "i̋": "i", 1129 "Ǹ": "N", 1130 "ǹ": "n", 1131 "Ồ": "O", 1132 "ồ": "o", 1133 "Ṑ": "O", 1134 "ṑ": "o", 1135 "Ừ": "U", 1136 "ừ": "u", 1137 "Ẁ": "W", 1138 "ẁ": "w", 1139 "Ỳ": "Y", 1140 "ỳ": "y", 1141 "Ȁ": "A", 1142 "ȁ": "a", 1143 "Ȅ": "E", 1144 "ȅ": "e", 1145 "Ȉ": "I", 1146 "ȉ": "i", 1147 "Ȍ": "O", 1148 "ȍ": "o", 1149 "Ȑ": "R", 1150 "ȑ": "r", 1151 "Ȕ": "U", 1152 "ȕ": "u", 1153 "B̌": "B", 1154 "b̌": "b", 1155 "Č̣": "C", 1156 "č̣": "c", 1157 "Ê̌": "E", 1158 "ê̌": "e", 1159 "F̌": "F", 1160 "f̌": "f", 1161 "Ǧ": "G", 1162 "ǧ": "g", 1163 "Ȟ": "H", 1164 "ȟ": "h", 1165 "J̌": "J", 1166 "ǰ": "j", 1167 "Ǩ": "K", 1168 "ǩ": "k", 1169 "M̌": "M", 1170 "m̌": "m", 1171 "P̌": "P", 1172 "p̌": "p", 1173 "Q̌": "Q", 1174 "q̌": "q", 1175 "Ř̩": "R", 1176 "ř̩": "r", 1177 "Ṧ": "S", 1178 "ṧ": "s", 1179 "V̌": "V", 1180 "v̌": "v", 1181 "W̌": "W", 1182 "w̌": "w", 1183 "X̌": "X", 1184 "x̌": "x", 1185 "Y̌": "Y", 1186 "y̌": "y", 1187 "A̧": "A", 1188 "a̧": "a", 1189 "B̧": "B", 1190 "b̧": "b", 1191 "Ḑ": "D", 1192 "ḑ": "d", 1193 "Ȩ": "E", 1194 "ȩ": "e", 1195 "Ɛ̧": "E", 1196 "ɛ̧": "e", 1197 "Ḩ": "H", 1198 "ḩ": "h", 1199 "I̧": "I", 1200 "i̧": "i", 1201 "Ɨ̧": "I", 1202 "ɨ̧": "i", 1203 "M̧": "M", 1204 "m̧": "m", 1205 "O̧": "O", 1206 "o̧": "o", 1207 "Q̧": "Q", 1208 "q̧": "q", 1209 "U̧": "U", 1210 "u̧": "u", 1211 "X̧": "X", 1212 "x̧": "x", 1213 "Z̧": "Z", 1214 "z̧": "z", 1215 "й":"и", 1216 "Й":"И", 1217 "ё":"е", 1218 "Ё":"Е", 1219 }; 1220 1221 var chars = Object.keys(characterMap).join('|'); 1222 var allAccents = new RegExp(chars, 'g'); 1223 var firstAccent = new RegExp(chars, ''); 1224 1225 function matcher(match) { 1226 return characterMap[match]; 1227 } 1228 1229 var removeAccents = function(string) { 1230 return string.replace(allAccents, matcher); 1231 }; 1232 1233 var hasAccents = function(string) { 1234 return !!string.match(firstAccent); 1235 }; 1236 1237 module.exports = removeAccents; 1238 module.exports.has = hasAccents; 1239 module.exports.remove = removeAccents; 1240 1241 1242 /***/ }), 1243 1244 /***/ 1609: 1245 /***/ ((module) => { 1246 1247 "use strict"; 1248 module.exports = window["React"]; 1249 1250 /***/ }) 1251 1252 /******/ }); 1253 /************************************************************************/ 1254 /******/ // The module cache 1255 /******/ var __webpack_module_cache__ = {}; 1256 /******/ 1257 /******/ // The require function 1258 /******/ function __webpack_require__(moduleId) { 1259 /******/ // Check if module is in cache 1260 /******/ var cachedModule = __webpack_module_cache__[moduleId]; 1261 /******/ if (cachedModule !== undefined) { 1262 /******/ return cachedModule.exports; 1263 /******/ } 1264 /******/ // Create a new module (and put it into the cache) 1265 /******/ var module = __webpack_module_cache__[moduleId] = { 1266 /******/ // no module.id needed 1267 /******/ // no module.loaded needed 1268 /******/ exports: {} 1269 /******/ }; 1270 /******/ 1271 /******/ // Execute the module function 1272 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); 1273 /******/ 1274 /******/ // Return the exports of the module 1275 /******/ return module.exports; 1276 /******/ } 1277 /******/ 1278 /************************************************************************/ 1279 /******/ /* webpack/runtime/compat get default export */ 1280 /******/ (() => { 1281 /******/ // getDefaultExport function for compatibility with non-harmony modules 1282 /******/ __webpack_require__.n = (module) => { 1283 /******/ var getter = module && module.__esModule ? 1284 /******/ () => (module['default']) : 1285 /******/ () => (module); 1286 /******/ __webpack_require__.d(getter, { a: getter }); 1287 /******/ return getter; 1288 /******/ }; 1289 /******/ })(); 1290 /******/ 1291 /******/ /* webpack/runtime/define property getters */ 1292 /******/ (() => { 1293 /******/ // define getter functions for harmony exports 1294 /******/ __webpack_require__.d = (exports, definition) => { 1295 /******/ for(var key in definition) { 1296 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 1297 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 1298 /******/ } 1299 /******/ } 1300 /******/ }; 1301 /******/ })(); 1302 /******/ 1303 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 1304 /******/ (() => { 1305 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 1306 /******/ })(); 1307 /******/ 1308 /******/ /* webpack/runtime/make namespace object */ 1309 /******/ (() => { 1310 /******/ // define __esModule on exports 1311 /******/ __webpack_require__.r = (exports) => { 1312 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 1313 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 1314 /******/ } 1315 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 1316 /******/ }; 1317 /******/ })(); 1318 /******/ 1319 /************************************************************************/ 1320 var __webpack_exports__ = {}; 1321 // This entry need to be wrapped in an IIFE because it need to be in strict mode. 1322 (() => { 1323 "use strict"; 1324 // ESM COMPAT FLAG 1325 __webpack_require__.r(__webpack_exports__); 1326 1327 // EXPORTS 1328 __webpack_require__.d(__webpack_exports__, { 1329 AlignmentToolbar: () => (/* reexport */ AlignmentToolbar), 1330 Autocomplete: () => (/* reexport */ Autocomplete), 1331 AutosaveMonitor: () => (/* reexport */ autosave_monitor), 1332 BlockAlignmentToolbar: () => (/* reexport */ BlockAlignmentToolbar), 1333 BlockControls: () => (/* reexport */ BlockControls), 1334 BlockEdit: () => (/* reexport */ BlockEdit), 1335 BlockEditorKeyboardShortcuts: () => (/* reexport */ BlockEditorKeyboardShortcuts), 1336 BlockFormatControls: () => (/* reexport */ BlockFormatControls), 1337 BlockIcon: () => (/* reexport */ BlockIcon), 1338 BlockInspector: () => (/* reexport */ BlockInspector), 1339 BlockList: () => (/* reexport */ BlockList), 1340 BlockMover: () => (/* reexport */ BlockMover), 1341 BlockNavigationDropdown: () => (/* reexport */ BlockNavigationDropdown), 1342 BlockSelectionClearer: () => (/* reexport */ BlockSelectionClearer), 1343 BlockSettingsMenu: () => (/* reexport */ BlockSettingsMenu), 1344 BlockTitle: () => (/* reexport */ BlockTitle), 1345 BlockToolbar: () => (/* reexport */ BlockToolbar), 1346 CharacterCount: () => (/* reexport */ CharacterCount), 1347 ColorPalette: () => (/* reexport */ ColorPalette), 1348 ContrastChecker: () => (/* reexport */ ContrastChecker), 1349 CopyHandler: () => (/* reexport */ CopyHandler), 1350 DefaultBlockAppender: () => (/* reexport */ DefaultBlockAppender), 1351 DocumentBar: () => (/* reexport */ DocumentBar), 1352 DocumentOutline: () => (/* reexport */ document_outline), 1353 DocumentOutlineCheck: () => (/* reexport */ check), 1354 EditorHistoryRedo: () => (/* reexport */ editor_history_redo), 1355 EditorHistoryUndo: () => (/* reexport */ editor_history_undo), 1356 EditorKeyboardShortcuts: () => (/* reexport */ EditorKeyboardShortcuts), 1357 EditorKeyboardShortcutsRegister: () => (/* reexport */ register_shortcuts), 1358 EditorNotices: () => (/* reexport */ editor_notices), 1359 EditorProvider: () => (/* reexport */ provider), 1360 EditorSnackbars: () => (/* reexport */ EditorSnackbars), 1361 EntitiesSavedStates: () => (/* reexport */ EntitiesSavedStates), 1362 ErrorBoundary: () => (/* reexport */ error_boundary), 1363 FontSizePicker: () => (/* reexport */ FontSizePicker), 1364 InnerBlocks: () => (/* reexport */ InnerBlocks), 1365 Inserter: () => (/* reexport */ Inserter), 1366 InspectorAdvancedControls: () => (/* reexport */ InspectorAdvancedControls), 1367 InspectorControls: () => (/* reexport */ InspectorControls), 1368 LocalAutosaveMonitor: () => (/* reexport */ local_autosave_monitor), 1369 MediaPlaceholder: () => (/* reexport */ MediaPlaceholder), 1370 MediaUpload: () => (/* reexport */ MediaUpload), 1371 MediaUploadCheck: () => (/* reexport */ MediaUploadCheck), 1372 MultiSelectScrollIntoView: () => (/* reexport */ MultiSelectScrollIntoView), 1373 NavigableToolbar: () => (/* reexport */ NavigableToolbar), 1374 ObserveTyping: () => (/* reexport */ ObserveTyping), 1375 PageAttributesCheck: () => (/* reexport */ page_attributes_check), 1376 PageAttributesOrder: () => (/* reexport */ PageAttributesOrderWithChecks), 1377 PageAttributesPanel: () => (/* reexport */ panel), 1378 PageAttributesParent: () => (/* reexport */ page_attributes_parent), 1379 PageTemplate: () => (/* reexport */ classic_theme), 1380 PanelColorSettings: () => (/* reexport */ PanelColorSettings), 1381 PlainText: () => (/* reexport */ PlainText), 1382 PostAuthor: () => (/* reexport */ post_author), 1383 PostAuthorCheck: () => (/* reexport */ PostAuthorCheck), 1384 PostAuthorPanel: () => (/* reexport */ post_author_panel), 1385 PostComments: () => (/* reexport */ post_comments), 1386 PostDiscussionPanel: () => (/* reexport */ post_discussion_panel), 1387 PostExcerpt: () => (/* reexport */ post_excerpt), 1388 PostExcerptCheck: () => (/* reexport */ post_excerpt_check), 1389 PostExcerptPanel: () => (/* reexport */ PostExcerptPanel), 1390 PostFeaturedImage: () => (/* reexport */ post_featured_image), 1391 PostFeaturedImageCheck: () => (/* reexport */ post_featured_image_check), 1392 PostFeaturedImagePanel: () => (/* reexport */ post_featured_image_panel), 1393 PostFormat: () => (/* reexport */ PostFormat), 1394 PostFormatCheck: () => (/* reexport */ post_format_check), 1395 PostLastRevision: () => (/* reexport */ post_last_revision), 1396 PostLastRevisionCheck: () => (/* reexport */ post_last_revision_check), 1397 PostLastRevisionPanel: () => (/* reexport */ post_last_revision_panel), 1398 PostLockedModal: () => (/* reexport */ PostLockedModal), 1399 PostPendingStatus: () => (/* reexport */ post_pending_status), 1400 PostPendingStatusCheck: () => (/* reexport */ post_pending_status_check), 1401 PostPingbacks: () => (/* reexport */ post_pingbacks), 1402 PostPreviewButton: () => (/* reexport */ PostPreviewButton), 1403 PostPublishButton: () => (/* reexport */ post_publish_button), 1404 PostPublishButtonLabel: () => (/* reexport */ label), 1405 PostPublishPanel: () => (/* reexport */ post_publish_panel), 1406 PostSavedState: () => (/* reexport */ PostSavedState), 1407 PostSchedule: () => (/* reexport */ PostSchedule), 1408 PostScheduleCheck: () => (/* reexport */ PostScheduleCheck), 1409 PostScheduleLabel: () => (/* reexport */ PostScheduleLabel), 1410 PostSchedulePanel: () => (/* reexport */ PostSchedulePanel), 1411 PostSlug: () => (/* reexport */ post_slug), 1412 PostSlugCheck: () => (/* reexport */ PostSlugCheck), 1413 PostSticky: () => (/* reexport */ PostSticky), 1414 PostStickyCheck: () => (/* reexport */ PostStickyCheck), 1415 PostSwitchToDraftButton: () => (/* reexport */ PostSwitchToDraftButton), 1416 PostSyncStatus: () => (/* reexport */ PostSyncStatus), 1417 PostTaxonomies: () => (/* reexport */ post_taxonomies), 1418 PostTaxonomiesCheck: () => (/* reexport */ PostTaxonomiesCheck), 1419 PostTaxonomiesFlatTermSelector: () => (/* reexport */ FlatTermSelector), 1420 PostTaxonomiesHierarchicalTermSelector: () => (/* reexport */ HierarchicalTermSelector), 1421 PostTaxonomiesPanel: () => (/* reexport */ post_taxonomies_panel), 1422 PostTemplatePanel: () => (/* reexport */ PostTemplatePanel), 1423 PostTextEditor: () => (/* reexport */ PostTextEditor), 1424 PostTitle: () => (/* reexport */ post_title), 1425 PostTitleRaw: () => (/* reexport */ post_title_raw), 1426 PostTrash: () => (/* reexport */ PostTrash), 1427 PostTrashCheck: () => (/* reexport */ post_trash_check), 1428 PostTypeSupportCheck: () => (/* reexport */ post_type_support_check), 1429 PostURL: () => (/* reexport */ PostURL), 1430 PostURLCheck: () => (/* reexport */ PostURLCheck), 1431 PostURLLabel: () => (/* reexport */ PostURLLabel), 1432 PostURLPanel: () => (/* reexport */ PostURLPanel), 1433 PostVisibility: () => (/* reexport */ PostVisibility), 1434 PostVisibilityCheck: () => (/* reexport */ PostVisibilityCheck), 1435 PostVisibilityLabel: () => (/* reexport */ PostVisibilityLabel), 1436 RichText: () => (/* reexport */ RichText), 1437 RichTextShortcut: () => (/* reexport */ RichTextShortcut), 1438 RichTextToolbarButton: () => (/* reexport */ RichTextToolbarButton), 1439 ServerSideRender: () => (/* reexport */ (external_wp_serverSideRender_default())), 1440 SkipToSelectedBlock: () => (/* reexport */ SkipToSelectedBlock), 1441 TableOfContents: () => (/* reexport */ table_of_contents), 1442 TextEditorGlobalKeyboardShortcuts: () => (/* reexport */ TextEditorGlobalKeyboardShortcuts), 1443 ThemeSupportCheck: () => (/* reexport */ theme_support_check), 1444 TimeToRead: () => (/* reexport */ TimeToRead), 1445 URLInput: () => (/* reexport */ URLInput), 1446 URLInputButton: () => (/* reexport */ URLInputButton), 1447 URLPopover: () => (/* reexport */ URLPopover), 1448 UnsavedChangesWarning: () => (/* reexport */ UnsavedChangesWarning), 1449 VisualEditorGlobalKeyboardShortcuts: () => (/* reexport */ VisualEditorGlobalKeyboardShortcuts), 1450 Warning: () => (/* reexport */ Warning), 1451 WordCount: () => (/* reexport */ WordCount), 1452 WritingFlow: () => (/* reexport */ WritingFlow), 1453 __unstableRichTextInputEvent: () => (/* reexport */ __unstableRichTextInputEvent), 1454 cleanForSlug: () => (/* reexport */ cleanForSlug), 1455 createCustomColorsHOC: () => (/* reexport */ createCustomColorsHOC), 1456 getColorClassName: () => (/* reexport */ getColorClassName), 1457 getColorObjectByAttributeValues: () => (/* reexport */ getColorObjectByAttributeValues), 1458 getColorObjectByColorValue: () => (/* reexport */ getColorObjectByColorValue), 1459 getFontSize: () => (/* reexport */ getFontSize), 1460 getFontSizeClass: () => (/* reexport */ getFontSizeClass), 1461 getTemplatePartIcon: () => (/* reexport */ getTemplatePartIcon), 1462 mediaUpload: () => (/* reexport */ mediaUpload), 1463 privateApis: () => (/* reexport */ privateApis), 1464 store: () => (/* reexport */ store_store), 1465 storeConfig: () => (/* reexport */ storeConfig), 1466 transformStyles: () => (/* reexport */ external_wp_blockEditor_namespaceObject.transformStyles), 1467 useEntitiesSavedStatesIsDirty: () => (/* reexport */ useIsDirty), 1468 usePostScheduleLabel: () => (/* reexport */ usePostScheduleLabel), 1469 usePostURLLabel: () => (/* reexport */ usePostURLLabel), 1470 usePostVisibilityLabel: () => (/* reexport */ usePostVisibilityLabel), 1471 userAutocompleter: () => (/* reexport */ user), 1472 withColorContext: () => (/* reexport */ withColorContext), 1473 withColors: () => (/* reexport */ withColors), 1474 withFontSizes: () => (/* reexport */ withFontSizes) 1475 }); 1476 1477 // NAMESPACE OBJECT: ./node_modules/@wordpress/editor/build-module/store/selectors.js 1478 var selectors_namespaceObject = {}; 1479 __webpack_require__.r(selectors_namespaceObject); 1480 __webpack_require__.d(selectors_namespaceObject, { 1481 __experimentalGetDefaultTemplatePartAreas: () => (__experimentalGetDefaultTemplatePartAreas), 1482 __experimentalGetDefaultTemplateType: () => (__experimentalGetDefaultTemplateType), 1483 __experimentalGetDefaultTemplateTypes: () => (__experimentalGetDefaultTemplateTypes), 1484 __experimentalGetTemplateInfo: () => (__experimentalGetTemplateInfo), 1485 __unstableIsEditorReady: () => (__unstableIsEditorReady), 1486 canInsertBlockType: () => (canInsertBlockType), 1487 canUserUseUnfilteredHTML: () => (canUserUseUnfilteredHTML), 1488 didPostSaveRequestFail: () => (didPostSaveRequestFail), 1489 didPostSaveRequestSucceed: () => (didPostSaveRequestSucceed), 1490 getActivePostLock: () => (getActivePostLock), 1491 getAdjacentBlockClientId: () => (getAdjacentBlockClientId), 1492 getAutosaveAttribute: () => (getAutosaveAttribute), 1493 getBlock: () => (getBlock), 1494 getBlockAttributes: () => (getBlockAttributes), 1495 getBlockCount: () => (getBlockCount), 1496 getBlockHierarchyRootClientId: () => (getBlockHierarchyRootClientId), 1497 getBlockIndex: () => (getBlockIndex), 1498 getBlockInsertionPoint: () => (getBlockInsertionPoint), 1499 getBlockListSettings: () => (getBlockListSettings), 1500 getBlockMode: () => (getBlockMode), 1501 getBlockName: () => (getBlockName), 1502 getBlockOrder: () => (getBlockOrder), 1503 getBlockRootClientId: () => (getBlockRootClientId), 1504 getBlockSelectionEnd: () => (getBlockSelectionEnd), 1505 getBlockSelectionStart: () => (getBlockSelectionStart), 1506 getBlocks: () => (getBlocks), 1507 getBlocksByClientId: () => (getBlocksByClientId), 1508 getClientIdsOfDescendants: () => (getClientIdsOfDescendants), 1509 getClientIdsWithDescendants: () => (getClientIdsWithDescendants), 1510 getCurrentPost: () => (getCurrentPost), 1511 getCurrentPostAttribute: () => (getCurrentPostAttribute), 1512 getCurrentPostId: () => (getCurrentPostId), 1513 getCurrentPostLastRevisionId: () => (getCurrentPostLastRevisionId), 1514 getCurrentPostRevisionsCount: () => (getCurrentPostRevisionsCount), 1515 getCurrentPostType: () => (getCurrentPostType), 1516 getCurrentTemplateId: () => (getCurrentTemplateId), 1517 getDeviceType: () => (getDeviceType), 1518 getEditedPostAttribute: () => (getEditedPostAttribute), 1519 getEditedPostContent: () => (getEditedPostContent), 1520 getEditedPostPreviewLink: () => (getEditedPostPreviewLink), 1521 getEditedPostSlug: () => (getEditedPostSlug), 1522 getEditedPostVisibility: () => (getEditedPostVisibility), 1523 getEditorBlocks: () => (getEditorBlocks), 1524 getEditorSelection: () => (getEditorSelection), 1525 getEditorSelectionEnd: () => (getEditorSelectionEnd), 1526 getEditorSelectionStart: () => (getEditorSelectionStart), 1527 getEditorSettings: () => (getEditorSettings), 1528 getFirstMultiSelectedBlockClientId: () => (getFirstMultiSelectedBlockClientId), 1529 getGlobalBlockCount: () => (getGlobalBlockCount), 1530 getInserterItems: () => (getInserterItems), 1531 getLastMultiSelectedBlockClientId: () => (getLastMultiSelectedBlockClientId), 1532 getMultiSelectedBlockClientIds: () => (getMultiSelectedBlockClientIds), 1533 getMultiSelectedBlocks: () => (getMultiSelectedBlocks), 1534 getMultiSelectedBlocksEndClientId: () => (getMultiSelectedBlocksEndClientId), 1535 getMultiSelectedBlocksStartClientId: () => (getMultiSelectedBlocksStartClientId), 1536 getNextBlockClientId: () => (getNextBlockClientId), 1537 getPermalink: () => (getPermalink), 1538 getPermalinkParts: () => (getPermalinkParts), 1539 getPostEdits: () => (getPostEdits), 1540 getPostLockUser: () => (getPostLockUser), 1541 getPostTypeLabel: () => (getPostTypeLabel), 1542 getPreviousBlockClientId: () => (getPreviousBlockClientId), 1543 getRenderingMode: () => (getRenderingMode), 1544 getSelectedBlock: () => (getSelectedBlock), 1545 getSelectedBlockClientId: () => (getSelectedBlockClientId), 1546 getSelectedBlockCount: () => (getSelectedBlockCount), 1547 getSelectedBlocksInitialCaretPosition: () => (getSelectedBlocksInitialCaretPosition), 1548 getStateBeforeOptimisticTransaction: () => (getStateBeforeOptimisticTransaction), 1549 getSuggestedPostFormat: () => (getSuggestedPostFormat), 1550 getTemplate: () => (getTemplate), 1551 getTemplateLock: () => (getTemplateLock), 1552 hasChangedContent: () => (hasChangedContent), 1553 hasEditorRedo: () => (hasEditorRedo), 1554 hasEditorUndo: () => (hasEditorUndo), 1555 hasInserterItems: () => (hasInserterItems), 1556 hasMultiSelection: () => (hasMultiSelection), 1557 hasNonPostEntityChanges: () => (hasNonPostEntityChanges), 1558 hasSelectedBlock: () => (hasSelectedBlock), 1559 hasSelectedInnerBlock: () => (hasSelectedInnerBlock), 1560 inSomeHistory: () => (inSomeHistory), 1561 isAncestorMultiSelected: () => (isAncestorMultiSelected), 1562 isAutosavingPost: () => (isAutosavingPost), 1563 isBlockInsertionPointVisible: () => (isBlockInsertionPointVisible), 1564 isBlockMultiSelected: () => (isBlockMultiSelected), 1565 isBlockSelected: () => (isBlockSelected), 1566 isBlockValid: () => (isBlockValid), 1567 isBlockWithinSelection: () => (isBlockWithinSelection), 1568 isCaretWithinFormattedText: () => (isCaretWithinFormattedText), 1569 isCleanNewPost: () => (isCleanNewPost), 1570 isCurrentPostPending: () => (isCurrentPostPending), 1571 isCurrentPostPublished: () => (isCurrentPostPublished), 1572 isCurrentPostScheduled: () => (isCurrentPostScheduled), 1573 isDeletingPost: () => (isDeletingPost), 1574 isEditedPostAutosaveable: () => (isEditedPostAutosaveable), 1575 isEditedPostBeingScheduled: () => (isEditedPostBeingScheduled), 1576 isEditedPostDateFloating: () => (isEditedPostDateFloating), 1577 isEditedPostDirty: () => (isEditedPostDirty), 1578 isEditedPostEmpty: () => (isEditedPostEmpty), 1579 isEditedPostNew: () => (isEditedPostNew), 1580 isEditedPostPublishable: () => (isEditedPostPublishable), 1581 isEditedPostSaveable: () => (isEditedPostSaveable), 1582 isEditorPanelEnabled: () => (isEditorPanelEnabled), 1583 isEditorPanelOpened: () => (isEditorPanelOpened), 1584 isEditorPanelRemoved: () => (isEditorPanelRemoved), 1585 isFirstMultiSelectedBlock: () => (isFirstMultiSelectedBlock), 1586 isInserterOpened: () => (isInserterOpened), 1587 isListViewOpened: () => (isListViewOpened), 1588 isMultiSelecting: () => (isMultiSelecting), 1589 isPermalinkEditable: () => (isPermalinkEditable), 1590 isPostAutosavingLocked: () => (isPostAutosavingLocked), 1591 isPostLockTakeover: () => (isPostLockTakeover), 1592 isPostLocked: () => (isPostLocked), 1593 isPostSavingLocked: () => (isPostSavingLocked), 1594 isPreviewingPost: () => (isPreviewingPost), 1595 isPublishSidebarEnabled: () => (isPublishSidebarEnabled), 1596 isPublishingPost: () => (isPublishingPost), 1597 isSavingNonPostEntityChanges: () => (isSavingNonPostEntityChanges), 1598 isSavingPost: () => (isSavingPost), 1599 isSelectionEnabled: () => (isSelectionEnabled), 1600 isTyping: () => (isTyping), 1601 isValidTemplate: () => (isValidTemplate) 1602 }); 1603 1604 // NAMESPACE OBJECT: ./node_modules/@wordpress/editor/build-module/store/actions.js 1605 var actions_namespaceObject = {}; 1606 __webpack_require__.r(actions_namespaceObject); 1607 __webpack_require__.d(actions_namespaceObject, { 1608 __experimentalTearDownEditor: () => (__experimentalTearDownEditor), 1609 __unstableSaveForPreview: () => (__unstableSaveForPreview), 1610 autosave: () => (autosave), 1611 clearSelectedBlock: () => (clearSelectedBlock), 1612 createUndoLevel: () => (createUndoLevel), 1613 disablePublishSidebar: () => (disablePublishSidebar), 1614 editPost: () => (editPost), 1615 enablePublishSidebar: () => (enablePublishSidebar), 1616 enterFormattedText: () => (enterFormattedText), 1617 exitFormattedText: () => (exitFormattedText), 1618 hideInsertionPoint: () => (hideInsertionPoint), 1619 insertBlock: () => (insertBlock), 1620 insertBlocks: () => (insertBlocks), 1621 insertDefaultBlock: () => (insertDefaultBlock), 1622 lockPostAutosaving: () => (lockPostAutosaving), 1623 lockPostSaving: () => (lockPostSaving), 1624 mergeBlocks: () => (mergeBlocks), 1625 moveBlockToPosition: () => (moveBlockToPosition), 1626 moveBlocksDown: () => (moveBlocksDown), 1627 moveBlocksUp: () => (moveBlocksUp), 1628 multiSelect: () => (multiSelect), 1629 receiveBlocks: () => (receiveBlocks), 1630 redo: () => (redo), 1631 refreshPost: () => (refreshPost), 1632 removeBlock: () => (removeBlock), 1633 removeBlocks: () => (removeBlocks), 1634 removeEditorPanel: () => (removeEditorPanel), 1635 replaceBlock: () => (replaceBlock), 1636 replaceBlocks: () => (replaceBlocks), 1637 resetBlocks: () => (resetBlocks), 1638 resetEditorBlocks: () => (resetEditorBlocks), 1639 resetPost: () => (resetPost), 1640 savePost: () => (savePost), 1641 selectBlock: () => (selectBlock), 1642 setDeviceType: () => (setDeviceType), 1643 setEditedPost: () => (setEditedPost), 1644 setIsInserterOpened: () => (setIsInserterOpened), 1645 setIsListViewOpened: () => (setIsListViewOpened), 1646 setRenderingMode: () => (setRenderingMode), 1647 setTemplateValidity: () => (setTemplateValidity), 1648 setupEditor: () => (setupEditor), 1649 setupEditorState: () => (setupEditorState), 1650 showInsertionPoint: () => (showInsertionPoint), 1651 startMultiSelect: () => (startMultiSelect), 1652 startTyping: () => (startTyping), 1653 stopMultiSelect: () => (stopMultiSelect), 1654 stopTyping: () => (stopTyping), 1655 synchronizeTemplate: () => (synchronizeTemplate), 1656 toggleBlockMode: () => (toggleBlockMode), 1657 toggleEditorPanelEnabled: () => (toggleEditorPanelEnabled), 1658 toggleEditorPanelOpened: () => (toggleEditorPanelOpened), 1659 toggleSelection: () => (toggleSelection), 1660 trashPost: () => (trashPost), 1661 undo: () => (undo), 1662 unlockPostAutosaving: () => (unlockPostAutosaving), 1663 unlockPostSaving: () => (unlockPostSaving), 1664 updateBlock: () => (updateBlock), 1665 updateBlockAttributes: () => (updateBlockAttributes), 1666 updateBlockListSettings: () => (updateBlockListSettings), 1667 updateEditorSettings: () => (updateEditorSettings), 1668 updatePost: () => (updatePost), 1669 updatePostLock: () => (updatePostLock) 1670 }); 1671 1672 // NAMESPACE OBJECT: ./node_modules/@wordpress/editor/build-module/store/private-actions.js 1673 var private_actions_namespaceObject = {}; 1674 __webpack_require__.r(private_actions_namespaceObject); 1675 __webpack_require__.d(private_actions_namespaceObject, { 1676 createTemplate: () => (createTemplate), 1677 hideBlockTypes: () => (hideBlockTypes), 1678 setCurrentTemplateId: () => (setCurrentTemplateId), 1679 showBlockTypes: () => (showBlockTypes) 1680 }); 1681 1682 // NAMESPACE OBJECT: ./node_modules/@wordpress/editor/build-module/store/private-selectors.js 1683 var private_selectors_namespaceObject = {}; 1684 __webpack_require__.r(private_selectors_namespaceObject); 1685 __webpack_require__.d(private_selectors_namespaceObject, { 1686 getInsertionPoint: () => (getInsertionPoint), 1687 getListViewToggleRef: () => (getListViewToggleRef) 1688 }); 1689 1690 ;// CONCATENATED MODULE: external ["wp","blocks"] 1691 const external_wp_blocks_namespaceObject = window["wp"]["blocks"]; 1692 ;// CONCATENATED MODULE: external ["wp","data"] 1693 const external_wp_data_namespaceObject = window["wp"]["data"]; 1694 ;// CONCATENATED MODULE: external ["wp","privateApis"] 1695 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; 1696 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/lock-unlock.js 1697 /** 1698 * WordPress dependencies 1699 */ 1700 1701 const { 1702 lock, 1703 unlock 1704 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/editor'); 1705 1706 ;// CONCATENATED MODULE: external ["wp","i18n"] 1707 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; 1708 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/bindings/pattern-overrides.js 1709 /** 1710 * WordPress dependencies 1711 */ 1712 1713 /* harmony default export */ const pattern_overrides = ({ 1714 name: 'core/pattern-overrides', 1715 label: (0,external_wp_i18n_namespaceObject._x)('Pattern Overrides', 'block bindings source'), 1716 useSource: null, 1717 lockAttributesEditing: false 1718 }); 1719 1720 ;// CONCATENATED MODULE: external ["wp","coreData"] 1721 const external_wp_coreData_namespaceObject = window["wp"]["coreData"]; 1722 ;// CONCATENATED MODULE: external ["wp","blockEditor"] 1723 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; 1724 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/defaults.js 1725 /** 1726 * WordPress dependencies 1727 */ 1728 1729 1730 /** 1731 * The default post editor settings. 1732 * 1733 * @property {boolean|Array} allowedBlockTypes Allowed block types 1734 * @property {boolean} richEditingEnabled Whether rich editing is enabled or not 1735 * @property {boolean} codeEditingEnabled Whether code editing is enabled or not 1736 * @property {boolean} fontLibraryEnabled Whether the font library is enabled or not. 1737 * @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not. 1738 * true = the user has opted to show the Custom Fields panel at the bottom of the editor. 1739 * false = the user has opted to hide the Custom Fields panel at the bottom of the editor. 1740 * 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. 1741 * @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API. 1742 * @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage. 1743 * @property {Array?} availableTemplates The available post templates 1744 * @property {boolean} disablePostFormats Whether or not the post formats are disabled 1745 * @property {Array?} allowedMimeTypes List of allowed mime types and file extensions 1746 * @property {number} maxUploadFileSize Maximum upload file size 1747 * @property {boolean} supportsLayout Whether the editor supports layouts. 1748 */ 1749 const EDITOR_SETTINGS_DEFAULTS = { 1750 ...external_wp_blockEditor_namespaceObject.SETTINGS_DEFAULTS, 1751 richEditingEnabled: true, 1752 codeEditingEnabled: true, 1753 fontLibraryEnabled: true, 1754 enableCustomFields: undefined, 1755 defaultRenderingMode: 'post-only' 1756 }; 1757 1758 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/reducer.js 1759 /** 1760 * WordPress dependencies 1761 */ 1762 1763 1764 /** 1765 * Internal dependencies 1766 */ 1767 1768 1769 /** 1770 * Returns a post attribute value, flattening nested rendered content using its 1771 * raw value in place of its original object form. 1772 * 1773 * @param {*} value Original value. 1774 * 1775 * @return {*} Raw value. 1776 */ 1777 function getPostRawValue(value) { 1778 if (value && 'object' === typeof value && 'raw' in value) { 1779 return value.raw; 1780 } 1781 return value; 1782 } 1783 1784 /** 1785 * Returns true if the two object arguments have the same keys, or false 1786 * otherwise. 1787 * 1788 * @param {Object} a First object. 1789 * @param {Object} b Second object. 1790 * 1791 * @return {boolean} Whether the two objects have the same keys. 1792 */ 1793 function hasSameKeys(a, b) { 1794 const keysA = Object.keys(a).sort(); 1795 const keysB = Object.keys(b).sort(); 1796 return keysA.length === keysB.length && keysA.every((key, index) => keysB[index] === key); 1797 } 1798 1799 /** 1800 * Returns true if, given the currently dispatching action and the previously 1801 * dispatched action, the two actions are editing the same post property, or 1802 * false otherwise. 1803 * 1804 * @param {Object} action Currently dispatching action. 1805 * @param {Object} previousAction Previously dispatched action. 1806 * 1807 * @return {boolean} Whether actions are updating the same post property. 1808 */ 1809 function isUpdatingSamePostProperty(action, previousAction) { 1810 return action.type === 'EDIT_POST' && hasSameKeys(action.edits, previousAction.edits); 1811 } 1812 1813 /** 1814 * Returns true if, given the currently dispatching action and the previously 1815 * dispatched action, the two actions are modifying the same property such that 1816 * undo history should be batched. 1817 * 1818 * @param {Object} action Currently dispatching action. 1819 * @param {Object} previousAction Previously dispatched action. 1820 * 1821 * @return {boolean} Whether to overwrite present state. 1822 */ 1823 function shouldOverwriteState(action, previousAction) { 1824 if (action.type === 'RESET_EDITOR_BLOCKS') { 1825 return !action.shouldCreateUndoLevel; 1826 } 1827 if (!previousAction || action.type !== previousAction.type) { 1828 return false; 1829 } 1830 return isUpdatingSamePostProperty(action, previousAction); 1831 } 1832 function postId(state = null, action) { 1833 switch (action.type) { 1834 case 'SET_EDITED_POST': 1835 return action.postId; 1836 } 1837 return state; 1838 } 1839 function templateId(state = null, action) { 1840 switch (action.type) { 1841 case 'SET_CURRENT_TEMPLATE_ID': 1842 return action.id; 1843 } 1844 return state; 1845 } 1846 function postType(state = null, action) { 1847 switch (action.type) { 1848 case 'SET_EDITED_POST': 1849 return action.postType; 1850 } 1851 return state; 1852 } 1853 1854 /** 1855 * Reducer returning whether the post blocks match the defined template or not. 1856 * 1857 * @param {Object} state Current state. 1858 * @param {Object} action Dispatched action. 1859 * 1860 * @return {boolean} Updated state. 1861 */ 1862 function template(state = { 1863 isValid: true 1864 }, action) { 1865 switch (action.type) { 1866 case 'SET_TEMPLATE_VALIDITY': 1867 return { 1868 ...state, 1869 isValid: action.isValid 1870 }; 1871 } 1872 return state; 1873 } 1874 1875 /** 1876 * Reducer returning current network request state (whether a request to 1877 * the WP REST API is in progress, successful, or failed). 1878 * 1879 * @param {Object} state Current state. 1880 * @param {Object} action Dispatched action. 1881 * 1882 * @return {Object} Updated state. 1883 */ 1884 function saving(state = {}, action) { 1885 switch (action.type) { 1886 case 'REQUEST_POST_UPDATE_START': 1887 case 'REQUEST_POST_UPDATE_FINISH': 1888 return { 1889 pending: action.type === 'REQUEST_POST_UPDATE_START', 1890 options: action.options || {} 1891 }; 1892 } 1893 return state; 1894 } 1895 1896 /** 1897 * Reducer returning deleting post request state. 1898 * 1899 * @param {Object} state Current state. 1900 * @param {Object} action Dispatched action. 1901 * 1902 * @return {Object} Updated state. 1903 */ 1904 function deleting(state = {}, action) { 1905 switch (action.type) { 1906 case 'REQUEST_POST_DELETE_START': 1907 case 'REQUEST_POST_DELETE_FINISH': 1908 return { 1909 pending: action.type === 'REQUEST_POST_DELETE_START' 1910 }; 1911 } 1912 return state; 1913 } 1914 1915 /** 1916 * Post Lock State. 1917 * 1918 * @typedef {Object} PostLockState 1919 * 1920 * @property {boolean} isLocked Whether the post is locked. 1921 * @property {?boolean} isTakeover Whether the post editing has been taken over. 1922 * @property {?boolean} activePostLock Active post lock value. 1923 * @property {?Object} user User that took over the post. 1924 */ 1925 1926 /** 1927 * Reducer returning the post lock status. 1928 * 1929 * @param {PostLockState} state Current state. 1930 * @param {Object} action Dispatched action. 1931 * 1932 * @return {PostLockState} Updated state. 1933 */ 1934 function postLock(state = { 1935 isLocked: false 1936 }, action) { 1937 switch (action.type) { 1938 case 'UPDATE_POST_LOCK': 1939 return action.lock; 1940 } 1941 return state; 1942 } 1943 1944 /** 1945 * Post saving lock. 1946 * 1947 * When post saving is locked, the post cannot be published or updated. 1948 * 1949 * @param {PostLockState} state Current state. 1950 * @param {Object} action Dispatched action. 1951 * 1952 * @return {PostLockState} Updated state. 1953 */ 1954 function postSavingLock(state = {}, action) { 1955 switch (action.type) { 1956 case 'LOCK_POST_SAVING': 1957 return { 1958 ...state, 1959 [action.lockName]: true 1960 }; 1961 case 'UNLOCK_POST_SAVING': 1962 { 1963 const { 1964 [action.lockName]: removedLockName, 1965 ...restState 1966 } = state; 1967 return restState; 1968 } 1969 } 1970 return state; 1971 } 1972 1973 /** 1974 * Post autosaving lock. 1975 * 1976 * When post autosaving is locked, the post will not autosave. 1977 * 1978 * @param {PostLockState} state Current state. 1979 * @param {Object} action Dispatched action. 1980 * 1981 * @return {PostLockState} Updated state. 1982 */ 1983 function postAutosavingLock(state = {}, action) { 1984 switch (action.type) { 1985 case 'LOCK_POST_AUTOSAVING': 1986 return { 1987 ...state, 1988 [action.lockName]: true 1989 }; 1990 case 'UNLOCK_POST_AUTOSAVING': 1991 { 1992 const { 1993 [action.lockName]: removedLockName, 1994 ...restState 1995 } = state; 1996 return restState; 1997 } 1998 } 1999 return state; 2000 } 2001 2002 /** 2003 * Reducer returning the post editor setting. 2004 * 2005 * @param {Object} state Current state. 2006 * @param {Object} action Dispatched action. 2007 * 2008 * @return {Object} Updated state. 2009 */ 2010 function editorSettings(state = EDITOR_SETTINGS_DEFAULTS, action) { 2011 switch (action.type) { 2012 case 'UPDATE_EDITOR_SETTINGS': 2013 return { 2014 ...state, 2015 ...action.settings 2016 }; 2017 } 2018 return state; 2019 } 2020 function renderingMode(state = 'post-only', action) { 2021 switch (action.type) { 2022 case 'SET_RENDERING_MODE': 2023 return action.mode; 2024 } 2025 return state; 2026 } 2027 2028 /** 2029 * Reducer returning the editing canvas device type. 2030 * 2031 * @param {Object} state Current state. 2032 * @param {Object} action Dispatched action. 2033 * 2034 * @return {Object} Updated state. 2035 */ 2036 function deviceType(state = 'Desktop', action) { 2037 switch (action.type) { 2038 case 'SET_DEVICE_TYPE': 2039 return action.deviceType; 2040 } 2041 return state; 2042 } 2043 2044 /** 2045 * Reducer storing the list of all programmatically removed panels. 2046 * 2047 * @param {Array} state Current state. 2048 * @param {Object} action Action object. 2049 * 2050 * @return {Array} Updated state. 2051 */ 2052 function removedPanels(state = [], action) { 2053 switch (action.type) { 2054 case 'REMOVE_PANEL': 2055 if (!state.includes(action.panelName)) { 2056 return [...state, action.panelName]; 2057 } 2058 } 2059 return state; 2060 } 2061 2062 /** 2063 * Reducer to set the block inserter panel open or closed. 2064 * 2065 * Note: this reducer interacts with the list view panel reducer 2066 * to make sure that only one of the two panels is open at the same time. 2067 * 2068 * @param {Object} state Current state. 2069 * @param {Object} action Dispatched action. 2070 */ 2071 function blockInserterPanel(state = false, action) { 2072 switch (action.type) { 2073 case 'SET_IS_LIST_VIEW_OPENED': 2074 return action.isOpen ? false : state; 2075 case 'SET_IS_INSERTER_OPENED': 2076 return action.value; 2077 } 2078 return state; 2079 } 2080 2081 /** 2082 * Reducer to set the list view panel open or closed. 2083 * 2084 * Note: this reducer interacts with the inserter panel reducer 2085 * to make sure that only one of the two panels is open at the same time. 2086 * 2087 * @param {Object} state Current state. 2088 * @param {Object} action Dispatched action. 2089 */ 2090 function listViewPanel(state = false, action) { 2091 switch (action.type) { 2092 case 'SET_IS_INSERTER_OPENED': 2093 return action.value ? false : state; 2094 case 'SET_IS_LIST_VIEW_OPENED': 2095 return action.isOpen; 2096 } 2097 return state; 2098 } 2099 2100 /** 2101 * This reducer does nothing aside initializing a ref to the list view toggle. 2102 * We will have a unique ref per "editor" instance. 2103 * 2104 * @param {Object} state 2105 * @return {Object} Reference to the list view toggle button. 2106 */ 2107 function listViewToggleRef(state = { 2108 current: null 2109 }) { 2110 return state; 2111 } 2112 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ 2113 postId, 2114 postType, 2115 templateId, 2116 saving, 2117 deleting, 2118 postLock, 2119 template, 2120 postSavingLock, 2121 editorSettings, 2122 postAutosavingLock, 2123 renderingMode, 2124 deviceType, 2125 removedPanels, 2126 blockInserterPanel, 2127 listViewPanel, 2128 listViewToggleRef 2129 })); 2130 2131 ;// CONCATENATED MODULE: ./node_modules/rememo/rememo.js 2132 2133 2134 /** @typedef {(...args: any[]) => *[]} GetDependants */ 2135 2136 /** @typedef {() => void} Clear */ 2137 2138 /** 2139 * @typedef {{ 2140 * getDependants: GetDependants, 2141 * clear: Clear 2142 * }} EnhancedSelector 2143 */ 2144 2145 /** 2146 * Internal cache entry. 2147 * 2148 * @typedef CacheNode 2149 * 2150 * @property {?CacheNode|undefined} [prev] Previous node. 2151 * @property {?CacheNode|undefined} [next] Next node. 2152 * @property {*[]} args Function arguments for cache entry. 2153 * @property {*} val Function result. 2154 */ 2155 2156 /** 2157 * @typedef Cache 2158 * 2159 * @property {Clear} clear Function to clear cache. 2160 * @property {boolean} [isUniqueByDependants] Whether dependants are valid in 2161 * considering cache uniqueness. A cache is unique if dependents are all arrays 2162 * or objects. 2163 * @property {CacheNode?} [head] Cache head. 2164 * @property {*[]} [lastDependants] Dependants from previous invocation. 2165 */ 2166 2167 /** 2168 * Arbitrary value used as key for referencing cache object in WeakMap tree. 2169 * 2170 * @type {{}} 2171 */ 2172 var LEAF_KEY = {}; 2173 2174 /** 2175 * Returns the first argument as the sole entry in an array. 2176 * 2177 * @template T 2178 * 2179 * @param {T} value Value to return. 2180 * 2181 * @return {[T]} Value returned as entry in array. 2182 */ 2183 function arrayOf(value) { 2184 return [value]; 2185 } 2186 2187 /** 2188 * Returns true if the value passed is object-like, or false otherwise. A value 2189 * is object-like if it can support property assignment, e.g. object or array. 2190 * 2191 * @param {*} value Value to test. 2192 * 2193 * @return {boolean} Whether value is object-like. 2194 */ 2195 function isObjectLike(value) { 2196 return !!value && 'object' === typeof value; 2197 } 2198 2199 /** 2200 * Creates and returns a new cache object. 2201 * 2202 * @return {Cache} Cache object. 2203 */ 2204 function createCache() { 2205 /** @type {Cache} */ 2206 var cache = { 2207 clear: function () { 2208 cache.head = null; 2209 }, 2210 }; 2211 2212 return cache; 2213 } 2214 2215 /** 2216 * Returns true if entries within the two arrays are strictly equal by 2217 * reference from a starting index. 2218 * 2219 * @param {*[]} a First array. 2220 * @param {*[]} b Second array. 2221 * @param {number} fromIndex Index from which to start comparison. 2222 * 2223 * @return {boolean} Whether arrays are shallowly equal. 2224 */ 2225 function isShallowEqual(a, b, fromIndex) { 2226 var i; 2227 2228 if (a.length !== b.length) { 2229 return false; 2230 } 2231 2232 for (i = fromIndex; i < a.length; i++) { 2233 if (a[i] !== b[i]) { 2234 return false; 2235 } 2236 } 2237 2238 return true; 2239 } 2240 2241 /** 2242 * Returns a memoized selector function. The getDependants function argument is 2243 * called before the memoized selector and is expected to return an immutable 2244 * reference or array of references on which the selector depends for computing 2245 * its own return value. The memoize cache is preserved only as long as those 2246 * dependant references remain the same. If getDependants returns a different 2247 * reference(s), the cache is cleared and the selector value regenerated. 2248 * 2249 * @template {(...args: *[]) => *} S 2250 * 2251 * @param {S} selector Selector function. 2252 * @param {GetDependants=} getDependants Dependant getter returning an array of 2253 * references used in cache bust consideration. 2254 */ 2255 /* harmony default export */ function rememo(selector, getDependants) { 2256 /** @type {WeakMap<*,*>} */ 2257 var rootCache; 2258 2259 /** @type {GetDependants} */ 2260 var normalizedGetDependants = getDependants ? getDependants : arrayOf; 2261 2262 /** 2263 * Returns the cache for a given dependants array. When possible, a WeakMap 2264 * will be used to create a unique cache for each set of dependants. This 2265 * is feasible due to the nature of WeakMap in allowing garbage collection 2266 * to occur on entries where the key object is no longer referenced. Since 2267 * WeakMap requires the key to be an object, this is only possible when the 2268 * dependant is object-like. The root cache is created as a hierarchy where 2269 * each top-level key is the first entry in a dependants set, the value a 2270 * WeakMap where each key is the next dependant, and so on. This continues 2271 * so long as the dependants are object-like. If no dependants are object- 2272 * like, then the cache is shared across all invocations. 2273 * 2274 * @see isObjectLike 2275 * 2276 * @param {*[]} dependants Selector dependants. 2277 * 2278 * @return {Cache} Cache object. 2279 */ 2280 function getCache(dependants) { 2281 var caches = rootCache, 2282 isUniqueByDependants = true, 2283 i, 2284 dependant, 2285 map, 2286 cache; 2287 2288 for (i = 0; i < dependants.length; i++) { 2289 dependant = dependants[i]; 2290 2291 // Can only compose WeakMap from object-like key. 2292 if (!isObjectLike(dependant)) { 2293 isUniqueByDependants = false; 2294 break; 2295 } 2296 2297 // Does current segment of cache already have a WeakMap? 2298 if (caches.has(dependant)) { 2299 // Traverse into nested WeakMap. 2300 caches = caches.get(dependant); 2301 } else { 2302 // Create, set, and traverse into a new one. 2303 map = new WeakMap(); 2304 caches.set(dependant, map); 2305 caches = map; 2306 } 2307 } 2308 2309 // We use an arbitrary (but consistent) object as key for the last item 2310 // in the WeakMap to serve as our running cache. 2311 if (!caches.has(LEAF_KEY)) { 2312 cache = createCache(); 2313 cache.isUniqueByDependants = isUniqueByDependants; 2314 caches.set(LEAF_KEY, cache); 2315 } 2316 2317 return caches.get(LEAF_KEY); 2318 } 2319 2320 /** 2321 * Resets root memoization cache. 2322 */ 2323 function clear() { 2324 rootCache = new WeakMap(); 2325 } 2326 2327 /* eslint-disable jsdoc/check-param-names */ 2328 /** 2329 * The augmented selector call, considering first whether dependants have 2330 * changed before passing it to underlying memoize function. 2331 * 2332 * @param {*} source Source object for derivation. 2333 * @param {...*} extraArgs Additional arguments to pass to selector. 2334 * 2335 * @return {*} Selector result. 2336 */ 2337 /* eslint-enable jsdoc/check-param-names */ 2338 function callSelector(/* source, ...extraArgs */) { 2339 var len = arguments.length, 2340 cache, 2341 node, 2342 i, 2343 args, 2344 dependants; 2345 2346 // Create copy of arguments (avoid leaking deoptimization). 2347 args = new Array(len); 2348 for (i = 0; i < len; i++) { 2349 args[i] = arguments[i]; 2350 } 2351 2352 dependants = normalizedGetDependants.apply(null, args); 2353 cache = getCache(dependants); 2354 2355 // If not guaranteed uniqueness by dependants (primitive type), shallow 2356 // compare against last dependants and, if references have changed, 2357 // destroy cache to recalculate result. 2358 if (!cache.isUniqueByDependants) { 2359 if ( 2360 cache.lastDependants && 2361 !isShallowEqual(dependants, cache.lastDependants, 0) 2362 ) { 2363 cache.clear(); 2364 } 2365 2366 cache.lastDependants = dependants; 2367 } 2368 2369 node = cache.head; 2370 while (node) { 2371 // Check whether node arguments match arguments 2372 if (!isShallowEqual(node.args, args, 1)) { 2373 node = node.next; 2374 continue; 2375 } 2376 2377 // At this point we can assume we've found a match 2378 2379 // Surface matched node to head if not already 2380 if (node !== cache.head) { 2381 // Adjust siblings to point to each other. 2382 /** @type {CacheNode} */ (node.prev).next = node.next; 2383 if (node.next) { 2384 node.next.prev = node.prev; 2385 } 2386 2387 node.next = cache.head; 2388 node.prev = null; 2389 /** @type {CacheNode} */ (cache.head).prev = node; 2390 cache.head = node; 2391 } 2392 2393 // Return immediately 2394 return node.val; 2395 } 2396 2397 // No cached value found. Continue to insertion phase: 2398 2399 node = /** @type {CacheNode} */ ({ 2400 // Generate the result from original function 2401 val: selector.apply(null, args), 2402 }); 2403 2404 // Avoid including the source object in the cache. 2405 args[0] = null; 2406 node.args = args; 2407 2408 // Don't need to check whether node is already head, since it would 2409 // have been returned above already if it was 2410 2411 // Shift existing head down list 2412 if (cache.head) { 2413 cache.head.prev = node; 2414 node.next = cache.head; 2415 } 2416 2417 cache.head = node; 2418 2419 return node.val; 2420 } 2421 2422 callSelector.getDependants = normalizedGetDependants; 2423 callSelector.clear = clear; 2424 clear(); 2425 2426 return /** @type {S & EnhancedSelector} */ (callSelector); 2427 } 2428 2429 ;// CONCATENATED MODULE: external ["wp","date"] 2430 const external_wp_date_namespaceObject = window["wp"]["date"]; 2431 ;// CONCATENATED MODULE: external ["wp","url"] 2432 const external_wp_url_namespaceObject = window["wp"]["url"]; 2433 ;// CONCATENATED MODULE: external ["wp","deprecated"] 2434 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; 2435 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); 2436 ;// CONCATENATED MODULE: external ["wp","element"] 2437 const external_wp_element_namespaceObject = window["wp"]["element"]; 2438 // EXTERNAL MODULE: external "React" 2439 var external_React_ = __webpack_require__(1609); 2440 ;// CONCATENATED MODULE: external ["wp","primitives"] 2441 const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; 2442 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/layout.js 2443 2444 /** 2445 * WordPress dependencies 2446 */ 2447 2448 const layout = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 2449 xmlns: "http://www.w3.org/2000/svg", 2450 viewBox: "0 0 24 24" 2451 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 2452 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" 2453 })); 2454 /* harmony default export */ const library_layout = (layout); 2455 2456 ;// CONCATENATED MODULE: external ["wp","preferences"] 2457 const external_wp_preferences_namespaceObject = window["wp"]["preferences"]; 2458 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/constants.js 2459 /** 2460 * Set of post properties for which edits should assume a merging behavior, 2461 * assuming an object value. 2462 * 2463 * @type {Set} 2464 */ 2465 const EDIT_MERGE_PROPERTIES = new Set(['meta']); 2466 2467 /** 2468 * Constant for the store module (or reducer) key. 2469 * 2470 * @type {string} 2471 */ 2472 const STORE_NAME = 'core/editor'; 2473 const SAVE_POST_NOTICE_ID = 'SAVE_POST_NOTICE_ID'; 2474 const TRASH_POST_NOTICE_ID = 'TRASH_POST_NOTICE_ID'; 2475 const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/; 2476 const ONE_MINUTE_IN_MS = 60 * 1000; 2477 const AUTOSAVE_PROPERTIES = ['title', 'excerpt', 'content']; 2478 2479 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/header.js 2480 2481 /** 2482 * WordPress dependencies 2483 */ 2484 2485 const header = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 2486 xmlns: "http://www.w3.org/2000/svg", 2487 viewBox: "0 0 24 24" 2488 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 2489 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" 2490 })); 2491 /* harmony default export */ const library_header = (header); 2492 2493 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/footer.js 2494 2495 /** 2496 * WordPress dependencies 2497 */ 2498 2499 const footer = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 2500 xmlns: "http://www.w3.org/2000/svg", 2501 viewBox: "0 0 24 24" 2502 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 2503 fillRule: "evenodd", 2504 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" 2505 })); 2506 /* harmony default export */ const library_footer = (footer); 2507 2508 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/sidebar.js 2509 2510 /** 2511 * WordPress dependencies 2512 */ 2513 2514 const sidebar = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 2515 xmlns: "http://www.w3.org/2000/svg", 2516 viewBox: "0 0 24 24" 2517 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 2518 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" 2519 })); 2520 /* harmony default export */ const library_sidebar = (sidebar); 2521 2522 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol-filled.js 2523 2524 /** 2525 * WordPress dependencies 2526 */ 2527 2528 const symbolFilled = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 2529 xmlns: "http://www.w3.org/2000/svg", 2530 viewBox: "0 0 24 24" 2531 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 2532 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" 2533 })); 2534 /* harmony default export */ const symbol_filled = (symbolFilled); 2535 2536 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/get-template-part-icon.js 2537 /** 2538 * WordPress dependencies 2539 */ 2540 2541 /** 2542 * Helper function to retrieve the corresponding icon by name. 2543 * 2544 * @param {string} iconName The name of the icon. 2545 * 2546 * @return {Object} The corresponding icon. 2547 */ 2548 function getTemplatePartIcon(iconName) { 2549 if ('header' === iconName) { 2550 return library_header; 2551 } else if ('footer' === iconName) { 2552 return library_footer; 2553 } else if ('sidebar' === iconName) { 2554 return library_sidebar; 2555 } 2556 return symbol_filled; 2557 } 2558 2559 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/selectors.js 2560 /** 2561 * External dependencies 2562 */ 2563 2564 2565 /** 2566 * WordPress dependencies 2567 */ 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 /** 2580 * Internal dependencies 2581 */ 2582 2583 2584 2585 2586 /** 2587 * Shared reference to an empty object for cases where it is important to avoid 2588 * returning a new object reference on every invocation, as in a connected or 2589 * other pure component which performs `shouldComponentUpdate` check on props. 2590 * This should be used as a last resort, since the normalized data should be 2591 * maintained by the reducer result in state. 2592 */ 2593 const EMPTY_OBJECT = {}; 2594 2595 /** 2596 * Returns true if any past editor history snapshots exist, or false otherwise. 2597 * 2598 * @param {Object} state Global application state. 2599 * 2600 * @return {boolean} Whether undo history exists. 2601 */ 2602 const hasEditorUndo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { 2603 return select(external_wp_coreData_namespaceObject.store).hasUndo(); 2604 }); 2605 2606 /** 2607 * Returns true if any future editor history snapshots exist, or false 2608 * otherwise. 2609 * 2610 * @param {Object} state Global application state. 2611 * 2612 * @return {boolean} Whether redo history exists. 2613 */ 2614 const hasEditorRedo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { 2615 return select(external_wp_coreData_namespaceObject.store).hasRedo(); 2616 }); 2617 2618 /** 2619 * Returns true if the currently edited post is yet to be saved, or false if 2620 * the post has been saved. 2621 * 2622 * @param {Object} state Global application state. 2623 * 2624 * @return {boolean} Whether the post is new. 2625 */ 2626 function isEditedPostNew(state) { 2627 return getCurrentPost(state).status === 'auto-draft'; 2628 } 2629 2630 /** 2631 * Returns true if content includes unsaved changes, or false otherwise. 2632 * 2633 * @param {Object} state Editor state. 2634 * 2635 * @return {boolean} Whether content includes unsaved changes. 2636 */ 2637 function hasChangedContent(state) { 2638 const edits = getPostEdits(state); 2639 return 'content' in edits; 2640 } 2641 2642 /** 2643 * Returns true if there are unsaved values for the current edit session, or 2644 * false if the editing state matches the saved or new post. 2645 * 2646 * @param {Object} state Global application state. 2647 * 2648 * @return {boolean} Whether unsaved values exist. 2649 */ 2650 const isEditedPostDirty = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { 2651 // Edits should contain only fields which differ from the saved post (reset 2652 // at initial load and save complete). Thus, a non-empty edits state can be 2653 // inferred to contain unsaved values. 2654 const postType = getCurrentPostType(state); 2655 const postId = getCurrentPostId(state); 2656 if (select(external_wp_coreData_namespaceObject.store).hasEditsForEntityRecord('postType', postType, postId)) { 2657 return true; 2658 } 2659 return false; 2660 }); 2661 2662 /** 2663 * Returns true if there are unsaved edits for entities other than 2664 * the editor's post, and false otherwise. 2665 * 2666 * @param {Object} state Global application state. 2667 * 2668 * @return {boolean} Whether there are edits or not. 2669 */ 2670 const hasNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { 2671 const dirtyEntityRecords = select(external_wp_coreData_namespaceObject.store).__experimentalGetDirtyEntityRecords(); 2672 const { 2673 type, 2674 id 2675 } = getCurrentPost(state); 2676 return dirtyEntityRecords.some(entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id); 2677 }); 2678 2679 /** 2680 * Returns true if there are no unsaved values for the current edit session and 2681 * if the currently edited post is new (has never been saved before). 2682 * 2683 * @param {Object} state Global application state. 2684 * 2685 * @return {boolean} Whether new post and unsaved values exist. 2686 */ 2687 function isCleanNewPost(state) { 2688 return !isEditedPostDirty(state) && isEditedPostNew(state); 2689 } 2690 2691 /** 2692 * Returns the post currently being edited in its last known saved state, not 2693 * including unsaved edits. Returns an object containing relevant default post 2694 * values if the post has not yet been saved. 2695 * 2696 * @param {Object} state Global application state. 2697 * 2698 * @return {Object} Post object. 2699 */ 2700 const getCurrentPost = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { 2701 const postId = getCurrentPostId(state); 2702 const postType = getCurrentPostType(state); 2703 const post = select(external_wp_coreData_namespaceObject.store).getRawEntityRecord('postType', postType, postId); 2704 if (post) { 2705 return post; 2706 } 2707 2708 // This exists for compatibility with the previous selector behavior 2709 // which would guarantee an object return based on the editor reducer's 2710 // default empty object state. 2711 return EMPTY_OBJECT; 2712 }); 2713 2714 /** 2715 * Returns the post type of the post currently being edited. 2716 * 2717 * @param {Object} state Global application state. 2718 * 2719 * @return {string} Post type. 2720 */ 2721 function getCurrentPostType(state) { 2722 return state.postType; 2723 } 2724 2725 /** 2726 * Returns the ID of the post currently being edited, or null if the post has 2727 * not yet been saved. 2728 * 2729 * @param {Object} state Global application state. 2730 * 2731 * @return {?number} ID of current post. 2732 */ 2733 function getCurrentPostId(state) { 2734 return state.postId; 2735 } 2736 2737 /** 2738 * Returns the template ID currently being rendered/edited 2739 * 2740 * @param {Object} state Global application state. 2741 * 2742 * @return {string?} Template ID. 2743 */ 2744 function getCurrentTemplateId(state) { 2745 return state.templateId; 2746 } 2747 2748 /** 2749 * Returns the number of revisions of the post currently being edited. 2750 * 2751 * @param {Object} state Global application state. 2752 * 2753 * @return {number} Number of revisions. 2754 */ 2755 function getCurrentPostRevisionsCount(state) { 2756 var _getCurrentPost$_link; 2757 return (_getCurrentPost$_link = getCurrentPost(state)._links?.['version-history']?.[0]?.count) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : 0; 2758 } 2759 2760 /** 2761 * Returns the last revision ID of the post currently being edited, 2762 * or null if the post has no revisions. 2763 * 2764 * @param {Object} state Global application state. 2765 * 2766 * @return {?number} ID of the last revision. 2767 */ 2768 function getCurrentPostLastRevisionId(state) { 2769 var _getCurrentPost$_link2; 2770 return (_getCurrentPost$_link2 = getCurrentPost(state)._links?.['predecessor-version']?.[0]?.id) !== null && _getCurrentPost$_link2 !== void 0 ? _getCurrentPost$_link2 : null; 2771 } 2772 2773 /** 2774 * Returns any post values which have been changed in the editor but not yet 2775 * been saved. 2776 * 2777 * @param {Object} state Global application state. 2778 * 2779 * @return {Object} Object of key value pairs comprising unsaved edits. 2780 */ 2781 const getPostEdits = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { 2782 const postType = getCurrentPostType(state); 2783 const postId = getCurrentPostId(state); 2784 return select(external_wp_coreData_namespaceObject.store).getEntityRecordEdits('postType', postType, postId) || EMPTY_OBJECT; 2785 }); 2786 2787 /** 2788 * Returns an attribute value of the saved post. 2789 * 2790 * @param {Object} state Global application state. 2791 * @param {string} attributeName Post attribute name. 2792 * 2793 * @return {*} Post attribute value. 2794 */ 2795 function getCurrentPostAttribute(state, attributeName) { 2796 switch (attributeName) { 2797 case 'type': 2798 return getCurrentPostType(state); 2799 case 'id': 2800 return getCurrentPostId(state); 2801 default: 2802 const post = getCurrentPost(state); 2803 if (!post.hasOwnProperty(attributeName)) { 2804 break; 2805 } 2806 return getPostRawValue(post[attributeName]); 2807 } 2808 } 2809 2810 /** 2811 * Returns a single attribute of the post being edited, preferring the unsaved 2812 * edit if one exists, but merging with the attribute value for the last known 2813 * saved state of the post (this is needed for some nested attributes like meta). 2814 * 2815 * @param {Object} state Global application state. 2816 * @param {string} attributeName Post attribute name. 2817 * 2818 * @return {*} Post attribute value. 2819 */ 2820 const getNestedEditedPostProperty = rememo((state, attributeName) => { 2821 const edits = getPostEdits(state); 2822 if (!edits.hasOwnProperty(attributeName)) { 2823 return getCurrentPostAttribute(state, attributeName); 2824 } 2825 return { 2826 ...getCurrentPostAttribute(state, attributeName), 2827 ...edits[attributeName] 2828 }; 2829 }, (state, attributeName) => [getCurrentPostAttribute(state, attributeName), getPostEdits(state)[attributeName]]); 2830 2831 /** 2832 * Returns a single attribute of the post being edited, preferring the unsaved 2833 * edit if one exists, but falling back to the attribute for the last known 2834 * saved state of the post. 2835 * 2836 * @param {Object} state Global application state. 2837 * @param {string} attributeName Post attribute name. 2838 * 2839 * @return {*} Post attribute value. 2840 */ 2841 function getEditedPostAttribute(state, attributeName) { 2842 // Special cases. 2843 switch (attributeName) { 2844 case 'content': 2845 return getEditedPostContent(state); 2846 } 2847 2848 // Fall back to saved post value if not edited. 2849 const edits = getPostEdits(state); 2850 if (!edits.hasOwnProperty(attributeName)) { 2851 return getCurrentPostAttribute(state, attributeName); 2852 } 2853 2854 // Merge properties are objects which contain only the patch edit in state, 2855 // and thus must be merged with the current post attribute. 2856 if (EDIT_MERGE_PROPERTIES.has(attributeName)) { 2857 return getNestedEditedPostProperty(state, attributeName); 2858 } 2859 return edits[attributeName]; 2860 } 2861 2862 /** 2863 * Returns an attribute value of the current autosave revision for a post, or 2864 * null if there is no autosave for the post. 2865 * 2866 * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector 2867 * from the '@wordpress/core-data' package and access properties on the returned 2868 * autosave object using getPostRawValue. 2869 * 2870 * @param {Object} state Global application state. 2871 * @param {string} attributeName Autosave attribute name. 2872 * 2873 * @return {*} Autosave attribute value. 2874 */ 2875 const getAutosaveAttribute = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, attributeName) => { 2876 if (!AUTOSAVE_PROPERTIES.includes(attributeName) && attributeName !== 'preview_link') { 2877 return; 2878 } 2879 const postType = getCurrentPostType(state); 2880 2881 // Currently template autosaving is not supported. 2882 if (postType === 'wp_template') { 2883 return false; 2884 } 2885 const postId = getCurrentPostId(state); 2886 const currentUserId = select(external_wp_coreData_namespaceObject.store).getCurrentUser()?.id; 2887 const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId); 2888 if (autosave) { 2889 return getPostRawValue(autosave[attributeName]); 2890 } 2891 }); 2892 2893 /** 2894 * Returns the current visibility of the post being edited, preferring the 2895 * unsaved value if different than the saved post. The return value is one of 2896 * "private", "password", or "public". 2897 * 2898 * @param {Object} state Global application state. 2899 * 2900 * @return {string} Post visibility. 2901 */ 2902 function getEditedPostVisibility(state) { 2903 const status = getEditedPostAttribute(state, 'status'); 2904 if (status === 'private') { 2905 return 'private'; 2906 } 2907 const password = getEditedPostAttribute(state, 'password'); 2908 if (password) { 2909 return 'password'; 2910 } 2911 return 'public'; 2912 } 2913 2914 /** 2915 * Returns true if post is pending review. 2916 * 2917 * @param {Object} state Global application state. 2918 * 2919 * @return {boolean} Whether current post is pending review. 2920 */ 2921 function isCurrentPostPending(state) { 2922 return getCurrentPost(state).status === 'pending'; 2923 } 2924 2925 /** 2926 * Return true if the current post has already been published. 2927 * 2928 * @param {Object} state Global application state. 2929 * @param {Object?} currentPost Explicit current post for bypassing registry selector. 2930 * 2931 * @return {boolean} Whether the post has been published. 2932 */ 2933 function isCurrentPostPublished(state, currentPost) { 2934 const post = currentPost || getCurrentPost(state); 2935 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)); 2936 } 2937 2938 /** 2939 * Returns true if post is already scheduled. 2940 * 2941 * @param {Object} state Global application state. 2942 * 2943 * @return {boolean} Whether current post is scheduled to be posted. 2944 */ 2945 function isCurrentPostScheduled(state) { 2946 return getCurrentPost(state).status === 'future' && !isCurrentPostPublished(state); 2947 } 2948 2949 /** 2950 * Return true if the post being edited can be published. 2951 * 2952 * @param {Object} state Global application state. 2953 * 2954 * @return {boolean} Whether the post can been published. 2955 */ 2956 function isEditedPostPublishable(state) { 2957 const post = getCurrentPost(state); 2958 2959 // TODO: Post being publishable should be superset of condition of post 2960 // being saveable. Currently this restriction is imposed at UI. 2961 // 2962 // See: <PostPublishButton /> (`isButtonEnabled` assigned by `isSaveable`). 2963 2964 return isEditedPostDirty(state) || ['publish', 'private', 'future'].indexOf(post.status) === -1; 2965 } 2966 2967 /** 2968 * Returns true if the post can be saved, or false otherwise. A post must 2969 * contain a title, an excerpt, or non-empty content to be valid for save. 2970 * 2971 * @param {Object} state Global application state. 2972 * 2973 * @return {boolean} Whether the post can be saved. 2974 */ 2975 function isEditedPostSaveable(state) { 2976 if (isSavingPost(state)) { 2977 return false; 2978 } 2979 2980 // TODO: Post should not be saveable if not dirty. Cannot be added here at 2981 // this time since posts where meta boxes are present can be saved even if 2982 // the post is not dirty. Currently this restriction is imposed at UI, but 2983 // should be moved here. 2984 // 2985 // See: `isEditedPostPublishable` (includes `isEditedPostDirty` condition) 2986 // See: <PostSavedState /> (`forceIsDirty` prop) 2987 // See: <PostPublishButton /> (`forceIsDirty` prop) 2988 // See: https://github.com/WordPress/gutenberg/pull/4184. 2989 2990 return !!getEditedPostAttribute(state, 'title') || !!getEditedPostAttribute(state, 'excerpt') || !isEditedPostEmpty(state) || external_wp_element_namespaceObject.Platform.OS === 'native'; 2991 } 2992 2993 /** 2994 * Returns true if the edited post has content. A post has content if it has at 2995 * least one saveable block or otherwise has a non-empty content property 2996 * assigned. 2997 * 2998 * @param {Object} state Global application state. 2999 * 3000 * @return {boolean} Whether post has content. 3001 */ 3002 const isEditedPostEmpty = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { 3003 // While the condition of truthy content string is sufficient to determine 3004 // emptiness, testing saveable blocks length is a trivial operation. Since 3005 // this function can be called frequently, optimize for the fast case as a 3006 // condition of the mere existence of blocks. Note that the value of edited 3007 // content takes precedent over block content, and must fall through to the 3008 // default logic. 3009 const postId = getCurrentPostId(state); 3010 const postType = getCurrentPostType(state); 3011 const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId); 3012 if (typeof record.content !== 'function') { 3013 return !record.content; 3014 } 3015 const blocks = getEditedPostAttribute(state, 'blocks'); 3016 if (blocks.length === 0) { 3017 return true; 3018 } 3019 3020 // Pierce the abstraction of the serializer in knowing that blocks are 3021 // joined with newlines such that even if every individual block 3022 // produces an empty save result, the serialized content is non-empty. 3023 if (blocks.length > 1) { 3024 return false; 3025 } 3026 3027 // There are two conditions under which the optimization cannot be 3028 // assumed, and a fallthrough to getEditedPostContent must occur: 3029 // 3030 // 1. getBlocksForSerialization has special treatment in omitting a 3031 // single unmodified default block. 3032 // 2. Comment delimiters are omitted for a freeform or unregistered 3033 // block in its serialization. The freeform block specifically may 3034 // produce an empty string in its saved output. 3035 // 3036 // For all other content, the single block is assumed to make a post 3037 // non-empty, if only by virtue of its own comment delimiters. 3038 const blockName = blocks[0].name; 3039 if (blockName !== (0,external_wp_blocks_namespaceObject.getDefaultBlockName)() && blockName !== (0,external_wp_blocks_namespaceObject.getFreeformContentHandlerName)()) { 3040 return false; 3041 } 3042 return !getEditedPostContent(state); 3043 }); 3044 3045 /** 3046 * Returns true if the post can be autosaved, or false otherwise. 3047 * 3048 * @param {Object} state Global application state. 3049 * @param {Object} autosave A raw autosave object from the REST API. 3050 * 3051 * @return {boolean} Whether the post can be autosaved. 3052 */ 3053 const isEditedPostAutosaveable = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { 3054 // A post must contain a title, an excerpt, or non-empty content to be valid for autosaving. 3055 if (!isEditedPostSaveable(state)) { 3056 return false; 3057 } 3058 3059 // A post is not autosavable when there is a post autosave lock. 3060 if (isPostAutosavingLocked(state)) { 3061 return false; 3062 } 3063 const postType = getCurrentPostType(state); 3064 3065 // Currently template autosaving is not supported. 3066 if (postType === 'wp_template') { 3067 return false; 3068 } 3069 const postId = getCurrentPostId(state); 3070 const hasFetchedAutosave = select(external_wp_coreData_namespaceObject.store).hasFetchedAutosaves(postType, postId); 3071 const currentUserId = select(external_wp_coreData_namespaceObject.store).getCurrentUser()?.id; 3072 3073 // Disable reason - this line causes the side-effect of fetching the autosave 3074 // via a resolver, moving below the return would result in the autosave never 3075 // being fetched. 3076 // eslint-disable-next-line @wordpress/no-unused-vars-before-return 3077 const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId); 3078 3079 // If any existing autosaves have not yet been fetched, this function is 3080 // unable to determine if the post is autosaveable, so return false. 3081 if (!hasFetchedAutosave) { 3082 return false; 3083 } 3084 3085 // If we don't already have an autosave, the post is autosaveable. 3086 if (!autosave) { 3087 return true; 3088 } 3089 3090 // To avoid an expensive content serialization, use the content dirtiness 3091 // flag in place of content field comparison against the known autosave. 3092 // This is not strictly accurate, and relies on a tolerance toward autosave 3093 // request failures for unnecessary saves. 3094 if (hasChangedContent(state)) { 3095 return true; 3096 } 3097 3098 // If title, excerpt, or meta have changed, the post is autosaveable. 3099 return ['title', 'excerpt', 'meta'].some(field => getPostRawValue(autosave[field]) !== getEditedPostAttribute(state, field)); 3100 }); 3101 3102 /** 3103 * Return true if the post being edited is being scheduled. Preferring the 3104 * unsaved status values. 3105 * 3106 * @param {Object} state Global application state. 3107 * 3108 * @return {boolean} Whether the post has been published. 3109 */ 3110 function isEditedPostBeingScheduled(state) { 3111 const date = getEditedPostAttribute(state, 'date'); 3112 // Offset the date by one minute (network latency). 3113 const checkedDate = new Date(Number((0,external_wp_date_namespaceObject.getDate)(date)) - ONE_MINUTE_IN_MS); 3114 return (0,external_wp_date_namespaceObject.isInTheFuture)(checkedDate); 3115 } 3116 3117 /** 3118 * Returns whether the current post should be considered to have a "floating" 3119 * date (i.e. that it would publish "Immediately" rather than at a set time). 3120 * 3121 * Unlike in the PHP backend, the REST API returns a full date string for posts 3122 * where the 0000-00-00T00:00:00 placeholder is present in the database. To 3123 * infer that a post is set to publish "Immediately" we check whether the date 3124 * and modified date are the same. 3125 * 3126 * @param {Object} state Editor state. 3127 * 3128 * @return {boolean} Whether the edited post has a floating date value. 3129 */ 3130 function isEditedPostDateFloating(state) { 3131 const date = getEditedPostAttribute(state, 'date'); 3132 const modified = getEditedPostAttribute(state, 'modified'); 3133 3134 // This should be the status of the persisted post 3135 // It shouldn't use the "edited" status otherwise it breaks the 3136 // inferred post data floating status 3137 // See https://github.com/WordPress/gutenberg/issues/28083. 3138 const status = getCurrentPost(state).status; 3139 if (status === 'draft' || status === 'auto-draft' || status === 'pending') { 3140 return date === modified || date === null; 3141 } 3142 return false; 3143 } 3144 3145 /** 3146 * Returns true if the post is currently being deleted, or false otherwise. 3147 * 3148 * @param {Object} state Editor state. 3149 * 3150 * @return {boolean} Whether post is being deleted. 3151 */ 3152 function isDeletingPost(state) { 3153 return !!state.deleting.pending; 3154 } 3155 3156 /** 3157 * Returns true if the post is currently being saved, or false otherwise. 3158 * 3159 * @param {Object} state Global application state. 3160 * 3161 * @return {boolean} Whether post is being saved. 3162 */ 3163 function isSavingPost(state) { 3164 return !!state.saving.pending; 3165 } 3166 3167 /** 3168 * Returns true if non-post entities are currently being saved, or false otherwise. 3169 * 3170 * @param {Object} state Global application state. 3171 * 3172 * @return {boolean} Whether non-post entities are being saved. 3173 */ 3174 const isSavingNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { 3175 const entitiesBeingSaved = select(external_wp_coreData_namespaceObject.store).__experimentalGetEntitiesBeingSaved(); 3176 const { 3177 type, 3178 id 3179 } = getCurrentPost(state); 3180 return entitiesBeingSaved.some(entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id); 3181 }); 3182 3183 /** 3184 * Returns true if a previous post save was attempted successfully, or false 3185 * otherwise. 3186 * 3187 * @param {Object} state Global application state. 3188 * 3189 * @return {boolean} Whether the post was saved successfully. 3190 */ 3191 const didPostSaveRequestSucceed = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { 3192 const postType = getCurrentPostType(state); 3193 const postId = getCurrentPostId(state); 3194 return !select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId); 3195 }); 3196 3197 /** 3198 * Returns true if a previous post save was attempted but failed, or false 3199 * otherwise. 3200 * 3201 * @param {Object} state Global application state. 3202 * 3203 * @return {boolean} Whether the post save failed. 3204 */ 3205 const didPostSaveRequestFail = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { 3206 const postType = getCurrentPostType(state); 3207 const postId = getCurrentPostId(state); 3208 return !!select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId); 3209 }); 3210 3211 /** 3212 * Returns true if the post is autosaving, or false otherwise. 3213 * 3214 * @param {Object} state Global application state. 3215 * 3216 * @return {boolean} Whether the post is autosaving. 3217 */ 3218 function isAutosavingPost(state) { 3219 return isSavingPost(state) && Boolean(state.saving.options?.isAutosave); 3220 } 3221 3222 /** 3223 * Returns true if the post is being previewed, or false otherwise. 3224 * 3225 * @param {Object} state Global application state. 3226 * 3227 * @return {boolean} Whether the post is being previewed. 3228 */ 3229 function isPreviewingPost(state) { 3230 return isSavingPost(state) && Boolean(state.saving.options?.isPreview); 3231 } 3232 3233 /** 3234 * Returns the post preview link 3235 * 3236 * @param {Object} state Global application state. 3237 * 3238 * @return {string | undefined} Preview Link. 3239 */ 3240 function getEditedPostPreviewLink(state) { 3241 if (state.saving.pending || isSavingPost(state)) { 3242 return; 3243 } 3244 let previewLink = getAutosaveAttribute(state, 'preview_link'); 3245 // Fix for issue: https://github.com/WordPress/gutenberg/issues/33616 3246 // If the post is draft, ignore the preview link from the autosave record, 3247 // because the preview could be a stale autosave if the post was switched from 3248 // published to draft. 3249 // See: https://github.com/WordPress/gutenberg/pull/37952. 3250 if (!previewLink || 'draft' === getCurrentPost(state).status) { 3251 previewLink = getEditedPostAttribute(state, 'link'); 3252 if (previewLink) { 3253 previewLink = (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, { 3254 preview: true 3255 }); 3256 } 3257 } 3258 const featuredImageId = getEditedPostAttribute(state, 'featured_media'); 3259 if (previewLink && featuredImageId) { 3260 return (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, { 3261 _thumbnail_id: featuredImageId 3262 }); 3263 } 3264 return previewLink; 3265 } 3266 3267 /** 3268 * Returns a suggested post format for the current post, inferred only if there 3269 * is a single block within the post and it is of a type known to match a 3270 * default post format. Returns null if the format cannot be determined. 3271 * 3272 * @return {?string} Suggested post format. 3273 */ 3274 const getSuggestedPostFormat = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { 3275 const blocks = select(external_wp_blockEditor_namespaceObject.store).getBlocks(); 3276 if (blocks.length > 2) return null; 3277 let name; 3278 // If there is only one block in the content of the post grab its name 3279 // so we can derive a suitable post format from it. 3280 if (blocks.length === 1) { 3281 name = blocks[0].name; 3282 // Check for core/embed `video` and `audio` eligible suggestions. 3283 if (name === 'core/embed') { 3284 const provider = blocks[0].attributes?.providerNameSlug; 3285 if (['youtube', 'vimeo'].includes(provider)) { 3286 name = 'core/video'; 3287 } else if (['spotify', 'soundcloud'].includes(provider)) { 3288 name = 'core/audio'; 3289 } 3290 } 3291 } 3292 3293 // If there are two blocks in the content and the last one is a text blocks 3294 // grab the name of the first one to also suggest a post format from it. 3295 if (blocks.length === 2 && blocks[1].name === 'core/paragraph') { 3296 name = blocks[0].name; 3297 } 3298 3299 // We only convert to default post formats in core. 3300 switch (name) { 3301 case 'core/image': 3302 return 'image'; 3303 case 'core/quote': 3304 case 'core/pullquote': 3305 return 'quote'; 3306 case 'core/gallery': 3307 return 'gallery'; 3308 case 'core/video': 3309 return 'video'; 3310 case 'core/audio': 3311 return 'audio'; 3312 default: 3313 return null; 3314 } 3315 }); 3316 3317 /** 3318 * Returns the content of the post being edited. 3319 * 3320 * @param {Object} state Global application state. 3321 * 3322 * @return {string} Post content. 3323 */ 3324 const getEditedPostContent = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { 3325 const postId = getCurrentPostId(state); 3326 const postType = getCurrentPostType(state); 3327 const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId); 3328 if (record) { 3329 if (typeof record.content === 'function') { 3330 return record.content(record); 3331 } else if (record.blocks) { 3332 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks); 3333 } else if (record.content) { 3334 return record.content; 3335 } 3336 } 3337 return ''; 3338 }); 3339 3340 /** 3341 * Returns true if the post is being published, or false otherwise. 3342 * 3343 * @param {Object} state Global application state. 3344 * 3345 * @return {boolean} Whether post is being published. 3346 */ 3347 function isPublishingPost(state) { 3348 return isSavingPost(state) && !isCurrentPostPublished(state) && getEditedPostAttribute(state, 'status') === 'publish'; 3349 } 3350 3351 /** 3352 * Returns whether the permalink is editable or not. 3353 * 3354 * @param {Object} state Editor state. 3355 * 3356 * @return {boolean} Whether or not the permalink is editable. 3357 */ 3358 function isPermalinkEditable(state) { 3359 const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template'); 3360 return PERMALINK_POSTNAME_REGEX.test(permalinkTemplate); 3361 } 3362 3363 /** 3364 * Returns the permalink for the post. 3365 * 3366 * @param {Object} state Editor state. 3367 * 3368 * @return {?string} The permalink, or null if the post is not viewable. 3369 */ 3370 function getPermalink(state) { 3371 const permalinkParts = getPermalinkParts(state); 3372 if (!permalinkParts) { 3373 return null; 3374 } 3375 const { 3376 prefix, 3377 postName, 3378 suffix 3379 } = permalinkParts; 3380 if (isPermalinkEditable(state)) { 3381 return prefix + postName + suffix; 3382 } 3383 return prefix; 3384 } 3385 3386 /** 3387 * Returns the slug for the post being edited, preferring a manually edited 3388 * value if one exists, then a sanitized version of the current post title, and 3389 * finally the post ID. 3390 * 3391 * @param {Object} state Editor state. 3392 * 3393 * @return {string} The current slug to be displayed in the editor 3394 */ 3395 function getEditedPostSlug(state) { 3396 return getEditedPostAttribute(state, 'slug') || (0,external_wp_url_namespaceObject.cleanForSlug)(getEditedPostAttribute(state, 'title')) || getCurrentPostId(state); 3397 } 3398 3399 /** 3400 * Returns the permalink for a post, split into it's three parts: the prefix, 3401 * the postName, and the suffix. 3402 * 3403 * @param {Object} state Editor state. 3404 * 3405 * @return {Object} An object containing the prefix, postName, and suffix for 3406 * the permalink, or null if the post is not viewable. 3407 */ 3408 function getPermalinkParts(state) { 3409 const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template'); 3410 if (!permalinkTemplate) { 3411 return null; 3412 } 3413 const postName = getEditedPostAttribute(state, 'slug') || getEditedPostAttribute(state, 'generated_slug'); 3414 const [prefix, suffix] = permalinkTemplate.split(PERMALINK_POSTNAME_REGEX); 3415 return { 3416 prefix, 3417 postName, 3418 suffix 3419 }; 3420 } 3421 3422 /** 3423 * Returns whether the post is locked. 3424 * 3425 * @param {Object} state Global application state. 3426 * 3427 * @return {boolean} Is locked. 3428 */ 3429 function isPostLocked(state) { 3430 return state.postLock.isLocked; 3431 } 3432 3433 /** 3434 * Returns whether post saving is locked. 3435 * 3436 * @param {Object} state Global application state. 3437 * 3438 * @return {boolean} Is locked. 3439 */ 3440 function isPostSavingLocked(state) { 3441 return Object.keys(state.postSavingLock).length > 0; 3442 } 3443 3444 /** 3445 * Returns whether post autosaving is locked. 3446 * 3447 * @param {Object} state Global application state. 3448 * 3449 * @return {boolean} Is locked. 3450 */ 3451 function isPostAutosavingLocked(state) { 3452 return Object.keys(state.postAutosavingLock).length > 0; 3453 } 3454 3455 /** 3456 * Returns whether the edition of the post has been taken over. 3457 * 3458 * @param {Object} state Global application state. 3459 * 3460 * @return {boolean} Is post lock takeover. 3461 */ 3462 function isPostLockTakeover(state) { 3463 return state.postLock.isTakeover; 3464 } 3465 3466 /** 3467 * Returns details about the post lock user. 3468 * 3469 * @param {Object} state Global application state. 3470 * 3471 * @return {Object} A user object. 3472 */ 3473 function getPostLockUser(state) { 3474 return state.postLock.user; 3475 } 3476 3477 /** 3478 * Returns the active post lock. 3479 * 3480 * @param {Object} state Global application state. 3481 * 3482 * @return {Object} The lock object. 3483 */ 3484 function getActivePostLock(state) { 3485 return state.postLock.activePostLock; 3486 } 3487 3488 /** 3489 * Returns whether or not the user has the unfiltered_html capability. 3490 * 3491 * @param {Object} state Editor state. 3492 * 3493 * @return {boolean} Whether the user can or can't post unfiltered HTML. 3494 */ 3495 function canUserUseUnfilteredHTML(state) { 3496 return Boolean(getCurrentPost(state)._links?.hasOwnProperty('wp:action-unfiltered-html')); 3497 } 3498 3499 /** 3500 * Returns whether the pre-publish panel should be shown 3501 * or skipped when the user clicks the "publish" button. 3502 * 3503 * @return {boolean} Whether the pre-publish panel should be shown or not. 3504 */ 3505 const isPublishSidebarEnabled = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => !!select(external_wp_preferences_namespaceObject.store).get('core/edit-post', 'isPublishSidebarEnabled')); 3506 3507 /** 3508 * Return the current block list. 3509 * 3510 * @param {Object} state 3511 * @return {Array} Block list. 3512 */ 3513 const getEditorBlocks = rememo(state => { 3514 return getEditedPostAttribute(state, 'blocks') || (0,external_wp_blocks_namespaceObject.parse)(getEditedPostContent(state)); 3515 }, state => [getEditedPostAttribute(state, 'blocks'), getEditedPostContent(state)]); 3516 3517 /** 3518 * Returns true if the given panel was programmatically removed, or false otherwise. 3519 * All panels are not removed by default. 3520 * 3521 * @param {Object} state Global application state. 3522 * @param {string} panelName A string that identifies the panel. 3523 * 3524 * @return {boolean} Whether or not the panel is removed. 3525 */ 3526 function isEditorPanelRemoved(state, panelName) { 3527 return state.removedPanels.includes(panelName); 3528 } 3529 3530 /** 3531 * Returns true if the given panel is enabled, or false otherwise. Panels are 3532 * enabled by default. 3533 * 3534 * @param {Object} state Global application state. 3535 * @param {string} panelName A string that identifies the panel. 3536 * 3537 * @return {boolean} Whether or not the panel is enabled. 3538 */ 3539 const isEditorPanelEnabled = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, panelName) => { 3540 // For backward compatibility, we check edit-post 3541 // even though now this is in "editor" package. 3542 const inactivePanels = select(external_wp_preferences_namespaceObject.store).get('core', 'inactivePanels'); 3543 return !isEditorPanelRemoved(state, panelName) && !inactivePanels?.includes(panelName); 3544 }); 3545 3546 /** 3547 * Returns true if the given panel is open, or false otherwise. Panels are 3548 * closed by default. 3549 * 3550 * @param {Object} state Global application state. 3551 * @param {string} panelName A string that identifies the panel. 3552 * 3553 * @return {boolean} Whether or not the panel is open. 3554 */ 3555 const isEditorPanelOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, panelName) => { 3556 // For backward compatibility, we check edit-post 3557 // even though now this is in "editor" package. 3558 const openPanels = select(external_wp_preferences_namespaceObject.store).get('core', 'openPanels'); 3559 return !!openPanels?.includes(panelName); 3560 }); 3561 3562 /** 3563 * A block selection object. 3564 * 3565 * @typedef {Object} WPBlockSelection 3566 * 3567 * @property {string} clientId A block client ID. 3568 * @property {string} attributeKey A block attribute key. 3569 * @property {number} offset An attribute value offset, based on the rich 3570 * text value. See `wp.richText.create`. 3571 */ 3572 3573 /** 3574 * Returns the current selection start. 3575 * 3576 * @param {Object} state 3577 * @return {WPBlockSelection} The selection start. 3578 * 3579 * @deprecated since Gutenberg 10.0.0. 3580 */ 3581 function getEditorSelectionStart(state) { 3582 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", { 3583 since: '5.8', 3584 alternative: "select('core/editor').getEditorSelection" 3585 }); 3586 return getEditedPostAttribute(state, 'selection')?.selectionStart; 3587 } 3588 3589 /** 3590 * Returns the current selection end. 3591 * 3592 * @param {Object} state 3593 * @return {WPBlockSelection} The selection end. 3594 * 3595 * @deprecated since Gutenberg 10.0.0. 3596 */ 3597 function getEditorSelectionEnd(state) { 3598 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", { 3599 since: '5.8', 3600 alternative: "select('core/editor').getEditorSelection" 3601 }); 3602 return getEditedPostAttribute(state, 'selection')?.selectionEnd; 3603 } 3604 3605 /** 3606 * Returns the current selection. 3607 * 3608 * @param {Object} state 3609 * @return {WPBlockSelection} The selection end. 3610 */ 3611 function getEditorSelection(state) { 3612 return getEditedPostAttribute(state, 'selection'); 3613 } 3614 3615 /** 3616 * Is the editor ready 3617 * 3618 * @param {Object} state 3619 * @return {boolean} is Ready. 3620 */ 3621 function __unstableIsEditorReady(state) { 3622 return !!state.postId; 3623 } 3624 3625 /** 3626 * Returns the post editor settings. 3627 * 3628 * @param {Object} state Editor state. 3629 * 3630 * @return {Object} The editor settings object. 3631 */ 3632 function getEditorSettings(state) { 3633 return state.editorSettings; 3634 } 3635 3636 /** 3637 * Returns the post editor's rendering mode. 3638 * 3639 * @param {Object} state Editor state. 3640 * 3641 * @return {string} Rendering mode. 3642 */ 3643 function getRenderingMode(state) { 3644 return state.renderingMode; 3645 } 3646 3647 /** 3648 * Returns the current editing canvas device type. 3649 * 3650 * @param {Object} state Global application state. 3651 * 3652 * @return {string} Device type. 3653 */ 3654 function getDeviceType(state) { 3655 return state.deviceType; 3656 } 3657 3658 /** 3659 * Returns true if the list view is opened. 3660 * 3661 * @param {Object} state Global application state. 3662 * 3663 * @return {boolean} Whether the list view is opened. 3664 */ 3665 function isListViewOpened(state) { 3666 return state.listViewPanel; 3667 } 3668 3669 /** 3670 * Returns true if the inserter is opened. 3671 * 3672 * @param {Object} state Global application state. 3673 * 3674 * @return {boolean} Whether the inserter is opened. 3675 */ 3676 function isInserterOpened(state) { 3677 return !!state.blockInserterPanel; 3678 } 3679 3680 /* 3681 * Backward compatibility 3682 */ 3683 3684 /** 3685 * Returns state object prior to a specified optimist transaction ID, or `null` 3686 * if the transaction corresponding to the given ID cannot be found. 3687 * 3688 * @deprecated since Gutenberg 9.7.0. 3689 */ 3690 function getStateBeforeOptimisticTransaction() { 3691 external_wp_deprecated_default()("select('core/editor').getStateBeforeOptimisticTransaction", { 3692 since: '5.7', 3693 hint: 'No state history is kept on this store anymore' 3694 }); 3695 return null; 3696 } 3697 /** 3698 * Returns true if an optimistic transaction is pending commit, for which the 3699 * before state satisfies the given predicate function. 3700 * 3701 * @deprecated since Gutenberg 9.7.0. 3702 */ 3703 function inSomeHistory() { 3704 external_wp_deprecated_default()("select('core/editor').inSomeHistory", { 3705 since: '5.7', 3706 hint: 'No state history is kept on this store anymore' 3707 }); 3708 return false; 3709 } 3710 function getBlockEditorSelector(name) { 3711 return (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, ...args) => { 3712 external_wp_deprecated_default()("`wp.data.select( 'core/editor' )." + name + '`', { 3713 since: '5.3', 3714 alternative: "`wp.data.select( 'core/block-editor' )." + name + '`', 3715 version: '6.2' 3716 }); 3717 return select(external_wp_blockEditor_namespaceObject.store)[name](...args); 3718 }); 3719 } 3720 3721 /** 3722 * @see getBlockName in core/block-editor store. 3723 */ 3724 const getBlockName = getBlockEditorSelector('getBlockName'); 3725 3726 /** 3727 * @see isBlockValid in core/block-editor store. 3728 */ 3729 const isBlockValid = getBlockEditorSelector('isBlockValid'); 3730 3731 /** 3732 * @see getBlockAttributes in core/block-editor store. 3733 */ 3734 const getBlockAttributes = getBlockEditorSelector('getBlockAttributes'); 3735 3736 /** 3737 * @see getBlock in core/block-editor store. 3738 */ 3739 const getBlock = getBlockEditorSelector('getBlock'); 3740 3741 /** 3742 * @see getBlocks in core/block-editor store. 3743 */ 3744 const getBlocks = getBlockEditorSelector('getBlocks'); 3745 3746 /** 3747 * @see getClientIdsOfDescendants in core/block-editor store. 3748 */ 3749 const getClientIdsOfDescendants = getBlockEditorSelector('getClientIdsOfDescendants'); 3750 3751 /** 3752 * @see getClientIdsWithDescendants in core/block-editor store. 3753 */ 3754 const getClientIdsWithDescendants = getBlockEditorSelector('getClientIdsWithDescendants'); 3755 3756 /** 3757 * @see getGlobalBlockCount in core/block-editor store. 3758 */ 3759 const getGlobalBlockCount = getBlockEditorSelector('getGlobalBlockCount'); 3760 3761 /** 3762 * @see getBlocksByClientId in core/block-editor store. 3763 */ 3764 const getBlocksByClientId = getBlockEditorSelector('getBlocksByClientId'); 3765 3766 /** 3767 * @see getBlockCount in core/block-editor store. 3768 */ 3769 const getBlockCount = getBlockEditorSelector('getBlockCount'); 3770 3771 /** 3772 * @see getBlockSelectionStart in core/block-editor store. 3773 */ 3774 const getBlockSelectionStart = getBlockEditorSelector('getBlockSelectionStart'); 3775 3776 /** 3777 * @see getBlockSelectionEnd in core/block-editor store. 3778 */ 3779 const getBlockSelectionEnd = getBlockEditorSelector('getBlockSelectionEnd'); 3780 3781 /** 3782 * @see getSelectedBlockCount in core/block-editor store. 3783 */ 3784 const getSelectedBlockCount = getBlockEditorSelector('getSelectedBlockCount'); 3785 3786 /** 3787 * @see hasSelectedBlock in core/block-editor store. 3788 */ 3789 const hasSelectedBlock = getBlockEditorSelector('hasSelectedBlock'); 3790 3791 /** 3792 * @see getSelectedBlockClientId in core/block-editor store. 3793 */ 3794 const getSelectedBlockClientId = getBlockEditorSelector('getSelectedBlockClientId'); 3795 3796 /** 3797 * @see getSelectedBlock in core/block-editor store. 3798 */ 3799 const getSelectedBlock = getBlockEditorSelector('getSelectedBlock'); 3800 3801 /** 3802 * @see getBlockRootClientId in core/block-editor store. 3803 */ 3804 const getBlockRootClientId = getBlockEditorSelector('getBlockRootClientId'); 3805 3806 /** 3807 * @see getBlockHierarchyRootClientId in core/block-editor store. 3808 */ 3809 const getBlockHierarchyRootClientId = getBlockEditorSelector('getBlockHierarchyRootClientId'); 3810 3811 /** 3812 * @see getAdjacentBlockClientId in core/block-editor store. 3813 */ 3814 const getAdjacentBlockClientId = getBlockEditorSelector('getAdjacentBlockClientId'); 3815 3816 /** 3817 * @see getPreviousBlockClientId in core/block-editor store. 3818 */ 3819 const getPreviousBlockClientId = getBlockEditorSelector('getPreviousBlockClientId'); 3820 3821 /** 3822 * @see getNextBlockClientId in core/block-editor store. 3823 */ 3824 const getNextBlockClientId = getBlockEditorSelector('getNextBlockClientId'); 3825 3826 /** 3827 * @see getSelectedBlocksInitialCaretPosition in core/block-editor store. 3828 */ 3829 const getSelectedBlocksInitialCaretPosition = getBlockEditorSelector('getSelectedBlocksInitialCaretPosition'); 3830 3831 /** 3832 * @see getMultiSelectedBlockClientIds in core/block-editor store. 3833 */ 3834 const getMultiSelectedBlockClientIds = getBlockEditorSelector('getMultiSelectedBlockClientIds'); 3835 3836 /** 3837 * @see getMultiSelectedBlocks in core/block-editor store. 3838 */ 3839 const getMultiSelectedBlocks = getBlockEditorSelector('getMultiSelectedBlocks'); 3840 3841 /** 3842 * @see getFirstMultiSelectedBlockClientId in core/block-editor store. 3843 */ 3844 const getFirstMultiSelectedBlockClientId = getBlockEditorSelector('getFirstMultiSelectedBlockClientId'); 3845 3846 /** 3847 * @see getLastMultiSelectedBlockClientId in core/block-editor store. 3848 */ 3849 const getLastMultiSelectedBlockClientId = getBlockEditorSelector('getLastMultiSelectedBlockClientId'); 3850 3851 /** 3852 * @see isFirstMultiSelectedBlock in core/block-editor store. 3853 */ 3854 const isFirstMultiSelectedBlock = getBlockEditorSelector('isFirstMultiSelectedBlock'); 3855 3856 /** 3857 * @see isBlockMultiSelected in core/block-editor store. 3858 */ 3859 const isBlockMultiSelected = getBlockEditorSelector('isBlockMultiSelected'); 3860 3861 /** 3862 * @see isAncestorMultiSelected in core/block-editor store. 3863 */ 3864 const isAncestorMultiSelected = getBlockEditorSelector('isAncestorMultiSelected'); 3865 3866 /** 3867 * @see getMultiSelectedBlocksStartClientId in core/block-editor store. 3868 */ 3869 const getMultiSelectedBlocksStartClientId = getBlockEditorSelector('getMultiSelectedBlocksStartClientId'); 3870 3871 /** 3872 * @see getMultiSelectedBlocksEndClientId in core/block-editor store. 3873 */ 3874 const getMultiSelectedBlocksEndClientId = getBlockEditorSelector('getMultiSelectedBlocksEndClientId'); 3875 3876 /** 3877 * @see getBlockOrder in core/block-editor store. 3878 */ 3879 const getBlockOrder = getBlockEditorSelector('getBlockOrder'); 3880 3881 /** 3882 * @see getBlockIndex in core/block-editor store. 3883 */ 3884 const getBlockIndex = getBlockEditorSelector('getBlockIndex'); 3885 3886 /** 3887 * @see isBlockSelected in core/block-editor store. 3888 */ 3889 const isBlockSelected = getBlockEditorSelector('isBlockSelected'); 3890 3891 /** 3892 * @see hasSelectedInnerBlock in core/block-editor store. 3893 */ 3894 const hasSelectedInnerBlock = getBlockEditorSelector('hasSelectedInnerBlock'); 3895 3896 /** 3897 * @see isBlockWithinSelection in core/block-editor store. 3898 */ 3899 const isBlockWithinSelection = getBlockEditorSelector('isBlockWithinSelection'); 3900 3901 /** 3902 * @see hasMultiSelection in core/block-editor store. 3903 */ 3904 const hasMultiSelection = getBlockEditorSelector('hasMultiSelection'); 3905 3906 /** 3907 * @see isMultiSelecting in core/block-editor store. 3908 */ 3909 const isMultiSelecting = getBlockEditorSelector('isMultiSelecting'); 3910 3911 /** 3912 * @see isSelectionEnabled in core/block-editor store. 3913 */ 3914 const isSelectionEnabled = getBlockEditorSelector('isSelectionEnabled'); 3915 3916 /** 3917 * @see getBlockMode in core/block-editor store. 3918 */ 3919 const getBlockMode = getBlockEditorSelector('getBlockMode'); 3920 3921 /** 3922 * @see isTyping in core/block-editor store. 3923 */ 3924 const isTyping = getBlockEditorSelector('isTyping'); 3925 3926 /** 3927 * @see isCaretWithinFormattedText in core/block-editor store. 3928 */ 3929 const isCaretWithinFormattedText = getBlockEditorSelector('isCaretWithinFormattedText'); 3930 3931 /** 3932 * @see getBlockInsertionPoint in core/block-editor store. 3933 */ 3934 const getBlockInsertionPoint = getBlockEditorSelector('getBlockInsertionPoint'); 3935 3936 /** 3937 * @see isBlockInsertionPointVisible in core/block-editor store. 3938 */ 3939 const isBlockInsertionPointVisible = getBlockEditorSelector('isBlockInsertionPointVisible'); 3940 3941 /** 3942 * @see isValidTemplate in core/block-editor store. 3943 */ 3944 const isValidTemplate = getBlockEditorSelector('isValidTemplate'); 3945 3946 /** 3947 * @see getTemplate in core/block-editor store. 3948 */ 3949 const getTemplate = getBlockEditorSelector('getTemplate'); 3950 3951 /** 3952 * @see getTemplateLock in core/block-editor store. 3953 */ 3954 const getTemplateLock = getBlockEditorSelector('getTemplateLock'); 3955 3956 /** 3957 * @see canInsertBlockType in core/block-editor store. 3958 */ 3959 const canInsertBlockType = getBlockEditorSelector('canInsertBlockType'); 3960 3961 /** 3962 * @see getInserterItems in core/block-editor store. 3963 */ 3964 const getInserterItems = getBlockEditorSelector('getInserterItems'); 3965 3966 /** 3967 * @see hasInserterItems in core/block-editor store. 3968 */ 3969 const hasInserterItems = getBlockEditorSelector('hasInserterItems'); 3970 3971 /** 3972 * @see getBlockListSettings in core/block-editor store. 3973 */ 3974 const getBlockListSettings = getBlockEditorSelector('getBlockListSettings'); 3975 3976 /** 3977 * Returns the default template types. 3978 * 3979 * @param {Object} state Global application state. 3980 * 3981 * @return {Object} The template types. 3982 */ 3983 function __experimentalGetDefaultTemplateTypes(state) { 3984 return getEditorSettings(state)?.defaultTemplateTypes; 3985 } 3986 3987 /** 3988 * Returns the default template part areas. 3989 * 3990 * @param {Object} state Global application state. 3991 * 3992 * @return {Array} The template part areas. 3993 */ 3994 const __experimentalGetDefaultTemplatePartAreas = rememo(state => { 3995 const areas = getEditorSettings(state)?.defaultTemplatePartAreas || []; 3996 return areas?.map(item => { 3997 return { 3998 ...item, 3999 icon: getTemplatePartIcon(item.icon) 4000 }; 4001 }); 4002 }, state => [getEditorSettings(state)?.defaultTemplatePartAreas]); 4003 4004 /** 4005 * Returns a default template type searched by slug. 4006 * 4007 * @param {Object} state Global application state. 4008 * @param {string} slug The template type slug. 4009 * 4010 * @return {Object} The template type. 4011 */ 4012 const __experimentalGetDefaultTemplateType = rememo((state, slug) => { 4013 var _Object$values$find; 4014 const templateTypes = __experimentalGetDefaultTemplateTypes(state); 4015 if (!templateTypes) { 4016 return EMPTY_OBJECT; 4017 } 4018 return (_Object$values$find = Object.values(templateTypes).find(type => type.slug === slug)) !== null && _Object$values$find !== void 0 ? _Object$values$find : EMPTY_OBJECT; 4019 }, (state, slug) => [__experimentalGetDefaultTemplateTypes(state), slug]); 4020 4021 /** 4022 * Given a template entity, return information about it which is ready to be 4023 * rendered, such as the title, description, and icon. 4024 * 4025 * @param {Object} state Global application state. 4026 * @param {Object} template The template for which we need information. 4027 * @return {Object} Information about the template, including title, description, and icon. 4028 */ 4029 function __experimentalGetTemplateInfo(state, template) { 4030 if (!template) { 4031 return EMPTY_OBJECT; 4032 } 4033 const { 4034 description, 4035 slug, 4036 title, 4037 area 4038 } = template; 4039 const { 4040 title: defaultTitle, 4041 description: defaultDescription 4042 } = __experimentalGetDefaultTemplateType(state, slug); 4043 const templateTitle = typeof title === 'string' ? title : title?.rendered; 4044 const templateDescription = typeof description === 'string' ? description : description?.raw; 4045 const templateIcon = __experimentalGetDefaultTemplatePartAreas(state).find(item => area === item.area)?.icon || library_layout; 4046 return { 4047 title: templateTitle && templateTitle !== slug ? templateTitle : defaultTitle || slug, 4048 description: templateDescription || defaultDescription, 4049 icon: templateIcon 4050 }; 4051 } 4052 4053 /** 4054 * Returns a post type label depending on the current post. 4055 * 4056 * @param {Object} state Global application state. 4057 * 4058 * @return {string|undefined} The post type label if available, otherwise undefined. 4059 */ 4060 const getPostTypeLabel = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { 4061 const currentPostType = getCurrentPostType(state); 4062 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(currentPostType); 4063 // Disable reason: Post type labels object is shaped like this. 4064 // eslint-disable-next-line camelcase 4065 return postType?.labels?.singular_name; 4066 }); 4067 4068 ;// CONCATENATED MODULE: external ["wp","apiFetch"] 4069 const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"]; 4070 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject); 4071 ;// CONCATENATED MODULE: external ["wp","notices"] 4072 const external_wp_notices_namespaceObject = window["wp"]["notices"]; 4073 ;// CONCATENATED MODULE: external ["wp","hooks"] 4074 const external_wp_hooks_namespaceObject = window["wp"]["hooks"]; 4075 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/local-autosave.js 4076 /** 4077 * Function returning a sessionStorage key to set or retrieve a given post's 4078 * automatic session backup. 4079 * 4080 * Keys are crucially prefixed with 'wp-autosave-' so that wp-login.php's 4081 * `loggedout` handler can clear sessionStorage of any user-private content. 4082 * 4083 * @see https://github.com/WordPress/wordpress-develop/blob/6dad32d2aed47e6c0cf2aee8410645f6d7aba6bd/src/wp-login.php#L103 4084 * 4085 * @param {string} postId Post ID. 4086 * @param {boolean} isPostNew Whether post new. 4087 * 4088 * @return {string} sessionStorage key 4089 */ 4090 function postKey(postId, isPostNew) { 4091 return `wp-autosave-block-editor-post-$isPostNew ? 'auto-draft' : postId}`; 4092 } 4093 function localAutosaveGet(postId, isPostNew) { 4094 return window.sessionStorage.getItem(postKey(postId, isPostNew)); 4095 } 4096 function localAutosaveSet(postId, isPostNew, title, content, excerpt) { 4097 window.sessionStorage.setItem(postKey(postId, isPostNew), JSON.stringify({ 4098 post_title: title, 4099 content, 4100 excerpt 4101 })); 4102 } 4103 function localAutosaveClear(postId, isPostNew) { 4104 window.sessionStorage.removeItem(postKey(postId, isPostNew)); 4105 } 4106 4107 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/utils/notice-builder.js 4108 /** 4109 * WordPress dependencies 4110 */ 4111 4112 4113 /** 4114 * Internal dependencies 4115 */ 4116 4117 4118 /** 4119 * Builds the arguments for a success notification dispatch. 4120 * 4121 * @param {Object} data Incoming data to build the arguments from. 4122 * 4123 * @return {Array} Arguments for dispatch. An empty array signals no 4124 * notification should be sent. 4125 */ 4126 function getNotificationArgumentsForSaveSuccess(data) { 4127 var _postType$viewable; 4128 const { 4129 previousPost, 4130 post, 4131 postType 4132 } = data; 4133 // Autosaves are neither shown a notice nor redirected. 4134 if (data.options?.isAutosave) { 4135 return []; 4136 } 4137 const publishStatus = ['publish', 'private', 'future']; 4138 const isPublished = publishStatus.includes(previousPost.status); 4139 const willPublish = publishStatus.includes(post.status); 4140 const willTrash = post.status === 'trash' && previousPost.status !== 'trash'; 4141 let noticeMessage; 4142 let shouldShowLink = (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false; 4143 let isDraft; 4144 4145 // Always should a notice, which will be spoken for accessibility. 4146 if (willTrash) { 4147 noticeMessage = postType.labels.item_trashed; 4148 shouldShowLink = false; 4149 } else if (!isPublished && !willPublish) { 4150 // If saving a non-published post, don't show notice. 4151 noticeMessage = (0,external_wp_i18n_namespaceObject.__)('Draft saved.'); 4152 isDraft = true; 4153 } else if (isPublished && !willPublish) { 4154 // If undoing publish status, show specific notice. 4155 noticeMessage = postType.labels.item_reverted_to_draft; 4156 shouldShowLink = false; 4157 } else if (!isPublished && willPublish) { 4158 // If publishing or scheduling a post, show the corresponding 4159 // publish message. 4160 noticeMessage = { 4161 publish: postType.labels.item_published, 4162 private: postType.labels.item_published_privately, 4163 future: postType.labels.item_scheduled 4164 }[post.status]; 4165 } else { 4166 // Generic fallback notice. 4167 noticeMessage = postType.labels.item_updated; 4168 } 4169 const actions = []; 4170 if (shouldShowLink) { 4171 actions.push({ 4172 label: isDraft ? (0,external_wp_i18n_namespaceObject.__)('View Preview') : postType.labels.view_item, 4173 url: post.link 4174 }); 4175 } 4176 return [noticeMessage, { 4177 id: SAVE_POST_NOTICE_ID, 4178 type: 'snackbar', 4179 actions 4180 }]; 4181 } 4182 4183 /** 4184 * Builds the fail notification arguments for dispatch. 4185 * 4186 * @param {Object} data Incoming data to build the arguments with. 4187 * 4188 * @return {Array} Arguments for dispatch. An empty array signals no 4189 * notification should be sent. 4190 */ 4191 function getNotificationArgumentsForSaveFail(data) { 4192 const { 4193 post, 4194 edits, 4195 error 4196 } = data; 4197 if (error && 'rest_autosave_no_changes' === error.code) { 4198 // Autosave requested a new autosave, but there were no changes. This shouldn't 4199 // result in an error notice for the user. 4200 return []; 4201 } 4202 const publishStatus = ['publish', 'private', 'future']; 4203 const isPublished = publishStatus.indexOf(post.status) !== -1; 4204 // If the post was being published, we show the corresponding publish error message 4205 // Unless we publish an "updating failed" message. 4206 const messages = { 4207 publish: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'), 4208 private: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'), 4209 future: (0,external_wp_i18n_namespaceObject.__)('Scheduling failed.') 4210 }; 4211 let noticeMessage = !isPublished && publishStatus.indexOf(edits.status) !== -1 ? messages[edits.status] : (0,external_wp_i18n_namespaceObject.__)('Updating failed.'); 4212 4213 // Check if message string contains HTML. Notice text is currently only 4214 // supported as plaintext, and stripping the tags may muddle the meaning. 4215 if (error.message && !/<\/?[^>]*>/.test(error.message)) { 4216 noticeMessage = [noticeMessage, error.message].join(' '); 4217 } 4218 return [noticeMessage, { 4219 id: SAVE_POST_NOTICE_ID 4220 }]; 4221 } 4222 4223 /** 4224 * Builds the trash fail notification arguments for dispatch. 4225 * 4226 * @param {Object} data 4227 * 4228 * @return {Array} Arguments for dispatch. 4229 */ 4230 function getNotificationArgumentsForTrashFail(data) { 4231 return [data.error.message && data.error.code !== 'unknown_error' ? data.error.message : (0,external_wp_i18n_namespaceObject.__)('Trashing failed'), { 4232 id: TRASH_POST_NOTICE_ID 4233 }]; 4234 } 4235 4236 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/actions.js 4237 /** 4238 * WordPress dependencies 4239 */ 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 /** 4250 * Internal dependencies 4251 */ 4252 4253 4254 4255 4256 /** 4257 * Returns an action generator used in signalling that editor has initialized with 4258 * the specified post object and editor settings. 4259 * 4260 * @param {Object} post Post object. 4261 * @param {Object} edits Initial edited attributes object. 4262 * @param {Array?} template Block Template. 4263 */ 4264 const setupEditor = (post, edits, template) => ({ 4265 dispatch 4266 }) => { 4267 dispatch.setEditedPost(post.type, post.id); 4268 // Apply a template for new posts only, if exists. 4269 const isNewPost = post.status === 'auto-draft'; 4270 if (isNewPost && template) { 4271 // In order to ensure maximum of a single parse during setup, edits are 4272 // included as part of editor setup action. Assume edited content as 4273 // canonical if provided, falling back to post. 4274 let content; 4275 if ('content' in edits) { 4276 content = edits.content; 4277 } else { 4278 content = post.content.raw; 4279 } 4280 let blocks = (0,external_wp_blocks_namespaceObject.parse)(content); 4281 blocks = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(blocks, template); 4282 dispatch.resetEditorBlocks(blocks, { 4283 __unstableShouldCreateUndoLevel: false 4284 }); 4285 } 4286 if (edits && Object.values(edits).some(([key, edit]) => { 4287 var _post$key$raw; 4288 return edit !== ((_post$key$raw = post[key]?.raw) !== null && _post$key$raw !== void 0 ? _post$key$raw : post[key]); 4289 })) { 4290 dispatch.editPost(edits); 4291 } 4292 }; 4293 4294 /** 4295 * Returns an action object signalling that the editor is being destroyed and 4296 * that any necessary state or side-effect cleanup should occur. 4297 * 4298 * @deprecated 4299 * 4300 * @return {Object} Action object. 4301 */ 4302 function __experimentalTearDownEditor() { 4303 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).__experimentalTearDownEditor", { 4304 since: '6.5' 4305 }); 4306 return { 4307 type: 'DO_NOTHING' 4308 }; 4309 } 4310 4311 /** 4312 * Returns an action object used in signalling that the latest version of the 4313 * post has been received, either by initialization or save. 4314 * 4315 * @deprecated Since WordPress 6.0. 4316 */ 4317 function resetPost() { 4318 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).resetPost", { 4319 since: '6.0', 4320 version: '6.3', 4321 alternative: 'Initialize the editor with the setupEditorState action' 4322 }); 4323 return { 4324 type: 'DO_NOTHING' 4325 }; 4326 } 4327 4328 /** 4329 * Returns an action object used in signalling that a patch of updates for the 4330 * latest version of the post have been received. 4331 * 4332 * @return {Object} Action object. 4333 * @deprecated since Gutenberg 9.7.0. 4334 */ 4335 function updatePost() { 4336 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).updatePost", { 4337 since: '5.7', 4338 alternative: 'Use the core entities store instead' 4339 }); 4340 return { 4341 type: 'DO_NOTHING' 4342 }; 4343 } 4344 4345 /** 4346 * Setup the editor state. 4347 * 4348 * @deprecated 4349 * 4350 * @param {Object} post Post object. 4351 */ 4352 function setupEditorState(post) { 4353 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).setupEditorState", { 4354 since: '6.5', 4355 alternative: "wp.data.dispatch( 'core/editor' ).setEditedPost" 4356 }); 4357 return setEditedPost(post.type, post.id); 4358 } 4359 4360 /** 4361 * Returns an action that sets the current post Type and post ID. 4362 * 4363 * @param {string} postType Post Type. 4364 * @param {string} postId Post ID. 4365 * 4366 * @return {Object} Action object. 4367 */ 4368 function setEditedPost(postType, postId) { 4369 return { 4370 type: 'SET_EDITED_POST', 4371 postType, 4372 postId 4373 }; 4374 } 4375 4376 /** 4377 * Returns an action object used in signalling that attributes of the post have 4378 * been edited. 4379 * 4380 * @param {Object} edits Post attributes to edit. 4381 * @param {Object} options Options for the edit. 4382 */ 4383 const editPost = (edits, options) => ({ 4384 select, 4385 registry 4386 }) => { 4387 const { 4388 id, 4389 type 4390 } = select.getCurrentPost(); 4391 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', type, id, edits, options); 4392 }; 4393 4394 /** 4395 * Action for saving the current post in the editor. 4396 * 4397 * @param {Object} options 4398 */ 4399 const savePost = (options = {}) => async ({ 4400 select, 4401 dispatch, 4402 registry 4403 }) => { 4404 if (!select.isEditedPostSaveable()) { 4405 return; 4406 } 4407 const content = select.getEditedPostContent(); 4408 if (!options.isAutosave) { 4409 dispatch.editPost({ 4410 content 4411 }, { 4412 undoIgnore: true 4413 }); 4414 } 4415 const previousRecord = select.getCurrentPost(); 4416 const edits = { 4417 id: previousRecord.id, 4418 ...registry.select(external_wp_coreData_namespaceObject.store).getEntityRecordNonTransientEdits('postType', previousRecord.type, previousRecord.id), 4419 content 4420 }; 4421 dispatch({ 4422 type: 'REQUEST_POST_UPDATE_START', 4423 options 4424 }); 4425 await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', previousRecord.type, edits, options); 4426 let error = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', previousRecord.type, previousRecord.id); 4427 if (!error) { 4428 await (0,external_wp_hooks_namespaceObject.applyFilters)('editor.__unstableSavePost', Promise.resolve(), options).catch(err => { 4429 error = err; 4430 }); 4431 } 4432 dispatch({ 4433 type: 'REQUEST_POST_UPDATE_FINISH', 4434 options 4435 }); 4436 if (error) { 4437 const args = getNotificationArgumentsForSaveFail({ 4438 post: previousRecord, 4439 edits, 4440 error 4441 }); 4442 if (args.length) { 4443 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...args); 4444 } 4445 } else { 4446 const updatedRecord = select.getCurrentPost(); 4447 const args = getNotificationArgumentsForSaveSuccess({ 4448 previousPost: previousRecord, 4449 post: updatedRecord, 4450 postType: await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(updatedRecord.type), 4451 options 4452 }); 4453 if (args.length) { 4454 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(...args); 4455 } 4456 // Make sure that any edits after saving create an undo level and are 4457 // considered for change detection. 4458 if (!options.isAutosave) { 4459 registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableMarkLastChangeAsPersistent(); 4460 } 4461 } 4462 }; 4463 4464 /** 4465 * Action for refreshing the current post. 4466 * 4467 * @deprecated Since WordPress 6.0. 4468 */ 4469 function refreshPost() { 4470 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).refreshPost", { 4471 since: '6.0', 4472 version: '6.3', 4473 alternative: 'Use the core entities store instead' 4474 }); 4475 return { 4476 type: 'DO_NOTHING' 4477 }; 4478 } 4479 4480 /** 4481 * Action for trashing the current post in the editor. 4482 */ 4483 const trashPost = () => async ({ 4484 select, 4485 dispatch, 4486 registry 4487 }) => { 4488 const postTypeSlug = select.getCurrentPostType(); 4489 const postType = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug); 4490 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(TRASH_POST_NOTICE_ID); 4491 const { 4492 rest_base: restBase, 4493 rest_namespace: restNamespace = 'wp/v2' 4494 } = postType; 4495 dispatch({ 4496 type: 'REQUEST_POST_DELETE_START' 4497 }); 4498 try { 4499 const post = select.getCurrentPost(); 4500 await external_wp_apiFetch_default()({ 4501 path: `/$restNamespace}/$restBase}/$post.id}`, 4502 method: 'DELETE' 4503 }); 4504 await dispatch.savePost(); 4505 } catch (error) { 4506 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...getNotificationArgumentsForTrashFail({ 4507 error 4508 })); 4509 } 4510 dispatch({ 4511 type: 'REQUEST_POST_DELETE_FINISH' 4512 }); 4513 }; 4514 4515 /** 4516 * Action that autosaves the current post. This 4517 * includes server-side autosaving (default) and client-side (a.k.a. local) 4518 * autosaving (e.g. on the Web, the post might be committed to Session 4519 * Storage). 4520 * 4521 * @param {Object?} options Extra flags to identify the autosave. 4522 */ 4523 const autosave = ({ 4524 local = false, 4525 ...options 4526 } = {}) => async ({ 4527 select, 4528 dispatch 4529 }) => { 4530 const post = select.getCurrentPost(); 4531 4532 // Currently template autosaving is not supported. 4533 if (post.type === 'wp_template') { 4534 return; 4535 } 4536 if (local) { 4537 const isPostNew = select.isEditedPostNew(); 4538 const title = select.getEditedPostAttribute('title'); 4539 const content = select.getEditedPostAttribute('content'); 4540 const excerpt = select.getEditedPostAttribute('excerpt'); 4541 localAutosaveSet(post.id, isPostNew, title, content, excerpt); 4542 } else { 4543 await dispatch.savePost({ 4544 isAutosave: true, 4545 ...options 4546 }); 4547 } 4548 }; 4549 const __unstableSaveForPreview = ({ 4550 forceIsAutosaveable 4551 } = {}) => async ({ 4552 select, 4553 dispatch 4554 }) => { 4555 if ((forceIsAutosaveable || select.isEditedPostAutosaveable()) && !select.isPostLocked()) { 4556 const isDraft = ['draft', 'auto-draft'].includes(select.getEditedPostAttribute('status')); 4557 if (isDraft) { 4558 await dispatch.savePost({ 4559 isPreview: true 4560 }); 4561 } else { 4562 await dispatch.autosave({ 4563 isPreview: true 4564 }); 4565 } 4566 } 4567 return select.getEditedPostPreviewLink(); 4568 }; 4569 4570 /** 4571 * Action that restores last popped state in undo history. 4572 */ 4573 const redo = () => ({ 4574 registry 4575 }) => { 4576 registry.dispatch(external_wp_coreData_namespaceObject.store).redo(); 4577 }; 4578 4579 /** 4580 * Action that pops a record from undo history and undoes the edit. 4581 */ 4582 const undo = () => ({ 4583 registry 4584 }) => { 4585 registry.dispatch(external_wp_coreData_namespaceObject.store).undo(); 4586 }; 4587 4588 /** 4589 * Action that creates an undo history record. 4590 * 4591 * @deprecated Since WordPress 6.0 4592 */ 4593 function createUndoLevel() { 4594 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).createUndoLevel", { 4595 since: '6.0', 4596 version: '6.3', 4597 alternative: 'Use the core entities store instead' 4598 }); 4599 return { 4600 type: 'DO_NOTHING' 4601 }; 4602 } 4603 4604 /** 4605 * Action that locks the editor. 4606 * 4607 * @param {Object} lock Details about the post lock status, user, and nonce. 4608 * @return {Object} Action object. 4609 */ 4610 function updatePostLock(lock) { 4611 return { 4612 type: 'UPDATE_POST_LOCK', 4613 lock 4614 }; 4615 } 4616 4617 /** 4618 * Enable the publish sidebar. 4619 */ 4620 const enablePublishSidebar = () => ({ 4621 registry 4622 }) => { 4623 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core/edit-post', 'isPublishSidebarEnabled', true); 4624 }; 4625 4626 /** 4627 * Disables the publish sidebar. 4628 */ 4629 const disablePublishSidebar = () => ({ 4630 registry 4631 }) => { 4632 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core/edit-post', 'isPublishSidebarEnabled', false); 4633 }; 4634 4635 /** 4636 * Action that locks post saving. 4637 * 4638 * @param {string} lockName The lock name. 4639 * 4640 * @example 4641 * ``` 4642 * const { subscribe } = wp.data; 4643 * 4644 * const initialPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' ); 4645 * 4646 * // Only allow publishing posts that are set to a future date. 4647 * if ( 'publish' !== initialPostStatus ) { 4648 * 4649 * // Track locking. 4650 * let locked = false; 4651 * 4652 * // Watch for the publish event. 4653 * let unssubscribe = subscribe( () => { 4654 * const currentPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' ); 4655 * if ( 'publish' !== currentPostStatus ) { 4656 * 4657 * // Compare the post date to the current date, lock the post if the date isn't in the future. 4658 * const postDate = new Date( wp.data.select( 'core/editor' ).getEditedPostAttribute( 'date' ) ); 4659 * const currentDate = new Date(); 4660 * if ( postDate.getTime() <= currentDate.getTime() ) { 4661 * if ( ! locked ) { 4662 * locked = true; 4663 * wp.data.dispatch( 'core/editor' ).lockPostSaving( 'futurelock' ); 4664 * } 4665 * } else { 4666 * if ( locked ) { 4667 * locked = false; 4668 * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'futurelock' ); 4669 * } 4670 * } 4671 * } 4672 * } ); 4673 * } 4674 * ``` 4675 * 4676 * @return {Object} Action object 4677 */ 4678 function lockPostSaving(lockName) { 4679 return { 4680 type: 'LOCK_POST_SAVING', 4681 lockName 4682 }; 4683 } 4684 4685 /** 4686 * Action that unlocks post saving. 4687 * 4688 * @param {string} lockName The lock name. 4689 * 4690 * @example 4691 * ``` 4692 * // Unlock post saving with the lock key `mylock`: 4693 * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'mylock' ); 4694 * ``` 4695 * 4696 * @return {Object} Action object 4697 */ 4698 function unlockPostSaving(lockName) { 4699 return { 4700 type: 'UNLOCK_POST_SAVING', 4701 lockName 4702 }; 4703 } 4704 4705 /** 4706 * Action that locks post autosaving. 4707 * 4708 * @param {string} lockName The lock name. 4709 * 4710 * @example 4711 * ``` 4712 * // Lock post autosaving with the lock key `mylock`: 4713 * wp.data.dispatch( 'core/editor' ).lockPostAutosaving( 'mylock' ); 4714 * ``` 4715 * 4716 * @return {Object} Action object 4717 */ 4718 function lockPostAutosaving(lockName) { 4719 return { 4720 type: 'LOCK_POST_AUTOSAVING', 4721 lockName 4722 }; 4723 } 4724 4725 /** 4726 * Action that unlocks post autosaving. 4727 * 4728 * @param {string} lockName The lock name. 4729 * 4730 * @example 4731 * ``` 4732 * // Unlock post saving with the lock key `mylock`: 4733 * wp.data.dispatch( 'core/editor' ).unlockPostAutosaving( 'mylock' ); 4734 * ``` 4735 * 4736 * @return {Object} Action object 4737 */ 4738 function unlockPostAutosaving(lockName) { 4739 return { 4740 type: 'UNLOCK_POST_AUTOSAVING', 4741 lockName 4742 }; 4743 } 4744 4745 /** 4746 * Returns an action object used to signal that the blocks have been updated. 4747 * 4748 * @param {Array} blocks Block Array. 4749 * @param {?Object} options Optional options. 4750 */ 4751 const resetEditorBlocks = (blocks, options = {}) => ({ 4752 select, 4753 dispatch, 4754 registry 4755 }) => { 4756 const { 4757 __unstableShouldCreateUndoLevel, 4758 selection 4759 } = options; 4760 const edits = { 4761 blocks, 4762 selection 4763 }; 4764 if (__unstableShouldCreateUndoLevel !== false) { 4765 const { 4766 id, 4767 type 4768 } = select.getCurrentPost(); 4769 const noChange = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', type, id).blocks === edits.blocks; 4770 if (noChange) { 4771 registry.dispatch(external_wp_coreData_namespaceObject.store).__unstableCreateUndoLevel('postType', type, id); 4772 return; 4773 } 4774 4775 // We create a new function here on every persistent edit 4776 // to make sure the edit makes the post dirty and creates 4777 // a new undo level. 4778 edits.content = ({ 4779 blocks: blocksForSerialization = [] 4780 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization); 4781 } 4782 dispatch.editPost(edits); 4783 }; 4784 4785 /* 4786 * Returns an action object used in signalling that the post editor settings have been updated. 4787 * 4788 * @param {Object} settings Updated settings 4789 * 4790 * @return {Object} Action object 4791 */ 4792 function updateEditorSettings(settings) { 4793 return { 4794 type: 'UPDATE_EDITOR_SETTINGS', 4795 settings 4796 }; 4797 } 4798 4799 /** 4800 * Returns an action used to set the rendering mode of the post editor. We support multiple rendering modes: 4801 * 4802 * - `all`: This is the default mode. It renders the post editor with all the features available. If a template is provided, it's preferred over the post. 4803 * - `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. 4804 * - `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. 4805 * 4806 * @param {string} mode Mode (one of 'post-only' or 'template-locked'). 4807 */ 4808 const setRenderingMode = mode => ({ 4809 dispatch, 4810 registry, 4811 select 4812 }) => { 4813 if (select.__unstableIsEditorReady()) { 4814 // We clear the block selection but we also need to clear the selection from the core store. 4815 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock(); 4816 dispatch.editPost({ 4817 selection: undefined 4818 }, { 4819 undoIgnore: true 4820 }); 4821 } 4822 dispatch({ 4823 type: 'SET_RENDERING_MODE', 4824 mode 4825 }); 4826 }; 4827 4828 /** 4829 * Action that changes the width of the editing canvas. 4830 * 4831 * @param {string} deviceType 4832 * 4833 * @return {Object} Action object. 4834 */ 4835 function setDeviceType(deviceType) { 4836 return { 4837 type: 'SET_DEVICE_TYPE', 4838 deviceType 4839 }; 4840 } 4841 4842 /** 4843 * Returns an action object used to enable or disable a panel in the editor. 4844 * 4845 * @param {string} panelName A string that identifies the panel to enable or disable. 4846 * 4847 * @return {Object} Action object. 4848 */ 4849 const toggleEditorPanelEnabled = panelName => ({ 4850 registry 4851 }) => { 4852 var _registry$select$get; 4853 const inactivePanels = (_registry$select$get = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'inactivePanels')) !== null && _registry$select$get !== void 0 ? _registry$select$get : []; 4854 const isPanelInactive = !!inactivePanels?.includes(panelName); 4855 4856 // If the panel is inactive, remove it to enable it, else add it to 4857 // make it inactive. 4858 let updatedInactivePanels; 4859 if (isPanelInactive) { 4860 updatedInactivePanels = inactivePanels.filter(invactivePanelName => invactivePanelName !== panelName); 4861 } else { 4862 updatedInactivePanels = [...inactivePanels, panelName]; 4863 } 4864 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'inactivePanels', updatedInactivePanels); 4865 }; 4866 4867 /** 4868 * Opens a closed panel and closes an open panel. 4869 * 4870 * @param {string} panelName A string that identifies the panel to open or close. 4871 */ 4872 const toggleEditorPanelOpened = panelName => ({ 4873 registry 4874 }) => { 4875 var _registry$select$get2; 4876 const openPanels = (_registry$select$get2 = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'openPanels')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : []; 4877 const isPanelOpen = !!openPanels?.includes(panelName); 4878 4879 // If the panel is open, remove it to close it, else add it to 4880 // make it open. 4881 let updatedOpenPanels; 4882 if (isPanelOpen) { 4883 updatedOpenPanels = openPanels.filter(openPanelName => openPanelName !== panelName); 4884 } else { 4885 updatedOpenPanels = [...openPanels, panelName]; 4886 } 4887 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'openPanels', updatedOpenPanels); 4888 }; 4889 4890 /** 4891 * Returns an action object used to remove a panel from the editor. 4892 * 4893 * @param {string} panelName A string that identifies the panel to remove. 4894 * 4895 * @return {Object} Action object. 4896 */ 4897 function removeEditorPanel(panelName) { 4898 return { 4899 type: 'REMOVE_PANEL', 4900 panelName 4901 }; 4902 } 4903 4904 /** 4905 * Returns an action object used to open/close the inserter. 4906 * 4907 * @param {boolean|Object} value Whether the inserter should be 4908 * opened (true) or closed (false). 4909 * To specify an insertion point, 4910 * use an object. 4911 * @param {string} value.rootClientId The root client ID to insert at. 4912 * @param {number} value.insertionIndex The index to insert at. 4913 * 4914 * @return {Object} Action object. 4915 */ 4916 function setIsInserterOpened(value) { 4917 return { 4918 type: 'SET_IS_INSERTER_OPENED', 4919 value 4920 }; 4921 } 4922 4923 /** 4924 * Returns an action object used to open/close the list view. 4925 * 4926 * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed. 4927 * @return {Object} Action object. 4928 */ 4929 function setIsListViewOpened(isOpen) { 4930 return { 4931 type: 'SET_IS_LIST_VIEW_OPENED', 4932 isOpen 4933 }; 4934 } 4935 4936 /** 4937 * Backward compatibility 4938 */ 4939 4940 const getBlockEditorAction = name => (...args) => ({ 4941 registry 4942 }) => { 4943 external_wp_deprecated_default()("`wp.data.dispatch( 'core/editor' )." + name + '`', { 4944 since: '5.3', 4945 alternative: "`wp.data.dispatch( 'core/block-editor' )." + name + '`', 4946 version: '6.2' 4947 }); 4948 registry.dispatch(external_wp_blockEditor_namespaceObject.store)[name](...args); 4949 }; 4950 4951 /** 4952 * @see resetBlocks in core/block-editor store. 4953 */ 4954 const resetBlocks = getBlockEditorAction('resetBlocks'); 4955 4956 /** 4957 * @see receiveBlocks in core/block-editor store. 4958 */ 4959 const receiveBlocks = getBlockEditorAction('receiveBlocks'); 4960 4961 /** 4962 * @see updateBlock in core/block-editor store. 4963 */ 4964 const updateBlock = getBlockEditorAction('updateBlock'); 4965 4966 /** 4967 * @see updateBlockAttributes in core/block-editor store. 4968 */ 4969 const updateBlockAttributes = getBlockEditorAction('updateBlockAttributes'); 4970 4971 /** 4972 * @see selectBlock in core/block-editor store. 4973 */ 4974 const selectBlock = getBlockEditorAction('selectBlock'); 4975 4976 /** 4977 * @see startMultiSelect in core/block-editor store. 4978 */ 4979 const startMultiSelect = getBlockEditorAction('startMultiSelect'); 4980 4981 /** 4982 * @see stopMultiSelect in core/block-editor store. 4983 */ 4984 const stopMultiSelect = getBlockEditorAction('stopMultiSelect'); 4985 4986 /** 4987 * @see multiSelect in core/block-editor store. 4988 */ 4989 const multiSelect = getBlockEditorAction('multiSelect'); 4990 4991 /** 4992 * @see clearSelectedBlock in core/block-editor store. 4993 */ 4994 const clearSelectedBlock = getBlockEditorAction('clearSelectedBlock'); 4995 4996 /** 4997 * @see toggleSelection in core/block-editor store. 4998 */ 4999 const toggleSelection = getBlockEditorAction('toggleSelection'); 5000 5001 /** 5002 * @see replaceBlocks in core/block-editor store. 5003 */ 5004 const replaceBlocks = getBlockEditorAction('replaceBlocks'); 5005 5006 /** 5007 * @see replaceBlock in core/block-editor store. 5008 */ 5009 const replaceBlock = getBlockEditorAction('replaceBlock'); 5010 5011 /** 5012 * @see moveBlocksDown in core/block-editor store. 5013 */ 5014 const moveBlocksDown = getBlockEditorAction('moveBlocksDown'); 5015 5016 /** 5017 * @see moveBlocksUp in core/block-editor store. 5018 */ 5019 const moveBlocksUp = getBlockEditorAction('moveBlocksUp'); 5020 5021 /** 5022 * @see moveBlockToPosition in core/block-editor store. 5023 */ 5024 const moveBlockToPosition = getBlockEditorAction('moveBlockToPosition'); 5025 5026 /** 5027 * @see insertBlock in core/block-editor store. 5028 */ 5029 const insertBlock = getBlockEditorAction('insertBlock'); 5030 5031 /** 5032 * @see insertBlocks in core/block-editor store. 5033 */ 5034 const insertBlocks = getBlockEditorAction('insertBlocks'); 5035 5036 /** 5037 * @see showInsertionPoint in core/block-editor store. 5038 */ 5039 const showInsertionPoint = getBlockEditorAction('showInsertionPoint'); 5040 5041 /** 5042 * @see hideInsertionPoint in core/block-editor store. 5043 */ 5044 const hideInsertionPoint = getBlockEditorAction('hideInsertionPoint'); 5045 5046 /** 5047 * @see setTemplateValidity in core/block-editor store. 5048 */ 5049 const setTemplateValidity = getBlockEditorAction('setTemplateValidity'); 5050 5051 /** 5052 * @see synchronizeTemplate in core/block-editor store. 5053 */ 5054 const synchronizeTemplate = getBlockEditorAction('synchronizeTemplate'); 5055 5056 /** 5057 * @see mergeBlocks in core/block-editor store. 5058 */ 5059 const mergeBlocks = getBlockEditorAction('mergeBlocks'); 5060 5061 /** 5062 * @see removeBlocks in core/block-editor store. 5063 */ 5064 const removeBlocks = getBlockEditorAction('removeBlocks'); 5065 5066 /** 5067 * @see removeBlock in core/block-editor store. 5068 */ 5069 const removeBlock = getBlockEditorAction('removeBlock'); 5070 5071 /** 5072 * @see toggleBlockMode in core/block-editor store. 5073 */ 5074 const toggleBlockMode = getBlockEditorAction('toggleBlockMode'); 5075 5076 /** 5077 * @see startTyping in core/block-editor store. 5078 */ 5079 const startTyping = getBlockEditorAction('startTyping'); 5080 5081 /** 5082 * @see stopTyping in core/block-editor store. 5083 */ 5084 const stopTyping = getBlockEditorAction('stopTyping'); 5085 5086 /** 5087 * @see enterFormattedText in core/block-editor store. 5088 */ 5089 const enterFormattedText = getBlockEditorAction('enterFormattedText'); 5090 5091 /** 5092 * @see exitFormattedText in core/block-editor store. 5093 */ 5094 const exitFormattedText = getBlockEditorAction('exitFormattedText'); 5095 5096 /** 5097 * @see insertDefaultBlock in core/block-editor store. 5098 */ 5099 const insertDefaultBlock = getBlockEditorAction('insertDefaultBlock'); 5100 5101 /** 5102 * @see updateBlockListSettings in core/block-editor store. 5103 */ 5104 const updateBlockListSettings = getBlockEditorAction('updateBlockListSettings'); 5105 5106 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/private-actions.js 5107 /** 5108 * WordPress dependencies 5109 */ 5110 5111 5112 5113 5114 5115 /** 5116 * Returns an action object used to set which template is currently being used/edited. 5117 * 5118 * @param {string} id Template Id. 5119 * 5120 * @return {Object} Action object. 5121 */ 5122 function setCurrentTemplateId(id) { 5123 return { 5124 type: 'SET_CURRENT_TEMPLATE_ID', 5125 id 5126 }; 5127 } 5128 5129 /** 5130 * Create a block based template. 5131 * 5132 * @param {Object?} template Template to create and assign. 5133 */ 5134 const createTemplate = template => async ({ 5135 select, 5136 dispatch, 5137 registry 5138 }) => { 5139 const savedTemplate = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', 'wp_template', template); 5140 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', select.getCurrentPostType(), select.getCurrentPostId(), { 5141 template: savedTemplate.slug 5142 }); 5143 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)("Custom template created. You're in template mode now."), { 5144 type: 'snackbar', 5145 actions: [{ 5146 label: (0,external_wp_i18n_namespaceObject.__)('Go back'), 5147 onClick: () => dispatch.setRenderingMode(select.getEditorSettings().defaultRenderingMode) 5148 }] 5149 }); 5150 return savedTemplate; 5151 }; 5152 5153 /** 5154 * Update the provided block types to be visible. 5155 * 5156 * @param {string[]} blockNames Names of block types to show. 5157 */ 5158 const showBlockTypes = blockNames => ({ 5159 registry 5160 }) => { 5161 var _registry$select$get; 5162 const existingBlockNames = (_registry$select$get = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get !== void 0 ? _registry$select$get : []; 5163 const newBlockNames = existingBlockNames.filter(type => !(Array.isArray(blockNames) ? blockNames : [blockNames]).includes(type)); 5164 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', newBlockNames); 5165 }; 5166 5167 /** 5168 * Update the provided block types to be hidden. 5169 * 5170 * @param {string[]} blockNames Names of block types to hide. 5171 */ 5172 const hideBlockTypes = blockNames => ({ 5173 registry 5174 }) => { 5175 var _registry$select$get2; 5176 const existingBlockNames = (_registry$select$get2 = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : []; 5177 const mergedBlockNames = new Set([...existingBlockNames, ...(Array.isArray(blockNames) ? blockNames : [blockNames])]); 5178 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', [...mergedBlockNames]); 5179 }; 5180 5181 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/private-selectors.js 5182 /** 5183 * WordPress dependencies 5184 */ 5185 5186 5187 5188 /** 5189 * Internal dependencies 5190 */ 5191 5192 const EMPTY_INSERTION_POINT = { 5193 rootClientId: undefined, 5194 insertionIndex: undefined, 5195 filterValue: undefined 5196 }; 5197 5198 /** 5199 * Get the insertion point for the inserter. 5200 * 5201 * @param {Object} state Global application state. 5202 * 5203 * @return {Object} The root client ID, index to insert at and starting filter value. 5204 */ 5205 const getInsertionPoint = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { 5206 if (typeof state.blockInserterPanel === 'object') { 5207 return state.blockInserterPanel; 5208 } 5209 if (getRenderingMode(state) === 'template-locked') { 5210 const [postContentClientId] = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/post-content'); 5211 if (postContentClientId) { 5212 return { 5213 rootClientId: postContentClientId, 5214 insertionIndex: undefined, 5215 filterValue: undefined 5216 }; 5217 } 5218 } 5219 return EMPTY_INSERTION_POINT; 5220 }); 5221 function getListViewToggleRef(state) { 5222 return state.listViewToggleRef; 5223 } 5224 5225 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/index.js 5226 /** 5227 * WordPress dependencies 5228 */ 5229 5230 5231 /** 5232 * Internal dependencies 5233 */ 5234 5235 5236 5237 5238 5239 5240 5241 5242 /** 5243 * Post editor data store configuration. 5244 * 5245 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore 5246 * 5247 * @type {Object} 5248 */ 5249 const storeConfig = { 5250 reducer: reducer, 5251 selectors: selectors_namespaceObject, 5252 actions: actions_namespaceObject 5253 }; 5254 5255 /** 5256 * Store definition for the editor namespace. 5257 * 5258 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore 5259 * 5260 * @type {Object} 5261 */ 5262 const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { 5263 ...storeConfig 5264 }); 5265 (0,external_wp_data_namespaceObject.register)(store_store); 5266 unlock(store_store).registerPrivateActions(private_actions_namespaceObject); 5267 unlock(store_store).registerPrivateSelectors(private_selectors_namespaceObject); 5268 5269 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/bindings/post-meta.js 5270 /** 5271 * WordPress dependencies 5272 */ 5273 5274 5275 5276 /** 5277 * Internal dependencies 5278 */ 5279 5280 /* harmony default export */ const post_meta = ({ 5281 name: 'core/post-meta', 5282 label: (0,external_wp_i18n_namespaceObject._x)('Post Meta', 'block bindings source'), 5283 useSource(props, sourceAttributes) { 5284 const { 5285 getCurrentPostType 5286 } = (0,external_wp_data_namespaceObject.useSelect)(store_store); 5287 const { 5288 context 5289 } = props; 5290 const { 5291 key: metaKey 5292 } = sourceAttributes; 5293 const postType = context.postType ? context.postType : getCurrentPostType(); 5294 const [meta, setMeta] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', context.postType, 'meta', context.postId); 5295 if (postType === 'wp_template') { 5296 return { 5297 placeholder: metaKey 5298 }; 5299 } 5300 const metaValue = meta[metaKey]; 5301 const updateMetaValue = newValue => { 5302 setMeta({ 5303 ...meta, 5304 [metaKey]: newValue 5305 }); 5306 }; 5307 return { 5308 placeholder: metaKey, 5309 value: metaValue, 5310 updateValue: updateMetaValue 5311 }; 5312 } 5313 }); 5314 5315 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/bindings/index.js 5316 /** 5317 * WordPress dependencies 5318 */ 5319 5320 5321 /** 5322 * Internal dependencies 5323 */ 5324 5325 5326 5327 const { 5328 registerBlockBindingsSource 5329 } = unlock((0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store)); 5330 registerBlockBindingsSource(post_meta); 5331 if (false) {} 5332 5333 ;// CONCATENATED MODULE: external ["wp","compose"] 5334 const external_wp_compose_namespaceObject = window["wp"]["compose"]; 5335 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/hooks/custom-sources-backwards-compatibility.js 5336 5337 /** 5338 * WordPress dependencies 5339 */ 5340 5341 5342 5343 5344 5345 5346 /** 5347 * Internal dependencies 5348 */ 5349 5350 5351 /** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */ 5352 /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */ 5353 5354 /** 5355 * Object whose keys are the names of block attributes, where each value 5356 * represents the meta key to which the block attribute is intended to save. 5357 * 5358 * @see https://developer.wordpress.org/reference/functions/register_meta/ 5359 * 5360 * @typedef {Object<string,string>} WPMetaAttributeMapping 5361 */ 5362 5363 /** 5364 * Given a mapping of attribute names (meta source attributes) to their 5365 * associated meta key, returns a higher order component that overrides its 5366 * `attributes` and `setAttributes` props to sync any changes with the edited 5367 * post's meta keys. 5368 * 5369 * @param {WPMetaAttributeMapping} metaAttributes Meta attribute mapping. 5370 * 5371 * @return {WPHigherOrderComponent} Higher-order component. 5372 */ 5373 const createWithMetaAttributeSource = metaAttributes => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => ({ 5374 attributes, 5375 setAttributes, 5376 ...props 5377 }) => { 5378 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []); 5379 const [meta, setMeta] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', postType, 'meta'); 5380 const mergedAttributes = (0,external_wp_element_namespaceObject.useMemo)(() => ({ 5381 ...attributes, 5382 ...Object.fromEntries(Object.entries(metaAttributes).map(([attributeKey, metaKey]) => [attributeKey, meta[metaKey]])) 5383 }), [attributes, meta]); 5384 return (0,external_React_.createElement)(BlockEdit, { 5385 attributes: mergedAttributes, 5386 setAttributes: nextAttributes => { 5387 const nextMeta = Object.fromEntries(Object.entries(nextAttributes !== null && nextAttributes !== void 0 ? nextAttributes : {}).filter( 5388 // Filter to intersection of keys between the updated 5389 // attributes and those with an associated meta key. 5390 ([key]) => key in metaAttributes).map(([attributeKey, value]) => [ 5391 // Rename the keys to the expected meta key name. 5392 metaAttributes[attributeKey], value])); 5393 if (Object.entries(nextMeta).length) { 5394 setMeta(nextMeta); 5395 } 5396 setAttributes(nextAttributes); 5397 }, 5398 ...props 5399 }); 5400 }, 'withMetaAttributeSource'); 5401 5402 /** 5403 * Filters a registered block's settings to enhance a block's `edit` component 5404 * to upgrade meta-sourced attributes to use the post's meta entity property. 5405 * 5406 * @param {WPBlockSettings} settings Registered block settings. 5407 * 5408 * @return {WPBlockSettings} Filtered block settings. 5409 */ 5410 function shimAttributeSource(settings) { 5411 var _settings$attributes; 5412 /** @type {WPMetaAttributeMapping} */ 5413 const metaAttributes = Object.fromEntries(Object.entries((_settings$attributes = settings.attributes) !== null && _settings$attributes !== void 0 ? _settings$attributes : {}).filter(([, { 5414 source 5415 }]) => source === 'meta').map(([attributeKey, { 5416 meta 5417 }]) => [attributeKey, meta])); 5418 if (Object.entries(metaAttributes).length) { 5419 settings.edit = createWithMetaAttributeSource(metaAttributes)(settings.edit); 5420 } 5421 return settings; 5422 } 5423 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/editor/custom-sources-backwards-compatibility/shim-attribute-source', shimAttributeSource); 5424 5425 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autocompleters/user.js 5426 5427 /** 5428 * WordPress dependencies 5429 */ 5430 5431 5432 5433 5434 /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */ 5435 5436 function getUserLabel(user) { 5437 const avatar = user.avatar_urls && user.avatar_urls[24] ? (0,external_React_.createElement)("img", { 5438 className: "editor-autocompleters__user-avatar", 5439 alt: "", 5440 src: user.avatar_urls[24] 5441 }) : (0,external_React_.createElement)("span", { 5442 className: "editor-autocompleters__no-avatar" 5443 }); 5444 return (0,external_React_.createElement)(external_React_.Fragment, null, avatar, (0,external_React_.createElement)("span", { 5445 className: "editor-autocompleters__user-name" 5446 }, user.name), (0,external_React_.createElement)("span", { 5447 className: "editor-autocompleters__user-slug" 5448 }, user.slug)); 5449 } 5450 5451 /** 5452 * A user mentions completer. 5453 * 5454 * @type {WPCompleter} 5455 */ 5456 /* harmony default export */ const user = ({ 5457 name: 'users', 5458 className: 'editor-autocompleters__user', 5459 triggerPrefix: '@', 5460 useItems(filterValue) { 5461 const users = (0,external_wp_data_namespaceObject.useSelect)(select => { 5462 const { 5463 getUsers 5464 } = select(external_wp_coreData_namespaceObject.store); 5465 return getUsers({ 5466 context: 'view', 5467 search: encodeURIComponent(filterValue) 5468 }); 5469 }, [filterValue]); 5470 const options = (0,external_wp_element_namespaceObject.useMemo)(() => users ? users.map(user => ({ 5471 key: `user-$user.slug}`, 5472 value: user, 5473 label: getUserLabel(user) 5474 })) : [], [users]); 5475 return [options]; 5476 }, 5477 getOptionCompletion(user) { 5478 return `@$user.slug}`; 5479 } 5480 }); 5481 5482 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/hooks/default-autocompleters.js 5483 /** 5484 * WordPress dependencies 5485 */ 5486 5487 5488 /** 5489 * Internal dependencies 5490 */ 5491 5492 function setDefaultCompleters(completers = []) { 5493 // Provide copies so filters may directly modify them. 5494 completers.push({ 5495 ...user 5496 }); 5497 return completers; 5498 } 5499 (0,external_wp_hooks_namespaceObject.addFilter)('editor.Autocomplete.completers', 'editor/autocompleters/set-default-completers', setDefaultCompleters); 5500 5501 ;// CONCATENATED MODULE: external ["wp","patterns"] 5502 const external_wp_patterns_namespaceObject = window["wp"]["patterns"]; 5503 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/hooks/pattern-overrides.js 5504 5505 /** 5506 * WordPress dependencies 5507 */ 5508 5509 5510 5511 5512 5513 5514 /** 5515 * Internal dependencies 5516 */ 5517 5518 5519 const { 5520 useSetPatternBindings, 5521 ResetOverridesControl, 5522 PATTERN_TYPES, 5523 PARTIAL_SYNCING_SUPPORTED_BLOCKS 5524 } = unlock(external_wp_patterns_namespaceObject.privateApis); 5525 5526 /** 5527 * Override the default edit UI to include a new block inspector control for 5528 * assigning a partial syncing controls to supported blocks in the pattern editor. 5529 * Currently, only the `core/paragraph` block is supported. 5530 * 5531 * @param {Component} BlockEdit Original component. 5532 * 5533 * @return {Component} Wrapped component. 5534 */ 5535 const withPatternOverrideControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { 5536 const isSupportedBlock = Object.keys(PARTIAL_SYNCING_SUPPORTED_BLOCKS).includes(props.name); 5537 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(BlockEdit, { 5538 ...props 5539 }), isSupportedBlock && (0,external_React_.createElement)(BindingUpdater, { 5540 ...props 5541 }), props.isSelected && isSupportedBlock && (0,external_React_.createElement)(ControlsWithStoreSubscription, { 5542 ...props 5543 })); 5544 }); 5545 function BindingUpdater(props) { 5546 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []); 5547 useSetPatternBindings(props, postType); 5548 return null; 5549 } 5550 5551 // Split into a separate component to avoid a store subscription 5552 // on every block. 5553 function ControlsWithStoreSubscription(props) { 5554 const blockEditingMode = (0,external_wp_blockEditor_namespaceObject.useBlockEditingMode)(); 5555 const isEditingPattern = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType() === PATTERN_TYPES.user, []); 5556 const bindings = props.attributes.metadata?.bindings; 5557 const hasPatternBindings = !!bindings && Object.values(bindings).some(binding => binding.source === 'core/pattern-overrides'); 5558 const shouldShowResetOverridesControl = !isEditingPattern && !!props.attributes.metadata?.name && blockEditingMode !== 'disabled' && hasPatternBindings; 5559 return (0,external_React_.createElement)(external_React_.Fragment, null, shouldShowResetOverridesControl && (0,external_React_.createElement)(ResetOverridesControl, { 5560 ...props 5561 })); 5562 } 5563 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/with-pattern-override-controls', withPatternOverrideControls); 5564 5565 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/hooks/index.js 5566 /** 5567 * Internal dependencies 5568 */ 5569 5570 5571 5572 5573 ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"] 5574 const external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"]; 5575 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/global-keyboard-shortcuts/index.js 5576 /** 5577 * WordPress dependencies 5578 */ 5579 5580 5581 5582 /** 5583 * Internal dependencies 5584 */ 5585 5586 function EditorKeyboardShortcuts() { 5587 const { 5588 redo, 5589 undo, 5590 savePost, 5591 setIsListViewOpened 5592 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 5593 const { 5594 isEditedPostDirty, 5595 isPostSavingLocked, 5596 isListViewOpened 5597 } = (0,external_wp_data_namespaceObject.useSelect)(store_store); 5598 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/undo', event => { 5599 undo(); 5600 event.preventDefault(); 5601 }); 5602 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/redo', event => { 5603 redo(); 5604 event.preventDefault(); 5605 }); 5606 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/save', event => { 5607 event.preventDefault(); 5608 5609 /** 5610 * Do not save the post if post saving is locked. 5611 */ 5612 if (isPostSavingLocked()) { 5613 return; 5614 } 5615 5616 // TODO: This should be handled in the `savePost` effect in 5617 // considering `isSaveable`. See note on `isEditedPostSaveable` 5618 // selector about dirtiness and meta-boxes. 5619 // 5620 // See: `isEditedPostSaveable` 5621 if (!isEditedPostDirty()) { 5622 return; 5623 } 5624 savePost(); 5625 }); 5626 5627 // Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar. 5628 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-list-view', event => { 5629 if (!isListViewOpened()) { 5630 event.preventDefault(); 5631 setIsListViewOpened(true); 5632 } 5633 }); 5634 return null; 5635 } 5636 5637 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autocompleters/index.js 5638 5639 5640 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autosave-monitor/index.js 5641 /** 5642 * WordPress dependencies 5643 */ 5644 5645 5646 5647 5648 5649 /** 5650 * Internal dependencies 5651 */ 5652 5653 5654 /** 5655 * AutosaveMonitor invokes `props.autosave()` within at most `interval` seconds after an unsaved change is detected. 5656 * 5657 * The logic is straightforward: a check is performed every `props.interval` seconds. If any changes are detected, `props.autosave()` is called. 5658 * 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 5659 * the specific way of detecting changes. 5660 * 5661 * There are two caveats: 5662 * * If `props.isAutosaveable` happens to be false at a time of checking for changes, the check is retried every second. 5663 * * The timer may be disabled by setting `props.disableIntervalChecks` to `true`. In that mode, any change will immediately trigger `props.autosave()`. 5664 */ 5665 class AutosaveMonitor extends external_wp_element_namespaceObject.Component { 5666 constructor(props) { 5667 super(props); 5668 this.needsAutosave = !!(props.isDirty && props.isAutosaveable); 5669 } 5670 componentDidMount() { 5671 if (!this.props.disableIntervalChecks) { 5672 this.setAutosaveTimer(); 5673 } 5674 } 5675 componentDidUpdate(prevProps) { 5676 if (this.props.disableIntervalChecks) { 5677 if (this.props.editsReference !== prevProps.editsReference) { 5678 this.props.autosave(); 5679 } 5680 return; 5681 } 5682 if (this.props.interval !== prevProps.interval) { 5683 clearTimeout(this.timerId); 5684 this.setAutosaveTimer(); 5685 } 5686 if (!this.props.isDirty) { 5687 this.needsAutosave = false; 5688 return; 5689 } 5690 if (this.props.isAutosaving && !prevProps.isAutosaving) { 5691 this.needsAutosave = false; 5692 return; 5693 } 5694 if (this.props.editsReference !== prevProps.editsReference) { 5695 this.needsAutosave = true; 5696 } 5697 } 5698 componentWillUnmount() { 5699 clearTimeout(this.timerId); 5700 } 5701 setAutosaveTimer(timeout = this.props.interval * 1000) { 5702 this.timerId = setTimeout(() => { 5703 this.autosaveTimerHandler(); 5704 }, timeout); 5705 } 5706 autosaveTimerHandler() { 5707 if (!this.props.isAutosaveable) { 5708 this.setAutosaveTimer(1000); 5709 return; 5710 } 5711 if (this.needsAutosave) { 5712 this.needsAutosave = false; 5713 this.props.autosave(); 5714 } 5715 this.setAutosaveTimer(); 5716 } 5717 render() { 5718 return null; 5719 } 5720 } 5721 /* harmony default export */ const autosave_monitor = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, ownProps) => { 5722 const { 5723 getReferenceByDistinctEdits 5724 } = select(external_wp_coreData_namespaceObject.store); 5725 const { 5726 isEditedPostDirty, 5727 isEditedPostAutosaveable, 5728 isAutosavingPost, 5729 getEditorSettings 5730 } = select(store_store); 5731 const { 5732 interval = getEditorSettings().autosaveInterval 5733 } = ownProps; 5734 return { 5735 editsReference: getReferenceByDistinctEdits(), 5736 isDirty: isEditedPostDirty(), 5737 isAutosaveable: isEditedPostAutosaveable(), 5738 isAutosaving: isAutosavingPost(), 5739 interval 5740 }; 5741 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps) => ({ 5742 autosave() { 5743 const { 5744 autosave = dispatch(store_store).autosave 5745 } = ownProps; 5746 autosave(); 5747 } 5748 }))])(AutosaveMonitor)); 5749 5750 // EXTERNAL MODULE: ./node_modules/classnames/index.js 5751 var classnames = __webpack_require__(5755); 5752 var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames); 5753 ;// CONCATENATED MODULE: external ["wp","components"] 5754 const external_wp_components_namespaceObject = window["wp"]["components"]; 5755 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js 5756 5757 /** 5758 * WordPress dependencies 5759 */ 5760 5761 const symbol = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 5762 xmlns: "http://www.w3.org/2000/svg", 5763 viewBox: "0 0 24 24" 5764 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 5765 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" 5766 })); 5767 /* harmony default export */ const library_symbol = (symbol); 5768 5769 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/navigation.js 5770 5771 /** 5772 * WordPress dependencies 5773 */ 5774 5775 const navigation = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 5776 viewBox: "0 0 24 24", 5777 xmlns: "http://www.w3.org/2000/svg" 5778 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 5779 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" 5780 })); 5781 /* harmony default export */ const library_navigation = (navigation); 5782 5783 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/page.js 5784 5785 /** 5786 * WordPress dependencies 5787 */ 5788 5789 const page = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 5790 xmlns: "http://www.w3.org/2000/svg", 5791 viewBox: "0 0 24 24" 5792 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 5793 d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z" 5794 }), (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 5795 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" 5796 })); 5797 /* harmony default export */ const library_page = (page); 5798 5799 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-right-small.js 5800 5801 /** 5802 * WordPress dependencies 5803 */ 5804 5805 const chevronRightSmall = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 5806 xmlns: "http://www.w3.org/2000/svg", 5807 viewBox: "0 0 24 24" 5808 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 5809 d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z" 5810 })); 5811 /* harmony default export */ const chevron_right_small = (chevronRightSmall); 5812 5813 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-left-small.js 5814 5815 /** 5816 * WordPress dependencies 5817 */ 5818 5819 const chevronLeftSmall = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 5820 xmlns: "http://www.w3.org/2000/svg", 5821 viewBox: "0 0 24 24" 5822 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 5823 d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z" 5824 })); 5825 /* harmony default export */ const chevron_left_small = (chevronLeftSmall); 5826 5827 ;// CONCATENATED MODULE: external ["wp","keycodes"] 5828 const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"]; 5829 ;// CONCATENATED MODULE: external ["wp","commands"] 5830 const external_wp_commands_namespaceObject = window["wp"]["commands"]; 5831 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/document-bar/index.js 5832 5833 /** 5834 * External dependencies 5835 */ 5836 5837 5838 /** 5839 * WordPress dependencies 5840 */ 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 /** 5852 * Internal dependencies 5853 */ 5854 5855 const typeLabels = { 5856 // translators: 1: Pattern title. 5857 wp_pattern: (0,external_wp_i18n_namespaceObject.__)('Editing pattern: %s'), 5858 // translators: 1: Navigation menu title. 5859 wp_navigation: (0,external_wp_i18n_namespaceObject.__)('Editing navigation menu: %s'), 5860 // translators: 1: Template title. 5861 wp_template: (0,external_wp_i18n_namespaceObject.__)('Editing template: %s'), 5862 // translators: 1: Template part title. 5863 wp_template_part: (0,external_wp_i18n_namespaceObject.__)('Editing template part: %s') 5864 }; 5865 const icons = { 5866 wp_block: library_symbol, 5867 wp_navigation: library_navigation 5868 }; 5869 function DocumentBar() { 5870 const { 5871 postType, 5872 postId, 5873 onNavigateToPreviousEntityRecord 5874 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 5875 const { 5876 getCurrentPostId, 5877 getCurrentPostType, 5878 getEditorSettings: getSettings 5879 } = select(store_store); 5880 return { 5881 postType: getCurrentPostType(), 5882 postId: getCurrentPostId(), 5883 onNavigateToPreviousEntityRecord: getSettings().onNavigateToPreviousEntityRecord, 5884 getEditorSettings: getSettings 5885 }; 5886 }, []); 5887 const handleOnBack = () => { 5888 if (onNavigateToPreviousEntityRecord) { 5889 onNavigateToPreviousEntityRecord(); 5890 } 5891 }; 5892 return (0,external_React_.createElement)(BaseDocumentActions, { 5893 postType: postType, 5894 postId: postId, 5895 onBack: onNavigateToPreviousEntityRecord ? handleOnBack : undefined 5896 }); 5897 } 5898 function BaseDocumentActions({ 5899 postType, 5900 postId, 5901 onBack 5902 }) { 5903 var _icons$postType; 5904 const { 5905 open: openCommandCenter 5906 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_commands_namespaceObject.store); 5907 const { 5908 editedRecord: doc, 5909 isResolving 5910 } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('postType', postType, postId); 5911 const { 5912 templateIcon, 5913 templateTitle 5914 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 5915 const { 5916 __experimentalGetTemplateInfo: getTemplateInfo 5917 } = select(store_store); 5918 const templateInfo = getTemplateInfo(doc); 5919 return { 5920 templateIcon: templateInfo.icon, 5921 templateTitle: templateInfo.title 5922 }; 5923 }); 5924 const isNotFound = !doc && !isResolving; 5925 const icon = (_icons$postType = icons[postType]) !== null && _icons$postType !== void 0 ? _icons$postType : library_page; 5926 const [isAnimated, setIsAnimated] = (0,external_wp_element_namespaceObject.useState)(false); 5927 const isMounting = (0,external_wp_element_namespaceObject.useRef)(true); 5928 const isTemplate = ['wp_template', 'wp_template_part'].includes(postType); 5929 const isGlobalEntity = ['wp_template', 'wp_navigation', 'wp_template_part', 'wp_block'].includes(postType); 5930 (0,external_wp_element_namespaceObject.useEffect)(() => { 5931 if (!isMounting.current) { 5932 setIsAnimated(true); 5933 } 5934 isMounting.current = false; 5935 }, [postType, postId]); 5936 const title = isTemplate ? templateTitle : doc.title; 5937 return (0,external_React_.createElement)("div", { 5938 className: classnames_default()('editor-document-bar', { 5939 'has-back-button': !!onBack, 5940 'is-animated': isAnimated, 5941 'is-global': isGlobalEntity 5942 }) 5943 }, onBack && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 5944 className: "editor-document-bar__back", 5945 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right_small : chevron_left_small, 5946 onClick: event => { 5947 event.stopPropagation(); 5948 onBack(); 5949 }, 5950 size: "compact" 5951 }, (0,external_wp_i18n_namespaceObject.__)('Back')), isNotFound && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, (0,external_wp_i18n_namespaceObject.__)('Document not found')), !isNotFound && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 5952 className: "editor-document-bar__command", 5953 onClick: () => openCommandCenter(), 5954 size: "compact" 5955 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 5956 className: "editor-document-bar__title", 5957 spacing: 1, 5958 justify: "center" 5959 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, { 5960 icon: isTemplate ? templateIcon : icon 5961 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 5962 size: "body", 5963 as: "h1", 5964 "aria-label": typeLabels[postType] ? 5965 // eslint-disable-next-line @wordpress/valid-sprintf 5966 (0,external_wp_i18n_namespaceObject.sprintf)(typeLabels[postType], title) : undefined 5967 }, title)), (0,external_React_.createElement)("span", { 5968 className: "editor-document-bar__shortcut" 5969 }, external_wp_keycodes_namespaceObject.displayShortcut.primary('k')))); 5970 } 5971 5972 ;// CONCATENATED MODULE: external ["wp","richText"] 5973 const external_wp_richText_namespaceObject = window["wp"]["richText"]; 5974 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/document-outline/item.js 5975 5976 /** 5977 * External dependencies 5978 */ 5979 5980 const TableOfContentsItem = ({ 5981 children, 5982 isValid, 5983 level, 5984 href, 5985 onSelect 5986 }) => (0,external_React_.createElement)("li", { 5987 className: classnames_default()('document-outline__item', `is-$level.toLowerCase()}`, { 5988 'is-invalid': !isValid 5989 }) 5990 }, (0,external_React_.createElement)("a", { 5991 href: href, 5992 className: "document-outline__button", 5993 onClick: onSelect 5994 }, (0,external_React_.createElement)("span", { 5995 className: "document-outline__emdash", 5996 "aria-hidden": "true" 5997 }), (0,external_React_.createElement)("strong", { 5998 className: "document-outline__level" 5999 }, level), (0,external_React_.createElement)("span", { 6000 className: "document-outline__item-content" 6001 }, children))); 6002 /* harmony default export */ const document_outline_item = (TableOfContentsItem); 6003 6004 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/document-outline/index.js 6005 6006 /** 6007 * WordPress dependencies 6008 */ 6009 6010 6011 6012 6013 6014 6015 6016 6017 /** 6018 * Internal dependencies 6019 */ 6020 6021 6022 6023 /** 6024 * Module constants 6025 */ 6026 const emptyHeadingContent = (0,external_React_.createElement)("em", null, (0,external_wp_i18n_namespaceObject.__)('(Empty heading)')); 6027 const incorrectLevelContent = [(0,external_React_.createElement)("br", { 6028 key: "incorrect-break" 6029 }), (0,external_React_.createElement)("em", { 6030 key: "incorrect-message" 6031 }, (0,external_wp_i18n_namespaceObject.__)('(Incorrect heading level)'))]; 6032 const singleH1Headings = [(0,external_React_.createElement)("br", { 6033 key: "incorrect-break-h1" 6034 }), (0,external_React_.createElement)("em", { 6035 key: "incorrect-message-h1" 6036 }, (0,external_wp_i18n_namespaceObject.__)('(Your theme may already use a H1 for the post title)'))]; 6037 const multipleH1Headings = [(0,external_React_.createElement)("br", { 6038 key: "incorrect-break-multiple-h1" 6039 }), (0,external_React_.createElement)("em", { 6040 key: "incorrect-message-multiple-h1" 6041 }, (0,external_wp_i18n_namespaceObject.__)('(Multiple H1 headings are not recommended)'))]; 6042 function EmptyOutlineIllustration() { 6043 return (0,external_React_.createElement)(external_wp_components_namespaceObject.SVG, { 6044 width: "138", 6045 height: "148", 6046 viewBox: "0 0 138 148", 6047 fill: "none", 6048 xmlns: "http://www.w3.org/2000/svg" 6049 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Rect, { 6050 width: "138", 6051 height: "148", 6052 rx: "4", 6053 fill: "#F0F6FC" 6054 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Line, { 6055 x1: "44", 6056 y1: "28", 6057 x2: "24", 6058 y2: "28", 6059 stroke: "#DDDDDD" 6060 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Rect, { 6061 x: "48", 6062 y: "16", 6063 width: "27", 6064 height: "23", 6065 rx: "4", 6066 fill: "#DDDDDD" 6067 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Path, { 6068 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", 6069 fill: "black" 6070 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Line, { 6071 x1: "55", 6072 y1: "59", 6073 x2: "24", 6074 y2: "59", 6075 stroke: "#DDDDDD" 6076 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Rect, { 6077 x: "59", 6078 y: "47", 6079 width: "29", 6080 height: "23", 6081 rx: "4", 6082 fill: "#DDDDDD" 6083 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Path, { 6084 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", 6085 fill: "black" 6086 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Line, { 6087 x1: "80", 6088 y1: "90", 6089 x2: "24", 6090 y2: "90", 6091 stroke: "#DDDDDD" 6092 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Rect, { 6093 x: "84", 6094 y: "78", 6095 width: "30", 6096 height: "23", 6097 rx: "4", 6098 fill: "#F0B849" 6099 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Path, { 6100 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", 6101 fill: "black" 6102 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Line, { 6103 x1: "66", 6104 y1: "121", 6105 x2: "24", 6106 y2: "121", 6107 stroke: "#DDDDDD" 6108 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Rect, { 6109 x: "70", 6110 y: "109", 6111 width: "29", 6112 height: "23", 6113 rx: "4", 6114 fill: "#DDDDDD" 6115 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Path, { 6116 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", 6117 fill: "black" 6118 })); 6119 } 6120 6121 /** 6122 * Returns an array of heading blocks enhanced with the following properties: 6123 * level - An integer with the heading level. 6124 * isEmpty - Flag indicating if the heading has no content. 6125 * 6126 * @param {?Array} blocks An array of blocks. 6127 * 6128 * @return {Array} An array of heading blocks enhanced with the properties described above. 6129 */ 6130 const computeOutlineHeadings = (blocks = []) => { 6131 return blocks.flatMap((block = {}) => { 6132 if (block.name === 'core/heading') { 6133 return { 6134 ...block, 6135 level: block.attributes.level, 6136 isEmpty: isEmptyHeading(block) 6137 }; 6138 } 6139 return computeOutlineHeadings(block.innerBlocks); 6140 }); 6141 }; 6142 const isEmptyHeading = heading => !heading.attributes.content || heading.attributes.content.length === 0; 6143 const DocumentOutline = ({ 6144 blocks = [], 6145 title, 6146 onSelect, 6147 isTitleSupported, 6148 hasOutlineItemsDisabled 6149 }) => { 6150 const headings = computeOutlineHeadings(blocks); 6151 const { 6152 selectBlock 6153 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 6154 if (headings.length < 1) { 6155 return (0,external_React_.createElement)("div", { 6156 className: "editor-document-outline has-no-headings" 6157 }, (0,external_React_.createElement)(EmptyOutlineIllustration, null), (0,external_React_.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Navigate the structure of your document and address issues like empty or incorrect heading levels.'))); 6158 } 6159 let prevHeadingLevel = 1; 6160 6161 // Not great but it's the simplest way to locate the title right now. 6162 const titleNode = document.querySelector('.editor-post-title__input'); 6163 const hasTitle = isTitleSupported && title && titleNode; 6164 const countByLevel = headings.reduce((acc, heading) => ({ 6165 ...acc, 6166 [heading.level]: (acc[heading.level] || 0) + 1 6167 }), {}); 6168 const hasMultipleH1 = countByLevel[1] > 1; 6169 return (0,external_React_.createElement)("div", { 6170 className: "document-outline" 6171 }, (0,external_React_.createElement)("ul", null, hasTitle && (0,external_React_.createElement)(document_outline_item, { 6172 level: (0,external_wp_i18n_namespaceObject.__)('Title'), 6173 isValid: true, 6174 onSelect: onSelect, 6175 href: `#$titleNode.id}`, 6176 isDisabled: hasOutlineItemsDisabled 6177 }, title), headings.map((item, index) => { 6178 // Headings remain the same, go up by one, or down by any amount. 6179 // Otherwise there are missing levels. 6180 const isIncorrectLevel = item.level > prevHeadingLevel + 1; 6181 const isValid = !item.isEmpty && !isIncorrectLevel && !!item.level && (item.level !== 1 || !hasMultipleH1 && !hasTitle); 6182 prevHeadingLevel = item.level; 6183 return (0,external_React_.createElement)(document_outline_item, { 6184 key: index, 6185 level: `H$item.level}`, 6186 isValid: isValid, 6187 isDisabled: hasOutlineItemsDisabled, 6188 href: `#block-$item.clientId}`, 6189 onSelect: () => { 6190 selectBlock(item.clientId); 6191 onSelect?.(); 6192 } 6193 }, item.isEmpty ? emptyHeadingContent : (0,external_wp_richText_namespaceObject.getTextContent)((0,external_wp_richText_namespaceObject.create)({ 6194 html: item.attributes.content 6195 })), isIncorrectLevel && incorrectLevelContent, item.level === 1 && hasMultipleH1 && multipleH1Headings, hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings); 6196 }))); 6197 }; 6198 /* harmony default export */ const document_outline = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => { 6199 var _postType$supports$ti; 6200 const { 6201 getBlocks 6202 } = select(external_wp_blockEditor_namespaceObject.store); 6203 const { 6204 getEditedPostAttribute 6205 } = select(store_store); 6206 const { 6207 getPostType 6208 } = select(external_wp_coreData_namespaceObject.store); 6209 const postType = getPostType(getEditedPostAttribute('type')); 6210 return { 6211 title: getEditedPostAttribute('title'), 6212 blocks: getBlocks(), 6213 isTitleSupported: (_postType$supports$ti = postType?.supports?.title) !== null && _postType$supports$ti !== void 0 ? _postType$supports$ti : false 6214 }; 6215 }))(DocumentOutline)); 6216 6217 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/document-outline/check.js 6218 /** 6219 * WordPress dependencies 6220 */ 6221 6222 6223 function DocumentOutlineCheck({ 6224 blocks, 6225 children 6226 }) { 6227 const headings = blocks.filter(block => block.name === 'core/heading'); 6228 if (headings.length < 1) { 6229 return null; 6230 } 6231 return children; 6232 } 6233 /* harmony default export */ const check = ((0,external_wp_data_namespaceObject.withSelect)(select => ({ 6234 blocks: select(external_wp_blockEditor_namespaceObject.store).getBlocks() 6235 }))(DocumentOutlineCheck)); 6236 6237 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/global-keyboard-shortcuts/register-shortcuts.js 6238 6239 /** 6240 * WordPress dependencies 6241 */ 6242 6243 6244 6245 6246 6247 6248 function EditorKeyboardShortcutsRegister() { 6249 // Registering the shortcuts. 6250 const { 6251 registerShortcut 6252 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store); 6253 (0,external_wp_element_namespaceObject.useEffect)(() => { 6254 registerShortcut({ 6255 name: 'core/editor/save', 6256 category: 'global', 6257 description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'), 6258 keyCombination: { 6259 modifier: 'primary', 6260 character: 's' 6261 } 6262 }); 6263 registerShortcut({ 6264 name: 'core/editor/undo', 6265 category: 'global', 6266 description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'), 6267 keyCombination: { 6268 modifier: 'primary', 6269 character: 'z' 6270 } 6271 }); 6272 registerShortcut({ 6273 name: 'core/editor/redo', 6274 category: 'global', 6275 description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'), 6276 keyCombination: { 6277 modifier: 'primaryShift', 6278 character: 'z' 6279 }, 6280 // Disable on Apple OS because it conflicts with the browser's 6281 // history shortcut. It's a fine alias for both Windows and Linux. 6282 // Since there's no conflict for Ctrl+Shift+Z on both Windows and 6283 // Linux, we keep it as the default for consistency. 6284 aliases: (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? [] : [{ 6285 modifier: 'primary', 6286 character: 'y' 6287 }] 6288 }); 6289 registerShortcut({ 6290 name: 'core/editor/toggle-list-view', 6291 category: 'global', 6292 description: (0,external_wp_i18n_namespaceObject.__)('Open the block list view.'), 6293 keyCombination: { 6294 modifier: 'access', 6295 character: 'o' 6296 } 6297 }); 6298 }, [registerShortcut]); 6299 return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts.Register, null); 6300 } 6301 /* harmony default export */ const register_shortcuts = (EditorKeyboardShortcutsRegister); 6302 6303 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/redo.js 6304 6305 /** 6306 * WordPress dependencies 6307 */ 6308 6309 const redo_redo = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 6310 xmlns: "http://www.w3.org/2000/svg", 6311 viewBox: "0 0 24 24" 6312 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 6313 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" 6314 })); 6315 /* harmony default export */ const library_redo = (redo_redo); 6316 6317 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/undo.js 6318 6319 /** 6320 * WordPress dependencies 6321 */ 6322 6323 const undo_undo = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 6324 xmlns: "http://www.w3.org/2000/svg", 6325 viewBox: "0 0 24 24" 6326 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 6327 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" 6328 })); 6329 /* harmony default export */ const library_undo = (undo_undo); 6330 6331 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/editor-history/redo.js 6332 6333 /** 6334 * WordPress dependencies 6335 */ 6336 6337 6338 6339 6340 6341 6342 6343 /** 6344 * Internal dependencies 6345 */ 6346 6347 function EditorHistoryRedo(props, ref) { 6348 const shortcut = (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') : external_wp_keycodes_namespaceObject.displayShortcut.primary('y'); 6349 const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorRedo(), []); 6350 const { 6351 redo 6352 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 6353 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 6354 ...props, 6355 ref: ref, 6356 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo 6357 /* translators: button label text should, if possible, be under 16 characters. */, 6358 label: (0,external_wp_i18n_namespaceObject.__)('Redo'), 6359 shortcut: shortcut 6360 // If there are no redo levels we don't want to actually disable this 6361 // button, because it will remove focus for keyboard users. 6362 // See: https://github.com/WordPress/gutenberg/issues/3486 6363 , 6364 "aria-disabled": !hasRedo, 6365 onClick: hasRedo ? redo : undefined, 6366 className: "editor-history__redo" 6367 }); 6368 } 6369 /* harmony default export */ const editor_history_redo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryRedo)); 6370 6371 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/editor-history/undo.js 6372 6373 /** 6374 * WordPress dependencies 6375 */ 6376 6377 6378 6379 6380 6381 6382 6383 /** 6384 * Internal dependencies 6385 */ 6386 6387 function EditorHistoryUndo(props, ref) { 6388 const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorUndo(), []); 6389 const { 6390 undo 6391 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 6392 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 6393 ...props, 6394 ref: ref, 6395 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo 6396 /* translators: button label text should, if possible, be under 16 characters. */, 6397 label: (0,external_wp_i18n_namespaceObject.__)('Undo'), 6398 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z') 6399 // If there are no undo levels we don't want to actually disable this 6400 // button, because it will remove focus for keyboard users. 6401 // See: https://github.com/WordPress/gutenberg/issues/3486 6402 , 6403 "aria-disabled": !hasUndo, 6404 onClick: hasUndo ? undo : undefined, 6405 className: "editor-history__undo" 6406 }); 6407 } 6408 /* harmony default export */ const editor_history_undo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryUndo)); 6409 6410 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/template-validation-notice/index.js 6411 6412 /** 6413 * WordPress dependencies 6414 */ 6415 6416 6417 6418 6419 6420 function TemplateValidationNotice({ 6421 isValid, 6422 ...props 6423 }) { 6424 if (isValid) { 6425 return null; 6426 } 6427 const confirmSynchronization = () => { 6428 if ( 6429 // eslint-disable-next-line no-alert 6430 window.confirm((0,external_wp_i18n_namespaceObject.__)('Resetting the template may result in loss of content, do you want to continue?'))) { 6431 props.synchronizeTemplate(); 6432 } 6433 }; 6434 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Notice, { 6435 className: "editor-template-validation-notice", 6436 isDismissible: false, 6437 status: "warning", 6438 actions: [{ 6439 label: (0,external_wp_i18n_namespaceObject.__)('Keep it as is'), 6440 onClick: props.resetTemplateValidity 6441 }, { 6442 label: (0,external_wp_i18n_namespaceObject.__)('Reset the template'), 6443 onClick: confirmSynchronization 6444 }] 6445 }, (0,external_wp_i18n_namespaceObject.__)('The content of your post doesn’t match the template assigned to your post type.')); 6446 } 6447 /* harmony default export */ const template_validation_notice = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => ({ 6448 isValid: select(external_wp_blockEditor_namespaceObject.store).isValidTemplate() 6449 })), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => { 6450 const { 6451 setTemplateValidity, 6452 synchronizeTemplate 6453 } = dispatch(external_wp_blockEditor_namespaceObject.store); 6454 return { 6455 resetTemplateValidity: () => setTemplateValidity(true), 6456 synchronizeTemplate 6457 }; 6458 })])(TemplateValidationNotice)); 6459 6460 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/editor-notices/index.js 6461 6462 /** 6463 * WordPress dependencies 6464 */ 6465 6466 6467 6468 6469 /** 6470 * Internal dependencies 6471 */ 6472 6473 function EditorNotices() { 6474 const { 6475 notices 6476 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ 6477 notices: select(external_wp_notices_namespaceObject.store).getNotices() 6478 }), []); 6479 const { 6480 removeNotice 6481 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 6482 const dismissibleNotices = notices.filter(({ 6483 isDismissible, 6484 type 6485 }) => isDismissible && type === 'default'); 6486 const nonDismissibleNotices = notices.filter(({ 6487 isDismissible, 6488 type 6489 }) => !isDismissible && type === 'default'); 6490 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.NoticeList, { 6491 notices: nonDismissibleNotices, 6492 className: "components-editor-notices__pinned" 6493 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.NoticeList, { 6494 notices: dismissibleNotices, 6495 className: "components-editor-notices__dismissible", 6496 onRemove: removeNotice 6497 }, (0,external_React_.createElement)(template_validation_notice, null))); 6498 } 6499 /* harmony default export */ const editor_notices = (EditorNotices); 6500 6501 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/editor-snackbars/index.js 6502 6503 /** 6504 * WordPress dependencies 6505 */ 6506 6507 6508 6509 6510 // Last three notices. Slices from the tail end of the list. 6511 const MAX_VISIBLE_NOTICES = -3; 6512 function EditorSnackbars() { 6513 const notices = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_notices_namespaceObject.store).getNotices(), []); 6514 const { 6515 removeNotice 6516 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 6517 const snackbarNotices = notices.filter(({ 6518 type 6519 }) => type === 'snackbar').slice(MAX_VISIBLE_NOTICES); 6520 return (0,external_React_.createElement)(external_wp_components_namespaceObject.SnackbarList, { 6521 notices: snackbarNotices, 6522 className: "components-editor-notices__snackbar", 6523 onRemove: removeNotice 6524 }); 6525 } 6526 6527 ;// CONCATENATED MODULE: external ["wp","htmlEntities"] 6528 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; 6529 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/entities-saved-states/entity-record-item.js 6530 6531 /** 6532 * WordPress dependencies 6533 */ 6534 6535 6536 6537 6538 6539 6540 /** 6541 * Internal dependencies 6542 */ 6543 6544 function EntityRecordItem({ 6545 record, 6546 checked, 6547 onChange 6548 }) { 6549 const { 6550 name, 6551 kind, 6552 title, 6553 key 6554 } = record; 6555 6556 // Handle templates that might use default descriptive titles. 6557 const entityRecordTitle = (0,external_wp_data_namespaceObject.useSelect)(select => { 6558 if ('postType' !== kind || 'wp_template' !== name) { 6559 return title; 6560 } 6561 const template = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(kind, name, key); 6562 return select(store_store).__experimentalGetTemplateInfo(template).title; 6563 }, [name, kind, title, key]); 6564 return (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelRow, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 6565 __nextHasNoMarginBottom: true, 6566 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(entityRecordTitle) || (0,external_wp_i18n_namespaceObject.__)('Untitled'), 6567 checked: checked, 6568 onChange: onChange 6569 })); 6570 } 6571 6572 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/entities-saved-states/entity-type-list.js 6573 6574 /** 6575 * WordPress dependencies 6576 */ 6577 6578 6579 6580 6581 6582 6583 6584 /** 6585 * Internal dependencies 6586 */ 6587 6588 6589 const { 6590 getGlobalStylesChanges, 6591 GlobalStylesContext 6592 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 6593 function getEntityDescription(entity, count) { 6594 switch (entity) { 6595 case 'site': 6596 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.'); 6597 case 'wp_template': 6598 return (0,external_wp_i18n_namespaceObject.__)('This change will affect pages and posts that use this template.'); 6599 case 'page': 6600 case 'post': 6601 return (0,external_wp_i18n_namespaceObject.__)('The following has been modified.'); 6602 } 6603 } 6604 function GlobalStylesDescription({ 6605 record 6606 }) { 6607 const { 6608 user: currentEditorGlobalStyles 6609 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext); 6610 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]); 6611 const globalStylesChanges = getGlobalStylesChanges(currentEditorGlobalStyles, savedRecord, { 6612 maxResults: 10 6613 }); 6614 return globalStylesChanges.length ? (0,external_React_.createElement)("ul", { 6615 className: "entities-saved-states__changes" 6616 }, globalStylesChanges.map(change => (0,external_React_.createElement)("li", { 6617 key: change 6618 }, change))) : null; 6619 } 6620 function EntityDescription({ 6621 record, 6622 count 6623 }) { 6624 if ('globalStyles' === record?.name) { 6625 return null; 6626 } 6627 const description = getEntityDescription(record?.name, count); 6628 return description ? (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelRow, null, description) : null; 6629 } 6630 function EntityTypeList({ 6631 list, 6632 unselectedEntities, 6633 setUnselectedEntities 6634 }) { 6635 const count = list.length; 6636 const firstRecord = list[0]; 6637 const entityConfig = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityConfig(firstRecord.kind, firstRecord.name), [firstRecord.kind, firstRecord.name]); 6638 let entityLabel = entityConfig.label; 6639 if (firstRecord?.name === 'wp_template_part') { 6640 entityLabel = 1 === count ? (0,external_wp_i18n_namespaceObject.__)('Template Part') : (0,external_wp_i18n_namespaceObject.__)('Template Parts'); 6641 } 6642 return (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 6643 title: entityLabel, 6644 initialOpen: true 6645 }, (0,external_React_.createElement)(EntityDescription, { 6646 record: firstRecord, 6647 count: count 6648 }), list.map(record => { 6649 return (0,external_React_.createElement)(EntityRecordItem, { 6650 key: record.key || record.property, 6651 record: record, 6652 checked: !unselectedEntities.some(elt => elt.kind === record.kind && elt.name === record.name && elt.key === record.key && elt.property === record.property), 6653 onChange: value => setUnselectedEntities(record, value) 6654 }); 6655 }), 'globalStyles' === firstRecord?.name && (0,external_React_.createElement)(GlobalStylesDescription, { 6656 record: firstRecord 6657 })); 6658 } 6659 6660 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/entities-saved-states/hooks/use-is-dirty.js 6661 /** 6662 * WordPress dependencies 6663 */ 6664 6665 6666 6667 6668 const TRANSLATED_SITE_PROPERTIES = { 6669 title: (0,external_wp_i18n_namespaceObject.__)('Title'), 6670 description: (0,external_wp_i18n_namespaceObject.__)('Tagline'), 6671 site_logo: (0,external_wp_i18n_namespaceObject.__)('Logo'), 6672 site_icon: (0,external_wp_i18n_namespaceObject.__)('Icon'), 6673 show_on_front: (0,external_wp_i18n_namespaceObject.__)('Show on front'), 6674 page_on_front: (0,external_wp_i18n_namespaceObject.__)('Page on front'), 6675 posts_per_page: (0,external_wp_i18n_namespaceObject.__)('Maximum posts per page'), 6676 default_comment_status: (0,external_wp_i18n_namespaceObject.__)('Allow comments on new posts') 6677 }; 6678 const useIsDirty = () => { 6679 const { 6680 editedEntities, 6681 siteEdits 6682 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 6683 const { 6684 __experimentalGetDirtyEntityRecords, 6685 getEntityRecordEdits 6686 } = select(external_wp_coreData_namespaceObject.store); 6687 return { 6688 editedEntities: __experimentalGetDirtyEntityRecords(), 6689 siteEdits: getEntityRecordEdits('root', 'site') 6690 }; 6691 }, []); 6692 const dirtyEntityRecords = (0,external_wp_element_namespaceObject.useMemo)(() => { 6693 // Remove site object and decouple into its edited pieces. 6694 const editedEntitiesWithoutSite = editedEntities.filter(record => !(record.kind === 'root' && record.name === 'site')); 6695 const editedSiteEntities = []; 6696 for (const property in siteEdits) { 6697 editedSiteEntities.push({ 6698 kind: 'root', 6699 name: 'site', 6700 title: TRANSLATED_SITE_PROPERTIES[property] || property, 6701 property 6702 }); 6703 } 6704 return [...editedEntitiesWithoutSite, ...editedSiteEntities]; 6705 }, [editedEntities, siteEdits]); 6706 6707 // Unchecked entities to be ignored by save function. 6708 const [unselectedEntities, _setUnselectedEntities] = (0,external_wp_element_namespaceObject.useState)([]); 6709 const setUnselectedEntities = ({ 6710 kind, 6711 name, 6712 key, 6713 property 6714 }, checked) => { 6715 if (checked) { 6716 _setUnselectedEntities(unselectedEntities.filter(elt => elt.kind !== kind || elt.name !== name || elt.key !== key || elt.property !== property)); 6717 } else { 6718 _setUnselectedEntities([...unselectedEntities, { 6719 kind, 6720 name, 6721 key, 6722 property 6723 }]); 6724 } 6725 }; 6726 const isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0; 6727 return { 6728 dirtyEntityRecords, 6729 isDirty, 6730 setUnselectedEntities, 6731 unselectedEntities 6732 }; 6733 }; 6734 6735 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/entities-saved-states/index.js 6736 6737 /** 6738 * WordPress dependencies 6739 */ 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 /** 6750 * Internal dependencies 6751 */ 6752 6753 6754 const PUBLISH_ON_SAVE_ENTITIES = [{ 6755 kind: 'postType', 6756 name: 'wp_navigation' 6757 }]; 6758 function identity(values) { 6759 return values; 6760 } 6761 function EntitiesSavedStates({ 6762 close 6763 }) { 6764 const isDirtyProps = useIsDirty(); 6765 return (0,external_React_.createElement)(EntitiesSavedStatesExtensible, { 6766 close: close, 6767 ...isDirtyProps 6768 }); 6769 } 6770 function EntitiesSavedStatesExtensible({ 6771 additionalPrompt = undefined, 6772 close, 6773 onSave = identity, 6774 saveEnabled: saveEnabledProp = undefined, 6775 saveLabel = (0,external_wp_i18n_namespaceObject.__)('Save'), 6776 dirtyEntityRecords, 6777 isDirty, 6778 setUnselectedEntities, 6779 unselectedEntities 6780 }) { 6781 const saveButtonRef = (0,external_wp_element_namespaceObject.useRef)(); 6782 const { 6783 editEntityRecord, 6784 saveEditedEntityRecord, 6785 __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits 6786 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 6787 const { 6788 __unstableMarkLastChangeAsPersistent 6789 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 6790 const { 6791 createSuccessNotice, 6792 createErrorNotice, 6793 removeNotice 6794 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 6795 6796 // To group entities by type. 6797 const partitionedSavables = dirtyEntityRecords.reduce((acc, record) => { 6798 const { 6799 name 6800 } = record; 6801 if (!acc[name]) { 6802 acc[name] = []; 6803 } 6804 acc[name].push(record); 6805 return acc; 6806 }, {}); 6807 6808 // Sort entity groups. 6809 const { 6810 site: siteSavables, 6811 wp_template: templateSavables, 6812 wp_template_part: templatePartSavables, 6813 ...contentSavables 6814 } = partitionedSavables; 6815 const sortedPartitionedSavables = [siteSavables, templateSavables, templatePartSavables, ...Object.values(contentSavables)].filter(Array.isArray); 6816 const saveEnabled = saveEnabledProp !== null && saveEnabledProp !== void 0 ? saveEnabledProp : isDirty; 6817 const { 6818 homeUrl 6819 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 6820 const { 6821 getUnstableBase // Site index. 6822 } = select(external_wp_coreData_namespaceObject.store); 6823 return { 6824 homeUrl: getUnstableBase()?.home 6825 }; 6826 }, []); 6827 const saveCheckedEntities = () => { 6828 const saveNoticeId = 'site-editor-save-success'; 6829 removeNotice(saveNoticeId); 6830 const entitiesToSave = dirtyEntityRecords.filter(({ 6831 kind, 6832 name, 6833 key, 6834 property 6835 }) => { 6836 return !unselectedEntities.some(elt => elt.kind === kind && elt.name === name && elt.key === key && elt.property === property); 6837 }); 6838 close(entitiesToSave); 6839 const siteItemsToSave = []; 6840 const pendingSavedRecords = []; 6841 entitiesToSave.forEach(({ 6842 kind, 6843 name, 6844 key, 6845 property 6846 }) => { 6847 if ('root' === kind && 'site' === name) { 6848 siteItemsToSave.push(property); 6849 } else { 6850 if (PUBLISH_ON_SAVE_ENTITIES.some(typeToPublish => typeToPublish.kind === kind && typeToPublish.name === name)) { 6851 editEntityRecord(kind, name, key, { 6852 status: 'publish' 6853 }); 6854 } 6855 pendingSavedRecords.push(saveEditedEntityRecord(kind, name, key)); 6856 } 6857 }); 6858 if (siteItemsToSave.length) { 6859 pendingSavedRecords.push(saveSpecifiedEntityEdits('root', 'site', undefined, siteItemsToSave)); 6860 } 6861 __unstableMarkLastChangeAsPersistent(); 6862 Promise.all(pendingSavedRecords).then(values => { 6863 return onSave(values); 6864 }).then(values => { 6865 if (values.some(value => typeof value === 'undefined')) { 6866 createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Saving failed.')); 6867 } else { 6868 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Site updated.'), { 6869 type: 'snackbar', 6870 id: saveNoticeId, 6871 actions: [{ 6872 label: (0,external_wp_i18n_namespaceObject.__)('View site'), 6873 url: homeUrl 6874 }] 6875 }); 6876 } 6877 }).catch(error => createErrorNotice(`${(0,external_wp_i18n_namespaceObject.__)('Saving failed.')} $error}`)); 6878 }; 6879 6880 // Explicitly define this with no argument passed. Using `close` on 6881 // its own will use the event object in place of the expected saved entities. 6882 const dismissPanel = (0,external_wp_element_namespaceObject.useCallback)(() => close(), [close]); 6883 const [saveDialogRef, saveDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({ 6884 onClose: () => dismissPanel() 6885 }); 6886 return (0,external_React_.createElement)("div", { 6887 ref: saveDialogRef, 6888 ...saveDialogProps, 6889 className: "entities-saved-states__panel" 6890 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 6891 className: "entities-saved-states__panel-header", 6892 gap: 2 6893 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { 6894 isBlock: true, 6895 as: external_wp_components_namespaceObject.Button, 6896 ref: saveButtonRef, 6897 variant: "primary", 6898 disabled: !saveEnabled, 6899 onClick: saveCheckedEntities, 6900 className: "editor-entities-saved-states__save-button" 6901 }, saveLabel), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { 6902 isBlock: true, 6903 as: external_wp_components_namespaceObject.Button, 6904 variant: "secondary", 6905 onClick: dismissPanel 6906 }, (0,external_wp_i18n_namespaceObject.__)('Cancel'))), (0,external_React_.createElement)("div", { 6907 className: "entities-saved-states__text-prompt" 6908 }, (0,external_React_.createElement)("strong", { 6909 className: "entities-saved-states__text-prompt--header" 6910 }, (0,external_wp_i18n_namespaceObject.__)('Are you ready to save?')), additionalPrompt, (0,external_React_.createElement)("p", null, isDirty ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of site changes waiting to be saved. */ 6911 (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), { 6912 strong: (0,external_React_.createElement)("strong", null) 6913 }) : (0,external_wp_i18n_namespaceObject.__)('Select the items you want to save.'))), sortedPartitionedSavables.map(list => { 6914 return (0,external_React_.createElement)(EntityTypeList, { 6915 key: list[0].name, 6916 list: list, 6917 unselectedEntities: unselectedEntities, 6918 setUnselectedEntities: setUnselectedEntities 6919 }); 6920 })); 6921 } 6922 6923 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/error-boundary/index.js 6924 6925 /** 6926 * WordPress dependencies 6927 */ 6928 6929 6930 6931 6932 6933 6934 6935 6936 /** 6937 * Internal dependencies 6938 */ 6939 6940 function getContent() { 6941 try { 6942 // While `select` in a component is generally discouraged, it is 6943 // used here because it (a) reduces the chance of data loss in the 6944 // case of additional errors by performing a direct retrieval and 6945 // (b) avoids the performance cost associated with unnecessary 6946 // content serialization throughout the lifetime of a non-erroring 6947 // application. 6948 return (0,external_wp_data_namespaceObject.select)(store_store).getEditedPostContent(); 6949 } catch (error) {} 6950 } 6951 function CopyButton({ 6952 text, 6953 children 6954 }) { 6955 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text); 6956 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 6957 variant: "secondary", 6958 ref: ref 6959 }, children); 6960 } 6961 class ErrorBoundary extends external_wp_element_namespaceObject.Component { 6962 constructor() { 6963 super(...arguments); 6964 this.state = { 6965 error: null 6966 }; 6967 } 6968 componentDidCatch(error) { 6969 (0,external_wp_hooks_namespaceObject.doAction)('editor.ErrorBoundary.errorLogged', error); 6970 } 6971 static getDerivedStateFromError(error) { 6972 return { 6973 error 6974 }; 6975 } 6976 render() { 6977 const { 6978 error 6979 } = this.state; 6980 if (!error) { 6981 return this.props.children; 6982 } 6983 const actions = [(0,external_React_.createElement)(CopyButton, { 6984 key: "copy-post", 6985 text: getContent 6986 }, (0,external_wp_i18n_namespaceObject.__)('Copy Post Text')), (0,external_React_.createElement)(CopyButton, { 6987 key: "copy-error", 6988 text: error.stack 6989 }, (0,external_wp_i18n_namespaceObject.__)('Copy Error'))]; 6990 return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.Warning, { 6991 className: "editor-error-boundary", 6992 actions: actions 6993 }, (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.')); 6994 } 6995 } 6996 /* harmony default export */ const error_boundary = (ErrorBoundary); 6997 6998 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/local-autosave-monitor/index.js 6999 7000 /** 7001 * WordPress dependencies 7002 */ 7003 7004 7005 7006 7007 7008 7009 7010 /** 7011 * Internal dependencies 7012 */ 7013 7014 7015 7016 const requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame; 7017 let hasStorageSupport; 7018 7019 /** 7020 * Function which returns true if the current environment supports browser 7021 * sessionStorage, or false otherwise. The result of this function is cached and 7022 * reused in subsequent invocations. 7023 */ 7024 const hasSessionStorageSupport = () => { 7025 if (hasStorageSupport !== undefined) { 7026 return hasStorageSupport; 7027 } 7028 try { 7029 // Private Browsing in Safari 10 and earlier will throw an error when 7030 // attempting to set into sessionStorage. The test here is intentional in 7031 // causing a thrown error as condition bailing from local autosave. 7032 window.sessionStorage.setItem('__wpEditorTestSessionStorage', ''); 7033 window.sessionStorage.removeItem('__wpEditorTestSessionStorage'); 7034 hasStorageSupport = true; 7035 } catch { 7036 hasStorageSupport = false; 7037 } 7038 return hasStorageSupport; 7039 }; 7040 7041 /** 7042 * Custom hook which manages the creation of a notice prompting the user to 7043 * restore a local autosave, if one exists. 7044 */ 7045 function useAutosaveNotice() { 7046 const { 7047 postId, 7048 isEditedPostNew, 7049 hasRemoteAutosave 7050 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ 7051 postId: select(store_store).getCurrentPostId(), 7052 isEditedPostNew: select(store_store).isEditedPostNew(), 7053 hasRemoteAutosave: !!select(store_store).getEditorSettings().autosave 7054 }), []); 7055 const { 7056 getEditedPostAttribute 7057 } = (0,external_wp_data_namespaceObject.useSelect)(store_store); 7058 const { 7059 createWarningNotice, 7060 removeNotice 7061 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 7062 const { 7063 editPost, 7064 resetEditorBlocks 7065 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 7066 (0,external_wp_element_namespaceObject.useEffect)(() => { 7067 let localAutosave = localAutosaveGet(postId, isEditedPostNew); 7068 if (!localAutosave) { 7069 return; 7070 } 7071 try { 7072 localAutosave = JSON.parse(localAutosave); 7073 } catch { 7074 // Not usable if it can't be parsed. 7075 return; 7076 } 7077 const { 7078 post_title: title, 7079 content, 7080 excerpt 7081 } = localAutosave; 7082 const edits = { 7083 title, 7084 content, 7085 excerpt 7086 }; 7087 { 7088 // Only display a notice if there is a difference between what has been 7089 // saved and that which is stored in sessionStorage. 7090 const hasDifference = Object.keys(edits).some(key => { 7091 return edits[key] !== getEditedPostAttribute(key); 7092 }); 7093 if (!hasDifference) { 7094 // If there is no difference, it can be safely ejected from storage. 7095 localAutosaveClear(postId, isEditedPostNew); 7096 return; 7097 } 7098 } 7099 if (hasRemoteAutosave) { 7100 return; 7101 } 7102 const id = 'wpEditorAutosaveRestore'; 7103 createWarningNotice((0,external_wp_i18n_namespaceObject.__)('The backup of this post in your browser is different from the version below.'), { 7104 id, 7105 actions: [{ 7106 label: (0,external_wp_i18n_namespaceObject.__)('Restore the backup'), 7107 onClick() { 7108 const { 7109 content: editsContent, 7110 ...editsWithoutContent 7111 } = edits; 7112 editPost(editsWithoutContent); 7113 resetEditorBlocks((0,external_wp_blocks_namespaceObject.parse)(edits.content)); 7114 removeNotice(id); 7115 } 7116 }] 7117 }); 7118 }, [isEditedPostNew, postId]); 7119 } 7120 7121 /** 7122 * Custom hook which ejects a local autosave after a successful save occurs. 7123 */ 7124 function useAutosavePurge() { 7125 const { 7126 postId, 7127 isEditedPostNew, 7128 isDirty, 7129 isAutosaving, 7130 didError 7131 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ 7132 postId: select(store_store).getCurrentPostId(), 7133 isEditedPostNew: select(store_store).isEditedPostNew(), 7134 isDirty: select(store_store).isEditedPostDirty(), 7135 isAutosaving: select(store_store).isAutosavingPost(), 7136 didError: select(store_store).didPostSaveRequestFail() 7137 }), []); 7138 const lastIsDirty = (0,external_wp_element_namespaceObject.useRef)(isDirty); 7139 const lastIsAutosaving = (0,external_wp_element_namespaceObject.useRef)(isAutosaving); 7140 (0,external_wp_element_namespaceObject.useEffect)(() => { 7141 if (!didError && (lastIsAutosaving.current && !isAutosaving || lastIsDirty.current && !isDirty)) { 7142 localAutosaveClear(postId, isEditedPostNew); 7143 } 7144 lastIsDirty.current = isDirty; 7145 lastIsAutosaving.current = isAutosaving; 7146 }, [isDirty, isAutosaving, didError]); 7147 7148 // Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave. 7149 const wasEditedPostNew = (0,external_wp_compose_namespaceObject.usePrevious)(isEditedPostNew); 7150 const prevPostId = (0,external_wp_compose_namespaceObject.usePrevious)(postId); 7151 (0,external_wp_element_namespaceObject.useEffect)(() => { 7152 if (prevPostId === postId && wasEditedPostNew && !isEditedPostNew) { 7153 localAutosaveClear(postId, true); 7154 } 7155 }, [isEditedPostNew, postId]); 7156 } 7157 function LocalAutosaveMonitor() { 7158 const { 7159 autosave 7160 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 7161 const deferredAutosave = (0,external_wp_element_namespaceObject.useCallback)(() => { 7162 requestIdleCallback(() => autosave({ 7163 local: true 7164 })); 7165 }, []); 7166 useAutosaveNotice(); 7167 useAutosavePurge(); 7168 const localAutosaveInterval = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditorSettings().localAutosaveInterval, []); 7169 return (0,external_React_.createElement)(autosave_monitor, { 7170 interval: localAutosaveInterval, 7171 autosave: deferredAutosave 7172 }); 7173 } 7174 /* harmony default export */ const local_autosave_monitor = ((0,external_wp_compose_namespaceObject.ifCondition)(hasSessionStorageSupport)(LocalAutosaveMonitor)); 7175 7176 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/page-attributes/check.js 7177 /** 7178 * WordPress dependencies 7179 */ 7180 7181 7182 7183 /** 7184 * Internal dependencies 7185 */ 7186 7187 function PageAttributesCheck({ 7188 children 7189 }) { 7190 const supportsPageAttributes = (0,external_wp_data_namespaceObject.useSelect)(select => { 7191 const { 7192 getEditedPostAttribute 7193 } = select(store_store); 7194 const { 7195 getPostType 7196 } = select(external_wp_coreData_namespaceObject.store); 7197 const postType = getPostType(getEditedPostAttribute('type')); 7198 return !!postType?.supports?.['page-attributes']; 7199 }, []); 7200 7201 // Only render fields if post type supports page attributes or available templates exist. 7202 if (!supportsPageAttributes) { 7203 return null; 7204 } 7205 return children; 7206 } 7207 /* harmony default export */ const page_attributes_check = (PageAttributesCheck); 7208 7209 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-type-support-check/index.js 7210 /** 7211 * WordPress dependencies 7212 */ 7213 7214 7215 7216 /** 7217 * Internal dependencies 7218 */ 7219 7220 7221 /** 7222 * A component which renders its own children only if the current editor post 7223 * type supports one of the given `supportKeys` prop. 7224 * 7225 * @param {Object} props Props. 7226 * @param {Element} props.children Children to be rendered if post 7227 * type supports. 7228 * @param {(string|string[])} props.supportKeys String or string array of keys 7229 * to test. 7230 * 7231 * @return {Component} The component to be rendered. 7232 */ 7233 function PostTypeSupportCheck({ 7234 children, 7235 supportKeys 7236 }) { 7237 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => { 7238 const { 7239 getEditedPostAttribute 7240 } = select(store_store); 7241 const { 7242 getPostType 7243 } = select(external_wp_coreData_namespaceObject.store); 7244 return getPostType(getEditedPostAttribute('type')); 7245 }, []); 7246 let isSupported = true; 7247 if (postType) { 7248 isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some(key => !!postType.supports[key]); 7249 } 7250 if (!isSupported) { 7251 return null; 7252 } 7253 return children; 7254 } 7255 /* harmony default export */ const post_type_support_check = (PostTypeSupportCheck); 7256 7257 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/page-attributes/order.js 7258 7259 /** 7260 * WordPress dependencies 7261 */ 7262 7263 7264 7265 7266 7267 /** 7268 * Internal dependencies 7269 */ 7270 7271 7272 function PageAttributesOrder() { 7273 const order = (0,external_wp_data_namespaceObject.useSelect)(select => { 7274 var _select$getEditedPost; 7275 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('menu_order')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 0; 7276 }, []); 7277 const { 7278 editPost 7279 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 7280 const [orderInput, setOrderInput] = (0,external_wp_element_namespaceObject.useState)(null); 7281 const setUpdatedOrder = value => { 7282 setOrderInput(value); 7283 const newOrder = Number(value); 7284 if (Number.isInteger(newOrder) && value.trim?.() !== '') { 7285 editPost({ 7286 menu_order: newOrder 7287 }); 7288 } 7289 }; 7290 const value = orderInput !== null && orderInput !== void 0 ? orderInput : order; 7291 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexBlock, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNumberControl, { 7292 __next40pxDefaultSize: true, 7293 label: (0,external_wp_i18n_namespaceObject.__)('Order'), 7294 value: value, 7295 onChange: setUpdatedOrder, 7296 labelPosition: "side", 7297 onBlur: () => { 7298 setOrderInput(null); 7299 } 7300 }))); 7301 } 7302 function PageAttributesOrderWithChecks() { 7303 return (0,external_React_.createElement)(post_type_support_check, { 7304 supportKeys: "page-attributes" 7305 }, (0,external_React_.createElement)(PageAttributesOrder, null)); 7306 } 7307 7308 // EXTERNAL MODULE: ./node_modules/remove-accents/index.js 7309 var remove_accents = __webpack_require__(9681); 7310 var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents); 7311 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/terms.js 7312 /** 7313 * WordPress dependencies 7314 */ 7315 7316 7317 /** 7318 * Returns terms in a tree form. 7319 * 7320 * @param {Array} flatTerms Array of terms in flat format. 7321 * 7322 * @return {Array} Array of terms in tree format. 7323 */ 7324 function buildTermsTree(flatTerms) { 7325 const flatTermsWithParentAndChildren = flatTerms.map(term => { 7326 return { 7327 children: [], 7328 parent: null, 7329 ...term 7330 }; 7331 }); 7332 7333 // All terms should have a `parent` because we're about to index them by it. 7334 if (flatTermsWithParentAndChildren.some(({ 7335 parent 7336 }) => parent === null)) { 7337 return flatTermsWithParentAndChildren; 7338 } 7339 const termsByParent = flatTermsWithParentAndChildren.reduce((acc, term) => { 7340 const { 7341 parent 7342 } = term; 7343 if (!acc[parent]) { 7344 acc[parent] = []; 7345 } 7346 acc[parent].push(term); 7347 return acc; 7348 }, {}); 7349 const fillWithChildren = terms => { 7350 return terms.map(term => { 7351 const children = termsByParent[term.id]; 7352 return { 7353 ...term, 7354 children: children && children.length ? fillWithChildren(children) : [] 7355 }; 7356 }); 7357 }; 7358 return fillWithChildren(termsByParent['0'] || []); 7359 } 7360 const unescapeString = arg => { 7361 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(arg); 7362 }; 7363 7364 /** 7365 * Returns a term object with name unescaped. 7366 * 7367 * @param {Object} term The term object to unescape. 7368 * 7369 * @return {Object} Term object with name property unescaped. 7370 */ 7371 const unescapeTerm = term => { 7372 return { 7373 ...term, 7374 name: unescapeString(term.name) 7375 }; 7376 }; 7377 7378 /** 7379 * Returns an array of term objects with names unescaped. 7380 * The unescape of each term is performed using the unescapeTerm function. 7381 * 7382 * @param {Object[]} terms Array of term objects to unescape. 7383 * 7384 * @return {Object[]} Array of term objects unescaped. 7385 */ 7386 const unescapeTerms = terms => { 7387 return (terms !== null && terms !== void 0 ? terms : []).map(unescapeTerm); 7388 }; 7389 7390 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/page-attributes/parent.js 7391 7392 /** 7393 * External dependencies 7394 */ 7395 7396 7397 /** 7398 * WordPress dependencies 7399 */ 7400 7401 7402 7403 7404 7405 7406 7407 7408 /** 7409 * Internal dependencies 7410 */ 7411 7412 7413 function getTitle(post) { 7414 return post?.title?.rendered ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title.rendered) : `#$post.id} (${(0,external_wp_i18n_namespaceObject.__)('no title')})`; 7415 } 7416 const getItemPriority = (name, searchValue) => { 7417 const normalizedName = remove_accents_default()(name || '').toLowerCase(); 7418 const normalizedSearch = remove_accents_default()(searchValue || '').toLowerCase(); 7419 if (normalizedName === normalizedSearch) { 7420 return 0; 7421 } 7422 if (normalizedName.startsWith(normalizedSearch)) { 7423 return normalizedName.length; 7424 } 7425 return Infinity; 7426 }; 7427 function PageAttributesParent() { 7428 const { 7429 editPost 7430 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 7431 const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)(false); 7432 const { 7433 isHierarchical, 7434 parentPostId, 7435 parentPostTitle, 7436 pageItems 7437 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 7438 var _pType$hierarchical; 7439 const { 7440 getPostType, 7441 getEntityRecords, 7442 getEntityRecord 7443 } = select(external_wp_coreData_namespaceObject.store); 7444 const { 7445 getCurrentPostId, 7446 getEditedPostAttribute 7447 } = select(store_store); 7448 const postTypeSlug = getEditedPostAttribute('type'); 7449 const pageId = getEditedPostAttribute('parent'); 7450 const pType = getPostType(postTypeSlug); 7451 const postId = getCurrentPostId(); 7452 const postIsHierarchical = (_pType$hierarchical = pType?.hierarchical) !== null && _pType$hierarchical !== void 0 ? _pType$hierarchical : false; 7453 const query = { 7454 per_page: 100, 7455 exclude: postId, 7456 parent_exclude: postId, 7457 orderby: 'menu_order', 7458 order: 'asc', 7459 _fields: 'id,title,parent' 7460 }; 7461 7462 // Perform a search when the field is changed. 7463 if (!!fieldValue) { 7464 query.search = fieldValue; 7465 } 7466 const parentPost = pageId ? getEntityRecord('postType', postTypeSlug, pageId) : null; 7467 return { 7468 isHierarchical: postIsHierarchical, 7469 parentPostId: pageId, 7470 parentPostTitle: parentPost ? getTitle(parentPost) : '', 7471 pageItems: postIsHierarchical ? getEntityRecords('postType', postTypeSlug, query) : null 7472 }; 7473 }, [fieldValue]); 7474 const parentOptions = (0,external_wp_element_namespaceObject.useMemo)(() => { 7475 const getOptionsFromTree = (tree, level = 0) => { 7476 const mappedNodes = tree.map(treeNode => [{ 7477 value: treeNode.id, 7478 label: '— '.repeat(level) + (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(treeNode.name), 7479 rawName: treeNode.name 7480 }, ...getOptionsFromTree(treeNode.children || [], level + 1)]); 7481 const sortedNodes = mappedNodes.sort(([a], [b]) => { 7482 const priorityA = getItemPriority(a.rawName, fieldValue); 7483 const priorityB = getItemPriority(b.rawName, fieldValue); 7484 return priorityA >= priorityB ? 1 : -1; 7485 }); 7486 return sortedNodes.flat(); 7487 }; 7488 if (!pageItems) { 7489 return []; 7490 } 7491 let tree = pageItems.map(item => ({ 7492 id: item.id, 7493 parent: item.parent, 7494 name: getTitle(item) 7495 })); 7496 7497 // Only build a hierarchical tree when not searching. 7498 if (!fieldValue) { 7499 tree = buildTermsTree(tree); 7500 } 7501 const opts = getOptionsFromTree(tree); 7502 7503 // Ensure the current parent is in the options list. 7504 const optsHasParent = opts.find(item => item.value === parentPostId); 7505 if (parentPostTitle && !optsHasParent) { 7506 opts.unshift({ 7507 value: parentPostId, 7508 label: parentPostTitle 7509 }); 7510 } 7511 return opts; 7512 }, [pageItems, fieldValue, parentPostTitle, parentPostId]); 7513 if (!isHierarchical) { 7514 return null; 7515 } 7516 /** 7517 * Handle user input. 7518 * 7519 * @param {string} inputValue The current value of the input field. 7520 */ 7521 const handleKeydown = inputValue => { 7522 setFieldValue(inputValue); 7523 }; 7524 7525 /** 7526 * Handle author selection. 7527 * 7528 * @param {Object} selectedPostId The selected Author. 7529 */ 7530 const handleChange = selectedPostId => { 7531 editPost({ 7532 parent: selectedPostId 7533 }); 7534 }; 7535 return (0,external_React_.createElement)(external_wp_components_namespaceObject.ComboboxControl, { 7536 __nextHasNoMarginBottom: true, 7537 __next40pxDefaultSize: true, 7538 className: "editor-page-attributes__parent", 7539 label: (0,external_wp_i18n_namespaceObject.__)('Parent'), 7540 value: parentPostId, 7541 options: parentOptions, 7542 onFilterValueChange: (0,external_wp_compose_namespaceObject.debounce)(handleKeydown, 300), 7543 onChange: handleChange 7544 }); 7545 } 7546 /* harmony default export */ const page_attributes_parent = (PageAttributesParent); 7547 7548 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/page-attributes/panel.js 7549 7550 /** 7551 * WordPress dependencies 7552 */ 7553 7554 7555 7556 7557 7558 /** 7559 * Internal dependencies 7560 */ 7561 7562 7563 7564 7565 const PANEL_NAME = 'page-attributes'; 7566 function PageAttributesPanel() { 7567 var _postType$labels$attr; 7568 const { 7569 isEnabled, 7570 isOpened, 7571 postType 7572 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 7573 const { 7574 getEditedPostAttribute, 7575 isEditorPanelEnabled, 7576 isEditorPanelOpened 7577 } = select(store_store); 7578 const { 7579 getPostType 7580 } = select(external_wp_coreData_namespaceObject.store); 7581 return { 7582 isEnabled: isEditorPanelEnabled(PANEL_NAME), 7583 isOpened: isEditorPanelOpened(PANEL_NAME), 7584 postType: getPostType(getEditedPostAttribute('type')) 7585 }; 7586 }, []); 7587 const { 7588 toggleEditorPanelOpened 7589 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 7590 if (!isEnabled || !postType) { 7591 return null; 7592 } 7593 const onTogglePanel = (...args) => toggleEditorPanelOpened(PANEL_NAME, ...args); 7594 return (0,external_React_.createElement)(page_attributes_check, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 7595 title: (_postType$labels$attr = postType?.labels?.attributes) !== null && _postType$labels$attr !== void 0 ? _postType$labels$attr : (0,external_wp_i18n_namespaceObject.__)('Page attributes'), 7596 opened: isOpened, 7597 onToggle: onTogglePanel 7598 }, (0,external_React_.createElement)(page_attributes_parent, null), (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelRow, null, (0,external_React_.createElement)(PageAttributesOrderWithChecks, null)))); 7599 } 7600 /* harmony default export */ const panel = (PageAttributesPanel); 7601 7602 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/add-template.js 7603 7604 /** 7605 * WordPress dependencies 7606 */ 7607 7608 const addTemplate = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 7609 viewBox: "0 0 24 24", 7610 xmlns: "http://www.w3.org/2000/svg" 7611 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 7612 fillRule: "evenodd", 7613 clipRule: "evenodd", 7614 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" 7615 })); 7616 /* harmony default export */ const add_template = (addTemplate); 7617 7618 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-template/create-new-template-modal.js 7619 7620 /** 7621 * WordPress dependencies 7622 */ 7623 7624 7625 7626 7627 7628 7629 7630 /** 7631 * Internal dependencies 7632 */ 7633 7634 7635 const DEFAULT_TITLE = (0,external_wp_i18n_namespaceObject.__)('Custom Template'); 7636 function CreateNewTemplateModal({ 7637 onClose 7638 }) { 7639 const { 7640 defaultBlockTemplate, 7641 onNavigateToEntityRecord 7642 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 7643 const { 7644 getEditorSettings, 7645 getCurrentTemplateId 7646 } = select(store_store); 7647 return { 7648 defaultBlockTemplate: getEditorSettings().defaultBlockTemplate, 7649 onNavigateToEntityRecord: getEditorSettings().onNavigateToEntityRecord, 7650 getTemplateId: getCurrentTemplateId 7651 }; 7652 }); 7653 const { 7654 createTemplate 7655 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 7656 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(''); 7657 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false); 7658 const cancel = () => { 7659 setTitle(''); 7660 onClose(); 7661 }; 7662 const submit = async event => { 7663 event.preventDefault(); 7664 if (isBusy) { 7665 return; 7666 } 7667 setIsBusy(true); 7668 const newTemplateContent = defaultBlockTemplate !== null && defaultBlockTemplate !== void 0 ? defaultBlockTemplate : (0,external_wp_blocks_namespaceObject.serialize)([(0,external_wp_blocks_namespaceObject.createBlock)('core/group', { 7669 tagName: 'header', 7670 layout: { 7671 inherit: true 7672 } 7673 }, [(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', { 7674 tagName: 'main' 7675 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/group', { 7676 layout: { 7677 inherit: true 7678 } 7679 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/post-title')]), (0,external_wp_blocks_namespaceObject.createBlock)('core/post-content', { 7680 layout: { 7681 inherit: true 7682 } 7683 })])]); 7684 const newTemplate = await createTemplate({ 7685 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(title || DEFAULT_TITLE), 7686 content: newTemplateContent, 7687 title: title || DEFAULT_TITLE 7688 }); 7689 setIsBusy(false); 7690 onNavigateToEntityRecord({ 7691 postId: newTemplate.id, 7692 postType: 'wp_template' 7693 }); 7694 cancel(); 7695 }; 7696 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 7697 title: (0,external_wp_i18n_namespaceObject.__)('Create custom template'), 7698 onRequestClose: cancel 7699 }, (0,external_React_.createElement)("form", { 7700 className: "editor-post-template__create-form", 7701 onSubmit: submit 7702 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 7703 spacing: "3" 7704 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 7705 __nextHasNoMarginBottom: true, 7706 label: (0,external_wp_i18n_namespaceObject.__)('Name'), 7707 value: title, 7708 onChange: setTitle, 7709 placeholder: DEFAULT_TITLE, 7710 disabled: isBusy, 7711 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.') 7712 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 7713 justify: "right" 7714 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 7715 variant: "tertiary", 7716 onClick: cancel 7717 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 7718 variant: "primary", 7719 type: "submit", 7720 isBusy: isBusy, 7721 "aria-disabled": isBusy 7722 }, (0,external_wp_i18n_namespaceObject.__)('Create')))))); 7723 } 7724 7725 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-template/hooks.js 7726 /** 7727 * WordPress dependencies 7728 */ 7729 7730 7731 7732 7733 /** 7734 * Internal dependencies 7735 */ 7736 7737 function useEditedPostContext() { 7738 return (0,external_wp_data_namespaceObject.useSelect)(select => { 7739 const { 7740 getCurrentPostId, 7741 getCurrentPostType 7742 } = select(store_store); 7743 return { 7744 postId: getCurrentPostId(), 7745 postType: getCurrentPostType() 7746 }; 7747 }, []); 7748 } 7749 function useAllowSwitchingTemplates() { 7750 const { 7751 postType, 7752 postId 7753 } = useEditedPostContext(); 7754 return (0,external_wp_data_namespaceObject.useSelect)(select => { 7755 const { 7756 getEntityRecord, 7757 getEntityRecords 7758 } = select(external_wp_coreData_namespaceObject.store); 7759 const siteSettings = getEntityRecord('root', 'site'); 7760 const templates = getEntityRecords('postType', 'wp_template', { 7761 per_page: -1 7762 }); 7763 const isPostsPage = +postId === siteSettings?.page_for_posts; 7764 // If current page is set front page or posts page, we also need 7765 // to check if the current theme has a template for it. If not 7766 const isFrontPage = postType === 'page' && +postId === siteSettings?.page_on_front && templates?.some(({ 7767 slug 7768 }) => slug === 'front-page'); 7769 return !isPostsPage && !isFrontPage; 7770 }, [postId, postType]); 7771 } 7772 function useTemplates(postType) { 7773 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template', { 7774 per_page: -1, 7775 post_type: postType 7776 }), [postType]); 7777 } 7778 function useAvailableTemplates(postType) { 7779 const currentTemplateSlug = useCurrentTemplateSlug(); 7780 const allowSwitchingTemplate = useAllowSwitchingTemplates(); 7781 const templates = useTemplates(postType); 7782 return (0,external_wp_element_namespaceObject.useMemo)(() => allowSwitchingTemplate && templates?.filter(template => template.is_custom && template.slug !== currentTemplateSlug && !!template.content.raw // Skip empty templates. 7783 ), [templates, currentTemplateSlug, allowSwitchingTemplate]); 7784 } 7785 function useCurrentTemplateSlug() { 7786 const { 7787 postType, 7788 postId 7789 } = useEditedPostContext(); 7790 const templates = useTemplates(postType); 7791 const entityTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => { 7792 const post = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId); 7793 return post?.template; 7794 }, [postType, postId]); 7795 if (!entityTemplate) { 7796 return; 7797 } 7798 // If a page has a `template` set and is not included in the list 7799 // of the theme's templates, do not return it, in order to resolve 7800 // to the current theme's default template. 7801 return templates?.find(template => template.slug === entityTemplate)?.slug; 7802 } 7803 7804 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-template/classic-theme.js 7805 7806 /** 7807 * WordPress dependencies 7808 */ 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 /** 7819 * Internal dependencies 7820 */ 7821 7822 7823 7824 const POPOVER_PROPS = { 7825 className: 'editor-post-template__dropdown', 7826 placement: 'bottom-start' 7827 }; 7828 function PostTemplateToggle({ 7829 isOpen, 7830 onClick 7831 }) { 7832 const templateTitle = (0,external_wp_data_namespaceObject.useSelect)(select => { 7833 const templateSlug = select(store_store).getEditedPostAttribute('template'); 7834 const { 7835 supportsTemplateMode, 7836 availableTemplates 7837 } = select(store_store).getEditorSettings(); 7838 if (!supportsTemplateMode && availableTemplates[templateSlug]) { 7839 return availableTemplates[templateSlug]; 7840 } 7841 const template = select(external_wp_coreData_namespaceObject.store).canUser('create', 'templates') && select(store_store).getCurrentTemplateId(); 7842 return template?.title || template?.slug || availableTemplates?.[templateSlug]; 7843 }, []); 7844 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 7845 __next40pxDefaultSize: true, 7846 className: "edit-post-post-template__toggle", 7847 variant: "tertiary", 7848 "aria-expanded": isOpen, 7849 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Template options'), 7850 onClick: onClick 7851 }, templateTitle !== null && templateTitle !== void 0 ? templateTitle : (0,external_wp_i18n_namespaceObject.__)('Default template')); 7852 } 7853 function PostTemplateDropdownContent({ 7854 onClose 7855 }) { 7856 var _options$find, _selectedOption$value; 7857 const allowSwitchingTemplate = useAllowSwitchingTemplates(); 7858 const { 7859 availableTemplates, 7860 fetchedTemplates, 7861 selectedTemplateSlug, 7862 canCreate, 7863 canEdit, 7864 currentTemplateId, 7865 onNavigateToEntityRecord, 7866 getEditorSettings 7867 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 7868 const { 7869 canUser, 7870 getEntityRecords 7871 } = select(external_wp_coreData_namespaceObject.store); 7872 const editorSettings = select(store_store).getEditorSettings(); 7873 const canCreateTemplates = canUser('create', 'templates'); 7874 const _currentTemplateId = select(store_store).getCurrentTemplateId(); 7875 return { 7876 availableTemplates: editorSettings.availableTemplates, 7877 fetchedTemplates: canCreateTemplates ? getEntityRecords('postType', 'wp_template', { 7878 post_type: select(store_store).getCurrentPostType(), 7879 per_page: -1 7880 }) : undefined, 7881 selectedTemplateSlug: select(store_store).getEditedPostAttribute('template'), 7882 canCreate: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode, 7883 canEdit: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode && !!_currentTemplateId, 7884 currentTemplateId: _currentTemplateId, 7885 onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord, 7886 getEditorSettings: select(store_store).getEditorSettings 7887 }; 7888 }, [allowSwitchingTemplate]); 7889 const options = (0,external_wp_element_namespaceObject.useMemo)(() => Object.entries({ 7890 ...availableTemplates, 7891 ...Object.fromEntries((fetchedTemplates !== null && fetchedTemplates !== void 0 ? fetchedTemplates : []).map(({ 7892 slug, 7893 title 7894 }) => [slug, title.rendered])) 7895 }).map(([slug, title]) => ({ 7896 value: slug, 7897 label: title 7898 })), [availableTemplates, fetchedTemplates]); 7899 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. 7900 7901 const { 7902 editPost 7903 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 7904 const { 7905 createSuccessNotice 7906 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 7907 const [isCreateModalOpen, setIsCreateModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); 7908 return (0,external_React_.createElement)("div", { 7909 className: "editor-post-template__classic-theme-dropdown" 7910 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, { 7911 title: (0,external_wp_i18n_namespaceObject.__)('Template'), 7912 help: (0,external_wp_i18n_namespaceObject.__)('Templates define the way content is displayed when viewing your site.'), 7913 actions: canCreate ? [{ 7914 icon: add_template, 7915 label: (0,external_wp_i18n_namespaceObject.__)('Add template'), 7916 onClick: () => setIsCreateModalOpen(true) 7917 }] : [], 7918 onClose: onClose 7919 }), !allowSwitchingTemplate ? (0,external_React_.createElement)(external_wp_components_namespaceObject.Notice, { 7920 status: "warning", 7921 isDismissible: false 7922 }, (0,external_wp_i18n_namespaceObject.__)('The posts page template cannot be changed.')) : (0,external_React_.createElement)(external_wp_components_namespaceObject.SelectControl, { 7923 __next40pxDefaultSize: true, 7924 __nextHasNoMarginBottom: true, 7925 hideLabelFromVision: true, 7926 label: (0,external_wp_i18n_namespaceObject.__)('Template'), 7927 value: (_selectedOption$value = selectedOption?.value) !== null && _selectedOption$value !== void 0 ? _selectedOption$value : '', 7928 options: options, 7929 onChange: slug => editPost({ 7930 template: slug || '' 7931 }) 7932 }), canEdit && onNavigateToEntityRecord && (0,external_React_.createElement)("p", null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 7933 variant: "link", 7934 onClick: () => { 7935 onNavigateToEntityRecord({ 7936 postId: currentTemplateId, 7937 postType: 'wp_template' 7938 }); 7939 onClose(); 7940 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Editing template. Changes made here affect all posts and pages that use the template.'), { 7941 type: 'snackbar', 7942 actions: [{ 7943 label: (0,external_wp_i18n_namespaceObject.__)('Go back'), 7944 onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord() 7945 }] 7946 }); 7947 } 7948 }, (0,external_wp_i18n_namespaceObject.__)('Edit template'))), isCreateModalOpen && (0,external_React_.createElement)(CreateNewTemplateModal, { 7949 onClose: () => setIsCreateModalOpen(false) 7950 })); 7951 } 7952 function ClassicThemeControl() { 7953 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Dropdown, { 7954 popoverProps: POPOVER_PROPS, 7955 focusOnMount: true, 7956 renderToggle: ({ 7957 isOpen, 7958 onToggle 7959 }) => (0,external_React_.createElement)(PostTemplateToggle, { 7960 isOpen: isOpen, 7961 onClick: onToggle 7962 }), 7963 renderContent: ({ 7964 onClose 7965 }) => (0,external_React_.createElement)(PostTemplateDropdownContent, { 7966 onClose: onClose 7967 }) 7968 }); 7969 } 7970 /* harmony default export */ const classic_theme = (ClassicThemeControl); 7971 7972 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/check.js 7973 7974 /** 7975 * WordPress dependencies 7976 */ 7977 7978 const check_check = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 7979 xmlns: "http://www.w3.org/2000/svg", 7980 viewBox: "0 0 24 24" 7981 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 7982 d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z" 7983 })); 7984 /* harmony default export */ const library_check = (check_check); 7985 7986 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-template/swap-template-button.js 7987 7988 /** 7989 * WordPress dependencies 7990 */ 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 /** 8002 * Internal dependencies 8003 */ 8004 8005 function SwapTemplateButton({ 8006 onClick 8007 }) { 8008 const [showModal, setShowModal] = (0,external_wp_element_namespaceObject.useState)(false); 8009 const onClose = (0,external_wp_element_namespaceObject.useCallback)(() => { 8010 setShowModal(false); 8011 }, []); 8012 const { 8013 postType, 8014 postId 8015 } = useEditedPostContext(); 8016 const availableTemplates = useAvailableTemplates(postType); 8017 const { 8018 editEntityRecord 8019 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 8020 if (!availableTemplates?.length) { 8021 return null; 8022 } 8023 const onTemplateSelect = async template => { 8024 editEntityRecord('postType', postType, postId, { 8025 template: template.name 8026 }, { 8027 undoIgnore: true 8028 }); 8029 onClose(); // Close the template suggestions modal first. 8030 onClick(); 8031 }; 8032 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 8033 onClick: () => setShowModal(true) 8034 }, (0,external_wp_i18n_namespaceObject.__)('Swap template')), showModal && (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 8035 title: (0,external_wp_i18n_namespaceObject.__)('Choose a template'), 8036 onRequestClose: onClose, 8037 overlayClassName: "editor-post-template__swap-template-modal", 8038 isFullScreen: true 8039 }, (0,external_React_.createElement)("div", { 8040 className: "editor-post-template__swap-template-modal-content" 8041 }, (0,external_React_.createElement)(TemplatesList, { 8042 postType: postType, 8043 onSelect: onTemplateSelect 8044 })))); 8045 } 8046 function TemplatesList({ 8047 postType, 8048 onSelect 8049 }) { 8050 const availableTemplates = useAvailableTemplates(postType); 8051 const templatesAsPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => availableTemplates.map(template => ({ 8052 name: template.slug, 8053 blocks: (0,external_wp_blocks_namespaceObject.parse)(template.content.raw), 8054 title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title.rendered), 8055 id: template.id 8056 })), [availableTemplates]); 8057 const shownTemplates = (0,external_wp_compose_namespaceObject.useAsyncList)(templatesAsPatterns); 8058 return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, { 8059 label: (0,external_wp_i18n_namespaceObject.__)('Templates'), 8060 blockPatterns: templatesAsPatterns, 8061 shownPatterns: shownTemplates, 8062 onClickPattern: onSelect 8063 }); 8064 } 8065 8066 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-template/reset-default-template.js 8067 8068 /** 8069 * WordPress dependencies 8070 */ 8071 8072 8073 8074 8075 8076 /** 8077 * Internal dependencies 8078 */ 8079 8080 function ResetDefaultTemplate({ 8081 onClick 8082 }) { 8083 const currentTemplateSlug = useCurrentTemplateSlug(); 8084 const allowSwitchingTemplate = useAllowSwitchingTemplates(); 8085 const { 8086 postType, 8087 postId 8088 } = useEditedPostContext(); 8089 const { 8090 editEntityRecord 8091 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 8092 // The default template in a post is indicated by an empty string. 8093 if (!currentTemplateSlug || !allowSwitchingTemplate) { 8094 return null; 8095 } 8096 return (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 8097 onClick: () => { 8098 editEntityRecord('postType', postType, postId, { 8099 template: '' 8100 }, { 8101 undoIgnore: true 8102 }); 8103 onClick(); 8104 } 8105 }, (0,external_wp_i18n_namespaceObject.__)('Use default template')); 8106 } 8107 8108 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-template/create-new-template.js 8109 8110 /** 8111 * WordPress dependencies 8112 */ 8113 8114 8115 8116 8117 8118 8119 /** 8120 * Internal dependencies 8121 */ 8122 8123 8124 function CreateNewTemplate({ 8125 onClick 8126 }) { 8127 const { 8128 canCreateTemplates 8129 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 8130 const { 8131 canUser 8132 } = select(external_wp_coreData_namespaceObject.store); 8133 return { 8134 canCreateTemplates: canUser('create', 'templates') 8135 }; 8136 }, []); 8137 const [isCreateModalOpen, setIsCreateModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); 8138 const allowSwitchingTemplate = useAllowSwitchingTemplates(); 8139 8140 // The default template in a post is indicated by an empty string. 8141 if (!canCreateTemplates || !allowSwitchingTemplate) { 8142 return null; 8143 } 8144 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 8145 onClick: () => { 8146 setIsCreateModalOpen(true); 8147 } 8148 }, (0,external_wp_i18n_namespaceObject.__)('Create new template')), isCreateModalOpen && (0,external_React_.createElement)(CreateNewTemplateModal, { 8149 onClose: () => { 8150 setIsCreateModalOpen(false); 8151 onClick(); 8152 } 8153 })); 8154 } 8155 8156 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-template/block-theme.js 8157 8158 /** 8159 * WordPress dependencies 8160 */ 8161 8162 8163 8164 8165 8166 8167 8168 8169 /** 8170 * Internal dependencies 8171 */ 8172 8173 8174 8175 8176 8177 const block_theme_POPOVER_PROPS = { 8178 className: 'editor-post-template__dropdown', 8179 placement: 'bottom-start' 8180 }; 8181 function BlockThemeControl({ 8182 id 8183 }) { 8184 const { 8185 isTemplateHidden, 8186 onNavigateToEntityRecord, 8187 getEditorSettings, 8188 hasGoBack 8189 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 8190 const { 8191 getRenderingMode, 8192 getEditorSettings: _getEditorSettings 8193 } = unlock(select(store_store)); 8194 const editorSettings = _getEditorSettings(); 8195 return { 8196 isTemplateHidden: getRenderingMode() === 'post-only', 8197 onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord, 8198 getEditorSettings: _getEditorSettings, 8199 hasGoBack: editorSettings.hasOwnProperty('onNavigateToPreviousEntityRecord') 8200 }; 8201 }, []); 8202 const { 8203 editedRecord: template, 8204 hasResolved 8205 } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('postType', 'wp_template', id); 8206 const { 8207 createSuccessNotice 8208 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 8209 const { 8210 setRenderingMode 8211 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 8212 if (!hasResolved) { 8213 return null; 8214 } 8215 8216 // The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing 8217 // and assigns its own backlink to focusMode pages. 8218 const notificationAction = hasGoBack ? [{ 8219 label: (0,external_wp_i18n_namespaceObject.__)('Go back'), 8220 onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord() 8221 }] : undefined; 8222 return (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 8223 popoverProps: block_theme_POPOVER_PROPS, 8224 focusOnMount: true, 8225 toggleProps: { 8226 __next40pxDefaultSize: true, 8227 variant: 'tertiary' 8228 }, 8229 label: (0,external_wp_i18n_namespaceObject.__)('Template options'), 8230 text: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title), 8231 icon: null 8232 }, ({ 8233 onClose 8234 }) => (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 8235 onClick: () => { 8236 onNavigateToEntityRecord({ 8237 postId: template.id, 8238 postType: 'wp_template' 8239 }); 8240 onClose(); 8241 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Editing template. Changes made here affect all posts and pages that use the template.'), { 8242 type: 'snackbar', 8243 actions: notificationAction 8244 }); 8245 } 8246 }, (0,external_wp_i18n_namespaceObject.__)('Edit template')), (0,external_React_.createElement)(SwapTemplateButton, { 8247 onClick: onClose 8248 }), (0,external_React_.createElement)(ResetDefaultTemplate, { 8249 onClick: onClose 8250 }), (0,external_React_.createElement)(CreateNewTemplate, { 8251 onClick: onClose 8252 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 8253 icon: !isTemplateHidden ? library_check : undefined, 8254 isSelected: !isTemplateHidden, 8255 role: "menuitemcheckbox", 8256 onClick: () => { 8257 setRenderingMode(isTemplateHidden ? 'template-locked' : 'post-only'); 8258 } 8259 }, (0,external_wp_i18n_namespaceObject.__)('Template preview'))))); 8260 } 8261 8262 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-panel-row/index.js 8263 8264 /** 8265 * External dependencies 8266 */ 8267 8268 8269 /** 8270 * WordPress dependencies 8271 */ 8272 8273 8274 const PostPanelRow = (0,external_wp_element_namespaceObject.forwardRef)(({ 8275 className, 8276 label, 8277 children 8278 }, ref) => { 8279 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 8280 className: classnames_default()('editor-post-panel__row', className), 8281 ref: ref 8282 }, label && (0,external_React_.createElement)("div", { 8283 className: "editor-post-panel__row-label" 8284 }, label), (0,external_React_.createElement)("div", { 8285 className: "editor-post-panel__row-control" 8286 }, children)); 8287 }); 8288 /* harmony default export */ const post_panel_row = (PostPanelRow); 8289 8290 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-template/panel.js 8291 8292 /** 8293 * WordPress dependencies 8294 */ 8295 8296 8297 8298 8299 /** 8300 * Internal dependencies 8301 */ 8302 8303 8304 8305 8306 function PostTemplatePanel() { 8307 const { 8308 templateId, 8309 isBlockTheme 8310 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 8311 const { 8312 getCurrentTemplateId, 8313 getEditorSettings 8314 } = select(store_store); 8315 return { 8316 templateId: getCurrentTemplateId(), 8317 isBlockTheme: getEditorSettings().__unstableIsBlockBasedTheme 8318 }; 8319 }, []); 8320 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => { 8321 var _select$canUser; 8322 const postTypeSlug = select(store_store).getCurrentPostType(); 8323 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug); 8324 if (!postType?.viewable) { 8325 return false; 8326 } 8327 const settings = select(store_store).getEditorSettings(); 8328 const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0; 8329 if (hasTemplates) { 8330 return true; 8331 } 8332 if (!settings.supportsTemplateMode) { 8333 return false; 8334 } 8335 const canCreateTemplates = (_select$canUser = select(external_wp_coreData_namespaceObject.store).canUser('create', 'templates')) !== null && _select$canUser !== void 0 ? _select$canUser : false; 8336 return canCreateTemplates; 8337 }, []); 8338 const canViewTemplates = (0,external_wp_data_namespaceObject.useSelect)(select => { 8339 var _select$canUser2; 8340 return (_select$canUser2 = select(external_wp_coreData_namespaceObject.store).canUser('read', 'templates')) !== null && _select$canUser2 !== void 0 ? _select$canUser2 : false; 8341 }, []); 8342 if ((!isBlockTheme || !canViewTemplates) && isVisible) { 8343 return (0,external_React_.createElement)(post_panel_row, { 8344 label: (0,external_wp_i18n_namespaceObject.__)('Template') 8345 }, (0,external_React_.createElement)(classic_theme, null)); 8346 } 8347 if (isBlockTheme && !!templateId) { 8348 return (0,external_React_.createElement)(post_panel_row, { 8349 label: (0,external_wp_i18n_namespaceObject.__)('Template') 8350 }, (0,external_React_.createElement)(BlockThemeControl, { 8351 id: templateId 8352 })); 8353 } 8354 return null; 8355 } 8356 8357 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/constants.js 8358 const BASE_QUERY = { 8359 _fields: 'id,name', 8360 context: 'view' // Allows non-admins to perform requests. 8361 }; 8362 const AUTHORS_QUERY = { 8363 who: 'authors', 8364 per_page: 50, 8365 ...BASE_QUERY 8366 }; 8367 8368 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/hook.js 8369 /** 8370 * WordPress dependencies 8371 */ 8372 8373 8374 8375 8376 8377 /** 8378 * Internal dependencies 8379 */ 8380 8381 8382 function useAuthorsQuery(search) { 8383 const { 8384 authorId, 8385 authors, 8386 postAuthor 8387 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 8388 const { 8389 getUser, 8390 getUsers 8391 } = select(external_wp_coreData_namespaceObject.store); 8392 const { 8393 getEditedPostAttribute 8394 } = select(store_store); 8395 const _authorId = getEditedPostAttribute('author'); 8396 const query = { 8397 ...AUTHORS_QUERY 8398 }; 8399 if (search) { 8400 query.search = search; 8401 } 8402 return { 8403 authorId: _authorId, 8404 authors: getUsers(query), 8405 postAuthor: getUser(_authorId, BASE_QUERY) 8406 }; 8407 }, [search]); 8408 const authorOptions = (0,external_wp_element_namespaceObject.useMemo)(() => { 8409 const fetchedAuthors = (authors !== null && authors !== void 0 ? authors : []).map(author => { 8410 return { 8411 value: author.id, 8412 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(author.name) 8413 }; 8414 }); 8415 8416 // Ensure the current author is included in the dropdown list. 8417 const foundAuthor = fetchedAuthors.findIndex(({ 8418 value 8419 }) => postAuthor?.id === value); 8420 if (foundAuthor < 0 && postAuthor) { 8421 return [{ 8422 value: postAuthor.id, 8423 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postAuthor.name) 8424 }, ...fetchedAuthors]; 8425 } 8426 return fetchedAuthors; 8427 }, [authors, postAuthor]); 8428 return { 8429 authorId, 8430 authorOptions 8431 }; 8432 } 8433 8434 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/combobox.js 8435 8436 /** 8437 * WordPress dependencies 8438 */ 8439 8440 8441 8442 8443 8444 8445 /** 8446 * Internal dependencies 8447 */ 8448 8449 8450 function PostAuthorCombobox() { 8451 const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)(); 8452 const { 8453 editPost 8454 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 8455 const { 8456 authorId, 8457 authorOptions 8458 } = useAuthorsQuery(fieldValue); 8459 8460 /** 8461 * Handle author selection. 8462 * 8463 * @param {number} postAuthorId The selected Author. 8464 */ 8465 const handleSelect = postAuthorId => { 8466 if (!postAuthorId) { 8467 return; 8468 } 8469 editPost({ 8470 author: postAuthorId 8471 }); 8472 }; 8473 8474 /** 8475 * Handle user input. 8476 * 8477 * @param {string} inputValue The current value of the input field. 8478 */ 8479 const handleKeydown = inputValue => { 8480 setFieldValue(inputValue); 8481 }; 8482 return (0,external_React_.createElement)(external_wp_components_namespaceObject.ComboboxControl, { 8483 __nextHasNoMarginBottom: true, 8484 __next40pxDefaultSize: true, 8485 label: (0,external_wp_i18n_namespaceObject.__)('Author'), 8486 options: authorOptions, 8487 value: authorId, 8488 onFilterValueChange: (0,external_wp_compose_namespaceObject.debounce)(handleKeydown, 300), 8489 onChange: handleSelect, 8490 allowReset: false 8491 }); 8492 } 8493 8494 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/select.js 8495 8496 /** 8497 * WordPress dependencies 8498 */ 8499 8500 8501 8502 8503 /** 8504 * Internal dependencies 8505 */ 8506 8507 8508 function PostAuthorSelect() { 8509 const { 8510 editPost 8511 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 8512 const { 8513 authorId, 8514 authorOptions 8515 } = useAuthorsQuery(); 8516 const setAuthorId = value => { 8517 const author = Number(value); 8518 editPost({ 8519 author 8520 }); 8521 }; 8522 return (0,external_React_.createElement)(external_wp_components_namespaceObject.SelectControl, { 8523 __next40pxDefaultSize: true, 8524 __nextHasNoMarginBottom: true, 8525 className: "post-author-selector", 8526 label: (0,external_wp_i18n_namespaceObject.__)('Author'), 8527 options: authorOptions, 8528 onChange: setAuthorId, 8529 value: authorId 8530 }); 8531 } 8532 8533 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/index.js 8534 8535 /** 8536 * WordPress dependencies 8537 */ 8538 8539 8540 8541 /** 8542 * Internal dependencies 8543 */ 8544 8545 8546 8547 const minimumUsersForCombobox = 25; 8548 function PostAuthor() { 8549 const showCombobox = (0,external_wp_data_namespaceObject.useSelect)(select => { 8550 const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY); 8551 return authors?.length >= minimumUsersForCombobox; 8552 }, []); 8553 if (showCombobox) { 8554 return (0,external_React_.createElement)(PostAuthorCombobox, null); 8555 } 8556 return (0,external_React_.createElement)(PostAuthorSelect, null); 8557 } 8558 /* harmony default export */ const post_author = (PostAuthor); 8559 8560 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/check.js 8561 8562 /** 8563 * WordPress dependencies 8564 */ 8565 8566 8567 8568 /** 8569 * Internal dependencies 8570 */ 8571 8572 8573 8574 function PostAuthorCheck({ 8575 children 8576 }) { 8577 const { 8578 hasAssignAuthorAction, 8579 hasAuthors 8580 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 8581 var _post$_links$wpActio; 8582 const post = select(store_store).getCurrentPost(); 8583 const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY); 8584 return { 8585 hasAssignAuthorAction: (_post$_links$wpActio = post._links?.['wp:action-assign-author']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false, 8586 hasAuthors: authors?.length >= 1 8587 }; 8588 }, []); 8589 if (!hasAssignAuthorAction || !hasAuthors) { 8590 return null; 8591 } 8592 return (0,external_React_.createElement)(post_type_support_check, { 8593 supportKeys: "author" 8594 }, children); 8595 } 8596 8597 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/panel.js 8598 8599 /** 8600 * Internal dependencies 8601 */ 8602 8603 8604 8605 function panel_PostAuthor() { 8606 return (0,external_React_.createElement)(PostAuthorCheck, null, (0,external_React_.createElement)(post_panel_row, { 8607 className: "editor-post-author__panel" 8608 }, (0,external_React_.createElement)(post_author, null))); 8609 } 8610 /* harmony default export */ const post_author_panel = (panel_PostAuthor); 8611 8612 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-comments/index.js 8613 8614 /** 8615 * WordPress dependencies 8616 */ 8617 8618 8619 8620 8621 /** 8622 * Internal dependencies 8623 */ 8624 8625 function PostComments() { 8626 const commentStatus = (0,external_wp_data_namespaceObject.useSelect)(select => { 8627 var _select$getEditedPost; 8628 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('comment_status')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 'open'; 8629 }, []); 8630 const { 8631 editPost 8632 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 8633 const onToggleComments = () => editPost({ 8634 comment_status: commentStatus === 'open' ? 'closed' : 'open' 8635 }); 8636 return (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 8637 __nextHasNoMarginBottom: true, 8638 label: (0,external_wp_i18n_namespaceObject.__)('Allow comments'), 8639 checked: commentStatus === 'open', 8640 onChange: onToggleComments 8641 }); 8642 } 8643 /* harmony default export */ const post_comments = (PostComments); 8644 8645 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-pingbacks/index.js 8646 8647 /** 8648 * WordPress dependencies 8649 */ 8650 8651 8652 8653 8654 /** 8655 * Internal dependencies 8656 */ 8657 8658 function PostPingbacks() { 8659 const pingStatus = (0,external_wp_data_namespaceObject.useSelect)(select => { 8660 var _select$getEditedPost; 8661 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('ping_status')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 'open'; 8662 }, []); 8663 const { 8664 editPost 8665 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 8666 const onTogglePingback = () => editPost({ 8667 ping_status: pingStatus === 'open' ? 'closed' : 'open' 8668 }); 8669 return (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 8670 __nextHasNoMarginBottom: true, 8671 label: (0,external_wp_i18n_namespaceObject.__)('Allow pingbacks & trackbacks'), 8672 checked: pingStatus === 'open', 8673 onChange: onTogglePingback 8674 }); 8675 } 8676 /* harmony default export */ const post_pingbacks = (PostPingbacks); 8677 8678 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-discussion/panel.js 8679 8680 /** 8681 * WordPress dependencies 8682 */ 8683 8684 8685 8686 8687 /** 8688 * Internal dependencies 8689 */ 8690 8691 8692 8693 8694 const panel_PANEL_NAME = 'discussion-panel'; 8695 function PostDiscussionPanel() { 8696 const { 8697 isEnabled, 8698 isOpened 8699 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 8700 const { 8701 isEditorPanelEnabled, 8702 isEditorPanelOpened 8703 } = select(store_store); 8704 return { 8705 isEnabled: isEditorPanelEnabled(panel_PANEL_NAME), 8706 isOpened: isEditorPanelOpened(panel_PANEL_NAME) 8707 }; 8708 }, []); 8709 const { 8710 toggleEditorPanelOpened 8711 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 8712 if (!isEnabled) { 8713 return null; 8714 } 8715 return (0,external_React_.createElement)(post_type_support_check, { 8716 supportKeys: ['comments', 'trackbacks'] 8717 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 8718 title: (0,external_wp_i18n_namespaceObject.__)('Discussion'), 8719 opened: isOpened, 8720 onToggle: () => toggleEditorPanelOpened(panel_PANEL_NAME) 8721 }, (0,external_React_.createElement)(post_type_support_check, { 8722 supportKeys: "comments" 8723 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelRow, null, (0,external_React_.createElement)(post_comments, null))), (0,external_React_.createElement)(post_type_support_check, { 8724 supportKeys: "trackbacks" 8725 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelRow, null, (0,external_React_.createElement)(post_pingbacks, null))))); 8726 } 8727 /* harmony default export */ const post_discussion_panel = (PostDiscussionPanel); 8728 8729 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-excerpt/index.js 8730 8731 /** 8732 * WordPress dependencies 8733 */ 8734 8735 8736 8737 8738 /** 8739 * Internal dependencies 8740 */ 8741 8742 function PostExcerpt() { 8743 const excerpt = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('excerpt'), []); 8744 const { 8745 editPost 8746 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 8747 return (0,external_React_.createElement)("div", { 8748 className: "editor-post-excerpt" 8749 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextareaControl, { 8750 __nextHasNoMarginBottom: true, 8751 label: (0,external_wp_i18n_namespaceObject.__)('Write an excerpt (optional)'), 8752 className: "editor-post-excerpt__textarea", 8753 onChange: value => editPost({ 8754 excerpt: value 8755 }), 8756 value: excerpt 8757 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.ExternalLink, { 8758 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt') 8759 }, (0,external_wp_i18n_namespaceObject.__)('Learn more about manual excerpts'))); 8760 } 8761 /* harmony default export */ const post_excerpt = (PostExcerpt); 8762 8763 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-excerpt/check.js 8764 8765 /** 8766 * WordPress dependencies 8767 */ 8768 8769 8770 /** 8771 * Internal dependencies 8772 */ 8773 8774 8775 function PostExcerptCheck({ 8776 children 8777 }) { 8778 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => { 8779 const { 8780 getEditedPostAttribute 8781 } = select(store_store); 8782 return getEditedPostAttribute('type'); 8783 }, []); 8784 8785 // This special case is unfortunate, but the REST API of wp_template and wp_template_part 8786 // support the excerpt field throught the "description" field rather than "excerpt" which means 8787 // the default ExcerptPanel won't work for these. 8788 if (['wp_template', 'wp_template_part'].includes(postType)) { 8789 return null; 8790 } 8791 return (0,external_React_.createElement)(post_type_support_check, { 8792 supportKeys: "excerpt" 8793 }, children); 8794 } 8795 /* harmony default export */ const post_excerpt_check = (PostExcerptCheck); 8796 8797 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-excerpt/plugin.js 8798 8799 /** 8800 * Defines as extensibility slot for the Excerpt panel. 8801 */ 8802 8803 /** 8804 * WordPress dependencies 8805 */ 8806 8807 const { 8808 Fill, 8809 Slot 8810 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostExcerpt'); 8811 8812 /** 8813 * Renders a post excerpt panel in the post sidebar. 8814 * 8815 * @param {Object} props Component properties. 8816 * @param {string} [props.className] An optional class name added to the row. 8817 * @param {Element} props.children Children to be rendered. 8818 * 8819 * @example 8820 * ```js 8821 * // Using ES5 syntax 8822 * var __ = wp.i18n.__; 8823 * var PluginPostExcerpt = wp.editPost.PluginPostExcerpt; 8824 * 8825 * function MyPluginPostExcerpt() { 8826 * return React.createElement( 8827 * PluginPostExcerpt, 8828 * { 8829 * className: 'my-plugin-post-excerpt', 8830 * }, 8831 * __( 'Post excerpt custom content' ) 8832 * ) 8833 * } 8834 * ``` 8835 * 8836 * @example 8837 * ```jsx 8838 * // Using ESNext syntax 8839 * import { __ } from '@wordpress/i18n'; 8840 * import { PluginPostExcerpt } from '@wordpress/edit-post'; 8841 * 8842 * const MyPluginPostExcerpt = () => ( 8843 * <PluginPostExcerpt className="my-plugin-post-excerpt"> 8844 * { __( 'Post excerpt custom content' ) } 8845 * </PluginPostExcerpt> 8846 * ); 8847 * ``` 8848 * 8849 * @return {Component} The component to be rendered. 8850 */ 8851 const PluginPostExcerpt = ({ 8852 children, 8853 className 8854 }) => { 8855 return (0,external_React_.createElement)(Fill, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelRow, { 8856 className: className 8857 }, children)); 8858 }; 8859 PluginPostExcerpt.Slot = Slot; 8860 /* harmony default export */ const post_excerpt_plugin = (PluginPostExcerpt); 8861 8862 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-excerpt/panel.js 8863 8864 /** 8865 * WordPress dependencies 8866 */ 8867 8868 8869 8870 8871 /** 8872 * Internal dependencies 8873 */ 8874 8875 8876 8877 8878 8879 /** 8880 * Module Constants 8881 */ 8882 const post_excerpt_panel_PANEL_NAME = 'post-excerpt'; 8883 function PostExcerptPanel() { 8884 const { 8885 isOpened, 8886 isEnabled 8887 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 8888 const { 8889 isEditorPanelOpened, 8890 isEditorPanelEnabled 8891 } = select(store_store); 8892 return { 8893 isOpened: isEditorPanelOpened(post_excerpt_panel_PANEL_NAME), 8894 isEnabled: isEditorPanelEnabled(post_excerpt_panel_PANEL_NAME) 8895 }; 8896 }, []); 8897 const { 8898 toggleEditorPanelOpened 8899 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 8900 const toggleExcerptPanel = () => toggleEditorPanelOpened(post_excerpt_panel_PANEL_NAME); 8901 if (!isEnabled) { 8902 return null; 8903 } 8904 return (0,external_React_.createElement)(post_excerpt_check, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 8905 title: (0,external_wp_i18n_namespaceObject.__)('Excerpt'), 8906 opened: isOpened, 8907 onToggle: toggleExcerptPanel 8908 }, (0,external_React_.createElement)(post_excerpt_plugin.Slot, null, fills => (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(post_excerpt, null), fills)))); 8909 } 8910 8911 ;// CONCATENATED MODULE: external ["wp","blob"] 8912 const external_wp_blob_namespaceObject = window["wp"]["blob"]; 8913 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/theme-support-check/index.js 8914 /** 8915 * WordPress dependencies 8916 */ 8917 8918 8919 8920 /** 8921 * Internal dependencies 8922 */ 8923 8924 function ThemeSupportCheck({ 8925 themeSupports, 8926 children, 8927 postType, 8928 supportKeys 8929 }) { 8930 const isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some(key => { 8931 var _themeSupports$key; 8932 const supported = (_themeSupports$key = themeSupports?.[key]) !== null && _themeSupports$key !== void 0 ? _themeSupports$key : false; 8933 // 'post-thumbnails' can be boolean or an array of post types. 8934 // In the latter case, we need to verify `postType` exists 8935 // within `supported`. If `postType` isn't passed, then the check 8936 // should fail. 8937 if ('post-thumbnails' === key && Array.isArray(supported)) { 8938 return supported.includes(postType); 8939 } 8940 return supported; 8941 }); 8942 if (!isSupported) { 8943 return null; 8944 } 8945 return children; 8946 } 8947 /* harmony default export */ const theme_support_check = ((0,external_wp_data_namespaceObject.withSelect)(select => { 8948 const { 8949 getThemeSupports 8950 } = select(external_wp_coreData_namespaceObject.store); 8951 const { 8952 getEditedPostAttribute 8953 } = select(store_store); 8954 return { 8955 postType: getEditedPostAttribute('type'), 8956 themeSupports: getThemeSupports() 8957 }; 8958 })(ThemeSupportCheck)); 8959 8960 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-featured-image/check.js 8961 8962 /** 8963 * Internal dependencies 8964 */ 8965 8966 8967 function PostFeaturedImageCheck({ 8968 children 8969 }) { 8970 return (0,external_React_.createElement)(theme_support_check, { 8971 supportKeys: "post-thumbnails" 8972 }, (0,external_React_.createElement)(post_type_support_check, { 8973 supportKeys: "thumbnail" 8974 }, children)); 8975 } 8976 /* harmony default export */ const post_featured_image_check = (PostFeaturedImageCheck); 8977 8978 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-featured-image/index.js 8979 8980 /** 8981 * WordPress dependencies 8982 */ 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 /** 8994 * Internal dependencies 8995 */ 8996 8997 8998 const ALLOWED_MEDIA_TYPES = ['image']; 8999 9000 // Used when labels from post type were not yet loaded or when they are not present. 9001 const DEFAULT_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Featured image'); 9002 const DEFAULT_SET_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Set featured image'); 9003 const instructions = (0,external_React_.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('To edit the featured image, you need permission to upload media.')); 9004 function getMediaDetails(media, postId) { 9005 var _media$media_details$, _media$media_details$2; 9006 if (!media) { 9007 return {}; 9008 } 9009 const defaultSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'large', media.id, postId); 9010 if (defaultSize in ((_media$media_details$ = media?.media_details?.sizes) !== null && _media$media_details$ !== void 0 ? _media$media_details$ : {})) { 9011 return { 9012 mediaWidth: media.media_details.sizes[defaultSize].width, 9013 mediaHeight: media.media_details.sizes[defaultSize].height, 9014 mediaSourceUrl: media.media_details.sizes[defaultSize].source_url 9015 }; 9016 } 9017 9018 // Use fallbackSize when defaultSize is not available. 9019 const fallbackSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'thumbnail', media.id, postId); 9020 if (fallbackSize in ((_media$media_details$2 = media?.media_details?.sizes) !== null && _media$media_details$2 !== void 0 ? _media$media_details$2 : {})) { 9021 return { 9022 mediaWidth: media.media_details.sizes[fallbackSize].width, 9023 mediaHeight: media.media_details.sizes[fallbackSize].height, 9024 mediaSourceUrl: media.media_details.sizes[fallbackSize].source_url 9025 }; 9026 } 9027 9028 // Use full image size when fallbackSize and defaultSize are not available. 9029 return { 9030 mediaWidth: media.media_details.width, 9031 mediaHeight: media.media_details.height, 9032 mediaSourceUrl: media.source_url 9033 }; 9034 } 9035 function PostFeaturedImage({ 9036 currentPostId, 9037 featuredImageId, 9038 onUpdateImage, 9039 onRemoveImage, 9040 media, 9041 postType, 9042 noticeUI, 9043 noticeOperations 9044 }) { 9045 const toggleRef = (0,external_wp_element_namespaceObject.useRef)(); 9046 const [isLoading, setIsLoading] = (0,external_wp_element_namespaceObject.useState)(false); 9047 const { 9048 getSettings 9049 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store); 9050 const { 9051 mediaWidth, 9052 mediaHeight, 9053 mediaSourceUrl 9054 } = getMediaDetails(media, currentPostId); 9055 function onDropFiles(filesList) { 9056 getSettings().mediaUpload({ 9057 allowedTypes: ALLOWED_MEDIA_TYPES, 9058 filesList, 9059 onFileChange([image]) { 9060 if ((0,external_wp_blob_namespaceObject.isBlobURL)(image?.url)) { 9061 setIsLoading(true); 9062 return; 9063 } 9064 if (image) { 9065 onUpdateImage(image); 9066 } 9067 setIsLoading(false); 9068 }, 9069 onError(message) { 9070 noticeOperations.removeAllNotices(); 9071 noticeOperations.createErrorNotice(message); 9072 } 9073 }); 9074 } 9075 return (0,external_React_.createElement)(post_featured_image_check, null, noticeUI, (0,external_React_.createElement)("div", { 9076 className: "editor-post-featured-image" 9077 }, media && (0,external_React_.createElement)("div", { 9078 id: `editor-post-featured-image-$featuredImageId}-describedby`, 9079 className: "hidden" 9080 }, media.alt_text && (0,external_wp_i18n_namespaceObject.sprintf)( 9081 // Translators: %s: The selected image alt text. 9082 (0,external_wp_i18n_namespaceObject.__)('Current image: %s'), media.alt_text), !media.alt_text && (0,external_wp_i18n_namespaceObject.sprintf)( 9083 // Translators: %s: The selected image filename. 9084 (0,external_wp_i18n_namespaceObject.__)('The current image has no alternative text. The file name is: %s'), media.media_details.sizes?.full?.file || media.slug)), (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.MediaUploadCheck, { 9085 fallback: instructions 9086 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.MediaUpload, { 9087 title: postType?.labels?.featured_image || DEFAULT_FEATURE_IMAGE_LABEL, 9088 onSelect: onUpdateImage, 9089 unstableFeaturedImageFlow: true, 9090 allowedTypes: ALLOWED_MEDIA_TYPES, 9091 modalClass: "editor-post-featured-image__media-modal", 9092 render: ({ 9093 open 9094 }) => (0,external_React_.createElement)("div", { 9095 className: "editor-post-featured-image__container" 9096 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 9097 ref: toggleRef, 9098 className: !featuredImageId ? 'editor-post-featured-image__toggle' : 'editor-post-featured-image__preview', 9099 onClick: open, 9100 "aria-label": !featuredImageId ? null : (0,external_wp_i18n_namespaceObject.__)('Edit or replace the image'), 9101 "aria-describedby": !featuredImageId ? null : `editor-post-featured-image-$featuredImageId}-describedby` 9102 }, !!featuredImageId && media && (0,external_React_.createElement)(external_wp_components_namespaceObject.ResponsiveWrapper, { 9103 naturalWidth: mediaWidth, 9104 naturalHeight: mediaHeight, 9105 isInline: true 9106 }, (0,external_React_.createElement)("img", { 9107 src: mediaSourceUrl, 9108 alt: "" 9109 })), isLoading && (0,external_React_.createElement)(external_wp_components_namespaceObject.Spinner, null), !featuredImageId && !isLoading && (postType?.labels?.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL)), !!featuredImageId && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 9110 className: "editor-post-featured-image__actions" 9111 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 9112 className: "editor-post-featured-image__action", 9113 onClick: open 9114 }, (0,external_wp_i18n_namespaceObject.__)('Replace')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 9115 className: "editor-post-featured-image__action", 9116 onClick: () => { 9117 onRemoveImage(); 9118 toggleRef.current.focus(); 9119 } 9120 }, (0,external_wp_i18n_namespaceObject.__)('Remove'))), (0,external_React_.createElement)(external_wp_components_namespaceObject.DropZone, { 9121 onFilesDrop: onDropFiles 9122 })), 9123 value: featuredImageId 9124 })))); 9125 } 9126 const applyWithSelect = (0,external_wp_data_namespaceObject.withSelect)(select => { 9127 const { 9128 getMedia, 9129 getPostType 9130 } = select(external_wp_coreData_namespaceObject.store); 9131 const { 9132 getCurrentPostId, 9133 getEditedPostAttribute 9134 } = select(store_store); 9135 const featuredImageId = getEditedPostAttribute('featured_media'); 9136 return { 9137 media: featuredImageId ? getMedia(featuredImageId, { 9138 context: 'view' 9139 }) : null, 9140 currentPostId: getCurrentPostId(), 9141 postType: getPostType(getEditedPostAttribute('type')), 9142 featuredImageId 9143 }; 9144 }); 9145 const applyWithDispatch = (0,external_wp_data_namespaceObject.withDispatch)((dispatch, { 9146 noticeOperations 9147 }, { 9148 select 9149 }) => { 9150 const { 9151 editPost 9152 } = dispatch(store_store); 9153 return { 9154 onUpdateImage(image) { 9155 editPost({ 9156 featured_media: image.id 9157 }); 9158 }, 9159 onDropImage(filesList) { 9160 select(external_wp_blockEditor_namespaceObject.store).getSettings().mediaUpload({ 9161 allowedTypes: ['image'], 9162 filesList, 9163 onFileChange([image]) { 9164 editPost({ 9165 featured_media: image.id 9166 }); 9167 }, 9168 onError(message) { 9169 noticeOperations.removeAllNotices(); 9170 noticeOperations.createErrorNotice(message); 9171 } 9172 }); 9173 }, 9174 onRemoveImage() { 9175 editPost({ 9176 featured_media: 0 9177 }); 9178 } 9179 }; 9180 }); 9181 /* 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)); 9182 9183 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-featured-image/panel.js 9184 9185 /** 9186 * WordPress dependencies 9187 */ 9188 9189 9190 9191 9192 9193 /** 9194 * Internal dependencies 9195 */ 9196 9197 9198 9199 const post_featured_image_panel_PANEL_NAME = 'featured-image'; 9200 function FeaturedImage() { 9201 var _postType$labels$feat; 9202 const { 9203 postType, 9204 isEnabled, 9205 isOpened 9206 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 9207 const { 9208 getEditedPostAttribute, 9209 isEditorPanelEnabled, 9210 isEditorPanelOpened 9211 } = select(store_store); 9212 const { 9213 getPostType 9214 } = select(external_wp_coreData_namespaceObject.store); 9215 return { 9216 postType: getPostType(getEditedPostAttribute('type')), 9217 isEnabled: isEditorPanelEnabled(post_featured_image_panel_PANEL_NAME), 9218 isOpened: isEditorPanelOpened(post_featured_image_panel_PANEL_NAME) 9219 }; 9220 }, []); 9221 const { 9222 toggleEditorPanelOpened 9223 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 9224 if (!isEnabled) { 9225 return null; 9226 } 9227 return (0,external_React_.createElement)(post_featured_image_check, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 9228 title: (_postType$labels$feat = postType?.labels?.featured_image) !== null && _postType$labels$feat !== void 0 ? _postType$labels$feat : (0,external_wp_i18n_namespaceObject.__)('Featured image'), 9229 opened: isOpened, 9230 onToggle: () => toggleEditorPanelOpened(post_featured_image_panel_PANEL_NAME) 9231 }, (0,external_React_.createElement)(post_featured_image, null))); 9232 } 9233 /* harmony default export */ const post_featured_image_panel = (FeaturedImage); 9234 9235 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-format/check.js 9236 9237 /** 9238 * WordPress dependencies 9239 */ 9240 9241 9242 /** 9243 * Internal dependencies 9244 */ 9245 9246 9247 function PostFormatCheck({ 9248 children 9249 }) { 9250 const disablePostFormats = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditorSettings().disablePostFormats, []); 9251 if (disablePostFormats) { 9252 return null; 9253 } 9254 return (0,external_React_.createElement)(post_type_support_check, { 9255 supportKeys: "post-formats" 9256 }, children); 9257 } 9258 /* harmony default export */ const post_format_check = (PostFormatCheck); 9259 9260 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-format/index.js 9261 9262 /** 9263 * WordPress dependencies 9264 */ 9265 9266 9267 9268 9269 9270 9271 /** 9272 * Internal dependencies 9273 */ 9274 9275 9276 9277 // All WP post formats, sorted alphabetically by translated name. 9278 const POST_FORMATS = [{ 9279 id: 'aside', 9280 caption: (0,external_wp_i18n_namespaceObject.__)('Aside') 9281 }, { 9282 id: 'audio', 9283 caption: (0,external_wp_i18n_namespaceObject.__)('Audio') 9284 }, { 9285 id: 'chat', 9286 caption: (0,external_wp_i18n_namespaceObject.__)('Chat') 9287 }, { 9288 id: 'gallery', 9289 caption: (0,external_wp_i18n_namespaceObject.__)('Gallery') 9290 }, { 9291 id: 'image', 9292 caption: (0,external_wp_i18n_namespaceObject.__)('Image') 9293 }, { 9294 id: 'link', 9295 caption: (0,external_wp_i18n_namespaceObject.__)('Link') 9296 }, { 9297 id: 'quote', 9298 caption: (0,external_wp_i18n_namespaceObject.__)('Quote') 9299 }, { 9300 id: 'standard', 9301 caption: (0,external_wp_i18n_namespaceObject.__)('Standard') 9302 }, { 9303 id: 'status', 9304 caption: (0,external_wp_i18n_namespaceObject.__)('Status') 9305 }, { 9306 id: 'video', 9307 caption: (0,external_wp_i18n_namespaceObject.__)('Video') 9308 }].sort((a, b) => { 9309 const normalizedA = a.caption.toUpperCase(); 9310 const normalizedB = b.caption.toUpperCase(); 9311 if (normalizedA < normalizedB) { 9312 return -1; 9313 } 9314 if (normalizedA > normalizedB) { 9315 return 1; 9316 } 9317 return 0; 9318 }); 9319 function PostFormat() { 9320 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostFormat); 9321 const postFormatSelectorId = `post-format-selector-$instanceId}`; 9322 const { 9323 postFormat, 9324 suggestedFormat, 9325 supportedFormats 9326 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 9327 const { 9328 getEditedPostAttribute, 9329 getSuggestedPostFormat 9330 } = select(store_store); 9331 const _postFormat = getEditedPostAttribute('format'); 9332 const themeSupports = select(external_wp_coreData_namespaceObject.store).getThemeSupports(); 9333 return { 9334 postFormat: _postFormat !== null && _postFormat !== void 0 ? _postFormat : 'standard', 9335 suggestedFormat: getSuggestedPostFormat(), 9336 supportedFormats: themeSupports.formats 9337 }; 9338 }, []); 9339 const formats = POST_FORMATS.filter(format => { 9340 // Ensure current format is always in the set. 9341 // The current format may not be a format supported by the theme. 9342 return supportedFormats?.includes(format.id) || postFormat === format.id; 9343 }); 9344 const suggestion = formats.find(format => format.id === suggestedFormat); 9345 const { 9346 editPost 9347 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 9348 const onUpdatePostFormat = format => editPost({ 9349 format 9350 }); 9351 return (0,external_React_.createElement)(post_format_check, null, (0,external_React_.createElement)("div", { 9352 className: "editor-post-format" 9353 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.SelectControl, { 9354 __nextHasNoMarginBottom: true, 9355 label: (0,external_wp_i18n_namespaceObject.__)('Post Format'), 9356 value: postFormat, 9357 onChange: format => onUpdatePostFormat(format), 9358 id: postFormatSelectorId, 9359 options: formats.map(format => ({ 9360 label: format.caption, 9361 value: format.id 9362 })) 9363 }), suggestion && suggestion.id !== postFormat && (0,external_React_.createElement)("p", { 9364 className: "editor-post-format__suggestion" 9365 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 9366 variant: "link", 9367 onClick: () => onUpdatePostFormat(suggestion.id) 9368 }, (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: post format */ 9369 (0,external_wp_i18n_namespaceObject.__)('Apply suggested format: %s'), suggestion.caption))))); 9370 } 9371 9372 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/backup.js 9373 9374 /** 9375 * WordPress dependencies 9376 */ 9377 9378 const backup = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 9379 xmlns: "http://www.w3.org/2000/svg", 9380 viewBox: "0 0 24 24" 9381 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 9382 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" 9383 })); 9384 /* harmony default export */ const library_backup = (backup); 9385 9386 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-last-revision/check.js 9387 9388 /** 9389 * WordPress dependencies 9390 */ 9391 9392 9393 /** 9394 * Internal dependencies 9395 */ 9396 9397 9398 function PostLastRevisionCheck({ 9399 children 9400 }) { 9401 const { 9402 lastRevisionId, 9403 revisionsCount 9404 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 9405 const { 9406 getCurrentPostLastRevisionId, 9407 getCurrentPostRevisionsCount 9408 } = select(store_store); 9409 return { 9410 lastRevisionId: getCurrentPostLastRevisionId(), 9411 revisionsCount: getCurrentPostRevisionsCount() 9412 }; 9413 }, []); 9414 if (!lastRevisionId || revisionsCount < 2) { 9415 return null; 9416 } 9417 return (0,external_React_.createElement)(post_type_support_check, { 9418 supportKeys: "revisions" 9419 }, children); 9420 } 9421 /* harmony default export */ const post_last_revision_check = (PostLastRevisionCheck); 9422 9423 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-last-revision/index.js 9424 9425 /** 9426 * WordPress dependencies 9427 */ 9428 9429 9430 9431 9432 9433 9434 /** 9435 * Internal dependencies 9436 */ 9437 9438 9439 function LastRevision() { 9440 const { 9441 lastRevisionId, 9442 revisionsCount 9443 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 9444 const { 9445 getCurrentPostLastRevisionId, 9446 getCurrentPostRevisionsCount 9447 } = select(store_store); 9448 return { 9449 lastRevisionId: getCurrentPostLastRevisionId(), 9450 revisionsCount: getCurrentPostRevisionsCount() 9451 }; 9452 }, []); 9453 return (0,external_React_.createElement)(post_last_revision_check, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 9454 href: (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', { 9455 revision: lastRevisionId 9456 }), 9457 className: "editor-post-last-revision__title", 9458 icon: library_backup, 9459 iconPosition: "right", 9460 text: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: number of revisions */ 9461 (0,external_wp_i18n_namespaceObject.__)('Revisions (%s)'), revisionsCount) 9462 })); 9463 } 9464 /* harmony default export */ const post_last_revision = (LastRevision); 9465 9466 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-last-revision/panel.js 9467 9468 /** 9469 * WordPress dependencies 9470 */ 9471 9472 9473 /** 9474 * Internal dependencies 9475 */ 9476 9477 9478 function PostLastRevisionPanel() { 9479 return (0,external_React_.createElement)(post_last_revision_check, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 9480 className: "editor-post-last-revision__panel" 9481 }, (0,external_React_.createElement)(post_last_revision, null))); 9482 } 9483 /* harmony default export */ const post_last_revision_panel = (PostLastRevisionPanel); 9484 9485 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-locked-modal/index.js 9486 9487 /** 9488 * WordPress dependencies 9489 */ 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 /** 9500 * Internal dependencies 9501 */ 9502 9503 function PostLockedModal() { 9504 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostLockedModal); 9505 const hookName = 'core/editor/post-locked-modal-' + instanceId; 9506 const { 9507 autosave, 9508 updatePostLock 9509 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 9510 const { 9511 isLocked, 9512 isTakeover, 9513 user, 9514 postId, 9515 postLockUtils, 9516 activePostLock, 9517 postType, 9518 previewLink 9519 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 9520 const { 9521 isPostLocked, 9522 isPostLockTakeover, 9523 getPostLockUser, 9524 getCurrentPostId, 9525 getActivePostLock, 9526 getEditedPostAttribute, 9527 getEditedPostPreviewLink, 9528 getEditorSettings 9529 } = select(store_store); 9530 const { 9531 getPostType 9532 } = select(external_wp_coreData_namespaceObject.store); 9533 return { 9534 isLocked: isPostLocked(), 9535 isTakeover: isPostLockTakeover(), 9536 user: getPostLockUser(), 9537 postId: getCurrentPostId(), 9538 postLockUtils: getEditorSettings().postLockUtils, 9539 activePostLock: getActivePostLock(), 9540 postType: getPostType(getEditedPostAttribute('type')), 9541 previewLink: getEditedPostPreviewLink() 9542 }; 9543 }, []); 9544 (0,external_wp_element_namespaceObject.useEffect)(() => { 9545 /** 9546 * Keep the lock refreshed. 9547 * 9548 * When the user does not send a heartbeat in a heartbeat-tick 9549 * the user is no longer editing and another user can start editing. 9550 * 9551 * @param {Object} data Data to send in the heartbeat request. 9552 */ 9553 function sendPostLock(data) { 9554 if (isLocked) { 9555 return; 9556 } 9557 data['wp-refresh-post-lock'] = { 9558 lock: activePostLock, 9559 post_id: postId 9560 }; 9561 } 9562 9563 /** 9564 * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing. 9565 * 9566 * @param {Object} data Data received in the heartbeat request 9567 */ 9568 function receivePostLock(data) { 9569 if (!data['wp-refresh-post-lock']) { 9570 return; 9571 } 9572 const received = data['wp-refresh-post-lock']; 9573 if (received.lock_error) { 9574 // Auto save and display the takeover modal. 9575 autosave(); 9576 updatePostLock({ 9577 isLocked: true, 9578 isTakeover: true, 9579 user: { 9580 name: received.lock_error.name, 9581 avatar: received.lock_error.avatar_src_2x 9582 } 9583 }); 9584 } else if (received.new_lock) { 9585 updatePostLock({ 9586 isLocked: false, 9587 activePostLock: received.new_lock 9588 }); 9589 } 9590 } 9591 9592 /** 9593 * Unlock the post before the window is exited. 9594 */ 9595 function releasePostLock() { 9596 if (isLocked || !activePostLock) { 9597 return; 9598 } 9599 const data = new window.FormData(); 9600 data.append('action', 'wp-remove-post-lock'); 9601 data.append('_wpnonce', postLockUtils.unlockNonce); 9602 data.append('post_ID', postId); 9603 data.append('active_post_lock', activePostLock); 9604 if (window.navigator.sendBeacon) { 9605 window.navigator.sendBeacon(postLockUtils.ajaxUrl, data); 9606 } else { 9607 const xhr = new window.XMLHttpRequest(); 9608 xhr.open('POST', postLockUtils.ajaxUrl, false); 9609 xhr.send(data); 9610 } 9611 } 9612 9613 // Details on these events on the Heartbeat API docs 9614 // https://developer.wordpress.org/plugins/javascript/heartbeat-api/ 9615 (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.send', hookName, sendPostLock); 9616 (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.tick', hookName, receivePostLock); 9617 window.addEventListener('beforeunload', releasePostLock); 9618 return () => { 9619 (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.send', hookName); 9620 (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.tick', hookName); 9621 window.removeEventListener('beforeunload', releasePostLock); 9622 }; 9623 }, []); 9624 if (!isLocked) { 9625 return null; 9626 } 9627 const userDisplayName = user.name; 9628 const userAvatar = user.avatar; 9629 const unlockUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('post.php', { 9630 'get-post-lock': '1', 9631 lockKey: true, 9632 post: postId, 9633 action: 'edit', 9634 _wpnonce: postLockUtils.nonce 9635 }); 9636 const allPostsUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', { 9637 post_type: postType?.slug 9638 }); 9639 const allPostsLabel = (0,external_wp_i18n_namespaceObject.__)('Exit editor'); 9640 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 9641 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'), 9642 focusOnMount: true, 9643 shouldCloseOnClickOutside: false, 9644 shouldCloseOnEsc: false, 9645 isDismissible: false, 9646 size: "medium" 9647 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 9648 alignment: "top", 9649 spacing: 6 9650 }, !!userAvatar && (0,external_React_.createElement)("img", { 9651 src: userAvatar, 9652 alt: (0,external_wp_i18n_namespaceObject.__)('Avatar'), 9653 className: "editor-post-locked-modal__avatar", 9654 width: 64, 9655 height: 64 9656 }), (0,external_React_.createElement)("div", null, !!isTakeover && (0,external_React_.createElement)("p", null, (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: user's display name */ 9657 (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.'), { 9658 strong: (0,external_React_.createElement)("strong", null), 9659 PreviewLink: (0,external_React_.createElement)(external_wp_components_namespaceObject.ExternalLink, { 9660 href: previewLink 9661 }, (0,external_wp_i18n_namespaceObject.__)('preview')) 9662 })), !isTakeover && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("p", null, (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: user's display name */ 9663 (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.'), { 9664 strong: (0,external_React_.createElement)("strong", null), 9665 PreviewLink: (0,external_React_.createElement)(external_wp_components_namespaceObject.ExternalLink, { 9666 href: previewLink 9667 }, (0,external_wp_i18n_namespaceObject.__)('preview')) 9668 })), (0,external_React_.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('If you take over, the other user will lose editing control to the post, but their changes will be saved.'))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 9669 className: "editor-post-locked-modal__buttons", 9670 justify: "flex-end" 9671 }, !isTakeover && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 9672 variant: "tertiary", 9673 href: unlockUrl 9674 }, (0,external_wp_i18n_namespaceObject.__)('Take over')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 9675 variant: "primary", 9676 href: allPostsUrl 9677 }, allPostsLabel))))); 9678 } 9679 9680 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-pending-status/check.js 9681 /** 9682 * WordPress dependencies 9683 */ 9684 9685 9686 /** 9687 * Internal dependencies 9688 */ 9689 9690 function PostPendingStatusCheck({ 9691 children 9692 }) { 9693 const { 9694 hasPublishAction, 9695 isPublished 9696 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 9697 var _getCurrentPost$_link; 9698 const { 9699 isCurrentPostPublished, 9700 getCurrentPost 9701 } = select(store_store); 9702 return { 9703 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false, 9704 isPublished: isCurrentPostPublished() 9705 }; 9706 }, []); 9707 if (isPublished || !hasPublishAction) { 9708 return null; 9709 } 9710 return children; 9711 } 9712 /* harmony default export */ const post_pending_status_check = (PostPendingStatusCheck); 9713 9714 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-pending-status/index.js 9715 9716 /** 9717 * WordPress dependencies 9718 */ 9719 9720 9721 9722 9723 /** 9724 * Internal dependencies 9725 */ 9726 9727 9728 function PostPendingStatus() { 9729 const status = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('status'), []); 9730 const { 9731 editPost 9732 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 9733 const togglePendingStatus = () => { 9734 const updatedStatus = status === 'pending' ? 'draft' : 'pending'; 9735 editPost({ 9736 status: updatedStatus 9737 }); 9738 }; 9739 return (0,external_React_.createElement)(post_pending_status_check, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 9740 __nextHasNoMarginBottom: true, 9741 label: (0,external_wp_i18n_namespaceObject.__)('Pending review'), 9742 checked: status === 'pending', 9743 onChange: togglePendingStatus 9744 })); 9745 } 9746 /* harmony default export */ const post_pending_status = (PostPendingStatus); 9747 9748 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-preview-button/index.js 9749 9750 /** 9751 * WordPress dependencies 9752 */ 9753 9754 9755 9756 9757 9758 9759 9760 /** 9761 * Internal dependencies 9762 */ 9763 9764 function writeInterstitialMessage(targetDocument) { 9765 let markup = (0,external_wp_element_namespaceObject.renderToString)((0,external_React_.createElement)("div", { 9766 className: "editor-post-preview-button__interstitial-message" 9767 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.SVG, { 9768 xmlns: "http://www.w3.org/2000/svg", 9769 viewBox: "0 0 96 96" 9770 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Path, { 9771 className: "outer", 9772 d: "M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36", 9773 fill: "none" 9774 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Path, { 9775 className: "inner", 9776 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", 9777 fill: "none" 9778 })), (0,external_React_.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Generating preview…')))); 9779 markup += ` 9780 <style> 9781 body { 9782 margin: 0; 9783 } 9784 .editor-post-preview-button__interstitial-message { 9785 display: flex; 9786 flex-direction: column; 9787 align-items: center; 9788 justify-content: center; 9789 height: 100vh; 9790 width: 100vw; 9791 } 9792 @-webkit-keyframes paint { 9793 0% { 9794 stroke-dashoffset: 0; 9795 } 9796 } 9797 @-moz-keyframes paint { 9798 0% { 9799 stroke-dashoffset: 0; 9800 } 9801 } 9802 @-o-keyframes paint { 9803 0% { 9804 stroke-dashoffset: 0; 9805 } 9806 } 9807 @keyframes paint { 9808 0% { 9809 stroke-dashoffset: 0; 9810 } 9811 } 9812 .editor-post-preview-button__interstitial-message svg { 9813 width: 192px; 9814 height: 192px; 9815 stroke: #555d66; 9816 stroke-width: 0.75; 9817 } 9818 .editor-post-preview-button__interstitial-message svg .outer, 9819 .editor-post-preview-button__interstitial-message svg .inner { 9820 stroke-dasharray: 280; 9821 stroke-dashoffset: 280; 9822 -webkit-animation: paint 1.5s ease infinite alternate; 9823 -moz-animation: paint 1.5s ease infinite alternate; 9824 -o-animation: paint 1.5s ease infinite alternate; 9825 animation: paint 1.5s ease infinite alternate; 9826 } 9827 p { 9828 text-align: center; 9829 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; 9830 } 9831 </style> 9832 `; 9833 9834 /** 9835 * Filters the interstitial message shown when generating previews. 9836 * 9837 * @param {string} markup The preview interstitial markup. 9838 */ 9839 markup = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostPreview.interstitialMarkup', markup); 9840 targetDocument.write(markup); 9841 targetDocument.title = (0,external_wp_i18n_namespaceObject.__)('Generating preview…'); 9842 targetDocument.close(); 9843 } 9844 function PostPreviewButton({ 9845 className, 9846 textContent, 9847 forceIsAutosaveable, 9848 role, 9849 onPreview 9850 }) { 9851 const { 9852 postId, 9853 currentPostLink, 9854 previewLink, 9855 isSaveable, 9856 isViewable 9857 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 9858 var _postType$viewable; 9859 const editor = select(store_store); 9860 const core = select(external_wp_coreData_namespaceObject.store); 9861 const postType = core.getPostType(editor.getCurrentPostType('type')); 9862 return { 9863 postId: editor.getCurrentPostId(), 9864 currentPostLink: editor.getCurrentPostAttribute('link'), 9865 previewLink: editor.getEditedPostPreviewLink(), 9866 isSaveable: editor.isEditedPostSaveable(), 9867 isViewable: (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false 9868 }; 9869 }, []); 9870 const { 9871 __unstableSaveForPreview 9872 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 9873 if (!isViewable) { 9874 return null; 9875 } 9876 const targetId = `wp-preview-$postId}`; 9877 const openPreviewWindow = async event => { 9878 // Our Preview button has its 'href' and 'target' set correctly for a11y 9879 // purposes. Unfortunately, though, we can't rely on the default 'click' 9880 // handler since sometimes it incorrectly opens a new tab instead of reusing 9881 // the existing one. 9882 // https://github.com/WordPress/gutenberg/pull/8330 9883 event.preventDefault(); 9884 9885 // Open up a Preview tab if needed. This is where we'll show the preview. 9886 const previewWindow = window.open('', targetId); 9887 9888 // Focus the Preview tab. This might not do anything, depending on the browser's 9889 // and user's preferences. 9890 // https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus 9891 previewWindow.focus(); 9892 writeInterstitialMessage(previewWindow.document); 9893 const link = await __unstableSaveForPreview({ 9894 forceIsAutosaveable 9895 }); 9896 previewWindow.location = link; 9897 onPreview?.(); 9898 }; 9899 9900 // Link to the `?preview=true` URL if we have it, since this lets us see 9901 // changes that were autosaved since the post was last published. Otherwise, 9902 // just link to the post's URL. 9903 const href = previewLink || currentPostLink; 9904 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 9905 variant: !className ? 'tertiary' : undefined, 9906 className: className || 'editor-post-preview', 9907 href: href, 9908 target: targetId, 9909 disabled: !isSaveable, 9910 onClick: openPreviewWindow, 9911 role: role 9912 }, textContent || (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject._x)('Preview', 'imperative verb'), (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 9913 as: "span" 9914 }, /* translators: accessibility text */ 9915 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')))); 9916 } 9917 9918 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-button/label.js 9919 /** 9920 * WordPress dependencies 9921 */ 9922 9923 9924 9925 9926 /** 9927 * Internal dependencies 9928 */ 9929 9930 function PublishButtonLabel({ 9931 isPublished, 9932 isBeingScheduled, 9933 isSaving, 9934 isPublishing, 9935 hasPublishAction, 9936 isAutosaving, 9937 hasNonPostEntityChanges 9938 }) { 9939 if (isPublishing) { 9940 /* translators: button label text should, if possible, be under 16 characters. */ 9941 return (0,external_wp_i18n_namespaceObject.__)('Publishing…'); 9942 } else if (isPublished && isSaving && !isAutosaving) { 9943 /* translators: button label text should, if possible, be under 16 characters. */ 9944 return (0,external_wp_i18n_namespaceObject.__)('Updating…'); 9945 } else if (isBeingScheduled && isSaving && !isAutosaving) { 9946 /* translators: button label text should, if possible, be under 16 characters. */ 9947 return (0,external_wp_i18n_namespaceObject.__)('Scheduling…'); 9948 } 9949 if (!hasPublishAction) { 9950 return hasNonPostEntityChanges ? (0,external_wp_i18n_namespaceObject.__)('Submit for Review…') : (0,external_wp_i18n_namespaceObject.__)('Submit for Review'); 9951 } else if (isPublished) { 9952 return hasNonPostEntityChanges ? (0,external_wp_i18n_namespaceObject.__)('Update…') : (0,external_wp_i18n_namespaceObject.__)('Update'); 9953 } else if (isBeingScheduled) { 9954 return hasNonPostEntityChanges ? (0,external_wp_i18n_namespaceObject.__)('Schedule…') : (0,external_wp_i18n_namespaceObject.__)('Schedule'); 9955 } 9956 return (0,external_wp_i18n_namespaceObject.__)('Publish'); 9957 } 9958 /* harmony default export */ const label = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => { 9959 var _getCurrentPost$_link; 9960 const { 9961 isCurrentPostPublished, 9962 isEditedPostBeingScheduled, 9963 isSavingPost, 9964 isPublishingPost, 9965 getCurrentPost, 9966 getCurrentPostType, 9967 isAutosavingPost 9968 } = select(store_store); 9969 return { 9970 isPublished: isCurrentPostPublished(), 9971 isBeingScheduled: isEditedPostBeingScheduled(), 9972 isSaving: isSavingPost(), 9973 isPublishing: isPublishingPost(), 9974 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false, 9975 postType: getCurrentPostType(), 9976 isAutosaving: isAutosavingPost() 9977 }; 9978 })])(PublishButtonLabel)); 9979 9980 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-button/index.js 9981 9982 /** 9983 * External dependencies 9984 */ 9985 9986 9987 /** 9988 * WordPress dependencies 9989 */ 9990 9991 9992 9993 9994 9995 9996 /** 9997 * Internal dependencies 9998 */ 9999 10000 10001 const noop = () => {}; 10002 class PostPublishButton extends external_wp_element_namespaceObject.Component { 10003 constructor(props) { 10004 super(props); 10005 this.buttonNode = (0,external_wp_element_namespaceObject.createRef)(); 10006 this.createOnClick = this.createOnClick.bind(this); 10007 this.closeEntitiesSavedStates = this.closeEntitiesSavedStates.bind(this); 10008 this.state = { 10009 entitiesSavedStatesCallback: false 10010 }; 10011 } 10012 componentDidMount() { 10013 if (this.props.focusOnMount) { 10014 // This timeout is necessary to make sure the `useEffect` hook of 10015 // `useFocusReturn` gets the correct element (the button that opens the 10016 // PostPublishPanel) otherwise it will get this button. 10017 this.timeoutID = setTimeout(() => { 10018 this.buttonNode.current.focus(); 10019 }, 0); 10020 } 10021 } 10022 componentWillUnmount() { 10023 clearTimeout(this.timeoutID); 10024 } 10025 createOnClick(callback) { 10026 return (...args) => { 10027 const { 10028 hasNonPostEntityChanges, 10029 setEntitiesSavedStatesCallback 10030 } = this.props; 10031 // If a post with non-post entities is published, but the user 10032 // elects to not save changes to the non-post entities, those 10033 // entities will still be dirty when the Publish button is clicked. 10034 // We also need to check that the `setEntitiesSavedStatesCallback` 10035 // prop was passed. See https://github.com/WordPress/gutenberg/pull/37383 10036 if (hasNonPostEntityChanges && setEntitiesSavedStatesCallback) { 10037 // The modal for multiple entity saving will open, 10038 // hold the callback for saving/publishing the post 10039 // so that we can call it if the post entity is checked. 10040 this.setState({ 10041 entitiesSavedStatesCallback: () => callback(...args) 10042 }); 10043 10044 // Open the save panel by setting its callback. 10045 // To set a function on the useState hook, we must set it 10046 // with another function (() => myFunction). Passing the 10047 // function on its own will cause an error when called. 10048 setEntitiesSavedStatesCallback(() => this.closeEntitiesSavedStates); 10049 return noop; 10050 } 10051 return callback(...args); 10052 }; 10053 } 10054 closeEntitiesSavedStates(savedEntities) { 10055 const { 10056 postType, 10057 postId 10058 } = this.props; 10059 const { 10060 entitiesSavedStatesCallback 10061 } = this.state; 10062 this.setState({ 10063 entitiesSavedStatesCallback: false 10064 }, () => { 10065 if (savedEntities && savedEntities.some(elt => elt.kind === 'postType' && elt.name === postType && elt.key === postId)) { 10066 // The post entity was checked, call the held callback from `createOnClick`. 10067 entitiesSavedStatesCallback(); 10068 } 10069 }); 10070 } 10071 render() { 10072 const { 10073 forceIsDirty, 10074 hasPublishAction, 10075 isBeingScheduled, 10076 isOpen, 10077 isPostSavingLocked, 10078 isPublishable, 10079 isPublished, 10080 isSaveable, 10081 isSaving, 10082 isAutoSaving, 10083 isToggle, 10084 onSave, 10085 onStatusChange, 10086 onSubmit = noop, 10087 onToggle, 10088 visibility, 10089 hasNonPostEntityChanges, 10090 isSavingNonPostEntityChanges 10091 } = this.props; 10092 const isButtonDisabled = (isSaving || !isSaveable || isPostSavingLocked || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges); 10093 const isToggleDisabled = (isPublished || isSaving || !isSaveable || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges); 10094 let publishStatus; 10095 if (!hasPublishAction) { 10096 publishStatus = 'pending'; 10097 } else if (visibility === 'private') { 10098 publishStatus = 'private'; 10099 } else if (isBeingScheduled) { 10100 publishStatus = 'future'; 10101 } else { 10102 publishStatus = 'publish'; 10103 } 10104 const onClickButton = () => { 10105 if (isButtonDisabled) { 10106 return; 10107 } 10108 onSubmit(); 10109 onStatusChange(publishStatus); 10110 onSave(); 10111 }; 10112 const onClickToggle = () => { 10113 if (isToggleDisabled) { 10114 return; 10115 } 10116 onToggle(); 10117 }; 10118 const buttonProps = { 10119 'aria-disabled': isButtonDisabled, 10120 className: 'editor-post-publish-button', 10121 isBusy: !isAutoSaving && isSaving, 10122 variant: 'primary', 10123 onClick: this.createOnClick(onClickButton) 10124 }; 10125 const toggleProps = { 10126 'aria-disabled': isToggleDisabled, 10127 'aria-expanded': isOpen, 10128 className: 'editor-post-publish-panel__toggle', 10129 isBusy: isSaving && isPublished, 10130 variant: 'primary', 10131 size: 'compact', 10132 onClick: this.createOnClick(onClickToggle) 10133 }; 10134 const toggleChildren = isBeingScheduled ? (0,external_wp_i18n_namespaceObject.__)('Schedule…') : (0,external_wp_i18n_namespaceObject.__)('Publish'); 10135 const buttonChildren = (0,external_React_.createElement)(label, { 10136 hasNonPostEntityChanges: hasNonPostEntityChanges 10137 }); 10138 const componentProps = isToggle ? toggleProps : buttonProps; 10139 const componentChildren = isToggle ? toggleChildren : buttonChildren; 10140 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 10141 ref: this.buttonNode, 10142 ...componentProps, 10143 className: classnames_default()(componentProps.className, 'editor-post-publish-button__button', { 10144 'has-changes-dot': hasNonPostEntityChanges 10145 }) 10146 }, componentChildren)); 10147 } 10148 } 10149 /* harmony default export */ const post_publish_button = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => { 10150 var _getCurrentPost$_link; 10151 const { 10152 isSavingPost, 10153 isAutosavingPost, 10154 isEditedPostBeingScheduled, 10155 getEditedPostVisibility, 10156 isCurrentPostPublished, 10157 isEditedPostSaveable, 10158 isEditedPostPublishable, 10159 isPostSavingLocked, 10160 getCurrentPost, 10161 getCurrentPostType, 10162 getCurrentPostId, 10163 hasNonPostEntityChanges, 10164 isSavingNonPostEntityChanges 10165 } = select(store_store); 10166 return { 10167 isSaving: isSavingPost(), 10168 isAutoSaving: isAutosavingPost(), 10169 isBeingScheduled: isEditedPostBeingScheduled(), 10170 visibility: getEditedPostVisibility(), 10171 isSaveable: isEditedPostSaveable(), 10172 isPostSavingLocked: isPostSavingLocked(), 10173 isPublishable: isEditedPostPublishable(), 10174 isPublished: isCurrentPostPublished(), 10175 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false, 10176 postType: getCurrentPostType(), 10177 postId: getCurrentPostId(), 10178 hasNonPostEntityChanges: hasNonPostEntityChanges(), 10179 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges() 10180 }; 10181 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => { 10182 const { 10183 editPost, 10184 savePost 10185 } = dispatch(store_store); 10186 return { 10187 onStatusChange: status => editPost({ 10188 status 10189 }, { 10190 undoIgnore: true 10191 }), 10192 onSave: savePost 10193 }; 10194 })])(PostPublishButton)); 10195 10196 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close-small.js 10197 10198 /** 10199 * WordPress dependencies 10200 */ 10201 10202 const closeSmall = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 10203 xmlns: "http://www.w3.org/2000/svg", 10204 viewBox: "0 0 24 24" 10205 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 10206 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" 10207 })); 10208 /* harmony default export */ const close_small = (closeSmall); 10209 10210 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/wordpress.js 10211 10212 /** 10213 * WordPress dependencies 10214 */ 10215 10216 const wordpress = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 10217 xmlns: "http://www.w3.org/2000/svg", 10218 viewBox: "-2 -2 24 24" 10219 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 10220 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" 10221 })); 10222 /* harmony default export */ const library_wordpress = (wordpress); 10223 10224 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/utils.js 10225 /** 10226 * WordPress dependencies 10227 */ 10228 10229 const visibilityOptions = { 10230 public: { 10231 label: (0,external_wp_i18n_namespaceObject.__)('Public'), 10232 info: (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.') 10233 }, 10234 private: { 10235 label: (0,external_wp_i18n_namespaceObject.__)('Private'), 10236 info: (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.') 10237 }, 10238 password: { 10239 label: (0,external_wp_i18n_namespaceObject.__)('Password protected'), 10240 info: (0,external_wp_i18n_namespaceObject.__)('Only those with the password can view this post.') 10241 } 10242 }; 10243 10244 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/index.js 10245 10246 /** 10247 * WordPress dependencies 10248 */ 10249 10250 10251 10252 10253 10254 10255 10256 /** 10257 * Internal dependencies 10258 */ 10259 10260 10261 function PostVisibility({ 10262 onClose 10263 }) { 10264 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostVisibility); 10265 const { 10266 status, 10267 visibility, 10268 password 10269 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ 10270 status: select(store_store).getEditedPostAttribute('status'), 10271 visibility: select(store_store).getEditedPostVisibility(), 10272 password: select(store_store).getEditedPostAttribute('password') 10273 })); 10274 const { 10275 editPost, 10276 savePost 10277 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 10278 const [hasPassword, setHasPassword] = (0,external_wp_element_namespaceObject.useState)(!!password); 10279 const [showPrivateConfirmDialog, setShowPrivateConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false); 10280 const setPublic = () => { 10281 editPost({ 10282 status: visibility === 'private' ? 'draft' : status, 10283 password: '' 10284 }); 10285 setHasPassword(false); 10286 }; 10287 const setPrivate = () => { 10288 setShowPrivateConfirmDialog(true); 10289 }; 10290 const confirmPrivate = () => { 10291 editPost({ 10292 status: 'private', 10293 password: '' 10294 }); 10295 setHasPassword(false); 10296 setShowPrivateConfirmDialog(false); 10297 savePost(); 10298 }; 10299 const handleDialogCancel = () => { 10300 setShowPrivateConfirmDialog(false); 10301 }; 10302 const setPasswordProtected = () => { 10303 editPost({ 10304 status: visibility === 'private' ? 'draft' : status, 10305 password: password || '' 10306 }); 10307 setHasPassword(true); 10308 }; 10309 const updatePassword = event => { 10310 editPost({ 10311 password: event.target.value 10312 }); 10313 }; 10314 return (0,external_React_.createElement)("div", { 10315 className: "editor-post-visibility" 10316 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, { 10317 title: (0,external_wp_i18n_namespaceObject.__)('Visibility'), 10318 help: (0,external_wp_i18n_namespaceObject.__)('Control how this post is viewed.'), 10319 onClose: onClose 10320 }), (0,external_React_.createElement)("fieldset", { 10321 className: "editor-post-visibility__fieldset" 10322 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 10323 as: "legend" 10324 }, (0,external_wp_i18n_namespaceObject.__)('Visibility')), (0,external_React_.createElement)(PostVisibilityChoice, { 10325 instanceId: instanceId, 10326 value: "public", 10327 label: visibilityOptions.public.label, 10328 info: visibilityOptions.public.info, 10329 checked: visibility === 'public' && !hasPassword, 10330 onChange: setPublic 10331 }), (0,external_React_.createElement)(PostVisibilityChoice, { 10332 instanceId: instanceId, 10333 value: "private", 10334 label: visibilityOptions.private.label, 10335 info: visibilityOptions.private.info, 10336 checked: visibility === 'private', 10337 onChange: setPrivate 10338 }), (0,external_React_.createElement)(PostVisibilityChoice, { 10339 instanceId: instanceId, 10340 value: "password", 10341 label: visibilityOptions.password.label, 10342 info: visibilityOptions.password.info, 10343 checked: hasPassword, 10344 onChange: setPasswordProtected 10345 }), hasPassword && (0,external_React_.createElement)("div", { 10346 className: "editor-post-visibility__password" 10347 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 10348 as: "label", 10349 htmlFor: `editor-post-visibility__password-input-$instanceId}` 10350 }, (0,external_wp_i18n_namespaceObject.__)('Create password')), (0,external_React_.createElement)("input", { 10351 className: "editor-post-visibility__password-input", 10352 id: `editor-post-visibility__password-input-$instanceId}`, 10353 type: "text", 10354 onChange: updatePassword, 10355 value: password, 10356 placeholder: (0,external_wp_i18n_namespaceObject.__)('Use a secure password') 10357 }))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { 10358 isOpen: showPrivateConfirmDialog, 10359 onConfirm: confirmPrivate, 10360 onCancel: handleDialogCancel 10361 }, (0,external_wp_i18n_namespaceObject.__)('Would you like to privately publish this post now?'))); 10362 } 10363 function PostVisibilityChoice({ 10364 instanceId, 10365 value, 10366 label, 10367 info, 10368 ...props 10369 }) { 10370 return (0,external_React_.createElement)("div", { 10371 className: "editor-post-visibility__choice" 10372 }, (0,external_React_.createElement)("input", { 10373 type: "radio", 10374 name: `editor-post-visibility__setting-$instanceId}`, 10375 value: value, 10376 id: `editor-post-$value}-$instanceId}`, 10377 "aria-describedby": `editor-post-$value}-$instanceId}-description`, 10378 className: "editor-post-visibility__radio", 10379 ...props 10380 }), (0,external_React_.createElement)("label", { 10381 htmlFor: `editor-post-$value}-$instanceId}`, 10382 className: "editor-post-visibility__label" 10383 }, label), (0,external_React_.createElement)("p", { 10384 id: `editor-post-$value}-$instanceId}-description`, 10385 className: "editor-post-visibility__info" 10386 }, info)); 10387 } 10388 10389 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/label.js 10390 /** 10391 * WordPress dependencies 10392 */ 10393 10394 10395 /** 10396 * Internal dependencies 10397 */ 10398 10399 10400 function PostVisibilityLabel() { 10401 return usePostVisibilityLabel(); 10402 } 10403 function usePostVisibilityLabel() { 10404 const visibility = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostVisibility()); 10405 return visibilityOptions[visibility]?.label; 10406 } 10407 10408 ;// CONCATENATED MODULE: ./node_modules/date-fns/esm/_lib/requiredArgs/index.js 10409 function requiredArgs(required, args) { 10410 if (args.length < required) { 10411 throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present'); 10412 } 10413 } 10414 ;// CONCATENATED MODULE: ./node_modules/date-fns/esm/toDate/index.js 10415 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 10416 10417 10418 /** 10419 * @name toDate 10420 * @category Common Helpers 10421 * @summary Convert the given argument to an instance of Date. 10422 * 10423 * @description 10424 * Convert the given argument to an instance of Date. 10425 * 10426 * If the argument is an instance of Date, the function returns its clone. 10427 * 10428 * If the argument is a number, it is treated as a timestamp. 10429 * 10430 * If the argument is none of the above, the function returns Invalid Date. 10431 * 10432 * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`. 10433 * 10434 * @param {Date|Number} argument - the value to convert 10435 * @returns {Date} the parsed date in the local time zone 10436 * @throws {TypeError} 1 argument required 10437 * 10438 * @example 10439 * // Clone the date: 10440 * const result = toDate(new Date(2014, 1, 11, 11, 30, 30)) 10441 * //=> Tue Feb 11 2014 11:30:30 10442 * 10443 * @example 10444 * // Convert the timestamp to date: 10445 * const result = toDate(1392098430000) 10446 * //=> Tue Feb 11 2014 11:30:30 10447 */ 10448 10449 function toDate(argument) { 10450 requiredArgs(1, arguments); 10451 var argStr = Object.prototype.toString.call(argument); // Clone the date 10452 10453 if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') { 10454 // Prevent the date to lose the milliseconds when passed to new Date() in IE10 10455 return new Date(argument.getTime()); 10456 } else if (typeof argument === 'number' || argStr === '[object Number]') { 10457 return new Date(argument); 10458 } else { 10459 if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') { 10460 // eslint-disable-next-line no-console 10461 console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"); // eslint-disable-next-line no-console 10462 10463 console.warn(new Error().stack); 10464 } 10465 10466 return new Date(NaN); 10467 } 10468 } 10469 ;// CONCATENATED MODULE: ./node_modules/date-fns/esm/startOfMonth/index.js 10470 10471 10472 /** 10473 * @name startOfMonth 10474 * @category Month Helpers 10475 * @summary Return the start of a month for the given date. 10476 * 10477 * @description 10478 * Return the start of a month for the given date. 10479 * The result will be in the local timezone. 10480 * 10481 * @param {Date|Number} date - the original date 10482 * @returns {Date} the start of a month 10483 * @throws {TypeError} 1 argument required 10484 * 10485 * @example 10486 * // The start of a month for 2 September 2014 11:55:00: 10487 * const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0)) 10488 * //=> Mon Sep 01 2014 00:00:00 10489 */ 10490 10491 function startOfMonth(dirtyDate) { 10492 requiredArgs(1, arguments); 10493 var date = toDate(dirtyDate); 10494 date.setDate(1); 10495 date.setHours(0, 0, 0, 0); 10496 return date; 10497 } 10498 ;// CONCATENATED MODULE: ./node_modules/date-fns/esm/endOfMonth/index.js 10499 10500 10501 /** 10502 * @name endOfMonth 10503 * @category Month Helpers 10504 * @summary Return the end of a month for the given date. 10505 * 10506 * @description 10507 * Return the end of a month for the given date. 10508 * The result will be in the local timezone. 10509 * 10510 * @param {Date|Number} date - the original date 10511 * @returns {Date} the end of a month 10512 * @throws {TypeError} 1 argument required 10513 * 10514 * @example 10515 * // The end of a month for 2 September 2014 11:55:00: 10516 * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0)) 10517 * //=> Tue Sep 30 2014 23:59:59.999 10518 */ 10519 10520 function endOfMonth(dirtyDate) { 10521 requiredArgs(1, arguments); 10522 var date = toDate(dirtyDate); 10523 var month = date.getMonth(); 10524 date.setFullYear(date.getFullYear(), month + 1, 0); 10525 date.setHours(23, 59, 59, 999); 10526 return date; 10527 } 10528 ;// CONCATENATED MODULE: ./node_modules/date-fns/esm/constants/index.js 10529 /** 10530 * Days in 1 week. 10531 * 10532 * @name daysInWeek 10533 * @constant 10534 * @type {number} 10535 * @default 10536 */ 10537 var daysInWeek = 7; 10538 /** 10539 * Days in 1 year 10540 * One years equals 365.2425 days according to the formula: 10541 * 10542 * > Leap year occures every 4 years, except for years that are divisable by 100 and not divisable by 400. 10543 * > 1 mean year = (365+1/4-1/100+1/400) days = 365.2425 days 10544 * 10545 * @name daysInYear 10546 * @constant 10547 * @type {number} 10548 * @default 10549 */ 10550 10551 var daysInYear = 365.2425; 10552 /** 10553 * Maximum allowed time. 10554 * 10555 * @name maxTime 10556 * @constant 10557 * @type {number} 10558 * @default 10559 */ 10560 10561 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1000; 10562 /** 10563 * Milliseconds in 1 minute 10564 * 10565 * @name millisecondsInMinute 10566 * @constant 10567 * @type {number} 10568 * @default 10569 */ 10570 10571 var millisecondsInMinute = 60000; 10572 /** 10573 * Milliseconds in 1 hour 10574 * 10575 * @name millisecondsInHour 10576 * @constant 10577 * @type {number} 10578 * @default 10579 */ 10580 10581 var millisecondsInHour = 3600000; 10582 /** 10583 * Milliseconds in 1 second 10584 * 10585 * @name millisecondsInSecond 10586 * @constant 10587 * @type {number} 10588 * @default 10589 */ 10590 10591 var millisecondsInSecond = 1000; 10592 /** 10593 * Minimum allowed time. 10594 * 10595 * @name minTime 10596 * @constant 10597 * @type {number} 10598 * @default 10599 */ 10600 10601 var minTime = -maxTime; 10602 /** 10603 * Minutes in 1 hour 10604 * 10605 * @name minutesInHour 10606 * @constant 10607 * @type {number} 10608 * @default 10609 */ 10610 10611 var minutesInHour = 60; 10612 /** 10613 * Months in 1 quarter 10614 * 10615 * @name monthsInQuarter 10616 * @constant 10617 * @type {number} 10618 * @default 10619 */ 10620 10621 var monthsInQuarter = 3; 10622 /** 10623 * Months in 1 year 10624 * 10625 * @name monthsInYear 10626 * @constant 10627 * @type {number} 10628 * @default 10629 */ 10630 10631 var monthsInYear = 12; 10632 /** 10633 * Quarters in 1 year 10634 * 10635 * @name quartersInYear 10636 * @constant 10637 * @type {number} 10638 * @default 10639 */ 10640 10641 var quartersInYear = 4; 10642 /** 10643 * Seconds in 1 hour 10644 * 10645 * @name secondsInHour 10646 * @constant 10647 * @type {number} 10648 * @default 10649 */ 10650 10651 var secondsInHour = 3600; 10652 /** 10653 * Seconds in 1 minute 10654 * 10655 * @name secondsInMinute 10656 * @constant 10657 * @type {number} 10658 * @default 10659 */ 10660 10661 var secondsInMinute = 60; 10662 /** 10663 * Seconds in 1 day 10664 * 10665 * @name secondsInDay 10666 * @constant 10667 * @type {number} 10668 * @default 10669 */ 10670 10671 var secondsInDay = secondsInHour * 24; 10672 /** 10673 * Seconds in 1 week 10674 * 10675 * @name secondsInWeek 10676 * @constant 10677 * @type {number} 10678 * @default 10679 */ 10680 10681 var secondsInWeek = secondsInDay * 7; 10682 /** 10683 * Seconds in 1 year 10684 * 10685 * @name secondsInYear 10686 * @constant 10687 * @type {number} 10688 * @default 10689 */ 10690 10691 var secondsInYear = secondsInDay * daysInYear; 10692 /** 10693 * Seconds in 1 month 10694 * 10695 * @name secondsInMonth 10696 * @constant 10697 * @type {number} 10698 * @default 10699 */ 10700 10701 var secondsInMonth = secondsInYear / 12; 10702 /** 10703 * Seconds in 1 quarter 10704 * 10705 * @name secondsInQuarter 10706 * @constant 10707 * @type {number} 10708 * @default 10709 */ 10710 10711 var secondsInQuarter = secondsInMonth * 3; 10712 ;// CONCATENATED MODULE: ./node_modules/date-fns/esm/_lib/toInteger/index.js 10713 function toInteger(dirtyNumber) { 10714 if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) { 10715 return NaN; 10716 } 10717 10718 var number = Number(dirtyNumber); 10719 10720 if (isNaN(number)) { 10721 return number; 10722 } 10723 10724 return number < 0 ? Math.ceil(number) : Math.floor(number); 10725 } 10726 ;// CONCATENATED MODULE: ./node_modules/date-fns/esm/parseISO/index.js 10727 10728 10729 10730 /** 10731 * @name parseISO 10732 * @category Common Helpers 10733 * @summary Parse ISO string 10734 * 10735 * @description 10736 * Parse the given string in ISO 8601 format and return an instance of Date. 10737 * 10738 * Function accepts complete ISO 8601 formats as well as partial implementations. 10739 * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601 10740 * 10741 * If the argument isn't a string, the function cannot parse the string or 10742 * the values are invalid, it returns Invalid Date. 10743 * 10744 * @param {String} argument - the value to convert 10745 * @param {Object} [options] - an object with options. 10746 * @param {0|1|2} [options.additionalDigits=2] - the additional number of digits in the extended year format 10747 * @returns {Date} the parsed date in the local time zone 10748 * @throws {TypeError} 1 argument required 10749 * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 10750 * 10751 * @example 10752 * // Convert string '2014-02-11T11:30:30' to date: 10753 * const result = parseISO('2014-02-11T11:30:30') 10754 * //=> Tue Feb 11 2014 11:30:30 10755 * 10756 * @example 10757 * // Convert string '+02014101' to date, 10758 * // if the additional number of digits in the extended year format is 1: 10759 * const result = parseISO('+02014101', { additionalDigits: 1 }) 10760 * //=> Fri Apr 11 2014 00:00:00 10761 */ 10762 10763 function parseISO(argument, options) { 10764 var _options$additionalDi; 10765 10766 requiredArgs(1, arguments); 10767 var additionalDigits = toInteger((_options$additionalDi = options === null || options === void 0 ? void 0 : options.additionalDigits) !== null && _options$additionalDi !== void 0 ? _options$additionalDi : 2); 10768 10769 if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) { 10770 throw new RangeError('additionalDigits must be 0, 1 or 2'); 10771 } 10772 10773 if (!(typeof argument === 'string' || Object.prototype.toString.call(argument) === '[object String]')) { 10774 return new Date(NaN); 10775 } 10776 10777 var dateStrings = splitDateString(argument); 10778 var date; 10779 10780 if (dateStrings.date) { 10781 var parseYearResult = parseYear(dateStrings.date, additionalDigits); 10782 date = parseDate(parseYearResult.restDateString, parseYearResult.year); 10783 } 10784 10785 if (!date || isNaN(date.getTime())) { 10786 return new Date(NaN); 10787 } 10788 10789 var timestamp = date.getTime(); 10790 var time = 0; 10791 var offset; 10792 10793 if (dateStrings.time) { 10794 time = parseTime(dateStrings.time); 10795 10796 if (isNaN(time)) { 10797 return new Date(NaN); 10798 } 10799 } 10800 10801 if (dateStrings.timezone) { 10802 offset = parseTimezone(dateStrings.timezone); 10803 10804 if (isNaN(offset)) { 10805 return new Date(NaN); 10806 } 10807 } else { 10808 var dirtyDate = new Date(timestamp + time); // js parsed string assuming it's in UTC timezone 10809 // but we need it to be parsed in our timezone 10810 // so we use utc values to build date in our timezone. 10811 // Year values from 0 to 99 map to the years 1900 to 1999 10812 // so set year explicitly with setFullYear. 10813 10814 var result = new Date(0); 10815 result.setFullYear(dirtyDate.getUTCFullYear(), dirtyDate.getUTCMonth(), dirtyDate.getUTCDate()); 10816 result.setHours(dirtyDate.getUTCHours(), dirtyDate.getUTCMinutes(), dirtyDate.getUTCSeconds(), dirtyDate.getUTCMilliseconds()); 10817 return result; 10818 } 10819 10820 return new Date(timestamp + time + offset); 10821 } 10822 var patterns = { 10823 dateTimeDelimiter: /[T ]/, 10824 timeZoneDelimiter: /[Z ]/i, 10825 timezone: /([Z+-].*)$/ 10826 }; 10827 var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/; 10828 var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/; 10829 var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/; 10830 10831 function splitDateString(dateString) { 10832 var dateStrings = {}; 10833 var array = dateString.split(patterns.dateTimeDelimiter); 10834 var timeString; // The regex match should only return at maximum two array elements. 10835 // [date], [time], or [date, time]. 10836 10837 if (array.length > 2) { 10838 return dateStrings; 10839 } 10840 10841 if (/:/.test(array[0])) { 10842 timeString = array[0]; 10843 } else { 10844 dateStrings.date = array[0]; 10845 timeString = array[1]; 10846 10847 if (patterns.timeZoneDelimiter.test(dateStrings.date)) { 10848 dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0]; 10849 timeString = dateString.substr(dateStrings.date.length, dateString.length); 10850 } 10851 } 10852 10853 if (timeString) { 10854 var token = patterns.timezone.exec(timeString); 10855 10856 if (token) { 10857 dateStrings.time = timeString.replace(token[1], ''); 10858 dateStrings.timezone = token[1]; 10859 } else { 10860 dateStrings.time = timeString; 10861 } 10862 } 10863 10864 return dateStrings; 10865 } 10866 10867 function parseYear(dateString, additionalDigits) { 10868 var regex = new RegExp('^(?:(\\d{4}|[+-]\\d{' + (4 + additionalDigits) + '})|(\\d{2}|[+-]\\d{' + (2 + additionalDigits) + '})$)'); 10869 var captures = dateString.match(regex); // Invalid ISO-formatted year 10870 10871 if (!captures) return { 10872 year: NaN, 10873 restDateString: '' 10874 }; 10875 var year = captures[1] ? parseInt(captures[1]) : null; 10876 var century = captures[2] ? parseInt(captures[2]) : null; // either year or century is null, not both 10877 10878 return { 10879 year: century === null ? year : century * 100, 10880 restDateString: dateString.slice((captures[1] || captures[2]).length) 10881 }; 10882 } 10883 10884 function parseDate(dateString, year) { 10885 // Invalid ISO-formatted year 10886 if (year === null) return new Date(NaN); 10887 var captures = dateString.match(dateRegex); // Invalid ISO-formatted string 10888 10889 if (!captures) return new Date(NaN); 10890 var isWeekDate = !!captures[4]; 10891 var dayOfYear = parseDateUnit(captures[1]); 10892 var month = parseDateUnit(captures[2]) - 1; 10893 var day = parseDateUnit(captures[3]); 10894 var week = parseDateUnit(captures[4]); 10895 var dayOfWeek = parseDateUnit(captures[5]) - 1; 10896 10897 if (isWeekDate) { 10898 if (!validateWeekDate(year, week, dayOfWeek)) { 10899 return new Date(NaN); 10900 } 10901 10902 return dayOfISOWeekYear(year, week, dayOfWeek); 10903 } else { 10904 var date = new Date(0); 10905 10906 if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) { 10907 return new Date(NaN); 10908 } 10909 10910 date.setUTCFullYear(year, month, Math.max(dayOfYear, day)); 10911 return date; 10912 } 10913 } 10914 10915 function parseDateUnit(value) { 10916 return value ? parseInt(value) : 1; 10917 } 10918 10919 function parseTime(timeString) { 10920 var captures = timeString.match(timeRegex); 10921 if (!captures) return NaN; // Invalid ISO-formatted time 10922 10923 var hours = parseTimeUnit(captures[1]); 10924 var minutes = parseTimeUnit(captures[2]); 10925 var seconds = parseTimeUnit(captures[3]); 10926 10927 if (!validateTime(hours, minutes, seconds)) { 10928 return NaN; 10929 } 10930 10931 return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1000; 10932 } 10933 10934 function parseTimeUnit(value) { 10935 return value && parseFloat(value.replace(',', '.')) || 0; 10936 } 10937 10938 function parseTimezone(timezoneString) { 10939 if (timezoneString === 'Z') return 0; 10940 var captures = timezoneString.match(timezoneRegex); 10941 if (!captures) return 0; 10942 var sign = captures[1] === '+' ? -1 : 1; 10943 var hours = parseInt(captures[2]); 10944 var minutes = captures[3] && parseInt(captures[3]) || 0; 10945 10946 if (!validateTimezone(hours, minutes)) { 10947 return NaN; 10948 } 10949 10950 return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute); 10951 } 10952 10953 function dayOfISOWeekYear(isoWeekYear, week, day) { 10954 var date = new Date(0); 10955 date.setUTCFullYear(isoWeekYear, 0, 4); 10956 var fourthOfJanuaryDay = date.getUTCDay() || 7; 10957 var diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay; 10958 date.setUTCDate(date.getUTCDate() + diff); 10959 return date; 10960 } // Validation functions 10961 // February is null to handle the leap year (using ||) 10962 10963 10964 var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; 10965 10966 function isLeapYearIndex(year) { 10967 return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0; 10968 } 10969 10970 function validateDate(year, month, date) { 10971 return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28)); 10972 } 10973 10974 function validateDayOfYearDate(year, dayOfYear) { 10975 return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365); 10976 } 10977 10978 function validateWeekDate(_year, week, day) { 10979 return week >= 1 && week <= 53 && day >= 0 && day <= 6; 10980 } 10981 10982 function validateTime(hours, minutes, seconds) { 10983 if (hours === 24) { 10984 return minutes === 0 && seconds === 0; 10985 } 10986 10987 return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25; 10988 } 10989 10990 function validateTimezone(_hours, minutes) { 10991 return minutes >= 0 && minutes <= 59; 10992 } 10993 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-schedule/index.js 10994 10995 /** 10996 * External dependencies 10997 */ 10998 10999 11000 /** 11001 * WordPress dependencies 11002 */ 11003 11004 11005 11006 11007 11008 11009 /** 11010 * Internal dependencies 11011 */ 11012 11013 function PostSchedule({ 11014 onClose 11015 }) { 11016 const { 11017 postDate, 11018 postType 11019 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ 11020 postDate: select(store_store).getEditedPostAttribute('date'), 11021 postType: select(store_store).getCurrentPostType() 11022 }), []); 11023 const { 11024 editPost 11025 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 11026 const onUpdateDate = date => editPost({ 11027 date 11028 }); 11029 const [previewedMonth, setPreviewedMonth] = (0,external_wp_element_namespaceObject.useState)(startOfMonth(new Date(postDate))); 11030 11031 // Pick up published and schduled site posts. 11032 const eventsByPostType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', postType, { 11033 status: 'publish,future', 11034 after: startOfMonth(previewedMonth).toISOString(), 11035 before: endOfMonth(previewedMonth).toISOString(), 11036 exclude: [select(store_store).getCurrentPostId()], 11037 per_page: 100, 11038 _fields: 'id,date' 11039 }), [previewedMonth, postType]); 11040 const events = (0,external_wp_element_namespaceObject.useMemo)(() => (eventsByPostType || []).map(({ 11041 date: eventDate 11042 }) => ({ 11043 date: new Date(eventDate) 11044 })), [eventsByPostType]); 11045 const settings = (0,external_wp_date_namespaceObject.getSettings)(); 11046 11047 // To know if the current timezone is a 12 hour time with look for "a" in the time format 11048 // We also make sure this a is not escaped by a "/" 11049 const is12HourTime = /a(?!\\)/i.test(settings.formats.time.toLowerCase() // Test only the lower case a. 11050 .replace(/\\\\/g, '') // Replace "//" with empty strings. 11051 .split('').reverse().join('') // Reverse the string and test for "a" not followed by a slash. 11052 ); 11053 return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__experimentalPublishDateTimePicker, { 11054 currentDate: postDate, 11055 onChange: onUpdateDate, 11056 is12Hour: is12HourTime, 11057 events: events, 11058 onMonthPreviewed: date => setPreviewedMonth(parseISO(date)), 11059 onClose: onClose 11060 }); 11061 } 11062 11063 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-schedule/label.js 11064 /** 11065 * WordPress dependencies 11066 */ 11067 11068 11069 11070 11071 /** 11072 * Internal dependencies 11073 */ 11074 11075 function PostScheduleLabel(props) { 11076 return usePostScheduleLabel(props); 11077 } 11078 function usePostScheduleLabel({ 11079 full = false 11080 } = {}) { 11081 const { 11082 date, 11083 isFloating 11084 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ 11085 date: select(store_store).getEditedPostAttribute('date'), 11086 isFloating: select(store_store).isEditedPostDateFloating() 11087 }), []); 11088 return full ? getFullPostScheduleLabel(date) : getPostScheduleLabel(date, { 11089 isFloating 11090 }); 11091 } 11092 function getFullPostScheduleLabel(dateAttribute) { 11093 const date = (0,external_wp_date_namespaceObject.getDate)(dateAttribute); 11094 const timezoneAbbreviation = getTimezoneAbbreviation(); 11095 const formattedDate = (0,external_wp_date_namespaceObject.dateI18n)( 11096 // translators: If using a space between 'g:i' and 'a', use a non-breaking space. 11097 (0,external_wp_i18n_namespaceObject._x)('F j, Y g:i\xa0a', 'post schedule full date format'), date); 11098 return (0,external_wp_i18n_namespaceObject.isRTL)() ? `$timezoneAbbreviation} $formattedDate}` : `$formattedDate} $timezoneAbbreviation}`; 11099 } 11100 function getPostScheduleLabel(dateAttribute, { 11101 isFloating = false, 11102 now = new Date() 11103 } = {}) { 11104 if (!dateAttribute || isFloating) { 11105 return (0,external_wp_i18n_namespaceObject.__)('Immediately'); 11106 } 11107 11108 // If the user timezone does not equal the site timezone then using words 11109 // like 'tomorrow' is confusing, so show the full date. 11110 if (!isTimezoneSameAsSiteTimezone(now)) { 11111 return getFullPostScheduleLabel(dateAttribute); 11112 } 11113 const date = (0,external_wp_date_namespaceObject.getDate)(dateAttribute); 11114 if (isSameDay(date, now)) { 11115 return (0,external_wp_i18n_namespaceObject.sprintf)( 11116 // translators: %s: Time of day the post is scheduled for. 11117 (0,external_wp_i18n_namespaceObject.__)('Today at %s'), 11118 // translators: If using a space between 'g:i' and 'a', use a non-breaking space. 11119 (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_i18n_namespaceObject._x)('g:i\xa0a', 'post schedule time format'), date)); 11120 } 11121 const tomorrow = new Date(now); 11122 tomorrow.setDate(tomorrow.getDate() + 1); 11123 if (isSameDay(date, tomorrow)) { 11124 return (0,external_wp_i18n_namespaceObject.sprintf)( 11125 // translators: %s: Time of day the post is scheduled for. 11126 (0,external_wp_i18n_namespaceObject.__)('Tomorrow at %s'), 11127 // translators: If using a space between 'g:i' and 'a', use a non-breaking space. 11128 (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_i18n_namespaceObject._x)('g:i\xa0a', 'post schedule time format'), date)); 11129 } 11130 if (date.getFullYear() === now.getFullYear()) { 11131 return (0,external_wp_date_namespaceObject.dateI18n)( 11132 // translators: If using a space between 'g:i' and 'a', use a non-breaking space. 11133 (0,external_wp_i18n_namespaceObject._x)('F j g:i\xa0a', 'post schedule date format without year'), date); 11134 } 11135 return (0,external_wp_date_namespaceObject.dateI18n)( 11136 // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate. 11137 (0,external_wp_i18n_namespaceObject._x)('F j, Y g:i\xa0a', 'post schedule full date format'), date); 11138 } 11139 function getTimezoneAbbreviation() { 11140 const { 11141 timezone 11142 } = (0,external_wp_date_namespaceObject.getSettings)(); 11143 if (timezone.abbr && isNaN(Number(timezone.abbr))) { 11144 return timezone.abbr; 11145 } 11146 const symbol = timezone.offset < 0 ? '' : '+'; 11147 return `UTC$symbol}$timezone.offsetFormatted}`; 11148 } 11149 function isTimezoneSameAsSiteTimezone(date) { 11150 const { 11151 timezone 11152 } = (0,external_wp_date_namespaceObject.getSettings)(); 11153 const siteOffset = Number(timezone.offset); 11154 const dateOffset = -1 * (date.getTimezoneOffset() / 60); 11155 return siteOffset === dateOffset; 11156 } 11157 function isSameDay(left, right) { 11158 return left.getDate() === right.getDate() && left.getMonth() === right.getMonth() && left.getFullYear() === right.getFullYear(); 11159 } 11160 11161 ;// CONCATENATED MODULE: external ["wp","a11y"] 11162 const external_wp_a11y_namespaceObject = window["wp"]["a11y"]; 11163 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/most-used-terms.js 11164 11165 /** 11166 * WordPress dependencies 11167 */ 11168 11169 11170 11171 11172 /** 11173 * Internal dependencies 11174 */ 11175 11176 const MIN_MOST_USED_TERMS = 3; 11177 const DEFAULT_QUERY = { 11178 per_page: 10, 11179 orderby: 'count', 11180 order: 'desc', 11181 hide_empty: true, 11182 _fields: 'id,name,count', 11183 context: 'view' 11184 }; 11185 function MostUsedTerms({ 11186 onSelect, 11187 taxonomy 11188 }) { 11189 const { 11190 _terms, 11191 showTerms 11192 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 11193 const mostUsedTerms = select(external_wp_coreData_namespaceObject.store).getEntityRecords('taxonomy', taxonomy.slug, DEFAULT_QUERY); 11194 return { 11195 _terms: mostUsedTerms, 11196 showTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS 11197 }; 11198 }, [taxonomy.slug]); 11199 if (!showTerms) { 11200 return null; 11201 } 11202 const terms = unescapeTerms(_terms); 11203 return (0,external_React_.createElement)("div", { 11204 className: "editor-post-taxonomies__flat-term-most-used" 11205 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.BaseControl.VisualLabel, { 11206 as: "h3", 11207 className: "editor-post-taxonomies__flat-term-most-used-label" 11208 }, taxonomy.labels.most_used), (0,external_React_.createElement)("ul", { 11209 role: "list", 11210 className: "editor-post-taxonomies__flat-term-most-used-list" 11211 }, terms.map(term => (0,external_React_.createElement)("li", { 11212 key: term.id 11213 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 11214 variant: "link", 11215 onClick: () => onSelect(term) 11216 }, term.name))))); 11217 } 11218 11219 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/flat-term-selector.js 11220 11221 /** 11222 * WordPress dependencies 11223 */ 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 /** 11234 * Internal dependencies 11235 */ 11236 11237 11238 11239 11240 /** 11241 * Shared reference to an empty array for cases where it is important to avoid 11242 * returning a new array reference on every invocation. 11243 * 11244 * @type {Array<any>} 11245 */ 11246 const EMPTY_ARRAY = []; 11247 11248 /** 11249 * Module constants 11250 */ 11251 const MAX_TERMS_SUGGESTIONS = 20; 11252 const flat_term_selector_DEFAULT_QUERY = { 11253 per_page: MAX_TERMS_SUGGESTIONS, 11254 _fields: 'id,name', 11255 context: 'view' 11256 }; 11257 const isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase(); 11258 const termNamesToIds = (names, terms) => { 11259 return names.map(termName => terms.find(term => isSameTermName(term.name, termName)).id); 11260 }; 11261 function FlatTermSelector({ 11262 slug 11263 }) { 11264 var _taxonomy$labels$add_, _taxonomy$labels$sing2; 11265 const [values, setValues] = (0,external_wp_element_namespaceObject.useState)([]); 11266 const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)(''); 11267 const debouncedSearch = (0,external_wp_compose_namespaceObject.useDebounce)(setSearch, 500); 11268 const { 11269 terms, 11270 termIds, 11271 taxonomy, 11272 hasAssignAction, 11273 hasCreateAction, 11274 hasResolvedTerms 11275 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 11276 var _post$_links, _post$_links2; 11277 const { 11278 getCurrentPost, 11279 getEditedPostAttribute 11280 } = select(store_store); 11281 const { 11282 getEntityRecords, 11283 getTaxonomy, 11284 hasFinishedResolution 11285 } = select(external_wp_coreData_namespaceObject.store); 11286 const post = getCurrentPost(); 11287 const _taxonomy = getTaxonomy(slug); 11288 const _termIds = _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : EMPTY_ARRAY; 11289 const query = { 11290 ...flat_term_selector_DEFAULT_QUERY, 11291 include: _termIds.join(','), 11292 per_page: -1 11293 }; 11294 return { 11295 hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false, 11296 hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false, 11297 taxonomy: _taxonomy, 11298 termIds: _termIds, 11299 terms: _termIds.length ? getEntityRecords('taxonomy', slug, query) : EMPTY_ARRAY, 11300 hasResolvedTerms: hasFinishedResolution('getEntityRecords', ['taxonomy', slug, query]) 11301 }; 11302 }, [slug]); 11303 const { 11304 searchResults 11305 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 11306 const { 11307 getEntityRecords 11308 } = select(external_wp_coreData_namespaceObject.store); 11309 return { 11310 searchResults: !!search ? getEntityRecords('taxonomy', slug, { 11311 ...flat_term_selector_DEFAULT_QUERY, 11312 search 11313 }) : EMPTY_ARRAY 11314 }; 11315 }, [search, slug]); 11316 11317 // Update terms state only after the selectors are resolved. 11318 // We're using this to avoid terms temporarily disappearing on slow networks 11319 // while core data makes REST API requests. 11320 (0,external_wp_element_namespaceObject.useEffect)(() => { 11321 if (hasResolvedTerms) { 11322 const newValues = (terms !== null && terms !== void 0 ? terms : []).map(term => unescapeString(term.name)); 11323 setValues(newValues); 11324 } 11325 }, [terms, hasResolvedTerms]); 11326 const suggestions = (0,external_wp_element_namespaceObject.useMemo)(() => { 11327 return (searchResults !== null && searchResults !== void 0 ? searchResults : []).map(term => unescapeString(term.name)); 11328 }, [searchResults]); 11329 const { 11330 editPost 11331 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 11332 const { 11333 saveEntityRecord 11334 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 11335 const { 11336 createErrorNotice 11337 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 11338 if (!hasAssignAction) { 11339 return null; 11340 } 11341 async function findOrCreateTerm(term) { 11342 try { 11343 const newTerm = await saveEntityRecord('taxonomy', slug, term, { 11344 throwOnError: true 11345 }); 11346 return unescapeTerm(newTerm); 11347 } catch (error) { 11348 if (error.code !== 'term_exists') { 11349 throw error; 11350 } 11351 return { 11352 id: error.data.term_id, 11353 name: term.name 11354 }; 11355 } 11356 } 11357 function onUpdateTerms(newTermIds) { 11358 editPost({ 11359 [taxonomy.rest_base]: newTermIds 11360 }); 11361 } 11362 function onChange(termNames) { 11363 const availableTerms = [...(terms !== null && terms !== void 0 ? terms : []), ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])]; 11364 const uniqueTerms = termNames.reduce((acc, name) => { 11365 if (!acc.some(n => n.toLowerCase() === name.toLowerCase())) { 11366 acc.push(name); 11367 } 11368 return acc; 11369 }, []); 11370 const newTermNames = uniqueTerms.filter(termName => !availableTerms.find(term => isSameTermName(term.name, termName))); 11371 11372 // Optimistically update term values. 11373 // The selector will always re-fetch terms later. 11374 setValues(uniqueTerms); 11375 if (newTermNames.length === 0) { 11376 return onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms)); 11377 } 11378 if (!hasCreateAction) { 11379 return; 11380 } 11381 Promise.all(newTermNames.map(termName => findOrCreateTerm({ 11382 name: termName 11383 }))).then(newTerms => { 11384 const newAvailableTerms = availableTerms.concat(newTerms); 11385 return onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms)); 11386 }).catch(error => { 11387 createErrorNotice(error.message, { 11388 type: 'snackbar' 11389 }); 11390 }); 11391 } 11392 function appendTerm(newTerm) { 11393 var _taxonomy$labels$sing; 11394 if (termIds.includes(newTerm.id)) { 11395 return; 11396 } 11397 const newTermIds = [...termIds, newTerm.id]; 11398 const defaultName = slug === 'post_tag' ? (0,external_wp_i18n_namespaceObject.__)('Tag') : (0,external_wp_i18n_namespaceObject.__)('Term'); 11399 const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */ 11400 (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); 11401 (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive'); 11402 onUpdateTerms(newTermIds); 11403 } 11404 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'); 11405 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'); 11406 const termAddedLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */ 11407 (0,external_wp_i18n_namespaceObject._x)('%s added', 'term'), singularName); 11408 const termRemovedLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */ 11409 (0,external_wp_i18n_namespaceObject._x)('%s removed', 'term'), singularName); 11410 const removeTermLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */ 11411 (0,external_wp_i18n_namespaceObject._x)('Remove %s', 'term'), singularName); 11412 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.FormTokenField, { 11413 __next40pxDefaultSize: true, 11414 value: values, 11415 suggestions: suggestions, 11416 onChange: onChange, 11417 onInputChange: debouncedSearch, 11418 maxSuggestions: MAX_TERMS_SUGGESTIONS, 11419 label: newTermLabel, 11420 messages: { 11421 added: termAddedLabel, 11422 removed: termRemovedLabel, 11423 remove: removeTermLabel 11424 } 11425 }), (0,external_React_.createElement)(MostUsedTerms, { 11426 taxonomy: taxonomy, 11427 onSelect: appendTerm 11428 })); 11429 } 11430 /* harmony default export */ const flat_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(FlatTermSelector)); 11431 11432 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/maybe-tags-panel.js 11433 11434 /** 11435 * WordPress dependencies 11436 */ 11437 11438 11439 11440 11441 11442 11443 /** 11444 * Internal dependencies 11445 */ 11446 11447 11448 const TagsPanel = () => { 11449 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), (0,external_React_.createElement)("span", { 11450 className: "editor-post-publish-panel__link", 11451 key: "label" 11452 }, (0,external_wp_i18n_namespaceObject.__)('Add tags'))]; 11453 return (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 11454 initialOpen: false, 11455 title: panelBodyTitle 11456 }, (0,external_React_.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Tags help users and search engines navigate your site and find your content. Add a few keywords to describe your post.')), (0,external_React_.createElement)(flat_term_selector, { 11457 slug: 'post_tag' 11458 })); 11459 }; 11460 const MaybeTagsPanel = () => { 11461 const { 11462 hasTags, 11463 isPostTypeSupported 11464 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 11465 const postType = select(store_store).getCurrentPostType(); 11466 const tagsTaxonomy = select(external_wp_coreData_namespaceObject.store).getTaxonomy('post_tag'); 11467 const _isPostTypeSupported = tagsTaxonomy?.types?.includes(postType); 11468 const areTagsFetched = tagsTaxonomy !== undefined; 11469 const tags = tagsTaxonomy && select(store_store).getEditedPostAttribute(tagsTaxonomy.rest_base); 11470 return { 11471 hasTags: !!tags?.length, 11472 isPostTypeSupported: areTagsFetched && _isPostTypeSupported 11473 }; 11474 }, []); 11475 const [hadTagsWhenOpeningThePanel] = (0,external_wp_element_namespaceObject.useState)(hasTags); 11476 if (!isPostTypeSupported) { 11477 return null; 11478 } 11479 11480 /* 11481 * We only want to show the tag panel if the post didn't have 11482 * any tags when the user hit the Publish button. 11483 * 11484 * We can't use the prop.hasTags because it'll change to true 11485 * if the user adds a new tag within the pre-publish panel. 11486 * This would force a re-render and a new prop.hasTags check, 11487 * hiding this panel and keeping the user from adding 11488 * more than one tag. 11489 */ 11490 if (!hadTagsWhenOpeningThePanel) { 11491 return (0,external_React_.createElement)(TagsPanel, null); 11492 } 11493 return null; 11494 }; 11495 /* harmony default export */ const maybe_tags_panel = (MaybeTagsPanel); 11496 11497 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/maybe-post-format-panel.js 11498 11499 /** 11500 * WordPress dependencies 11501 */ 11502 11503 11504 11505 11506 11507 /** 11508 * Internal dependencies 11509 */ 11510 11511 11512 const getSuggestion = (supportedFormats, suggestedPostFormat) => { 11513 const formats = POST_FORMATS.filter(format => supportedFormats?.includes(format.id)); 11514 return formats.find(format => format.id === suggestedPostFormat); 11515 }; 11516 const PostFormatSuggestion = ({ 11517 suggestedPostFormat, 11518 suggestionText, 11519 onUpdatePostFormat 11520 }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 11521 variant: "link", 11522 onClick: () => onUpdatePostFormat(suggestedPostFormat) 11523 }, suggestionText); 11524 function PostFormatPanel() { 11525 const { 11526 currentPostFormat, 11527 suggestion 11528 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 11529 var _select$getThemeSuppo; 11530 const { 11531 getEditedPostAttribute, 11532 getSuggestedPostFormat 11533 } = select(store_store); 11534 const supportedFormats = (_select$getThemeSuppo = select(external_wp_coreData_namespaceObject.store).getThemeSupports().formats) !== null && _select$getThemeSuppo !== void 0 ? _select$getThemeSuppo : []; 11535 return { 11536 currentPostFormat: getEditedPostAttribute('format'), 11537 suggestion: getSuggestion(supportedFormats, getSuggestedPostFormat()) 11538 }; 11539 }, []); 11540 const { 11541 editPost 11542 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 11543 const onUpdatePostFormat = format => editPost({ 11544 format 11545 }); 11546 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), (0,external_React_.createElement)("span", { 11547 className: "editor-post-publish-panel__link", 11548 key: "label" 11549 }, (0,external_wp_i18n_namespaceObject.__)('Use a post format'))]; 11550 if (!suggestion || suggestion.id === currentPostFormat) { 11551 return null; 11552 } 11553 return (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 11554 initialOpen: false, 11555 title: panelBodyTitle 11556 }, (0,external_React_.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Your theme uses post formats to highlight different kinds of content, like images or videos. Apply a post format to see this special styling.')), (0,external_React_.createElement)("p", null, (0,external_React_.createElement)(PostFormatSuggestion, { 11557 onUpdatePostFormat: onUpdatePostFormat, 11558 suggestedPostFormat: suggestion.id, 11559 suggestionText: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: post format */ 11560 (0,external_wp_i18n_namespaceObject.__)('Apply the "%1$s" format.'), suggestion.caption) 11561 }))); 11562 } 11563 11564 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/hierarchical-term-selector.js 11565 11566 /** 11567 * WordPress dependencies 11568 */ 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 /** 11580 * Internal dependencies 11581 */ 11582 11583 11584 11585 /** 11586 * Module Constants 11587 */ 11588 const hierarchical_term_selector_DEFAULT_QUERY = { 11589 per_page: -1, 11590 orderby: 'name', 11591 order: 'asc', 11592 _fields: 'id,name,parent', 11593 context: 'view' 11594 }; 11595 const MIN_TERMS_COUNT_FOR_FILTER = 8; 11596 const hierarchical_term_selector_EMPTY_ARRAY = []; 11597 11598 /** 11599 * Sort Terms by Selected. 11600 * 11601 * @param {Object[]} termsTree Array of terms in tree format. 11602 * @param {number[]} terms Selected terms. 11603 * 11604 * @return {Object[]} Sorted array of terms. 11605 */ 11606 function sortBySelected(termsTree, terms) { 11607 const treeHasSelection = termTree => { 11608 if (terms.indexOf(termTree.id) !== -1) { 11609 return true; 11610 } 11611 if (undefined === termTree.children) { 11612 return false; 11613 } 11614 return termTree.children.map(treeHasSelection).filter(child => child).length > 0; 11615 }; 11616 const termOrChildIsSelected = (termA, termB) => { 11617 const termASelected = treeHasSelection(termA); 11618 const termBSelected = treeHasSelection(termB); 11619 if (termASelected === termBSelected) { 11620 return 0; 11621 } 11622 if (termASelected && !termBSelected) { 11623 return -1; 11624 } 11625 if (!termASelected && termBSelected) { 11626 return 1; 11627 } 11628 return 0; 11629 }; 11630 const newTermTree = [...termsTree]; 11631 newTermTree.sort(termOrChildIsSelected); 11632 return newTermTree; 11633 } 11634 11635 /** 11636 * Find term by parent id or name. 11637 * 11638 * @param {Object[]} terms Array of Terms. 11639 * @param {number|string} parent id. 11640 * @param {string} name Term name. 11641 * @return {Object} Term object. 11642 */ 11643 function findTerm(terms, parent, name) { 11644 return terms.find(term => { 11645 return (!term.parent && !parent || parseInt(term.parent) === parseInt(parent)) && term.name.toLowerCase() === name.toLowerCase(); 11646 }); 11647 } 11648 11649 /** 11650 * Get filter matcher function. 11651 * 11652 * @param {string} filterValue Filter value. 11653 * @return {(function(Object): (Object|boolean))} Matcher function. 11654 */ 11655 function getFilterMatcher(filterValue) { 11656 const matchTermsForFilter = originalTerm => { 11657 if ('' === filterValue) { 11658 return originalTerm; 11659 } 11660 11661 // Shallow clone, because we'll be filtering the term's children and 11662 // don't want to modify the original term. 11663 const term = { 11664 ...originalTerm 11665 }; 11666 11667 // Map and filter the children, recursive so we deal with grandchildren 11668 // and any deeper levels. 11669 if (term.children.length > 0) { 11670 term.children = term.children.map(matchTermsForFilter).filter(child => child); 11671 } 11672 11673 // If the term's name contains the filterValue, or it has children 11674 // (i.e. some child matched at some point in the tree) then return it. 11675 if (-1 !== term.name.toLowerCase().indexOf(filterValue.toLowerCase()) || term.children.length > 0) { 11676 return term; 11677 } 11678 11679 // Otherwise, return false. After mapping, the list of terms will need 11680 // to have false values filtered out. 11681 return false; 11682 }; 11683 return matchTermsForFilter; 11684 } 11685 11686 /** 11687 * Hierarchical term selector. 11688 * 11689 * @param {Object} props Component props. 11690 * @param {string} props.slug Taxonomy slug. 11691 * @return {Element} Hierarchical term selector component. 11692 */ 11693 function HierarchicalTermSelector({ 11694 slug 11695 }) { 11696 var _taxonomy$labels$sear, _taxonomy$name; 11697 const [adding, setAdding] = (0,external_wp_element_namespaceObject.useState)(false); 11698 const [formName, setFormName] = (0,external_wp_element_namespaceObject.useState)(''); 11699 /** 11700 * @type {[number|'', Function]} 11701 */ 11702 const [formParent, setFormParent] = (0,external_wp_element_namespaceObject.useState)(''); 11703 const [showForm, setShowForm] = (0,external_wp_element_namespaceObject.useState)(false); 11704 const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)(''); 11705 const [filteredTermsTree, setFilteredTermsTree] = (0,external_wp_element_namespaceObject.useState)([]); 11706 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500); 11707 const { 11708 hasCreateAction, 11709 hasAssignAction, 11710 terms, 11711 loading, 11712 availableTerms, 11713 taxonomy 11714 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 11715 var _post$_links, _post$_links2; 11716 const { 11717 getCurrentPost, 11718 getEditedPostAttribute 11719 } = select(store_store); 11720 const { 11721 getTaxonomy, 11722 getEntityRecords, 11723 isResolving 11724 } = select(external_wp_coreData_namespaceObject.store); 11725 const _taxonomy = getTaxonomy(slug); 11726 const post = getCurrentPost(); 11727 return { 11728 hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false, 11729 hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false, 11730 terms: _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : hierarchical_term_selector_EMPTY_ARRAY, 11731 loading: isResolving('getEntityRecords', ['taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY]), 11732 availableTerms: getEntityRecords('taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY) || hierarchical_term_selector_EMPTY_ARRAY, 11733 taxonomy: _taxonomy 11734 }; 11735 }, [slug]); 11736 const { 11737 editPost 11738 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 11739 const { 11740 saveEntityRecord 11741 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 11742 const availableTermsTree = (0,external_wp_element_namespaceObject.useMemo)(() => sortBySelected(buildTermsTree(availableTerms), terms), 11743 // Remove `terms` from the dependency list to avoid reordering every time 11744 // checking or unchecking a term. 11745 [availableTerms]); 11746 const { 11747 createErrorNotice 11748 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 11749 if (!hasAssignAction) { 11750 return null; 11751 } 11752 11753 /** 11754 * Append new term. 11755 * 11756 * @param {Object} term Term object. 11757 * @return {Promise} A promise that resolves to save term object. 11758 */ 11759 const addTerm = term => { 11760 return saveEntityRecord('taxonomy', slug, term, { 11761 throwOnError: true 11762 }); 11763 }; 11764 11765 /** 11766 * Update terms for post. 11767 * 11768 * @param {number[]} termIds Term ids. 11769 */ 11770 const onUpdateTerms = termIds => { 11771 editPost({ 11772 [taxonomy.rest_base]: termIds 11773 }); 11774 }; 11775 11776 /** 11777 * Handler for checking term. 11778 * 11779 * @param {number} termId 11780 */ 11781 const onChange = termId => { 11782 const hasTerm = terms.includes(termId); 11783 const newTerms = hasTerm ? terms.filter(id => id !== termId) : [...terms, termId]; 11784 onUpdateTerms(newTerms); 11785 }; 11786 const onChangeFormName = value => { 11787 setFormName(value); 11788 }; 11789 11790 /** 11791 * Handler for changing form parent. 11792 * 11793 * @param {number|''} parentId Parent post id. 11794 */ 11795 const onChangeFormParent = parentId => { 11796 setFormParent(parentId); 11797 }; 11798 const onToggleForm = () => { 11799 setShowForm(!showForm); 11800 }; 11801 const onAddTerm = async event => { 11802 var _taxonomy$labels$sing; 11803 event.preventDefault(); 11804 if (formName === '' || adding) { 11805 return; 11806 } 11807 11808 // Check if the term we are adding already exists. 11809 const existingTerm = findTerm(availableTerms, formParent, formName); 11810 if (existingTerm) { 11811 // If the term we are adding exists but is not selected select it. 11812 if (!terms.some(term => term === existingTerm.id)) { 11813 onUpdateTerms([...terms, existingTerm.id]); 11814 } 11815 setFormName(''); 11816 setFormParent(''); 11817 return; 11818 } 11819 setAdding(true); 11820 let newTerm; 11821 try { 11822 newTerm = await addTerm({ 11823 name: formName, 11824 parent: formParent ? formParent : undefined 11825 }); 11826 } catch (error) { 11827 createErrorNotice(error.message, { 11828 type: 'snackbar' 11829 }); 11830 return; 11831 } 11832 const defaultName = slug === 'category' ? (0,external_wp_i18n_namespaceObject.__)('Category') : (0,external_wp_i18n_namespaceObject.__)('Term'); 11833 const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: taxonomy name */ 11834 (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); 11835 (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive'); 11836 setAdding(false); 11837 setFormName(''); 11838 setFormParent(''); 11839 onUpdateTerms([...terms, newTerm.id]); 11840 }; 11841 const setFilter = value => { 11842 const newFilteredTermsTree = availableTermsTree.map(getFilterMatcher(value)).filter(term => term); 11843 const getResultCount = termsTree => { 11844 let count = 0; 11845 for (let i = 0; i < termsTree.length; i++) { 11846 count++; 11847 if (undefined !== termsTree[i].children) { 11848 count += getResultCount(termsTree[i].children); 11849 } 11850 } 11851 return count; 11852 }; 11853 setFilterValue(value); 11854 setFilteredTermsTree(newFilteredTermsTree); 11855 const resultCount = getResultCount(newFilteredTermsTree); 11856 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of results */ 11857 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', resultCount), resultCount); 11858 debouncedSpeak(resultsFoundMessage, 'assertive'); 11859 }; 11860 const renderTerms = renderedTerms => { 11861 return renderedTerms.map(term => { 11862 return (0,external_React_.createElement)("div", { 11863 key: term.id, 11864 className: "editor-post-taxonomies__hierarchical-terms-choice" 11865 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 11866 __nextHasNoMarginBottom: true, 11867 checked: terms.indexOf(term.id) !== -1, 11868 onChange: () => { 11869 const termId = parseInt(term.id, 10); 11870 onChange(termId); 11871 }, 11872 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(term.name) 11873 }), !!term.children.length && (0,external_React_.createElement)("div", { 11874 className: "editor-post-taxonomies__hierarchical-terms-subchoices" 11875 }, renderTerms(term.children))); 11876 }); 11877 }; 11878 const labelWithFallback = (labelProperty, fallbackIsCategory, fallbackIsNotCategory) => { 11879 var _taxonomy$labels$labe; 11880 return (_taxonomy$labels$labe = taxonomy?.labels?.[labelProperty]) !== null && _taxonomy$labels$labe !== void 0 ? _taxonomy$labels$labe : slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory; 11881 }; 11882 const newTermButtonLabel = labelWithFallback('add_new_item', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term')); 11883 const newTermLabel = labelWithFallback('new_item_name', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term')); 11884 const parentSelectLabel = labelWithFallback('parent_item', (0,external_wp_i18n_namespaceObject.__)('Parent Category'), (0,external_wp_i18n_namespaceObject.__)('Parent Term')); 11885 const noParentOption = `— $parentSelectLabel} —`; 11886 const newTermSubmitLabel = newTermButtonLabel; 11887 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'); 11888 const groupLabel = (_taxonomy$name = taxonomy?.name) !== null && _taxonomy$name !== void 0 ? _taxonomy$name : (0,external_wp_i18n_namespaceObject.__)('Terms'); 11889 const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER; 11890 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 11891 direction: "column", 11892 gap: "4" 11893 }, showFilter && (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 11894 __nextHasNoMarginBottom: true, 11895 label: filterLabel, 11896 value: filterValue, 11897 onChange: setFilter 11898 }), (0,external_React_.createElement)("div", { 11899 className: "editor-post-taxonomies__hierarchical-terms-list", 11900 tabIndex: "0", 11901 role: "group", 11902 "aria-label": groupLabel 11903 }, renderTerms('' !== filterValue ? filteredTermsTree : availableTermsTree)), !loading && hasCreateAction && (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 11904 onClick: onToggleForm, 11905 className: "editor-post-taxonomies__hierarchical-terms-add", 11906 "aria-expanded": showForm, 11907 variant: "link" 11908 }, newTermButtonLabel)), showForm && (0,external_React_.createElement)("form", { 11909 onSubmit: onAddTerm 11910 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 11911 direction: "column", 11912 gap: "4" 11913 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 11914 __nextHasNoMarginBottom: true, 11915 className: "editor-post-taxonomies__hierarchical-terms-input", 11916 label: newTermLabel, 11917 value: formName, 11918 onChange: onChangeFormName, 11919 required: true 11920 }), !!availableTerms.length && (0,external_React_.createElement)(external_wp_components_namespaceObject.TreeSelect, { 11921 __nextHasNoMarginBottom: true, 11922 label: parentSelectLabel, 11923 noOptionLabel: noParentOption, 11924 onChange: onChangeFormParent, 11925 selectedId: formParent, 11926 tree: availableTermsTree 11927 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 11928 variant: "secondary", 11929 type: "submit", 11930 className: "editor-post-taxonomies__hierarchical-terms-submit" 11931 }, newTermSubmitLabel))))); 11932 } 11933 /* harmony default export */ const hierarchical_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(HierarchicalTermSelector)); 11934 11935 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/maybe-category-panel.js 11936 11937 /** 11938 * WordPress dependencies 11939 */ 11940 11941 11942 11943 11944 11945 11946 /** 11947 * Internal dependencies 11948 */ 11949 11950 11951 function MaybeCategoryPanel() { 11952 const hasNoCategory = (0,external_wp_data_namespaceObject.useSelect)(select => { 11953 const postType = select(store_store).getCurrentPostType(); 11954 const { 11955 canUser, 11956 getEntityRecord, 11957 getTaxonomy 11958 } = select(external_wp_coreData_namespaceObject.store); 11959 const categoriesTaxonomy = getTaxonomy('category'); 11960 const defaultCategoryId = canUser('read', 'settings') ? getEntityRecord('root', 'site')?.default_category : undefined; 11961 const defaultCategory = defaultCategoryId ? getEntityRecord('taxonomy', 'category', defaultCategoryId) : undefined; 11962 const postTypeSupportsCategories = categoriesTaxonomy && categoriesTaxonomy.types.some(type => type === postType); 11963 const categories = categoriesTaxonomy && select(store_store).getEditedPostAttribute(categoriesTaxonomy.rest_base); 11964 11965 // This boolean should return true if everything is loaded 11966 // ( categoriesTaxonomy, defaultCategory ) 11967 // and the post has not been assigned a category different than "uncategorized". 11968 return !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && (categories?.length === 0 || categories?.length === 1 && defaultCategory?.id === categories[0]); 11969 }, []); 11970 const [shouldShowPanel, setShouldShowPanel] = (0,external_wp_element_namespaceObject.useState)(false); 11971 (0,external_wp_element_namespaceObject.useEffect)(() => { 11972 // We use state to avoid hiding the panel if the user edits the categories 11973 // and adds one within the panel itself (while visible). 11974 if (hasNoCategory) { 11975 setShouldShowPanel(true); 11976 } 11977 }, [hasNoCategory]); 11978 if (!shouldShowPanel) { 11979 return null; 11980 } 11981 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), (0,external_React_.createElement)("span", { 11982 className: "editor-post-publish-panel__link", 11983 key: "label" 11984 }, (0,external_wp_i18n_namespaceObject.__)('Assign a category'))]; 11985 return (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 11986 initialOpen: false, 11987 title: panelBodyTitle 11988 }, (0,external_React_.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about.')), (0,external_React_.createElement)(hierarchical_term_selector, { 11989 slug: "category" 11990 })); 11991 } 11992 /* harmony default export */ const maybe_category_panel = (MaybeCategoryPanel); 11993 11994 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/maybe-upload-media.js 11995 11996 /** 11997 * WordPress dependencies 11998 */ 11999 12000 12001 12002 12003 12004 12005 12006 /** 12007 * Internal dependencies 12008 */ 12009 12010 function flattenBlocks(blocks) { 12011 const result = []; 12012 blocks.forEach(block => { 12013 result.push(block); 12014 result.push(...flattenBlocks(block.innerBlocks)); 12015 }); 12016 return result; 12017 } 12018 function Image(block) { 12019 const { 12020 selectBlock 12021 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 12022 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.img, { 12023 tabIndex: 0, 12024 role: "button", 12025 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Select image block.'), 12026 onClick: () => { 12027 selectBlock(block.clientId); 12028 }, 12029 onKeyDown: event => { 12030 if (event.key === 'Enter' || event.key === ' ') { 12031 selectBlock(block.clientId); 12032 event.preventDefault(); 12033 } 12034 }, 12035 key: block.clientId, 12036 alt: block.attributes.alt, 12037 src: block.attributes.url, 12038 animate: { 12039 opacity: 1 12040 }, 12041 exit: { 12042 opacity: 0, 12043 scale: 0 12044 }, 12045 style: { 12046 width: '36px', 12047 height: '36px', 12048 objectFit: 'cover', 12049 borderRadius: '2px', 12050 cursor: 'pointer' 12051 }, 12052 whileHover: { 12053 scale: 1.08 12054 } 12055 }); 12056 } 12057 function maybe_upload_media_PostFormatPanel() { 12058 const [isUploading, setIsUploading] = (0,external_wp_element_namespaceObject.useState)(false); 12059 const { 12060 editorBlocks, 12061 mediaUpload 12062 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ 12063 editorBlocks: select(store_store).getEditorBlocks(), 12064 mediaUpload: select(external_wp_blockEditor_namespaceObject.store).getSettings().mediaUpload 12065 }), []); 12066 const externalImages = flattenBlocks(editorBlocks).filter(block => block.name === 'core/image' && block.attributes.url && !block.attributes.id); 12067 const { 12068 updateBlockAttributes 12069 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 12070 if (!mediaUpload || !externalImages.length) { 12071 return null; 12072 } 12073 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), (0,external_React_.createElement)("span", { 12074 className: "editor-post-publish-panel__link", 12075 key: "label" 12076 }, (0,external_wp_i18n_namespaceObject.__)('External media'))]; 12077 function uploadImages() { 12078 setIsUploading(true); 12079 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) => { 12080 mediaUpload({ 12081 filesList: [blob], 12082 onFileChange: ([media]) => { 12083 if ((0,external_wp_blob_namespaceObject.isBlobURL)(media.url)) { 12084 return; 12085 } 12086 updateBlockAttributes(image.clientId, { 12087 id: media.id, 12088 url: media.url 12089 }); 12090 resolve(); 12091 }, 12092 onError() { 12093 reject(); 12094 } 12095 }); 12096 })))).finally(() => { 12097 setIsUploading(false); 12098 }); 12099 } 12100 return (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 12101 initialOpen: true, 12102 title: panelBodyTitle 12103 }, (0,external_React_.createElement)("p", null, (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.')), (0,external_React_.createElement)("div", { 12104 style: { 12105 display: 'inline-flex', 12106 flexWrap: 'wrap', 12107 gap: '8px' 12108 } 12109 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableAnimatePresence, null, externalImages.map(image => { 12110 return (0,external_React_.createElement)(Image, { 12111 key: image.clientId, 12112 ...image 12113 }); 12114 })), isUploading ? (0,external_React_.createElement)(external_wp_components_namespaceObject.Spinner, null) : (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 12115 variant: "primary", 12116 onClick: uploadImages 12117 }, (0,external_wp_i18n_namespaceObject.__)('Upload')))); 12118 } 12119 12120 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/prepublish.js 12121 12122 /** 12123 * WordPress dependencies 12124 */ 12125 12126 12127 12128 12129 12130 12131 12132 12133 /** 12134 * Internal dependencies 12135 */ 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 function PostPublishPanelPrepublish({ 12146 children 12147 }) { 12148 const { 12149 isBeingScheduled, 12150 isRequestingSiteIcon, 12151 hasPublishAction, 12152 siteIconUrl, 12153 siteTitle, 12154 siteHome 12155 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 12156 var _getCurrentPost$_link; 12157 const { 12158 getCurrentPost, 12159 isEditedPostBeingScheduled 12160 } = select(store_store); 12161 const { 12162 getEntityRecord, 12163 isResolving 12164 } = select(external_wp_coreData_namespaceObject.store); 12165 const siteData = getEntityRecord('root', '__unstableBase', undefined) || {}; 12166 return { 12167 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false, 12168 isBeingScheduled: isEditedPostBeingScheduled(), 12169 isRequestingSiteIcon: isResolving('getEntityRecord', ['root', '__unstableBase', undefined]), 12170 siteIconUrl: siteData.site_icon_url, 12171 siteTitle: siteData.name, 12172 siteHome: siteData.home && (0,external_wp_url_namespaceObject.filterURLForDisplay)(siteData.home) 12173 }; 12174 }, []); 12175 let siteIcon = (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 12176 className: "components-site-icon", 12177 size: "36px", 12178 icon: library_wordpress 12179 }); 12180 if (siteIconUrl) { 12181 siteIcon = (0,external_React_.createElement)("img", { 12182 alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'), 12183 className: "components-site-icon", 12184 src: siteIconUrl 12185 }); 12186 } 12187 if (isRequestingSiteIcon) { 12188 siteIcon = null; 12189 } 12190 let prePublishTitle, prePublishBodyText; 12191 if (!hasPublishAction) { 12192 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to submit for review?'); 12193 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.'); 12194 } else if (isBeingScheduled) { 12195 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to schedule?'); 12196 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Your work will be published at the specified date and time.'); 12197 } else { 12198 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to publish?'); 12199 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Double-check your settings before publishing.'); 12200 } 12201 return (0,external_React_.createElement)("div", { 12202 className: "editor-post-publish-panel__prepublish" 12203 }, (0,external_React_.createElement)("div", null, (0,external_React_.createElement)("strong", null, prePublishTitle)), (0,external_React_.createElement)("p", null, prePublishBodyText), (0,external_React_.createElement)("div", { 12204 className: "components-site-card" 12205 }, siteIcon, (0,external_React_.createElement)("div", { 12206 className: "components-site-info" 12207 }, (0,external_React_.createElement)("span", { 12208 className: "components-site-name" 12209 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle) || (0,external_wp_i18n_namespaceObject.__)('(Untitled)')), (0,external_React_.createElement)("span", { 12210 className: "components-site-home" 12211 }, siteHome))), (0,external_React_.createElement)(maybe_upload_media_PostFormatPanel, null), hasPublishAction && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 12212 initialOpen: false, 12213 title: [(0,external_wp_i18n_namespaceObject.__)('Visibility:'), (0,external_React_.createElement)("span", { 12214 className: "editor-post-publish-panel__link", 12215 key: "label" 12216 }, (0,external_React_.createElement)(PostVisibilityLabel, null))] 12217 }, (0,external_React_.createElement)(PostVisibility, null)), (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 12218 initialOpen: false, 12219 title: [(0,external_wp_i18n_namespaceObject.__)('Publish:'), (0,external_React_.createElement)("span", { 12220 className: "editor-post-publish-panel__link", 12221 key: "label" 12222 }, (0,external_React_.createElement)(PostScheduleLabel, null))] 12223 }, (0,external_React_.createElement)(PostSchedule, null))), (0,external_React_.createElement)(PostFormatPanel, null), (0,external_React_.createElement)(maybe_tags_panel, null), (0,external_React_.createElement)(maybe_category_panel, null), children); 12224 } 12225 /* harmony default export */ const prepublish = (PostPublishPanelPrepublish); 12226 12227 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/postpublish.js 12228 12229 /** 12230 * WordPress dependencies 12231 */ 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 /** 12242 * Internal dependencies 12243 */ 12244 12245 12246 const POSTNAME = '%postname%'; 12247 const PAGENAME = '%pagename%'; 12248 12249 /** 12250 * Returns URL for a future post. 12251 * 12252 * @param {Object} post Post object. 12253 * 12254 * @return {string} PostPublish URL. 12255 */ 12256 12257 const getFuturePostUrl = post => { 12258 const { 12259 slug 12260 } = post; 12261 if (post.permalink_template.includes(POSTNAME)) { 12262 return post.permalink_template.replace(POSTNAME, slug); 12263 } 12264 if (post.permalink_template.includes(PAGENAME)) { 12265 return post.permalink_template.replace(PAGENAME, slug); 12266 } 12267 return post.permalink_template; 12268 }; 12269 function postpublish_CopyButton({ 12270 text, 12271 onCopy, 12272 children 12273 }) { 12274 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text, onCopy); 12275 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 12276 variant: "secondary", 12277 ref: ref 12278 }, children); 12279 } 12280 class PostPublishPanelPostpublish extends external_wp_element_namespaceObject.Component { 12281 constructor() { 12282 super(...arguments); 12283 this.state = { 12284 showCopyConfirmation: false 12285 }; 12286 this.onCopy = this.onCopy.bind(this); 12287 this.onSelectInput = this.onSelectInput.bind(this); 12288 this.postLink = (0,external_wp_element_namespaceObject.createRef)(); 12289 } 12290 componentDidMount() { 12291 if (this.props.focusOnMount) { 12292 this.postLink.current.focus(); 12293 } 12294 } 12295 componentWillUnmount() { 12296 clearTimeout(this.dismissCopyConfirmation); 12297 } 12298 onCopy() { 12299 this.setState({ 12300 showCopyConfirmation: true 12301 }); 12302 clearTimeout(this.dismissCopyConfirmation); 12303 this.dismissCopyConfirmation = setTimeout(() => { 12304 this.setState({ 12305 showCopyConfirmation: false 12306 }); 12307 }, 4000); 12308 } 12309 onSelectInput(event) { 12310 event.target.select(); 12311 } 12312 render() { 12313 const { 12314 children, 12315 isScheduled, 12316 post, 12317 postType 12318 } = this.props; 12319 const postLabel = postType?.labels?.singular_name; 12320 const viewPostLabel = postType?.labels?.view_item; 12321 const addNewPostLabel = postType?.labels?.add_new_item; 12322 const link = post.status === 'future' ? getFuturePostUrl(post) : post.link; 12323 const addLink = (0,external_wp_url_namespaceObject.addQueryArgs)('post-new.php', { 12324 post_type: post.type 12325 }); 12326 const postPublishNonLinkHeader = isScheduled ? (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('is now scheduled. It will go live on'), ' ', (0,external_React_.createElement)(PostScheduleLabel, null), ".") : (0,external_wp_i18n_namespaceObject.__)('is now live.'); 12327 return (0,external_React_.createElement)("div", { 12328 className: "post-publish-panel__postpublish" 12329 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 12330 className: "post-publish-panel__postpublish-header" 12331 }, (0,external_React_.createElement)("a", { 12332 ref: this.postLink, 12333 href: link 12334 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title) || (0,external_wp_i18n_namespaceObject.__)('(no title)')), ' ', postPublishNonLinkHeader), (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, null, (0,external_React_.createElement)("p", { 12335 className: "post-publish-panel__postpublish-subheader" 12336 }, (0,external_React_.createElement)("strong", null, (0,external_wp_i18n_namespaceObject.__)('What’s next?'))), (0,external_React_.createElement)("div", { 12337 className: "post-publish-panel__postpublish-post-address-container" 12338 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 12339 __nextHasNoMarginBottom: true, 12340 className: "post-publish-panel__postpublish-post-address", 12341 readOnly: true, 12342 label: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: post type singular name */ 12343 (0,external_wp_i18n_namespaceObject.__)('%s address'), postLabel), 12344 value: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(link), 12345 onFocus: this.onSelectInput 12346 }), (0,external_React_.createElement)("div", { 12347 className: "post-publish-panel__postpublish-post-address__copy-button-wrap" 12348 }, (0,external_React_.createElement)(postpublish_CopyButton, { 12349 text: link, 12350 onCopy: this.onCopy 12351 }, this.state.showCopyConfirmation ? (0,external_wp_i18n_namespaceObject.__)('Copied!') : (0,external_wp_i18n_namespaceObject.__)('Copy')))), (0,external_React_.createElement)("div", { 12352 className: "post-publish-panel__postpublish-buttons" 12353 }, !isScheduled && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 12354 variant: "primary", 12355 href: link 12356 }, viewPostLabel), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 12357 variant: isScheduled ? 'primary' : 'secondary', 12358 href: addLink 12359 }, addNewPostLabel))), children); 12360 } 12361 } 12362 /* harmony default export */ const postpublish = ((0,external_wp_data_namespaceObject.withSelect)(select => { 12363 const { 12364 getEditedPostAttribute, 12365 getCurrentPost, 12366 isCurrentPostScheduled 12367 } = select(store_store); 12368 const { 12369 getPostType 12370 } = select(external_wp_coreData_namespaceObject.store); 12371 return { 12372 post: getCurrentPost(), 12373 postType: getPostType(getEditedPostAttribute('type')), 12374 isScheduled: isCurrentPostScheduled() 12375 }; 12376 })(PostPublishPanelPostpublish)); 12377 12378 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/index.js 12379 12380 /** 12381 * WordPress dependencies 12382 */ 12383 12384 12385 12386 12387 12388 12389 12390 12391 /** 12392 * Internal dependencies 12393 */ 12394 12395 12396 12397 12398 class PostPublishPanel extends external_wp_element_namespaceObject.Component { 12399 constructor() { 12400 super(...arguments); 12401 this.onSubmit = this.onSubmit.bind(this); 12402 } 12403 componentDidUpdate(prevProps) { 12404 // Automatically collapse the publish sidebar when a post 12405 // is published and the user makes an edit. 12406 if (prevProps.isPublished && !this.props.isSaving && this.props.isDirty) { 12407 this.props.onClose(); 12408 } 12409 } 12410 onSubmit() { 12411 const { 12412 onClose, 12413 hasPublishAction, 12414 isPostTypeViewable 12415 } = this.props; 12416 if (!hasPublishAction || !isPostTypeViewable) { 12417 onClose(); 12418 } 12419 } 12420 render() { 12421 const { 12422 forceIsDirty, 12423 isBeingScheduled, 12424 isPublished, 12425 isPublishSidebarEnabled, 12426 isScheduled, 12427 isSaving, 12428 isSavingNonPostEntityChanges, 12429 onClose, 12430 onTogglePublishSidebar, 12431 PostPublishExtension, 12432 PrePublishExtension, 12433 ...additionalProps 12434 } = this.props; 12435 const { 12436 hasPublishAction, 12437 isDirty, 12438 isPostTypeViewable, 12439 ...propsForPanel 12440 } = additionalProps; 12441 const isPublishedOrScheduled = isPublished || isScheduled && isBeingScheduled; 12442 const isPrePublish = !isPublishedOrScheduled && !isSaving; 12443 const isPostPublish = isPublishedOrScheduled && !isSaving; 12444 return (0,external_React_.createElement)("div", { 12445 className: "editor-post-publish-panel", 12446 ...propsForPanel 12447 }, (0,external_React_.createElement)("div", { 12448 className: "editor-post-publish-panel__header" 12449 }, isPostPublish ? (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 12450 onClick: onClose, 12451 icon: close_small, 12452 label: (0,external_wp_i18n_namespaceObject.__)('Close panel') 12453 }) : (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { 12454 className: "editor-post-publish-panel__header-publish-button" 12455 }, (0,external_React_.createElement)(post_publish_button, { 12456 focusOnMount: true, 12457 onSubmit: this.onSubmit, 12458 forceIsDirty: forceIsDirty 12459 })), (0,external_React_.createElement)("div", { 12460 className: "editor-post-publish-panel__header-cancel-button" 12461 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 12462 disabled: isSavingNonPostEntityChanges, 12463 onClick: onClose, 12464 variant: "secondary" 12465 }, (0,external_wp_i18n_namespaceObject.__)('Cancel'))))), (0,external_React_.createElement)("div", { 12466 className: "editor-post-publish-panel__content" 12467 }, isPrePublish && (0,external_React_.createElement)(prepublish, null, PrePublishExtension && (0,external_React_.createElement)(PrePublishExtension, null)), isPostPublish && (0,external_React_.createElement)(postpublish, { 12468 focusOnMount: true 12469 }, PostPublishExtension && (0,external_React_.createElement)(PostPublishExtension, null)), isSaving && (0,external_React_.createElement)(external_wp_components_namespaceObject.Spinner, null)), (0,external_React_.createElement)("div", { 12470 className: "editor-post-publish-panel__footer" 12471 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 12472 __nextHasNoMarginBottom: true, 12473 label: (0,external_wp_i18n_namespaceObject.__)('Always show pre-publish checks.'), 12474 checked: isPublishSidebarEnabled, 12475 onChange: onTogglePublishSidebar 12476 }))); 12477 } 12478 } 12479 /* harmony default export */ const post_publish_panel = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => { 12480 var _getCurrentPost$_link; 12481 const { 12482 getPostType 12483 } = select(external_wp_coreData_namespaceObject.store); 12484 const { 12485 getCurrentPost, 12486 getEditedPostAttribute, 12487 isCurrentPostPublished, 12488 isCurrentPostScheduled, 12489 isEditedPostBeingScheduled, 12490 isEditedPostDirty, 12491 isAutosavingPost, 12492 isSavingPost, 12493 isSavingNonPostEntityChanges 12494 } = select(store_store); 12495 const { 12496 isPublishSidebarEnabled 12497 } = select(store_store); 12498 const postType = getPostType(getEditedPostAttribute('type')); 12499 return { 12500 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false, 12501 isPostTypeViewable: postType?.viewable, 12502 isBeingScheduled: isEditedPostBeingScheduled(), 12503 isDirty: isEditedPostDirty(), 12504 isPublished: isCurrentPostPublished(), 12505 isPublishSidebarEnabled: isPublishSidebarEnabled(), 12506 isSaving: isSavingPost() && !isAutosavingPost(), 12507 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges(), 12508 isScheduled: isCurrentPostScheduled() 12509 }; 12510 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, { 12511 isPublishSidebarEnabled 12512 }) => { 12513 const { 12514 disablePublishSidebar, 12515 enablePublishSidebar 12516 } = dispatch(store_store); 12517 return { 12518 onTogglePublishSidebar: () => { 12519 if (isPublishSidebarEnabled) { 12520 disablePublishSidebar(); 12521 } else { 12522 enablePublishSidebar(); 12523 } 12524 } 12525 }; 12526 }), external_wp_components_namespaceObject.withFocusReturn, external_wp_components_namespaceObject.withConstrainedTabbing])(PostPublishPanel)); 12527 12528 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/cloud-upload.js 12529 12530 /** 12531 * WordPress dependencies 12532 */ 12533 12534 const cloudUpload = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 12535 xmlns: "http://www.w3.org/2000/svg", 12536 viewBox: "0 0 24 24" 12537 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 12538 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" 12539 })); 12540 /* harmony default export */ const cloud_upload = (cloudUpload); 12541 12542 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js 12543 /** 12544 * WordPress dependencies 12545 */ 12546 12547 12548 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */ 12549 12550 /** 12551 * Return an SVG icon. 12552 * 12553 * @param {IconProps} props icon is the SVG component to render 12554 * size is a number specifiying the icon size in pixels 12555 * Other props will be passed to wrapped SVG component 12556 * @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element. 12557 * 12558 * @return {JSX.Element} Icon component 12559 */ 12560 function Icon({ 12561 icon, 12562 size = 24, 12563 ...props 12564 }, ref) { 12565 return (0,external_wp_element_namespaceObject.cloneElement)(icon, { 12566 width: size, 12567 height: size, 12568 ...props, 12569 ref 12570 }); 12571 } 12572 /* harmony default export */ const icon = ((0,external_wp_element_namespaceObject.forwardRef)(Icon)); 12573 12574 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/cloud.js 12575 12576 /** 12577 * WordPress dependencies 12578 */ 12579 12580 const cloud = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 12581 xmlns: "http://www.w3.org/2000/svg", 12582 viewBox: "0 0 24 24" 12583 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 12584 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" 12585 })); 12586 /* harmony default export */ const library_cloud = (cloud); 12587 12588 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-saved-state/index.js 12589 12590 /** 12591 * External dependencies 12592 */ 12593 12594 12595 /** 12596 * WordPress dependencies 12597 */ 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 /** 12608 * Internal dependencies 12609 */ 12610 12611 12612 /** 12613 * Component showing whether the post is saved or not and providing save 12614 * buttons. 12615 * 12616 * @param {Object} props Component props. 12617 * @param {?boolean} props.forceIsDirty Whether to force the post to be marked 12618 * as dirty. 12619 * @return {import('react').ComponentType} The component. 12620 */ 12621 function PostSavedState({ 12622 forceIsDirty 12623 }) { 12624 const [forceSavedMessage, setForceSavedMessage] = (0,external_wp_element_namespaceObject.useState)(false); 12625 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small'); 12626 const { 12627 isAutosaving, 12628 isDirty, 12629 isNew, 12630 isPending, 12631 isPublished, 12632 isSaveable, 12633 isSaving, 12634 isScheduled, 12635 hasPublishAction, 12636 showIconLabels 12637 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 12638 var _getCurrentPost$_link; 12639 const { 12640 isEditedPostNew, 12641 isCurrentPostPublished, 12642 isCurrentPostScheduled, 12643 isEditedPostDirty, 12644 isSavingPost, 12645 isEditedPostSaveable, 12646 getCurrentPost, 12647 isAutosavingPost, 12648 getEditedPostAttribute 12649 } = select(store_store); 12650 const { 12651 get 12652 } = select(external_wp_preferences_namespaceObject.store); 12653 return { 12654 isAutosaving: isAutosavingPost(), 12655 isDirty: forceIsDirty || isEditedPostDirty(), 12656 isNew: isEditedPostNew(), 12657 isPending: 'pending' === getEditedPostAttribute('status'), 12658 isPublished: isCurrentPostPublished(), 12659 isSaving: isSavingPost(), 12660 isSaveable: isEditedPostSaveable(), 12661 isScheduled: isCurrentPostScheduled(), 12662 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()?._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false, 12663 showIconLabels: get('core', 'showIconLabels') 12664 }; 12665 }, [forceIsDirty]); 12666 const { 12667 savePost 12668 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 12669 const wasSaving = (0,external_wp_compose_namespaceObject.usePrevious)(isSaving); 12670 (0,external_wp_element_namespaceObject.useEffect)(() => { 12671 let timeoutId; 12672 if (wasSaving && !isSaving) { 12673 setForceSavedMessage(true); 12674 timeoutId = setTimeout(() => { 12675 setForceSavedMessage(false); 12676 }, 1000); 12677 } 12678 return () => clearTimeout(timeoutId); 12679 }, [isSaving]); 12680 12681 // Once the post has been submitted for review this button 12682 // is not needed for the contributor role. 12683 if (!hasPublishAction && isPending) { 12684 return null; 12685 } 12686 if (isPublished || isScheduled) { 12687 return null; 12688 } 12689 12690 /* translators: button label text should, if possible, be under 16 characters. */ 12691 const label = isPending ? (0,external_wp_i18n_namespaceObject.__)('Save as pending') : (0,external_wp_i18n_namespaceObject.__)('Save draft'); 12692 12693 /* translators: button label text should, if possible, be under 16 characters. */ 12694 const shortLabel = (0,external_wp_i18n_namespaceObject.__)('Save'); 12695 const isSaved = forceSavedMessage || !isNew && !isDirty; 12696 const isSavedState = isSaving || isSaved; 12697 const isDisabled = isSaving || isSaved || !isSaveable; 12698 let text; 12699 if (isSaving) { 12700 text = isAutosaving ? (0,external_wp_i18n_namespaceObject.__)('Autosaving') : (0,external_wp_i18n_namespaceObject.__)('Saving'); 12701 } else if (isSaved) { 12702 text = (0,external_wp_i18n_namespaceObject.__)('Saved'); 12703 } else if (isLargeViewport) { 12704 text = label; 12705 } else if (showIconLabels) { 12706 text = shortLabel; 12707 } 12708 12709 // Use common Button instance for all saved states so that focus is not 12710 // lost. 12711 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 12712 className: isSaveable || isSaving ? classnames_default()({ 12713 'editor-post-save-draft': !isSavedState, 12714 'editor-post-saved-state': isSavedState, 12715 'is-saving': isSaving, 12716 'is-autosaving': isAutosaving, 12717 'is-saved': isSaved, 12718 [(0,external_wp_components_namespaceObject.__unstableGetAnimateClassName)({ 12719 type: 'loading' 12720 })]: isSaving 12721 }) : undefined, 12722 onClick: isDisabled ? undefined : () => savePost() 12723 /* 12724 * We want the tooltip to show the keyboard shortcut only when the 12725 * button does something, i.e. when it's not disabled. 12726 */, 12727 shortcut: isDisabled ? undefined : external_wp_keycodes_namespaceObject.displayShortcut.primary('s'), 12728 variant: "tertiary", 12729 size: "compact", 12730 icon: isLargeViewport ? undefined : cloud_upload, 12731 label: text || label, 12732 "aria-disabled": isDisabled 12733 }, isSavedState && (0,external_React_.createElement)(icon, { 12734 icon: isSaved ? library_check : library_cloud 12735 }), text); 12736 } 12737 12738 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-schedule/check.js 12739 /** 12740 * WordPress dependencies 12741 */ 12742 12743 12744 /** 12745 * Internal dependencies 12746 */ 12747 12748 function PostScheduleCheck({ 12749 children 12750 }) { 12751 const hasPublishAction = (0,external_wp_data_namespaceObject.useSelect)(select => { 12752 var _select$getCurrentPos; 12753 return (_select$getCurrentPos = select(store_store).getCurrentPost()._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false; 12754 }, []); 12755 if (!hasPublishAction) { 12756 return null; 12757 } 12758 return children; 12759 } 12760 12761 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-schedule/panel.js 12762 12763 /** 12764 * WordPress dependencies 12765 */ 12766 12767 12768 12769 12770 /** 12771 * Internal dependencies 12772 */ 12773 12774 12775 12776 12777 function PostSchedulePanel() { 12778 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null); 12779 // Memoize popoverProps to avoid returning a new object every time. 12780 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({ 12781 // Anchor the popover to the middle of the entire row so that it doesn't 12782 // move around when the label changes. 12783 anchor: popoverAnchor, 12784 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Change publish date'), 12785 placement: 'bottom-end' 12786 }), [popoverAnchor]); 12787 const label = usePostScheduleLabel(); 12788 const fullLabel = usePostScheduleLabel({ 12789 full: true 12790 }); 12791 return (0,external_React_.createElement)(PostScheduleCheck, null, (0,external_React_.createElement)(post_panel_row, { 12792 label: (0,external_wp_i18n_namespaceObject.__)('Publish'), 12793 ref: setPopoverAnchor 12794 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Dropdown, { 12795 popoverProps: popoverProps, 12796 focusOnMount: true, 12797 className: "editor-post-schedule__panel-dropdown", 12798 contentClassName: "editor-post-schedule__dialog", 12799 renderToggle: ({ 12800 onToggle, 12801 isOpen 12802 }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 12803 __next40pxDefaultSize: true, 12804 className: "editor-post-schedule__dialog-toggle", 12805 variant: "tertiary", 12806 onClick: onToggle, 12807 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)( 12808 // translators: %s: Current post date. 12809 (0,external_wp_i18n_namespaceObject.__)('Change date: %s'), label), 12810 label: fullLabel, 12811 showTooltip: label !== fullLabel, 12812 "aria-expanded": isOpen 12813 }, label), 12814 renderContent: ({ 12815 onClose 12816 }) => (0,external_React_.createElement)(PostSchedule, { 12817 onClose: onClose 12818 }) 12819 }))); 12820 } 12821 12822 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-slug/check.js 12823 12824 /** 12825 * Internal dependencies 12826 */ 12827 12828 function PostSlugCheck({ 12829 children 12830 }) { 12831 return (0,external_React_.createElement)(post_type_support_check, { 12832 supportKeys: "slug" 12833 }, children); 12834 } 12835 12836 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-slug/index.js 12837 12838 /** 12839 * WordPress dependencies 12840 */ 12841 12842 12843 12844 12845 12846 12847 12848 /** 12849 * Internal dependencies 12850 */ 12851 12852 12853 class PostSlug extends external_wp_element_namespaceObject.Component { 12854 constructor({ 12855 postSlug, 12856 postTitle, 12857 postID 12858 }) { 12859 super(...arguments); 12860 this.state = { 12861 editedSlug: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(postSlug) || (0,external_wp_url_namespaceObject.cleanForSlug)(postTitle) || postID 12862 }; 12863 this.setSlug = this.setSlug.bind(this); 12864 } 12865 setSlug(event) { 12866 const { 12867 postSlug, 12868 onUpdateSlug 12869 } = this.props; 12870 const { 12871 value 12872 } = event.target; 12873 const editedSlug = (0,external_wp_url_namespaceObject.cleanForSlug)(value); 12874 if (editedSlug === postSlug) { 12875 return; 12876 } 12877 onUpdateSlug(editedSlug); 12878 } 12879 render() { 12880 const { 12881 editedSlug 12882 } = this.state; 12883 return (0,external_React_.createElement)(PostSlugCheck, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 12884 __nextHasNoMarginBottom: true, 12885 label: (0,external_wp_i18n_namespaceObject.__)('Slug'), 12886 autoComplete: "off", 12887 spellCheck: "false", 12888 value: editedSlug, 12889 onChange: slug => this.setState({ 12890 editedSlug: slug 12891 }), 12892 onBlur: this.setSlug, 12893 className: "editor-post-slug" 12894 })); 12895 } 12896 } 12897 /* harmony default export */ const post_slug = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => { 12898 const { 12899 getCurrentPost, 12900 getEditedPostAttribute 12901 } = select(store_store); 12902 const { 12903 id 12904 } = getCurrentPost(); 12905 return { 12906 postSlug: getEditedPostAttribute('slug'), 12907 postTitle: getEditedPostAttribute('title'), 12908 postID: id 12909 }; 12910 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => { 12911 const { 12912 editPost 12913 } = dispatch(store_store); 12914 return { 12915 onUpdateSlug(slug) { 12916 editPost({ 12917 slug 12918 }); 12919 } 12920 }; 12921 })])(PostSlug)); 12922 12923 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-sticky/check.js 12924 /** 12925 * WordPress dependencies 12926 */ 12927 12928 12929 /** 12930 * Internal dependencies 12931 */ 12932 12933 function PostStickyCheck({ 12934 children 12935 }) { 12936 const { 12937 hasStickyAction, 12938 postType 12939 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 12940 var _post$_links$wpActio; 12941 const post = select(store_store).getCurrentPost(); 12942 return { 12943 hasStickyAction: (_post$_links$wpActio = post._links?.['wp:action-sticky']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false, 12944 postType: select(store_store).getCurrentPostType() 12945 }; 12946 }, []); 12947 if (postType !== 'post' || !hasStickyAction) { 12948 return null; 12949 } 12950 return children; 12951 } 12952 12953 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-sticky/index.js 12954 12955 /** 12956 * WordPress dependencies 12957 */ 12958 12959 12960 12961 12962 /** 12963 * Internal dependencies 12964 */ 12965 12966 12967 function PostSticky() { 12968 const postSticky = (0,external_wp_data_namespaceObject.useSelect)(select => { 12969 var _select$getEditedPost; 12970 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('sticky')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : false; 12971 }, []); 12972 const { 12973 editPost 12974 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 12975 return (0,external_React_.createElement)(PostStickyCheck, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 12976 __nextHasNoMarginBottom: true, 12977 label: (0,external_wp_i18n_namespaceObject.__)('Stick to the top of the blog'), 12978 checked: postSticky, 12979 onChange: () => editPost({ 12980 sticky: !postSticky 12981 }) 12982 })); 12983 } 12984 12985 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-switch-to-draft-button/index.js 12986 12987 /** 12988 * WordPress dependencies 12989 */ 12990 12991 12992 12993 12994 12995 /** 12996 * Internal dependencies 12997 */ 12998 12999 function PostSwitchToDraftButton() { 13000 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false); 13001 const { 13002 editPost, 13003 savePost 13004 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 13005 const { 13006 isSaving, 13007 isPublished, 13008 isScheduled 13009 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 13010 const { 13011 isSavingPost, 13012 isCurrentPostPublished, 13013 isCurrentPostScheduled 13014 } = select(store_store); 13015 return { 13016 isSaving: isSavingPost(), 13017 isPublished: isCurrentPostPublished(), 13018 isScheduled: isCurrentPostScheduled() 13019 }; 13020 }, []); 13021 const isDisabled = isSaving || !isPublished && !isScheduled; 13022 let alertMessage; 13023 if (isPublished) { 13024 alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unpublish this post?'); 13025 } else if (isScheduled) { 13026 alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unschedule this post?'); 13027 } 13028 const handleConfirm = () => { 13029 setShowConfirmDialog(false); 13030 editPost({ 13031 status: 'draft' 13032 }); 13033 savePost(); 13034 }; 13035 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 13036 __next40pxDefaultSize: true, 13037 className: "editor-post-switch-to-draft", 13038 onClick: () => { 13039 if (!isDisabled) { 13040 setShowConfirmDialog(true); 13041 } 13042 }, 13043 "aria-disabled": isDisabled, 13044 variant: "secondary", 13045 style: { 13046 flexGrow: '1', 13047 justifyContent: 'center' 13048 } 13049 }, (0,external_wp_i18n_namespaceObject.__)('Switch to draft')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { 13050 isOpen: showConfirmDialog, 13051 onConfirm: handleConfirm, 13052 onCancel: () => setShowConfirmDialog(false) 13053 }, alertMessage)); 13054 } 13055 13056 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-sync-status/index.js 13057 13058 /** 13059 * WordPress dependencies 13060 */ 13061 13062 13063 13064 /** 13065 * Internal dependencies 13066 */ 13067 13068 13069 function PostSyncStatus() { 13070 const { 13071 syncStatus, 13072 postType 13073 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 13074 const { 13075 getEditedPostAttribute 13076 } = select(store_store); 13077 const meta = getEditedPostAttribute('meta'); 13078 13079 // When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead. 13080 const currentSyncStatus = meta?.wp_pattern_sync_status === 'unsynced' ? 'unsynced' : getEditedPostAttribute('wp_pattern_sync_status'); 13081 return { 13082 syncStatus: currentSyncStatus, 13083 postType: getEditedPostAttribute('type') 13084 }; 13085 }); 13086 if (postType !== 'wp_block') { 13087 return null; 13088 } 13089 return (0,external_React_.createElement)(post_panel_row, { 13090 label: (0,external_wp_i18n_namespaceObject.__)('Sync status') 13091 }, (0,external_React_.createElement)("div", { 13092 className: "editor-post-sync-status__value" 13093 }, syncStatus === 'unsynced' ? (0,external_wp_i18n_namespaceObject._x)('Not synced', 'Text that indicates that the pattern is not synchronized') : (0,external_wp_i18n_namespaceObject._x)('Synced', 'Text that indicates that the pattern is synchronized'))); 13094 } 13095 13096 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/index.js 13097 13098 /** 13099 * WordPress dependencies 13100 */ 13101 13102 13103 13104 13105 /** 13106 * Internal dependencies 13107 */ 13108 13109 13110 13111 const post_taxonomies_identity = x => x; 13112 function PostTaxonomies({ 13113 taxonomyWrapper = post_taxonomies_identity 13114 }) { 13115 const { 13116 postType, 13117 taxonomies 13118 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 13119 return { 13120 postType: select(store_store).getCurrentPostType(), 13121 taxonomies: select(external_wp_coreData_namespaceObject.store).getTaxonomies({ 13122 per_page: -1 13123 }) 13124 }; 13125 }, []); 13126 const visibleTaxonomies = (taxonomies !== null && taxonomies !== void 0 ? taxonomies : []).filter(taxonomy => 13127 // In some circumstances .visibility can end up as undefined so optional chaining operator required. 13128 // https://github.com/WordPress/gutenberg/issues/40326 13129 taxonomy.types.includes(postType) && taxonomy.visibility?.show_ui); 13130 return visibleTaxonomies.map(taxonomy => { 13131 const TaxonomyComponent = taxonomy.hierarchical ? hierarchical_term_selector : flat_term_selector; 13132 return (0,external_React_.createElement)(external_wp_element_namespaceObject.Fragment, { 13133 key: `taxonomy-$taxonomy.slug}` 13134 }, taxonomyWrapper((0,external_React_.createElement)(TaxonomyComponent, { 13135 slug: taxonomy.slug 13136 }), taxonomy)); 13137 }); 13138 } 13139 /* harmony default export */ const post_taxonomies = (PostTaxonomies); 13140 13141 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/check.js 13142 /** 13143 * WordPress dependencies 13144 */ 13145 13146 13147 13148 /** 13149 * Internal dependencies 13150 */ 13151 13152 function PostTaxonomiesCheck({ 13153 children 13154 }) { 13155 const hasTaxonomies = (0,external_wp_data_namespaceObject.useSelect)(select => { 13156 const postType = select(store_store).getCurrentPostType(); 13157 const taxonomies = select(external_wp_coreData_namespaceObject.store).getTaxonomies({ 13158 per_page: -1 13159 }); 13160 return taxonomies?.some(taxonomy => taxonomy.types.includes(postType)); 13161 }, []); 13162 if (!hasTaxonomies) { 13163 return null; 13164 } 13165 return children; 13166 } 13167 13168 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/panel.js 13169 13170 /** 13171 * WordPress dependencies 13172 */ 13173 13174 13175 13176 /** 13177 * Internal dependencies 13178 */ 13179 13180 13181 13182 function TaxonomyPanel({ 13183 taxonomy, 13184 children 13185 }) { 13186 const slug = taxonomy?.slug; 13187 const panelName = slug ? `taxonomy-panel-$slug}` : ''; 13188 const { 13189 isEnabled, 13190 isOpened 13191 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 13192 const { 13193 isEditorPanelEnabled, 13194 isEditorPanelOpened 13195 } = select(store_store); 13196 return { 13197 isEnabled: slug ? isEditorPanelEnabled(panelName) : false, 13198 isOpened: slug ? isEditorPanelOpened(panelName) : false 13199 }; 13200 }, [panelName, slug]); 13201 const { 13202 toggleEditorPanelOpened 13203 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 13204 if (!isEnabled) { 13205 return null; 13206 } 13207 const taxonomyMenuName = taxonomy?.labels?.menu_name; 13208 if (!taxonomyMenuName) { 13209 return null; 13210 } 13211 return (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 13212 title: taxonomyMenuName, 13213 opened: isOpened, 13214 onToggle: () => toggleEditorPanelOpened(panelName) 13215 }, children); 13216 } 13217 function panel_PostTaxonomies() { 13218 return (0,external_React_.createElement)(PostTaxonomiesCheck, null, (0,external_React_.createElement)(post_taxonomies, { 13219 taxonomyWrapper: (content, taxonomy) => { 13220 return (0,external_React_.createElement)(TaxonomyPanel, { 13221 taxonomy: taxonomy 13222 }, content); 13223 } 13224 })); 13225 } 13226 /* harmony default export */ const post_taxonomies_panel = (panel_PostTaxonomies); 13227 13228 // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js 13229 var lib = __webpack_require__(4132); 13230 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-text-editor/index.js 13231 13232 /** 13233 * External dependencies 13234 */ 13235 13236 13237 /** 13238 * WordPress dependencies 13239 */ 13240 13241 13242 13243 13244 13245 13246 13247 13248 /** 13249 * Internal dependencies 13250 */ 13251 13252 function PostTextEditor() { 13253 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostTextEditor); 13254 const { 13255 content, 13256 blocks, 13257 type, 13258 id 13259 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 13260 const { 13261 getEditedEntityRecord 13262 } = select(external_wp_coreData_namespaceObject.store); 13263 const { 13264 getCurrentPostType, 13265 getCurrentPostId 13266 } = select(store_store); 13267 const _type = getCurrentPostType(); 13268 const _id = getCurrentPostId(); 13269 const editedRecord = getEditedEntityRecord('postType', _type, _id); 13270 return { 13271 content: editedRecord?.content, 13272 blocks: editedRecord?.blocks, 13273 type: _type, 13274 id: _id 13275 }; 13276 }, []); 13277 const { 13278 editEntityRecord 13279 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 13280 // Replicates the logic found in getEditedPostContent(). 13281 const value = (0,external_wp_element_namespaceObject.useMemo)(() => { 13282 if (content instanceof Function) { 13283 return content({ 13284 blocks 13285 }); 13286 } else if (blocks) { 13287 // If we have parsed blocks already, they should be our source of truth. 13288 // Parsing applies block deprecations and legacy block conversions that 13289 // unparsed content will not have. 13290 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocks); 13291 } 13292 return content; 13293 }, [content, blocks]); 13294 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 13295 as: "label", 13296 htmlFor: `post-content-$instanceId}` 13297 }, (0,external_wp_i18n_namespaceObject.__)('Type text or HTML')), (0,external_React_.createElement)(lib/* default */.A, { 13298 autoComplete: "off", 13299 dir: "auto", 13300 value: value, 13301 onChange: event => { 13302 editEntityRecord('postType', type, id, { 13303 content: event.target.value, 13304 blocks: undefined, 13305 selection: undefined 13306 }); 13307 }, 13308 className: "editor-post-text-editor", 13309 id: `post-content-$instanceId}`, 13310 placeholder: (0,external_wp_i18n_namespaceObject.__)('Start writing with text or HTML') 13311 })); 13312 } 13313 13314 ;// CONCATENATED MODULE: external ["wp","dom"] 13315 const external_wp_dom_namespaceObject = window["wp"]["dom"]; 13316 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-title/constants.js 13317 const DEFAULT_CLASSNAMES = 'wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text'; 13318 const REGEXP_NEWLINES = /[\r\n]+/g; 13319 13320 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-title/use-post-title-focus.js 13321 /** 13322 * WordPress dependencies 13323 */ 13324 13325 13326 13327 /** 13328 * Internal dependencies 13329 */ 13330 13331 function usePostTitleFocus(forwardedRef) { 13332 const ref = (0,external_wp_element_namespaceObject.useRef)(); 13333 const { 13334 isCleanNewPost 13335 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 13336 const { 13337 isCleanNewPost: _isCleanNewPost 13338 } = select(store_store); 13339 return { 13340 isCleanNewPost: _isCleanNewPost() 13341 }; 13342 }, []); 13343 (0,external_wp_element_namespaceObject.useImperativeHandle)(forwardedRef, () => ({ 13344 focus: () => { 13345 ref?.current?.focus(); 13346 } 13347 })); 13348 (0,external_wp_element_namespaceObject.useEffect)(() => { 13349 if (!ref.current) { 13350 return; 13351 } 13352 const { 13353 defaultView 13354 } = ref.current.ownerDocument; 13355 const { 13356 name, 13357 parent 13358 } = defaultView; 13359 const ownerDocument = name === 'editor-canvas' ? parent.document : defaultView.document; 13360 const { 13361 activeElement, 13362 body 13363 } = ownerDocument; 13364 13365 // Only autofocus the title when the post is entirely empty. This should 13366 // only happen for a new post, which means we focus the title on new 13367 // post so the author can start typing right away, without needing to 13368 // click anything. 13369 if (isCleanNewPost && (!activeElement || body === activeElement)) { 13370 ref.current.focus(); 13371 } 13372 }, [isCleanNewPost]); 13373 return { 13374 ref 13375 }; 13376 } 13377 13378 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-title/use-post-title.js 13379 /** 13380 * WordPress dependencies 13381 */ 13382 13383 /** 13384 * Internal dependencies 13385 */ 13386 13387 function usePostTitle() { 13388 const { 13389 editPost 13390 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 13391 const { 13392 title 13393 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 13394 const { 13395 getEditedPostAttribute 13396 } = select(store_store); 13397 return { 13398 title: getEditedPostAttribute('title') 13399 }; 13400 }, []); 13401 function updateTitle(newTitle) { 13402 editPost({ 13403 title: newTitle 13404 }); 13405 } 13406 return { 13407 title, 13408 setTitle: updateTitle 13409 }; 13410 } 13411 13412 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-title/index.js 13413 13414 /** 13415 * External dependencies 13416 */ 13417 13418 13419 /** 13420 * WordPress dependencies 13421 */ 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 /** 13434 * Internal dependencies 13435 */ 13436 13437 13438 13439 13440 13441 function PostTitle(_, forwardedRef) { 13442 const { 13443 placeholder, 13444 hasFixedToolbar 13445 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 13446 const { 13447 getEditedPostAttribute 13448 } = select(store_store); 13449 const { 13450 getSettings 13451 } = select(external_wp_blockEditor_namespaceObject.store); 13452 const { 13453 titlePlaceholder, 13454 hasFixedToolbar: _hasFixedToolbar 13455 } = getSettings(); 13456 return { 13457 title: getEditedPostAttribute('title'), 13458 placeholder: titlePlaceholder, 13459 hasFixedToolbar: _hasFixedToolbar 13460 }; 13461 }, []); 13462 const [isSelected, setIsSelected] = (0,external_wp_element_namespaceObject.useState)(false); 13463 const { 13464 ref: focusRef 13465 } = usePostTitleFocus(forwardedRef); 13466 const { 13467 title, 13468 setTitle: onUpdate 13469 } = usePostTitle(); 13470 const [selection, setSelection] = (0,external_wp_element_namespaceObject.useState)({}); 13471 const { 13472 clearSelectedBlock, 13473 insertBlocks, 13474 insertDefaultBlock 13475 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 13476 function onChange(value) { 13477 onUpdate(value.replace(REGEXP_NEWLINES, ' ')); 13478 } 13479 function onInsertBlockAfter(blocks) { 13480 insertBlocks(blocks, 0); 13481 } 13482 function onSelect() { 13483 setIsSelected(true); 13484 clearSelectedBlock(); 13485 } 13486 function onUnselect() { 13487 setIsSelected(false); 13488 setSelection({}); 13489 } 13490 function onEnterPress() { 13491 insertDefaultBlock(undefined, undefined, 0); 13492 } 13493 function onKeyDown(event) { 13494 if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) { 13495 event.preventDefault(); 13496 onEnterPress(); 13497 } 13498 } 13499 function onPaste(event) { 13500 const clipboardData = event.clipboardData; 13501 let plainText = ''; 13502 let html = ''; 13503 13504 // IE11 only supports `Text` as an argument for `getData` and will 13505 // otherwise throw an invalid argument error, so we try the standard 13506 // arguments first, then fallback to `Text` if they fail. 13507 try { 13508 plainText = clipboardData.getData('text/plain'); 13509 html = clipboardData.getData('text/html'); 13510 } catch (error1) { 13511 try { 13512 html = clipboardData.getData('Text'); 13513 } catch (error2) { 13514 // Some browsers like UC Browser paste plain text by default and 13515 // don't support clipboardData at all, so allow default 13516 // behaviour. 13517 return; 13518 } 13519 } 13520 13521 // Allows us to ask for this information when we get a report. 13522 window.console.log('Received HTML:\n\n', html); 13523 window.console.log('Received plain text:\n\n', plainText); 13524 const content = (0,external_wp_blocks_namespaceObject.pasteHandler)({ 13525 HTML: html, 13526 plainText 13527 }); 13528 event.preventDefault(); 13529 if (!content.length) { 13530 return; 13531 } 13532 if (typeof content !== 'string') { 13533 const [firstBlock] = content; 13534 if (!title && (firstBlock.name === 'core/heading' || firstBlock.name === 'core/paragraph')) { 13535 // Strip HTML to avoid unwanted HTML being added to the title. 13536 // In the majority of cases it is assumed that HTML in the title 13537 // is undesirable. 13538 const contentNoHTML = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(firstBlock.attributes.content); 13539 onUpdate(contentNoHTML); 13540 onInsertBlockAfter(content.slice(1)); 13541 } else { 13542 onInsertBlockAfter(content); 13543 } 13544 } else { 13545 const value = { 13546 ...(0,external_wp_richText_namespaceObject.create)({ 13547 html: title 13548 }), 13549 ...selection 13550 }; 13551 13552 // Strip HTML to avoid unwanted HTML being added to the title. 13553 // In the majority of cases it is assumed that HTML in the title 13554 // is undesirable. 13555 const contentNoHTML = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(content); 13556 const newValue = (0,external_wp_richText_namespaceObject.insert)(value, (0,external_wp_richText_namespaceObject.create)({ 13557 html: contentNoHTML 13558 })); 13559 onUpdate((0,external_wp_richText_namespaceObject.toHTMLString)({ 13560 value: newValue 13561 })); 13562 setSelection({ 13563 start: newValue.start, 13564 end: newValue.end 13565 }); 13566 } 13567 } 13568 const decodedPlaceholder = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Add title'); 13569 const { 13570 ref: richTextRef 13571 } = (0,external_wp_richText_namespaceObject.__unstableUseRichText)({ 13572 value: title, 13573 onChange, 13574 placeholder: decodedPlaceholder, 13575 selectionStart: selection.start, 13576 selectionEnd: selection.end, 13577 onSelectionChange(newStart, newEnd) { 13578 setSelection(sel => { 13579 const { 13580 start, 13581 end 13582 } = sel; 13583 if (start === newStart && end === newEnd) { 13584 return sel; 13585 } 13586 return { 13587 start: newStart, 13588 end: newEnd 13589 }; 13590 }); 13591 }, 13592 __unstableDisableFormats: false 13593 }); 13594 13595 // The wp-block className is important for editor styles. 13596 // This same block is used in both the visual and the code editor. 13597 const className = classnames_default()(DEFAULT_CLASSNAMES, { 13598 'is-selected': isSelected, 13599 'has-fixed-toolbar': hasFixedToolbar 13600 }); 13601 return /* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */( 13602 (0,external_React_.createElement)(post_type_support_check, { 13603 supportKeys: "title" 13604 }, (0,external_React_.createElement)("h1", { 13605 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([richTextRef, focusRef]), 13606 contentEditable: true, 13607 className: className, 13608 "aria-label": decodedPlaceholder, 13609 role: "textbox", 13610 "aria-multiline": "true", 13611 onFocus: onSelect, 13612 onBlur: onUnselect, 13613 onKeyDown: onKeyDown, 13614 onKeyPress: onUnselect, 13615 onPaste: onPaste 13616 })) 13617 /* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */ 13618 ); 13619 } 13620 /* harmony default export */ const post_title = ((0,external_wp_element_namespaceObject.forwardRef)(PostTitle)); 13621 13622 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-title/post-title-raw.js 13623 13624 /** 13625 * External dependencies 13626 */ 13627 13628 13629 /** 13630 * WordPress dependencies 13631 */ 13632 13633 13634 13635 13636 13637 13638 13639 /** 13640 * Internal dependencies 13641 */ 13642 13643 13644 13645 function PostTitleRaw(_, forwardedRef) { 13646 const { 13647 placeholder, 13648 hasFixedToolbar 13649 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 13650 const { 13651 getSettings 13652 } = select(external_wp_blockEditor_namespaceObject.store); 13653 const { 13654 titlePlaceholder, 13655 hasFixedToolbar: _hasFixedToolbar 13656 } = getSettings(); 13657 return { 13658 placeholder: titlePlaceholder, 13659 hasFixedToolbar: _hasFixedToolbar 13660 }; 13661 }, []); 13662 const [isSelected, setIsSelected] = (0,external_wp_element_namespaceObject.useState)(false); 13663 const { 13664 title, 13665 setTitle: onUpdate 13666 } = usePostTitle(); 13667 const { 13668 ref: focusRef 13669 } = usePostTitleFocus(forwardedRef); 13670 function onChange(value) { 13671 onUpdate(value.replace(REGEXP_NEWLINES, ' ')); 13672 } 13673 function onSelect() { 13674 setIsSelected(true); 13675 } 13676 function onUnselect() { 13677 setIsSelected(false); 13678 } 13679 13680 // The wp-block className is important for editor styles. 13681 // This same block is used in both the visual and the code editor. 13682 const className = classnames_default()(DEFAULT_CLASSNAMES, { 13683 'is-selected': isSelected, 13684 'has-fixed-toolbar': hasFixedToolbar, 13685 'is-raw-text': true 13686 }); 13687 const decodedPlaceholder = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Add title'); 13688 return (0,external_React_.createElement)(external_wp_components_namespaceObject.TextareaControl, { 13689 ref: focusRef, 13690 value: title, 13691 onChange: onChange, 13692 onFocus: onSelect, 13693 onBlur: onUnselect, 13694 label: placeholder, 13695 className: className, 13696 placeholder: decodedPlaceholder, 13697 hideLabelFromVision: true, 13698 autoComplete: "off", 13699 dir: "auto", 13700 rows: 1, 13701 __nextHasNoMarginBottom: true 13702 }); 13703 } 13704 /* harmony default export */ const post_title_raw = ((0,external_wp_element_namespaceObject.forwardRef)(PostTitleRaw)); 13705 13706 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-trash/index.js 13707 13708 /** 13709 * WordPress dependencies 13710 */ 13711 13712 13713 13714 13715 13716 /** 13717 * Internal dependencies 13718 */ 13719 13720 function PostTrash() { 13721 const { 13722 isNew, 13723 isDeleting, 13724 postId 13725 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 13726 const store = select(store_store); 13727 return { 13728 isNew: store.isEditedPostNew(), 13729 isDeleting: store.isDeletingPost(), 13730 postId: store.getCurrentPostId() 13731 }; 13732 }, []); 13733 const { 13734 trashPost 13735 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 13736 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false); 13737 if (isNew || !postId) { 13738 return null; 13739 } 13740 const handleConfirm = () => { 13741 setShowConfirmDialog(false); 13742 trashPost(); 13743 }; 13744 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 13745 __next40pxDefaultSize: true, 13746 className: "editor-post-trash", 13747 isDestructive: true, 13748 variant: "secondary", 13749 isBusy: isDeleting, 13750 "aria-disabled": isDeleting, 13751 onClick: isDeleting ? undefined : () => setShowConfirmDialog(true) 13752 }, (0,external_wp_i18n_namespaceObject.__)('Move to trash')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { 13753 isOpen: showConfirmDialog, 13754 onConfirm: handleConfirm, 13755 onCancel: () => setShowConfirmDialog(false) 13756 }, (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to move this post to the trash?'))); 13757 } 13758 13759 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-trash/check.js 13760 /** 13761 * WordPress dependencies 13762 */ 13763 13764 13765 13766 /** 13767 * Internal dependencies 13768 */ 13769 13770 function PostTrashCheck({ 13771 isNew, 13772 postId, 13773 canUserDelete, 13774 children 13775 }) { 13776 if (isNew || !postId || !canUserDelete) { 13777 return null; 13778 } 13779 return children; 13780 } 13781 /* harmony default export */ const post_trash_check = ((0,external_wp_data_namespaceObject.withSelect)(select => { 13782 const { 13783 isEditedPostNew, 13784 getCurrentPostId, 13785 getCurrentPostType 13786 } = select(store_store); 13787 const { 13788 getPostType, 13789 canUser 13790 } = select(external_wp_coreData_namespaceObject.store); 13791 const postId = getCurrentPostId(); 13792 const postType = getPostType(getCurrentPostType()); 13793 const resource = postType?.rest_base || ''; // eslint-disable-line camelcase 13794 13795 return { 13796 isNew: isEditedPostNew(), 13797 postId, 13798 canUserDelete: postId && resource ? canUser('delete', resource, postId) : false 13799 }; 13800 })(PostTrashCheck)); 13801 13802 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-url/index.js 13803 13804 /** 13805 * WordPress dependencies 13806 */ 13807 13808 13809 13810 13811 13812 13813 13814 13815 /** 13816 * Internal dependencies 13817 */ 13818 13819 function PostURL({ 13820 onClose 13821 }) { 13822 const { 13823 isEditable, 13824 postSlug, 13825 viewPostLabel, 13826 postLink, 13827 permalinkPrefix, 13828 permalinkSuffix 13829 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 13830 var _post$_links$wpActio; 13831 const post = select(store_store).getCurrentPost(); 13832 const postTypeSlug = select(store_store).getCurrentPostType(); 13833 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug); 13834 const permalinkParts = select(store_store).getPermalinkParts(); 13835 const hasPublishAction = (_post$_links$wpActio = post?._links?.['wp:action-publish']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false; 13836 return { 13837 isEditable: select(store_store).isPermalinkEditable() && hasPublishAction, 13838 postSlug: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(select(store_store).getEditedPostSlug()), 13839 viewPostLabel: postType?.labels.view_item, 13840 postLink: post.link, 13841 permalinkPrefix: permalinkParts?.prefix, 13842 permalinkSuffix: permalinkParts?.suffix 13843 }; 13844 }, []); 13845 const { 13846 editPost 13847 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 13848 const [forceEmptyField, setForceEmptyField] = (0,external_wp_element_namespaceObject.useState)(false); 13849 return (0,external_React_.createElement)("div", { 13850 className: "editor-post-url" 13851 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, { 13852 title: (0,external_wp_i18n_namespaceObject.__)('URL'), 13853 onClose: onClose 13854 }), isEditable && (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 13855 __nextHasNoMarginBottom: true, 13856 label: (0,external_wp_i18n_namespaceObject.__)('Permalink'), 13857 value: forceEmptyField ? '' : postSlug, 13858 autoComplete: "off", 13859 spellCheck: "false", 13860 help: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('The last part of the URL.'), ' ', (0,external_React_.createElement)(external_wp_components_namespaceObject.ExternalLink, { 13861 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink') 13862 }, (0,external_wp_i18n_namespaceObject.__)('Learn more.'))), 13863 onChange: newValue => { 13864 editPost({ 13865 slug: newValue 13866 }); 13867 // When we delete the field the permalink gets 13868 // reverted to the original value. 13869 // The forceEmptyField logic allows the user to have 13870 // the field temporarily empty while typing. 13871 if (!newValue) { 13872 if (!forceEmptyField) { 13873 setForceEmptyField(true); 13874 } 13875 return; 13876 } 13877 if (forceEmptyField) { 13878 setForceEmptyField(false); 13879 } 13880 }, 13881 onBlur: event => { 13882 editPost({ 13883 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(event.target.value) 13884 }); 13885 if (forceEmptyField) { 13886 setForceEmptyField(false); 13887 } 13888 } 13889 }), isEditable && (0,external_React_.createElement)("h3", { 13890 className: "editor-post-url__link-label" 13891 }, viewPostLabel !== null && viewPostLabel !== void 0 ? viewPostLabel : (0,external_wp_i18n_namespaceObject.__)('View post')), (0,external_React_.createElement)("p", null, (0,external_React_.createElement)(external_wp_components_namespaceObject.ExternalLink, { 13892 className: "editor-post-url__link", 13893 href: postLink, 13894 target: "_blank" 13895 }, isEditable ? (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("span", { 13896 className: "editor-post-url__link-prefix" 13897 }, permalinkPrefix), (0,external_React_.createElement)("span", { 13898 className: "editor-post-url__link-slug" 13899 }, postSlug), (0,external_React_.createElement)("span", { 13900 className: "editor-post-url__link-suffix" 13901 }, permalinkSuffix)) : postLink))); 13902 } 13903 13904 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-url/check.js 13905 /** 13906 * WordPress dependencies 13907 */ 13908 13909 13910 13911 /** 13912 * Internal dependencies 13913 */ 13914 13915 function PostURLCheck({ 13916 children 13917 }) { 13918 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => { 13919 const postTypeSlug = select(store_store).getCurrentPostType(); 13920 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug); 13921 if (!postType?.viewable) { 13922 return false; 13923 } 13924 const post = select(store_store).getCurrentPost(); 13925 if (!post.link) { 13926 return false; 13927 } 13928 const permalinkParts = select(store_store).getPermalinkParts(); 13929 if (!permalinkParts) { 13930 return false; 13931 } 13932 return true; 13933 }, []); 13934 if (!isVisible) { 13935 return null; 13936 } 13937 return children; 13938 } 13939 13940 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-url/label.js 13941 /** 13942 * WordPress dependencies 13943 */ 13944 13945 13946 13947 /** 13948 * Internal dependencies 13949 */ 13950 13951 function PostURLLabel() { 13952 return usePostURLLabel(); 13953 } 13954 function usePostURLLabel() { 13955 const postLink = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getPermalink(), []); 13956 return (0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURIComponent)(postLink)); 13957 } 13958 13959 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-url/panel.js 13960 13961 /** 13962 * WordPress dependencies 13963 */ 13964 13965 13966 13967 13968 /** 13969 * Internal dependencies 13970 */ 13971 13972 13973 13974 13975 function PostURLPanel() { 13976 // Use internal state instead of a ref to make sure that the component 13977 // re-renders when the popover's anchor updates. 13978 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null); 13979 // Memoize popoverProps to avoid returning a new object every time. 13980 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({ 13981 anchor: popoverAnchor, 13982 placement: 'bottom-end' 13983 }), [popoverAnchor]); 13984 return (0,external_React_.createElement)(PostURLCheck, null, (0,external_React_.createElement)(post_panel_row, { 13985 label: (0,external_wp_i18n_namespaceObject.__)('URL'), 13986 ref: setPopoverAnchor 13987 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Dropdown, { 13988 popoverProps: popoverProps, 13989 className: "editor-post-url__panel-dropdown", 13990 contentClassName: "editor-post-url__panel-dialog", 13991 focusOnMount: true, 13992 renderToggle: ({ 13993 isOpen, 13994 onToggle 13995 }) => (0,external_React_.createElement)(PostURLToggle, { 13996 isOpen: isOpen, 13997 onClick: onToggle 13998 }), 13999 renderContent: ({ 14000 onClose 14001 }) => (0,external_React_.createElement)(PostURL, { 14002 onClose: onClose 14003 }) 14004 }))); 14005 } 14006 function PostURLToggle({ 14007 isOpen, 14008 onClick 14009 }) { 14010 const label = usePostURLLabel(); 14011 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 14012 __next40pxDefaultSize: true, 14013 className: "editor-post-url__panel-toggle", 14014 variant: "tertiary", 14015 "aria-expanded": isOpen 14016 // translators: %s: Current post URL. 14017 , 14018 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change URL: %s'), label), 14019 onClick: onClick 14020 }, label); 14021 } 14022 14023 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/check.js 14024 /** 14025 * WordPress dependencies 14026 */ 14027 14028 14029 /** 14030 * Internal dependencies 14031 */ 14032 14033 function PostVisibilityCheck({ 14034 render 14035 }) { 14036 const canEdit = (0,external_wp_data_namespaceObject.useSelect)(select => { 14037 var _select$getCurrentPos; 14038 return (_select$getCurrentPos = select(store_store).getCurrentPost()._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false; 14039 }); 14040 return render({ 14041 canEdit 14042 }); 14043 } 14044 14045 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/info.js 14046 14047 /** 14048 * WordPress dependencies 14049 */ 14050 14051 const info = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 14052 xmlns: "http://www.w3.org/2000/svg", 14053 viewBox: "0 0 24 24" 14054 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 14055 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" 14056 })); 14057 /* harmony default export */ const library_info = (info); 14058 14059 ;// CONCATENATED MODULE: external ["wp","wordcount"] 14060 const external_wp_wordcount_namespaceObject = window["wp"]["wordcount"]; 14061 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/word-count/index.js 14062 14063 /** 14064 * WordPress dependencies 14065 */ 14066 14067 14068 14069 14070 /** 14071 * Internal dependencies 14072 */ 14073 14074 function WordCount() { 14075 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []); 14076 14077 /* 14078 * translators: If your word count is based on single characters (e.g. East Asian characters), 14079 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'. 14080 * Do not translate into your own language. 14081 */ 14082 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!'); 14083 return (0,external_React_.createElement)("span", { 14084 className: "word-count" 14085 }, (0,external_wp_wordcount_namespaceObject.count)(content, wordCountType)); 14086 } 14087 14088 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/time-to-read/index.js 14089 14090 /** 14091 * WordPress dependencies 14092 */ 14093 14094 14095 14096 14097 14098 /** 14099 * Internal dependencies 14100 */ 14101 14102 14103 /** 14104 * Average reading rate - based on average taken from 14105 * https://irisreading.com/average-reading-speed-in-various-languages/ 14106 * (Characters/minute used for Chinese rather than words). 14107 * 14108 * @type {number} A rough estimate of the average reading rate across multiple languages. 14109 */ 14110 const AVERAGE_READING_RATE = 189; 14111 function TimeToRead() { 14112 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []); 14113 14114 /* 14115 * translators: If your word count is based on single characters (e.g. East Asian characters), 14116 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'. 14117 * Do not translate into your own language. 14118 */ 14119 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!'); 14120 const minutesToRead = Math.round((0,external_wp_wordcount_namespaceObject.count)(content, wordCountType) / AVERAGE_READING_RATE); 14121 const minutesToReadString = minutesToRead === 0 ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('<span>< 1</span> minute'), { 14122 span: (0,external_React_.createElement)("span", null) 14123 }) : (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. */ 14124 (0,external_wp_i18n_namespaceObject._n)('<span>%d</span> minute', '<span>%d</span> minutes', minutesToRead), minutesToRead), { 14125 span: (0,external_React_.createElement)("span", null) 14126 }); 14127 return (0,external_React_.createElement)("span", { 14128 className: "time-to-read" 14129 }, minutesToReadString); 14130 } 14131 14132 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/character-count/index.js 14133 /** 14134 * WordPress dependencies 14135 */ 14136 14137 14138 14139 /** 14140 * Internal dependencies 14141 */ 14142 14143 function CharacterCount() { 14144 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []); 14145 return (0,external_wp_wordcount_namespaceObject.count)(content, 'characters_including_spaces'); 14146 } 14147 14148 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/table-of-contents/panel.js 14149 14150 /** 14151 * WordPress dependencies 14152 */ 14153 14154 14155 14156 14157 /** 14158 * Internal dependencies 14159 */ 14160 14161 14162 14163 14164 function TableOfContentsPanel({ 14165 hasOutlineItemsDisabled, 14166 onRequestClose 14167 }) { 14168 const { 14169 headingCount, 14170 paragraphCount, 14171 numberOfBlocks 14172 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 14173 const { 14174 getGlobalBlockCount 14175 } = select(external_wp_blockEditor_namespaceObject.store); 14176 return { 14177 headingCount: getGlobalBlockCount('core/heading'), 14178 paragraphCount: getGlobalBlockCount('core/paragraph'), 14179 numberOfBlocks: getGlobalBlockCount() 14180 }; 14181 }, []); 14182 return ( 14183 /* 14184 * Disable reason: The `list` ARIA role is redundant but 14185 * Safari+VoiceOver won't announce the list otherwise. 14186 */ 14187 /* eslint-disable jsx-a11y/no-redundant-roles */ 14188 (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { 14189 className: "table-of-contents__wrapper", 14190 role: "note", 14191 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document Statistics'), 14192 tabIndex: "0" 14193 }, (0,external_React_.createElement)("ul", { 14194 role: "list", 14195 className: "table-of-contents__counts" 14196 }, (0,external_React_.createElement)("li", { 14197 className: "table-of-contents__count" 14198 }, (0,external_wp_i18n_namespaceObject.__)('Words'), (0,external_React_.createElement)(WordCount, null)), (0,external_React_.createElement)("li", { 14199 className: "table-of-contents__count" 14200 }, (0,external_wp_i18n_namespaceObject.__)('Characters'), (0,external_React_.createElement)("span", { 14201 className: "table-of-contents__number" 14202 }, (0,external_React_.createElement)(CharacterCount, null))), (0,external_React_.createElement)("li", { 14203 className: "table-of-contents__count" 14204 }, (0,external_wp_i18n_namespaceObject.__)('Time to read'), (0,external_React_.createElement)(TimeToRead, null)), (0,external_React_.createElement)("li", { 14205 className: "table-of-contents__count" 14206 }, (0,external_wp_i18n_namespaceObject.__)('Headings'), (0,external_React_.createElement)("span", { 14207 className: "table-of-contents__number" 14208 }, headingCount)), (0,external_React_.createElement)("li", { 14209 className: "table-of-contents__count" 14210 }, (0,external_wp_i18n_namespaceObject.__)('Paragraphs'), (0,external_React_.createElement)("span", { 14211 className: "table-of-contents__number" 14212 }, paragraphCount)), (0,external_React_.createElement)("li", { 14213 className: "table-of-contents__count" 14214 }, (0,external_wp_i18n_namespaceObject.__)('Blocks'), (0,external_React_.createElement)("span", { 14215 className: "table-of-contents__number" 14216 }, numberOfBlocks)))), headingCount > 0 && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("hr", null), (0,external_React_.createElement)("h2", { 14217 className: "table-of-contents__title" 14218 }, (0,external_wp_i18n_namespaceObject.__)('Document Outline')), (0,external_React_.createElement)(document_outline, { 14219 onSelect: onRequestClose, 14220 hasOutlineItemsDisabled: hasOutlineItemsDisabled 14221 }))) 14222 /* eslint-enable jsx-a11y/no-redundant-roles */ 14223 ); 14224 } 14225 /* harmony default export */ const table_of_contents_panel = (TableOfContentsPanel); 14226 14227 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/table-of-contents/index.js 14228 14229 /** 14230 * WordPress dependencies 14231 */ 14232 14233 14234 14235 14236 14237 14238 14239 /** 14240 * Internal dependencies 14241 */ 14242 14243 function TableOfContents({ 14244 hasOutlineItemsDisabled, 14245 repositionDropdown, 14246 ...props 14247 }, ref) { 14248 const hasBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_blockEditor_namespaceObject.store).getBlockCount(), []); 14249 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Dropdown, { 14250 popoverProps: { 14251 placement: repositionDropdown ? 'right' : 'bottom' 14252 }, 14253 className: "table-of-contents", 14254 contentClassName: "table-of-contents__popover", 14255 renderToggle: ({ 14256 isOpen, 14257 onToggle 14258 }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 14259 ...props, 14260 ref: ref, 14261 onClick: hasBlocks ? onToggle : undefined, 14262 icon: library_info, 14263 "aria-expanded": isOpen, 14264 "aria-haspopup": "true" 14265 /* translators: button label text should, if possible, be under 16 characters. */, 14266 label: (0,external_wp_i18n_namespaceObject.__)('Details'), 14267 tooltipPosition: "bottom", 14268 "aria-disabled": !hasBlocks 14269 }), 14270 renderContent: ({ 14271 onClose 14272 }) => (0,external_React_.createElement)(table_of_contents_panel, { 14273 onRequestClose: onClose, 14274 hasOutlineItemsDisabled: hasOutlineItemsDisabled 14275 }) 14276 }); 14277 } 14278 /* harmony default export */ const table_of_contents = ((0,external_wp_element_namespaceObject.forwardRef)(TableOfContents)); 14279 14280 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/unsaved-changes-warning/index.js 14281 /** 14282 * WordPress dependencies 14283 */ 14284 14285 14286 14287 14288 14289 /** 14290 * Warns the user if there are unsaved changes before leaving the editor. 14291 * Compatible with Post Editor and Site Editor. 14292 * 14293 * @return {Component} The component. 14294 */ 14295 function UnsavedChangesWarning() { 14296 const { 14297 __experimentalGetDirtyEntityRecords 14298 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store); 14299 (0,external_wp_element_namespaceObject.useEffect)(() => { 14300 /** 14301 * Warns the user if there are unsaved changes before leaving the editor. 14302 * 14303 * @param {Event} event `beforeunload` event. 14304 * 14305 * @return {string | undefined} Warning prompt message, if unsaved changes exist. 14306 */ 14307 const warnIfUnsavedChanges = event => { 14308 // We need to call the selector directly in the listener to avoid race 14309 // conditions with `BrowserURL` where `componentDidUpdate` gets the 14310 // new value of `isEditedPostDirty` before this component does, 14311 // causing this component to incorrectly think a trashed post is still dirty. 14312 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); 14313 if (dirtyEntityRecords.length > 0) { 14314 event.returnValue = (0,external_wp_i18n_namespaceObject.__)('You have unsaved changes. If you proceed, they will be lost.'); 14315 return event.returnValue; 14316 } 14317 }; 14318 window.addEventListener('beforeunload', warnIfUnsavedChanges); 14319 return () => { 14320 window.removeEventListener('beforeunload', warnIfUnsavedChanges); 14321 }; 14322 }, [__experimentalGetDirtyEntityRecords]); 14323 return null; 14324 } 14325 14326 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/provider/with-registry-provider.js 14327 14328 /** 14329 * WordPress dependencies 14330 */ 14331 14332 14333 14334 14335 14336 /** 14337 * Internal dependencies 14338 */ 14339 14340 const withRegistryProvider = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => (0,external_wp_data_namespaceObject.withRegistry)(props => { 14341 const { 14342 useSubRegistry = true, 14343 registry, 14344 ...additionalProps 14345 } = props; 14346 if (!useSubRegistry) { 14347 return (0,external_React_.createElement)(WrappedComponent, { 14348 ...additionalProps 14349 }); 14350 } 14351 const [subRegistry, setSubRegistry] = (0,external_wp_element_namespaceObject.useState)(null); 14352 (0,external_wp_element_namespaceObject.useEffect)(() => { 14353 const newRegistry = (0,external_wp_data_namespaceObject.createRegistry)({ 14354 'core/block-editor': external_wp_blockEditor_namespaceObject.storeConfig 14355 }, registry); 14356 newRegistry.registerStore('core/editor', storeConfig); 14357 setSubRegistry(newRegistry); 14358 }, [registry]); 14359 if (!subRegistry) { 14360 return null; 14361 } 14362 return (0,external_React_.createElement)(external_wp_data_namespaceObject.RegistryProvider, { 14363 value: subRegistry 14364 }, (0,external_React_.createElement)(WrappedComponent, { 14365 ...additionalProps 14366 })); 14367 }), 'withRegistryProvider'); 14368 /* harmony default export */ const with_registry_provider = (withRegistryProvider); 14369 14370 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/media-categories/index.js 14371 /** 14372 * The `editor` settings here need to be in sync with the corresponding ones in `editor` package. 14373 * See `packages/editor/src/components/media-categories/index.js`. 14374 * 14375 * In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`. 14376 * The rest of the settings would still need to be in sync though. 14377 */ 14378 14379 /** 14380 * WordPress dependencies 14381 */ 14382 14383 14384 14385 14386 /** 14387 * Internal dependencies 14388 */ 14389 14390 14391 /** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */ 14392 /** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */ 14393 /** @typedef {import('@wordpress/block-editor').InserterMediaCategory} InserterMediaCategory */ 14394 14395 const getExternalLink = (url, text) => `<a $getExternalLinkAttributes(url)}>$text}</a>`; 14396 const getExternalLinkAttributes = url => `href="$url}" target="_blank" rel="noreferrer noopener"`; 14397 const getOpenverseLicense = (license, licenseVersion) => { 14398 let licenseName = license.trim(); 14399 // PDM has no abbreviation 14400 if (license !== 'pdm') { 14401 licenseName = license.toUpperCase().replace('SAMPLING', 'Sampling'); 14402 } 14403 // If version is known, append version to the name. 14404 // The license has to have a version to be valid. Only 14405 // PDM (public domain mark) doesn't have a version. 14406 if (licenseVersion) { 14407 licenseName += ` $licenseVersion}`; 14408 } 14409 // For licenses other than public-domain marks, prepend 'CC' to the name. 14410 if (!['pdm', 'cc0'].includes(license)) { 14411 licenseName = `CC $licenseName}`; 14412 } 14413 return licenseName; 14414 }; 14415 const getOpenverseCaption = item => { 14416 const { 14417 title, 14418 foreign_landing_url: foreignLandingUrl, 14419 creator, 14420 creator_url: creatorUrl, 14421 license, 14422 license_version: licenseVersion, 14423 license_url: licenseUrl 14424 } = item; 14425 const fullLicense = getOpenverseLicense(license, licenseVersion); 14426 const _creator = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(creator); 14427 let _caption; 14428 if (_creator) { 14429 _caption = title ? (0,external_wp_i18n_namespaceObject.sprintf)( 14430 // 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". 14431 (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)( 14432 // 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". 14433 (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); 14434 } else { 14435 _caption = title ? (0,external_wp_i18n_namespaceObject.sprintf)( 14436 // translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: "CC0 1.0". 14437 (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)( 14438 // translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: "CC0 1.0". 14439 (0,external_wp_i18n_namespaceObject._x)('<a %1$s>Work</a>/ %2$s', 'caption'), getExternalLinkAttributes(foreignLandingUrl), licenseUrl ? getExternalLink(`$licenseUrl}?ref=openverse`, fullLicense) : fullLicense); 14440 } 14441 return _caption.replace(/\s{2}/g, ' '); 14442 }; 14443 const coreMediaFetch = async (query = {}) => { 14444 const mediaItems = await (0,external_wp_data_namespaceObject.resolveSelect)(external_wp_coreData_namespaceObject.store).getMediaItems({ 14445 ...query, 14446 orderBy: !!query?.search ? 'relevance' : 'date' 14447 }); 14448 return mediaItems.map(mediaItem => ({ 14449 ...mediaItem, 14450 alt: mediaItem.alt_text, 14451 url: mediaItem.source_url, 14452 previewUrl: mediaItem.media_details?.sizes?.medium?.source_url, 14453 caption: mediaItem.caption?.raw 14454 })); 14455 }; 14456 14457 /** @type {InserterMediaCategory[]} */ 14458 const inserterMediaCategories = [{ 14459 name: 'images', 14460 labels: { 14461 name: (0,external_wp_i18n_namespaceObject.__)('Images'), 14462 search_items: (0,external_wp_i18n_namespaceObject.__)('Search images') 14463 }, 14464 mediaType: 'image', 14465 async fetch(query = {}) { 14466 return coreMediaFetch({ 14467 ...query, 14468 media_type: 'image' 14469 }); 14470 } 14471 }, { 14472 name: 'videos', 14473 labels: { 14474 name: (0,external_wp_i18n_namespaceObject.__)('Videos'), 14475 search_items: (0,external_wp_i18n_namespaceObject.__)('Search videos') 14476 }, 14477 mediaType: 'video', 14478 async fetch(query = {}) { 14479 return coreMediaFetch({ 14480 ...query, 14481 media_type: 'video' 14482 }); 14483 } 14484 }, { 14485 name: 'audio', 14486 labels: { 14487 name: (0,external_wp_i18n_namespaceObject.__)('Audio'), 14488 search_items: (0,external_wp_i18n_namespaceObject.__)('Search audio') 14489 }, 14490 mediaType: 'audio', 14491 async fetch(query = {}) { 14492 return coreMediaFetch({ 14493 ...query, 14494 media_type: 'audio' 14495 }); 14496 } 14497 }, { 14498 name: 'openverse', 14499 labels: { 14500 name: (0,external_wp_i18n_namespaceObject.__)('Openverse'), 14501 search_items: (0,external_wp_i18n_namespaceObject.__)('Search Openverse') 14502 }, 14503 mediaType: 'image', 14504 async fetch(query = {}) { 14505 const defaultArgs = { 14506 mature: false, 14507 excluded_source: 'flickr,inaturalist,wikimedia', 14508 license: 'pdm,cc0' 14509 }; 14510 const finalQuery = { 14511 ...query, 14512 ...defaultArgs 14513 }; 14514 const mapFromInserterMediaRequest = { 14515 per_page: 'page_size', 14516 search: 'q' 14517 }; 14518 const url = new URL('https://api.openverse.engineering/v1/images/'); 14519 Object.entries(finalQuery).forEach(([key, value]) => { 14520 const queryKey = mapFromInserterMediaRequest[key] || key; 14521 url.searchParams.set(queryKey, value); 14522 }); 14523 const response = await window.fetch(url, { 14524 headers: { 14525 'User-Agent': 'WordPress/inserter-media-fetch' 14526 } 14527 }); 14528 const jsonResponse = await response.json(); 14529 const results = jsonResponse.results; 14530 return results.map(result => ({ 14531 ...result, 14532 // This is a temp solution for better titles, until Openverse API 14533 // completes the cleaning up of some titles of their upstream data. 14534 title: result.title?.toLowerCase().startsWith('file:') ? result.title.slice(5) : result.title, 14535 sourceId: result.id, 14536 id: undefined, 14537 caption: getOpenverseCaption(result), 14538 previewUrl: result.thumbnail 14539 })); 14540 }, 14541 getReportUrl: ({ 14542 sourceId 14543 }) => `https://wordpress.org/openverse/image/$sourceId}/report/`, 14544 isExternalResource: true 14545 }]; 14546 /* harmony default export */ const media_categories = (inserterMediaCategories); 14547 14548 ;// CONCATENATED MODULE: external ["wp","mediaUtils"] 14549 const external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"]; 14550 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/media-upload/index.js 14551 /** 14552 * WordPress dependencies 14553 */ 14554 14555 14556 14557 /** 14558 * Internal dependencies 14559 */ 14560 14561 const media_upload_noop = () => {}; 14562 14563 /** 14564 * Upload a media file when the file upload button is activated. 14565 * Wrapper around mediaUpload() that injects the current post ID. 14566 * 14567 * @param {Object} $0 Parameters object passed to the function. 14568 * @param {?Object} $0.additionalData Additional data to include in the request. 14569 * @param {string} $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed. 14570 * @param {Array} $0.filesList List of files. 14571 * @param {?number} $0.maxUploadFileSize Maximum upload size in bytes allowed for the site. 14572 * @param {Function} $0.onError Function called when an error happens. 14573 * @param {Function} $0.onFileChange Function called each time a file or a temporary representation of the file is available. 14574 */ 14575 function mediaUpload({ 14576 additionalData = {}, 14577 allowedTypes, 14578 filesList, 14579 maxUploadFileSize, 14580 onError = media_upload_noop, 14581 onFileChange 14582 }) { 14583 const { 14584 getCurrentPost, 14585 getEditorSettings 14586 } = (0,external_wp_data_namespaceObject.select)(store_store); 14587 const wpAllowedMimeTypes = getEditorSettings().allowedMimeTypes; 14588 maxUploadFileSize = maxUploadFileSize || getEditorSettings().maxUploadFileSize; 14589 const currentPost = getCurrentPost(); 14590 // Templates and template parts' numerical ID is stored in `wp_id`. 14591 const currentPostId = typeof currentPost?.id === 'number' ? currentPost.id : currentPost?.wp_id; 14592 const postData = currentPostId ? { 14593 post: currentPostId 14594 } : {}; 14595 (0,external_wp_mediaUtils_namespaceObject.uploadMedia)({ 14596 allowedTypes, 14597 filesList, 14598 onFileChange, 14599 additionalData: { 14600 ...postData, 14601 ...additionalData 14602 }, 14603 maxUploadFileSize, 14604 onError: ({ 14605 message 14606 }) => onError(message), 14607 wpAllowedMimeTypes 14608 }); 14609 } 14610 14611 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/provider/use-block-editor-settings.js 14612 /** 14613 * WordPress dependencies 14614 */ 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 /** 14625 * Internal dependencies 14626 */ 14627 14628 14629 14630 14631 const EMPTY_BLOCKS_LIST = []; 14632 const BLOCK_EDITOR_SETTINGS = ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalGlobalStylesBaseStyles', '__experimentalPreferredStyleVariations', '__unstableGalleryWithImageBlocks', 'alignWide', 'blockInspectorTabs', 'allowedMimeTypes', 'bodyPlaceholder', 'canLockBlocks', 'capabilities', 'clearBlockSelection', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomSpacingSizes', 'disableCustomGradients', 'disableLayoutStyles', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'enableOpenverseMediaCategory', 'fontSizes', 'gradients', 'generateAnchors', 'onNavigateToEntityRecord', 'hasInlineToolbar', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'locale', 'maxWidth', 'onUpdateDefaultBlockStyles', 'postContentAttributes', 'postsPerPage', 'readOnly', 'styles', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock', '__unstableHasCustomAppender', '__unstableIsPreviewMode', '__unstableResolvedAssets', '__unstableIsBlockBasedTheme', '__experimentalArchiveTitleTypeLabel', '__experimentalArchiveTitleNameLabel']; 14633 14634 /** 14635 * React hook used to compute the block editor settings to use for the post editor. 14636 * 14637 * @param {Object} settings EditorProvider settings prop. 14638 * @param {string} postType Editor root level post type. 14639 * @param {string} postId Editor root level post ID. 14640 * 14641 * @return {Object} Block Editor Settings. 14642 */ 14643 function useBlockEditorSettings(settings, postType, postId) { 14644 var _settings$__experimen, _settings$__experimen2; 14645 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); 14646 const { 14647 allowRightClickOverrides, 14648 blockTypes, 14649 focusMode, 14650 hasFixedToolbar, 14651 isDistractionFree, 14652 keepCaretInsideBlock, 14653 reusableBlocks, 14654 hasUploadPermissions, 14655 hiddenBlockTypes, 14656 canUseUnfilteredHTML, 14657 userCanCreatePages, 14658 pageOnFront, 14659 pageForPosts, 14660 userPatternCategories, 14661 restBlockPatternCategories 14662 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 14663 var _canUser; 14664 const isWeb = external_wp_element_namespaceObject.Platform.OS === 'web'; 14665 const { 14666 canUser, 14667 getRawEntityRecord, 14668 getEntityRecord, 14669 getUserPatternCategories, 14670 getEntityRecords, 14671 getBlockPatternCategories 14672 } = select(external_wp_coreData_namespaceObject.store); 14673 const { 14674 get 14675 } = select(external_wp_preferences_namespaceObject.store); 14676 const { 14677 getBlockTypes 14678 } = select(external_wp_blocks_namespaceObject.store); 14679 const siteSettings = canUser('read', 'settings') ? getEntityRecord('root', 'site') : undefined; 14680 return { 14681 allowRightClickOverrides: get('core', 'allowRightClickOverrides'), 14682 blockTypes: getBlockTypes(), 14683 canUseUnfilteredHTML: getRawEntityRecord('postType', postType, postId)?._links?.hasOwnProperty('wp:action-unfiltered-html'), 14684 focusMode: get('core', 'focusMode'), 14685 hasFixedToolbar: get('core', 'fixedToolbar') || !isLargeViewport, 14686 hiddenBlockTypes: get('core', 'hiddenBlockTypes'), 14687 isDistractionFree: get('core', 'distractionFree'), 14688 keepCaretInsideBlock: get('core', 'keepCaretInsideBlock'), 14689 reusableBlocks: isWeb ? getEntityRecords('postType', 'wp_block', { 14690 per_page: -1 14691 }) : EMPTY_BLOCKS_LIST, 14692 // Reusable blocks are fetched in the native version of this hook. 14693 hasUploadPermissions: (_canUser = canUser('create', 'media')) !== null && _canUser !== void 0 ? _canUser : true, 14694 userCanCreatePages: canUser('create', 'pages'), 14695 pageOnFront: siteSettings?.page_on_front, 14696 pageForPosts: siteSettings?.page_for_posts, 14697 userPatternCategories: getUserPatternCategories(), 14698 restBlockPatternCategories: getBlockPatternCategories() 14699 }; 14700 }, [postType, postId, isLargeViewport]); 14701 const settingsBlockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : 14702 // WP 6.0 14703 settings.__experimentalBlockPatterns; // WP 5.9 14704 const settingsBlockPatternCategories = (_settings$__experimen2 = settings.__experimentalAdditionalBlockPatternCategories) !== null && _settings$__experimen2 !== void 0 ? _settings$__experimen2 : 14705 // WP 6.0 14706 settings.__experimentalBlockPatternCategories; // WP 5.9 14707 14708 const blockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatterns || [])].filter(({ 14709 postTypes 14710 }) => { 14711 return !postTypes || Array.isArray(postTypes) && postTypes.includes(postType); 14712 }), [settingsBlockPatterns, postType]); 14713 const blockPatternCategories = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatternCategories || []), ...(restBlockPatternCategories || [])].filter((x, index, arr) => index === arr.findIndex(y => x.name === y.name)), [settingsBlockPatternCategories, restBlockPatternCategories]); 14714 const { 14715 undo, 14716 setIsInserterOpened 14717 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 14718 const { 14719 saveEntityRecord 14720 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 14721 14722 /** 14723 * Creates a Post entity. 14724 * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages. 14725 * 14726 * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord. 14727 * @return {Object} the post type object that was created. 14728 */ 14729 const createPageEntity = (0,external_wp_element_namespaceObject.useCallback)(options => { 14730 if (!userCanCreatePages) { 14731 return Promise.reject({ 14732 message: (0,external_wp_i18n_namespaceObject.__)('You do not have permission to create Pages.') 14733 }); 14734 } 14735 return saveEntityRecord('postType', 'page', options); 14736 }, [saveEntityRecord, userCanCreatePages]); 14737 const allowedBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => { 14738 // Omit hidden block types if exists and non-empty. 14739 if (hiddenBlockTypes && hiddenBlockTypes.length > 0) { 14740 // Defer to passed setting for `allowedBlockTypes` if provided as 14741 // anything other than `true` (where `true` is equivalent to allow 14742 // all block types). 14743 const defaultAllowedBlockTypes = true === settings.allowedBlockTypes ? blockTypes.map(({ 14744 name 14745 }) => name) : settings.allowedBlockTypes || []; 14746 return defaultAllowedBlockTypes.filter(type => !hiddenBlockTypes.includes(type)); 14747 } 14748 return settings.allowedBlockTypes; 14749 }, [settings.allowedBlockTypes, hiddenBlockTypes, blockTypes]); 14750 const forceDisableFocusMode = settings.focusMode === false; 14751 return (0,external_wp_element_namespaceObject.useMemo)(() => ({ 14752 ...Object.fromEntries(Object.entries(settings).filter(([key]) => BLOCK_EDITOR_SETTINGS.includes(key))), 14753 allowedBlockTypes, 14754 allowRightClickOverrides, 14755 focusMode: focusMode && !forceDisableFocusMode, 14756 hasFixedToolbar, 14757 isDistractionFree, 14758 keepCaretInsideBlock, 14759 mediaUpload: hasUploadPermissions ? mediaUpload : undefined, 14760 __experimentalBlockPatterns: blockPatterns, 14761 [unlock(external_wp_blockEditor_namespaceObject.privateApis).selectBlockPatternsKey]: select => unlock(select(external_wp_coreData_namespaceObject.store)).getBlockPatternsForPostType(postType), 14762 __experimentalReusableBlocks: reusableBlocks, 14763 __experimentalBlockPatternCategories: blockPatternCategories, 14764 __experimentalUserPatternCategories: userPatternCategories, 14765 __experimentalFetchLinkSuggestions: (search, searchOptions) => (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings), 14766 inserterMediaCategories: media_categories, 14767 __experimentalFetchRichUrlData: external_wp_coreData_namespaceObject.__experimentalFetchUrlData, 14768 // Todo: This only checks the top level post, not the post within a template or any other entity that can be edited. 14769 // This might be better as a generic "canUser" selector. 14770 __experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML, 14771 //Todo: this is only needed for native and should probably be removed. 14772 __experimentalUndo: undo, 14773 // Check whether we want all site editor frames to have outlines 14774 // including the navigation / pattern / parts editors. 14775 outlineMode: postType === 'wp_template', 14776 // Check these two properties: they were not present in the site editor. 14777 __experimentalCreatePageEntity: createPageEntity, 14778 __experimentalUserCanCreatePages: userCanCreatePages, 14779 pageOnFront, 14780 pageForPosts, 14781 __experimentalPreferPatternsOnRoot: postType === 'wp_template', 14782 templateLock: postType === 'wp_navigation' ? 'insert' : settings.templateLock, 14783 template: postType === 'wp_navigation' ? [['core/navigation', {}, []]] : settings.template, 14784 __experimentalSetIsInserterOpened: setIsInserterOpened 14785 }), [allowedBlockTypes, allowRightClickOverrides, focusMode, forceDisableFocusMode, hasFixedToolbar, isDistractionFree, keepCaretInsideBlock, settings, hasUploadPermissions, reusableBlocks, userPatternCategories, blockPatterns, blockPatternCategories, canUseUnfilteredHTML, undo, createPageEntity, userCanCreatePages, pageOnFront, pageForPosts, postType, setIsInserterOpened]); 14786 } 14787 /* harmony default export */ const use_block_editor_settings = (useBlockEditorSettings); 14788 14789 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/provider/disable-non-page-content-blocks.js 14790 /** 14791 * WordPress dependencies 14792 */ 14793 14794 14795 14796 const PAGE_CONTENT_BLOCKS = ['core/post-title', 'core/post-featured-image', 'core/post-content']; 14797 function useDisableNonPageContentBlocks() { 14798 const contentIds = (0,external_wp_data_namespaceObject.useSelect)(select => { 14799 const { 14800 getBlocksByName, 14801 getBlockParents, 14802 getBlockName 14803 } = select(external_wp_blockEditor_namespaceObject.store); 14804 return getBlocksByName(PAGE_CONTENT_BLOCKS).filter(clientId => getBlockParents(clientId).every(parentClientId => { 14805 const parentBlockName = getBlockName(parentClientId); 14806 return parentBlockName !== 'core/query' && !PAGE_CONTENT_BLOCKS.includes(parentBlockName); 14807 })); 14808 }, []); 14809 const { 14810 setBlockEditingMode, 14811 unsetBlockEditingMode 14812 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 14813 (0,external_wp_element_namespaceObject.useEffect)(() => { 14814 setBlockEditingMode('', 'disabled'); // Disable editing at the root level. 14815 14816 for (const contentId of contentIds) { 14817 setBlockEditingMode(contentId, 'contentOnly'); // Re-enable each content block. 14818 } 14819 return () => { 14820 unsetBlockEditingMode(''); 14821 for (const contentId of contentIds) { 14822 unsetBlockEditingMode(contentId); 14823 } 14824 }; 14825 }, [contentIds, setBlockEditingMode, unsetBlockEditingMode]); 14826 } 14827 14828 /** 14829 * Component that when rendered, makes it so that the site editor allows only 14830 * page content to be edited. 14831 */ 14832 function DisableNonPageContentBlocks() { 14833 useDisableNonPageContentBlocks(); 14834 } 14835 14836 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/provider/navigation-block-editing-mode.js 14837 /** 14838 * WordPress dependencies 14839 */ 14840 14841 14842 14843 14844 /** 14845 * For the Navigation block editor, we need to force the block editor to contentOnly for that block. 14846 * 14847 * Set block editing mode to contentOnly when entering Navigation focus mode. 14848 * this ensures that non-content controls on the block will be hidden and thus 14849 * the user can focus on editing the Navigation Menu content only. 14850 */ 14851 14852 function NavigationBlockEditingMode() { 14853 // In the navigation block editor, 14854 // the navigation block is the only root block. 14855 const blockClientId = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getBlockOrder()?.[0], []); 14856 const { 14857 setBlockEditingMode, 14858 unsetBlockEditingMode 14859 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 14860 (0,external_wp_element_namespaceObject.useEffect)(() => { 14861 if (!blockClientId) { 14862 return; 14863 } 14864 setBlockEditingMode(blockClientId, 'contentOnly'); 14865 return () => { 14866 unsetBlockEditingMode(blockClientId); 14867 }; 14868 }, [blockClientId, unsetBlockEditingMode, setBlockEditingMode]); 14869 } 14870 14871 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/provider/index.js 14872 14873 /** 14874 * WordPress dependencies 14875 */ 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 /** 14886 * Internal dependencies 14887 */ 14888 14889 14890 14891 14892 14893 14894 const { 14895 ExperimentalBlockEditorProvider 14896 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 14897 const { 14898 PatternsMenuItems 14899 } = unlock(external_wp_patterns_namespaceObject.privateApis); 14900 const provider_noop = () => {}; 14901 14902 /** 14903 * These are global entities that are only there to split blocks into logical units 14904 * They don't provide a "context" for the current post/page being rendered. 14905 * So we should not use their ids as post context. This is important to allow post blocks 14906 * (post content, post title) to be used within them without issues. 14907 */ 14908 const NON_CONTEXTUAL_POST_TYPES = ['wp_block', 'wp_template', 'wp_navigation', 'wp_template_part']; 14909 14910 /** 14911 * Depending on the post, template and template mode, 14912 * returns the appropriate blocks and change handlers for the block editor provider. 14913 * 14914 * @param {Array} post Block list. 14915 * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`. 14916 * @param {string} mode Rendering mode. 14917 * @return {Array} Block editor props. 14918 */ 14919 function useBlockEditorProps(post, template, mode) { 14920 const rootLevelPost = mode === 'post-only' || !template ? 'post' : 'template'; 14921 const [postBlocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', post.type, { 14922 id: post.id 14923 }); 14924 const [templateBlocks, onInputTemplate, onChangeTemplate] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', template?.type, { 14925 id: template?.id 14926 }); 14927 const maybeNavigationBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => { 14928 if (post.type === 'wp_navigation') { 14929 return [(0,external_wp_blocks_namespaceObject.createBlock)('core/navigation', { 14930 ref: post.id, 14931 // As the parent editor is locked with `templateLock`, the template locking 14932 // must be explicitly "unset" on the block itself to allow the user to modify 14933 // the block's content. 14934 templateLock: false 14935 })]; 14936 } 14937 }, [post.type, post.id]); 14938 14939 // It is important that we don't create a new instance of blocks on every change 14940 // We should only create a new instance if the blocks them selves change, not a dependency of them. 14941 const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => { 14942 if (maybeNavigationBlocks) { 14943 return maybeNavigationBlocks; 14944 } 14945 if (rootLevelPost === 'template') { 14946 return templateBlocks; 14947 } 14948 return postBlocks; 14949 }, [maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks]); 14950 14951 // Handle fallback to postBlocks outside of the above useMemo, to ensure 14952 // that constructed block templates that call `createBlock` are not generated 14953 // too frequently. This ensures that clientIds are stable. 14954 const disableRootLevelChanges = !!template && mode === 'template-locked' || post.type === 'wp_navigation'; 14955 if (disableRootLevelChanges) { 14956 return [blocks, provider_noop, provider_noop]; 14957 } 14958 return [blocks, rootLevelPost === 'post' ? onInput : onInputTemplate, rootLevelPost === 'post' ? onChange : onChangeTemplate]; 14959 } 14960 const ExperimentalEditorProvider = with_registry_provider(({ 14961 post, 14962 settings, 14963 recovery, 14964 initialEdits, 14965 children, 14966 BlockEditorProviderComponent = ExperimentalBlockEditorProvider, 14967 __unstableTemplate: template 14968 }) => { 14969 const mode = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getRenderingMode(), []); 14970 const shouldRenderTemplate = !!template && mode !== 'post-only'; 14971 const rootLevelPost = shouldRenderTemplate ? template : post; 14972 const defaultBlockContext = (0,external_wp_element_namespaceObject.useMemo)(() => { 14973 const postContext = !NON_CONTEXTUAL_POST_TYPES.includes(rootLevelPost.type) || shouldRenderTemplate ? { 14974 postId: post.id, 14975 postType: post.type 14976 } : {}; 14977 return { 14978 ...postContext, 14979 templateSlug: rootLevelPost.type === 'wp_template' ? rootLevelPost.slug : undefined 14980 }; 14981 }, [shouldRenderTemplate, post.id, post.type, rootLevelPost.type, rootLevelPost.slug]); 14982 const { 14983 editorSettings, 14984 selection, 14985 isReady 14986 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 14987 const { 14988 getEditorSettings, 14989 getEditorSelection, 14990 __unstableIsEditorReady 14991 } = select(store_store); 14992 return { 14993 editorSettings: getEditorSettings(), 14994 isReady: __unstableIsEditorReady(), 14995 selection: getEditorSelection() 14996 }; 14997 }, []); 14998 const { 14999 id, 15000 type 15001 } = rootLevelPost; 15002 const blockEditorSettings = use_block_editor_settings(editorSettings, type, id); 15003 const [blocks, onInput, onChange] = useBlockEditorProps(post, template, mode); 15004 const { 15005 updatePostLock, 15006 setupEditor, 15007 updateEditorSettings, 15008 setCurrentTemplateId, 15009 setEditedPost, 15010 setRenderingMode 15011 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 15012 const { 15013 createWarningNotice 15014 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 15015 15016 // Ideally this should be synced on each change and not just something you do once. 15017 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 15018 // Assume that we don't need to initialize in the case of an error recovery. 15019 if (recovery) { 15020 return; 15021 } 15022 updatePostLock(settings.postLock); 15023 setupEditor(post, initialEdits, settings.template); 15024 if (settings.autosave) { 15025 createWarningNotice((0,external_wp_i18n_namespaceObject.__)('There is an autosave of this post that is more recent than the version below.'), { 15026 id: 'autosave-exists', 15027 actions: [{ 15028 label: (0,external_wp_i18n_namespaceObject.__)('View the autosave'), 15029 url: settings.autosave.editLink 15030 }] 15031 }); 15032 } 15033 }, []); 15034 15035 // Synchronizes the active post with the state 15036 (0,external_wp_element_namespaceObject.useEffect)(() => { 15037 setEditedPost(post.type, post.id); 15038 }, [post.type, post.id, setEditedPost]); 15039 15040 // Synchronize the editor settings as they change. 15041 (0,external_wp_element_namespaceObject.useEffect)(() => { 15042 updateEditorSettings(settings); 15043 }, [settings, updateEditorSettings]); 15044 15045 // Synchronizes the active template with the state. 15046 (0,external_wp_element_namespaceObject.useEffect)(() => { 15047 setCurrentTemplateId(template?.id); 15048 }, [template?.id, setCurrentTemplateId]); 15049 15050 // Sets the right rendering mode when loading the editor. 15051 (0,external_wp_element_namespaceObject.useEffect)(() => { 15052 var _settings$defaultRend; 15053 setRenderingMode((_settings$defaultRend = settings.defaultRenderingMode) !== null && _settings$defaultRend !== void 0 ? _settings$defaultRend : 'post-only'); 15054 }, [settings.defaultRenderingMode, setRenderingMode]); 15055 if (!isReady) { 15056 return null; 15057 } 15058 return (0,external_React_.createElement)(external_wp_coreData_namespaceObject.EntityProvider, { 15059 kind: "root", 15060 type: "site" 15061 }, (0,external_React_.createElement)(external_wp_coreData_namespaceObject.EntityProvider, { 15062 kind: "postType", 15063 type: post.type, 15064 id: post.id 15065 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockContextProvider, { 15066 value: defaultBlockContext 15067 }, (0,external_React_.createElement)(BlockEditorProviderComponent, { 15068 value: blocks, 15069 onChange: onChange, 15070 onInput: onInput, 15071 selection: selection, 15072 settings: blockEditorSettings, 15073 useSubRegistry: false 15074 }, children, (0,external_React_.createElement)(PatternsMenuItems, null), mode === 'template-locked' && (0,external_React_.createElement)(DisableNonPageContentBlocks, null), type === 'wp_navigation' && (0,external_React_.createElement)(NavigationBlockEditingMode, null))))); 15075 }); 15076 function EditorProvider(props) { 15077 return (0,external_React_.createElement)(ExperimentalEditorProvider, { 15078 ...props, 15079 BlockEditorProviderComponent: external_wp_blockEditor_namespaceObject.BlockEditorProvider 15080 }, props.children); 15081 } 15082 /* harmony default export */ const provider = (EditorProvider); 15083 15084 ;// CONCATENATED MODULE: external ["wp","serverSideRender"] 15085 const external_wp_serverSideRender_namespaceObject = window["wp"]["serverSideRender"]; 15086 var external_wp_serverSideRender_default = /*#__PURE__*/__webpack_require__.n(external_wp_serverSideRender_namespaceObject); 15087 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/deprecated.js 15088 15089 // Block Creation Components. 15090 /** 15091 * WordPress dependencies 15092 */ 15093 15094 15095 15096 15097 function deprecateComponent(name, Wrapped, staticsToHoist = []) { 15098 const Component = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => { 15099 external_wp_deprecated_default()('wp.editor.' + name, { 15100 since: '5.3', 15101 alternative: 'wp.blockEditor.' + name, 15102 version: '6.2' 15103 }); 15104 return (0,external_React_.createElement)(Wrapped, { 15105 ref: ref, 15106 ...props 15107 }); 15108 }); 15109 staticsToHoist.forEach(staticName => { 15110 Component[staticName] = deprecateComponent(name + '.' + staticName, Wrapped[staticName]); 15111 }); 15112 return Component; 15113 } 15114 function deprecateFunction(name, func) { 15115 return (...args) => { 15116 external_wp_deprecated_default()('wp.editor.' + name, { 15117 since: '5.3', 15118 alternative: 'wp.blockEditor.' + name, 15119 version: '6.2' 15120 }); 15121 return func(...args); 15122 }; 15123 } 15124 const RichText = deprecateComponent('RichText', external_wp_blockEditor_namespaceObject.RichText, ['Content']); 15125 RichText.isEmpty = deprecateFunction('RichText.isEmpty', external_wp_blockEditor_namespaceObject.RichText.isEmpty); 15126 15127 const Autocomplete = deprecateComponent('Autocomplete', external_wp_blockEditor_namespaceObject.Autocomplete); 15128 const AlignmentToolbar = deprecateComponent('AlignmentToolbar', external_wp_blockEditor_namespaceObject.AlignmentToolbar); 15129 const BlockAlignmentToolbar = deprecateComponent('BlockAlignmentToolbar', external_wp_blockEditor_namespaceObject.BlockAlignmentToolbar); 15130 const BlockControls = deprecateComponent('BlockControls', external_wp_blockEditor_namespaceObject.BlockControls, ['Slot']); 15131 const BlockEdit = deprecateComponent('BlockEdit', external_wp_blockEditor_namespaceObject.BlockEdit); 15132 const BlockEditorKeyboardShortcuts = deprecateComponent('BlockEditorKeyboardShortcuts', external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts); 15133 const BlockFormatControls = deprecateComponent('BlockFormatControls', external_wp_blockEditor_namespaceObject.BlockFormatControls, ['Slot']); 15134 const BlockIcon = deprecateComponent('BlockIcon', external_wp_blockEditor_namespaceObject.BlockIcon); 15135 const BlockInspector = deprecateComponent('BlockInspector', external_wp_blockEditor_namespaceObject.BlockInspector); 15136 const BlockList = deprecateComponent('BlockList', external_wp_blockEditor_namespaceObject.BlockList); 15137 const BlockMover = deprecateComponent('BlockMover', external_wp_blockEditor_namespaceObject.BlockMover); 15138 const BlockNavigationDropdown = deprecateComponent('BlockNavigationDropdown', external_wp_blockEditor_namespaceObject.BlockNavigationDropdown); 15139 const BlockSelectionClearer = deprecateComponent('BlockSelectionClearer', external_wp_blockEditor_namespaceObject.BlockSelectionClearer); 15140 const BlockSettingsMenu = deprecateComponent('BlockSettingsMenu', external_wp_blockEditor_namespaceObject.BlockSettingsMenu); 15141 const BlockTitle = deprecateComponent('BlockTitle', external_wp_blockEditor_namespaceObject.BlockTitle); 15142 const BlockToolbar = deprecateComponent('BlockToolbar', external_wp_blockEditor_namespaceObject.BlockToolbar); 15143 const ColorPalette = deprecateComponent('ColorPalette', external_wp_blockEditor_namespaceObject.ColorPalette); 15144 const ContrastChecker = deprecateComponent('ContrastChecker', external_wp_blockEditor_namespaceObject.ContrastChecker); 15145 const CopyHandler = deprecateComponent('CopyHandler', external_wp_blockEditor_namespaceObject.CopyHandler); 15146 const DefaultBlockAppender = deprecateComponent('DefaultBlockAppender', external_wp_blockEditor_namespaceObject.DefaultBlockAppender); 15147 const FontSizePicker = deprecateComponent('FontSizePicker', external_wp_blockEditor_namespaceObject.FontSizePicker); 15148 const Inserter = deprecateComponent('Inserter', external_wp_blockEditor_namespaceObject.Inserter); 15149 const InnerBlocks = deprecateComponent('InnerBlocks', external_wp_blockEditor_namespaceObject.InnerBlocks, ['ButtonBlockAppender', 'DefaultBlockAppender', 'Content']); 15150 const InspectorAdvancedControls = deprecateComponent('InspectorAdvancedControls', external_wp_blockEditor_namespaceObject.InspectorAdvancedControls, ['Slot']); 15151 const InspectorControls = deprecateComponent('InspectorControls', external_wp_blockEditor_namespaceObject.InspectorControls, ['Slot']); 15152 const PanelColorSettings = deprecateComponent('PanelColorSettings', external_wp_blockEditor_namespaceObject.PanelColorSettings); 15153 const PlainText = deprecateComponent('PlainText', external_wp_blockEditor_namespaceObject.PlainText); 15154 const RichTextShortcut = deprecateComponent('RichTextShortcut', external_wp_blockEditor_namespaceObject.RichTextShortcut); 15155 const RichTextToolbarButton = deprecateComponent('RichTextToolbarButton', external_wp_blockEditor_namespaceObject.RichTextToolbarButton); 15156 const __unstableRichTextInputEvent = deprecateComponent('__unstableRichTextInputEvent', external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent); 15157 const MediaPlaceholder = deprecateComponent('MediaPlaceholder', external_wp_blockEditor_namespaceObject.MediaPlaceholder); 15158 const MediaUpload = deprecateComponent('MediaUpload', external_wp_blockEditor_namespaceObject.MediaUpload); 15159 const MediaUploadCheck = deprecateComponent('MediaUploadCheck', external_wp_blockEditor_namespaceObject.MediaUploadCheck); 15160 const MultiSelectScrollIntoView = deprecateComponent('MultiSelectScrollIntoView', external_wp_blockEditor_namespaceObject.MultiSelectScrollIntoView); 15161 const NavigableToolbar = deprecateComponent('NavigableToolbar', external_wp_blockEditor_namespaceObject.NavigableToolbar); 15162 const ObserveTyping = deprecateComponent('ObserveTyping', external_wp_blockEditor_namespaceObject.ObserveTyping); 15163 const SkipToSelectedBlock = deprecateComponent('SkipToSelectedBlock', external_wp_blockEditor_namespaceObject.SkipToSelectedBlock); 15164 const URLInput = deprecateComponent('URLInput', external_wp_blockEditor_namespaceObject.URLInput); 15165 const URLInputButton = deprecateComponent('URLInputButton', external_wp_blockEditor_namespaceObject.URLInputButton); 15166 const URLPopover = deprecateComponent('URLPopover', external_wp_blockEditor_namespaceObject.URLPopover); 15167 const Warning = deprecateComponent('Warning', external_wp_blockEditor_namespaceObject.Warning); 15168 const WritingFlow = deprecateComponent('WritingFlow', external_wp_blockEditor_namespaceObject.WritingFlow); 15169 const createCustomColorsHOC = deprecateFunction('createCustomColorsHOC', external_wp_blockEditor_namespaceObject.createCustomColorsHOC); 15170 const getColorClassName = deprecateFunction('getColorClassName', external_wp_blockEditor_namespaceObject.getColorClassName); 15171 const getColorObjectByAttributeValues = deprecateFunction('getColorObjectByAttributeValues', external_wp_blockEditor_namespaceObject.getColorObjectByAttributeValues); 15172 const getColorObjectByColorValue = deprecateFunction('getColorObjectByColorValue', external_wp_blockEditor_namespaceObject.getColorObjectByColorValue); 15173 const getFontSize = deprecateFunction('getFontSize', external_wp_blockEditor_namespaceObject.getFontSize); 15174 const getFontSizeClass = deprecateFunction('getFontSizeClass', external_wp_blockEditor_namespaceObject.getFontSizeClass); 15175 const withColorContext = deprecateFunction('withColorContext', external_wp_blockEditor_namespaceObject.withColorContext); 15176 const withColors = deprecateFunction('withColors', external_wp_blockEditor_namespaceObject.withColors); 15177 const withFontSizes = deprecateFunction('withFontSizes', external_wp_blockEditor_namespaceObject.withFontSizes); 15178 15179 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/index.js 15180 /** 15181 * Internal dependencies 15182 */ 15183 15184 15185 // Block Creation Components. 15186 15187 15188 // Post Related Components. 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 15259 15260 15261 15262 15263 15264 15265 15266 15267 15268 15269 // State Related Components. 15270 15271 15272 const VisualEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts; 15273 const TextEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts; 15274 15275 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/url.js 15276 /** 15277 * WordPress dependencies 15278 */ 15279 15280 15281 15282 /** 15283 * Performs some basic cleanup of a string for use as a post slug 15284 * 15285 * This replicates some of what sanitize_title() does in WordPress core, but 15286 * is only designed to approximate what the slug will be. 15287 * 15288 * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin letters. 15289 * Removes combining diacritical marks. Converts whitespace, periods, 15290 * and forward slashes to hyphens. Removes any remaining non-word characters 15291 * except hyphens and underscores. Converts remaining string to lowercase. 15292 * It does not account for octets, HTML entities, or other encoded characters. 15293 * 15294 * @param {string} string Title or slug to be processed 15295 * 15296 * @return {string} Processed string 15297 */ 15298 function cleanForSlug(string) { 15299 external_wp_deprecated_default()('wp.editor.cleanForSlug', { 15300 since: '12.7', 15301 plugin: 'Gutenberg', 15302 alternative: 'wp.url.cleanForSlug' 15303 }); 15304 return (0,external_wp_url_namespaceObject.cleanForSlug)(string); 15305 } 15306 15307 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/index.js 15308 /** 15309 * Internal dependencies 15310 */ 15311 15312 15313 15314 15315 15316 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/editor-canvas/edit-template-blocks-notification.js 15317 15318 /** 15319 * WordPress dependencies 15320 */ 15321 15322 15323 15324 15325 15326 15327 /** 15328 * Internal dependencies 15329 */ 15330 15331 15332 /** 15333 * Component that: 15334 * 15335 * - Displays a 'Edit your template to edit this block' notification when the 15336 * user is focusing on editing page content and clicks on a disabled template 15337 * block. 15338 * - Displays a 'Edit your template to edit this block' dialog when the user 15339 * is focusing on editing page conetnt and double clicks on a disabled 15340 * template block. 15341 * 15342 * @param {Object} props 15343 * @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block 15344 * editor iframe canvas. 15345 */ 15346 function EditTemplateBlocksNotification({ 15347 contentRef 15348 }) { 15349 const { 15350 onNavigateToEntityRecord, 15351 templateId 15352 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 15353 const { 15354 getEditorSettings, 15355 getCurrentTemplateId 15356 } = select(store_store); 15357 return { 15358 onNavigateToEntityRecord: getEditorSettings().onNavigateToEntityRecord, 15359 templateId: getCurrentTemplateId() 15360 }; 15361 }, []); 15362 const { 15363 getNotices 15364 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_notices_namespaceObject.store); 15365 const { 15366 createInfoNotice, 15367 removeNotice 15368 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 15369 const [isDialogOpen, setIsDialogOpen] = (0,external_wp_element_namespaceObject.useState)(false); 15370 const lastNoticeId = (0,external_wp_element_namespaceObject.useRef)(0); 15371 (0,external_wp_element_namespaceObject.useEffect)(() => { 15372 const handleClick = async event => { 15373 if (!event.target.classList.contains('is-root-container')) { 15374 return; 15375 } 15376 const isNoticeAlreadyShowing = getNotices().some(notice => notice.id === lastNoticeId.current); 15377 if (isNoticeAlreadyShowing) { 15378 return; 15379 } 15380 const { 15381 notice 15382 } = await createInfoNotice((0,external_wp_i18n_namespaceObject.__)('Edit your template to edit this block.'), { 15383 isDismissible: true, 15384 type: 'snackbar', 15385 actions: [{ 15386 label: (0,external_wp_i18n_namespaceObject.__)('Edit template'), 15387 onClick: () => onNavigateToEntityRecord({ 15388 postId: templateId, 15389 postType: 'wp_template' 15390 }) 15391 }] 15392 }); 15393 lastNoticeId.current = notice.id; 15394 }; 15395 const handleDblClick = event => { 15396 if (!event.target.classList.contains('is-root-container')) { 15397 return; 15398 } 15399 if (lastNoticeId.current) { 15400 removeNotice(lastNoticeId.current); 15401 } 15402 setIsDialogOpen(true); 15403 }; 15404 const canvas = contentRef.current; 15405 canvas?.addEventListener('click', handleClick); 15406 canvas?.addEventListener('dblclick', handleDblClick); 15407 return () => { 15408 canvas?.removeEventListener('click', handleClick); 15409 canvas?.removeEventListener('dblclick', handleDblClick); 15410 }; 15411 }, [lastNoticeId, contentRef, getNotices, createInfoNotice, onNavigateToEntityRecord, templateId, removeNotice]); 15412 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { 15413 isOpen: isDialogOpen, 15414 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Edit template'), 15415 onConfirm: () => { 15416 setIsDialogOpen(false); 15417 onNavigateToEntityRecord({ 15418 postId: templateId, 15419 postType: 'wp_template' 15420 }); 15421 }, 15422 onCancel: () => setIsDialogOpen(false) 15423 }, (0,external_wp_i18n_namespaceObject.__)('Edit your template to edit this block.')); 15424 } 15425 15426 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/editor-canvas/index.js 15427 15428 /** 15429 * External dependencies 15430 */ 15431 15432 15433 /** 15434 * WordPress dependencies 15435 */ 15436 15437 15438 15439 15440 15441 15442 15443 /** 15444 * Internal dependencies 15445 */ 15446 15447 15448 15449 15450 const { 15451 LayoutStyle, 15452 useLayoutClasses, 15453 useLayoutStyles, 15454 ExperimentalBlockCanvas: BlockCanvas, 15455 useFlashEditableBlocks 15456 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 15457 const editor_canvas_noop = () => {}; 15458 15459 /** 15460 * These post types have a special editor where they don't allow you to fill the title 15461 * and they don't apply the layout styles. 15462 */ 15463 const DESIGN_POST_TYPES = ['wp_block', 'wp_template', 'wp_navigation', 'wp_template_part']; 15464 15465 /** 15466 * Given an array of nested blocks, find the first Post Content 15467 * block inside it, recursing through any nesting levels, 15468 * and return its attributes. 15469 * 15470 * @param {Array} blocks A list of blocks. 15471 * 15472 * @return {Object | undefined} The Post Content block. 15473 */ 15474 function getPostContentAttributes(blocks) { 15475 for (let i = 0; i < blocks.length; i++) { 15476 if (blocks[i].name === 'core/post-content') { 15477 return blocks[i].attributes; 15478 } 15479 if (blocks[i].innerBlocks.length) { 15480 const nestedPostContent = getPostContentAttributes(blocks[i].innerBlocks); 15481 if (nestedPostContent) { 15482 return nestedPostContent; 15483 } 15484 } 15485 } 15486 } 15487 function checkForPostContentAtRootLevel(blocks) { 15488 for (let i = 0; i < blocks.length; i++) { 15489 if (blocks[i].name === 'core/post-content') { 15490 return true; 15491 } 15492 } 15493 return false; 15494 } 15495 function EditorCanvas({ 15496 // Ideally as we unify post and site editors, we won't need these props. 15497 autoFocus, 15498 className, 15499 renderAppender, 15500 styles, 15501 disableIframe = false, 15502 iframeProps, 15503 children 15504 }) { 15505 const { 15506 renderingMode, 15507 postContentAttributes, 15508 editedPostTemplate = {}, 15509 wrapperBlockName, 15510 wrapperUniqueId, 15511 deviceType, 15512 showEditorPadding, 15513 isDesignPostType 15514 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 15515 const { 15516 getCurrentPostId, 15517 getCurrentPostType, 15518 getCurrentTemplateId, 15519 getEditorSettings, 15520 getRenderingMode, 15521 getDeviceType 15522 } = select(store_store); 15523 const { 15524 getPostType, 15525 canUser, 15526 getEditedEntityRecord 15527 } = select(external_wp_coreData_namespaceObject.store); 15528 const postTypeSlug = getCurrentPostType(); 15529 const _renderingMode = getRenderingMode(); 15530 let _wrapperBlockName; 15531 if (postTypeSlug === 'wp_block') { 15532 _wrapperBlockName = 'core/block'; 15533 } else if (_renderingMode === 'post-only') { 15534 _wrapperBlockName = 'core/post-content'; 15535 } 15536 const editorSettings = getEditorSettings(); 15537 const supportsTemplateMode = editorSettings.supportsTemplateMode; 15538 const postType = getPostType(postTypeSlug); 15539 const canEditTemplate = canUser('create', 'templates'); 15540 const currentTemplateId = getCurrentTemplateId(); 15541 const template = currentTemplateId ? getEditedEntityRecord('postType', 'wp_template', currentTemplateId) : undefined; 15542 return { 15543 renderingMode: _renderingMode, 15544 postContentAttributes: editorSettings.postContentAttributes, 15545 isDesignPostType: DESIGN_POST_TYPES.includes(postTypeSlug), 15546 // Post template fetch returns a 404 on classic themes, which 15547 // messes with e2e tests, so check it's a block theme first. 15548 editedPostTemplate: postType?.viewable && supportsTemplateMode && canEditTemplate ? template : undefined, 15549 wrapperBlockName: _wrapperBlockName, 15550 wrapperUniqueId: getCurrentPostId(), 15551 deviceType: getDeviceType(), 15552 showEditorPadding: !!editorSettings.onNavigateToPreviousEntityRecord 15553 }; 15554 }, []); 15555 const { 15556 isCleanNewPost 15557 } = (0,external_wp_data_namespaceObject.useSelect)(store_store); 15558 const { 15559 hasRootPaddingAwareAlignments, 15560 themeHasDisabledLayoutStyles, 15561 themeSupportsLayout 15562 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 15563 const _settings = select(external_wp_blockEditor_namespaceObject.store).getSettings(); 15564 return { 15565 themeHasDisabledLayoutStyles: _settings.disableLayoutStyles, 15566 themeSupportsLayout: _settings.supportsLayout, 15567 hasRootPaddingAwareAlignments: _settings.__experimentalFeatures?.useRootPaddingAwareAlignments 15568 }; 15569 }, []); 15570 const deviceStyles = (0,external_wp_blockEditor_namespaceObject.__experimentalUseResizeCanvas)(deviceType); 15571 const [globalLayoutSettings] = (0,external_wp_blockEditor_namespaceObject.useSettings)('layout'); 15572 15573 // fallbackLayout is used if there is no Post Content, 15574 // and for Post Title. 15575 const fallbackLayout = (0,external_wp_element_namespaceObject.useMemo)(() => { 15576 if (renderingMode !== 'post-only' || isDesignPostType) { 15577 return { 15578 type: 'default' 15579 }; 15580 } 15581 if (themeSupportsLayout) { 15582 // We need to ensure support for wide and full alignments, 15583 // so we add the constrained type. 15584 return { 15585 ...globalLayoutSettings, 15586 type: 'constrained' 15587 }; 15588 } 15589 // Set default layout for classic themes so all alignments are supported. 15590 return { 15591 type: 'default' 15592 }; 15593 }, [renderingMode, themeSupportsLayout, globalLayoutSettings, isDesignPostType]); 15594 const newestPostContentAttributes = (0,external_wp_element_namespaceObject.useMemo)(() => { 15595 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks && postContentAttributes) { 15596 return postContentAttributes; 15597 } 15598 // When in template editing mode, we can access the blocks directly. 15599 if (editedPostTemplate?.blocks) { 15600 return getPostContentAttributes(editedPostTemplate?.blocks); 15601 } 15602 // If there are no blocks, we have to parse the content string. 15603 // Best double-check it's a string otherwise the parse function gets unhappy. 15604 const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : ''; 15605 return getPostContentAttributes((0,external_wp_blocks_namespaceObject.parse)(parseableContent)) || {}; 15606 }, [editedPostTemplate?.content, editedPostTemplate?.blocks, postContentAttributes]); 15607 const hasPostContentAtRootLevel = (0,external_wp_element_namespaceObject.useMemo)(() => { 15608 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) { 15609 return false; 15610 } 15611 // When in template editing mode, we can access the blocks directly. 15612 if (editedPostTemplate?.blocks) { 15613 return checkForPostContentAtRootLevel(editedPostTemplate?.blocks); 15614 } 15615 // If there are no blocks, we have to parse the content string. 15616 // Best double-check it's a string otherwise the parse function gets unhappy. 15617 const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : ''; 15618 return checkForPostContentAtRootLevel((0,external_wp_blocks_namespaceObject.parse)(parseableContent)) || false; 15619 }, [editedPostTemplate?.content, editedPostTemplate?.blocks]); 15620 const { 15621 layout = {}, 15622 align = '' 15623 } = newestPostContentAttributes || {}; 15624 const postContentLayoutClasses = useLayoutClasses(newestPostContentAttributes, 'core/post-content'); 15625 const blockListLayoutClass = classnames_default()({ 15626 'is-layout-flow': !themeSupportsLayout 15627 }, themeSupportsLayout && postContentLayoutClasses, align && `align$align}`); 15628 const postContentLayoutStyles = useLayoutStyles(newestPostContentAttributes, 'core/post-content', '.block-editor-block-list__layout.is-root-container'); 15629 15630 // Update type for blocks using legacy layouts. 15631 const postContentLayout = (0,external_wp_element_namespaceObject.useMemo)(() => { 15632 return layout && (layout?.type === 'constrained' || layout?.inherit || layout?.contentSize || layout?.wideSize) ? { 15633 ...globalLayoutSettings, 15634 ...layout, 15635 type: 'constrained' 15636 } : { 15637 ...globalLayoutSettings, 15638 ...layout, 15639 type: 'default' 15640 }; 15641 }, [layout?.type, layout?.inherit, layout?.contentSize, layout?.wideSize, globalLayoutSettings]); 15642 15643 // If there is a Post Content block we use its layout for the block list; 15644 // if not, this must be a classic theme, in which case we use the fallback layout. 15645 const blockListLayout = postContentAttributes ? postContentLayout : fallbackLayout; 15646 const postEditorLayout = blockListLayout?.type === 'default' && !hasPostContentAtRootLevel ? fallbackLayout : blockListLayout; 15647 const observeTypingRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseTypingObserver)(); 15648 const titleRef = (0,external_wp_element_namespaceObject.useRef)(); 15649 (0,external_wp_element_namespaceObject.useEffect)(() => { 15650 if (!autoFocus || !isCleanNewPost()) { 15651 return; 15652 } 15653 titleRef?.current?.focus(); 15654 }, [autoFocus, isCleanNewPost]); 15655 15656 // Add some styles for alignwide/alignfull Post Content and its children. 15657 const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;} 15658 .is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);} 15659 .is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;} 15660 .is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`; 15661 const localRef = (0,external_wp_element_namespaceObject.useRef)(); 15662 const typewriterRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseTypewriter)(); 15663 const contentRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([localRef, renderingMode === 'post-only' ? typewriterRef : editor_canvas_noop, useFlashEditableBlocks({ 15664 isEnabled: renderingMode === 'template-locked' 15665 })]); 15666 return (0,external_React_.createElement)(BlockCanvas, { 15667 shouldIframe: !disableIframe || ['Tablet', 'Mobile'].includes(deviceType), 15668 contentRef: contentRef, 15669 styles: styles, 15670 height: "100%", 15671 iframeProps: { 15672 className: classnames_default()('editor-canvas__iframe', { 15673 'has-editor-padding': showEditorPadding 15674 }), 15675 ...iframeProps, 15676 style: { 15677 ...iframeProps?.style, 15678 ...deviceStyles 15679 } 15680 } 15681 }, themeSupportsLayout && !themeHasDisabledLayoutStyles && renderingMode === 'post-only' && !isDesignPostType && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(LayoutStyle, { 15682 selector: ".editor-editor-canvas__post-title-wrapper", 15683 layout: fallbackLayout 15684 }), (0,external_React_.createElement)(LayoutStyle, { 15685 selector: ".block-editor-block-list__layout.is-root-container", 15686 layout: postEditorLayout 15687 }), align && (0,external_React_.createElement)(LayoutStyle, { 15688 css: alignCSS 15689 }), postContentLayoutStyles && (0,external_React_.createElement)(LayoutStyle, { 15690 layout: postContentLayout, 15691 css: postContentLayoutStyles 15692 })), renderingMode === 'post-only' && !isDesignPostType && (0,external_React_.createElement)("div", { 15693 className: classnames_default()('editor-editor-canvas__post-title-wrapper', 15694 // The following class is only here for backward comapatibility 15695 // some themes might be using it to style the post title. 15696 'edit-post-visual-editor__post-title-wrapper', { 15697 'has-global-padding': hasRootPaddingAwareAlignments 15698 }), 15699 contentEditable: false, 15700 ref: observeTypingRef, 15701 style: { 15702 // This is using inline styles 15703 // so it's applied for both iframed and non iframed editors. 15704 marginTop: '4rem' 15705 } 15706 }, (0,external_React_.createElement)(post_title, { 15707 ref: titleRef 15708 })), (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.RecursionProvider, { 15709 blockName: wrapperBlockName, 15710 uniqueId: wrapperUniqueId 15711 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockList, { 15712 className: classnames_default()(className, '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. 15713 ), 15714 layout: blockListLayout, 15715 dropZoneElement: 15716 // When iframed, pass in the html element of the iframe to 15717 // ensure the drop zone extends to the edges of the iframe. 15718 disableIframe ? localRef.current : localRef.current?.parentNode, 15719 renderAppender: renderAppender, 15720 __unstableDisableDropZone: 15721 // In template preview mode, disable drop zones at the root of the template. 15722 renderingMode === 'template-locked' ? true : false 15723 }), renderingMode === 'template-locked' && (0,external_React_.createElement)(EditTemplateBlocksNotification, { 15724 contentRef: localRef 15725 })), children); 15726 } 15727 /* harmony default export */ const editor_canvas = (EditorCanvas); 15728 15729 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/preferences-modal/enable-panel.js 15730 /** 15731 * WordPress dependencies 15732 */ 15733 15734 15735 15736 15737 /** 15738 * Internal dependencies 15739 */ 15740 15741 15742 const { 15743 PreferenceBaseOption 15744 } = unlock(external_wp_preferences_namespaceObject.privateApis); 15745 /* harmony default export */ const enable_panel = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, { 15746 panelName 15747 }) => { 15748 const { 15749 isEditorPanelEnabled, 15750 isEditorPanelRemoved 15751 } = select(store_store); 15752 return { 15753 isRemoved: isEditorPanelRemoved(panelName), 15754 isChecked: isEditorPanelEnabled(panelName) 15755 }; 15756 }), (0,external_wp_compose_namespaceObject.ifCondition)(({ 15757 isRemoved 15758 }) => !isRemoved), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, { 15759 panelName 15760 }) => ({ 15761 onChange: () => dispatch(store_store).toggleEditorPanelEnabled(panelName) 15762 })))(PreferenceBaseOption)); 15763 15764 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js 15765 15766 /** 15767 * WordPress dependencies 15768 */ 15769 15770 15771 /** 15772 * Internal dependencies 15773 */ 15774 15775 const { 15776 Fill: enable_plugin_document_setting_panel_Fill, 15777 Slot: enable_plugin_document_setting_panel_Slot 15778 } = (0,external_wp_components_namespaceObject.createSlotFill)('EnablePluginDocumentSettingPanelOption'); 15779 const EnablePluginDocumentSettingPanelOption = ({ 15780 label, 15781 panelName 15782 }) => (0,external_React_.createElement)(enable_plugin_document_setting_panel_Fill, null, (0,external_React_.createElement)(enable_panel, { 15783 label: label, 15784 panelName: panelName 15785 })); 15786 EnablePluginDocumentSettingPanelOption.Slot = enable_plugin_document_setting_panel_Slot; 15787 /* harmony default export */ const enable_plugin_document_setting_panel = (EnablePluginDocumentSettingPanelOption); 15788 15789 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plus.js 15790 15791 /** 15792 * WordPress dependencies 15793 */ 15794 15795 const plus = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 15796 xmlns: "http://www.w3.org/2000/svg", 15797 viewBox: "0 0 24 24" 15798 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 15799 d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" 15800 })); 15801 /* harmony default export */ const library_plus = (plus); 15802 15803 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/list-view.js 15804 15805 /** 15806 * WordPress dependencies 15807 */ 15808 15809 const listView = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 15810 viewBox: "0 0 24 24", 15811 xmlns: "http://www.w3.org/2000/svg" 15812 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 15813 d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z" 15814 })); 15815 /* harmony default export */ const list_view = (listView); 15816 15817 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/document-tools/index.js 15818 15819 /** 15820 * External dependencies 15821 */ 15822 15823 15824 /** 15825 * WordPress dependencies 15826 */ 15827 15828 15829 15830 15831 15832 15833 15834 15835 15836 15837 /** 15838 * Internal dependencies 15839 */ 15840 15841 15842 15843 15844 const { 15845 useCanBlockToolbarBeFocused 15846 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 15847 const preventDefault = event => { 15848 event.preventDefault(); 15849 }; 15850 function DocumentTools({ 15851 className, 15852 disableBlockTools = false, 15853 children, 15854 // This is a temporary prop until the list view is fully unified between post and site editors. 15855 listViewLabel = (0,external_wp_i18n_namespaceObject.__)('Document Overview') 15856 }) { 15857 const inserterButton = (0,external_wp_element_namespaceObject.useRef)(); 15858 const { 15859 setIsInserterOpened, 15860 setIsListViewOpened 15861 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 15862 const { 15863 isDistractionFree, 15864 isInserterOpened, 15865 isListViewOpen, 15866 listViewShortcut, 15867 listViewToggleRef, 15868 hasFixedToolbar, 15869 showIconLabels 15870 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 15871 const { 15872 getSettings 15873 } = select(external_wp_blockEditor_namespaceObject.store); 15874 const { 15875 get 15876 } = select(external_wp_preferences_namespaceObject.store); 15877 const { 15878 isListViewOpened, 15879 getListViewToggleRef 15880 } = unlock(select(store_store)); 15881 const { 15882 getShortcutRepresentation 15883 } = select(external_wp_keyboardShortcuts_namespaceObject.store); 15884 return { 15885 isInserterOpened: select(store_store).isInserterOpened(), 15886 isListViewOpen: isListViewOpened(), 15887 listViewShortcut: getShortcutRepresentation('core/editor/toggle-list-view'), 15888 listViewToggleRef: getListViewToggleRef(), 15889 hasFixedToolbar: getSettings().hasFixedToolbar, 15890 showIconLabels: get('core', 'showIconLabels'), 15891 isDistractionFree: get('core', 'distractionFree') 15892 }; 15893 }, []); 15894 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); 15895 const isWideViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('wide'); 15896 const blockToolbarCanBeFocused = useCanBlockToolbarBeFocused(); 15897 15898 /* translators: accessibility text for the editor toolbar */ 15899 const toolbarAriaLabel = (0,external_wp_i18n_namespaceObject.__)('Document tools'); 15900 const toggleListView = (0,external_wp_element_namespaceObject.useCallback)(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]); 15901 const toggleInserter = (0,external_wp_element_namespaceObject.useCallback)(() => { 15902 if (isInserterOpened) { 15903 // Focusing the inserter button should close the inserter popover. 15904 // However, there are some cases it won't close when the focus is lost. 15905 // See https://github.com/WordPress/gutenberg/issues/43090 for more details. 15906 inserterButton.current.focus(); 15907 setIsInserterOpened(false); 15908 } else { 15909 setIsInserterOpened(true); 15910 } 15911 }, [isInserterOpened, setIsInserterOpened]); 15912 15913 /* translators: button label text should, if possible, be under 16 characters. */ 15914 const longLabel = (0,external_wp_i18n_namespaceObject._x)('Toggle block inserter', 'Generic label for block inserter button'); 15915 const shortLabel = !isInserterOpened ? (0,external_wp_i18n_namespaceObject.__)('Add') : (0,external_wp_i18n_namespaceObject.__)('Close'); 15916 return ( 15917 // Some plugins expect and use the `edit-post-header-toolbar` CSS class to 15918 // find the toolbar and inject UI elements into it. This is not officially 15919 // supported, but we're keeping it in the list of class names for backwards 15920 // compatibility. 15921 (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.NavigableToolbar, { 15922 className: classnames_default()('editor-document-tools', 'edit-post-header-toolbar', className), 15923 "aria-label": toolbarAriaLabel, 15924 shouldUseKeyboardFocusShortcut: !blockToolbarCanBeFocused, 15925 variant: "unstyled" 15926 }, (0,external_React_.createElement)("div", { 15927 className: "editor-document-tools__left" 15928 }, !isDistractionFree && (0,external_React_.createElement)(external_wp_components_namespaceObject.ToolbarItem, { 15929 ref: inserterButton, 15930 as: external_wp_components_namespaceObject.Button, 15931 className: "editor-document-tools__inserter-toggle", 15932 variant: "primary", 15933 isPressed: isInserterOpened, 15934 onMouseDown: preventDefault, 15935 onClick: toggleInserter, 15936 disabled: disableBlockTools, 15937 icon: library_plus, 15938 label: showIconLabels ? shortLabel : longLabel, 15939 showTooltip: !showIconLabels, 15940 "aria-expanded": isInserterOpened 15941 }), (isWideViewport || !showIconLabels) && (0,external_React_.createElement)(external_React_.Fragment, null, isLargeViewport && !hasFixedToolbar && (0,external_React_.createElement)(external_wp_components_namespaceObject.ToolbarItem, { 15942 as: external_wp_blockEditor_namespaceObject.ToolSelector, 15943 showTooltip: !showIconLabels, 15944 variant: showIconLabels ? 'tertiary' : undefined, 15945 disabled: disableBlockTools, 15946 size: "compact" 15947 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.ToolbarItem, { 15948 as: editor_history_undo, 15949 showTooltip: !showIconLabels, 15950 variant: showIconLabels ? 'tertiary' : undefined, 15951 size: "compact" 15952 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.ToolbarItem, { 15953 as: editor_history_redo, 15954 showTooltip: !showIconLabels, 15955 variant: showIconLabels ? 'tertiary' : undefined, 15956 size: "compact" 15957 }), !isDistractionFree && (0,external_React_.createElement)(external_wp_components_namespaceObject.ToolbarItem, { 15958 as: external_wp_components_namespaceObject.Button, 15959 className: "editor-document-tools__document-overview-toggle", 15960 icon: list_view, 15961 disabled: disableBlockTools, 15962 isPressed: isListViewOpen 15963 /* translators: button label text should, if possible, be under 16 characters. */, 15964 label: listViewLabel, 15965 onClick: toggleListView, 15966 shortcut: listViewShortcut, 15967 showTooltip: !showIconLabels, 15968 variant: showIconLabels ? 'tertiary' : undefined, 15969 "aria-expanded": isListViewOpen, 15970 ref: listViewToggleRef, 15971 size: "compact" 15972 })), children)) 15973 ); 15974 } 15975 /* harmony default export */ const document_tools = (DocumentTools); 15976 15977 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close.js 15978 15979 /** 15980 * WordPress dependencies 15981 */ 15982 15983 const close_close = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 15984 xmlns: "http://www.w3.org/2000/svg", 15985 viewBox: "0 0 24 24" 15986 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 15987 d: "M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z" 15988 })); 15989 /* harmony default export */ const library_close = (close_close); 15990 15991 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/inserter-sidebar/index.js 15992 15993 /** 15994 * WordPress dependencies 15995 */ 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 /** 16006 * Internal dependencies 16007 */ 16008 16009 16010 function InserterSidebar() { 16011 const { 16012 insertionPoint, 16013 showMostUsedBlocks 16014 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 16015 const { 16016 getInsertionPoint 16017 } = unlock(select(store_store)); 16018 const { 16019 get 16020 } = select(external_wp_preferences_namespaceObject.store); 16021 return { 16022 insertionPoint: getInsertionPoint(), 16023 showMostUsedBlocks: get('core', 'mostUsedBlocks') 16024 }; 16025 }, []); 16026 const { 16027 setIsInserterOpened 16028 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 16029 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); 16030 const TagName = !isMobileViewport ? external_wp_components_namespaceObject.VisuallyHidden : 'div'; 16031 const [inserterDialogRef, inserterDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({ 16032 onClose: () => setIsInserterOpened(false), 16033 focusOnMount: null 16034 }); 16035 const libraryRef = (0,external_wp_element_namespaceObject.useRef)(); 16036 (0,external_wp_element_namespaceObject.useEffect)(() => { 16037 libraryRef.current.focusSearch(); 16038 }, []); 16039 return (0,external_React_.createElement)("div", { 16040 ref: inserterDialogRef, 16041 ...inserterDialogProps, 16042 className: "editor-inserter-sidebar" 16043 }, (0,external_React_.createElement)(TagName, { 16044 className: "editor-inserter-sidebar__header" 16045 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 16046 icon: library_close, 16047 label: (0,external_wp_i18n_namespaceObject.__)('Close block inserter'), 16048 onClick: () => setIsInserterOpened(false) 16049 })), (0,external_React_.createElement)("div", { 16050 className: "editor-inserter-sidebar__content" 16051 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLibrary, { 16052 showMostUsedBlocks: showMostUsedBlocks, 16053 showInserterHelpPanel: true, 16054 shouldFocusBlock: isMobileViewport, 16055 rootClientId: insertionPoint.rootClientId, 16056 __experimentalInsertionIndex: insertionPoint.insertionIndex, 16057 __experimentalFilterValue: insertionPoint.filterValue, 16058 ref: libraryRef 16059 }))); 16060 } 16061 16062 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/list-view-sidebar/list-view-outline.js 16063 16064 /** 16065 * WordPress dependencies 16066 */ 16067 16068 16069 16070 /** 16071 * Internal dependencies 16072 */ 16073 16074 16075 16076 16077 function ListViewOutline() { 16078 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { 16079 className: "editor-list-view-sidebar__outline" 16080 }, (0,external_React_.createElement)("div", null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, (0,external_wp_i18n_namespaceObject.__)('Characters:')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, (0,external_React_.createElement)(CharacterCount, null))), (0,external_React_.createElement)("div", null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, (0,external_wp_i18n_namespaceObject.__)('Words:')), (0,external_React_.createElement)(WordCount, null)), (0,external_React_.createElement)("div", null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, (0,external_wp_i18n_namespaceObject.__)('Time to read:')), (0,external_React_.createElement)(TimeToRead, null))), (0,external_React_.createElement)(document_outline, null)); 16081 } 16082 16083 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/list-view-sidebar/index.js 16084 16085 /** 16086 * WordPress dependencies 16087 */ 16088 16089 16090 16091 16092 16093 16094 16095 16096 16097 16098 16099 /** 16100 * Internal dependencies 16101 */ 16102 16103 16104 16105 const { 16106 Tabs 16107 } = unlock(external_wp_components_namespaceObject.privateApis); 16108 function ListViewSidebar() { 16109 const { 16110 setIsListViewOpened 16111 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 16112 const { 16113 getListViewToggleRef 16114 } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store)); 16115 16116 // This hook handles focus when the sidebar first renders. 16117 const focusOnMountRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)('firstElement'); 16118 16119 // When closing the list view, focus should return to the toggle button. 16120 const closeListView = (0,external_wp_element_namespaceObject.useCallback)(() => { 16121 setIsListViewOpened(false); 16122 getListViewToggleRef().current?.focus(); 16123 }, [getListViewToggleRef, setIsListViewOpened]); 16124 const closeOnEscape = (0,external_wp_element_namespaceObject.useCallback)(event => { 16125 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) { 16126 event.preventDefault(); 16127 closeListView(); 16128 } 16129 }, [closeListView]); 16130 16131 // Use internal state instead of a ref to make sure that the component 16132 // re-renders when the dropZoneElement updates. 16133 const [dropZoneElement, setDropZoneElement] = (0,external_wp_element_namespaceObject.useState)(null); 16134 // Tracks our current tab. 16135 const [tab, setTab] = (0,external_wp_element_namespaceObject.useState)('list-view'); 16136 16137 // This ref refers to the sidebar as a whole. 16138 const sidebarRef = (0,external_wp_element_namespaceObject.useRef)(); 16139 // This ref refers to the tab panel. 16140 const tabsRef = (0,external_wp_element_namespaceObject.useRef)(); 16141 // This ref refers to the list view application area. 16142 const listViewRef = (0,external_wp_element_namespaceObject.useRef)(); 16143 16144 // Must merge the refs together so focus can be handled properly in the next function. 16145 const listViewContainerRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([focusOnMountRef, listViewRef, setDropZoneElement]); 16146 16147 /* 16148 * Callback function to handle list view or outline focus. 16149 * 16150 * @param {string} currentTab The current tab. Either list view or outline. 16151 * 16152 * @return void 16153 */ 16154 function handleSidebarFocus(currentTab) { 16155 // Tab panel focus. 16156 const tabPanelFocus = external_wp_dom_namespaceObject.focus.tabbable.find(tabsRef.current)[0]; 16157 // List view tab is selected. 16158 if (currentTab === 'list-view') { 16159 // 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. 16160 const listViewApplicationFocus = external_wp_dom_namespaceObject.focus.tabbable.find(listViewRef.current)[0]; 16161 const listViewFocusArea = sidebarRef.current.contains(listViewApplicationFocus) ? listViewApplicationFocus : tabPanelFocus; 16162 listViewFocusArea.focus(); 16163 // Outline tab is selected. 16164 } else { 16165 tabPanelFocus.focus(); 16166 } 16167 } 16168 const handleToggleListViewShortcut = (0,external_wp_element_namespaceObject.useCallback)(() => { 16169 // If the sidebar has focus, it is safe to close. 16170 if (sidebarRef.current.contains(sidebarRef.current.ownerDocument.activeElement)) { 16171 closeListView(); 16172 } else { 16173 // If the list view or outline does not have focus, focus should be moved to it. 16174 handleSidebarFocus(tab); 16175 } 16176 }, [closeListView, tab]); 16177 16178 // This only fires when the sidebar is open because of the conditional rendering. 16179 // It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed. 16180 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-list-view', handleToggleListViewShortcut); 16181 return ( 16182 // eslint-disable-next-line jsx-a11y/no-static-element-interactions 16183 (0,external_React_.createElement)("div", { 16184 className: "editor-list-view-sidebar", 16185 onKeyDown: closeOnEscape, 16186 ref: sidebarRef 16187 }, (0,external_React_.createElement)(Tabs, { 16188 onSelect: tabName => setTab(tabName), 16189 selectOnMove: false 16190 // The initial tab value is set explicitly to avoid an initial 16191 // render where no tab is selected. This ensures that the 16192 // tabpanel height is correct so the relevant scroll container 16193 // can be rendered internally. 16194 , 16195 initialTabId: "list-view" 16196 }, (0,external_React_.createElement)("div", { 16197 className: "edit-post-editor__document-overview-panel__header" 16198 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 16199 className: "editor-list-view-sidebar__close-button", 16200 icon: close_small, 16201 label: (0,external_wp_i18n_namespaceObject.__)('Close'), 16202 onClick: closeListView 16203 }), (0,external_React_.createElement)(Tabs.TabList, { 16204 className: "editor-list-view-sidebar__tabs-tablist", 16205 ref: tabsRef 16206 }, (0,external_React_.createElement)(Tabs.Tab, { 16207 className: "editor-list-view-sidebar__tabs-tab", 16208 tabId: "list-view" 16209 }, (0,external_wp_i18n_namespaceObject._x)('List View', 'Post overview')), (0,external_React_.createElement)(Tabs.Tab, { 16210 className: "editor-list-view-sidebar__tabs-tab", 16211 tabId: "outline" 16212 }, (0,external_wp_i18n_namespaceObject._x)('Outline', 'Post overview')))), (0,external_React_.createElement)(Tabs.TabPanel, { 16213 ref: listViewContainerRef, 16214 className: "editor-list-view-sidebar__tabs-tabpanel", 16215 tabId: "list-view", 16216 focusable: false 16217 }, (0,external_React_.createElement)("div", { 16218 className: "editor-list-view-sidebar__list-view-container" 16219 }, (0,external_React_.createElement)("div", { 16220 className: "editor-list-view-sidebar__list-view-panel-content" 16221 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__experimentalListView, { 16222 dropZoneElement: dropZoneElement 16223 })))), (0,external_React_.createElement)(Tabs.TabPanel, { 16224 className: "editor-list-view-sidebar__tabs-tabpanel", 16225 tabId: "outline", 16226 focusable: false 16227 }, (0,external_React_.createElement)("div", { 16228 className: "editor-list-view-sidebar__list-view-container" 16229 }, (0,external_React_.createElement)(ListViewOutline, null))))) 16230 ); 16231 } 16232 16233 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/external.js 16234 16235 /** 16236 * WordPress dependencies 16237 */ 16238 16239 const external = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 16240 xmlns: "http://www.w3.org/2000/svg", 16241 viewBox: "0 0 24 24" 16242 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 16243 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" 16244 })); 16245 /* harmony default export */ const library_external = (external); 16246 16247 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-view-link/index.js 16248 16249 /** 16250 * WordPress dependencies 16251 */ 16252 16253 16254 16255 16256 16257 16258 16259 /** 16260 * Internal dependencies 16261 */ 16262 16263 function PostViewLink() { 16264 const { 16265 hasLoaded, 16266 permalink, 16267 isPublished, 16268 label, 16269 showIconLabels 16270 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 16271 // Grab post type to retrieve the view_item label. 16272 const postTypeSlug = select(store_store).getCurrentPostType(); 16273 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug); 16274 const { 16275 get 16276 } = select(external_wp_preferences_namespaceObject.store); 16277 return { 16278 permalink: select(store_store).getPermalink(), 16279 isPublished: select(store_store).isCurrentPostPublished(), 16280 label: postType?.labels.view_item, 16281 hasLoaded: !!postType, 16282 showIconLabels: get('core', 'showIconLabels') 16283 }; 16284 }, []); 16285 16286 // Only render the view button if the post is published and has a permalink. 16287 if (!isPublished || !permalink || !hasLoaded) { 16288 return null; 16289 } 16290 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 16291 icon: library_external, 16292 label: label || (0,external_wp_i18n_namespaceObject.__)('View post'), 16293 href: permalink, 16294 target: "_blank", 16295 showTooltip: !showIconLabels 16296 }); 16297 } 16298 16299 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/mobile.js 16300 16301 /** 16302 * WordPress dependencies 16303 */ 16304 16305 const mobile = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 16306 xmlns: "http://www.w3.org/2000/svg", 16307 viewBox: "0 0 24 24" 16308 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 16309 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" 16310 })); 16311 /* harmony default export */ const library_mobile = (mobile); 16312 16313 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/tablet.js 16314 16315 /** 16316 * WordPress dependencies 16317 */ 16318 16319 const tablet = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 16320 xmlns: "http://www.w3.org/2000/svg", 16321 viewBox: "0 0 24 24" 16322 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 16323 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" 16324 })); 16325 /* harmony default export */ const library_tablet = (tablet); 16326 16327 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/desktop.js 16328 16329 /** 16330 * WordPress dependencies 16331 */ 16332 16333 const desktop = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 16334 xmlns: "http://www.w3.org/2000/svg", 16335 viewBox: "0 0 24 24" 16336 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 16337 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" 16338 })); 16339 /* harmony default export */ const library_desktop = (desktop); 16340 16341 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/preview-dropdown/index.js 16342 16343 /** 16344 * WordPress dependencies 16345 */ 16346 16347 16348 16349 16350 16351 16352 16353 16354 /** 16355 * Internal dependencies 16356 */ 16357 16358 16359 function PreviewDropdown({ 16360 forceIsAutosaveable, 16361 disabled 16362 }) { 16363 const { 16364 deviceType, 16365 homeUrl, 16366 isTemplate, 16367 isViewable, 16368 showIconLabels 16369 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 16370 var _getPostType$viewable; 16371 const { 16372 getDeviceType, 16373 getCurrentPostType 16374 } = select(store_store); 16375 const { 16376 getUnstableBase, 16377 getPostType 16378 } = select(external_wp_coreData_namespaceObject.store); 16379 const { 16380 get 16381 } = select(external_wp_preferences_namespaceObject.store); 16382 const _currentPostType = getCurrentPostType(); 16383 return { 16384 deviceType: getDeviceType(), 16385 homeUrl: getUnstableBase()?.home, 16386 isTemplate: _currentPostType === 'wp_template', 16387 isViewable: (_getPostType$viewable = getPostType(_currentPostType)?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false, 16388 showIconLabels: get('core', 'showIconLabels') 16389 }; 16390 }, []); 16391 const { 16392 setDeviceType 16393 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 16394 const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); 16395 if (isMobile) return null; 16396 const popoverProps = { 16397 placement: 'bottom-end' 16398 }; 16399 const toggleProps = { 16400 className: 'editor-preview-dropdown__toggle', 16401 size: 'compact', 16402 showTooltip: !showIconLabels, 16403 disabled, 16404 __experimentalIsFocusable: disabled 16405 }; 16406 const menuProps = { 16407 'aria-label': (0,external_wp_i18n_namespaceObject.__)('View options') 16408 }; 16409 const deviceIcons = { 16410 mobile: library_mobile, 16411 tablet: library_tablet, 16412 desktop: library_desktop 16413 }; 16414 return (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 16415 className: "editor-preview-dropdown", 16416 popoverProps: popoverProps, 16417 toggleProps: toggleProps, 16418 menuProps: menuProps, 16419 icon: deviceIcons[deviceType.toLowerCase()], 16420 label: (0,external_wp_i18n_namespaceObject.__)('View'), 16421 disableOpenOnArrowDown: disabled 16422 }, ({ 16423 onClose 16424 }) => (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 16425 onClick: () => setDeviceType('Desktop'), 16426 icon: deviceType === 'Desktop' && library_check 16427 }, (0,external_wp_i18n_namespaceObject.__)('Desktop')), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 16428 onClick: () => setDeviceType('Tablet'), 16429 icon: deviceType === 'Tablet' && library_check 16430 }, (0,external_wp_i18n_namespaceObject.__)('Tablet')), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 16431 onClick: () => setDeviceType('Mobile'), 16432 icon: deviceType === 'Mobile' && library_check 16433 }, (0,external_wp_i18n_namespaceObject.__)('Mobile'))), isTemplate && (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 16434 href: homeUrl, 16435 target: "_blank", 16436 icon: library_external, 16437 onClick: onClose 16438 }, (0,external_wp_i18n_namespaceObject.__)('View site'), (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 16439 as: "span" 16440 }, /* translators: accessibility text */ 16441 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')))), isViewable && (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(PostPreviewButton, { 16442 className: "editor-preview-dropdown__button-external", 16443 role: "menuitem", 16444 forceIsAutosaveable: forceIsAutosaveable, 16445 textContent: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Preview in new tab'), (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 16446 icon: library_external 16447 })), 16448 onPreview: onClose 16449 })))); 16450 } 16451 16452 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/block-manager/checklist.js 16453 16454 /** 16455 * WordPress dependencies 16456 */ 16457 16458 16459 function BlockTypesChecklist({ 16460 blockTypes, 16461 value, 16462 onItemChange 16463 }) { 16464 return (0,external_React_.createElement)("ul", { 16465 className: "editor-block-manager__checklist" 16466 }, blockTypes.map(blockType => (0,external_React_.createElement)("li", { 16467 key: blockType.name, 16468 className: "editor-block-manager__checklist-item" 16469 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 16470 __nextHasNoMarginBottom: true, 16471 label: blockType.title, 16472 checked: value.includes(blockType.name), 16473 onChange: (...args) => onItemChange(blockType.name, ...args) 16474 }), (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, { 16475 icon: blockType.icon 16476 })))); 16477 } 16478 /* harmony default export */ const checklist = (BlockTypesChecklist); 16479 16480 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/block-manager/category.js 16481 16482 /** 16483 * WordPress dependencies 16484 */ 16485 16486 16487 16488 16489 16490 16491 /** 16492 * Internal dependencies 16493 */ 16494 16495 16496 16497 function BlockManagerCategory({ 16498 title, 16499 blockTypes 16500 }) { 16501 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockManagerCategory); 16502 const { 16503 allowedBlockTypes, 16504 hiddenBlockTypes 16505 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 16506 const { 16507 getEditorSettings 16508 } = select(store_store); 16509 const { 16510 get 16511 } = select(external_wp_preferences_namespaceObject.store); 16512 return { 16513 allowedBlockTypes: getEditorSettings().allowedBlockTypes, 16514 hiddenBlockTypes: get('core', 'hiddenBlockTypes') 16515 }; 16516 }, []); 16517 const filteredBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => { 16518 if (allowedBlockTypes === true) { 16519 return blockTypes; 16520 } 16521 return blockTypes.filter(({ 16522 name 16523 }) => { 16524 return allowedBlockTypes?.includes(name); 16525 }); 16526 }, [allowedBlockTypes, blockTypes]); 16527 const { 16528 showBlockTypes, 16529 hideBlockTypes 16530 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 16531 const toggleVisible = (0,external_wp_element_namespaceObject.useCallback)((blockName, nextIsChecked) => { 16532 if (nextIsChecked) { 16533 showBlockTypes(blockName); 16534 } else { 16535 hideBlockTypes(blockName); 16536 } 16537 }, [showBlockTypes, hideBlockTypes]); 16538 const toggleAllVisible = (0,external_wp_element_namespaceObject.useCallback)(nextIsChecked => { 16539 const blockNames = blockTypes.map(({ 16540 name 16541 }) => name); 16542 if (nextIsChecked) { 16543 showBlockTypes(blockNames); 16544 } else { 16545 hideBlockTypes(blockNames); 16546 } 16547 }, [blockTypes, showBlockTypes, hideBlockTypes]); 16548 if (!filteredBlockTypes.length) { 16549 return null; 16550 } 16551 const checkedBlockNames = filteredBlockTypes.map(({ 16552 name 16553 }) => name).filter(type => !(hiddenBlockTypes !== null && hiddenBlockTypes !== void 0 ? hiddenBlockTypes : []).includes(type)); 16554 const titleId = 'editor-block-manager__category-title-' + instanceId; 16555 const isAllChecked = checkedBlockNames.length === filteredBlockTypes.length; 16556 const isIndeterminate = !isAllChecked && checkedBlockNames.length > 0; 16557 return (0,external_React_.createElement)("div", { 16558 role: "group", 16559 "aria-labelledby": titleId, 16560 className: "editor-block-manager__category" 16561 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 16562 __nextHasNoMarginBottom: true, 16563 checked: isAllChecked, 16564 onChange: toggleAllVisible, 16565 className: "editor-block-manager__category-title", 16566 indeterminate: isIndeterminate, 16567 label: (0,external_React_.createElement)("span", { 16568 id: titleId 16569 }, title) 16570 }), (0,external_React_.createElement)(checklist, { 16571 blockTypes: filteredBlockTypes, 16572 value: checkedBlockNames, 16573 onItemChange: toggleVisible 16574 })); 16575 } 16576 /* harmony default export */ const block_manager_category = (BlockManagerCategory); 16577 16578 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/block-manager/index.js 16579 16580 /** 16581 * WordPress dependencies 16582 */ 16583 16584 16585 16586 16587 16588 16589 16590 16591 16592 /** 16593 * Internal dependencies 16594 */ 16595 16596 16597 16598 function BlockManager({ 16599 blockTypes, 16600 categories, 16601 hasBlockSupport, 16602 isMatchingSearchTerm, 16603 numberOfHiddenBlocks, 16604 enableAllBlockTypes 16605 }) { 16606 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500); 16607 const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)(''); 16608 16609 // Filtering occurs here (as opposed to `withSelect`) to avoid 16610 // wasted renders by consequence of `Array#filter` producing 16611 // a new value reference on each call. 16612 blockTypes = blockTypes.filter(blockType => hasBlockSupport(blockType, 'inserter', true) && (!search || isMatchingSearchTerm(blockType, search)) && (!blockType.parent || blockType.parent.includes('core/post-content'))); 16613 16614 // Announce search results on change 16615 (0,external_wp_element_namespaceObject.useEffect)(() => { 16616 if (!search) { 16617 return; 16618 } 16619 const count = blockTypes.length; 16620 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of results. */ 16621 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count); 16622 debouncedSpeak(resultsFoundMessage); 16623 }, [blockTypes.length, search, debouncedSpeak]); 16624 return (0,external_React_.createElement)("div", { 16625 className: "editor-block-manager__content" 16626 }, !!numberOfHiddenBlocks && (0,external_React_.createElement)("div", { 16627 className: "editor-block-manager__disabled-blocks-count" 16628 }, (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of blocks. */ 16629 (0,external_wp_i18n_namespaceObject._n)('%d block is hidden.', '%d blocks are hidden.', numberOfHiddenBlocks), numberOfHiddenBlocks), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 16630 variant: "link", 16631 onClick: () => enableAllBlockTypes(blockTypes) 16632 }, (0,external_wp_i18n_namespaceObject.__)('Reset'))), (0,external_React_.createElement)(external_wp_components_namespaceObject.SearchControl, { 16633 __nextHasNoMarginBottom: true, 16634 label: (0,external_wp_i18n_namespaceObject.__)('Search for a block'), 16635 placeholder: (0,external_wp_i18n_namespaceObject.__)('Search for a block'), 16636 value: search, 16637 onChange: nextSearch => setSearch(nextSearch), 16638 className: "editor-block-manager__search" 16639 }), (0,external_React_.createElement)("div", { 16640 tabIndex: "0", 16641 role: "region", 16642 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Available block types'), 16643 className: "editor-block-manager__results" 16644 }, blockTypes.length === 0 && (0,external_React_.createElement)("p", { 16645 className: "editor-block-manager__no-results" 16646 }, (0,external_wp_i18n_namespaceObject.__)('No blocks found.')), categories.map(category => (0,external_React_.createElement)(block_manager_category, { 16647 key: category.slug, 16648 title: category.title, 16649 blockTypes: blockTypes.filter(blockType => blockType.category === category.slug) 16650 })), (0,external_React_.createElement)(block_manager_category, { 16651 title: (0,external_wp_i18n_namespaceObject.__)('Uncategorized'), 16652 blockTypes: blockTypes.filter(({ 16653 category 16654 }) => !category) 16655 }))); 16656 } 16657 /* harmony default export */ const block_manager = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => { 16658 var _get; 16659 const { 16660 getBlockTypes, 16661 getCategories, 16662 hasBlockSupport, 16663 isMatchingSearchTerm 16664 } = select(external_wp_blocks_namespaceObject.store); 16665 const { 16666 get 16667 } = select(external_wp_preferences_namespaceObject.store); 16668 16669 // Some hidden blocks become unregistered 16670 // by removing for instance the plugin that registered them, yet 16671 // they're still remain as hidden by the user's action. 16672 // We consider "hidden", blocks which were hidden and 16673 // are still registered. 16674 const blockTypes = getBlockTypes(); 16675 const hiddenBlockTypes = ((_get = get('core', 'hiddenBlockTypes')) !== null && _get !== void 0 ? _get : []).filter(hiddenBlock => { 16676 return blockTypes.some(registeredBlock => registeredBlock.name === hiddenBlock); 16677 }); 16678 const numberOfHiddenBlocks = Array.isArray(hiddenBlockTypes) && hiddenBlockTypes.length; 16679 return { 16680 blockTypes, 16681 categories: getCategories(), 16682 hasBlockSupport, 16683 isMatchingSearchTerm, 16684 numberOfHiddenBlocks 16685 }; 16686 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => { 16687 const { 16688 showBlockTypes 16689 } = unlock(dispatch(store_store)); 16690 return { 16691 enableAllBlockTypes: blockTypes => { 16692 const blockNames = blockTypes.map(({ 16693 name 16694 }) => name); 16695 showBlockTypes(blockNames); 16696 } 16697 }; 16698 })])(BlockManager)); 16699 16700 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/preferences-modal/index.js 16701 16702 /** 16703 * WordPress dependencies 16704 */ 16705 16706 16707 16708 16709 16710 16711 16712 /** 16713 * Internal dependencies 16714 */ 16715 16716 16717 16718 16719 16720 16721 16722 16723 16724 16725 const { 16726 PreferencesModal, 16727 PreferencesModalTabs, 16728 PreferencesModalSection, 16729 PreferenceToggleControl 16730 } = unlock(external_wp_preferences_namespaceObject.privateApis); 16731 function EditorPreferencesModal({ 16732 extraSections = {}, 16733 isActive, 16734 onClose 16735 }) { 16736 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); 16737 const { 16738 showBlockBreadcrumbsOption 16739 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 16740 const { 16741 getEditorSettings 16742 } = select(store_store); 16743 const { 16744 get 16745 } = select(external_wp_preferences_namespaceObject.store); 16746 const isRichEditingEnabled = getEditorSettings().richEditingEnabled; 16747 const isDistractionFreeEnabled = get('core', 'distractionFree'); 16748 return { 16749 showBlockBreadcrumbsOption: !isDistractionFreeEnabled && isLargeViewport && isRichEditingEnabled 16750 }; 16751 }, [isLargeViewport]); 16752 const { 16753 setIsListViewOpened, 16754 setIsInserterOpened 16755 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 16756 const { 16757 set: setPreference 16758 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); 16759 const toggleDistractionFree = () => { 16760 setPreference('core', 'fixedToolbar', true); 16761 setIsInserterOpened(false); 16762 setIsListViewOpened(false); 16763 // Todo: Check sidebar when closing/opening distraction free. 16764 }; 16765 const turnOffDistractionFree = () => { 16766 setPreference('core', 'distractionFree', false); 16767 }; 16768 const sections = (0,external_wp_element_namespaceObject.useMemo)(() => [{ 16769 name: 'general', 16770 tabLabel: (0,external_wp_i18n_namespaceObject.__)('General'), 16771 content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(PreferencesModalSection, { 16772 title: (0,external_wp_i18n_namespaceObject.__)('Interface') 16773 }, (0,external_React_.createElement)(PreferenceToggleControl, { 16774 scope: "core", 16775 featureName: "showListViewByDefault", 16776 help: (0,external_wp_i18n_namespaceObject.__)('Opens the block list view sidebar by default.'), 16777 label: (0,external_wp_i18n_namespaceObject.__)('Always open list view') 16778 }), showBlockBreadcrumbsOption && (0,external_React_.createElement)(PreferenceToggleControl, { 16779 scope: "core", 16780 featureName: "showBlockBreadcrumbs", 16781 help: (0,external_wp_i18n_namespaceObject.__)('Display the block hierarchy trail at the bottom of the editor.'), 16782 label: (0,external_wp_i18n_namespaceObject.__)('Show block breadcrumbs') 16783 }), (0,external_React_.createElement)(PreferenceToggleControl, { 16784 scope: "core", 16785 featureName: "allowRightClickOverrides", 16786 help: (0,external_wp_i18n_namespaceObject.__)('Allows contextual list view menus via right-click, overriding browser defaults.'), 16787 label: (0,external_wp_i18n_namespaceObject.__)('Allow right-click contextual menus') 16788 })), (0,external_React_.createElement)(PreferencesModalSection, { 16789 title: (0,external_wp_i18n_namespaceObject.__)('Document settings'), 16790 description: (0,external_wp_i18n_namespaceObject.__)('Select what settings are shown in the document panel.') 16791 }, (0,external_React_.createElement)(enable_plugin_document_setting_panel.Slot, null), (0,external_React_.createElement)(post_taxonomies, { 16792 taxonomyWrapper: (content, taxonomy) => (0,external_React_.createElement)(enable_panel, { 16793 label: taxonomy.labels.menu_name, 16794 panelName: `taxonomy-panel-$taxonomy.slug}` 16795 }) 16796 }), (0,external_React_.createElement)(post_featured_image_check, null, (0,external_React_.createElement)(enable_panel, { 16797 label: (0,external_wp_i18n_namespaceObject.__)('Featured image'), 16798 panelName: "featured-image" 16799 })), (0,external_React_.createElement)(post_excerpt_check, null, (0,external_React_.createElement)(enable_panel, { 16800 label: (0,external_wp_i18n_namespaceObject.__)('Excerpt'), 16801 panelName: "post-excerpt" 16802 })), (0,external_React_.createElement)(post_type_support_check, { 16803 supportKeys: ['comments', 'trackbacks'] 16804 }, (0,external_React_.createElement)(enable_panel, { 16805 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'), 16806 panelName: "discussion-panel" 16807 })), (0,external_React_.createElement)(page_attributes_check, null, (0,external_React_.createElement)(enable_panel, { 16808 label: (0,external_wp_i18n_namespaceObject.__)('Page attributes'), 16809 panelName: "page-attributes" 16810 }))), extraSections?.general) 16811 }, { 16812 name: 'appearance', 16813 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Appearance'), 16814 content: (0,external_React_.createElement)(PreferencesModalSection, { 16815 title: (0,external_wp_i18n_namespaceObject.__)('Appearance'), 16816 description: (0,external_wp_i18n_namespaceObject.__)('Customize the editor interface to suit your needs.') 16817 }, (0,external_React_.createElement)(PreferenceToggleControl, { 16818 scope: "core", 16819 featureName: "fixedToolbar", 16820 onToggle: turnOffDistractionFree, 16821 help: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place.'), 16822 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar') 16823 }), (0,external_React_.createElement)(PreferenceToggleControl, { 16824 scope: "core", 16825 featureName: "distractionFree", 16826 onToggle: toggleDistractionFree, 16827 help: (0,external_wp_i18n_namespaceObject.__)('Reduce visual distractions by hiding the toolbar and other elements to focus on writing.'), 16828 label: (0,external_wp_i18n_namespaceObject.__)('Distraction free') 16829 }), (0,external_React_.createElement)(PreferenceToggleControl, { 16830 scope: "core", 16831 featureName: "focusMode", 16832 help: (0,external_wp_i18n_namespaceObject.__)('Highlights the current block and fades other content.'), 16833 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode') 16834 }), extraSections?.appearance) 16835 }, { 16836 name: 'accessibility', 16837 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Accessibility'), 16838 content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(PreferencesModalSection, { 16839 title: (0,external_wp_i18n_namespaceObject.__)('Navigation'), 16840 description: (0,external_wp_i18n_namespaceObject.__)('Optimize the editing experience for enhanced control.') 16841 }, (0,external_React_.createElement)(PreferenceToggleControl, { 16842 scope: "core", 16843 featureName: "keepCaretInsideBlock", 16844 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.'), 16845 label: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block') 16846 })), (0,external_React_.createElement)(PreferencesModalSection, { 16847 title: (0,external_wp_i18n_namespaceObject.__)('Interface') 16848 }, (0,external_React_.createElement)(PreferenceToggleControl, { 16849 scope: "core", 16850 featureName: "showIconLabels", 16851 label: (0,external_wp_i18n_namespaceObject.__)('Show button text labels'), 16852 help: (0,external_wp_i18n_namespaceObject.__)('Show text instead of icons on buttons across the interface.') 16853 }))) 16854 }, { 16855 name: 'blocks', 16856 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Blocks'), 16857 content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(PreferencesModalSection, { 16858 title: (0,external_wp_i18n_namespaceObject.__)('Inserter') 16859 }, (0,external_React_.createElement)(PreferenceToggleControl, { 16860 scope: "core", 16861 featureName: "mostUsedBlocks", 16862 help: (0,external_wp_i18n_namespaceObject.__)('Adds a category with the most frequently used blocks in the inserter.'), 16863 label: (0,external_wp_i18n_namespaceObject.__)('Show most used blocks') 16864 })), (0,external_React_.createElement)(PreferencesModalSection, { 16865 title: (0,external_wp_i18n_namespaceObject.__)('Manage block visibility'), 16866 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.") 16867 }, (0,external_React_.createElement)(block_manager, null))) 16868 }], [isLargeViewport, showBlockBreadcrumbsOption, extraSections]); 16869 if (!isActive) { 16870 return null; 16871 } 16872 return (0,external_React_.createElement)(PreferencesModal, { 16873 closeModal: onClose 16874 }, (0,external_React_.createElement)(PreferencesModalTabs, { 16875 sections: sections 16876 })); 16877 } 16878 16879 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/private-apis.js 16880 /** 16881 * Internal dependencies 16882 */ 16883 16884 16885 16886 16887 16888 16889 16890 16891 16892 16893 16894 16895 16896 16897 const privateApis = {}; 16898 lock(privateApis, { 16899 DocumentTools: document_tools, 16900 EditorCanvas: editor_canvas, 16901 ExperimentalEditorProvider: ExperimentalEditorProvider, 16902 EnablePluginDocumentSettingPanelOption: enable_plugin_document_setting_panel, 16903 EntitiesSavedStatesExtensible: EntitiesSavedStatesExtensible, 16904 InserterSidebar: InserterSidebar, 16905 ListViewSidebar: ListViewSidebar, 16906 PluginPostExcerpt: post_excerpt_plugin, 16907 PostPanelRow: post_panel_row, 16908 PostViewLink: PostViewLink, 16909 PreviewDropdown: PreviewDropdown, 16910 PreferencesModal: EditorPreferencesModal, 16911 // This is a temporary private API while we're updating the site editor to use EditorProvider. 16912 useBlockEditorSettings: use_block_editor_settings 16913 }); 16914 16915 ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/index.js 16916 /** 16917 * Internal dependencies 16918 */ 16919 16920 16921 16922 16923 16924 16925 16926 /* 16927 * Backward compatibility 16928 */ 16929 16930 16931 })(); 16932 16933 (window.wp = window.wp || {}).editor = __webpack_exports__; 16934 /******/ })() 16935 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Thu May 9 08:20:02 2024 | Cross-referenced by PHPXref |