[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 /******/ (function() { // webpackBootstrap 2 /******/ var __webpack_modules__ = ({ 3 4 /***/ 6411: 5 /***/ (function(module, exports) { 6 7 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 8 autosize 4.0.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 /***/ 4403: 294 /***/ (function(module, exports) { 295 296 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 297 Copyright (c) 2018 Jed Watson. 298 Licensed under the MIT License (MIT), see 299 http://jedwatson.github.io/classnames 300 */ 301 /* global define */ 302 303 (function () { 304 'use strict'; 305 306 var hasOwn = {}.hasOwnProperty; 307 308 function classNames() { 309 var classes = []; 310 311 for (var i = 0; i < arguments.length; i++) { 312 var arg = arguments[i]; 313 if (!arg) continue; 314 315 var argType = typeof arg; 316 317 if (argType === 'string' || argType === 'number') { 318 classes.push(arg); 319 } else if (Array.isArray(arg)) { 320 if (arg.length) { 321 var inner = classNames.apply(null, arg); 322 if (inner) { 323 classes.push(inner); 324 } 325 } 326 } else if (argType === 'object') { 327 if (arg.toString === Object.prototype.toString) { 328 for (var key in arg) { 329 if (hasOwn.call(arg, key) && arg[key]) { 330 classes.push(key); 331 } 332 } 333 } else { 334 classes.push(arg.toString()); 335 } 336 } 337 } 338 339 return classes.join(' '); 340 } 341 342 if ( true && module.exports) { 343 classNames.default = classNames; 344 module.exports = classNames; 345 } else if (true) { 346 // register as 'classnames', consistent with npm package name 347 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { 348 return classNames; 349 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), 350 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 351 } else {} 352 }()); 353 354 355 /***/ }), 356 357 /***/ 4827: 358 /***/ (function(module) { 359 360 // This code has been refactored for 140 bytes 361 // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js 362 var computedStyle = function (el, prop, getComputedStyle) { 363 getComputedStyle = window.getComputedStyle; 364 365 // In one fell swoop 366 return ( 367 // If we have getComputedStyle 368 getComputedStyle ? 369 // Query it 370 // TODO: From CSS-Query notes, we might need (node, null) for FF 371 getComputedStyle(el) : 372 373 // Otherwise, we are in IE and use currentStyle 374 el.currentStyle 375 )[ 376 // Switch to camelCase for CSSOM 377 // DEV: Grabbed from jQuery 378 // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194 379 // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597 380 prop.replace(/-(\w)/gi, function (word, letter) { 381 return letter.toUpperCase(); 382 }) 383 ]; 384 }; 385 386 module.exports = computedStyle; 387 388 389 /***/ }), 390 391 /***/ 1198: 392 /***/ (function(__unused_webpack_module, exports) { 393 394 "use strict"; 395 /*istanbul ignore start*/ 396 397 398 Object.defineProperty(exports, "__esModule", ({ 399 value: true 400 })); 401 exports["default"] = Diff; 402 403 /*istanbul ignore end*/ 404 function Diff() {} 405 406 Diff.prototype = { 407 /*istanbul ignore start*/ 408 409 /*istanbul ignore end*/ 410 diff: function diff(oldString, newString) { 411 /*istanbul ignore start*/ 412 var 413 /*istanbul ignore end*/ 414 options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; 415 var callback = options.callback; 416 417 if (typeof options === 'function') { 418 callback = options; 419 options = {}; 420 } 421 422 this.options = options; 423 var self = this; 424 425 function done(value) { 426 if (callback) { 427 setTimeout(function () { 428 callback(undefined, value); 429 }, 0); 430 return true; 431 } else { 432 return value; 433 } 434 } // Allow subclasses to massage the input prior to running 435 436 437 oldString = this.castInput(oldString); 438 newString = this.castInput(newString); 439 oldString = this.removeEmpty(this.tokenize(oldString)); 440 newString = this.removeEmpty(this.tokenize(newString)); 441 var newLen = newString.length, 442 oldLen = oldString.length; 443 var editLength = 1; 444 var maxEditLength = newLen + oldLen; 445 var bestPath = [{ 446 newPos: -1, 447 components: [] 448 }]; // Seed editLength = 0, i.e. the content starts with the same values 449 450 var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0); 451 452 if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) { 453 // Identity per the equality and tokenizer 454 return done([{ 455 value: this.join(newString), 456 count: newString.length 457 }]); 458 } // Main worker method. checks all permutations of a given edit length for acceptance. 459 460 461 function execEditLength() { 462 for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) { 463 var basePath = 464 /*istanbul ignore start*/ 465 void 0 466 /*istanbul ignore end*/ 467 ; 468 469 var addPath = bestPath[diagonalPath - 1], 470 removePath = bestPath[diagonalPath + 1], 471 _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath; 472 473 if (addPath) { 474 // No one else is going to attempt to use this value, clear it 475 bestPath[diagonalPath - 1] = undefined; 476 } 477 478 var canAdd = addPath && addPath.newPos + 1 < newLen, 479 canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen; 480 481 if (!canAdd && !canRemove) { 482 // If this path is a terminal then prune 483 bestPath[diagonalPath] = undefined; 484 continue; 485 } // Select the diagonal that we want to branch from. We select the prior 486 // path whose position in the new string is the farthest from the origin 487 // and does not pass the bounds of the diff graph 488 489 490 if (!canAdd || canRemove && addPath.newPos < removePath.newPos) { 491 basePath = clonePath(removePath); 492 self.pushComponent(basePath.components, undefined, true); 493 } else { 494 basePath = addPath; // No need to clone, we've pulled it from the list 495 496 basePath.newPos++; 497 self.pushComponent(basePath.components, true, undefined); 498 } 499 500 _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done 501 502 if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) { 503 return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken)); 504 } else { 505 // Otherwise track this path as a potential candidate and continue. 506 bestPath[diagonalPath] = basePath; 507 } 508 } 509 510 editLength++; 511 } // Performs the length of edit iteration. Is a bit fugly as this has to support the 512 // sync and async mode which is never fun. Loops over execEditLength until a value 513 // is produced. 514 515 516 if (callback) { 517 (function exec() { 518 setTimeout(function () { 519 // This should not happen, but we want to be safe. 520 521 /* istanbul ignore next */ 522 if (editLength > maxEditLength) { 523 return callback(); 524 } 525 526 if (!execEditLength()) { 527 exec(); 528 } 529 }, 0); 530 })(); 531 } else { 532 while (editLength <= maxEditLength) { 533 var ret = execEditLength(); 534 535 if (ret) { 536 return ret; 537 } 538 } 539 } 540 }, 541 542 /*istanbul ignore start*/ 543 544 /*istanbul ignore end*/ 545 pushComponent: function pushComponent(components, added, removed) { 546 var last = components[components.length - 1]; 547 548 if (last && last.added === added && last.removed === removed) { 549 // We need to clone here as the component clone operation is just 550 // as shallow array clone 551 components[components.length - 1] = { 552 count: last.count + 1, 553 added: added, 554 removed: removed 555 }; 556 } else { 557 components.push({ 558 count: 1, 559 added: added, 560 removed: removed 561 }); 562 } 563 }, 564 565 /*istanbul ignore start*/ 566 567 /*istanbul ignore end*/ 568 extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) { 569 var newLen = newString.length, 570 oldLen = oldString.length, 571 newPos = basePath.newPos, 572 oldPos = newPos - diagonalPath, 573 commonCount = 0; 574 575 while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) { 576 newPos++; 577 oldPos++; 578 commonCount++; 579 } 580 581 if (commonCount) { 582 basePath.components.push({ 583 count: commonCount 584 }); 585 } 586 587 basePath.newPos = newPos; 588 return oldPos; 589 }, 590 591 /*istanbul ignore start*/ 592 593 /*istanbul ignore end*/ 594 equals: function equals(left, right) { 595 if (this.options.comparator) { 596 return this.options.comparator(left, right); 597 } else { 598 return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase(); 599 } 600 }, 601 602 /*istanbul ignore start*/ 603 604 /*istanbul ignore end*/ 605 removeEmpty: function removeEmpty(array) { 606 var ret = []; 607 608 for (var i = 0; i < array.length; i++) { 609 if (array[i]) { 610 ret.push(array[i]); 611 } 612 } 613 614 return ret; 615 }, 616 617 /*istanbul ignore start*/ 618 619 /*istanbul ignore end*/ 620 castInput: function castInput(value) { 621 return value; 622 }, 623 624 /*istanbul ignore start*/ 625 626 /*istanbul ignore end*/ 627 tokenize: function tokenize(value) { 628 return value.split(''); 629 }, 630 631 /*istanbul ignore start*/ 632 633 /*istanbul ignore end*/ 634 join: function join(chars) { 635 return chars.join(''); 636 } 637 }; 638 639 function buildValues(diff, components, newString, oldString, useLongestToken) { 640 var componentPos = 0, 641 componentLen = components.length, 642 newPos = 0, 643 oldPos = 0; 644 645 for (; componentPos < componentLen; componentPos++) { 646 var component = components[componentPos]; 647 648 if (!component.removed) { 649 if (!component.added && useLongestToken) { 650 var value = newString.slice(newPos, newPos + component.count); 651 value = value.map(function (value, i) { 652 var oldValue = oldString[oldPos + i]; 653 return oldValue.length > value.length ? oldValue : value; 654 }); 655 component.value = diff.join(value); 656 } else { 657 component.value = diff.join(newString.slice(newPos, newPos + component.count)); 658 } 659 660 newPos += component.count; // Common case 661 662 if (!component.added) { 663 oldPos += component.count; 664 } 665 } else { 666 component.value = diff.join(oldString.slice(oldPos, oldPos + component.count)); 667 oldPos += component.count; // Reverse add and remove so removes are output first to match common convention 668 // The diffing algorithm is tied to add then remove output and this is the simplest 669 // route to get the desired output with minimal overhead. 670 671 if (componentPos && components[componentPos - 1].added) { 672 var tmp = components[componentPos - 1]; 673 components[componentPos - 1] = components[componentPos]; 674 components[componentPos] = tmp; 675 } 676 } 677 } // Special case handle for when one terminal is ignored (i.e. whitespace). 678 // For this case we merge the terminal into the prior string and drop the change. 679 // This is only available for string mode. 680 681 682 var lastComponent = components[componentLen - 1]; 683 684 if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) { 685 components[componentLen - 2].value += lastComponent.value; 686 components.pop(); 687 } 688 689 return components; 690 } 691 692 function clonePath(path) { 693 return { 694 newPos: path.newPos, 695 components: path.components.slice(0) 696 }; 697 } 698 699 700 /***/ }), 701 702 /***/ 1973: 703 /***/ (function(__unused_webpack_module, exports, __webpack_require__) { 704 705 "use strict"; 706 var __webpack_unused_export__; 707 /*istanbul ignore start*/ 708 709 710 __webpack_unused_export__ = ({ 711 value: true 712 }); 713 exports.Kx = diffChars; 714 __webpack_unused_export__ = void 0; 715 716 /*istanbul ignore end*/ 717 var 718 /*istanbul ignore start*/ 719 _base = _interopRequireDefault(__webpack_require__(1198)) 720 /*istanbul ignore end*/ 721 ; 722 723 /*istanbul ignore start*/ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 724 725 /*istanbul ignore end*/ 726 var characterDiff = new 727 /*istanbul ignore start*/ 728 _base 729 /*istanbul ignore end*/ 730 . 731 /*istanbul ignore start*/ 732 default 733 /*istanbul ignore end*/ 734 (); 735 736 /*istanbul ignore start*/ 737 __webpack_unused_export__ = characterDiff; 738 739 /*istanbul ignore end*/ 740 function diffChars(oldStr, newStr, options) { 741 return characterDiff.diff(oldStr, newStr, options); 742 } 743 744 745 /***/ }), 746 747 /***/ 1345: 748 /***/ (function(module, __unused_webpack_exports, __webpack_require__) { 749 750 "use strict"; 751 752 753 var util = __webpack_require__(5022); 754 755 function scrollIntoView(elem, container, config) { 756 config = config || {}; 757 // document 归一化到 window 758 if (container.nodeType === 9) { 759 container = util.getWindow(container); 760 } 761 762 var allowHorizontalScroll = config.allowHorizontalScroll; 763 var onlyScrollIfNeeded = config.onlyScrollIfNeeded; 764 var alignWithTop = config.alignWithTop; 765 var alignWithLeft = config.alignWithLeft; 766 var offsetTop = config.offsetTop || 0; 767 var offsetLeft = config.offsetLeft || 0; 768 var offsetBottom = config.offsetBottom || 0; 769 var offsetRight = config.offsetRight || 0; 770 771 allowHorizontalScroll = allowHorizontalScroll === undefined ? true : allowHorizontalScroll; 772 773 var isWin = util.isWindow(container); 774 var elemOffset = util.offset(elem); 775 var eh = util.outerHeight(elem); 776 var ew = util.outerWidth(elem); 777 var containerOffset = undefined; 778 var ch = undefined; 779 var cw = undefined; 780 var containerScroll = undefined; 781 var diffTop = undefined; 782 var diffBottom = undefined; 783 var win = undefined; 784 var winScroll = undefined; 785 var ww = undefined; 786 var wh = undefined; 787 788 if (isWin) { 789 win = container; 790 wh = util.height(win); 791 ww = util.width(win); 792 winScroll = { 793 left: util.scrollLeft(win), 794 top: util.scrollTop(win) 795 }; 796 // elem 相对 container 可视视窗的距离 797 diffTop = { 798 left: elemOffset.left - winScroll.left - offsetLeft, 799 top: elemOffset.top - winScroll.top - offsetTop 800 }; 801 diffBottom = { 802 left: elemOffset.left + ew - (winScroll.left + ww) + offsetRight, 803 top: elemOffset.top + eh - (winScroll.top + wh) + offsetBottom 804 }; 805 containerScroll = winScroll; 806 } else { 807 containerOffset = util.offset(container); 808 ch = container.clientHeight; 809 cw = container.clientWidth; 810 containerScroll = { 811 left: container.scrollLeft, 812 top: container.scrollTop 813 }; 814 // elem 相对 container 可视视窗的距离 815 // 注意边框, offset 是边框到根节点 816 diffTop = { 817 left: elemOffset.left - (containerOffset.left + (parseFloat(util.css(container, 'borderLeftWidth')) || 0)) - offsetLeft, 818 top: elemOffset.top - (containerOffset.top + (parseFloat(util.css(container, 'borderTopWidth')) || 0)) - offsetTop 819 }; 820 diffBottom = { 821 left: elemOffset.left + ew - (containerOffset.left + cw + (parseFloat(util.css(container, 'borderRightWidth')) || 0)) + offsetRight, 822 top: elemOffset.top + eh - (containerOffset.top + ch + (parseFloat(util.css(container, 'borderBottomWidth')) || 0)) + offsetBottom 823 }; 824 } 825 826 if (diffTop.top < 0 || diffBottom.top > 0) { 827 // 强制向上 828 if (alignWithTop === true) { 829 util.scrollTop(container, containerScroll.top + diffTop.top); 830 } else if (alignWithTop === false) { 831 util.scrollTop(container, containerScroll.top + diffBottom.top); 832 } else { 833 // 自动调整 834 if (diffTop.top < 0) { 835 util.scrollTop(container, containerScroll.top + diffTop.top); 836 } else { 837 util.scrollTop(container, containerScroll.top + diffBottom.top); 838 } 839 } 840 } else { 841 if (!onlyScrollIfNeeded) { 842 alignWithTop = alignWithTop === undefined ? true : !!alignWithTop; 843 if (alignWithTop) { 844 util.scrollTop(container, containerScroll.top + diffTop.top); 845 } else { 846 util.scrollTop(container, containerScroll.top + diffBottom.top); 847 } 848 } 849 } 850 851 if (allowHorizontalScroll) { 852 if (diffTop.left < 0 || diffBottom.left > 0) { 853 // 强制向上 854 if (alignWithLeft === true) { 855 util.scrollLeft(container, containerScroll.left + diffTop.left); 856 } else if (alignWithLeft === false) { 857 util.scrollLeft(container, containerScroll.left + diffBottom.left); 858 } else { 859 // 自动调整 860 if (diffTop.left < 0) { 861 util.scrollLeft(container, containerScroll.left + diffTop.left); 862 } else { 863 util.scrollLeft(container, containerScroll.left + diffBottom.left); 864 } 865 } 866 } else { 867 if (!onlyScrollIfNeeded) { 868 alignWithLeft = alignWithLeft === undefined ? true : !!alignWithLeft; 869 if (alignWithLeft) { 870 util.scrollLeft(container, containerScroll.left + diffTop.left); 871 } else { 872 util.scrollLeft(container, containerScroll.left + diffBottom.left); 873 } 874 } 875 } 876 } 877 } 878 879 module.exports = scrollIntoView; 880 881 /***/ }), 882 883 /***/ 5425: 884 /***/ (function(module, __unused_webpack_exports, __webpack_require__) { 885 886 "use strict"; 887 888 889 module.exports = __webpack_require__(1345); 890 891 /***/ }), 892 893 /***/ 5022: 894 /***/ (function(module) { 895 896 "use strict"; 897 898 899 var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 900 901 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; 902 903 var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source; 904 905 function getClientPosition(elem) { 906 var box = undefined; 907 var x = undefined; 908 var y = undefined; 909 var doc = elem.ownerDocument; 910 var body = doc.body; 911 var docElem = doc && doc.documentElement; 912 // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式 913 box = elem.getBoundingClientRect(); 914 915 // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop 916 // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确 917 // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin 918 919 x = box.left; 920 y = box.top; 921 922 // In IE, most of the time, 2 extra pixels are added to the top and left 923 // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and 924 // IE6 standards mode, this border can be overridden by setting the 925 // document element's border to zero -- thus, we cannot rely on the 926 // offset always being 2 pixels. 927 928 // In quirks mode, the offset can be determined by querying the body's 929 // clientLeft/clientTop, but in standards mode, it is found by querying 930 // the document element's clientLeft/clientTop. Since we already called 931 // getClientBoundingRect we have already forced a reflow, so it is not 932 // too expensive just to query them all. 933 934 // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的 935 // 窗口边框标准是设 documentElement ,quirks 时设置 body 936 // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去 937 // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置 938 // 标准 ie 下 docElem.clientTop 就是 border-top 939 // ie7 html 即窗口边框改变不了。永远为 2 940 // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0 941 942 x -= docElem.clientLeft || body.clientLeft || 0; 943 y -= docElem.clientTop || body.clientTop || 0; 944 945 return { 946 left: x, 947 top: y 948 }; 949 } 950 951 function getScroll(w, top) { 952 var ret = w['page' + (top ? 'Y' : 'X') + 'Offset']; 953 var method = 'scroll' + (top ? 'Top' : 'Left'); 954 if (typeof ret !== 'number') { 955 var d = w.document; 956 // ie6,7,8 standard mode 957 ret = d.documentElement[method]; 958 if (typeof ret !== 'number') { 959 // quirks mode 960 ret = d.body[method]; 961 } 962 } 963 return ret; 964 } 965 966 function getScrollLeft(w) { 967 return getScroll(w); 968 } 969 970 function getScrollTop(w) { 971 return getScroll(w, true); 972 } 973 974 function getOffset(el) { 975 var pos = getClientPosition(el); 976 var doc = el.ownerDocument; 977 var w = doc.defaultView || doc.parentWindow; 978 pos.left += getScrollLeft(w); 979 pos.top += getScrollTop(w); 980 return pos; 981 } 982 function _getComputedStyle(elem, name, computedStyle_) { 983 var val = ''; 984 var d = elem.ownerDocument; 985 var computedStyle = computedStyle_ || d.defaultView.getComputedStyle(elem, null); 986 987 // https://github.com/kissyteam/kissy/issues/61 988 if (computedStyle) { 989 val = computedStyle.getPropertyValue(name) || computedStyle[name]; 990 } 991 992 return val; 993 } 994 995 var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i'); 996 var RE_POS = /^(top|right|bottom|left)$/; 997 var CURRENT_STYLE = 'currentStyle'; 998 var RUNTIME_STYLE = 'runtimeStyle'; 999 var LEFT = 'left'; 1000 var PX = 'px'; 1001 1002 function _getComputedStyleIE(elem, name) { 1003 // currentStyle maybe null 1004 // http://msdn.microsoft.com/en-us/library/ms535231.aspx 1005 var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name]; 1006 1007 // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值 1008 // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19 1009 // 在 ie 下不对,需要直接用 offset 方式 1010 // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了 1011 1012 // From the awesome hack by Dean Edwards 1013 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 1014 // If we're not dealing with a regular pixel number 1015 // but a number that has a weird ending, we need to convert it to pixels 1016 // exclude left right for relativity 1017 if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) { 1018 // Remember the original values 1019 var style = elem.style; 1020 var left = style[LEFT]; 1021 var rsLeft = elem[RUNTIME_STYLE][LEFT]; 1022 1023 // prevent flashing of content 1024 elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT]; 1025 1026 // Put in the new values to get a computed value out 1027 style[LEFT] = name === 'fontSize' ? '1em' : ret || 0; 1028 ret = style.pixelLeft + PX; 1029 1030 // Revert the changed values 1031 style[LEFT] = left; 1032 1033 elem[RUNTIME_STYLE][LEFT] = rsLeft; 1034 } 1035 return ret === '' ? 'auto' : ret; 1036 } 1037 1038 var getComputedStyleX = undefined; 1039 if (typeof window !== 'undefined') { 1040 getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE; 1041 } 1042 1043 function each(arr, fn) { 1044 for (var i = 0; i < arr.length; i++) { 1045 fn(arr[i]); 1046 } 1047 } 1048 1049 function isBorderBoxFn(elem) { 1050 return getComputedStyleX(elem, 'boxSizing') === 'border-box'; 1051 } 1052 1053 var BOX_MODELS = ['margin', 'border', 'padding']; 1054 var CONTENT_INDEX = -1; 1055 var PADDING_INDEX = 2; 1056 var BORDER_INDEX = 1; 1057 var MARGIN_INDEX = 0; 1058 1059 function swap(elem, options, callback) { 1060 var old = {}; 1061 var style = elem.style; 1062 var name = undefined; 1063 1064 // Remember the old values, and insert the new ones 1065 for (name in options) { 1066 if (options.hasOwnProperty(name)) { 1067 old[name] = style[name]; 1068 style[name] = options[name]; 1069 } 1070 } 1071 1072 callback.call(elem); 1073 1074 // Revert the old values 1075 for (name in options) { 1076 if (options.hasOwnProperty(name)) { 1077 style[name] = old[name]; 1078 } 1079 } 1080 } 1081 1082 function getPBMWidth(elem, props, which) { 1083 var value = 0; 1084 var prop = undefined; 1085 var j = undefined; 1086 var i = undefined; 1087 for (j = 0; j < props.length; j++) { 1088 prop = props[j]; 1089 if (prop) { 1090 for (i = 0; i < which.length; i++) { 1091 var cssProp = undefined; 1092 if (prop === 'border') { 1093 cssProp = prop + which[i] + 'Width'; 1094 } else { 1095 cssProp = prop + which[i]; 1096 } 1097 value += parseFloat(getComputedStyleX(elem, cssProp)) || 0; 1098 } 1099 } 1100 } 1101 return value; 1102 } 1103 1104 /** 1105 * A crude way of determining if an object is a window 1106 * @member util 1107 */ 1108 function isWindow(obj) { 1109 // must use == for ie8 1110 /* eslint eqeqeq:0 */ 1111 return obj != null && obj == obj.window; 1112 } 1113 1114 var domUtils = {}; 1115 1116 each(['Width', 'Height'], function (name) { 1117 domUtils['doc' + name] = function (refWin) { 1118 var d = refWin.document; 1119 return Math.max( 1120 // firefox chrome documentElement.scrollHeight< body.scrollHeight 1121 // ie standard mode : documentElement.scrollHeight> body.scrollHeight 1122 d.documentElement['scroll' + name], 1123 // quirks : documentElement.scrollHeight 最大等于可视窗口多一点? 1124 d.body['scroll' + name], domUtils['viewport' + name](d)); 1125 }; 1126 1127 domUtils['viewport' + name] = function (win) { 1128 // pc browser includes scrollbar in window.innerWidth 1129 var prop = 'client' + name; 1130 var doc = win.document; 1131 var body = doc.body; 1132 var documentElement = doc.documentElement; 1133 var documentElementProp = documentElement[prop]; 1134 // 标准模式取 documentElement 1135 // backcompat 取 body 1136 return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp; 1137 }; 1138 }); 1139 1140 /* 1141 得到元素的大小信息 1142 @param elem 1143 @param name 1144 @param {String} [extra] 'padding' : (css width) + padding 1145 'border' : (css width) + padding + border 1146 'margin' : (css width) + padding + border + margin 1147 */ 1148 function getWH(elem, name, extra) { 1149 if (isWindow(elem)) { 1150 return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem); 1151 } else if (elem.nodeType === 9) { 1152 return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem); 1153 } 1154 var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; 1155 var borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight; 1156 var computedStyle = getComputedStyleX(elem); 1157 var isBorderBox = isBorderBoxFn(elem, computedStyle); 1158 var cssBoxValue = 0; 1159 if (borderBoxValue == null || borderBoxValue <= 0) { 1160 borderBoxValue = undefined; 1161 // Fall back to computed then un computed css if necessary 1162 cssBoxValue = getComputedStyleX(elem, name); 1163 if (cssBoxValue == null || Number(cssBoxValue) < 0) { 1164 cssBoxValue = elem.style[name] || 0; 1165 } 1166 // Normalize '', auto, and prepare for extra 1167 cssBoxValue = parseFloat(cssBoxValue) || 0; 1168 } 1169 if (extra === undefined) { 1170 extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX; 1171 } 1172 var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox; 1173 var val = borderBoxValue || cssBoxValue; 1174 if (extra === CONTENT_INDEX) { 1175 if (borderBoxValueOrIsBorderBox) { 1176 return val - getPBMWidth(elem, ['border', 'padding'], which, computedStyle); 1177 } 1178 return cssBoxValue; 1179 } 1180 if (borderBoxValueOrIsBorderBox) { 1181 var padding = extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which, computedStyle) : getPBMWidth(elem, ['margin'], which, computedStyle); 1182 return val + (extra === BORDER_INDEX ? 0 : padding); 1183 } 1184 return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which, computedStyle); 1185 } 1186 1187 var cssShow = { 1188 position: 'absolute', 1189 visibility: 'hidden', 1190 display: 'block' 1191 }; 1192 1193 // fix #119 : https://github.com/kissyteam/kissy/issues/119 1194 function getWHIgnoreDisplay(elem) { 1195 var val = undefined; 1196 var args = arguments; 1197 // in case elem is window 1198 // elem.offsetWidth === undefined 1199 if (elem.offsetWidth !== 0) { 1200 val = getWH.apply(undefined, args); 1201 } else { 1202 swap(elem, cssShow, function () { 1203 val = getWH.apply(undefined, args); 1204 }); 1205 } 1206 return val; 1207 } 1208 1209 function css(el, name, v) { 1210 var value = v; 1211 if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') { 1212 for (var i in name) { 1213 if (name.hasOwnProperty(i)) { 1214 css(el, i, name[i]); 1215 } 1216 } 1217 return undefined; 1218 } 1219 if (typeof value !== 'undefined') { 1220 if (typeof value === 'number') { 1221 value += 'px'; 1222 } 1223 el.style[name] = value; 1224 return undefined; 1225 } 1226 return getComputedStyleX(el, name); 1227 } 1228 1229 each(['width', 'height'], function (name) { 1230 var first = name.charAt(0).toUpperCase() + name.slice(1); 1231 domUtils['outer' + first] = function (el, includeMargin) { 1232 return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX); 1233 }; 1234 var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; 1235 1236 domUtils[name] = function (elem, val) { 1237 if (val !== undefined) { 1238 if (elem) { 1239 var computedStyle = getComputedStyleX(elem); 1240 var isBorderBox = isBorderBoxFn(elem); 1241 if (isBorderBox) { 1242 val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle); 1243 } 1244 return css(elem, name, val); 1245 } 1246 return undefined; 1247 } 1248 return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX); 1249 }; 1250 }); 1251 1252 // 设置 elem 相对 elem.ownerDocument 的坐标 1253 function setOffset(elem, offset) { 1254 // set position first, in-case top/left are set even on static elem 1255 if (css(elem, 'position') === 'static') { 1256 elem.style.position = 'relative'; 1257 } 1258 1259 var old = getOffset(elem); 1260 var ret = {}; 1261 var current = undefined; 1262 var key = undefined; 1263 1264 for (key in offset) { 1265 if (offset.hasOwnProperty(key)) { 1266 current = parseFloat(css(elem, key)) || 0; 1267 ret[key] = current + offset[key] - old[key]; 1268 } 1269 } 1270 css(elem, ret); 1271 } 1272 1273 module.exports = _extends({ 1274 getWindow: function getWindow(node) { 1275 var doc = node.ownerDocument || node; 1276 return doc.defaultView || doc.parentWindow; 1277 }, 1278 offset: function offset(el, value) { 1279 if (typeof value !== 'undefined') { 1280 setOffset(el, value); 1281 } else { 1282 return getOffset(el); 1283 } 1284 }, 1285 1286 isWindow: isWindow, 1287 each: each, 1288 css: css, 1289 clone: function clone(obj) { 1290 var ret = {}; 1291 for (var i in obj) { 1292 if (obj.hasOwnProperty(i)) { 1293 ret[i] = obj[i]; 1294 } 1295 } 1296 var overflow = obj.overflow; 1297 if (overflow) { 1298 for (var i in obj) { 1299 if (obj.hasOwnProperty(i)) { 1300 ret.overflow[i] = obj.overflow[i]; 1301 } 1302 } 1303 } 1304 return ret; 1305 }, 1306 scrollLeft: function scrollLeft(w, v) { 1307 if (isWindow(w)) { 1308 if (v === undefined) { 1309 return getScrollLeft(w); 1310 } 1311 window.scrollTo(v, getScrollTop(w)); 1312 } else { 1313 if (v === undefined) { 1314 return w.scrollLeft; 1315 } 1316 w.scrollLeft = v; 1317 } 1318 }, 1319 scrollTop: function scrollTop(w, v) { 1320 if (isWindow(w)) { 1321 if (v === undefined) { 1322 return getScrollTop(w); 1323 } 1324 window.scrollTo(getScrollLeft(w), v); 1325 } else { 1326 if (v === undefined) { 1327 return w.scrollTop; 1328 } 1329 w.scrollTop = v; 1330 } 1331 }, 1332 1333 viewportWidth: 0, 1334 viewportHeight: 0 1335 }, domUtils); 1336 1337 /***/ }), 1338 1339 /***/ 8575: 1340 /***/ (function(module) { 1341 1342 if (typeof Object.create === 'function') { 1343 // implementation from standard node.js 'util' module 1344 module.exports = function inherits(ctor, superCtor) { 1345 if (superCtor) { 1346 ctor.super_ = superCtor 1347 ctor.prototype = Object.create(superCtor.prototype, { 1348 constructor: { 1349 value: ctor, 1350 enumerable: false, 1351 writable: true, 1352 configurable: true 1353 } 1354 }) 1355 } 1356 }; 1357 } else { 1358 // old school shim for old browsers 1359 module.exports = function inherits(ctor, superCtor) { 1360 if (superCtor) { 1361 ctor.super_ = superCtor 1362 var TempCtor = function () {} 1363 TempCtor.prototype = superCtor.prototype 1364 ctor.prototype = new TempCtor() 1365 ctor.prototype.constructor = ctor 1366 } 1367 } 1368 } 1369 1370 1371 /***/ }), 1372 1373 /***/ 9894: 1374 /***/ (function(module, __unused_webpack_exports, __webpack_require__) { 1375 1376 // Load in dependencies 1377 var computedStyle = __webpack_require__(4827); 1378 1379 /** 1380 * Calculate the `line-height` of a given node 1381 * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM. 1382 * @returns {Number} `line-height` of the element in pixels 1383 */ 1384 function lineHeight(node) { 1385 // Grab the line-height via style 1386 var lnHeightStr = computedStyle(node, 'line-height'); 1387 var lnHeight = parseFloat(lnHeightStr, 10); 1388 1389 // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em') 1390 if (lnHeightStr === lnHeight + '') { 1391 // Save the old lineHeight style and update the em unit to the element 1392 var _lnHeightStyle = node.style.lineHeight; 1393 node.style.lineHeight = lnHeightStr + 'em'; 1394 1395 // Calculate the em based height 1396 lnHeightStr = computedStyle(node, 'line-height'); 1397 lnHeight = parseFloat(lnHeightStr, 10); 1398 1399 // Revert the lineHeight style 1400 if (_lnHeightStyle) { 1401 node.style.lineHeight = _lnHeightStyle; 1402 } else { 1403 delete node.style.lineHeight; 1404 } 1405 } 1406 1407 // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt) 1408 // DEV: `em` units are converted to `pt` in IE6 1409 // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length 1410 if (lnHeightStr.indexOf('pt') !== -1) { 1411 lnHeight *= 4; 1412 lnHeight /= 3; 1413 // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm) 1414 } else if (lnHeightStr.indexOf('mm') !== -1) { 1415 lnHeight *= 96; 1416 lnHeight /= 25.4; 1417 // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm) 1418 } else if (lnHeightStr.indexOf('cm') !== -1) { 1419 lnHeight *= 96; 1420 lnHeight /= 2.54; 1421 // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in) 1422 } else if (lnHeightStr.indexOf('in') !== -1) { 1423 lnHeight *= 96; 1424 // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc) 1425 } else if (lnHeightStr.indexOf('pc') !== -1) { 1426 lnHeight *= 16; 1427 } 1428 1429 // Continue our computation 1430 lnHeight = Math.round(lnHeight); 1431 1432 // If the line-height is "normal", calculate by font-size 1433 if (lnHeightStr === 'normal') { 1434 // Create a temporary node 1435 var nodeName = node.nodeName; 1436 var _node = document.createElement(nodeName); 1437 _node.innerHTML = ' '; 1438 1439 // If we have a text area, reset it to only 1 row 1440 // https://github.com/twolfson/line-height/issues/4 1441 if (nodeName.toUpperCase() === 'TEXTAREA') { 1442 _node.setAttribute('rows', '1'); 1443 } 1444 1445 // Set the font-size of the element 1446 var fontSizeStr = computedStyle(node, 'font-size'); 1447 _node.style.fontSize = fontSizeStr; 1448 1449 // Remove default padding/border which can affect offset height 1450 // https://github.com/twolfson/line-height/issues/4 1451 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight 1452 _node.style.padding = '0px'; 1453 _node.style.border = '0px'; 1454 1455 // Append it to the body 1456 var body = document.body; 1457 body.appendChild(_node); 1458 1459 // Assume the line height of the element is the height 1460 var height = _node.offsetHeight; 1461 lnHeight = height; 1462 1463 // Remove our child from the DOM 1464 body.removeChild(_node); 1465 } 1466 1467 // Return the calculated height 1468 return lnHeight; 1469 } 1470 1471 // Export lineHeight 1472 module.exports = lineHeight; 1473 1474 1475 /***/ }), 1476 1477 /***/ 7970: 1478 /***/ (function(module, __unused_webpack_exports, __webpack_require__) { 1479 1480 module.exports = __webpack_require__(195); 1481 1482 1483 /***/ }), 1484 1485 /***/ 3110: 1486 /***/ (function(module) { 1487 1488 "use strict"; 1489 /** 1490 * Copyright (c) 2015, Facebook, Inc. 1491 * All rights reserved. 1492 * 1493 * This source code is licensed under the BSD-style license found in the 1494 * LICENSE file in the root directory of this source tree. An additional grant 1495 * of patent rights can be found in the PATENTS file in the same directory. 1496 * 1497 * @providesModule ExecutionEnvironment 1498 */ 1499 1500 /*jslint evil: true */ 1501 1502 1503 1504 var canUseDOM = !!( 1505 typeof window !== 'undefined' && 1506 window.document && 1507 window.document.createElement 1508 ); 1509 1510 /** 1511 * Simple, lightweight module assisting with the detection and context of 1512 * Worker. Helps avoid circular dependencies and allows code to reason about 1513 * whether or not they are in a Worker, even if they never include the main 1514 * `ReactWorker` dependency. 1515 */ 1516 var ExecutionEnvironment = { 1517 1518 canUseDOM: canUseDOM, 1519 1520 canUseWorkers: typeof Worker !== 'undefined', 1521 1522 canUseEventListeners: 1523 canUseDOM && !!(window.addEventListener || window.attachEvent), 1524 1525 canUseViewport: canUseDOM && !!window.screen, 1526 1527 isInWorker: !canUseDOM // For now, this is true - might change in the future. 1528 1529 }; 1530 1531 module.exports = ExecutionEnvironment; 1532 1533 1534 /***/ }), 1535 1536 /***/ 3812: 1537 /***/ (function(module) { 1538 1539 /** 1540 * Copyright 2004-present Facebook. All Rights Reserved. 1541 * 1542 * @providesModule UserAgent_DEPRECATED 1543 */ 1544 1545 /** 1546 * Provides entirely client-side User Agent and OS detection. You should prefer 1547 * the non-deprecated UserAgent module when possible, which exposes our 1548 * authoritative server-side PHP-based detection to the client. 1549 * 1550 * Usage is straightforward: 1551 * 1552 * if (UserAgent_DEPRECATED.ie()) { 1553 * // IE 1554 * } 1555 * 1556 * You can also do version checks: 1557 * 1558 * if (UserAgent_DEPRECATED.ie() >= 7) { 1559 * // IE7 or better 1560 * } 1561 * 1562 * The browser functions will return NaN if the browser does not match, so 1563 * you can also do version compares the other way: 1564 * 1565 * if (UserAgent_DEPRECATED.ie() < 7) { 1566 * // IE6 or worse 1567 * } 1568 * 1569 * Note that the version is a float and may include a minor version number, 1570 * so you should always use range operators to perform comparisons, not 1571 * strict equality. 1572 * 1573 * **Note:** You should **strongly** prefer capability detection to browser 1574 * version detection where it's reasonable: 1575 * 1576 * http://www.quirksmode.org/js/support.html 1577 * 1578 * Further, we have a large number of mature wrapper functions and classes 1579 * which abstract away many browser irregularities. Check the documentation, 1580 * grep for things, or ask on javascript@lists.facebook.com before writing yet 1581 * another copy of "event || window.event". 1582 * 1583 */ 1584 1585 var _populated = false; 1586 1587 // Browsers 1588 var _ie, _firefox, _opera, _webkit, _chrome; 1589 1590 // Actual IE browser for compatibility mode 1591 var _ie_real_version; 1592 1593 // Platforms 1594 var _osx, _windows, _linux, _android; 1595 1596 // Architectures 1597 var _win64; 1598 1599 // Devices 1600 var _iphone, _ipad, _native; 1601 1602 var _mobile; 1603 1604 function _populate() { 1605 if (_populated) { 1606 return; 1607 } 1608 1609 _populated = true; 1610 1611 // To work around buggy JS libraries that can't handle multi-digit 1612 // version numbers, Opera 10's user agent string claims it's Opera 1613 // 9, then later includes a Version/X.Y field: 1614 // 1615 // Opera/9.80 (foo) Presto/2.2.15 Version/10.10 1616 var uas = navigator.userAgent; 1617 var agent = /(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(uas); 1618 var os = /(Mac OS X)|(Windows)|(Linux)/.exec(uas); 1619 1620 _iphone = /\b(iPhone|iP[ao]d)/.exec(uas); 1621 _ipad = /\b(iP[ao]d)/.exec(uas); 1622 _android = /Android/i.exec(uas); 1623 _native = /FBAN\/\w+;/i.exec(uas); 1624 _mobile = /Mobile/i.exec(uas); 1625 1626 // Note that the IE team blog would have you believe you should be checking 1627 // for 'Win64; x64'. But MSDN then reveals that you can actually be coming 1628 // from either x64 or ia64; so ultimately, you should just check for Win64 1629 // as in indicator of whether you're in 64-bit IE. 32-bit IE on 64-bit 1630 // Windows will send 'WOW64' instead. 1631 _win64 = !!(/Win64/.exec(uas)); 1632 1633 if (agent) { 1634 _ie = agent[1] ? parseFloat(agent[1]) : ( 1635 agent[5] ? parseFloat(agent[5]) : NaN); 1636 // IE compatibility mode 1637 if (_ie && document && document.documentMode) { 1638 _ie = document.documentMode; 1639 } 1640 // grab the "true" ie version from the trident token if available 1641 var trident = /(?:Trident\/(\d+.\d+))/.exec(uas); 1642 _ie_real_version = trident ? parseFloat(trident[1]) + 4 : _ie; 1643 1644 _firefox = agent[2] ? parseFloat(agent[2]) : NaN; 1645 _opera = agent[3] ? parseFloat(agent[3]) : NaN; 1646 _webkit = agent[4] ? parseFloat(agent[4]) : NaN; 1647 if (_webkit) { 1648 // We do not add the regexp to the above test, because it will always 1649 // match 'safari' only since 'AppleWebKit' appears before 'Chrome' in 1650 // the userAgent string. 1651 agent = /(?:Chrome\/(\d+\.\d+))/.exec(uas); 1652 _chrome = agent && agent[1] ? parseFloat(agent[1]) : NaN; 1653 } else { 1654 _chrome = NaN; 1655 } 1656 } else { 1657 _ie = _firefox = _opera = _chrome = _webkit = NaN; 1658 } 1659 1660 if (os) { 1661 if (os[1]) { 1662 // Detect OS X version. If no version number matches, set _osx to true. 1663 // Version examples: 10, 10_6_1, 10.7 1664 // Parses version number as a float, taking only first two sets of 1665 // digits. If only one set of digits is found, returns just the major 1666 // version number. 1667 var ver = /(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(uas); 1668 1669 _osx = ver ? parseFloat(ver[1].replace('_', '.')) : true; 1670 } else { 1671 _osx = false; 1672 } 1673 _windows = !!os[2]; 1674 _linux = !!os[3]; 1675 } else { 1676 _osx = _windows = _linux = false; 1677 } 1678 } 1679 1680 var UserAgent_DEPRECATED = { 1681 1682 /** 1683 * Check if the UA is Internet Explorer. 1684 * 1685 * 1686 * @return float|NaN Version number (if match) or NaN. 1687 */ 1688 ie: function() { 1689 return _populate() || _ie; 1690 }, 1691 1692 /** 1693 * Check if we're in Internet Explorer compatibility mode. 1694 * 1695 * @return bool true if in compatibility mode, false if 1696 * not compatibility mode or not ie 1697 */ 1698 ieCompatibilityMode: function() { 1699 return _populate() || (_ie_real_version > _ie); 1700 }, 1701 1702 1703 /** 1704 * Whether the browser is 64-bit IE. Really, this is kind of weak sauce; we 1705 * only need this because Skype can't handle 64-bit IE yet. We need to remove 1706 * this when we don't need it -- tracked by #601957. 1707 */ 1708 ie64: function() { 1709 return UserAgent_DEPRECATED.ie() && _win64; 1710 }, 1711 1712 /** 1713 * Check if the UA is Firefox. 1714 * 1715 * 1716 * @return float|NaN Version number (if match) or NaN. 1717 */ 1718 firefox: function() { 1719 return _populate() || _firefox; 1720 }, 1721 1722 1723 /** 1724 * Check if the UA is Opera. 1725 * 1726 * 1727 * @return float|NaN Version number (if match) or NaN. 1728 */ 1729 opera: function() { 1730 return _populate() || _opera; 1731 }, 1732 1733 1734 /** 1735 * Check if the UA is WebKit. 1736 * 1737 * 1738 * @return float|NaN Version number (if match) or NaN. 1739 */ 1740 webkit: function() { 1741 return _populate() || _webkit; 1742 }, 1743 1744 /** 1745 * For Push 1746 * WILL BE REMOVED VERY SOON. Use UserAgent_DEPRECATED.webkit 1747 */ 1748 safari: function() { 1749 return UserAgent_DEPRECATED.webkit(); 1750 }, 1751 1752 /** 1753 * Check if the UA is a Chrome browser. 1754 * 1755 * 1756 * @return float|NaN Version number (if match) or NaN. 1757 */ 1758 chrome : function() { 1759 return _populate() || _chrome; 1760 }, 1761 1762 1763 /** 1764 * Check if the user is running Windows. 1765 * 1766 * @return bool `true' if the user's OS is Windows. 1767 */ 1768 windows: function() { 1769 return _populate() || _windows; 1770 }, 1771 1772 1773 /** 1774 * Check if the user is running Mac OS X. 1775 * 1776 * @return float|bool Returns a float if a version number is detected, 1777 * otherwise true/false. 1778 */ 1779 osx: function() { 1780 return _populate() || _osx; 1781 }, 1782 1783 /** 1784 * Check if the user is running Linux. 1785 * 1786 * @return bool `true' if the user's OS is some flavor of Linux. 1787 */ 1788 linux: function() { 1789 return _populate() || _linux; 1790 }, 1791 1792 /** 1793 * Check if the user is running on an iPhone or iPod platform. 1794 * 1795 * @return bool `true' if the user is running some flavor of the 1796 * iPhone OS. 1797 */ 1798 iphone: function() { 1799 return _populate() || _iphone; 1800 }, 1801 1802 mobile: function() { 1803 return _populate() || (_iphone || _ipad || _android || _mobile); 1804 }, 1805 1806 nativeApp: function() { 1807 // webviews inside of the native apps 1808 return _populate() || _native; 1809 }, 1810 1811 android: function() { 1812 return _populate() || _android; 1813 }, 1814 1815 ipad: function() { 1816 return _populate() || _ipad; 1817 } 1818 }; 1819 1820 module.exports = UserAgent_DEPRECATED; 1821 1822 1823 /***/ }), 1824 1825 /***/ 7939: 1826 /***/ (function(module, __unused_webpack_exports, __webpack_require__) { 1827 1828 "use strict"; 1829 /** 1830 * Copyright 2013-2015, Facebook, Inc. 1831 * All rights reserved. 1832 * 1833 * This source code is licensed under the BSD-style license found in the 1834 * LICENSE file in the root directory of this source tree. An additional grant 1835 * of patent rights can be found in the PATENTS file in the same directory. 1836 * 1837 * @providesModule isEventSupported 1838 */ 1839 1840 1841 1842 var ExecutionEnvironment = __webpack_require__(3110); 1843 1844 var useHasFeature; 1845 if (ExecutionEnvironment.canUseDOM) { 1846 useHasFeature = 1847 document.implementation && 1848 document.implementation.hasFeature && 1849 // always returns true in newer browsers as per the standard. 1850 // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature 1851 document.implementation.hasFeature('', '') !== true; 1852 } 1853 1854 /** 1855 * Checks if an event is supported in the current execution environment. 1856 * 1857 * NOTE: This will not work correctly for non-generic events such as `change`, 1858 * `reset`, `load`, `error`, and `select`. 1859 * 1860 * Borrows from Modernizr. 1861 * 1862 * @param {string} eventNameSuffix Event name, e.g. "click". 1863 * @param {?boolean} capture Check if the capture phase is supported. 1864 * @return {boolean} True if the event is supported. 1865 * @internal 1866 * @license Modernizr 3.0.0pre (Custom Build) | MIT 1867 */ 1868 function isEventSupported(eventNameSuffix, capture) { 1869 if (!ExecutionEnvironment.canUseDOM || 1870 capture && !('addEventListener' in document)) { 1871 return false; 1872 } 1873 1874 var eventName = 'on' + eventNameSuffix; 1875 var isSupported = eventName in document; 1876 1877 if (!isSupported) { 1878 var element = document.createElement('div'); 1879 element.setAttribute(eventName, 'return;'); 1880 isSupported = typeof element[eventName] === 'function'; 1881 } 1882 1883 if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') { 1884 // This is the only way to test support for the `wheel` event in IE9+. 1885 isSupported = document.implementation.hasFeature('Events.wheel', '3.0'); 1886 } 1887 1888 return isSupported; 1889 } 1890 1891 module.exports = isEventSupported; 1892 1893 1894 /***/ }), 1895 1896 /***/ 195: 1897 /***/ (function(module, __unused_webpack_exports, __webpack_require__) { 1898 1899 "use strict"; 1900 /** 1901 * Copyright (c) 2015, Facebook, Inc. 1902 * All rights reserved. 1903 * 1904 * This source code is licensed under the BSD-style license found in the 1905 * LICENSE file in the root directory of this source tree. An additional grant 1906 * of patent rights can be found in the PATENTS file in the same directory. 1907 * 1908 * @providesModule normalizeWheel 1909 * @typechecks 1910 */ 1911 1912 1913 1914 var UserAgent_DEPRECATED = __webpack_require__(3812); 1915 1916 var isEventSupported = __webpack_require__(7939); 1917 1918 1919 // Reasonable defaults 1920 var PIXEL_STEP = 10; 1921 var LINE_HEIGHT = 40; 1922 var PAGE_HEIGHT = 800; 1923 1924 /** 1925 * Mouse wheel (and 2-finger trackpad) support on the web sucks. It is 1926 * complicated, thus this doc is long and (hopefully) detailed enough to answer 1927 * your questions. 1928 * 1929 * If you need to react to the mouse wheel in a predictable way, this code is 1930 * like your bestest friend. * hugs * 1931 * 1932 * As of today, there are 4 DOM event types you can listen to: 1933 * 1934 * 'wheel' -- Chrome(31+), FF(17+), IE(9+) 1935 * 'mousewheel' -- Chrome, IE(6+), Opera, Safari 1936 * 'MozMousePixelScroll' -- FF(3.5 only!) (2010-2013) -- don't bother! 1937 * 'DOMMouseScroll' -- FF(0.9.7+) since 2003 1938 * 1939 * So what to do? The is the best: 1940 * 1941 * normalizeWheel.getEventType(); 1942 * 1943 * In your event callback, use this code to get sane interpretation of the 1944 * deltas. This code will return an object with properties: 1945 * 1946 * spinX -- normalized spin speed (use for zoom) - x plane 1947 * spinY -- " - y plane 1948 * pixelX -- normalized distance (to pixels) - x plane 1949 * pixelY -- " - y plane 1950 * 1951 * Wheel values are provided by the browser assuming you are using the wheel to 1952 * scroll a web page by a number of lines or pixels (or pages). Values can vary 1953 * significantly on different platforms and browsers, forgetting that you can 1954 * scroll at different speeds. Some devices (like trackpads) emit more events 1955 * at smaller increments with fine granularity, and some emit massive jumps with 1956 * linear speed or acceleration. 1957 * 1958 * This code does its best to normalize the deltas for you: 1959 * 1960 * - spin is trying to normalize how far the wheel was spun (or trackpad 1961 * dragged). This is super useful for zoom support where you want to 1962 * throw away the chunky scroll steps on the PC and make those equal to 1963 * the slow and smooth tiny steps on the Mac. Key data: This code tries to 1964 * resolve a single slow step on a wheel to 1. 1965 * 1966 * - pixel is normalizing the desired scroll delta in pixel units. You'll 1967 * get the crazy differences between browsers, but at least it'll be in 1968 * pixels! 1969 * 1970 * - positive value indicates scrolling DOWN/RIGHT, negative UP/LEFT. This 1971 * should translate to positive value zooming IN, negative zooming OUT. 1972 * This matches the newer 'wheel' event. 1973 * 1974 * Why are there spinX, spinY (or pixels)? 1975 * 1976 * - spinX is a 2-finger side drag on the trackpad, and a shift + wheel turn 1977 * with a mouse. It results in side-scrolling in the browser by default. 1978 * 1979 * - spinY is what you expect -- it's the classic axis of a mouse wheel. 1980 * 1981 * - I dropped spinZ/pixelZ. It is supported by the DOM 3 'wheel' event and 1982 * probably is by browsers in conjunction with fancy 3D controllers .. but 1983 * you know. 1984 * 1985 * Implementation info: 1986 * 1987 * Examples of 'wheel' event if you scroll slowly (down) by one step with an 1988 * average mouse: 1989 * 1990 * OS X + Chrome (mouse) - 4 pixel delta (wheelDelta -120) 1991 * OS X + Safari (mouse) - N/A pixel delta (wheelDelta -12) 1992 * OS X + Firefox (mouse) - 0.1 line delta (wheelDelta N/A) 1993 * Win8 + Chrome (mouse) - 100 pixel delta (wheelDelta -120) 1994 * Win8 + Firefox (mouse) - 3 line delta (wheelDelta -120) 1995 * 1996 * On the trackpad: 1997 * 1998 * OS X + Chrome (trackpad) - 2 pixel delta (wheelDelta -6) 1999 * OS X + Firefox (trackpad) - 1 pixel delta (wheelDelta N/A) 2000 * 2001 * On other/older browsers.. it's more complicated as there can be multiple and 2002 * also missing delta values. 2003 * 2004 * The 'wheel' event is more standard: 2005 * 2006 * http://www.w3.org/TR/DOM-Level-3-Events/#events-wheelevents 2007 * 2008 * The basics is that it includes a unit, deltaMode (pixels, lines, pages), and 2009 * deltaX, deltaY and deltaZ. Some browsers provide other values to maintain 2010 * backward compatibility with older events. Those other values help us 2011 * better normalize spin speed. Example of what the browsers provide: 2012 * 2013 * | event.wheelDelta | event.detail 2014 * ------------------+------------------+-------------- 2015 * Safari v5/OS X | -120 | 0 2016 * Safari v5/Win7 | -120 | 0 2017 * Chrome v17/OS X | -120 | 0 2018 * Chrome v17/Win7 | -120 | 0 2019 * IE9/Win7 | -120 | undefined 2020 * Firefox v4/OS X | undefined | 1 2021 * Firefox v4/Win7 | undefined | 3 2022 * 2023 */ 2024 function normalizeWheel(/*object*/ event) /*object*/ { 2025 var sX = 0, sY = 0, // spinX, spinY 2026 pX = 0, pY = 0; // pixelX, pixelY 2027 2028 // Legacy 2029 if ('detail' in event) { sY = event.detail; } 2030 if ('wheelDelta' in event) { sY = -event.wheelDelta / 120; } 2031 if ('wheelDeltaY' in event) { sY = -event.wheelDeltaY / 120; } 2032 if ('wheelDeltaX' in event) { sX = -event.wheelDeltaX / 120; } 2033 2034 // side scrolling on FF with DOMMouseScroll 2035 if ( 'axis' in event && event.axis === event.HORIZONTAL_AXIS ) { 2036 sX = sY; 2037 sY = 0; 2038 } 2039 2040 pX = sX * PIXEL_STEP; 2041 pY = sY * PIXEL_STEP; 2042 2043 if ('deltaY' in event) { pY = event.deltaY; } 2044 if ('deltaX' in event) { pX = event.deltaX; } 2045 2046 if ((pX || pY) && event.deltaMode) { 2047 if (event.deltaMode == 1) { // delta in LINE units 2048 pX *= LINE_HEIGHT; 2049 pY *= LINE_HEIGHT; 2050 } else { // delta in PAGE units 2051 pX *= PAGE_HEIGHT; 2052 pY *= PAGE_HEIGHT; 2053 } 2054 } 2055 2056 // Fall-back if spin cannot be determined 2057 if (pX && !sX) { sX = (pX < 1) ? -1 : 1; } 2058 if (pY && !sY) { sY = (pY < 1) ? -1 : 1; } 2059 2060 return { spinX : sX, 2061 spinY : sY, 2062 pixelX : pX, 2063 pixelY : pY }; 2064 } 2065 2066 2067 /** 2068 * The best combination if you prefer spinX + spinY normalization. It favors 2069 * the older DOMMouseScroll for Firefox, as FF does not include wheelDelta with 2070 * 'wheel' event, making spin speed determination impossible. 2071 */ 2072 normalizeWheel.getEventType = function() /*string*/ { 2073 return (UserAgent_DEPRECATED.firefox()) 2074 ? 'DOMMouseScroll' 2075 : (isEventSupported('wheel')) 2076 ? 'wheel' 2077 : 'mousewheel'; 2078 }; 2079 2080 module.exports = normalizeWheel; 2081 2082 2083 /***/ }), 2084 2085 /***/ 5372: 2086 /***/ (function(module, __unused_webpack_exports, __webpack_require__) { 2087 2088 "use strict"; 2089 /** 2090 * Copyright (c) 2013-present, Facebook, Inc. 2091 * 2092 * This source code is licensed under the MIT license found in the 2093 * LICENSE file in the root directory of this source tree. 2094 */ 2095 2096 2097 2098 var ReactPropTypesSecret = __webpack_require__(9567); 2099 2100 function emptyFunction() {} 2101 function emptyFunctionWithReset() {} 2102 emptyFunctionWithReset.resetWarningCache = emptyFunction; 2103 2104 module.exports = function() { 2105 function shim(props, propName, componentName, location, propFullName, secret) { 2106 if (secret === ReactPropTypesSecret) { 2107 // It is still safe when called from React. 2108 return; 2109 } 2110 var err = new Error( 2111 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 2112 'Use PropTypes.checkPropTypes() to call them. ' + 2113 'Read more at http://fb.me/use-check-prop-types' 2114 ); 2115 err.name = 'Invariant Violation'; 2116 throw err; 2117 }; 2118 shim.isRequired = shim; 2119 function getShim() { 2120 return shim; 2121 }; 2122 // Important! 2123 // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. 2124 var ReactPropTypes = { 2125 array: shim, 2126 bigint: shim, 2127 bool: shim, 2128 func: shim, 2129 number: shim, 2130 object: shim, 2131 string: shim, 2132 symbol: shim, 2133 2134 any: shim, 2135 arrayOf: getShim, 2136 element: shim, 2137 elementType: shim, 2138 instanceOf: getShim, 2139 node: shim, 2140 objectOf: getShim, 2141 oneOf: getShim, 2142 oneOfType: getShim, 2143 shape: getShim, 2144 exact: getShim, 2145 2146 checkPropTypes: emptyFunctionWithReset, 2147 resetWarningCache: emptyFunction 2148 }; 2149 2150 ReactPropTypes.PropTypes = ReactPropTypes; 2151 2152 return ReactPropTypes; 2153 }; 2154 2155 2156 /***/ }), 2157 2158 /***/ 2652: 2159 /***/ (function(module, __unused_webpack_exports, __webpack_require__) { 2160 2161 /** 2162 * Copyright (c) 2013-present, Facebook, Inc. 2163 * 2164 * This source code is licensed under the MIT license found in the 2165 * LICENSE file in the root directory of this source tree. 2166 */ 2167 2168 if (false) { var throwOnDirectAccess, ReactIs; } else { 2169 // By explicitly using `prop-types` you are opting into new production behavior. 2170 // http://fb.me/prop-types-in-prod 2171 module.exports = __webpack_require__(5372)(); 2172 } 2173 2174 2175 /***/ }), 2176 2177 /***/ 9567: 2178 /***/ (function(module) { 2179 2180 "use strict"; 2181 /** 2182 * Copyright (c) 2013-present, Facebook, Inc. 2183 * 2184 * This source code is licensed under the MIT license found in the 2185 * LICENSE file in the root directory of this source tree. 2186 */ 2187 2188 2189 2190 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; 2191 2192 module.exports = ReactPropTypesSecret; 2193 2194 2195 /***/ }), 2196 2197 /***/ 5438: 2198 /***/ (function(__unused_webpack_module, exports, __webpack_require__) { 2199 2200 "use strict"; 2201 2202 var __extends = (this && this.__extends) || (function () { 2203 var extendStatics = Object.setPrototypeOf || 2204 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 2205 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 2206 return function (d, b) { 2207 extendStatics(d, b); 2208 function __() { this.constructor = d; } 2209 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 2210 }; 2211 })(); 2212 var __assign = (this && this.__assign) || Object.assign || function(t) { 2213 for (var s, i = 1, n = arguments.length; i < n; i++) { 2214 s = arguments[i]; 2215 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) 2216 t[p] = s[p]; 2217 } 2218 return t; 2219 }; 2220 var __rest = (this && this.__rest) || function (s, e) { 2221 var t = {}; 2222 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) 2223 t[p] = s[p]; 2224 if (s != null && typeof Object.getOwnPropertySymbols === "function") 2225 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) 2226 t[p[i]] = s[p[i]]; 2227 return t; 2228 }; 2229 exports.__esModule = true; 2230 var React = __webpack_require__(9196); 2231 var PropTypes = __webpack_require__(2652); 2232 var autosize = __webpack_require__(6411); 2233 var _getLineHeight = __webpack_require__(9894); 2234 var getLineHeight = _getLineHeight; 2235 var RESIZED = "autosize:resized"; 2236 /** 2237 * A light replacement for built-in textarea component 2238 * which automaticaly adjusts its height to match the content 2239 */ 2240 var TextareaAutosizeClass = /** @class */ (function (_super) { 2241 __extends(TextareaAutosizeClass, _super); 2242 function TextareaAutosizeClass() { 2243 var _this = _super !== null && _super.apply(this, arguments) || this; 2244 _this.state = { 2245 lineHeight: null 2246 }; 2247 _this.textarea = null; 2248 _this.onResize = function (e) { 2249 if (_this.props.onResize) { 2250 _this.props.onResize(e); 2251 } 2252 }; 2253 _this.updateLineHeight = function () { 2254 if (_this.textarea) { 2255 _this.setState({ 2256 lineHeight: getLineHeight(_this.textarea) 2257 }); 2258 } 2259 }; 2260 _this.onChange = function (e) { 2261 var onChange = _this.props.onChange; 2262 _this.currentValue = e.currentTarget.value; 2263 onChange && onChange(e); 2264 }; 2265 return _this; 2266 } 2267 TextareaAutosizeClass.prototype.componentDidMount = function () { 2268 var _this = this; 2269 var _a = this.props, maxRows = _a.maxRows, async = _a.async; 2270 if (typeof maxRows === "number") { 2271 this.updateLineHeight(); 2272 } 2273 if (typeof maxRows === "number" || async) { 2274 /* 2275 the defer is needed to: 2276 - force "autosize" to activate the scrollbar when this.props.maxRows is passed 2277 - support StyledComponents (see #71) 2278 */ 2279 setTimeout(function () { return _this.textarea && autosize(_this.textarea); }); 2280 } 2281 else { 2282 this.textarea && autosize(this.textarea); 2283 } 2284 if (this.textarea) { 2285 this.textarea.addEventListener(RESIZED, this.onResize); 2286 } 2287 }; 2288 TextareaAutosizeClass.prototype.componentWillUnmount = function () { 2289 if (this.textarea) { 2290 this.textarea.removeEventListener(RESIZED, this.onResize); 2291 autosize.destroy(this.textarea); 2292 } 2293 }; 2294 TextareaAutosizeClass.prototype.render = function () { 2295 var _this = this; 2296 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; 2297 var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null; 2298 return (React.createElement("textarea", __assign({}, props, { onChange: this.onChange, style: maxHeight ? __assign({}, style, { maxHeight: maxHeight }) : style, ref: function (element) { 2299 _this.textarea = element; 2300 if (typeof _this.props.innerRef === 'function') { 2301 _this.props.innerRef(element); 2302 } 2303 else if (_this.props.innerRef) { 2304 _this.props.innerRef.current = element; 2305 } 2306 } }), children)); 2307 }; 2308 TextareaAutosizeClass.prototype.componentDidUpdate = function () { 2309 this.textarea && autosize.update(this.textarea); 2310 }; 2311 TextareaAutosizeClass.defaultProps = { 2312 rows: 1, 2313 async: false 2314 }; 2315 TextareaAutosizeClass.propTypes = { 2316 rows: PropTypes.number, 2317 maxRows: PropTypes.number, 2318 onResize: PropTypes.func, 2319 innerRef: PropTypes.any, 2320 async: PropTypes.bool 2321 }; 2322 return TextareaAutosizeClass; 2323 }(React.Component)); 2324 exports.TextareaAutosize = React.forwardRef(function (props, ref) { 2325 return React.createElement(TextareaAutosizeClass, __assign({}, props, { innerRef: ref })); 2326 }); 2327 2328 2329 /***/ }), 2330 2331 /***/ 773: 2332 /***/ (function(__unused_webpack_module, exports, __webpack_require__) { 2333 2334 "use strict"; 2335 var __webpack_unused_export__; 2336 2337 __webpack_unused_export__ = true; 2338 var TextareaAutosize_1 = __webpack_require__(5438); 2339 exports.Z = TextareaAutosize_1.TextareaAutosize; 2340 2341 2342 /***/ }), 2343 2344 /***/ 3124: 2345 /***/ (function(module) { 2346 2347 var traverse = module.exports = function (obj) { 2348 return new Traverse(obj); 2349 }; 2350 2351 function Traverse (obj) { 2352 this.value = obj; 2353 } 2354 2355 Traverse.prototype.get = function (ps) { 2356 var node = this.value; 2357 for (var i = 0; i < ps.length; i ++) { 2358 var key = ps[i]; 2359 if (!node || !hasOwnProperty.call(node, key)) { 2360 node = undefined; 2361 break; 2362 } 2363 node = node[key]; 2364 } 2365 return node; 2366 }; 2367 2368 Traverse.prototype.has = function (ps) { 2369 var node = this.value; 2370 for (var i = 0; i < ps.length; i ++) { 2371 var key = ps[i]; 2372 if (!node || !hasOwnProperty.call(node, key)) { 2373 return false; 2374 } 2375 node = node[key]; 2376 } 2377 return true; 2378 }; 2379 2380 Traverse.prototype.set = function (ps, value) { 2381 var node = this.value; 2382 for (var i = 0; i < ps.length - 1; i ++) { 2383 var key = ps[i]; 2384 if (!hasOwnProperty.call(node, key)) node[key] = {}; 2385 node = node[key]; 2386 } 2387 node[ps[i]] = value; 2388 return value; 2389 }; 2390 2391 Traverse.prototype.map = function (cb) { 2392 return walk(this.value, cb, true); 2393 }; 2394 2395 Traverse.prototype.forEach = function (cb) { 2396 this.value = walk(this.value, cb, false); 2397 return this.value; 2398 }; 2399 2400 Traverse.prototype.reduce = function (cb, init) { 2401 var skip = arguments.length === 1; 2402 var acc = skip ? this.value : init; 2403 this.forEach(function (x) { 2404 if (!this.isRoot || !skip) { 2405 acc = cb.call(this, acc, x); 2406 } 2407 }); 2408 return acc; 2409 }; 2410 2411 Traverse.prototype.paths = function () { 2412 var acc = []; 2413 this.forEach(function (x) { 2414 acc.push(this.path); 2415 }); 2416 return acc; 2417 }; 2418 2419 Traverse.prototype.nodes = function () { 2420 var acc = []; 2421 this.forEach(function (x) { 2422 acc.push(this.node); 2423 }); 2424 return acc; 2425 }; 2426 2427 Traverse.prototype.clone = function () { 2428 var parents = [], nodes = []; 2429 2430 return (function clone (src) { 2431 for (var i = 0; i < parents.length; i++) { 2432 if (parents[i] === src) { 2433 return nodes[i]; 2434 } 2435 } 2436 2437 if (typeof src === 'object' && src !== null) { 2438 var dst = copy(src); 2439 2440 parents.push(src); 2441 nodes.push(dst); 2442 2443 forEach(objectKeys(src), function (key) { 2444 dst[key] = clone(src[key]); 2445 }); 2446 2447 parents.pop(); 2448 nodes.pop(); 2449 return dst; 2450 } 2451 else { 2452 return src; 2453 } 2454 })(this.value); 2455 }; 2456 2457 function walk (root, cb, immutable) { 2458 var path = []; 2459 var parents = []; 2460 var alive = true; 2461 2462 return (function walker (node_) { 2463 var node = immutable ? copy(node_) : node_; 2464 var modifiers = {}; 2465 2466 var keepGoing = true; 2467 2468 var state = { 2469 node : node, 2470 node_ : node_, 2471 path : [].concat(path), 2472 parent : parents[parents.length - 1], 2473 parents : parents, 2474 key : path.slice(-1)[0], 2475 isRoot : path.length === 0, 2476 level : path.length, 2477 circular : null, 2478 update : function (x, stopHere) { 2479 if (!state.isRoot) { 2480 state.parent.node[state.key] = x; 2481 } 2482 state.node = x; 2483 if (stopHere) keepGoing = false; 2484 }, 2485 'delete' : function (stopHere) { 2486 delete state.parent.node[state.key]; 2487 if (stopHere) keepGoing = false; 2488 }, 2489 remove : function (stopHere) { 2490 if (isArray(state.parent.node)) { 2491 state.parent.node.splice(state.key, 1); 2492 } 2493 else { 2494 delete state.parent.node[state.key]; 2495 } 2496 if (stopHere) keepGoing = false; 2497 }, 2498 keys : null, 2499 before : function (f) { modifiers.before = f }, 2500 after : function (f) { modifiers.after = f }, 2501 pre : function (f) { modifiers.pre = f }, 2502 post : function (f) { modifiers.post = f }, 2503 stop : function () { alive = false }, 2504 block : function () { keepGoing = false } 2505 }; 2506 2507 if (!alive) return state; 2508 2509 function updateState() { 2510 if (typeof state.node === 'object' && state.node !== null) { 2511 if (!state.keys || state.node_ !== state.node) { 2512 state.keys = objectKeys(state.node) 2513 } 2514 2515 state.isLeaf = state.keys.length == 0; 2516 2517 for (var i = 0; i < parents.length; i++) { 2518 if (parents[i].node_ === node_) { 2519 state.circular = parents[i]; 2520 break; 2521 } 2522 } 2523 } 2524 else { 2525 state.isLeaf = true; 2526 state.keys = null; 2527 } 2528 2529 state.notLeaf = !state.isLeaf; 2530 state.notRoot = !state.isRoot; 2531 } 2532 2533 updateState(); 2534 2535 // use return values to update if defined 2536 var ret = cb.call(state, state.node); 2537 if (ret !== undefined && state.update) state.update(ret); 2538 2539 if (modifiers.before) modifiers.before.call(state, state.node); 2540 2541 if (!keepGoing) return state; 2542 2543 if (typeof state.node == 'object' 2544 && state.node !== null && !state.circular) { 2545 parents.push(state); 2546 2547 updateState(); 2548 2549 forEach(state.keys, function (key, i) { 2550 path.push(key); 2551 2552 if (modifiers.pre) modifiers.pre.call(state, state.node[key], key); 2553 2554 var child = walker(state.node[key]); 2555 if (immutable && hasOwnProperty.call(state.node, key)) { 2556 state.node[key] = child.node; 2557 } 2558 2559 child.isLast = i == state.keys.length - 1; 2560 child.isFirst = i == 0; 2561 2562 if (modifiers.post) modifiers.post.call(state, child); 2563 2564 path.pop(); 2565 }); 2566 parents.pop(); 2567 } 2568 2569 if (modifiers.after) modifiers.after.call(state, state.node); 2570 2571 return state; 2572 })(root).node; 2573 } 2574 2575 function copy (src) { 2576 if (typeof src === 'object' && src !== null) { 2577 var dst; 2578 2579 if (isArray(src)) { 2580 dst = []; 2581 } 2582 else if (isDate(src)) { 2583 dst = new Date(src.getTime ? src.getTime() : src); 2584 } 2585 else if (isRegExp(src)) { 2586 dst = new RegExp(src); 2587 } 2588 else if (isError(src)) { 2589 dst = { message: src.message }; 2590 } 2591 else if (isBoolean(src)) { 2592 dst = new Boolean(src); 2593 } 2594 else if (isNumber(src)) { 2595 dst = new Number(src); 2596 } 2597 else if (isString(src)) { 2598 dst = new String(src); 2599 } 2600 else if (Object.create && Object.getPrototypeOf) { 2601 dst = Object.create(Object.getPrototypeOf(src)); 2602 } 2603 else if (src.constructor === Object) { 2604 dst = {}; 2605 } 2606 else { 2607 var proto = 2608 (src.constructor && src.constructor.prototype) 2609 || src.__proto__ 2610 || {} 2611 ; 2612 var T = function () {}; 2613 T.prototype = proto; 2614 dst = new T; 2615 } 2616 2617 forEach(objectKeys(src), function (key) { 2618 dst[key] = src[key]; 2619 }); 2620 return dst; 2621 } 2622 else return src; 2623 } 2624 2625 var objectKeys = Object.keys || function keys (obj) { 2626 var res = []; 2627 for (var key in obj) res.push(key) 2628 return res; 2629 }; 2630 2631 function toS (obj) { return Object.prototype.toString.call(obj) } 2632 function isDate (obj) { return toS(obj) === '[object Date]' } 2633 function isRegExp (obj) { return toS(obj) === '[object RegExp]' } 2634 function isError (obj) { return toS(obj) === '[object Error]' } 2635 function isBoolean (obj) { return toS(obj) === '[object Boolean]' } 2636 function isNumber (obj) { return toS(obj) === '[object Number]' } 2637 function isString (obj) { return toS(obj) === '[object String]' } 2638 2639 var isArray = Array.isArray || function isArray (xs) { 2640 return Object.prototype.toString.call(xs) === '[object Array]'; 2641 }; 2642 2643 var forEach = function (xs, fn) { 2644 if (xs.forEach) return xs.forEach(fn) 2645 else for (var i = 0; i < xs.length; i++) { 2646 fn(xs[i], i, xs); 2647 } 2648 }; 2649 2650 forEach(objectKeys(Traverse.prototype), function (key) { 2651 traverse[key] = function (obj) { 2652 var args = [].slice.call(arguments, 1); 2653 var t = new Traverse(obj); 2654 return t[key].apply(t, args); 2655 }; 2656 }); 2657 2658 var hasOwnProperty = Object.hasOwnProperty || function (obj, key) { 2659 return key in obj; 2660 }; 2661 2662 2663 /***/ }), 2664 2665 /***/ 9196: 2666 /***/ (function(module) { 2667 2668 "use strict"; 2669 module.exports = window["React"]; 2670 2671 /***/ }) 2672 2673 /******/ }); 2674 /************************************************************************/ 2675 /******/ // The module cache 2676 /******/ var __webpack_module_cache__ = {}; 2677 /******/ 2678 /******/ // The require function 2679 /******/ function __webpack_require__(moduleId) { 2680 /******/ // Check if module is in cache 2681 /******/ var cachedModule = __webpack_module_cache__[moduleId]; 2682 /******/ if (cachedModule !== undefined) { 2683 /******/ return cachedModule.exports; 2684 /******/ } 2685 /******/ // Create a new module (and put it into the cache) 2686 /******/ var module = __webpack_module_cache__[moduleId] = { 2687 /******/ // no module.id needed 2688 /******/ // no module.loaded needed 2689 /******/ exports: {} 2690 /******/ }; 2691 /******/ 2692 /******/ // Execute the module function 2693 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); 2694 /******/ 2695 /******/ // Return the exports of the module 2696 /******/ return module.exports; 2697 /******/ } 2698 /******/ 2699 /************************************************************************/ 2700 /******/ /* webpack/runtime/compat get default export */ 2701 /******/ !function() { 2702 /******/ // getDefaultExport function for compatibility with non-harmony modules 2703 /******/ __webpack_require__.n = function(module) { 2704 /******/ var getter = module && module.__esModule ? 2705 /******/ function() { return module['default']; } : 2706 /******/ function() { return module; }; 2707 /******/ __webpack_require__.d(getter, { a: getter }); 2708 /******/ return getter; 2709 /******/ }; 2710 /******/ }(); 2711 /******/ 2712 /******/ /* webpack/runtime/define property getters */ 2713 /******/ !function() { 2714 /******/ // define getter functions for harmony exports 2715 /******/ __webpack_require__.d = function(exports, definition) { 2716 /******/ for(var key in definition) { 2717 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 2718 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 2719 /******/ } 2720 /******/ } 2721 /******/ }; 2722 /******/ }(); 2723 /******/ 2724 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 2725 /******/ !function() { 2726 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } 2727 /******/ }(); 2728 /******/ 2729 /******/ /* webpack/runtime/make namespace object */ 2730 /******/ !function() { 2731 /******/ // define __esModule on exports 2732 /******/ __webpack_require__.r = function(exports) { 2733 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 2734 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 2735 /******/ } 2736 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 2737 /******/ }; 2738 /******/ }(); 2739 /******/ 2740 /************************************************************************/ 2741 var __webpack_exports__ = {}; 2742 // This entry need to be wrapped in an IIFE because it need to be in strict mode. 2743 !function() { 2744 "use strict"; 2745 // ESM COMPAT FLAG 2746 __webpack_require__.r(__webpack_exports__); 2747 2748 // EXPORTS 2749 __webpack_require__.d(__webpack_exports__, { 2750 "AlignmentControl": function() { return /* reexport */ AlignmentControl; }, 2751 "AlignmentToolbar": function() { return /* reexport */ AlignmentToolbar; }, 2752 "Autocomplete": function() { return /* reexport */ autocomplete; }, 2753 "BlockAlignmentControl": function() { return /* reexport */ BlockAlignmentControl; }, 2754 "BlockAlignmentToolbar": function() { return /* reexport */ BlockAlignmentToolbar; }, 2755 "BlockBreadcrumb": function() { return /* reexport */ block_breadcrumb; }, 2756 "BlockColorsStyleSelector": function() { return /* reexport */ color_style_selector; }, 2757 "BlockContextProvider": function() { return /* reexport */ BlockContextProvider; }, 2758 "BlockControls": function() { return /* reexport */ block_controls; }, 2759 "BlockEdit": function() { return /* reexport */ BlockEdit; }, 2760 "BlockEditorKeyboardShortcuts": function() { return /* reexport */ keyboard_shortcuts; }, 2761 "BlockEditorProvider": function() { return /* reexport */ provider; }, 2762 "BlockFormatControls": function() { return /* reexport */ BlockFormatControls; }, 2763 "BlockIcon": function() { return /* reexport */ block_icon; }, 2764 "BlockInspector": function() { return /* reexport */ block_inspector; }, 2765 "BlockList": function() { return /* reexport */ BlockList; }, 2766 "BlockMover": function() { return /* reexport */ block_mover; }, 2767 "BlockNavigationDropdown": function() { return /* reexport */ dropdown; }, 2768 "BlockPreview": function() { return /* reexport */ block_preview; }, 2769 "BlockSelectionClearer": function() { return /* reexport */ BlockSelectionClearer; }, 2770 "BlockSettingsMenu": function() { return /* reexport */ block_settings_menu; }, 2771 "BlockSettingsMenuControls": function() { return /* reexport */ block_settings_menu_controls; }, 2772 "BlockStyles": function() { return /* reexport */ block_styles; }, 2773 "BlockTitle": function() { return /* reexport */ BlockTitle; }, 2774 "BlockToolbar": function() { return /* reexport */ block_toolbar; }, 2775 "BlockTools": function() { return /* reexport */ BlockTools; }, 2776 "BlockVerticalAlignmentControl": function() { return /* reexport */ BlockVerticalAlignmentControl; }, 2777 "BlockVerticalAlignmentToolbar": function() { return /* reexport */ BlockVerticalAlignmentToolbar; }, 2778 "ButtonBlockAppender": function() { return /* reexport */ button_block_appender; }, 2779 "ButtonBlockerAppender": function() { return /* reexport */ ButtonBlockerAppender; }, 2780 "ColorPalette": function() { return /* reexport */ color_palette; }, 2781 "ColorPaletteControl": function() { return /* reexport */ ColorPaletteControl; }, 2782 "ContrastChecker": function() { return /* reexport */ contrast_checker; }, 2783 "CopyHandler": function() { return /* reexport */ copy_handler; }, 2784 "DefaultBlockAppender": function() { return /* reexport */ default_block_appender; }, 2785 "FontSizePicker": function() { return /* reexport */ font_size_picker; }, 2786 "InnerBlocks": function() { return /* reexport */ inner_blocks; }, 2787 "Inserter": function() { return /* reexport */ inserter; }, 2788 "InspectorAdvancedControls": function() { return /* reexport */ InspectorAdvancedControls; }, 2789 "InspectorControls": function() { return /* reexport */ inspector_controls; }, 2790 "JustifyContentControl": function() { return /* reexport */ JustifyContentControl; }, 2791 "JustifyToolbar": function() { return /* reexport */ JustifyToolbar; }, 2792 "LineHeightControl": function() { return /* reexport */ line_height_control; }, 2793 "MediaPlaceholder": function() { return /* reexport */ media_placeholder; }, 2794 "MediaReplaceFlow": function() { return /* reexport */ media_replace_flow; }, 2795 "MediaUpload": function() { return /* reexport */ media_upload; }, 2796 "MediaUploadCheck": function() { return /* reexport */ media_upload_check; }, 2797 "MultiSelectScrollIntoView": function() { return /* reexport */ MultiSelectScrollIntoView; }, 2798 "NavigableToolbar": function() { return /* reexport */ navigable_toolbar; }, 2799 "ObserveTyping": function() { return /* reexport */ observe_typing; }, 2800 "PanelColorSettings": function() { return /* reexport */ panel_color_settings; }, 2801 "PlainText": function() { return /* reexport */ plain_text; }, 2802 "RichText": function() { return /* reexport */ rich_text; }, 2803 "RichTextShortcut": function() { return /* reexport */ RichTextShortcut; }, 2804 "RichTextToolbarButton": function() { return /* reexport */ RichTextToolbarButton; }, 2805 "SETTINGS_DEFAULTS": function() { return /* reexport */ SETTINGS_DEFAULTS; }, 2806 "SkipToSelectedBlock": function() { return /* reexport */ skip_to_selected_block; }, 2807 "ToolSelector": function() { return /* reexport */ tool_selector; }, 2808 "Typewriter": function() { return /* reexport */ typewriter; }, 2809 "URLInput": function() { return /* reexport */ url_input; }, 2810 "URLInputButton": function() { return /* reexport */ url_input_button; }, 2811 "URLPopover": function() { return /* reexport */ url_popover; }, 2812 "Warning": function() { return /* reexport */ warning; }, 2813 "WritingFlow": function() { return /* reexport */ writing_flow; }, 2814 "__experimentalBlockAlignmentMatrixControl": function() { return /* reexport */ block_alignment_matrix_control; }, 2815 "__experimentalBlockContentOverlay": function() { return /* reexport */ BlockContentOverlay; }, 2816 "__experimentalBlockFullHeightAligmentControl": function() { return /* reexport */ block_full_height_alignment_control; }, 2817 "__experimentalBlockPatternSetup": function() { return /* reexport */ block_pattern_setup; }, 2818 "__experimentalBlockPatternsList": function() { return /* reexport */ block_patterns_list; }, 2819 "__experimentalBlockVariationPicker": function() { return /* reexport */ block_variation_picker; }, 2820 "__experimentalBlockVariationTransforms": function() { return /* reexport */ block_variation_transforms; }, 2821 "__experimentalBorderRadiusControl": function() { return /* reexport */ BorderRadiusControl; }, 2822 "__experimentalBorderStyleControl": function() { return /* reexport */ BorderStyleControl; }, 2823 "__experimentalColorGradientControl": function() { return /* reexport */ control; }, 2824 "__experimentalColorGradientSettingsDropdown": function() { return /* reexport */ ColorGradientSettingsDropdown; }, 2825 "__experimentalDateFormatPicker": function() { return /* reexport */ DateFormatPicker; }, 2826 "__experimentalDuotoneControl": function() { return /* reexport */ duotone_control; }, 2827 "__experimentalFontAppearanceControl": function() { return /* reexport */ FontAppearanceControl; }, 2828 "__experimentalFontFamilyControl": function() { return /* reexport */ FontFamilyControl; }, 2829 "__experimentalGetBorderClassesAndStyles": function() { return /* reexport */ getBorderClassesAndStyles; }, 2830 "__experimentalGetColorClassesAndStyles": function() { return /* reexport */ getColorClassesAndStyles; }, 2831 "__experimentalGetGradientClass": function() { return /* reexport */ __experimentalGetGradientClass; }, 2832 "__experimentalGetGradientObjectByGradientValue": function() { return /* reexport */ __experimentalGetGradientObjectByGradientValue; }, 2833 "__experimentalGetMatchingVariation": function() { return /* reexport */ __experimentalGetMatchingVariation; }, 2834 "__experimentalGetSpacingClassesAndStyles": function() { return /* reexport */ getSpacingClassesAndStyles; }, 2835 "__experimentalImageEditingProvider": function() { return /* reexport */ ImageEditingProvider; }, 2836 "__experimentalImageEditor": function() { return /* reexport */ ImageEditor; }, 2837 "__experimentalImageSizeControl": function() { return /* reexport */ ImageSizeControl; }, 2838 "__experimentalImageURLInputUI": function() { return /* reexport */ ImageURLInputUI; }, 2839 "__experimentalLayoutStyle": function() { return /* reexport */ LayoutStyle; }, 2840 "__experimentalLetterSpacingControl": function() { return /* reexport */ LetterSpacingControl; }, 2841 "__experimentalLibrary": function() { return /* reexport */ library; }, 2842 "__experimentalLinkControl": function() { return /* reexport */ link_control; }, 2843 "__experimentalLinkControlSearchInput": function() { return /* reexport */ search_input; }, 2844 "__experimentalLinkControlSearchItem": function() { return /* reexport */ search_item; }, 2845 "__experimentalLinkControlSearchResults": function() { return /* reexport */ LinkControlSearchResults; }, 2846 "__experimentalListView": function() { return /* reexport */ components_list_view; }, 2847 "__experimentalPanelColorGradientSettings": function() { return /* reexport */ panel_color_gradient_settings; }, 2848 "__experimentalPreviewOptions": function() { return /* reexport */ PreviewOptions; }, 2849 "__experimentalResponsiveBlockControl": function() { return /* reexport */ responsive_block_control; }, 2850 "__experimentalTextDecorationControl": function() { return /* reexport */ TextDecorationControl; }, 2851 "__experimentalTextTransformControl": function() { return /* reexport */ TextTransformControl; }, 2852 "__experimentalToolsPanelColorDropdown": function() { return /* reexport */ ToolsPanelColorDropdown; }, 2853 "__experimentalUnitControl": function() { return /* reexport */ UnitControl; }, 2854 "__experimentalUseBlockPreview": function() { return /* reexport */ useBlockPreview; }, 2855 "__experimentalUseBorderProps": function() { return /* reexport */ useBorderProps; }, 2856 "__experimentalUseColorProps": function() { return /* reexport */ useColorProps; }, 2857 "__experimentalUseCustomSides": function() { return /* reexport */ useCustomSides; }, 2858 "__experimentalUseGradient": function() { return /* reexport */ __experimentalUseGradient; }, 2859 "__experimentalUseNoRecursiveRenders": function() { return /* reexport */ useNoRecursiveRenders; }, 2860 "__experimentalUseResizeCanvas": function() { return /* reexport */ useResizeCanvas; }, 2861 "__unstableBlockNameContext": function() { return /* reexport */ block_name_context; }, 2862 "__unstableBlockSettingsMenuFirstItem": function() { return /* reexport */ block_settings_menu_first_item; }, 2863 "__unstableBlockToolbarLastItem": function() { return /* reexport */ block_toolbar_last_item; }, 2864 "__unstableEditorStyles": function() { return /* reexport */ EditorStyles; }, 2865 "__unstableIframe": function() { return /* reexport */ iframe; }, 2866 "__unstableInserterMenuExtension": function() { return /* reexport */ inserter_menu_extension; }, 2867 "__unstablePresetDuotoneFilter": function() { return /* reexport */ PresetDuotoneFilter; }, 2868 "__unstableRichTextInputEvent": function() { return /* reexport */ __unstableRichTextInputEvent; }, 2869 "__unstableUseBlockSelectionClearer": function() { return /* reexport */ useBlockSelectionClearer; }, 2870 "__unstableUseClipboardHandler": function() { return /* reexport */ useClipboardHandler; }, 2871 "__unstableUseMouseMoveTypingReset": function() { return /* reexport */ useMouseMoveTypingReset; }, 2872 "__unstableUseTypewriter": function() { return /* reexport */ useTypewriter; }, 2873 "__unstableUseTypingObserver": function() { return /* reexport */ useTypingObserver; }, 2874 "createCustomColorsHOC": function() { return /* reexport */ createCustomColorsHOC; }, 2875 "getColorClassName": function() { return /* reexport */ getColorClassName; }, 2876 "getColorObjectByAttributeValues": function() { return /* reexport */ getColorObjectByAttributeValues; }, 2877 "getColorObjectByColorValue": function() { return /* reexport */ getColorObjectByColorValue; }, 2878 "getFontSize": function() { return /* reexport */ getFontSize; }, 2879 "getFontSizeClass": function() { return /* reexport */ getFontSizeClass; }, 2880 "getFontSizeObjectByValue": function() { return /* reexport */ getFontSizeObjectByValue; }, 2881 "getGradientSlugByValue": function() { return /* reexport */ getGradientSlugByValue; }, 2882 "getGradientValueBySlug": function() { return /* reexport */ getGradientValueBySlug; }, 2883 "getPxFromCssUnit": function() { return /* reexport */ parse_css_unit_to_px; }, 2884 "store": function() { return /* reexport */ store; }, 2885 "storeConfig": function() { return /* reexport */ storeConfig; }, 2886 "transformStyles": function() { return /* reexport */ transform_styles; }, 2887 "useBlockDisplayInformation": function() { return /* reexport */ useBlockDisplayInformation; }, 2888 "useBlockEditContext": function() { return /* reexport */ useBlockEditContext; }, 2889 "useBlockProps": function() { return /* reexport */ useBlockProps; }, 2890 "useCachedTruthy": function() { return /* reexport */ useCachedTruthy; }, 2891 "useInnerBlocksProps": function() { return /* reexport */ useInnerBlocksProps; }, 2892 "useSetting": function() { return /* reexport */ useSetting; }, 2893 "withColorContext": function() { return /* reexport */ with_color_context; }, 2894 "withColors": function() { return /* reexport */ withColors; }, 2895 "withFontSizes": function() { return /* reexport */ with_font_sizes; } 2896 }); 2897 2898 // NAMESPACE OBJECT: ./node_modules/@wordpress/block-editor/build-module/store/selectors.js 2899 var selectors_namespaceObject = {}; 2900 __webpack_require__.r(selectors_namespaceObject); 2901 __webpack_require__.d(selectors_namespaceObject, { 2902 "__experimentalGetActiveBlockIdByBlockNames": function() { return __experimentalGetActiveBlockIdByBlockNames; }, 2903 "__experimentalGetAllowedBlocks": function() { return __experimentalGetAllowedBlocks; }, 2904 "__experimentalGetAllowedPatterns": function() { return __experimentalGetAllowedPatterns; }, 2905 "__experimentalGetBlockListSettingsForBlocks": function() { return __experimentalGetBlockListSettingsForBlocks; }, 2906 "__experimentalGetDirectInsertBlock": function() { return __experimentalGetDirectInsertBlock; }, 2907 "__experimentalGetGlobalBlocksByName": function() { return __experimentalGetGlobalBlocksByName; }, 2908 "__experimentalGetLastBlockAttributeChanges": function() { return __experimentalGetLastBlockAttributeChanges; }, 2909 "__experimentalGetParsedPattern": function() { return __experimentalGetParsedPattern; }, 2910 "__experimentalGetPatternTransformItems": function() { return __experimentalGetPatternTransformItems; }, 2911 "__experimentalGetPatternsByBlockTypes": function() { return __experimentalGetPatternsByBlockTypes; }, 2912 "__experimentalGetReusableBlockTitle": function() { return __experimentalGetReusableBlockTitle; }, 2913 "__unstableGetBlockWithoutInnerBlocks": function() { return __unstableGetBlockWithoutInnerBlocks; }, 2914 "__unstableGetClientIdWithClientIdsTree": function() { return __unstableGetClientIdWithClientIdsTree; }, 2915 "__unstableGetClientIdsTree": function() { return __unstableGetClientIdsTree; }, 2916 "__unstableGetSelectedBlocksWithPartialSelection": function() { return __unstableGetSelectedBlocksWithPartialSelection; }, 2917 "__unstableIsFullySelected": function() { return __unstableIsFullySelected; }, 2918 "__unstableIsLastBlockChangeIgnored": function() { return __unstableIsLastBlockChangeIgnored; }, 2919 "__unstableIsSelectionCollapsed": function() { return __unstableIsSelectionCollapsed; }, 2920 "__unstableIsSelectionMergeable": function() { return __unstableIsSelectionMergeable; }, 2921 "areInnerBlocksControlled": function() { return areInnerBlocksControlled; }, 2922 "canInsertBlockType": function() { return canInsertBlockType; }, 2923 "canInsertBlocks": function() { return canInsertBlocks; }, 2924 "canLockBlockType": function() { return canLockBlockType; }, 2925 "canMoveBlock": function() { return canMoveBlock; }, 2926 "canMoveBlocks": function() { return canMoveBlocks; }, 2927 "canRemoveBlock": function() { return canRemoveBlock; }, 2928 "canRemoveBlocks": function() { return canRemoveBlocks; }, 2929 "didAutomaticChange": function() { return didAutomaticChange; }, 2930 "getAdjacentBlockClientId": function() { return getAdjacentBlockClientId; }, 2931 "getBlock": function() { return getBlock; }, 2932 "getBlockAttributes": function() { return getBlockAttributes; }, 2933 "getBlockCount": function() { return getBlockCount; }, 2934 "getBlockHierarchyRootClientId": function() { return getBlockHierarchyRootClientId; }, 2935 "getBlockIndex": function() { return getBlockIndex; }, 2936 "getBlockInsertionPoint": function() { return getBlockInsertionPoint; }, 2937 "getBlockListSettings": function() { return getBlockListSettings; }, 2938 "getBlockMode": function() { return getBlockMode; }, 2939 "getBlockName": function() { return getBlockName; }, 2940 "getBlockOrder": function() { return getBlockOrder; }, 2941 "getBlockParents": function() { return getBlockParents; }, 2942 "getBlockParentsByBlockName": function() { return getBlockParentsByBlockName; }, 2943 "getBlockRootClientId": function() { return getBlockRootClientId; }, 2944 "getBlockSelectionEnd": function() { return getBlockSelectionEnd; }, 2945 "getBlockSelectionStart": function() { return getBlockSelectionStart; }, 2946 "getBlockTransformItems": function() { return getBlockTransformItems; }, 2947 "getBlocks": function() { return getBlocks; }, 2948 "getBlocksByClientId": function() { return getBlocksByClientId; }, 2949 "getClientIdsOfDescendants": function() { return getClientIdsOfDescendants; }, 2950 "getClientIdsWithDescendants": function() { return getClientIdsWithDescendants; }, 2951 "getDraggedBlockClientIds": function() { return getDraggedBlockClientIds; }, 2952 "getFirstMultiSelectedBlockClientId": function() { return getFirstMultiSelectedBlockClientId; }, 2953 "getGlobalBlockCount": function() { return getGlobalBlockCount; }, 2954 "getInserterItems": function() { return getInserterItems; }, 2955 "getLastMultiSelectedBlockClientId": function() { return getLastMultiSelectedBlockClientId; }, 2956 "getLowestCommonAncestorWithSelectedBlock": function() { return getLowestCommonAncestorWithSelectedBlock; }, 2957 "getMultiSelectedBlockClientIds": function() { return getMultiSelectedBlockClientIds; }, 2958 "getMultiSelectedBlocks": function() { return getMultiSelectedBlocks; }, 2959 "getMultiSelectedBlocksEndClientId": function() { return getMultiSelectedBlocksEndClientId; }, 2960 "getMultiSelectedBlocksStartClientId": function() { return getMultiSelectedBlocksStartClientId; }, 2961 "getNextBlockClientId": function() { return getNextBlockClientId; }, 2962 "getPreviousBlockClientId": function() { return getPreviousBlockClientId; }, 2963 "getSelectedBlock": function() { return getSelectedBlock; }, 2964 "getSelectedBlockClientId": function() { return getSelectedBlockClientId; }, 2965 "getSelectedBlockClientIds": function() { return getSelectedBlockClientIds; }, 2966 "getSelectedBlockCount": function() { return getSelectedBlockCount; }, 2967 "getSelectedBlocksInitialCaretPosition": function() { return getSelectedBlocksInitialCaretPosition; }, 2968 "getSelectionEnd": function() { return getSelectionEnd; }, 2969 "getSelectionStart": function() { return getSelectionStart; }, 2970 "getSettings": function() { return getSettings; }, 2971 "getTemplate": function() { return getTemplate; }, 2972 "getTemplateLock": function() { return getTemplateLock; }, 2973 "hasBlockMovingClientId": function() { return selectors_hasBlockMovingClientId; }, 2974 "hasInserterItems": function() { return hasInserterItems; }, 2975 "hasMultiSelection": function() { return hasMultiSelection; }, 2976 "hasSelectedBlock": function() { return hasSelectedBlock; }, 2977 "hasSelectedInnerBlock": function() { return hasSelectedInnerBlock; }, 2978 "isAncestorBeingDragged": function() { return isAncestorBeingDragged; }, 2979 "isAncestorMultiSelected": function() { return isAncestorMultiSelected; }, 2980 "isBlockBeingDragged": function() { return isBlockBeingDragged; }, 2981 "isBlockHighlighted": function() { return isBlockHighlighted; }, 2982 "isBlockInsertionPointVisible": function() { return isBlockInsertionPointVisible; }, 2983 "isBlockMultiSelected": function() { return isBlockMultiSelected; }, 2984 "isBlockSelected": function() { return isBlockSelected; }, 2985 "isBlockValid": function() { return isBlockValid; }, 2986 "isBlockWithinSelection": function() { return isBlockWithinSelection; }, 2987 "isCaretWithinFormattedText": function() { return selectors_isCaretWithinFormattedText; }, 2988 "isDraggingBlocks": function() { return isDraggingBlocks; }, 2989 "isFirstMultiSelectedBlock": function() { return isFirstMultiSelectedBlock; }, 2990 "isLastBlockChangePersistent": function() { return isLastBlockChangePersistent; }, 2991 "isMultiSelecting": function() { return selectors_isMultiSelecting; }, 2992 "isNavigationMode": function() { return selectors_isNavigationMode; }, 2993 "isSelectionEnabled": function() { return selectors_isSelectionEnabled; }, 2994 "isTyping": function() { return selectors_isTyping; }, 2995 "isValidTemplate": function() { return isValidTemplate; }, 2996 "wasBlockJustInserted": function() { return wasBlockJustInserted; } 2997 }); 2998 2999 // NAMESPACE OBJECT: ./node_modules/@wordpress/block-editor/build-module/store/actions.js 3000 var actions_namespaceObject = {}; 3001 __webpack_require__.r(actions_namespaceObject); 3002 __webpack_require__.d(actions_namespaceObject, { 3003 "__unstableDeleteSelection": function() { return __unstableDeleteSelection; }, 3004 "__unstableExpandSelection": function() { return __unstableExpandSelection; }, 3005 "__unstableMarkAutomaticChange": function() { return __unstableMarkAutomaticChange; }, 3006 "__unstableMarkLastChangeAsPersistent": function() { return __unstableMarkLastChangeAsPersistent; }, 3007 "__unstableMarkNextChangeAsNotPersistent": function() { return __unstableMarkNextChangeAsNotPersistent; }, 3008 "__unstableSaveReusableBlock": function() { return __unstableSaveReusableBlock; }, 3009 "__unstableSplitSelection": function() { return __unstableSplitSelection; }, 3010 "clearSelectedBlock": function() { return clearSelectedBlock; }, 3011 "duplicateBlocks": function() { return duplicateBlocks; }, 3012 "enterFormattedText": function() { return enterFormattedText; }, 3013 "exitFormattedText": function() { return exitFormattedText; }, 3014 "flashBlock": function() { return flashBlock; }, 3015 "hideInsertionPoint": function() { return hideInsertionPoint; }, 3016 "insertAfterBlock": function() { return insertAfterBlock; }, 3017 "insertBeforeBlock": function() { return insertBeforeBlock; }, 3018 "insertBlock": function() { return insertBlock; }, 3019 "insertBlocks": function() { return insertBlocks; }, 3020 "insertDefaultBlock": function() { return insertDefaultBlock; }, 3021 "mergeBlocks": function() { return mergeBlocks; }, 3022 "moveBlockToPosition": function() { return moveBlockToPosition; }, 3023 "moveBlocksDown": function() { return moveBlocksDown; }, 3024 "moveBlocksToPosition": function() { return moveBlocksToPosition; }, 3025 "moveBlocksUp": function() { return moveBlocksUp; }, 3026 "multiSelect": function() { return multiSelect; }, 3027 "receiveBlocks": function() { return receiveBlocks; }, 3028 "removeBlock": function() { return removeBlock; }, 3029 "removeBlocks": function() { return removeBlocks; }, 3030 "replaceBlock": function() { return replaceBlock; }, 3031 "replaceBlocks": function() { return replaceBlocks; }, 3032 "replaceInnerBlocks": function() { return replaceInnerBlocks; }, 3033 "resetBlocks": function() { return resetBlocks; }, 3034 "resetSelection": function() { return resetSelection; }, 3035 "selectBlock": function() { return selectBlock; }, 3036 "selectNextBlock": function() { return selectNextBlock; }, 3037 "selectPreviousBlock": function() { return selectPreviousBlock; }, 3038 "selectionChange": function() { return selectionChange; }, 3039 "setBlockMovingClientId": function() { return setBlockMovingClientId; }, 3040 "setHasControlledInnerBlocks": function() { return setHasControlledInnerBlocks; }, 3041 "setNavigationMode": function() { return setNavigationMode; }, 3042 "setTemplateValidity": function() { return setTemplateValidity; }, 3043 "showInsertionPoint": function() { return showInsertionPoint; }, 3044 "startDraggingBlocks": function() { return startDraggingBlocks; }, 3045 "startMultiSelect": function() { return startMultiSelect; }, 3046 "startTyping": function() { return startTyping; }, 3047 "stopDraggingBlocks": function() { return stopDraggingBlocks; }, 3048 "stopMultiSelect": function() { return stopMultiSelect; }, 3049 "stopTyping": function() { return stopTyping; }, 3050 "synchronizeTemplate": function() { return synchronizeTemplate; }, 3051 "toggleBlockHighlight": function() { return toggleBlockHighlight; }, 3052 "toggleBlockMode": function() { return toggleBlockMode; }, 3053 "toggleSelection": function() { return toggleSelection; }, 3054 "updateBlock": function() { return updateBlock; }, 3055 "updateBlockAttributes": function() { return updateBlockAttributes; }, 3056 "updateBlockListSettings": function() { return updateBlockListSettings; }, 3057 "updateSettings": function() { return updateSettings; }, 3058 "validateBlocksToTemplate": function() { return validateBlocksToTemplate; } 3059 }); 3060 3061 ;// CONCATENATED MODULE: external ["wp","blocks"] 3062 var external_wp_blocks_namespaceObject = window["wp"]["blocks"]; 3063 ;// CONCATENATED MODULE: external ["wp","hooks"] 3064 var external_wp_hooks_namespaceObject = window["wp"]["hooks"]; 3065 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/compat.js 3066 /** 3067 * WordPress dependencies 3068 */ 3069 3070 3071 3072 function migrateLightBlockWrapper(settings) { 3073 const { 3074 apiVersion = 1 3075 } = settings; 3076 3077 if (apiVersion < 2 && (0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'lightBlockWrapper', false)) { 3078 settings.apiVersion = 2; 3079 } 3080 3081 return settings; 3082 } 3083 3084 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/compat/migrateLightBlockWrapper', migrateLightBlockWrapper); 3085 3086 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js 3087 function _extends() { 3088 _extends = Object.assign || function (target) { 3089 for (var i = 1; i < arguments.length; i++) { 3090 var source = arguments[i]; 3091 3092 for (var key in source) { 3093 if (Object.prototype.hasOwnProperty.call(source, key)) { 3094 target[key] = source[key]; 3095 } 3096 } 3097 } 3098 3099 return target; 3100 }; 3101 3102 return _extends.apply(this, arguments); 3103 } 3104 ;// CONCATENATED MODULE: external ["wp","element"] 3105 var external_wp_element_namespaceObject = window["wp"]["element"]; 3106 // EXTERNAL MODULE: ./node_modules/classnames/index.js 3107 var classnames = __webpack_require__(4403); 3108 var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames); 3109 ;// CONCATENATED MODULE: external "lodash" 3110 var external_lodash_namespaceObject = window["lodash"]; 3111 ;// CONCATENATED MODULE: external ["wp","compose"] 3112 var external_wp_compose_namespaceObject = window["wp"]["compose"]; 3113 ;// CONCATENATED MODULE: external ["wp","components"] 3114 var external_wp_components_namespaceObject = window["wp"]["components"]; 3115 ;// CONCATENATED MODULE: external ["wp","data"] 3116 var external_wp_data_namespaceObject = window["wp"]["data"]; 3117 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/groups.js 3118 /** 3119 * WordPress dependencies 3120 */ 3121 3122 const BlockControlsDefault = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControls'); 3123 const BlockControlsBlock = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControlsBlock'); 3124 const BlockControlsInline = (0,external_wp_components_namespaceObject.createSlotFill)('BlockFormatControls'); 3125 const BlockControlsOther = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControlsOther'); 3126 const BlockControlsParent = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControlsParent'); 3127 const groups = { 3128 default: BlockControlsDefault, 3129 block: BlockControlsBlock, 3130 inline: BlockControlsInline, 3131 other: BlockControlsOther, 3132 parent: BlockControlsParent 3133 }; 3134 /* harmony default export */ var block_controls_groups = (groups); 3135 3136 ;// CONCATENATED MODULE: external ["wp","i18n"] 3137 var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; 3138 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/defaults.js 3139 /** 3140 * WordPress dependencies 3141 */ 3142 3143 const PREFERENCES_DEFAULTS = { 3144 insertUsage: {} 3145 }; 3146 /** 3147 * The default editor settings 3148 * 3149 * @typedef {Object} SETTINGS_DEFAULT 3150 * @property {boolean} alignWide Enable/Disable Wide/Full Alignments 3151 * @property {boolean} supportsLayout Enable/disable layouts support in container blocks. 3152 * @property {boolean} imageEditing Image Editing settings set to false to disable. 3153 * @property {Array} imageSizes Available image sizes 3154 * @property {number} maxWidth Max width to constraint resizing 3155 * @property {boolean|Array} allowedBlockTypes Allowed block types 3156 * @property {boolean} hasFixedToolbar Whether or not the editor toolbar is fixed 3157 * @property {boolean} focusMode Whether the focus mode is enabled or not 3158 * @property {Array} styles Editor Styles 3159 * @property {boolean} keepCaretInsideBlock Whether caret should move between blocks in edit mode 3160 * @property {string} bodyPlaceholder Empty post placeholder 3161 * @property {string} titlePlaceholder Empty title placeholder 3162 * @property {boolean} canLockBlocks Whether the user can manage Block Lock state 3163 * @property {boolean} codeEditingEnabled Whether or not the user can switch to the code editor 3164 * @property {boolean} generateAnchors Enable/Disable auto anchor generation for Heading blocks 3165 * @property {boolean} __experimentalCanUserUseUnfilteredHTML Whether the user should be able to use unfiltered HTML or the HTML should be filtered e.g., to remove elements considered insecure like iframes. 3166 * @property {boolean} __experimentalBlockDirectory Whether the user has enabled the Block Directory 3167 * @property {Array} __experimentalBlockPatterns Array of objects representing the block patterns 3168 * @property {Array} __experimentalBlockPatternCategories Array of objects representing the block pattern categories 3169 * @property {boolean} __unstableGalleryWithImageBlocks Whether the user has enabled the refactored gallery block which uses InnerBlocks 3170 */ 3171 3172 const SETTINGS_DEFAULTS = { 3173 alignWide: false, 3174 supportsLayout: true, 3175 // colors setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults. 3176 // The setting is only kept for backward compatibility purposes. 3177 colors: [{ 3178 name: (0,external_wp_i18n_namespaceObject.__)('Black'), 3179 slug: 'black', 3180 color: '#000000' 3181 }, { 3182 name: (0,external_wp_i18n_namespaceObject.__)('Cyan bluish gray'), 3183 slug: 'cyan-bluish-gray', 3184 color: '#abb8c3' 3185 }, { 3186 name: (0,external_wp_i18n_namespaceObject.__)('White'), 3187 slug: 'white', 3188 color: '#ffffff' 3189 }, { 3190 name: (0,external_wp_i18n_namespaceObject.__)('Pale pink'), 3191 slug: 'pale-pink', 3192 color: '#f78da7' 3193 }, { 3194 name: (0,external_wp_i18n_namespaceObject.__)('Vivid red'), 3195 slug: 'vivid-red', 3196 color: '#cf2e2e' 3197 }, { 3198 name: (0,external_wp_i18n_namespaceObject.__)('Luminous vivid orange'), 3199 slug: 'luminous-vivid-orange', 3200 color: '#ff6900' 3201 }, { 3202 name: (0,external_wp_i18n_namespaceObject.__)('Luminous vivid amber'), 3203 slug: 'luminous-vivid-amber', 3204 color: '#fcb900' 3205 }, { 3206 name: (0,external_wp_i18n_namespaceObject.__)('Light green cyan'), 3207 slug: 'light-green-cyan', 3208 color: '#7bdcb5' 3209 }, { 3210 name: (0,external_wp_i18n_namespaceObject.__)('Vivid green cyan'), 3211 slug: 'vivid-green-cyan', 3212 color: '#00d084' 3213 }, { 3214 name: (0,external_wp_i18n_namespaceObject.__)('Pale cyan blue'), 3215 slug: 'pale-cyan-blue', 3216 color: '#8ed1fc' 3217 }, { 3218 name: (0,external_wp_i18n_namespaceObject.__)('Vivid cyan blue'), 3219 slug: 'vivid-cyan-blue', 3220 color: '#0693e3' 3221 }, { 3222 name: (0,external_wp_i18n_namespaceObject.__)('Vivid purple'), 3223 slug: 'vivid-purple', 3224 color: '#9b51e0' 3225 }], 3226 // fontSizes setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults. 3227 // The setting is only kept for backward compatibility purposes. 3228 fontSizes: [{ 3229 name: (0,external_wp_i18n_namespaceObject._x)('Small', 'font size name'), 3230 size: 13, 3231 slug: 'small' 3232 }, { 3233 name: (0,external_wp_i18n_namespaceObject._x)('Normal', 'font size name'), 3234 size: 16, 3235 slug: 'normal' 3236 }, { 3237 name: (0,external_wp_i18n_namespaceObject._x)('Medium', 'font size name'), 3238 size: 20, 3239 slug: 'medium' 3240 }, { 3241 name: (0,external_wp_i18n_namespaceObject._x)('Large', 'font size name'), 3242 size: 36, 3243 slug: 'large' 3244 }, { 3245 name: (0,external_wp_i18n_namespaceObject._x)('Huge', 'font size name'), 3246 size: 42, 3247 slug: 'huge' 3248 }], 3249 // Image default size slug. 3250 imageDefaultSize: 'large', 3251 imageSizes: [{ 3252 slug: 'thumbnail', 3253 name: (0,external_wp_i18n_namespaceObject.__)('Thumbnail') 3254 }, { 3255 slug: 'medium', 3256 name: (0,external_wp_i18n_namespaceObject.__)('Medium') 3257 }, { 3258 slug: 'large', 3259 name: (0,external_wp_i18n_namespaceObject.__)('Large') 3260 }, { 3261 slug: 'full', 3262 name: (0,external_wp_i18n_namespaceObject.__)('Full Size') 3263 }], 3264 // Allow plugin to disable Image Editor if need be. 3265 imageEditing: true, 3266 // This is current max width of the block inner area 3267 // It's used to constraint image resizing and this value could be overridden later by themes 3268 maxWidth: 580, 3269 // Allowed block types for the editor, defaulting to true (all supported). 3270 allowedBlockTypes: true, 3271 // Maximum upload size in bytes allowed for the site. 3272 maxUploadFileSize: 0, 3273 // List of allowed mime types and file extensions. 3274 allowedMimeTypes: null, 3275 // Allows to disable block locking interface. 3276 canLockBlocks: true, 3277 __experimentalCanUserUseUnfilteredHTML: false, 3278 __experimentalBlockDirectory: false, 3279 __mobileEnablePageTemplates: false, 3280 __experimentalBlockPatterns: [], 3281 __experimentalBlockPatternCategories: [], 3282 __experimentalSpotlightEntityBlocks: [], 3283 __unstableGalleryWithImageBlocks: false, 3284 generateAnchors: false, 3285 // gradients setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults. 3286 // The setting is only kept for backward compatibility purposes. 3287 gradients: [{ 3288 name: (0,external_wp_i18n_namespaceObject.__)('Vivid cyan blue to vivid purple'), 3289 gradient: 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', 3290 slug: 'vivid-cyan-blue-to-vivid-purple' 3291 }, { 3292 name: (0,external_wp_i18n_namespaceObject.__)('Light green cyan to vivid green cyan'), 3293 gradient: 'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)', 3294 slug: 'light-green-cyan-to-vivid-green-cyan' 3295 }, { 3296 name: (0,external_wp_i18n_namespaceObject.__)('Luminous vivid amber to luminous vivid orange'), 3297 gradient: 'linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%)', 3298 slug: 'luminous-vivid-amber-to-luminous-vivid-orange' 3299 }, { 3300 name: (0,external_wp_i18n_namespaceObject.__)('Luminous vivid orange to vivid red'), 3301 gradient: 'linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%)', 3302 slug: 'luminous-vivid-orange-to-vivid-red' 3303 }, { 3304 name: (0,external_wp_i18n_namespaceObject.__)('Very light gray to cyan bluish gray'), 3305 gradient: 'linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%)', 3306 slug: 'very-light-gray-to-cyan-bluish-gray' 3307 }, { 3308 name: (0,external_wp_i18n_namespaceObject.__)('Cool to warm spectrum'), 3309 gradient: 'linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%)', 3310 slug: 'cool-to-warm-spectrum' 3311 }, { 3312 name: (0,external_wp_i18n_namespaceObject.__)('Blush light purple'), 3313 gradient: 'linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%)', 3314 slug: 'blush-light-purple' 3315 }, { 3316 name: (0,external_wp_i18n_namespaceObject.__)('Blush bordeaux'), 3317 gradient: 'linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%)', 3318 slug: 'blush-bordeaux' 3319 }, { 3320 name: (0,external_wp_i18n_namespaceObject.__)('Luminous dusk'), 3321 gradient: 'linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%)', 3322 slug: 'luminous-dusk' 3323 }, { 3324 name: (0,external_wp_i18n_namespaceObject.__)('Pale ocean'), 3325 gradient: 'linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%)', 3326 slug: 'pale-ocean' 3327 }, { 3328 name: (0,external_wp_i18n_namespaceObject.__)('Electric grass'), 3329 gradient: 'linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%)', 3330 slug: 'electric-grass' 3331 }, { 3332 name: (0,external_wp_i18n_namespaceObject.__)('Midnight'), 3333 gradient: 'linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%)', 3334 slug: 'midnight' 3335 }], 3336 __unstableResolvedAssets: { 3337 styles: [], 3338 scripts: [] 3339 } 3340 }; 3341 3342 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/array.js 3343 /** 3344 * External dependencies 3345 */ 3346 3347 /** 3348 * Insert one or multiple elements into a given position of an array. 3349 * 3350 * @param {Array} array Source array. 3351 * @param {*} elements Elements to insert. 3352 * @param {number} index Insert Position. 3353 * 3354 * @return {Array} Result. 3355 */ 3356 3357 function insertAt(array, elements, index) { 3358 return [...array.slice(0, index), ...(0,external_lodash_namespaceObject.castArray)(elements), ...array.slice(index)]; 3359 } 3360 /** 3361 * Moves an element in an array. 3362 * 3363 * @param {Array} array Source array. 3364 * @param {number} from Source index. 3365 * @param {number} to Destination index. 3366 * @param {number} count Number of elements to move. 3367 * 3368 * @return {Array} Result. 3369 */ 3370 3371 function moveTo(array, from, to) { 3372 let count = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; 3373 const withoutMovedElements = [...array]; 3374 withoutMovedElements.splice(from, count); 3375 return insertAt(withoutMovedElements, array.slice(from, from + count), to); 3376 } 3377 3378 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/reducer.js 3379 /** 3380 * External dependencies 3381 */ 3382 3383 /** 3384 * WordPress dependencies 3385 */ 3386 3387 3388 3389 /** 3390 * Internal dependencies 3391 */ 3392 3393 3394 3395 /** 3396 * Given an array of blocks, returns an object where each key is a nesting 3397 * context, the value of which is an array of block client IDs existing within 3398 * that nesting context. 3399 * 3400 * @param {Array} blocks Blocks to map. 3401 * @param {?string} rootClientId Assumed root client ID. 3402 * 3403 * @return {Object} Block order map object. 3404 */ 3405 3406 function mapBlockOrder(blocks) { 3407 let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 3408 const result = { 3409 [rootClientId]: [] 3410 }; 3411 blocks.forEach(block => { 3412 const { 3413 clientId, 3414 innerBlocks 3415 } = block; 3416 result[rootClientId].push(clientId); 3417 Object.assign(result, mapBlockOrder(innerBlocks, clientId)); 3418 }); 3419 return result; 3420 } 3421 /** 3422 * Given an array of blocks, returns an object where each key contains 3423 * the clientId of the block and the value is the parent of the block. 3424 * 3425 * @param {Array} blocks Blocks to map. 3426 * @param {?string} rootClientId Assumed root client ID. 3427 * 3428 * @return {Object} Block order map object. 3429 */ 3430 3431 3432 function mapBlockParents(blocks) { 3433 let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 3434 return blocks.reduce((result, block) => Object.assign(result, { 3435 [block.clientId]: rootClientId 3436 }, mapBlockParents(block.innerBlocks, block.clientId)), {}); 3437 } 3438 /** 3439 * Helper method to iterate through all blocks, recursing into inner blocks, 3440 * applying a transformation function to each one. 3441 * Returns a flattened object with the transformed blocks. 3442 * 3443 * @param {Array} blocks Blocks to flatten. 3444 * @param {Function} transform Transforming function to be applied to each block. 3445 * 3446 * @return {Object} Flattened object. 3447 */ 3448 3449 3450 function flattenBlocks(blocks) { 3451 let transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : external_lodash_namespaceObject.identity; 3452 const result = {}; 3453 const stack = [...blocks]; 3454 3455 while (stack.length) { 3456 const { 3457 innerBlocks, 3458 ...block 3459 } = stack.shift(); 3460 stack.push(...innerBlocks); 3461 result[block.clientId] = transform(block); 3462 } 3463 3464 return result; 3465 } 3466 /** 3467 * Given an array of blocks, returns an object containing all blocks, without 3468 * attributes, recursing into inner blocks. Keys correspond to the block client 3469 * ID, the value of which is the attributes object. 3470 * 3471 * @param {Array} blocks Blocks to flatten. 3472 * 3473 * @return {Object} Flattened block attributes object. 3474 */ 3475 3476 3477 function getFlattenedBlocksWithoutAttributes(blocks) { 3478 return flattenBlocks(blocks, block => (0,external_lodash_namespaceObject.omit)(block, 'attributes')); 3479 } 3480 /** 3481 * Given an array of blocks, returns an object containing all block attributes, 3482 * recursing into inner blocks. Keys correspond to the block client ID, the 3483 * value of which is the attributes object. 3484 * 3485 * @param {Array} blocks Blocks to flatten. 3486 * 3487 * @return {Object} Flattened block attributes object. 3488 */ 3489 3490 3491 function getFlattenedBlockAttributes(blocks) { 3492 return flattenBlocks(blocks, block => block.attributes); 3493 } 3494 /** 3495 * Returns an object against which it is safe to perform mutating operations, 3496 * given the original object and its current working copy. 3497 * 3498 * @param {Object} original Original object. 3499 * @param {Object} working Working object. 3500 * 3501 * @return {Object} Mutation-safe object. 3502 */ 3503 3504 3505 function getMutateSafeObject(original, working) { 3506 if (original === working) { 3507 return { ...original 3508 }; 3509 } 3510 3511 return working; 3512 } 3513 /** 3514 * Returns true if the two object arguments have the same keys, or false 3515 * otherwise. 3516 * 3517 * @param {Object} a First object. 3518 * @param {Object} b Second object. 3519 * 3520 * @return {boolean} Whether the two objects have the same keys. 3521 */ 3522 3523 3524 function hasSameKeys(a, b) { 3525 return (0,external_lodash_namespaceObject.isEqual)((0,external_lodash_namespaceObject.keys)(a), (0,external_lodash_namespaceObject.keys)(b)); 3526 } 3527 /** 3528 * Returns true if, given the currently dispatching action and the previously 3529 * dispatched action, the two actions are updating the same block attribute, or 3530 * false otherwise. 3531 * 3532 * @param {Object} action Currently dispatching action. 3533 * @param {Object} lastAction Previously dispatched action. 3534 * 3535 * @return {boolean} Whether actions are updating the same block attribute. 3536 */ 3537 3538 function isUpdatingSameBlockAttribute(action, lastAction) { 3539 return action.type === 'UPDATE_BLOCK_ATTRIBUTES' && lastAction !== undefined && lastAction.type === 'UPDATE_BLOCK_ATTRIBUTES' && (0,external_lodash_namespaceObject.isEqual)(action.clientIds, lastAction.clientIds) && hasSameKeys(action.attributes, lastAction.attributes); 3540 } 3541 3542 function buildBlockTree(state, blocks) { 3543 const result = {}; 3544 const stack = [...blocks]; 3545 const flattenedBlocks = [...blocks]; 3546 3547 while (stack.length) { 3548 const block = stack.shift(); 3549 stack.push(...block.innerBlocks); 3550 flattenedBlocks.push(...block.innerBlocks); 3551 } // Create objects before mutating them, that way it's always defined. 3552 3553 3554 for (const block of flattenedBlocks) { 3555 result[block.clientId] = {}; 3556 } 3557 3558 for (const block of flattenedBlocks) { 3559 result[block.clientId] = Object.assign(result[block.clientId], { ...state.byClientId[block.clientId], 3560 attributes: state.attributes[block.clientId], 3561 innerBlocks: block.innerBlocks.map(subBlock => result[subBlock.clientId]) 3562 }); 3563 } 3564 3565 return result; 3566 } 3567 3568 function updateParentInnerBlocksInTree(state, tree, updatedClientIds) { 3569 let updateChildrenOfUpdatedClientIds = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; 3570 const uncontrolledParents = new Set([]); 3571 const controlledParents = new Set(); 3572 3573 for (const clientId of updatedClientIds) { 3574 let current = updateChildrenOfUpdatedClientIds ? clientId : state.parents[clientId]; 3575 3576 do { 3577 if (state.controlledInnerBlocks[current]) { 3578 // Should stop on controlled blocks. 3579 // If we reach a controlled parent, break out of the loop. 3580 controlledParents.add(current); 3581 break; 3582 } else { 3583 // Else continue traversing up through parents. 3584 uncontrolledParents.add(current); 3585 current = state.parents[current]; 3586 } 3587 } while (current !== undefined); 3588 } // To make sure the order of assignments doesn't matter, 3589 // we first create empty objects and mutates the inner blocks later. 3590 3591 3592 for (const clientId of uncontrolledParents) { 3593 tree[clientId] = { ...tree[clientId] 3594 }; 3595 } 3596 3597 for (const clientId of uncontrolledParents) { 3598 tree[clientId].innerBlocks = (state.order[clientId] || []).map(subClientId => tree[subClientId]); 3599 } // Controlled parent blocks, need a dedicated key for their inner blocks 3600 // to be used when doing getBlocks( controlledBlockClientId ). 3601 3602 3603 for (const clientId of controlledParents) { 3604 tree['controlled||' + clientId] = { 3605 innerBlocks: (state.order[clientId] || []).map(subClientId => tree[subClientId]) 3606 }; 3607 } 3608 3609 return tree; 3610 } 3611 /** 3612 * Higher-order reducer intended to compute full block objects key for each block in the post. 3613 * This is a denormalization to optimize the performance of the getBlock selectors and avoid 3614 * recomputing the block objects and avoid heavy memoization. 3615 * 3616 * @param {Function} reducer Original reducer function. 3617 * 3618 * @return {Function} Enhanced reducer function. 3619 */ 3620 3621 3622 const withBlockTree = reducer => function () { 3623 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 3624 let action = arguments.length > 1 ? arguments[1] : undefined; 3625 const newState = reducer(state, action); 3626 3627 if (newState === state) { 3628 return state; 3629 } 3630 3631 newState.tree = state.tree ? state.tree : {}; 3632 3633 switch (action.type) { 3634 case 'RECEIVE_BLOCKS': 3635 case 'INSERT_BLOCKS': 3636 { 3637 const subTree = buildBlockTree(newState, action.blocks); 3638 newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree, 3639 ...subTree 3640 }, action.rootClientId ? [action.rootClientId] : [''], true); 3641 break; 3642 } 3643 3644 case 'UPDATE_BLOCK': 3645 newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree, 3646 [action.clientId]: { ...newState.tree[action.clientId], 3647 ...newState.byClientId[action.clientId], 3648 attributes: newState.attributes[action.clientId] 3649 } 3650 }, [action.clientId], false); 3651 break; 3652 3653 case 'UPDATE_BLOCK_ATTRIBUTES': 3654 { 3655 const newSubTree = action.clientIds.reduce((result, clientId) => { 3656 result[clientId] = { ...newState.tree[clientId], 3657 attributes: newState.attributes[clientId] 3658 }; 3659 return result; 3660 }, {}); 3661 newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree, 3662 ...newSubTree 3663 }, action.clientIds, false); 3664 break; 3665 } 3666 3667 case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN': 3668 { 3669 const subTree = buildBlockTree(newState, action.blocks); 3670 newState.tree = updateParentInnerBlocksInTree(newState, { ...(0,external_lodash_namespaceObject.omit)(newState.tree, action.replacedClientIds.concat( // Controlled inner blocks are only removed 3671 // if the block doesn't move to another position 3672 // otherwise their content will be lost. 3673 action.replacedClientIds.filter(clientId => !subTree[clientId]).map(clientId => 'controlled||' + clientId))), 3674 ...subTree 3675 }, action.blocks.map(b => b.clientId), false); // If there are no replaced blocks, it means we're removing blocks so we need to update their parent. 3676 3677 const parentsOfRemovedBlocks = []; 3678 3679 for (const clientId of action.clientIds) { 3680 if (state.parents[clientId] !== undefined && (state.parents[clientId] === '' || newState.byClientId[state.parents[clientId]])) { 3681 parentsOfRemovedBlocks.push(state.parents[clientId]); 3682 } 3683 } 3684 3685 newState.tree = updateParentInnerBlocksInTree(newState, newState.tree, parentsOfRemovedBlocks, true); 3686 break; 3687 } 3688 3689 case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN': 3690 const parentsOfRemovedBlocks = []; 3691 3692 for (const clientId of action.clientIds) { 3693 if (state.parents[clientId] !== undefined && (state.parents[clientId] === '' || newState.byClientId[state.parents[clientId]])) { 3694 parentsOfRemovedBlocks.push(state.parents[clientId]); 3695 } 3696 } 3697 3698 newState.tree = updateParentInnerBlocksInTree(newState, (0,external_lodash_namespaceObject.omit)(newState.tree, action.removedClientIds.concat(action.removedClientIds.map(clientId => 'controlled||' + clientId))), parentsOfRemovedBlocks, true); 3699 break; 3700 3701 case 'MOVE_BLOCKS_TO_POSITION': 3702 { 3703 const updatedBlockUids = []; 3704 3705 if (action.fromRootClientId) { 3706 updatedBlockUids.push(action.fromRootClientId); 3707 } 3708 3709 if (action.toRootClientId) { 3710 updatedBlockUids.push(action.toRootClientId); 3711 } 3712 3713 if (!action.fromRootClientId || !action.fromRootClientId) { 3714 updatedBlockUids.push(''); 3715 } 3716 3717 newState.tree = updateParentInnerBlocksInTree(newState, newState.tree, updatedBlockUids, true); 3718 break; 3719 } 3720 3721 case 'MOVE_BLOCKS_UP': 3722 case 'MOVE_BLOCKS_DOWN': 3723 { 3724 const updatedBlockUids = [action.rootClientId ? action.rootClientId : '']; 3725 newState.tree = updateParentInnerBlocksInTree(newState, newState.tree, updatedBlockUids, true); 3726 break; 3727 } 3728 3729 case 'SAVE_REUSABLE_BLOCK_SUCCESS': 3730 { 3731 const updatedBlockUids = (0,external_lodash_namespaceObject.keys)((0,external_lodash_namespaceObject.omitBy)(newState.attributes, (attributes, clientId) => { 3732 return newState.byClientId[clientId].name !== 'core/block' || attributes.ref !== action.updatedId; 3733 })); 3734 newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree, 3735 ...updatedBlockUids.reduce((result, clientId) => { 3736 result[clientId] = { ...newState.byClientId[clientId], 3737 attributes: newState.attributes[clientId], 3738 innerBlocks: newState.tree[clientId].innerBlocks 3739 }; 3740 return result; 3741 }, {}) 3742 }, updatedBlockUids, false); 3743 } 3744 } 3745 3746 return newState; 3747 }; 3748 /** 3749 * Higher-order reducer intended to augment the blocks reducer, assigning an 3750 * `isPersistentChange` property value corresponding to whether a change in 3751 * state can be considered as persistent. All changes are considered persistent 3752 * except when updating the same block attribute as in the previous action. 3753 * 3754 * @param {Function} reducer Original reducer function. 3755 * 3756 * @return {Function} Enhanced reducer function. 3757 */ 3758 3759 3760 function withPersistentBlockChange(reducer) { 3761 let lastAction; 3762 let markNextChangeAsNotPersistent = false; 3763 return (state, action) => { 3764 let nextState = reducer(state, action); 3765 const isExplicitPersistentChange = action.type === 'MARK_LAST_CHANGE_AS_PERSISTENT' || markNextChangeAsNotPersistent; // Defer to previous state value (or default) unless changing or 3766 // explicitly marking as persistent. 3767 3768 if (state === nextState && !isExplicitPersistentChange) { 3769 var _state$isPersistentCh; 3770 3771 markNextChangeAsNotPersistent = action.type === 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT'; 3772 const nextIsPersistentChange = (_state$isPersistentCh = state === null || state === void 0 ? void 0 : state.isPersistentChange) !== null && _state$isPersistentCh !== void 0 ? _state$isPersistentCh : true; 3773 3774 if (state.isPersistentChange === nextIsPersistentChange) { 3775 return state; 3776 } 3777 3778 return { ...nextState, 3779 isPersistentChange: nextIsPersistentChange 3780 }; 3781 } 3782 3783 nextState = { ...nextState, 3784 isPersistentChange: isExplicitPersistentChange ? !markNextChangeAsNotPersistent : !isUpdatingSameBlockAttribute(action, lastAction) 3785 }; // In comparing against the previous action, consider only those which 3786 // would have qualified as one which would have been ignored or not 3787 // have resulted in a changed state. 3788 3789 lastAction = action; 3790 markNextChangeAsNotPersistent = action.type === 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT'; 3791 return nextState; 3792 }; 3793 } 3794 /** 3795 * Higher-order reducer intended to augment the blocks reducer, assigning an 3796 * `isIgnoredChange` property value corresponding to whether a change in state 3797 * can be considered as ignored. A change is considered ignored when the result 3798 * of an action not incurred by direct user interaction. 3799 * 3800 * @param {Function} reducer Original reducer function. 3801 * 3802 * @return {Function} Enhanced reducer function. 3803 */ 3804 3805 3806 function withIgnoredBlockChange(reducer) { 3807 /** 3808 * Set of action types for which a blocks state change should be ignored. 3809 * 3810 * @type {Set} 3811 */ 3812 const IGNORED_ACTION_TYPES = new Set(['RECEIVE_BLOCKS']); 3813 return (state, action) => { 3814 const nextState = reducer(state, action); 3815 3816 if (nextState !== state) { 3817 nextState.isIgnoredChange = IGNORED_ACTION_TYPES.has(action.type); 3818 } 3819 3820 return nextState; 3821 }; 3822 } 3823 /** 3824 * Higher-order reducer targeting the combined blocks reducer, augmenting 3825 * block client IDs in remove action to include cascade of inner blocks. 3826 * 3827 * @param {Function} reducer Original reducer function. 3828 * 3829 * @return {Function} Enhanced reducer function. 3830 */ 3831 3832 3833 const withInnerBlocksRemoveCascade = reducer => (state, action) => { 3834 // Gets all children which need to be removed. 3835 const getAllChildren = clientIds => { 3836 let result = clientIds; 3837 3838 for (let i = 0; i < result.length; i++) { 3839 if (!state.order[result[i]] || action.keepControlledInnerBlocks && action.keepControlledInnerBlocks[result[i]]) { 3840 continue; 3841 } 3842 3843 if (result === clientIds) { 3844 result = [...result]; 3845 } 3846 3847 result.push(...state.order[result[i]]); 3848 } 3849 3850 return result; 3851 }; 3852 3853 if (state) { 3854 switch (action.type) { 3855 case 'REMOVE_BLOCKS': 3856 action = { ...action, 3857 type: 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN', 3858 removedClientIds: getAllChildren(action.clientIds) 3859 }; 3860 break; 3861 3862 case 'REPLACE_BLOCKS': 3863 action = { ...action, 3864 type: 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN', 3865 replacedClientIds: getAllChildren(action.clientIds) 3866 }; 3867 break; 3868 } 3869 } 3870 3871 return reducer(state, action); 3872 }; 3873 /** 3874 * Higher-order reducer which targets the combined blocks reducer and handles 3875 * the `RESET_BLOCKS` action. When dispatched, this action will replace all 3876 * blocks that exist in the post, leaving blocks that exist only in state (e.g. 3877 * reusable blocks and blocks controlled by inner blocks controllers) alone. 3878 * 3879 * @param {Function} reducer Original reducer function. 3880 * 3881 * @return {Function} Enhanced reducer function. 3882 */ 3883 3884 3885 const withBlockReset = reducer => (state, action) => { 3886 if (action.type === 'RESET_BLOCKS') { 3887 const newState = { ...state, 3888 byClientId: getFlattenedBlocksWithoutAttributes(action.blocks), 3889 attributes: getFlattenedBlockAttributes(action.blocks), 3890 order: mapBlockOrder(action.blocks), 3891 parents: mapBlockParents(action.blocks), 3892 controlledInnerBlocks: {} 3893 }; 3894 const subTree = buildBlockTree(newState, action.blocks); 3895 newState.tree = { ...subTree, 3896 // Root. 3897 '': { 3898 innerBlocks: action.blocks.map(subBlock => subTree[subBlock.clientId]) 3899 } 3900 }; 3901 return newState; 3902 } 3903 3904 return reducer(state, action); 3905 }; 3906 /** 3907 * Higher-order reducer which targets the combined blocks reducer and handles 3908 * the `REPLACE_INNER_BLOCKS` action. When dispatched, this action the state 3909 * should become equivalent to the execution of a `REMOVE_BLOCKS` action 3910 * containing all the child's of the root block followed by the execution of 3911 * `INSERT_BLOCKS` with the new blocks. 3912 * 3913 * @param {Function} reducer Original reducer function. 3914 * 3915 * @return {Function} Enhanced reducer function. 3916 */ 3917 3918 3919 const withReplaceInnerBlocks = reducer => (state, action) => { 3920 if (action.type !== 'REPLACE_INNER_BLOCKS') { 3921 return reducer(state, action); 3922 } // Finds every nested inner block controller. We must check the action blocks 3923 // and not just the block parent state because some inner block controllers 3924 // should be deleted if specified, whereas others should not be deleted. If 3925 // a controlled should not be deleted, then we need to avoid deleting its 3926 // inner blocks from the block state because its inner blocks will not be 3927 // attached to the block in the action. 3928 3929 3930 const nestedControllers = {}; 3931 3932 if (Object.keys(state.controlledInnerBlocks).length) { 3933 const stack = [...action.blocks]; 3934 3935 while (stack.length) { 3936 const { 3937 innerBlocks, 3938 ...block 3939 } = stack.shift(); 3940 stack.push(...innerBlocks); 3941 3942 if (!!state.controlledInnerBlocks[block.clientId]) { 3943 nestedControllers[block.clientId] = true; 3944 } 3945 } 3946 } // The `keepControlledInnerBlocks` prop will keep the inner blocks of the 3947 // marked block in the block state so that they can be reattached to the 3948 // marked block when we re-insert everything a few lines below. 3949 3950 3951 let stateAfterBlocksRemoval = state; 3952 3953 if (state.order[action.rootClientId]) { 3954 stateAfterBlocksRemoval = reducer(stateAfterBlocksRemoval, { 3955 type: 'REMOVE_BLOCKS', 3956 keepControlledInnerBlocks: nestedControllers, 3957 clientIds: state.order[action.rootClientId] 3958 }); 3959 } 3960 3961 let stateAfterInsert = stateAfterBlocksRemoval; 3962 3963 if (action.blocks.length) { 3964 stateAfterInsert = reducer(stateAfterInsert, { ...action, 3965 type: 'INSERT_BLOCKS', 3966 index: 0 3967 }); // We need to re-attach the block order of the controlled inner blocks. 3968 // Otherwise, an inner block controller's blocks will be deleted entirely 3969 // from its entity.. 3970 3971 stateAfterInsert.order = { ...stateAfterInsert.order, 3972 ...(0,external_lodash_namespaceObject.reduce)(nestedControllers, (result, value, key) => { 3973 if (state.order[key]) { 3974 result[key] = state.order[key]; 3975 } 3976 3977 return result; 3978 }, {}) 3979 }; 3980 } 3981 3982 return stateAfterInsert; 3983 }; 3984 /** 3985 * Higher-order reducer which targets the combined blocks reducer and handles 3986 * the `SAVE_REUSABLE_BLOCK_SUCCESS` action. This action can't be handled by 3987 * regular reducers and needs a higher-order reducer since it needs access to 3988 * both `byClientId` and `attributes` simultaneously. 3989 * 3990 * @param {Function} reducer Original reducer function. 3991 * 3992 * @return {Function} Enhanced reducer function. 3993 */ 3994 3995 3996 const withSaveReusableBlock = reducer => (state, action) => { 3997 if (state && action.type === 'SAVE_REUSABLE_BLOCK_SUCCESS') { 3998 const { 3999 id, 4000 updatedId 4001 } = action; // If a temporary reusable block is saved, we swap the temporary id with the final one. 4002 4003 if (id === updatedId) { 4004 return state; 4005 } 4006 4007 state = { ...state 4008 }; 4009 state.attributes = (0,external_lodash_namespaceObject.mapValues)(state.attributes, (attributes, clientId) => { 4010 const { 4011 name 4012 } = state.byClientId[clientId]; 4013 4014 if (name === 'core/block' && attributes.ref === id) { 4015 return { ...attributes, 4016 ref: updatedId 4017 }; 4018 } 4019 4020 return attributes; 4021 }); 4022 } 4023 4024 return reducer(state, action); 4025 }; 4026 /** 4027 * Higher-order reducer which removes blocks from state when switching parent block controlled state. 4028 * 4029 * @param {Function} reducer Original reducer function. 4030 * 4031 * @return {Function} Enhanced reducer function. 4032 */ 4033 4034 4035 const withResetControlledBlocks = reducer => (state, action) => { 4036 if (action.type === 'SET_HAS_CONTROLLED_INNER_BLOCKS') { 4037 // when switching a block from controlled to uncontrolled or inverse, 4038 // we need to remove its content first. 4039 const tempState = reducer(state, { 4040 type: 'REPLACE_INNER_BLOCKS', 4041 rootClientId: action.clientId, 4042 blocks: [] 4043 }); 4044 return reducer(tempState, action); 4045 } 4046 4047 return reducer(state, action); 4048 }; 4049 /** 4050 * Reducer returning the blocks state. 4051 * 4052 * @param {Object} state Current state. 4053 * @param {Object} action Dispatched action. 4054 * 4055 * @return {Object} Updated state. 4056 */ 4057 4058 4059 const blocks = (0,external_lodash_namespaceObject.flow)(external_wp_data_namespaceObject.combineReducers, withSaveReusableBlock, // Needs to be before withBlockCache. 4060 withBlockTree, // Needs to be before withInnerBlocksRemoveCascade. 4061 withInnerBlocksRemoveCascade, withReplaceInnerBlocks, // Needs to be after withInnerBlocksRemoveCascade. 4062 withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetControlledBlocks)({ 4063 byClientId() { 4064 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 4065 let action = arguments.length > 1 ? arguments[1] : undefined; 4066 4067 switch (action.type) { 4068 case 'RECEIVE_BLOCKS': 4069 case 'INSERT_BLOCKS': 4070 return { ...state, 4071 ...getFlattenedBlocksWithoutAttributes(action.blocks) 4072 }; 4073 4074 case 'UPDATE_BLOCK': 4075 // Ignore updates if block isn't known. 4076 if (!state[action.clientId]) { 4077 return state; 4078 } // Do nothing if only attributes change. 4079 4080 4081 const changes = (0,external_lodash_namespaceObject.omit)(action.updates, 'attributes'); 4082 4083 if ((0,external_lodash_namespaceObject.isEmpty)(changes)) { 4084 return state; 4085 } 4086 4087 return { ...state, 4088 [action.clientId]: { ...state[action.clientId], 4089 ...changes 4090 } 4091 }; 4092 4093 case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN': 4094 if (!action.blocks) { 4095 return state; 4096 } 4097 4098 return { ...(0,external_lodash_namespaceObject.omit)(state, action.replacedClientIds), 4099 ...getFlattenedBlocksWithoutAttributes(action.blocks) 4100 }; 4101 4102 case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN': 4103 return (0,external_lodash_namespaceObject.omit)(state, action.removedClientIds); 4104 } 4105 4106 return state; 4107 }, 4108 4109 attributes() { 4110 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 4111 let action = arguments.length > 1 ? arguments[1] : undefined; 4112 4113 switch (action.type) { 4114 case 'RECEIVE_BLOCKS': 4115 case 'INSERT_BLOCKS': 4116 return { ...state, 4117 ...getFlattenedBlockAttributes(action.blocks) 4118 }; 4119 4120 case 'UPDATE_BLOCK': 4121 // Ignore updates if block isn't known or there are no attribute changes. 4122 if (!state[action.clientId] || !action.updates.attributes) { 4123 return state; 4124 } 4125 4126 return { ...state, 4127 [action.clientId]: { ...state[action.clientId], 4128 ...action.updates.attributes 4129 } 4130 }; 4131 4132 case 'UPDATE_BLOCK_ATTRIBUTES': 4133 { 4134 // Avoid a state change if none of the block IDs are known. 4135 if (action.clientIds.every(id => !state[id])) { 4136 return state; 4137 } 4138 4139 const next = action.clientIds.reduce((accumulator, id) => ({ ...accumulator, 4140 [id]: (0,external_lodash_namespaceObject.reduce)(action.uniqueByBlock ? action.attributes[id] : action.attributes, (result, value, key) => { 4141 // Consider as updates only changed values. 4142 if (value !== result[key]) { 4143 result = getMutateSafeObject(state[id], result); 4144 result[key] = value; 4145 } 4146 4147 return result; 4148 }, state[id]) 4149 }), {}); 4150 4151 if (action.clientIds.every(id => next[id] === state[id])) { 4152 return state; 4153 } 4154 4155 return { ...state, 4156 ...next 4157 }; 4158 } 4159 4160 case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN': 4161 if (!action.blocks) { 4162 return state; 4163 } 4164 4165 return { ...(0,external_lodash_namespaceObject.omit)(state, action.replacedClientIds), 4166 ...getFlattenedBlockAttributes(action.blocks) 4167 }; 4168 4169 case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN': 4170 return (0,external_lodash_namespaceObject.omit)(state, action.removedClientIds); 4171 } 4172 4173 return state; 4174 }, 4175 4176 order() { 4177 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 4178 let action = arguments.length > 1 ? arguments[1] : undefined; 4179 4180 switch (action.type) { 4181 case 'RECEIVE_BLOCKS': 4182 { 4183 const blockOrder = mapBlockOrder(action.blocks); 4184 return { ...state, 4185 ...(0,external_lodash_namespaceObject.omit)(blockOrder, ''), 4186 '': ((state === null || state === void 0 ? void 0 : state['']) || []).concat(blockOrder['']) 4187 }; 4188 } 4189 4190 case 'INSERT_BLOCKS': 4191 { 4192 const { 4193 rootClientId = '' 4194 } = action; 4195 const subState = state[rootClientId] || []; 4196 const mappedBlocks = mapBlockOrder(action.blocks, rootClientId); 4197 const { 4198 index = subState.length 4199 } = action; 4200 return { ...state, 4201 ...mappedBlocks, 4202 [rootClientId]: insertAt(subState, mappedBlocks[rootClientId], index) 4203 }; 4204 } 4205 4206 case 'MOVE_BLOCKS_TO_POSITION': 4207 { 4208 const { 4209 fromRootClientId = '', 4210 toRootClientId = '', 4211 clientIds 4212 } = action; 4213 const { 4214 index = state[toRootClientId].length 4215 } = action; // Moving inside the same parent block. 4216 4217 if (fromRootClientId === toRootClientId) { 4218 const subState = state[toRootClientId]; 4219 const fromIndex = subState.indexOf(clientIds[0]); 4220 return { ...state, 4221 [toRootClientId]: moveTo(state[toRootClientId], fromIndex, index, clientIds.length) 4222 }; 4223 } // Moving from a parent block to another. 4224 4225 4226 return { ...state, 4227 [fromRootClientId]: (0,external_lodash_namespaceObject.without)(state[fromRootClientId], ...clientIds), 4228 [toRootClientId]: insertAt(state[toRootClientId], clientIds, index) 4229 }; 4230 } 4231 4232 case 'MOVE_BLOCKS_UP': 4233 { 4234 const { 4235 clientIds, 4236 rootClientId = '' 4237 } = action; 4238 const firstClientId = (0,external_lodash_namespaceObject.first)(clientIds); 4239 const subState = state[rootClientId]; 4240 4241 if (!subState.length || firstClientId === (0,external_lodash_namespaceObject.first)(subState)) { 4242 return state; 4243 } 4244 4245 const firstIndex = subState.indexOf(firstClientId); 4246 return { ...state, 4247 [rootClientId]: moveTo(subState, firstIndex, firstIndex - 1, clientIds.length) 4248 }; 4249 } 4250 4251 case 'MOVE_BLOCKS_DOWN': 4252 { 4253 const { 4254 clientIds, 4255 rootClientId = '' 4256 } = action; 4257 const firstClientId = (0,external_lodash_namespaceObject.first)(clientIds); 4258 const lastClientId = (0,external_lodash_namespaceObject.last)(clientIds); 4259 const subState = state[rootClientId]; 4260 4261 if (!subState.length || lastClientId === (0,external_lodash_namespaceObject.last)(subState)) { 4262 return state; 4263 } 4264 4265 const firstIndex = subState.indexOf(firstClientId); 4266 return { ...state, 4267 [rootClientId]: moveTo(subState, firstIndex, firstIndex + 1, clientIds.length) 4268 }; 4269 } 4270 4271 case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN': 4272 { 4273 const { 4274 clientIds 4275 } = action; 4276 4277 if (!action.blocks) { 4278 return state; 4279 } 4280 4281 const mappedBlocks = mapBlockOrder(action.blocks); 4282 return (0,external_lodash_namespaceObject.flow)([nextState => (0,external_lodash_namespaceObject.omit)(nextState, action.replacedClientIds), nextState => ({ ...nextState, 4283 ...(0,external_lodash_namespaceObject.omit)(mappedBlocks, '') 4284 }), nextState => (0,external_lodash_namespaceObject.mapValues)(nextState, subState => (0,external_lodash_namespaceObject.reduce)(subState, (result, clientId) => { 4285 if (clientId === clientIds[0]) { 4286 return [...result, ...mappedBlocks['']]; 4287 } 4288 4289 if (clientIds.indexOf(clientId) === -1) { 4290 result.push(clientId); 4291 } 4292 4293 return result; 4294 }, []))])(state); 4295 } 4296 4297 case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN': 4298 return (0,external_lodash_namespaceObject.flow)([// Remove inner block ordering for removed blocks. 4299 nextState => (0,external_lodash_namespaceObject.omit)(nextState, action.removedClientIds), // Remove deleted blocks from other blocks' orderings. 4300 nextState => (0,external_lodash_namespaceObject.mapValues)(nextState, subState => (0,external_lodash_namespaceObject.without)(subState, ...action.removedClientIds))])(state); 4301 } 4302 4303 return state; 4304 }, 4305 4306 // While technically redundant data as the inverse of `order`, it serves as 4307 // an optimization for the selectors which derive the ancestry of a block. 4308 parents() { 4309 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 4310 let action = arguments.length > 1 ? arguments[1] : undefined; 4311 4312 switch (action.type) { 4313 case 'RECEIVE_BLOCKS': 4314 return { ...state, 4315 ...mapBlockParents(action.blocks) 4316 }; 4317 4318 case 'INSERT_BLOCKS': 4319 return { ...state, 4320 ...mapBlockParents(action.blocks, action.rootClientId || '') 4321 }; 4322 4323 case 'MOVE_BLOCKS_TO_POSITION': 4324 { 4325 return { ...state, 4326 ...action.clientIds.reduce((accumulator, id) => { 4327 accumulator[id] = action.toRootClientId || ''; 4328 return accumulator; 4329 }, {}) 4330 }; 4331 } 4332 4333 case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN': 4334 return { ...(0,external_lodash_namespaceObject.omit)(state, action.replacedClientIds), 4335 ...mapBlockParents(action.blocks, state[action.clientIds[0]]) 4336 }; 4337 4338 case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN': 4339 return (0,external_lodash_namespaceObject.omit)(state, action.removedClientIds); 4340 } 4341 4342 return state; 4343 }, 4344 4345 controlledInnerBlocks() { 4346 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 4347 let { 4348 type, 4349 clientId, 4350 hasControlledInnerBlocks 4351 } = arguments.length > 1 ? arguments[1] : undefined; 4352 4353 if (type === 'SET_HAS_CONTROLLED_INNER_BLOCKS') { 4354 return { ...state, 4355 [clientId]: hasControlledInnerBlocks 4356 }; 4357 } 4358 4359 return state; 4360 } 4361 4362 }); 4363 /** 4364 * Reducer returning typing state. 4365 * 4366 * @param {boolean} state Current state. 4367 * @param {Object} action Dispatched action. 4368 * 4369 * @return {boolean} Updated state. 4370 */ 4371 4372 function isTyping() { 4373 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 4374 let action = arguments.length > 1 ? arguments[1] : undefined; 4375 4376 switch (action.type) { 4377 case 'START_TYPING': 4378 return true; 4379 4380 case 'STOP_TYPING': 4381 return false; 4382 } 4383 4384 return state; 4385 } 4386 /** 4387 * Reducer returning dragged block client id. 4388 * 4389 * @param {string[]} state Current state. 4390 * @param {Object} action Dispatched action. 4391 * 4392 * @return {string[]} Updated state. 4393 */ 4394 4395 function draggedBlocks() { 4396 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; 4397 let action = arguments.length > 1 ? arguments[1] : undefined; 4398 4399 switch (action.type) { 4400 case 'START_DRAGGING_BLOCKS': 4401 return action.clientIds; 4402 4403 case 'STOP_DRAGGING_BLOCKS': 4404 return []; 4405 } 4406 4407 return state; 4408 } 4409 /** 4410 * Reducer returning whether the caret is within formatted text. 4411 * 4412 * @param {boolean} state Current state. 4413 * @param {Object} action Dispatched action. 4414 * 4415 * @return {boolean} Updated state. 4416 */ 4417 4418 function isCaretWithinFormattedText() { 4419 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 4420 let action = arguments.length > 1 ? arguments[1] : undefined; 4421 4422 switch (action.type) { 4423 case 'ENTER_FORMATTED_TEXT': 4424 return true; 4425 4426 case 'EXIT_FORMATTED_TEXT': 4427 return false; 4428 } 4429 4430 return state; 4431 } 4432 /** 4433 * Internal helper reducer for selectionStart and selectionEnd. Can hold a block 4434 * selection, represented by an object with property clientId. 4435 * 4436 * @param {Object} state Current state. 4437 * @param {Object} action Dispatched action. 4438 * 4439 * @return {Object} Updated state. 4440 */ 4441 4442 function selectionHelper() { 4443 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 4444 let action = arguments.length > 1 ? arguments[1] : undefined; 4445 4446 switch (action.type) { 4447 case 'CLEAR_SELECTED_BLOCK': 4448 { 4449 if (state.clientId) { 4450 return {}; 4451 } 4452 4453 return state; 4454 } 4455 4456 case 'SELECT_BLOCK': 4457 if (action.clientId === state.clientId) { 4458 return state; 4459 } 4460 4461 return { 4462 clientId: action.clientId 4463 }; 4464 4465 case 'REPLACE_INNER_BLOCKS': 4466 case 'INSERT_BLOCKS': 4467 { 4468 if (!action.updateSelection || !action.blocks.length) { 4469 return state; 4470 } 4471 4472 return { 4473 clientId: action.blocks[0].clientId 4474 }; 4475 } 4476 4477 case 'REMOVE_BLOCKS': 4478 if (!action.clientIds || !action.clientIds.length || action.clientIds.indexOf(state.clientId) === -1) { 4479 return state; 4480 } 4481 4482 return {}; 4483 4484 case 'REPLACE_BLOCKS': 4485 { 4486 if (action.clientIds.indexOf(state.clientId) === -1) { 4487 return state; 4488 } 4489 4490 const blockToSelect = action.blocks[action.indexToSelect] || action.blocks[action.blocks.length - 1]; 4491 4492 if (!blockToSelect) { 4493 return {}; 4494 } 4495 4496 if (blockToSelect.clientId === state.clientId) { 4497 return state; 4498 } 4499 4500 return { 4501 clientId: blockToSelect.clientId 4502 }; 4503 } 4504 } 4505 4506 return state; 4507 } 4508 /** 4509 * Reducer returning the selection state. 4510 * 4511 * @param {boolean} state Current state. 4512 * @param {Object} action Dispatched action. 4513 * 4514 * @return {boolean} Updated state. 4515 */ 4516 4517 4518 function selection() { 4519 var _state$selectionStart, _state$selectionEnd, _state$selectionStart2, _state$selectionEnd2; 4520 4521 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 4522 let action = arguments.length > 1 ? arguments[1] : undefined; 4523 4524 switch (action.type) { 4525 case 'SELECTION_CHANGE': 4526 if (action.clientId) { 4527 return { 4528 selectionStart: { 4529 clientId: action.clientId, 4530 attributeKey: action.attributeKey, 4531 offset: action.startOffset 4532 }, 4533 selectionEnd: { 4534 clientId: action.clientId, 4535 attributeKey: action.attributeKey, 4536 offset: action.endOffset 4537 } 4538 }; 4539 } 4540 4541 return { 4542 selectionStart: action.start || state.selectionStart, 4543 selectionEnd: action.end || state.selectionEnd 4544 }; 4545 4546 case 'RESET_SELECTION': 4547 const { 4548 selectionStart, 4549 selectionEnd 4550 } = action; 4551 return { 4552 selectionStart, 4553 selectionEnd 4554 }; 4555 4556 case 'MULTI_SELECT': 4557 const { 4558 start, 4559 end 4560 } = action; 4561 4562 if (start === ((_state$selectionStart = state.selectionStart) === null || _state$selectionStart === void 0 ? void 0 : _state$selectionStart.clientId) && end === ((_state$selectionEnd = state.selectionEnd) === null || _state$selectionEnd === void 0 ? void 0 : _state$selectionEnd.clientId)) { 4563 return state; 4564 } 4565 4566 return { 4567 selectionStart: { 4568 clientId: start 4569 }, 4570 selectionEnd: { 4571 clientId: end 4572 } 4573 }; 4574 4575 case 'RESET_BLOCKS': 4576 const startClientId = state === null || state === void 0 ? void 0 : (_state$selectionStart2 = state.selectionStart) === null || _state$selectionStart2 === void 0 ? void 0 : _state$selectionStart2.clientId; 4577 const endClientId = state === null || state === void 0 ? void 0 : (_state$selectionEnd2 = state.selectionEnd) === null || _state$selectionEnd2 === void 0 ? void 0 : _state$selectionEnd2.clientId; // Do nothing if there's no selected block. 4578 4579 if (!startClientId && !endClientId) { 4580 return state; 4581 } // If the start of the selection won't exist after reset, remove selection. 4582 4583 4584 if (!action.blocks.some(block => block.clientId === startClientId)) { 4585 return { 4586 selectionStart: {}, 4587 selectionEnd: {} 4588 }; 4589 } // If the end of the selection won't exist after reset, collapse selection. 4590 4591 4592 if (!action.blocks.some(block => block.clientId === endClientId)) { 4593 return { ...state, 4594 selectionEnd: state.selectionStart 4595 }; 4596 } 4597 4598 } 4599 4600 return { 4601 selectionStart: selectionHelper(state.selectionStart, action), 4602 selectionEnd: selectionHelper(state.selectionEnd, action) 4603 }; 4604 } 4605 /** 4606 * Reducer returning whether the user is multi-selecting. 4607 * 4608 * @param {boolean} state Current state. 4609 * @param {Object} action Dispatched action. 4610 * 4611 * @return {boolean} Updated state. 4612 */ 4613 4614 function isMultiSelecting() { 4615 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 4616 let action = arguments.length > 1 ? arguments[1] : undefined; 4617 4618 switch (action.type) { 4619 case 'START_MULTI_SELECT': 4620 return true; 4621 4622 case 'STOP_MULTI_SELECT': 4623 return false; 4624 } 4625 4626 return state; 4627 } 4628 /** 4629 * Reducer returning whether selection is enabled. 4630 * 4631 * @param {boolean} state Current state. 4632 * @param {Object} action Dispatched action. 4633 * 4634 * @return {boolean} Updated state. 4635 */ 4636 4637 function isSelectionEnabled() { 4638 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; 4639 let action = arguments.length > 1 ? arguments[1] : undefined; 4640 4641 switch (action.type) { 4642 case 'TOGGLE_SELECTION': 4643 return action.isSelectionEnabled; 4644 } 4645 4646 return state; 4647 } 4648 /** 4649 * Reducer returning the initial block selection. 4650 * 4651 * Currently this in only used to restore the selection after block deletion and 4652 * pasting new content.This reducer should eventually be removed in favour of setting 4653 * selection directly. 4654 * 4655 * @param {boolean} state Current state. 4656 * @param {Object} action Dispatched action. 4657 * 4658 * @return {number|null} Initial position: 0, -1 or null. 4659 */ 4660 4661 function initialPosition() { 4662 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 4663 let action = arguments.length > 1 ? arguments[1] : undefined; 4664 4665 if (action.type === 'REPLACE_BLOCKS' && action.initialPosition !== undefined) { 4666 return action.initialPosition; 4667 } else if (['MULTI_SELECT', 'SELECT_BLOCK', 'RESET_SELECTION', 'INSERT_BLOCKS', 'REPLACE_INNER_BLOCKS'].includes(action.type)) { 4668 return action.initialPosition; 4669 } 4670 4671 return state; 4672 } 4673 function blocksMode() { 4674 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 4675 let action = arguments.length > 1 ? arguments[1] : undefined; 4676 4677 if (action.type === 'TOGGLE_BLOCK_MODE') { 4678 const { 4679 clientId 4680 } = action; 4681 return { ...state, 4682 [clientId]: state[clientId] && state[clientId] === 'html' ? 'visual' : 'html' 4683 }; 4684 } 4685 4686 return state; 4687 } 4688 /** 4689 * Reducer returning the block insertion point visibility, either null if there 4690 * is not an explicit insertion point assigned, or an object of its `index` and 4691 * `rootClientId`. 4692 * 4693 * @param {Object} state Current state. 4694 * @param {Object} action Dispatched action. 4695 * 4696 * @return {Object} Updated state. 4697 */ 4698 4699 function insertionPoint() { 4700 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 4701 let action = arguments.length > 1 ? arguments[1] : undefined; 4702 4703 switch (action.type) { 4704 case 'SHOW_INSERTION_POINT': 4705 const { 4706 rootClientId, 4707 index, 4708 __unstableWithInserter 4709 } = action; 4710 return { 4711 rootClientId, 4712 index, 4713 __unstableWithInserter 4714 }; 4715 4716 case 'HIDE_INSERTION_POINT': 4717 return null; 4718 } 4719 4720 return state; 4721 } 4722 /** 4723 * Reducer returning whether the post blocks match the defined template or not. 4724 * 4725 * @param {Object} state Current state. 4726 * @param {Object} action Dispatched action. 4727 * 4728 * @return {boolean} Updated state. 4729 */ 4730 4731 function template() { 4732 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { 4733 isValid: true 4734 }; 4735 let action = arguments.length > 1 ? arguments[1] : undefined; 4736 4737 switch (action.type) { 4738 case 'SET_TEMPLATE_VALIDITY': 4739 return { ...state, 4740 isValid: action.isValid 4741 }; 4742 } 4743 4744 return state; 4745 } 4746 /** 4747 * Reducer returning the editor setting. 4748 * 4749 * @param {Object} state Current state. 4750 * @param {Object} action Dispatched action. 4751 * 4752 * @return {Object} Updated state. 4753 */ 4754 4755 function settings() { 4756 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SETTINGS_DEFAULTS; 4757 let action = arguments.length > 1 ? arguments[1] : undefined; 4758 4759 switch (action.type) { 4760 case 'UPDATE_SETTINGS': 4761 return { ...state, 4762 ...action.settings 4763 }; 4764 } 4765 4766 return state; 4767 } 4768 /** 4769 * Reducer returning the user preferences. 4770 * 4771 * @param {Object} state Current state. 4772 * @param {Object} action Dispatched action. 4773 * 4774 * @return {string} Updated state. 4775 */ 4776 4777 function preferences() { 4778 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : PREFERENCES_DEFAULTS; 4779 let action = arguments.length > 1 ? arguments[1] : undefined; 4780 4781 switch (action.type) { 4782 case 'INSERT_BLOCKS': 4783 case 'REPLACE_BLOCKS': 4784 return action.blocks.reduce((prevState, block) => { 4785 const { 4786 attributes, 4787 name: blockName 4788 } = block; 4789 const match = (0,external_wp_data_namespaceObject.select)(external_wp_blocks_namespaceObject.store).getActiveBlockVariation(blockName, attributes); // If a block variation match is found change the name to be the same with the 4790 // one that is used for block variations in the Inserter (`getItemFromVariation`). 4791 4792 let id = match !== null && match !== void 0 && match.name ? `$blockName}/$match.name}` : blockName; 4793 const insert = { 4794 name: id 4795 }; 4796 4797 if (blockName === 'core/block') { 4798 insert.ref = attributes.ref; 4799 id += '/' + attributes.ref; 4800 } 4801 4802 return { ...prevState, 4803 insertUsage: { ...prevState.insertUsage, 4804 [id]: { 4805 time: action.time, 4806 count: prevState.insertUsage[id] ? prevState.insertUsage[id].count + 1 : 1, 4807 insert 4808 } 4809 } 4810 }; 4811 }, state); 4812 } 4813 4814 return state; 4815 } 4816 /** 4817 * Reducer returning an object where each key is a block client ID, its value 4818 * representing the settings for its nested blocks. 4819 * 4820 * @param {Object} state Current state. 4821 * @param {Object} action Dispatched action. 4822 * 4823 * @return {Object} Updated state. 4824 */ 4825 4826 const blockListSettings = function () { 4827 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 4828 let action = arguments.length > 1 ? arguments[1] : undefined; 4829 4830 switch (action.type) { 4831 // Even if the replaced blocks have the same client ID, our logic 4832 // should correct the state. 4833 case 'REPLACE_BLOCKS': 4834 case 'REMOVE_BLOCKS': 4835 { 4836 return (0,external_lodash_namespaceObject.omit)(state, action.clientIds); 4837 } 4838 4839 case 'UPDATE_BLOCK_LIST_SETTINGS': 4840 { 4841 const { 4842 clientId 4843 } = action; 4844 4845 if (!action.settings) { 4846 if (state.hasOwnProperty(clientId)) { 4847 return (0,external_lodash_namespaceObject.omit)(state, clientId); 4848 } 4849 4850 return state; 4851 } 4852 4853 if ((0,external_lodash_namespaceObject.isEqual)(state[clientId], action.settings)) { 4854 return state; 4855 } 4856 4857 return { ...state, 4858 [clientId]: action.settings 4859 }; 4860 } 4861 } 4862 4863 return state; 4864 }; 4865 /** 4866 * Reducer returning whether the navigation mode is enabled or not. 4867 * 4868 * @param {string} state Current state. 4869 * @param {Object} action Dispatched action. 4870 * 4871 * @return {string} Updated state. 4872 */ 4873 4874 function isNavigationMode() { 4875 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 4876 let action = arguments.length > 1 ? arguments[1] : undefined; 4877 4878 // Let inserting block always trigger Edit mode. 4879 if (action.type === 'INSERT_BLOCKS') { 4880 return false; 4881 } 4882 4883 if (action.type === 'SET_NAVIGATION_MODE') { 4884 return action.isNavigationMode; 4885 } 4886 4887 return state; 4888 } 4889 /** 4890 * Reducer returning whether the block moving mode is enabled or not. 4891 * 4892 * @param {string|null} state Current state. 4893 * @param {Object} action Dispatched action. 4894 * 4895 * @return {string|null} Updated state. 4896 */ 4897 4898 function hasBlockMovingClientId() { 4899 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 4900 let action = arguments.length > 1 ? arguments[1] : undefined; 4901 4902 // Let inserting block always trigger Edit mode. 4903 if (action.type === 'SET_BLOCK_MOVING_MODE') { 4904 return action.hasBlockMovingClientId; 4905 } 4906 4907 if (action.type === 'SET_NAVIGATION_MODE') { 4908 return null; 4909 } 4910 4911 return state; 4912 } 4913 /** 4914 * Reducer return an updated state representing the most recent block attribute 4915 * update. The state is structured as an object where the keys represent the 4916 * client IDs of blocks, the values a subset of attributes from the most recent 4917 * block update. The state is always reset to null if the last action is 4918 * anything other than an attributes update. 4919 * 4920 * @param {Object<string,Object>} state Current state. 4921 * @param {Object} action Action object. 4922 * 4923 * @return {[string,Object]} Updated state. 4924 */ 4925 4926 function lastBlockAttributesChange(state, action) { 4927 switch (action.type) { 4928 case 'UPDATE_BLOCK': 4929 if (!action.updates.attributes) { 4930 break; 4931 } 4932 4933 return { 4934 [action.clientId]: action.updates.attributes 4935 }; 4936 4937 case 'UPDATE_BLOCK_ATTRIBUTES': 4938 return action.clientIds.reduce((accumulator, id) => ({ ...accumulator, 4939 [id]: action.uniqueByBlock ? action.attributes[id] : action.attributes 4940 }), {}); 4941 } 4942 4943 return null; 4944 } 4945 /** 4946 * Reducer returning automatic change state. 4947 * 4948 * @param {boolean} state Current state. 4949 * @param {Object} action Dispatched action. 4950 * 4951 * @return {string} Updated state. 4952 */ 4953 4954 function automaticChangeStatus(state, action) { 4955 switch (action.type) { 4956 case 'MARK_AUTOMATIC_CHANGE': 4957 return 'pending'; 4958 4959 case 'MARK_AUTOMATIC_CHANGE_FINAL': 4960 if (state === 'pending') { 4961 return 'final'; 4962 } 4963 4964 return; 4965 4966 case 'SELECTION_CHANGE': 4967 // As long as the state is not final, ignore any selection changes. 4968 if (state !== 'final') { 4969 return state; 4970 } 4971 4972 return; 4973 // Undoing an automatic change should still be possible after mouse 4974 // move. 4975 4976 case 'START_TYPING': 4977 case 'STOP_TYPING': 4978 return state; 4979 } // Reset the state by default (for any action not handled). 4980 4981 } 4982 /** 4983 * Reducer returning current highlighted block. 4984 * 4985 * @param {boolean} state Current highlighted block. 4986 * @param {Object} action Dispatched action. 4987 * 4988 * @return {string} Updated state. 4989 */ 4990 4991 function highlightedBlock(state, action) { 4992 switch (action.type) { 4993 case 'TOGGLE_BLOCK_HIGHLIGHT': 4994 const { 4995 clientId, 4996 isHighlighted 4997 } = action; 4998 4999 if (isHighlighted) { 5000 return clientId; 5001 } else if (state === clientId) { 5002 return null; 5003 } 5004 5005 return state; 5006 5007 case 'SELECT_BLOCK': 5008 if (action.clientId !== state) { 5009 return null; 5010 } 5011 5012 } 5013 5014 return state; 5015 } 5016 /** 5017 * Reducer returning the block insertion event list state. 5018 * 5019 * @param {Object} state Current state. 5020 * @param {Object} action Dispatched action. 5021 * 5022 * @return {Object} Updated state. 5023 */ 5024 5025 function lastBlockInserted() { 5026 var _action$meta; 5027 5028 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 5029 let action = arguments.length > 1 ? arguments[1] : undefined; 5030 5031 switch (action.type) { 5032 case 'INSERT_BLOCKS': 5033 if (!action.blocks.length) { 5034 return state; 5035 } 5036 5037 const clientId = action.blocks[0].clientId; 5038 const source = (_action$meta = action.meta) === null || _action$meta === void 0 ? void 0 : _action$meta.source; 5039 return { 5040 clientId, 5041 source 5042 }; 5043 5044 case 'RESET_BLOCKS': 5045 return {}; 5046 } 5047 5048 return state; 5049 } 5050 /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ 5051 blocks, 5052 isTyping, 5053 draggedBlocks, 5054 isCaretWithinFormattedText, 5055 selection, 5056 isMultiSelecting, 5057 isSelectionEnabled, 5058 initialPosition, 5059 blocksMode, 5060 blockListSettings, 5061 insertionPoint, 5062 template, 5063 settings, 5064 preferences, 5065 lastBlockAttributesChange, 5066 isNavigationMode, 5067 hasBlockMovingClientId, 5068 automaticChangeStatus, 5069 highlightedBlock, 5070 lastBlockInserted 5071 })); 5072 5073 ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js 5074 5075 5076 var LEAF_KEY, hasWeakMap; 5077 5078 /** 5079 * Arbitrary value used as key for referencing cache object in WeakMap tree. 5080 * 5081 * @type {Object} 5082 */ 5083 LEAF_KEY = {}; 5084 5085 /** 5086 * Whether environment supports WeakMap. 5087 * 5088 * @type {boolean} 5089 */ 5090 hasWeakMap = typeof WeakMap !== 'undefined'; 5091 5092 /** 5093 * Returns the first argument as the sole entry in an array. 5094 * 5095 * @param {*} value Value to return. 5096 * 5097 * @return {Array} Value returned as entry in array. 5098 */ 5099 function arrayOf( value ) { 5100 return [ value ]; 5101 } 5102 5103 /** 5104 * Returns true if the value passed is object-like, or false otherwise. A value 5105 * is object-like if it can support property assignment, e.g. object or array. 5106 * 5107 * @param {*} value Value to test. 5108 * 5109 * @return {boolean} Whether value is object-like. 5110 */ 5111 function isObjectLike( value ) { 5112 return !! value && 'object' === typeof value; 5113 } 5114 5115 /** 5116 * Creates and returns a new cache object. 5117 * 5118 * @return {Object} Cache object. 5119 */ 5120 function createCache() { 5121 var cache = { 5122 clear: function() { 5123 cache.head = null; 5124 }, 5125 }; 5126 5127 return cache; 5128 } 5129 5130 /** 5131 * Returns true if entries within the two arrays are strictly equal by 5132 * reference from a starting index. 5133 * 5134 * @param {Array} a First array. 5135 * @param {Array} b Second array. 5136 * @param {number} fromIndex Index from which to start comparison. 5137 * 5138 * @return {boolean} Whether arrays are shallowly equal. 5139 */ 5140 function isShallowEqual( a, b, fromIndex ) { 5141 var i; 5142 5143 if ( a.length !== b.length ) { 5144 return false; 5145 } 5146 5147 for ( i = fromIndex; i < a.length; i++ ) { 5148 if ( a[ i ] !== b[ i ] ) { 5149 return false; 5150 } 5151 } 5152 5153 return true; 5154 } 5155 5156 /** 5157 * Returns a memoized selector function. The getDependants function argument is 5158 * called before the memoized selector and is expected to return an immutable 5159 * reference or array of references on which the selector depends for computing 5160 * its own return value. The memoize cache is preserved only as long as those 5161 * dependant references remain the same. If getDependants returns a different 5162 * reference(s), the cache is cleared and the selector value regenerated. 5163 * 5164 * @param {Function} selector Selector function. 5165 * @param {Function} getDependants Dependant getter returning an immutable 5166 * reference or array of reference used in 5167 * cache bust consideration. 5168 * 5169 * @return {Function} Memoized selector. 5170 */ 5171 /* harmony default export */ function rememo(selector, getDependants ) { 5172 var rootCache, getCache; 5173 5174 // Use object source as dependant if getter not provided 5175 if ( ! getDependants ) { 5176 getDependants = arrayOf; 5177 } 5178 5179 /** 5180 * Returns the root cache. If WeakMap is supported, this is assigned to the 5181 * root WeakMap cache set, otherwise it is a shared instance of the default 5182 * cache object. 5183 * 5184 * @return {(WeakMap|Object)} Root cache object. 5185 */ 5186 function getRootCache() { 5187 return rootCache; 5188 } 5189 5190 /** 5191 * Returns the cache for a given dependants array. When possible, a WeakMap 5192 * will be used to create a unique cache for each set of dependants. This 5193 * is feasible due to the nature of WeakMap in allowing garbage collection 5194 * to occur on entries where the key object is no longer referenced. Since 5195 * WeakMap requires the key to be an object, this is only possible when the 5196 * dependant is object-like. The root cache is created as a hierarchy where 5197 * each top-level key is the first entry in a dependants set, the value a 5198 * WeakMap where each key is the next dependant, and so on. This continues 5199 * so long as the dependants are object-like. If no dependants are object- 5200 * like, then the cache is shared across all invocations. 5201 * 5202 * @see isObjectLike 5203 * 5204 * @param {Array} dependants Selector dependants. 5205 * 5206 * @return {Object} Cache object. 5207 */ 5208 function getWeakMapCache( dependants ) { 5209 var caches = rootCache, 5210 isUniqueByDependants = true, 5211 i, dependant, map, cache; 5212 5213 for ( i = 0; i < dependants.length; i++ ) { 5214 dependant = dependants[ i ]; 5215 5216 // Can only compose WeakMap from object-like key. 5217 if ( ! isObjectLike( dependant ) ) { 5218 isUniqueByDependants = false; 5219 break; 5220 } 5221 5222 // Does current segment of cache already have a WeakMap? 5223 if ( caches.has( dependant ) ) { 5224 // Traverse into nested WeakMap. 5225 caches = caches.get( dependant ); 5226 } else { 5227 // Create, set, and traverse into a new one. 5228 map = new WeakMap(); 5229 caches.set( dependant, map ); 5230 caches = map; 5231 } 5232 } 5233 5234 // We use an arbitrary (but consistent) object as key for the last item 5235 // in the WeakMap to serve as our running cache. 5236 if ( ! caches.has( LEAF_KEY ) ) { 5237 cache = createCache(); 5238 cache.isUniqueByDependants = isUniqueByDependants; 5239 caches.set( LEAF_KEY, cache ); 5240 } 5241 5242 return caches.get( LEAF_KEY ); 5243 } 5244 5245 // Assign cache handler by availability of WeakMap 5246 getCache = hasWeakMap ? getWeakMapCache : getRootCache; 5247 5248 /** 5249 * Resets root memoization cache. 5250 */ 5251 function clear() { 5252 rootCache = hasWeakMap ? new WeakMap() : createCache(); 5253 } 5254 5255 // eslint-disable-next-line jsdoc/check-param-names 5256 /** 5257 * The augmented selector call, considering first whether dependants have 5258 * changed before passing it to underlying memoize function. 5259 * 5260 * @param {Object} source Source object for derivation. 5261 * @param {...*} extraArgs Additional arguments to pass to selector. 5262 * 5263 * @return {*} Selector result. 5264 */ 5265 function callSelector( /* source, ...extraArgs */ ) { 5266 var len = arguments.length, 5267 cache, node, i, args, dependants; 5268 5269 // Create copy of arguments (avoid leaking deoptimization). 5270 args = new Array( len ); 5271 for ( i = 0; i < len; i++ ) { 5272 args[ i ] = arguments[ i ]; 5273 } 5274 5275 dependants = getDependants.apply( null, args ); 5276 cache = getCache( dependants ); 5277 5278 // If not guaranteed uniqueness by dependants (primitive type or lack 5279 // of WeakMap support), shallow compare against last dependants and, if 5280 // references have changed, destroy cache to recalculate result. 5281 if ( ! cache.isUniqueByDependants ) { 5282 if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) { 5283 cache.clear(); 5284 } 5285 5286 cache.lastDependants = dependants; 5287 } 5288 5289 node = cache.head; 5290 while ( node ) { 5291 // Check whether node arguments match arguments 5292 if ( ! isShallowEqual( node.args, args, 1 ) ) { 5293 node = node.next; 5294 continue; 5295 } 5296 5297 // At this point we can assume we've found a match 5298 5299 // Surface matched node to head if not already 5300 if ( node !== cache.head ) { 5301 // Adjust siblings to point to each other. 5302 node.prev.next = node.next; 5303 if ( node.next ) { 5304 node.next.prev = node.prev; 5305 } 5306 5307 node.next = cache.head; 5308 node.prev = null; 5309 cache.head.prev = node; 5310 cache.head = node; 5311 } 5312 5313 // Return immediately 5314 return node.val; 5315 } 5316 5317 // No cached value found. Continue to insertion phase: 5318 5319 node = { 5320 // Generate the result from original function 5321 val: selector.apply( null, args ), 5322 }; 5323 5324 // Avoid including the source object in the cache. 5325 args[ 0 ] = null; 5326 node.args = args; 5327 5328 // Don't need to check whether node is already head, since it would 5329 // have been returned above already if it was 5330 5331 // Shift existing head down list 5332 if ( cache.head ) { 5333 cache.head.prev = node; 5334 node.next = cache.head; 5335 } 5336 5337 cache.head = node; 5338 5339 return node.val; 5340 } 5341 5342 callSelector.getDependants = getDependants; 5343 callSelector.clear = clear; 5344 clear(); 5345 5346 return callSelector; 5347 } 5348 5349 ;// CONCATENATED MODULE: external ["wp","primitives"] 5350 var external_wp_primitives_namespaceObject = window["wp"]["primitives"]; 5351 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js 5352 5353 5354 /** 5355 * WordPress dependencies 5356 */ 5357 5358 const symbol = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 5359 xmlns: "http://www.w3.org/2000/svg", 5360 viewBox: "0 0 24 24" 5361 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 5362 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" 5363 })); 5364 /* harmony default export */ var library_symbol = (symbol); 5365 5366 ;// CONCATENATED MODULE: external ["wp","richText"] 5367 var external_wp_richText_namespaceObject = window["wp"]["richText"]; 5368 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/utils.js 5369 /** 5370 * Helper function that maps attribute definition properties to the 5371 * ones used by RichText utils like `create, toHTMLString, etc..`. 5372 * 5373 * @param {Object} attributeDefinition A block's attribute definition object. 5374 * @return {Object} The mapped object. 5375 */ 5376 function mapRichTextSettings(attributeDefinition) { 5377 const { 5378 multiline: multilineTag, 5379 __unstableMultilineWrapperTags: multilineWrapperTags, 5380 __unstablePreserveWhiteSpace: preserveWhiteSpace 5381 } = attributeDefinition; 5382 return { 5383 multilineTag, 5384 multilineWrapperTags, 5385 preserveWhiteSpace 5386 }; 5387 } 5388 5389 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/selectors.js 5390 /** 5391 * External dependencies 5392 */ 5393 5394 5395 /** 5396 * WordPress dependencies 5397 */ 5398 5399 5400 5401 5402 5403 5404 5405 /** 5406 * Internal dependencies 5407 */ 5408 5409 5410 /** 5411 * A block selection object. 5412 * 5413 * @typedef {Object} WPBlockSelection 5414 * 5415 * @property {string} clientId A block client ID. 5416 * @property {string} attributeKey A block attribute key. 5417 * @property {number} offset An attribute value offset, based on the rich 5418 * text value. See `wp.richText.create`. 5419 */ 5420 // Module constants. 5421 5422 const MILLISECONDS_PER_HOUR = 3600 * 1000; 5423 const MILLISECONDS_PER_DAY = 24 * 3600 * 1000; 5424 const MILLISECONDS_PER_WEEK = 7 * 24 * 3600 * 1000; 5425 /** 5426 * Shared reference to an empty array for cases where it is important to avoid 5427 * returning a new array reference on every invocation, as in a connected or 5428 * other pure component which performs `shouldComponentUpdate` check on props. 5429 * This should be used as a last resort, since the normalized data should be 5430 * maintained by the reducer result in state. 5431 * 5432 * @type {Array} 5433 */ 5434 5435 const EMPTY_ARRAY = []; 5436 /** 5437 * Returns a block's name given its client ID, or null if no block exists with 5438 * the client ID. 5439 * 5440 * @param {Object} state Editor state. 5441 * @param {string} clientId Block client ID. 5442 * 5443 * @return {string} Block name. 5444 */ 5445 5446 function getBlockName(state, clientId) { 5447 const block = state.blocks.byClientId[clientId]; 5448 const socialLinkName = 'core/social-link'; 5449 5450 if (external_wp_element_namespaceObject.Platform.OS !== 'web' && (block === null || block === void 0 ? void 0 : block.name) === socialLinkName) { 5451 const attributes = state.blocks.attributes[clientId]; 5452 const { 5453 service 5454 } = attributes; 5455 return service ? `$socialLinkName}-$service}` : socialLinkName; 5456 } 5457 5458 return block ? block.name : null; 5459 } 5460 /** 5461 * Returns whether a block is valid or not. 5462 * 5463 * @param {Object} state Editor state. 5464 * @param {string} clientId Block client ID. 5465 * 5466 * @return {boolean} Is Valid. 5467 */ 5468 5469 function isBlockValid(state, clientId) { 5470 const block = state.blocks.byClientId[clientId]; 5471 return !!block && block.isValid; 5472 } 5473 /** 5474 * Returns a block's attributes given its client ID, or null if no block exists with 5475 * the client ID. 5476 * 5477 * @param {Object} state Editor state. 5478 * @param {string} clientId Block client ID. 5479 * 5480 * @return {Object?} Block attributes. 5481 */ 5482 5483 function getBlockAttributes(state, clientId) { 5484 const block = state.blocks.byClientId[clientId]; 5485 5486 if (!block) { 5487 return null; 5488 } 5489 5490 return state.blocks.attributes[clientId]; 5491 } 5492 /** 5493 * Returns a block given its client ID. This is a parsed copy of the block, 5494 * containing its `blockName`, `clientId`, and current `attributes` state. This 5495 * is not the block's registration settings, which must be retrieved from the 5496 * blocks module registration store. 5497 * 5498 * getBlock recurses through its inner blocks until all its children blocks have 5499 * been retrieved. Note that getBlock will not return the child inner blocks of 5500 * an inner block controller. This is because an inner block controller syncs 5501 * itself with its own entity, and should therefore not be included with the 5502 * blocks of a different entity. For example, say you call `getBlocks( TP )` to 5503 * get the blocks of a template part. If another template part is a child of TP, 5504 * then the nested template part's child blocks will not be returned. This way, 5505 * the template block itself is considered part of the parent, but the children 5506 * are not. 5507 * 5508 * @param {Object} state Editor state. 5509 * @param {string} clientId Block client ID. 5510 * 5511 * @return {Object} Parsed block object. 5512 */ 5513 5514 function getBlock(state, clientId) { 5515 const block = state.blocks.byClientId[clientId]; 5516 5517 if (!block) { 5518 return null; 5519 } 5520 5521 return state.blocks.tree[clientId]; 5522 } 5523 const __unstableGetBlockWithoutInnerBlocks = rememo((state, clientId) => { 5524 const block = state.blocks.byClientId[clientId]; 5525 5526 if (!block) { 5527 return null; 5528 } 5529 5530 return { ...block, 5531 attributes: getBlockAttributes(state, clientId) 5532 }; 5533 }, (state, clientId) => [state.blocks.byClientId[clientId], state.blocks.attributes[clientId]]); 5534 /** 5535 * Returns all block objects for the current post being edited as an array in 5536 * the order they appear in the post. Note that this will exclude child blocks 5537 * of nested inner block controllers. 5538 * 5539 * @param {Object} state Editor state. 5540 * @param {?string} rootClientId Optional root client ID of block list. 5541 * 5542 * @return {Object[]} Post blocks. 5543 */ 5544 5545 function getBlocks(state, rootClientId) { 5546 var _state$blocks$tree$tr; 5547 5548 const treeKey = !rootClientId || !areInnerBlocksControlled(state, rootClientId) ? rootClientId || '' : 'controlled||' + rootClientId; 5549 return ((_state$blocks$tree$tr = state.blocks.tree[treeKey]) === null || _state$blocks$tree$tr === void 0 ? void 0 : _state$blocks$tree$tr.innerBlocks) || EMPTY_ARRAY; 5550 } 5551 /** 5552 * Returns a stripped down block object containing only its client ID, 5553 * and its inner blocks' client IDs. 5554 * 5555 * @param {Object} state Editor state. 5556 * @param {string} clientId Client ID of the block to get. 5557 * 5558 * @return {Object} Client IDs of the post blocks. 5559 */ 5560 5561 const __unstableGetClientIdWithClientIdsTree = rememo((state, clientId) => ({ 5562 clientId, 5563 innerBlocks: __unstableGetClientIdsTree(state, clientId) 5564 }), state => [state.blocks.order]); 5565 /** 5566 * Returns the block tree represented in the block-editor store from the 5567 * given root, consisting of stripped down block objects containing only 5568 * their client IDs, and their inner blocks' client IDs. 5569 * 5570 * @param {Object} state Editor state. 5571 * @param {?string} rootClientId Optional root client ID of block list. 5572 * 5573 * @return {Object[]} Client IDs of the post blocks. 5574 */ 5575 5576 const __unstableGetClientIdsTree = rememo(function (state) { 5577 let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 5578 return (0,external_lodash_namespaceObject.map)(getBlockOrder(state, rootClientId), clientId => __unstableGetClientIdWithClientIdsTree(state, clientId)); 5579 }, state => [state.blocks.order]); 5580 /** 5581 * Returns an array containing the clientIds of all descendants of the blocks 5582 * given. Returned ids are ordered first by the order of the ids given, then 5583 * by the order that they appear in the editor. 5584 * 5585 * @param {Object} state Global application state. 5586 * @param {Array} clientIds Array of blocks to inspect. 5587 * 5588 * @return {Array} ids of descendants. 5589 */ 5590 5591 const getClientIdsOfDescendants = rememo((state, clientIds) => { 5592 const collectedIds = []; 5593 5594 for (const givenId of clientIds) { 5595 for (const descendantId of getBlockOrder(state, givenId)) { 5596 collectedIds.push(descendantId, ...getClientIdsOfDescendants(state, [descendantId])); 5597 } 5598 } 5599 5600 return collectedIds; 5601 }, state => [state.blocks.order]); 5602 /** 5603 * Returns an array containing the clientIds of the top-level blocks and 5604 * their descendants of any depth (for nested blocks). Ids are returned 5605 * in the same order that they appear in the editor. 5606 * 5607 * @param {Object} state Global application state. 5608 * 5609 * @return {Array} ids of top-level and descendant blocks. 5610 */ 5611 5612 const getClientIdsWithDescendants = rememo(state => { 5613 const collectedIds = []; 5614 5615 for (const topLevelId of getBlockOrder(state)) { 5616 collectedIds.push(topLevelId, ...getClientIdsOfDescendants(state, [topLevelId])); 5617 } 5618 5619 return collectedIds; 5620 }, state => [state.blocks.order]); 5621 /** 5622 * Returns the total number of blocks, or the total number of blocks with a specific name in a post. 5623 * The number returned includes nested blocks. 5624 * 5625 * @param {Object} state Global application state. 5626 * @param {?string} blockName Optional block name, if specified only blocks of that type will be counted. 5627 * 5628 * @return {number} Number of blocks in the post, or number of blocks with name equal to blockName. 5629 */ 5630 5631 const getGlobalBlockCount = rememo((state, blockName) => { 5632 const clientIds = getClientIdsWithDescendants(state); 5633 5634 if (!blockName) { 5635 return clientIds.length; 5636 } 5637 5638 return (0,external_lodash_namespaceObject.reduce)(clientIds, (accumulator, clientId) => { 5639 const block = state.blocks.byClientId[clientId]; 5640 return block.name === blockName ? accumulator + 1 : accumulator; 5641 }, 0); 5642 }, state => [state.blocks.order, state.blocks.byClientId]); 5643 /** 5644 * Returns all global blocks that match a blockName. Results include nested blocks. 5645 * 5646 * @param {Object} state Global application state. 5647 * @param {?string} blockName Optional block name, if not specified, returns an empty array. 5648 * 5649 * @return {Array} Array of clientIds of blocks with name equal to blockName. 5650 */ 5651 5652 const __experimentalGetGlobalBlocksByName = rememo((state, blockName) => { 5653 if (!blockName) { 5654 return EMPTY_ARRAY; 5655 } 5656 5657 const clientIds = getClientIdsWithDescendants(state); 5658 const foundBlocks = clientIds.filter(clientId => { 5659 const block = state.blocks.byClientId[clientId]; 5660 return block.name === blockName; 5661 }); 5662 return foundBlocks.length > 0 ? foundBlocks : EMPTY_ARRAY; 5663 }, state => [state.blocks.order, state.blocks.byClientId]); 5664 /** 5665 * Given an array of block client IDs, returns the corresponding array of block 5666 * objects. 5667 * 5668 * @param {Object} state Editor state. 5669 * @param {string[]} clientIds Client IDs for which blocks are to be returned. 5670 * 5671 * @return {WPBlock[]} Block objects. 5672 */ 5673 5674 const getBlocksByClientId = rememo((state, clientIds) => (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.castArray)(clientIds), clientId => getBlock(state, clientId)), (state, clientIds) => (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.castArray)(clientIds), clientId => state.blocks.tree[clientId])); 5675 /** 5676 * Returns the number of blocks currently present in the post. 5677 * 5678 * @param {Object} state Editor state. 5679 * @param {?string} rootClientId Optional root client ID of block list. 5680 * 5681 * @return {number} Number of blocks in the post. 5682 */ 5683 5684 function getBlockCount(state, rootClientId) { 5685 return getBlockOrder(state, rootClientId).length; 5686 } 5687 /** 5688 * Returns the current selection start block client ID, attribute key and text 5689 * offset. 5690 * 5691 * @param {Object} state Block editor state. 5692 * 5693 * @return {WPBlockSelection} Selection start information. 5694 */ 5695 5696 function getSelectionStart(state) { 5697 return state.selection.selectionStart; 5698 } 5699 /** 5700 * Returns the current selection end block client ID, attribute key and text 5701 * offset. 5702 * 5703 * @param {Object} state Block editor state. 5704 * 5705 * @return {WPBlockSelection} Selection end information. 5706 */ 5707 5708 function getSelectionEnd(state) { 5709 return state.selection.selectionEnd; 5710 } 5711 /** 5712 * Returns the current block selection start. This value may be null, and it 5713 * may represent either a singular block selection or multi-selection start. 5714 * A selection is singular if its start and end match. 5715 * 5716 * @param {Object} state Global application state. 5717 * 5718 * @return {?string} Client ID of block selection start. 5719 */ 5720 5721 function getBlockSelectionStart(state) { 5722 return state.selection.selectionStart.clientId; 5723 } 5724 /** 5725 * Returns the current block selection end. This value may be null, and it 5726 * may represent either a singular block selection or multi-selection end. 5727 * A selection is singular if its start and end match. 5728 * 5729 * @param {Object} state Global application state. 5730 * 5731 * @return {?string} Client ID of block selection end. 5732 */ 5733 5734 function getBlockSelectionEnd(state) { 5735 return state.selection.selectionEnd.clientId; 5736 } 5737 /** 5738 * Returns the number of blocks currently selected in the post. 5739 * 5740 * @param {Object} state Global application state. 5741 * 5742 * @return {number} Number of blocks selected in the post. 5743 */ 5744 5745 function getSelectedBlockCount(state) { 5746 const multiSelectedBlockCount = getMultiSelectedBlockClientIds(state).length; 5747 5748 if (multiSelectedBlockCount) { 5749 return multiSelectedBlockCount; 5750 } 5751 5752 return state.selection.selectionStart.clientId ? 1 : 0; 5753 } 5754 /** 5755 * Returns true if there is a single selected block, or false otherwise. 5756 * 5757 * @param {Object} state Editor state. 5758 * 5759 * @return {boolean} Whether a single block is selected. 5760 */ 5761 5762 function hasSelectedBlock(state) { 5763 const { 5764 selectionStart, 5765 selectionEnd 5766 } = state.selection; 5767 return !!selectionStart.clientId && selectionStart.clientId === selectionEnd.clientId; 5768 } 5769 /** 5770 * Returns the currently selected block client ID, or null if there is no 5771 * selected block. 5772 * 5773 * @param {Object} state Editor state. 5774 * 5775 * @return {?string} Selected block client ID. 5776 */ 5777 5778 function getSelectedBlockClientId(state) { 5779 const { 5780 selectionStart, 5781 selectionEnd 5782 } = state.selection; 5783 const { 5784 clientId 5785 } = selectionStart; 5786 5787 if (!clientId || clientId !== selectionEnd.clientId) { 5788 return null; 5789 } 5790 5791 return clientId; 5792 } 5793 /** 5794 * Returns the currently selected block, or null if there is no selected block. 5795 * 5796 * @param {Object} state Global application state. 5797 * 5798 * @return {?Object} Selected block. 5799 */ 5800 5801 function getSelectedBlock(state) { 5802 const clientId = getSelectedBlockClientId(state); 5803 return clientId ? getBlock(state, clientId) : null; 5804 } 5805 /** 5806 * Given a block client ID, returns the root block from which the block is 5807 * nested, an empty string for top-level blocks, or null if the block does not 5808 * exist. 5809 * 5810 * @param {Object} state Editor state. 5811 * @param {string} clientId Block from which to find root client ID. 5812 * 5813 * @return {?string} Root client ID, if exists 5814 */ 5815 5816 function getBlockRootClientId(state, clientId) { 5817 return state.blocks.parents[clientId] !== undefined ? state.blocks.parents[clientId] : null; 5818 } 5819 /** 5820 * Given a block client ID, returns the list of all its parents from top to bottom. 5821 * 5822 * @param {Object} state Editor state. 5823 * @param {string} clientId Block from which to find root client ID. 5824 * @param {boolean} ascending Order results from bottom to top (true) or top to bottom (false). 5825 * 5826 * @return {Array} ClientIDs of the parent blocks. 5827 */ 5828 5829 const getBlockParents = rememo(function (state, clientId) { 5830 let ascending = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 5831 const parents = []; 5832 let current = clientId; 5833 5834 while (!!state.blocks.parents[current]) { 5835 current = state.blocks.parents[current]; 5836 parents.push(current); 5837 } 5838 5839 return ascending ? parents : parents.reverse(); 5840 }, state => [state.blocks.parents]); 5841 /** 5842 * Given a block client ID and a block name, returns the list of all its parents 5843 * from top to bottom, filtered by the given name(s). For example, if passed 5844 * 'core/group' as the blockName, it will only return parents which are group 5845 * blocks. If passed `[ 'core/group', 'core/cover']`, as the blockName, it will 5846 * return parents which are group blocks and parents which are cover blocks. 5847 * 5848 * @param {Object} state Editor state. 5849 * @param {string} clientId Block from which to find root client ID. 5850 * @param {string|string[]} blockName Block name(s) to filter. 5851 * @param {boolean} ascending Order results from bottom to top (true) or top to bottom (false). 5852 * 5853 * @return {Array} ClientIDs of the parent blocks. 5854 */ 5855 5856 const getBlockParentsByBlockName = rememo(function (state, clientId, blockName) { 5857 let ascending = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; 5858 const parents = getBlockParents(state, clientId, ascending); 5859 return (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.filter)((0,external_lodash_namespaceObject.map)(parents, id => ({ 5860 id, 5861 name: getBlockName(state, id) 5862 })), _ref => { 5863 let { 5864 name 5865 } = _ref; 5866 5867 if (Array.isArray(blockName)) { 5868 return blockName.includes(name); 5869 } 5870 5871 return name === blockName; 5872 }), _ref2 => { 5873 let { 5874 id 5875 } = _ref2; 5876 return id; 5877 }); 5878 }, state => [state.blocks.parents]); 5879 /** 5880 * Given a block client ID, returns the root of the hierarchy from which the block is nested, return the block itself for root level blocks. 5881 * 5882 * @param {Object} state Editor state. 5883 * @param {string} clientId Block from which to find root client ID. 5884 * 5885 * @return {string} Root client ID 5886 */ 5887 5888 function getBlockHierarchyRootClientId(state, clientId) { 5889 let current = clientId; 5890 let parent; 5891 5892 do { 5893 parent = current; 5894 current = state.blocks.parents[current]; 5895 } while (current); 5896 5897 return parent; 5898 } 5899 /** 5900 * Given a block client ID, returns the lowest common ancestor with selected client ID. 5901 * 5902 * @param {Object} state Editor state. 5903 * @param {string} clientId Block from which to find common ancestor client ID. 5904 * 5905 * @return {string} Common ancestor client ID or undefined 5906 */ 5907 5908 function getLowestCommonAncestorWithSelectedBlock(state, clientId) { 5909 const selectedId = getSelectedBlockClientId(state); 5910 const clientParents = [...getBlockParents(state, clientId), clientId]; 5911 const selectedParents = [...getBlockParents(state, selectedId), selectedId]; 5912 let lowestCommonAncestor; 5913 const maxDepth = Math.min(clientParents.length, selectedParents.length); 5914 5915 for (let index = 0; index < maxDepth; index++) { 5916 if (clientParents[index] === selectedParents[index]) { 5917 lowestCommonAncestor = clientParents[index]; 5918 } else { 5919 break; 5920 } 5921 } 5922 5923 return lowestCommonAncestor; 5924 } 5925 /** 5926 * Returns the client ID of the block adjacent one at the given reference 5927 * startClientId and modifier directionality. Defaults start startClientId to 5928 * the selected block, and direction as next block. Returns null if there is no 5929 * adjacent block. 5930 * 5931 * @param {Object} state Editor state. 5932 * @param {?string} startClientId Optional client ID of block from which to 5933 * search. 5934 * @param {?number} modifier Directionality multiplier (1 next, -1 5935 * previous). 5936 * 5937 * @return {?string} Return the client ID of the block, or null if none exists. 5938 */ 5939 5940 function getAdjacentBlockClientId(state, startClientId) { 5941 let modifier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; 5942 5943 // Default to selected block. 5944 if (startClientId === undefined) { 5945 startClientId = getSelectedBlockClientId(state); 5946 } // Try multi-selection starting at extent based on modifier. 5947 5948 5949 if (startClientId === undefined) { 5950 if (modifier < 0) { 5951 startClientId = getFirstMultiSelectedBlockClientId(state); 5952 } else { 5953 startClientId = getLastMultiSelectedBlockClientId(state); 5954 } 5955 } // Validate working start client ID. 5956 5957 5958 if (!startClientId) { 5959 return null; 5960 } // Retrieve start block root client ID, being careful to allow the falsey 5961 // empty string top-level root by explicitly testing against null. 5962 5963 5964 const rootClientId = getBlockRootClientId(state, startClientId); 5965 5966 if (rootClientId === null) { 5967 return null; 5968 } 5969 5970 const { 5971 order 5972 } = state.blocks; 5973 const orderSet = order[rootClientId]; 5974 const index = orderSet.indexOf(startClientId); 5975 const nextIndex = index + 1 * modifier; // Block was first in set and we're attempting to get previous. 5976 5977 if (nextIndex < 0) { 5978 return null; 5979 } // Block was last in set and we're attempting to get next. 5980 5981 5982 if (nextIndex === orderSet.length) { 5983 return null; 5984 } // Assume incremented index is within the set. 5985 5986 5987 return orderSet[nextIndex]; 5988 } 5989 /** 5990 * Returns the previous block's client ID from the given reference start ID. 5991 * Defaults start to the selected block. Returns null if there is no previous 5992 * block. 5993 * 5994 * @param {Object} state Editor state. 5995 * @param {?string} startClientId Optional client ID of block from which to 5996 * search. 5997 * 5998 * @return {?string} Adjacent block's client ID, or null if none exists. 5999 */ 6000 6001 function getPreviousBlockClientId(state, startClientId) { 6002 return getAdjacentBlockClientId(state, startClientId, -1); 6003 } 6004 /** 6005 * Returns the next block's client ID from the given reference start ID. 6006 * Defaults start to the selected block. Returns null if there is no next 6007 * block. 6008 * 6009 * @param {Object} state Editor state. 6010 * @param {?string} startClientId Optional client ID of block from which to 6011 * search. 6012 * 6013 * @return {?string} Adjacent block's client ID, or null if none exists. 6014 */ 6015 6016 function getNextBlockClientId(state, startClientId) { 6017 return getAdjacentBlockClientId(state, startClientId, 1); 6018 } 6019 /* eslint-disable jsdoc/valid-types */ 6020 6021 /** 6022 * Returns the initial caret position for the selected block. 6023 * This position is to used to position the caret properly when the selected block changes. 6024 * If the current block is not a RichText, having initial position set to 0 means "focus block" 6025 * 6026 * @param {Object} state Global application state. 6027 * 6028 * @return {0|-1|null} Initial position. 6029 */ 6030 6031 function getSelectedBlocksInitialCaretPosition(state) { 6032 /* eslint-enable jsdoc/valid-types */ 6033 return state.initialPosition; 6034 } 6035 /** 6036 * Returns the current selection set of block client IDs (multiselection or single selection). 6037 * 6038 * @param {Object} state Editor state. 6039 * 6040 * @return {Array} Multi-selected block client IDs. 6041 */ 6042 6043 const getSelectedBlockClientIds = rememo(state => { 6044 const { 6045 selectionStart, 6046 selectionEnd 6047 } = state.selection; 6048 6049 if (selectionStart.clientId === undefined || selectionEnd.clientId === undefined) { 6050 return EMPTY_ARRAY; 6051 } 6052 6053 if (selectionStart.clientId === selectionEnd.clientId) { 6054 return [selectionStart.clientId]; 6055 } // Retrieve root client ID to aid in retrieving relevant nested block 6056 // order, being careful to allow the falsey empty string top-level root 6057 // by explicitly testing against null. 6058 6059 6060 const rootClientId = getBlockRootClientId(state, selectionStart.clientId); 6061 6062 if (rootClientId === null) { 6063 return EMPTY_ARRAY; 6064 } 6065 6066 const blockOrder = getBlockOrder(state, rootClientId); 6067 const startIndex = blockOrder.indexOf(selectionStart.clientId); 6068 const endIndex = blockOrder.indexOf(selectionEnd.clientId); 6069 6070 if (startIndex > endIndex) { 6071 return blockOrder.slice(endIndex, startIndex + 1); 6072 } 6073 6074 return blockOrder.slice(startIndex, endIndex + 1); 6075 }, state => [state.blocks.order, state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId]); 6076 /** 6077 * Returns the current multi-selection set of block client IDs, or an empty 6078 * array if there is no multi-selection. 6079 * 6080 * @param {Object} state Editor state. 6081 * 6082 * @return {Array} Multi-selected block client IDs. 6083 */ 6084 6085 function getMultiSelectedBlockClientIds(state) { 6086 const { 6087 selectionStart, 6088 selectionEnd 6089 } = state.selection; 6090 6091 if (selectionStart.clientId === selectionEnd.clientId) { 6092 return EMPTY_ARRAY; 6093 } 6094 6095 return getSelectedBlockClientIds(state); 6096 } 6097 /** 6098 * Returns the current multi-selection set of blocks, or an empty array if 6099 * there is no multi-selection. 6100 * 6101 * @param {Object} state Editor state. 6102 * 6103 * @return {Array} Multi-selected block objects. 6104 */ 6105 6106 const getMultiSelectedBlocks = rememo(state => { 6107 const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds(state); 6108 6109 if (!multiSelectedBlockClientIds.length) { 6110 return EMPTY_ARRAY; 6111 } 6112 6113 return multiSelectedBlockClientIds.map(clientId => getBlock(state, clientId)); 6114 }, state => [...getSelectedBlockClientIds.getDependants(state), state.blocks.byClientId, state.blocks.order, state.blocks.attributes]); 6115 /** 6116 * Returns the client ID of the first block in the multi-selection set, or null 6117 * if there is no multi-selection. 6118 * 6119 * @param {Object} state Editor state. 6120 * 6121 * @return {?string} First block client ID in the multi-selection set. 6122 */ 6123 6124 function getFirstMultiSelectedBlockClientId(state) { 6125 return (0,external_lodash_namespaceObject.first)(getMultiSelectedBlockClientIds(state)) || null; 6126 } 6127 /** 6128 * Returns the client ID of the last block in the multi-selection set, or null 6129 * if there is no multi-selection. 6130 * 6131 * @param {Object} state Editor state. 6132 * 6133 * @return {?string} Last block client ID in the multi-selection set. 6134 */ 6135 6136 function getLastMultiSelectedBlockClientId(state) { 6137 return (0,external_lodash_namespaceObject.last)(getMultiSelectedBlockClientIds(state)) || null; 6138 } 6139 /** 6140 * Returns true if a multi-selection exists, and the block corresponding to the 6141 * specified client ID is the first block of the multi-selection set, or false 6142 * otherwise. 6143 * 6144 * @param {Object} state Editor state. 6145 * @param {string} clientId Block client ID. 6146 * 6147 * @return {boolean} Whether block is first in multi-selection. 6148 */ 6149 6150 function isFirstMultiSelectedBlock(state, clientId) { 6151 return getFirstMultiSelectedBlockClientId(state) === clientId; 6152 } 6153 /** 6154 * Returns true if the client ID occurs within the block multi-selection, or 6155 * false otherwise. 6156 * 6157 * @param {Object} state Editor state. 6158 * @param {string} clientId Block client ID. 6159 * 6160 * @return {boolean} Whether block is in multi-selection set. 6161 */ 6162 6163 function isBlockMultiSelected(state, clientId) { 6164 return getMultiSelectedBlockClientIds(state).indexOf(clientId) !== -1; 6165 } 6166 /** 6167 * Returns true if an ancestor of the block is multi-selected, or false 6168 * otherwise. 6169 * 6170 * @param {Object} state Editor state. 6171 * @param {string} clientId Block client ID. 6172 * 6173 * @return {boolean} Whether an ancestor of the block is in multi-selection 6174 * set. 6175 */ 6176 6177 const isAncestorMultiSelected = rememo((state, clientId) => { 6178 let ancestorClientId = clientId; 6179 let isMultiSelected = false; 6180 6181 while (ancestorClientId && !isMultiSelected) { 6182 ancestorClientId = getBlockRootClientId(state, ancestorClientId); 6183 isMultiSelected = isBlockMultiSelected(state, ancestorClientId); 6184 } 6185 6186 return isMultiSelected; 6187 }, state => [state.blocks.order, state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId]); 6188 /** 6189 * Returns the client ID of the block which begins the multi-selection set, or 6190 * null if there is no multi-selection. 6191 * 6192 * This is not necessarily the first client ID in the selection. 6193 * 6194 * @see getFirstMultiSelectedBlockClientId 6195 * 6196 * @param {Object} state Editor state. 6197 * 6198 * @return {?string} Client ID of block beginning multi-selection. 6199 */ 6200 6201 function getMultiSelectedBlocksStartClientId(state) { 6202 const { 6203 selectionStart, 6204 selectionEnd 6205 } = state.selection; 6206 6207 if (selectionStart.clientId === selectionEnd.clientId) { 6208 return null; 6209 } 6210 6211 return selectionStart.clientId || null; 6212 } 6213 /** 6214 * Returns the client ID of the block which ends the multi-selection set, or 6215 * null if there is no multi-selection. 6216 * 6217 * This is not necessarily the last client ID in the selection. 6218 * 6219 * @see getLastMultiSelectedBlockClientId 6220 * 6221 * @param {Object} state Editor state. 6222 * 6223 * @return {?string} Client ID of block ending multi-selection. 6224 */ 6225 6226 function getMultiSelectedBlocksEndClientId(state) { 6227 const { 6228 selectionStart, 6229 selectionEnd 6230 } = state.selection; 6231 6232 if (selectionStart.clientId === selectionEnd.clientId) { 6233 return null; 6234 } 6235 6236 return selectionEnd.clientId || null; 6237 } 6238 /** 6239 * Returns true if the selection is not partial. 6240 * 6241 * @param {Object} state Editor state. 6242 * 6243 * @return {boolean} Whether the selection is mergeable. 6244 */ 6245 6246 function __unstableIsFullySelected(state) { 6247 const selectionAnchor = getSelectionStart(state); 6248 const selectionFocus = getSelectionEnd(state); 6249 return !selectionAnchor.attributeKey && !selectionFocus.attributeKey && typeof selectionAnchor.offset === 'undefined' && typeof selectionFocus.offset === 'undefined'; 6250 } 6251 /** 6252 * Returns true if the selection is collapsed. 6253 * 6254 * @param {Object} state Editor state. 6255 * 6256 * @return {boolean} Whether the selection is collapsed. 6257 */ 6258 6259 function __unstableIsSelectionCollapsed(state) { 6260 const selectionAnchor = getSelectionStart(state); 6261 const selectionFocus = getSelectionEnd(state); 6262 return !!selectionAnchor && !!selectionFocus && selectionAnchor.clientId === selectionFocus.clientId && selectionAnchor.attributeKey === selectionFocus.attributeKey && selectionAnchor.offset === selectionFocus.offset; 6263 } 6264 /** 6265 * Check whether the selection is mergeable. 6266 * 6267 * @param {Object} state Editor state. 6268 * @param {boolean} isForward Whether to merge forwards. 6269 * 6270 * @return {boolean} Whether the selection is mergeable. 6271 */ 6272 6273 function __unstableIsSelectionMergeable(state, isForward) { 6274 const selectionAnchor = getSelectionStart(state); 6275 const selectionFocus = getSelectionEnd(state); // It's not mergeable if the start and end are within the same block. 6276 6277 if (selectionAnchor.clientId === selectionFocus.clientId) return false; // It's not mergeable if there's no rich text selection. 6278 6279 if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') return false; 6280 const anchorRootClientId = getBlockRootClientId(state, selectionAnchor.clientId); 6281 const focusRootClientId = getBlockRootClientId(state, selectionFocus.clientId); // It's not mergeable if the selection doesn't start and end in the same 6282 // block list. Maybe in the future it should be allowed. 6283 6284 if (anchorRootClientId !== focusRootClientId) { 6285 return false; 6286 } 6287 6288 const blockOrder = getBlockOrder(state, anchorRootClientId); 6289 const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId); 6290 const focusIndex = blockOrder.indexOf(selectionFocus.clientId); // Reassign selection start and end based on order. 6291 6292 let selectionStart, selectionEnd; 6293 6294 if (anchorIndex > focusIndex) { 6295 selectionStart = selectionFocus; 6296 selectionEnd = selectionAnchor; 6297 } else { 6298 selectionStart = selectionAnchor; 6299 selectionEnd = selectionFocus; 6300 } 6301 6302 const targetBlockClientId = isForward ? selectionEnd.clientId : selectionStart.clientId; 6303 const blockToMergeClientId = isForward ? selectionStart.clientId : selectionEnd.clientId; 6304 const targetBlock = getBlock(state, targetBlockClientId); 6305 const targetBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(targetBlock.name); 6306 if (!targetBlockType.merge) return false; 6307 const blockToMerge = getBlock(state, blockToMergeClientId); // It's mergeable if the blocks are of the same type. 6308 6309 if (blockToMerge.name === targetBlock.name) return true; // If the blocks are of a different type, try to transform the block being 6310 // merged into the same type of block. 6311 6312 const blocksToMerge = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blockToMerge, targetBlock.name); 6313 return blocksToMerge && blocksToMerge.length; 6314 } 6315 /** 6316 * Get partial selected blocks with their content updated 6317 * based on the selection. 6318 * 6319 * @param {Object} state Editor state. 6320 * 6321 * @return {Object[]} Updated partial selected blocks. 6322 */ 6323 6324 const __unstableGetSelectedBlocksWithPartialSelection = state => { 6325 const selectionAnchor = getSelectionStart(state); 6326 const selectionFocus = getSelectionEnd(state); 6327 6328 if (selectionAnchor.clientId === selectionFocus.clientId) { 6329 return EMPTY_ARRAY; 6330 } // Can't split if the selection is not set. 6331 6332 6333 if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') { 6334 return EMPTY_ARRAY; 6335 } 6336 6337 const anchorRootClientId = getBlockRootClientId(state, selectionAnchor.clientId); 6338 const focusRootClientId = getBlockRootClientId(state, selectionFocus.clientId); // It's not splittable if the selection doesn't start and end in the same 6339 // block list. Maybe in the future it should be allowed. 6340 6341 if (anchorRootClientId !== focusRootClientId) { 6342 return EMPTY_ARRAY; 6343 } 6344 6345 const blockOrder = getBlockOrder(state, anchorRootClientId); 6346 const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId); 6347 const focusIndex = blockOrder.indexOf(selectionFocus.clientId); // Reassign selection start and end based on order. 6348 6349 const [selectionStart, selectionEnd] = anchorIndex > focusIndex ? [selectionFocus, selectionAnchor] : [selectionAnchor, selectionFocus]; 6350 const blockA = getBlock(state, selectionStart.clientId); 6351 const blockAType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockA.name); 6352 const blockB = getBlock(state, selectionEnd.clientId); 6353 const blockBType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockB.name); 6354 const htmlA = blockA.attributes[selectionStart.attributeKey]; 6355 const htmlB = blockB.attributes[selectionEnd.attributeKey]; 6356 const attributeDefinitionA = blockAType.attributes[selectionStart.attributeKey]; 6357 const attributeDefinitionB = blockBType.attributes[selectionEnd.attributeKey]; 6358 let valueA = (0,external_wp_richText_namespaceObject.create)({ 6359 html: htmlA, 6360 ...mapRichTextSettings(attributeDefinitionA) 6361 }); 6362 let valueB = (0,external_wp_richText_namespaceObject.create)({ 6363 html: htmlB, 6364 ...mapRichTextSettings(attributeDefinitionB) 6365 }); 6366 valueA = (0,external_wp_richText_namespaceObject.remove)(valueA, 0, selectionStart.offset); 6367 valueB = (0,external_wp_richText_namespaceObject.remove)(valueB, selectionEnd.offset, valueB.text.length); 6368 return [{ ...blockA, 6369 attributes: { ...blockA.attributes, 6370 [selectionStart.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({ 6371 value: valueA, 6372 ...mapRichTextSettings(attributeDefinitionA) 6373 }) 6374 } 6375 }, { ...blockB, 6376 attributes: { ...blockB.attributes, 6377 [selectionEnd.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({ 6378 value: valueB, 6379 ...mapRichTextSettings(attributeDefinitionB) 6380 }) 6381 } 6382 }]; 6383 }; 6384 /** 6385 * Returns an array containing all block client IDs in the editor in the order 6386 * they appear. Optionally accepts a root client ID of the block list for which 6387 * the order should be returned, defaulting to the top-level block order. 6388 * 6389 * @param {Object} state Editor state. 6390 * @param {?string} rootClientId Optional root client ID of block list. 6391 * 6392 * @return {Array} Ordered client IDs of editor blocks. 6393 */ 6394 6395 function getBlockOrder(state, rootClientId) { 6396 return state.blocks.order[rootClientId || ''] || EMPTY_ARRAY; 6397 } 6398 /** 6399 * Returns the index at which the block corresponding to the specified client 6400 * ID occurs within the block order, or `-1` if the block does not exist. 6401 * 6402 * @param {Object} state Editor state. 6403 * @param {string} clientId Block client ID. 6404 * 6405 * @return {number} Index at which block exists in order. 6406 */ 6407 6408 function getBlockIndex(state, clientId) { 6409 const rootClientId = getBlockRootClientId(state, clientId); 6410 return getBlockOrder(state, rootClientId).indexOf(clientId); 6411 } 6412 /** 6413 * Returns true if the block corresponding to the specified client ID is 6414 * currently selected and no multi-selection exists, or false otherwise. 6415 * 6416 * @param {Object} state Editor state. 6417 * @param {string} clientId Block client ID. 6418 * 6419 * @return {boolean} Whether block is selected and multi-selection exists. 6420 */ 6421 6422 function isBlockSelected(state, clientId) { 6423 const { 6424 selectionStart, 6425 selectionEnd 6426 } = state.selection; 6427 6428 if (selectionStart.clientId !== selectionEnd.clientId) { 6429 return false; 6430 } 6431 6432 return selectionStart.clientId === clientId; 6433 } 6434 /** 6435 * Returns true if one of the block's inner blocks is selected. 6436 * 6437 * @param {Object} state Editor state. 6438 * @param {string} clientId Block client ID. 6439 * @param {boolean} deep Perform a deep check. 6440 * 6441 * @return {boolean} Whether the block as an inner block selected 6442 */ 6443 6444 function hasSelectedInnerBlock(state, clientId) { 6445 let deep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 6446 return (0,external_lodash_namespaceObject.some)(getBlockOrder(state, clientId), innerClientId => isBlockSelected(state, innerClientId) || isBlockMultiSelected(state, innerClientId) || deep && hasSelectedInnerBlock(state, innerClientId, deep)); 6447 } 6448 /** 6449 * Returns true if the block corresponding to the specified client ID is 6450 * currently selected but isn't the last of the selected blocks. Here "last" 6451 * refers to the block sequence in the document, _not_ the sequence of 6452 * multi-selection, which is why `state.selectionEnd` isn't used. 6453 * 6454 * @param {Object} state Editor state. 6455 * @param {string} clientId Block client ID. 6456 * 6457 * @return {boolean} Whether block is selected and not the last in the 6458 * selection. 6459 */ 6460 6461 function isBlockWithinSelection(state, clientId) { 6462 if (!clientId) { 6463 return false; 6464 } 6465 6466 const clientIds = getMultiSelectedBlockClientIds(state); 6467 const index = clientIds.indexOf(clientId); 6468 return index > -1 && index < clientIds.length - 1; 6469 } 6470 /** 6471 * Returns true if a multi-selection has been made, or false otherwise. 6472 * 6473 * @param {Object} state Editor state. 6474 * 6475 * @return {boolean} Whether multi-selection has been made. 6476 */ 6477 6478 function hasMultiSelection(state) { 6479 const { 6480 selectionStart, 6481 selectionEnd 6482 } = state.selection; 6483 return selectionStart.clientId !== selectionEnd.clientId; 6484 } 6485 /** 6486 * Whether in the process of multi-selecting or not. This flag is only true 6487 * while the multi-selection is being selected (by mouse move), and is false 6488 * once the multi-selection has been settled. 6489 * 6490 * @see hasMultiSelection 6491 * 6492 * @param {Object} state Global application state. 6493 * 6494 * @return {boolean} True if multi-selecting, false if not. 6495 */ 6496 6497 function selectors_isMultiSelecting(state) { 6498 return state.isMultiSelecting; 6499 } 6500 /** 6501 * Selector that returns if multi-selection is enabled or not. 6502 * 6503 * @param {Object} state Global application state. 6504 * 6505 * @return {boolean} True if it should be possible to multi-select blocks, false if multi-selection is disabled. 6506 */ 6507 6508 function selectors_isSelectionEnabled(state) { 6509 return state.isSelectionEnabled; 6510 } 6511 /** 6512 * Returns the block's editing mode, defaulting to "visual" if not explicitly 6513 * assigned. 6514 * 6515 * @param {Object} state Editor state. 6516 * @param {string} clientId Block client ID. 6517 * 6518 * @return {Object} Block editing mode. 6519 */ 6520 6521 function getBlockMode(state, clientId) { 6522 return state.blocksMode[clientId] || 'visual'; 6523 } 6524 /** 6525 * Returns true if the user is typing, or false otherwise. 6526 * 6527 * @param {Object} state Global application state. 6528 * 6529 * @return {boolean} Whether user is typing. 6530 */ 6531 6532 function selectors_isTyping(state) { 6533 return state.isTyping; 6534 } 6535 /** 6536 * Returns true if the user is dragging blocks, or false otherwise. 6537 * 6538 * @param {Object} state Global application state. 6539 * 6540 * @return {boolean} Whether user is dragging blocks. 6541 */ 6542 6543 function isDraggingBlocks(state) { 6544 return !!state.draggedBlocks.length; 6545 } 6546 /** 6547 * Returns the client ids of any blocks being directly dragged. 6548 * 6549 * This does not include children of a parent being dragged. 6550 * 6551 * @param {Object} state Global application state. 6552 * 6553 * @return {string[]} Array of dragged block client ids. 6554 */ 6555 6556 function getDraggedBlockClientIds(state) { 6557 return state.draggedBlocks; 6558 } 6559 /** 6560 * Returns whether the block is being dragged. 6561 * 6562 * Only returns true if the block is being directly dragged, 6563 * not if the block is a child of a parent being dragged. 6564 * See `isAncestorBeingDragged` for child blocks. 6565 * 6566 * @param {Object} state Global application state. 6567 * @param {string} clientId Client id for block to check. 6568 * 6569 * @return {boolean} Whether the block is being dragged. 6570 */ 6571 6572 function isBlockBeingDragged(state, clientId) { 6573 return state.draggedBlocks.includes(clientId); 6574 } 6575 /** 6576 * Returns whether a parent/ancestor of the block is being dragged. 6577 * 6578 * @param {Object} state Global application state. 6579 * @param {string} clientId Client id for block to check. 6580 * 6581 * @return {boolean} Whether the block's ancestor is being dragged. 6582 */ 6583 6584 function isAncestorBeingDragged(state, clientId) { 6585 // Return early if no blocks are being dragged rather than 6586 // the more expensive check for parents. 6587 if (!isDraggingBlocks(state)) { 6588 return false; 6589 } 6590 6591 const parents = getBlockParents(state, clientId); 6592 return (0,external_lodash_namespaceObject.some)(parents, parentClientId => isBlockBeingDragged(state, parentClientId)); 6593 } 6594 /** 6595 * Returns true if the caret is within formatted text, or false otherwise. 6596 * 6597 * @param {Object} state Global application state. 6598 * 6599 * @return {boolean} Whether the caret is within formatted text. 6600 */ 6601 6602 function selectors_isCaretWithinFormattedText(state) { 6603 return state.isCaretWithinFormattedText; 6604 } 6605 /** 6606 * Returns the insertion point, the index at which the new inserted block would 6607 * be placed. Defaults to the last index. 6608 * 6609 * @param {Object} state Editor state. 6610 * 6611 * @return {Object} Insertion point object with `rootClientId`, `index`. 6612 */ 6613 6614 function getBlockInsertionPoint(state) { 6615 let rootClientId, index; 6616 const { 6617 insertionPoint, 6618 selection: { 6619 selectionEnd 6620 } 6621 } = state; 6622 6623 if (insertionPoint !== null) { 6624 return insertionPoint; 6625 } 6626 6627 const { 6628 clientId 6629 } = selectionEnd; 6630 6631 if (clientId) { 6632 rootClientId = getBlockRootClientId(state, clientId) || undefined; 6633 index = getBlockIndex(state, selectionEnd.clientId, rootClientId) + 1; 6634 } else { 6635 index = getBlockOrder(state).length; 6636 } 6637 6638 return { 6639 rootClientId, 6640 index 6641 }; 6642 } 6643 /** 6644 * Returns true if we should show the block insertion point. 6645 * 6646 * @param {Object} state Global application state. 6647 * 6648 * @return {?boolean} Whether the insertion point is visible or not. 6649 */ 6650 6651 function isBlockInsertionPointVisible(state) { 6652 return state.insertionPoint !== null; 6653 } 6654 /** 6655 * Returns whether the blocks matches the template or not. 6656 * 6657 * @param {boolean} state 6658 * @return {?boolean} Whether the template is valid or not. 6659 */ 6660 6661 function isValidTemplate(state) { 6662 return state.template.isValid; 6663 } 6664 /** 6665 * Returns the defined block template 6666 * 6667 * @param {boolean} state 6668 * 6669 * @return {?Array} Block Template. 6670 */ 6671 6672 function getTemplate(state) { 6673 return state.settings.template; 6674 } 6675 /** 6676 * Returns the defined block template lock. Optionally accepts a root block 6677 * client ID as context, otherwise defaulting to the global context. 6678 * 6679 * @param {Object} state Editor state. 6680 * @param {?string} rootClientId Optional block root client ID. 6681 * 6682 * @return {?string} Block Template Lock 6683 */ 6684 6685 function getTemplateLock(state, rootClientId) { 6686 if (!rootClientId) { 6687 return state.settings.templateLock; 6688 } 6689 6690 const blockListSettings = getBlockListSettings(state, rootClientId); 6691 6692 if (!blockListSettings) { 6693 return null; 6694 } 6695 6696 return blockListSettings.templateLock; 6697 } 6698 6699 const checkAllowList = function (list, item) { 6700 let defaultResult = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 6701 6702 if ((0,external_lodash_namespaceObject.isBoolean)(list)) { 6703 return list; 6704 } 6705 6706 if ((0,external_lodash_namespaceObject.isArray)(list)) { 6707 // TODO: when there is a canonical way to detect that we are editing a post 6708 // the following check should be changed to something like: 6709 // if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null ) 6710 if (list.includes('core/post-content') && item === null) { 6711 return true; 6712 } 6713 6714 return list.includes(item); 6715 } 6716 6717 return defaultResult; 6718 }; 6719 /** 6720 * Determines if the given block type is allowed to be inserted into the block list. 6721 * This function is not exported and not memoized because using a memoized selector 6722 * inside another memoized selector is just a waste of time. 6723 * 6724 * @param {Object} state Editor state. 6725 * @param {string|Object} blockName The block type object, e.g., the response 6726 * from the block directory; or a string name of 6727 * an installed block type, e.g.' core/paragraph'. 6728 * @param {?string} rootClientId Optional root client ID of block list. 6729 * 6730 * @return {boolean} Whether the given block type is allowed to be inserted. 6731 */ 6732 6733 6734 const canInsertBlockTypeUnmemoized = function (state, blockName) { 6735 let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 6736 let blockType; 6737 6738 if (blockName && 'object' === typeof blockName) { 6739 blockType = blockName; 6740 blockName = blockType.name; 6741 } else { 6742 blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName); 6743 } 6744 6745 if (!blockType) { 6746 return false; 6747 } 6748 6749 const { 6750 allowedBlockTypes 6751 } = getSettings(state); 6752 const isBlockAllowedInEditor = checkAllowList(allowedBlockTypes, blockName, true); 6753 6754 if (!isBlockAllowedInEditor) { 6755 return false; 6756 } 6757 6758 const isLocked = !!getTemplateLock(state, rootClientId); 6759 6760 if (isLocked) { 6761 return false; 6762 } 6763 6764 const parentBlockListSettings = getBlockListSettings(state, rootClientId); // The parent block doesn't have settings indicating it doesn't support 6765 // inner blocks, return false. 6766 6767 if (rootClientId && parentBlockListSettings === undefined) { 6768 return false; 6769 } 6770 6771 const parentAllowedBlocks = parentBlockListSettings === null || parentBlockListSettings === void 0 ? void 0 : parentBlockListSettings.allowedBlocks; 6772 const hasParentAllowedBlock = checkAllowList(parentAllowedBlocks, blockName); 6773 const blockAllowedParentBlocks = blockType.parent; 6774 const parentName = getBlockName(state, rootClientId); 6775 const hasBlockAllowedParent = checkAllowList(blockAllowedParentBlocks, parentName); 6776 let hasBlockAllowedAncestor = true; 6777 const blockAllowedAncestorBlocks = blockType.ancestor; 6778 6779 if (blockAllowedAncestorBlocks) { 6780 const ancestors = [rootClientId, ...getBlockParents(state, rootClientId)]; 6781 hasBlockAllowedAncestor = (0,external_lodash_namespaceObject.some)(ancestors, ancestorClientId => checkAllowList(blockAllowedAncestorBlocks, getBlockName(state, ancestorClientId))); 6782 } 6783 6784 const canInsert = hasBlockAllowedAncestor && (hasParentAllowedBlock === null && hasBlockAllowedParent === null || hasParentAllowedBlock === true || hasBlockAllowedParent === true); 6785 6786 if (!canInsert) { 6787 return canInsert; 6788 } 6789 /** 6790 * This filter is an ad-hoc solution to prevent adding template parts inside post content. 6791 * Conceptually, having a filter inside a selector is bad pattern so this code will be 6792 * replaced by a declarative API that doesn't the following drawbacks: 6793 * 6794 * Filters are not reactive: Upon switching between "template mode" and non "template mode", 6795 * the filter and selector won't necessarily be executed again. For now, it doesn't matter much 6796 * because you can't switch between the two modes while the inserter stays open. 6797 * 6798 * Filters are global: Once they're defined, they will affect all editor instances and all registries. 6799 * An ideal API would only affect specific editor instances. 6800 */ 6801 6802 6803 return (0,external_wp_hooks_namespaceObject.applyFilters)('blockEditor.__unstableCanInsertBlockType', canInsert, blockType, rootClientId, { 6804 // Pass bound selectors of the current registry. If we're in a nested 6805 // context, the data will differ from the one selected from the root 6806 // registry. 6807 getBlock: getBlock.bind(null, state), 6808 getBlockParentsByBlockName: getBlockParentsByBlockName.bind(null, state) 6809 }); 6810 }; 6811 /** 6812 * Determines if the given block type is allowed to be inserted into the block list. 6813 * 6814 * @param {Object} state Editor state. 6815 * @param {string} blockName The name of the block type, e.g.' core/paragraph'. 6816 * @param {?string} rootClientId Optional root client ID of block list. 6817 * 6818 * @return {boolean} Whether the given block type is allowed to be inserted. 6819 */ 6820 6821 6822 const canInsertBlockType = rememo(canInsertBlockTypeUnmemoized, (state, blockName, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId[rootClientId], state.settings.allowedBlockTypes, state.settings.templateLock]); 6823 /** 6824 * Determines if the given blocks are allowed to be inserted into the block 6825 * list. 6826 * 6827 * @param {Object} state Editor state. 6828 * @param {string} clientIds The block client IDs to be inserted. 6829 * @param {?string} rootClientId Optional root client ID of block list. 6830 * 6831 * @return {boolean} Whether the given blocks are allowed to be inserted. 6832 */ 6833 6834 function canInsertBlocks(state, clientIds) { 6835 let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 6836 return clientIds.every(id => canInsertBlockType(state, getBlockName(state, id), rootClientId)); 6837 } 6838 /** 6839 * Determines if the given block is allowed to be deleted. 6840 * 6841 * @param {Object} state Editor state. 6842 * @param {string} clientId The block client Id. 6843 * @param {?string} rootClientId Optional root client ID of block list. 6844 * 6845 * @return {boolean} Whether the given block is allowed to be removed. 6846 */ 6847 6848 function canRemoveBlock(state, clientId) { 6849 let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 6850 const attributes = getBlockAttributes(state, clientId); // attributes can be null if the block is already deleted. 6851 6852 if (attributes === null) { 6853 return true; 6854 } 6855 6856 const { 6857 lock 6858 } = attributes; 6859 const parentIsLocked = !!getTemplateLock(state, rootClientId); // If we don't have a lock on the blockType level, we defer to the parent templateLock. 6860 6861 if (lock === undefined || (lock === null || lock === void 0 ? void 0 : lock.remove) === undefined) { 6862 return !parentIsLocked; 6863 } // When remove is true, it means we cannot remove it. 6864 6865 6866 return !(lock !== null && lock !== void 0 && lock.remove); 6867 } 6868 /** 6869 * Determines if the given blocks are allowed to be removed. 6870 * 6871 * @param {Object} state Editor state. 6872 * @param {string} clientIds The block client IDs to be removed. 6873 * @param {?string} rootClientId Optional root client ID of block list. 6874 * 6875 * @return {boolean} Whether the given blocks are allowed to be removed. 6876 */ 6877 6878 function canRemoveBlocks(state, clientIds) { 6879 let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 6880 return clientIds.every(clientId => canRemoveBlock(state, clientId, rootClientId)); 6881 } 6882 /** 6883 * Determines if the given block is allowed to be moved. 6884 * 6885 * @param {Object} state Editor state. 6886 * @param {string} clientId The block client Id. 6887 * @param {?string} rootClientId Optional root client ID of block list. 6888 * 6889 * @return {boolean} Whether the given block is allowed to be moved. 6890 */ 6891 6892 function canMoveBlock(state, clientId) { 6893 let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 6894 const attributes = getBlockAttributes(state, clientId); 6895 6896 if (attributes === null) { 6897 return; 6898 } 6899 6900 const { 6901 lock 6902 } = attributes; 6903 const parentIsLocked = getTemplateLock(state, rootClientId) === 'all'; // If we don't have a lock on the blockType level, we defer to the parent templateLock. 6904 6905 if (lock === undefined || (lock === null || lock === void 0 ? void 0 : lock.move) === undefined) { 6906 return !parentIsLocked; 6907 } // When move is true, it means we cannot move it. 6908 6909 6910 return !(lock !== null && lock !== void 0 && lock.move); 6911 } 6912 /** 6913 * Determines if the given blocks are allowed to be moved. 6914 * 6915 * @param {Object} state Editor state. 6916 * @param {string} clientIds The block client IDs to be moved. 6917 * @param {?string} rootClientId Optional root client ID of block list. 6918 * 6919 * @return {boolean} Whether the given blocks are allowed to be moved. 6920 */ 6921 6922 function canMoveBlocks(state, clientIds) { 6923 let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 6924 return clientIds.every(clientId => canMoveBlock(state, clientId, rootClientId)); 6925 } 6926 /** 6927 * Determines if the given block type can be locked/unlocked by a user. 6928 * 6929 * @param {Object} state Editor state. 6930 * @param {(string|Object)} nameOrType Block name or type object. 6931 * 6932 * @return {boolean} Whether a given block type can be locked/unlocked. 6933 */ 6934 6935 function canLockBlockType(state, nameOrType) { 6936 var _state$settings; 6937 6938 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(nameOrType, 'lock', true)) { 6939 return false; 6940 } // Use block editor settings as the default value. 6941 6942 6943 return !!((_state$settings = state.settings) !== null && _state$settings !== void 0 && _state$settings.canLockBlocks); 6944 } 6945 /** 6946 * Returns information about how recently and frequently a block has been inserted. 6947 * 6948 * @param {Object} state Global application state. 6949 * @param {string} id A string which identifies the insert, e.g. 'core/block/12' 6950 * 6951 * @return {?{ time: number, count: number }} An object containing `time` which is when the last 6952 * insert occurred as a UNIX epoch, and `count` which is 6953 * the number of inserts that have occurred. 6954 */ 6955 6956 function getInsertUsage(state, id) { 6957 var _state$preferences$in, _state$preferences$in2; 6958 6959 return (_state$preferences$in = (_state$preferences$in2 = state.preferences.insertUsage) === null || _state$preferences$in2 === void 0 ? void 0 : _state$preferences$in2[id]) !== null && _state$preferences$in !== void 0 ? _state$preferences$in : null; 6960 } 6961 /** 6962 * Returns whether we can show a block type in the inserter 6963 * 6964 * @param {Object} state Global State 6965 * @param {Object} blockType BlockType 6966 * @param {?string} rootClientId Optional root client ID of block list. 6967 * 6968 * @return {boolean} Whether the given block type is allowed to be shown in the inserter. 6969 */ 6970 6971 6972 const canIncludeBlockTypeInInserter = (state, blockType, rootClientId) => { 6973 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'inserter', true)) { 6974 return false; 6975 } 6976 6977 return canInsertBlockTypeUnmemoized(state, blockType.name, rootClientId); 6978 }; 6979 /** 6980 * Return a function to be used to tranform a block variation to an inserter item 6981 * 6982 * @param {Object} state Global State 6983 * @param {Object} item Denormalized inserter item 6984 * @return {Function} Function to transform a block variation to inserter item 6985 */ 6986 6987 6988 const getItemFromVariation = (state, item) => variation => { 6989 const variationId = `$item.id}/$variation.name}`; 6990 const { 6991 time, 6992 count = 0 6993 } = getInsertUsage(state, variationId) || {}; 6994 return { ...item, 6995 id: variationId, 6996 icon: variation.icon || item.icon, 6997 title: variation.title || item.title, 6998 description: variation.description || item.description, 6999 category: variation.category || item.category, 7000 // If `example` is explicitly undefined for the variation, the preview will not be shown. 7001 example: variation.hasOwnProperty('example') ? variation.example : item.example, 7002 initialAttributes: { ...item.initialAttributes, 7003 ...variation.attributes 7004 }, 7005 innerBlocks: variation.innerBlocks, 7006 keywords: variation.keywords || item.keywords, 7007 frecency: calculateFrecency(time, count) 7008 }; 7009 }; 7010 /** 7011 * Returns the calculated frecency. 7012 * 7013 * 'frecency' is a heuristic (https://en.wikipedia.org/wiki/Frecency) 7014 * that combines block usage frequenty and recency. 7015 * 7016 * @param {number} time When the last insert occurred as a UNIX epoch 7017 * @param {number} count The number of inserts that have occurred. 7018 * 7019 * @return {number} The calculated frecency. 7020 */ 7021 7022 7023 const calculateFrecency = (time, count) => { 7024 if (!time) { 7025 return count; 7026 } // The selector is cached, which means Date.now() is the last time that the 7027 // relevant state changed. This suits our needs. 7028 7029 7030 const duration = Date.now() - time; 7031 7032 switch (true) { 7033 case duration < MILLISECONDS_PER_HOUR: 7034 return count * 4; 7035 7036 case duration < MILLISECONDS_PER_DAY: 7037 return count * 2; 7038 7039 case duration < MILLISECONDS_PER_WEEK: 7040 return count / 2; 7041 7042 default: 7043 return count / 4; 7044 } 7045 }; 7046 /** 7047 * Returns a function that accepts a block type and builds an item to be shown 7048 * in a specific context. It's used for building items for Inserter and available 7049 * block Transfroms list. 7050 * 7051 * @param {Object} state Editor state. 7052 * @param {Object} options Options object for handling the building of a block type. 7053 * @param {string} options.buildScope The scope for which the item is going to be used. 7054 * @return {Function} Function returns an item to be shown in a specific context (Inserter|Transforms list). 7055 */ 7056 7057 7058 const buildBlockTypeItem = (state, _ref3) => { 7059 let { 7060 buildScope = 'inserter' 7061 } = _ref3; 7062 return blockType => { 7063 const id = blockType.name; 7064 let isDisabled = false; 7065 7066 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType.name, 'multiple', true)) { 7067 isDisabled = (0,external_lodash_namespaceObject.some)(getBlocksByClientId(state, getClientIdsWithDescendants(state)), { 7068 name: blockType.name 7069 }); 7070 } 7071 7072 const { 7073 time, 7074 count = 0 7075 } = getInsertUsage(state, id) || {}; 7076 const blockItemBase = { 7077 id, 7078 name: blockType.name, 7079 title: blockType.title, 7080 icon: blockType.icon, 7081 isDisabled, 7082 frecency: calculateFrecency(time, count) 7083 }; 7084 if (buildScope === 'transform') return blockItemBase; 7085 const inserterVariations = (0,external_wp_blocks_namespaceObject.getBlockVariations)(blockType.name, 'inserter'); 7086 return { ...blockItemBase, 7087 initialAttributes: {}, 7088 description: blockType.description, 7089 category: blockType.category, 7090 keywords: blockType.keywords, 7091 variations: inserterVariations, 7092 example: blockType.example, 7093 utility: 1 // Deprecated. 7094 7095 }; 7096 }; 7097 }; 7098 /** 7099 * Determines the items that appear in the inserter. Includes both static 7100 * items (e.g. a regular block type) and dynamic items (e.g. a reusable block). 7101 * 7102 * Each item object contains what's necessary to display a button in the 7103 * inserter and handle its selection. 7104 * 7105 * The 'frecency' property is a heuristic (https://en.wikipedia.org/wiki/Frecency) 7106 * that combines block usage frequenty and recency. 7107 * 7108 * Items are returned ordered descendingly by their 'utility' and 'frecency'. 7109 * 7110 * @param {Object} state Editor state. 7111 * @param {?string} rootClientId Optional root client ID of block list. 7112 * 7113 * @return {WPEditorInserterItem[]} Items that appear in inserter. 7114 * 7115 * @typedef {Object} WPEditorInserterItem 7116 * @property {string} id Unique identifier for the item. 7117 * @property {string} name The type of block to create. 7118 * @property {Object} initialAttributes Attributes to pass to the newly created block. 7119 * @property {string} title Title of the item, as it appears in the inserter. 7120 * @property {string} icon Dashicon for the item, as it appears in the inserter. 7121 * @property {string} category Block category that the item is associated with. 7122 * @property {string[]} keywords Keywords that can be searched to find this item. 7123 * @property {boolean} isDisabled Whether or not the user should be prevented from inserting 7124 * this item. 7125 * @property {number} frecency Heuristic that combines frequency and recency. 7126 */ 7127 7128 7129 const getInserterItems = rememo(function (state) { 7130 let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 7131 const buildBlockTypeInserterItem = buildBlockTypeItem(state, { 7132 buildScope: 'inserter' 7133 }); 7134 /* 7135 * Matches block comment delimiters amid serialized content. 7136 * 7137 * @see `tokenizer` in `@wordpress/block-serialization-default-parser` 7138 * package 7139 * 7140 * blockParserTokenizer differs from the original tokenizer in the 7141 * following ways: 7142 * 7143 * - removed global flag (/g) 7144 * - prepended ^\s* 7145 * 7146 */ 7147 7148 const blockParserTokenizer = /^\s*<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?:(?=([^}]+|}+(?=})|(?!}\s+\/?-->)[^])*)\5|[^]*?)}\s+)?(\/)?-->/; 7149 7150 const buildReusableBlockInserterItem = reusableBlock => { 7151 let icon = library_symbol; 7152 /* 7153 * Instead of always displaying a generic "symbol" icon for every 7154 * reusable block, try to use an icon that represents the first 7155 * outermost block contained in the reusable block. This requires 7156 * scanning the serialized form of the reusable block to find its 7157 * first block delimiter, then looking up the corresponding block 7158 * type, if available. 7159 */ 7160 7161 if (external_wp_element_namespaceObject.Platform.OS === 'web') { 7162 const content = typeof reusableBlock.content.raw === 'string' ? reusableBlock.content.raw : reusableBlock.content; 7163 const rawBlockMatch = content.match(blockParserTokenizer); 7164 7165 if (rawBlockMatch) { 7166 const [,, namespace = 'core/', blockName] = rawBlockMatch; 7167 const referencedBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(namespace + blockName); 7168 7169 if (referencedBlockType) { 7170 icon = referencedBlockType.icon; 7171 } 7172 } 7173 } 7174 7175 const id = `core/block/$reusableBlock.id}`; 7176 const { 7177 time, 7178 count = 0 7179 } = getInsertUsage(state, id) || {}; 7180 const frecency = calculateFrecency(time, count); 7181 return { 7182 id, 7183 name: 'core/block', 7184 initialAttributes: { 7185 ref: reusableBlock.id 7186 }, 7187 title: reusableBlock.title.raw, 7188 icon, 7189 category: 'reusable', 7190 keywords: [], 7191 isDisabled: false, 7192 utility: 1, 7193 // Deprecated. 7194 frecency 7195 }; 7196 }; 7197 7198 const blockTypeInserterItems = (0,external_wp_blocks_namespaceObject.getBlockTypes)().filter(blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId)).map(buildBlockTypeInserterItem); 7199 const reusableBlockInserterItems = canInsertBlockTypeUnmemoized(state, 'core/block', rootClientId) ? getReusableBlocks(state).map(buildReusableBlockInserterItem) : []; 7200 const items = blockTypeInserterItems.reduce((accumulator, item) => { 7201 const { 7202 variations = [] 7203 } = item; // Exclude any block type item that is to be replaced by a default variation. 7204 7205 if (!variations.some(_ref4 => { 7206 let { 7207 isDefault 7208 } = _ref4; 7209 return isDefault; 7210 })) { 7211 accumulator.push(item); 7212 } 7213 7214 if (variations.length) { 7215 const variationMapper = getItemFromVariation(state, item); 7216 accumulator.push(...variations.map(variationMapper)); 7217 } 7218 7219 return accumulator; 7220 }, []); // Ensure core blocks are prioritized in the returned results, 7221 // because third party blocks can be registered earlier than 7222 // the core blocks (usually by using the `init` action), 7223 // thus affecting the display order. 7224 // We don't sort reusable blocks as they are handled differently. 7225 7226 const groupByType = (blocks, block) => { 7227 const { 7228 core, 7229 noncore 7230 } = blocks; 7231 const type = block.name.startsWith('core/') ? core : noncore; 7232 type.push(block); 7233 return blocks; 7234 }; 7235 7236 const { 7237 core: coreItems, 7238 noncore: nonCoreItems 7239 } = items.reduce(groupByType, { 7240 core: [], 7241 noncore: [] 7242 }); 7243 const sortedBlockTypes = [...coreItems, ...nonCoreItems]; 7244 return [...sortedBlockTypes, ...reusableBlockInserterItems]; 7245 }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.blocks.order, state.preferences.insertUsage, state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks(state), (0,external_wp_blocks_namespaceObject.getBlockTypes)()]); 7246 /** 7247 * Determines the items that appear in the available block transforms list. 7248 * 7249 * Each item object contains what's necessary to display a menu item in the 7250 * transform list and handle its selection. 7251 * 7252 * The 'frecency' property is a heuristic (https://en.wikipedia.org/wiki/Frecency) 7253 * that combines block usage frequenty and recency. 7254 * 7255 * Items are returned ordered descendingly by their 'frecency'. 7256 * 7257 * @param {Object} state Editor state. 7258 * @param {?string} rootClientId Optional root client ID of block list. 7259 * 7260 * @return {WPEditorTransformItem[]} Items that appear in inserter. 7261 * 7262 * @typedef {Object} WPEditorTransformItem 7263 * @property {string} id Unique identifier for the item. 7264 * @property {string} name The type of block to create. 7265 * @property {string} title Title of the item, as it appears in the inserter. 7266 * @property {string} icon Dashicon for the item, as it appears in the inserter. 7267 * @property {boolean} isDisabled Whether or not the user should be prevented from inserting 7268 * this item. 7269 * @property {number} frecency Heuristic that combines frequency and recency. 7270 */ 7271 7272 const getBlockTransformItems = rememo(function (state, blocks) { 7273 var _itemsByName$sourceBl; 7274 7275 let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 7276 const [sourceBlock] = blocks; 7277 const buildBlockTypeTransformItem = buildBlockTypeItem(state, { 7278 buildScope: 'transform' 7279 }); 7280 const blockTypeTransformItems = (0,external_wp_blocks_namespaceObject.getBlockTypes)().filter(blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId)).map(buildBlockTypeTransformItem); 7281 const itemsByName = (0,external_lodash_namespaceObject.mapKeys)(blockTypeTransformItems, _ref5 => { 7282 let { 7283 name 7284 } = _ref5; 7285 return name; 7286 }); // Consider unwraping the highest priority. 7287 7288 itemsByName['*'] = { 7289 frecency: +Infinity, 7290 id: '*', 7291 isDisabled: false, 7292 name: '*', 7293 title: (0,external_wp_i18n_namespaceObject.__)('Unwrap'), 7294 icon: (_itemsByName$sourceBl = itemsByName[sourceBlock.name]) === null || _itemsByName$sourceBl === void 0 ? void 0 : _itemsByName$sourceBl.icon 7295 }; 7296 const possibleTransforms = (0,external_wp_blocks_namespaceObject.getPossibleBlockTransformations)(blocks).reduce((accumulator, block) => { 7297 if (block === '*') { 7298 accumulator.push(itemsByName['*']); 7299 } else if (itemsByName[block === null || block === void 0 ? void 0 : block.name]) { 7300 accumulator.push(itemsByName[block.name]); 7301 } 7302 7303 return accumulator; 7304 }, []); 7305 return (0,external_lodash_namespaceObject.orderBy)(possibleTransforms, block => itemsByName[block.name].frecency, 'desc'); 7306 }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.preferences.insertUsage, state.settings.allowedBlockTypes, state.settings.templateLock, (0,external_wp_blocks_namespaceObject.getBlockTypes)()]); 7307 /** 7308 * Determines whether there are items to show in the inserter. 7309 * 7310 * @param {Object} state Editor state. 7311 * @param {?string} rootClientId Optional root client ID of block list. 7312 * 7313 * @return {boolean} Items that appear in inserter. 7314 */ 7315 7316 const hasInserterItems = rememo(function (state) { 7317 let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 7318 const hasBlockType = (0,external_lodash_namespaceObject.some)((0,external_wp_blocks_namespaceObject.getBlockTypes)(), blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId)); 7319 7320 if (hasBlockType) { 7321 return true; 7322 } 7323 7324 const hasReusableBlock = canInsertBlockTypeUnmemoized(state, 'core/block', rootClientId) && getReusableBlocks(state).length > 0; 7325 return hasReusableBlock; 7326 }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks(state), (0,external_wp_blocks_namespaceObject.getBlockTypes)()]); 7327 /** 7328 * Returns the list of allowed inserter blocks for inner blocks children 7329 * 7330 * @param {Object} state Editor state. 7331 * @param {?string} rootClientId Optional root client ID of block list. 7332 * 7333 * @return {Array?} The list of allowed block types. 7334 */ 7335 7336 const __experimentalGetAllowedBlocks = rememo(function (state) { 7337 let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 7338 7339 if (!rootClientId) { 7340 return; 7341 } 7342 7343 return (0,external_lodash_namespaceObject.filter)((0,external_wp_blocks_namespaceObject.getBlockTypes)(), blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId)); 7344 }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.settings.allowedBlockTypes, state.settings.templateLock, (0,external_wp_blocks_namespaceObject.getBlockTypes)()]); 7345 /** 7346 * Returns the block to be directly inserted by the block appender. 7347 * 7348 * @param {Object} state Editor state. 7349 * @param {?string} rootClientId Optional root client ID of block list. 7350 * 7351 * @return {?WPDirectInsertBlock} The block type to be directly inserted. 7352 * 7353 * @typedef {Object} WPDirectInsertBlock 7354 * @property {string} name The type of block. 7355 * @property {?Object} attributes Attributes to pass to the newly created block. 7356 * @property {?Array<string>} attributesToCopy Attributes to be copied from adjecent blocks when inserted. 7357 */ 7358 7359 const __experimentalGetDirectInsertBlock = rememo(function (state) { 7360 var _state$blockListSetti, _state$blockListSetti2; 7361 7362 let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 7363 7364 if (!rootClientId) { 7365 return; 7366 } 7367 7368 const defaultBlock = (_state$blockListSetti = state.blockListSettings[rootClientId]) === null || _state$blockListSetti === void 0 ? void 0 : _state$blockListSetti.__experimentalDefaultBlock; 7369 const directInsert = (_state$blockListSetti2 = state.blockListSettings[rootClientId]) === null || _state$blockListSetti2 === void 0 ? void 0 : _state$blockListSetti2.__experimentalDirectInsert; 7370 7371 if (!defaultBlock || !directInsert) { 7372 return; 7373 } 7374 7375 if (typeof directInsert === 'function') { 7376 return directInsert(getBlock(state, rootClientId)) ? defaultBlock : null; 7377 } 7378 7379 return defaultBlock; 7380 }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.tree[rootClientId]]); 7381 7382 const checkAllowListRecursive = (blocks, allowedBlockTypes) => { 7383 if ((0,external_lodash_namespaceObject.isBoolean)(allowedBlockTypes)) { 7384 return allowedBlockTypes; 7385 } 7386 7387 const blocksQueue = [...blocks]; 7388 7389 while (blocksQueue.length > 0) { 7390 var _block$innerBlocks; 7391 7392 const block = blocksQueue.shift(); 7393 const isAllowed = checkAllowList(allowedBlockTypes, block.name || block.blockName, true); 7394 7395 if (!isAllowed) { 7396 return false; 7397 } 7398 7399 (_block$innerBlocks = block.innerBlocks) === null || _block$innerBlocks === void 0 ? void 0 : _block$innerBlocks.forEach(innerBlock => { 7400 blocksQueue.push(innerBlock); 7401 }); 7402 } 7403 7404 return true; 7405 }; 7406 7407 const __experimentalGetParsedPattern = rememo((state, patternName) => { 7408 const patterns = state.settings.__experimentalBlockPatterns; 7409 const pattern = patterns.find(_ref6 => { 7410 let { 7411 name 7412 } = _ref6; 7413 return name === patternName; 7414 }); 7415 7416 if (!pattern) { 7417 return null; 7418 } 7419 7420 return { ...pattern, 7421 blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content, { 7422 __unstableSkipMigrationLogs: true 7423 }) 7424 }; 7425 }, state => [state.settings.__experimentalBlockPatterns]); 7426 const getAllAllowedPatterns = rememo(state => { 7427 const patterns = state.settings.__experimentalBlockPatterns; 7428 const { 7429 allowedBlockTypes 7430 } = getSettings(state); 7431 const parsedPatterns = patterns.filter(_ref7 => { 7432 let { 7433 inserter = true 7434 } = _ref7; 7435 return !!inserter; 7436 }).map(_ref8 => { 7437 let { 7438 name 7439 } = _ref8; 7440 return __experimentalGetParsedPattern(state, name); 7441 }); 7442 const allowedPatterns = parsedPatterns.filter(_ref9 => { 7443 let { 7444 blocks 7445 } = _ref9; 7446 return checkAllowListRecursive(blocks, allowedBlockTypes); 7447 }); 7448 return allowedPatterns; 7449 }, state => [state.settings.__experimentalBlockPatterns, state.settings.allowedBlockTypes]); 7450 /** 7451 * Returns the list of allowed patterns for inner blocks children. 7452 * 7453 * @param {Object} state Editor state. 7454 * @param {?string} rootClientId Optional target root client ID. 7455 * 7456 * @return {Array?} The list of allowed patterns. 7457 */ 7458 7459 const __experimentalGetAllowedPatterns = rememo(function (state) { 7460 let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 7461 const availableParsedPatterns = getAllAllowedPatterns(state); 7462 const patternsAllowed = (0,external_lodash_namespaceObject.filter)(availableParsedPatterns, _ref10 => { 7463 let { 7464 blocks 7465 } = _ref10; 7466 return blocks.every(_ref11 => { 7467 let { 7468 name 7469 } = _ref11; 7470 return canInsertBlockType(state, name, rootClientId); 7471 }); 7472 }); 7473 return patternsAllowed; 7474 }, (state, rootClientId) => [state.settings.__experimentalBlockPatterns, state.settings.allowedBlockTypes, state.settings.templateLock, state.blockListSettings[rootClientId], state.blocks.byClientId[rootClientId]]); 7475 /** 7476 * Returns the list of patterns based on their declared `blockTypes` 7477 * and a block's name. 7478 * Patterns can use `blockTypes` to integrate in work flows like 7479 * suggesting appropriate patterns in a Placeholder state(during insertion) 7480 * or blocks transformations. 7481 * 7482 * @param {Object} state Editor state. 7483 * @param {string|string[]} blockNames Block's name or array of block names to find matching pattens. 7484 * @param {?string} rootClientId Optional target root client ID. 7485 * 7486 * @return {Array} The list of matched block patterns based on declared `blockTypes` and block name. 7487 */ 7488 7489 const __experimentalGetPatternsByBlockTypes = rememo(function (state, blockNames) { 7490 let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 7491 if (!blockNames) return EMPTY_ARRAY; 7492 7493 const patterns = __experimentalGetAllowedPatterns(state, rootClientId); 7494 7495 const normalizedBlockNames = Array.isArray(blockNames) ? blockNames : [blockNames]; 7496 return patterns.filter(pattern => { 7497 var _pattern$blockTypes, _pattern$blockTypes$s; 7498 7499 return pattern === null || pattern === void 0 ? void 0 : (_pattern$blockTypes = pattern.blockTypes) === null || _pattern$blockTypes === void 0 ? void 0 : (_pattern$blockTypes$s = _pattern$blockTypes.some) === null || _pattern$blockTypes$s === void 0 ? void 0 : _pattern$blockTypes$s.call(_pattern$blockTypes, blockName => normalizedBlockNames.includes(blockName)); 7500 }); 7501 }, (state, rootClientId) => [...__experimentalGetAllowedPatterns.getDependants(state, rootClientId)]); 7502 /** 7503 * Determines the items that appear in the available pattern transforms list. 7504 * 7505 * For now we only handle blocks without InnerBlocks and take into account 7506 * the `__experimentalRole` property of blocks' attributes for the transformation. 7507 * 7508 * We return the first set of possible eligible block patterns, 7509 * by checking the `blockTypes` property. We still have to recurse through 7510 * block pattern's blocks and try to find matches from the selected blocks. 7511 * Now this happens in the consumer to avoid heavy operations in the selector. 7512 * 7513 * @param {Object} state Editor state. 7514 * @param {Object[]} blocks The selected blocks. 7515 * @param {?string} rootClientId Optional root client ID of block list. 7516 * 7517 * @return {WPBlockPattern[]} Items that are eligible for a pattern transformation. 7518 */ 7519 7520 const __experimentalGetPatternTransformItems = rememo(function (state, blocks) { 7521 let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 7522 if (!blocks) return EMPTY_ARRAY; 7523 /** 7524 * For now we only handle blocks without InnerBlocks and take into account 7525 * the `__experimentalRole` property of blocks' attributes for the transformation. 7526 * Note that the blocks have been retrieved through `getBlock`, which doesn't 7527 * return the inner blocks of an inner block controller, so we still need 7528 * to check for this case too. 7529 */ 7530 7531 if (blocks.some(_ref12 => { 7532 let { 7533 clientId, 7534 innerBlocks 7535 } = _ref12; 7536 return innerBlocks.length || areInnerBlocksControlled(state, clientId); 7537 })) { 7538 return EMPTY_ARRAY; 7539 } // Create a Set of the selected block names that is used in patterns filtering. 7540 7541 7542 const selectedBlockNames = Array.from(new Set(blocks.map(_ref13 => { 7543 let { 7544 name 7545 } = _ref13; 7546 return name; 7547 }))); 7548 /** 7549 * Here we will return first set of possible eligible block patterns, 7550 * by checking the `blockTypes` property. We still have to recurse through 7551 * block pattern's blocks and try to find matches from the selected blocks. 7552 * Now this happens in the consumer to avoid heavy operations in the selector. 7553 */ 7554 7555 return __experimentalGetPatternsByBlockTypes(state, selectedBlockNames, rootClientId); 7556 }, (state, rootClientId) => [...__experimentalGetPatternsByBlockTypes.getDependants(state, rootClientId)]); 7557 /** 7558 * Returns the Block List settings of a block, if any exist. 7559 * 7560 * @param {Object} state Editor state. 7561 * @param {?string} clientId Block client ID. 7562 * 7563 * @return {?Object} Block settings of the block if set. 7564 */ 7565 7566 function getBlockListSettings(state, clientId) { 7567 return state.blockListSettings[clientId]; 7568 } 7569 /** 7570 * Returns the editor settings. 7571 * 7572 * @param {Object} state Editor state. 7573 * 7574 * @return {Object} The editor settings object. 7575 */ 7576 7577 function getSettings(state) { 7578 return state.settings; 7579 } 7580 /** 7581 * Returns true if the most recent block change is be considered persistent, or 7582 * false otherwise. A persistent change is one committed by BlockEditorProvider 7583 * via its `onChange` callback, in addition to `onInput`. 7584 * 7585 * @param {Object} state Block editor state. 7586 * 7587 * @return {boolean} Whether the most recent block change was persistent. 7588 */ 7589 7590 function isLastBlockChangePersistent(state) { 7591 return state.blocks.isPersistentChange; 7592 } 7593 /** 7594 * Returns the block list settings for an array of blocks, if any exist. 7595 * 7596 * @param {Object} state Editor state. 7597 * @param {Array} clientIds Block client IDs. 7598 * 7599 * @return {Object} An object where the keys are client ids and the values are 7600 * a block list setting object. 7601 */ 7602 7603 const __experimentalGetBlockListSettingsForBlocks = rememo(function (state) { 7604 let clientIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; 7605 return clientIds.reduce((blockListSettingsForBlocks, clientId) => { 7606 if (!state.blockListSettings[clientId]) { 7607 return blockListSettingsForBlocks; 7608 } 7609 7610 return { ...blockListSettingsForBlocks, 7611 [clientId]: state.blockListSettings[clientId] 7612 }; 7613 }, {}); 7614 }, state => [state.blockListSettings]); 7615 /** 7616 * Returns the title of a given reusable block 7617 * 7618 * @param {Object} state Global application state. 7619 * @param {number|string} ref The shared block's ID. 7620 * 7621 * @return {string} The reusable block saved title. 7622 */ 7623 7624 const __experimentalGetReusableBlockTitle = rememo((state, ref) => { 7625 var _reusableBlock$title; 7626 7627 const reusableBlock = (0,external_lodash_namespaceObject.find)(getReusableBlocks(state), block => block.id === ref); 7628 7629 if (!reusableBlock) { 7630 return null; 7631 } 7632 7633 return (_reusableBlock$title = reusableBlock.title) === null || _reusableBlock$title === void 0 ? void 0 : _reusableBlock$title.raw; 7634 }, state => [getReusableBlocks(state)]); 7635 /** 7636 * Returns true if the most recent block change is be considered ignored, or 7637 * false otherwise. An ignored change is one not to be committed by 7638 * BlockEditorProvider, neither via `onChange` nor `onInput`. 7639 * 7640 * @param {Object} state Block editor state. 7641 * 7642 * @return {boolean} Whether the most recent block change was ignored. 7643 */ 7644 7645 function __unstableIsLastBlockChangeIgnored(state) { 7646 // TODO: Removal Plan: Changes incurred by RECEIVE_BLOCKS should not be 7647 // ignored if in-fact they result in a change in blocks state. The current 7648 // need to ignore changes not a result of user interaction should be 7649 // accounted for in the refactoring of reusable blocks as occurring within 7650 // their own separate block editor / state (#7119). 7651 return state.blocks.isIgnoredChange; 7652 } 7653 /** 7654 * Returns the block attributes changed as a result of the last dispatched 7655 * action. 7656 * 7657 * @param {Object} state Block editor state. 7658 * 7659 * @return {Object<string,Object>} Subsets of block attributes changed, keyed 7660 * by block client ID. 7661 */ 7662 7663 function __experimentalGetLastBlockAttributeChanges(state) { 7664 return state.lastBlockAttributesChange; 7665 } 7666 /** 7667 * Returns the available reusable blocks 7668 * 7669 * @param {Object} state Global application state. 7670 * 7671 * @return {Array} Reusable blocks 7672 */ 7673 7674 function getReusableBlocks(state) { 7675 var _state$settings$__exp, _state$settings2; 7676 7677 return (_state$settings$__exp = state === null || state === void 0 ? void 0 : (_state$settings2 = state.settings) === null || _state$settings2 === void 0 ? void 0 : _state$settings2.__experimentalReusableBlocks) !== null && _state$settings$__exp !== void 0 ? _state$settings$__exp : EMPTY_ARRAY; 7678 } 7679 /** 7680 * Returns whether the navigation mode is enabled. 7681 * 7682 * @param {Object} state Editor state. 7683 * 7684 * @return {boolean} Is navigation mode enabled. 7685 */ 7686 7687 7688 function selectors_isNavigationMode(state) { 7689 return state.isNavigationMode; 7690 } 7691 /** 7692 * Returns whether block moving mode is enabled. 7693 * 7694 * @param {Object} state Editor state. 7695 * 7696 * @return {string} Client Id of moving block. 7697 */ 7698 7699 function selectors_hasBlockMovingClientId(state) { 7700 return state.hasBlockMovingClientId; 7701 } 7702 /** 7703 * Returns true if the last change was an automatic change, false otherwise. 7704 * 7705 * @param {Object} state Global application state. 7706 * 7707 * @return {boolean} Whether the last change was automatic. 7708 */ 7709 7710 function didAutomaticChange(state) { 7711 return !!state.automaticChangeStatus; 7712 } 7713 /** 7714 * Returns true if the current highlighted block matches the block clientId. 7715 * 7716 * @param {Object} state Global application state. 7717 * @param {string} clientId The block to check. 7718 * 7719 * @return {boolean} Whether the block is currently highlighted. 7720 */ 7721 7722 function isBlockHighlighted(state, clientId) { 7723 return state.highlightedBlock === clientId; 7724 } 7725 /** 7726 * Checks if a given block has controlled inner blocks. 7727 * 7728 * @param {Object} state Global application state. 7729 * @param {string} clientId The block to check. 7730 * 7731 * @return {boolean} True if the block has controlled inner blocks. 7732 */ 7733 7734 function areInnerBlocksControlled(state, clientId) { 7735 return !!state.blocks.controlledInnerBlocks[clientId]; 7736 } 7737 /** 7738 * Returns the clientId for the first 'active' block of a given array of block names. 7739 * A block is 'active' if it (or a child) is the selected block. 7740 * Returns the first match moving up the DOM from the selected block. 7741 * 7742 * @param {Object} state Global application state. 7743 * @param {string[]} validBlocksNames The names of block types to check for. 7744 * 7745 * @return {string} The matching block's clientId. 7746 */ 7747 7748 const __experimentalGetActiveBlockIdByBlockNames = rememo((state, validBlockNames) => { 7749 if (!validBlockNames.length) { 7750 return null; 7751 } // Check if selected block is a valid entity area. 7752 7753 7754 const selectedBlockClientId = getSelectedBlockClientId(state); 7755 7756 if (validBlockNames.includes(getBlockName(state, selectedBlockClientId))) { 7757 return selectedBlockClientId; 7758 } // Check if first selected block is a child of a valid entity area. 7759 7760 7761 const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds(state); 7762 const entityAreaParents = getBlockParentsByBlockName(state, selectedBlockClientId || multiSelectedBlockClientIds[0], validBlockNames); 7763 7764 if (entityAreaParents) { 7765 // Last parent closest/most interior. 7766 return (0,external_lodash_namespaceObject.last)(entityAreaParents); 7767 } 7768 7769 return null; 7770 }, (state, validBlockNames) => [state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId, validBlockNames]); 7771 /** 7772 * Tells if the block with the passed clientId was just inserted. 7773 * 7774 * @param {Object} state Global application state. 7775 * @param {Object} clientId Client Id of the block. 7776 * @param {?string} source Optional insertion source of the block. 7777 * @return {boolean} True if the block matches the last block inserted from the specified source. 7778 */ 7779 7780 function wasBlockJustInserted(state, clientId, source) { 7781 const { 7782 lastBlockInserted 7783 } = state; 7784 return lastBlockInserted.clientId === clientId && lastBlockInserted.source === source; 7785 } 7786 7787 ;// CONCATENATED MODULE: external ["wp","a11y"] 7788 var external_wp_a11y_namespaceObject = window["wp"]["a11y"]; 7789 ;// CONCATENATED MODULE: external ["wp","deprecated"] 7790 var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; 7791 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); 7792 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/actions.js 7793 /** 7794 * External dependencies 7795 */ 7796 7797 /** 7798 * WordPress dependencies 7799 */ 7800 7801 7802 7803 7804 7805 7806 /** 7807 * Internal dependencies 7808 */ 7809 7810 7811 /** 7812 * Action which will insert a default block insert action if there 7813 * are no other blocks at the root of the editor. This action should be used 7814 * in actions which may result in no blocks remaining in the editor (removal, 7815 * replacement, etc). 7816 */ 7817 7818 const ensureDefaultBlock = () => _ref => { 7819 let { 7820 select, 7821 dispatch 7822 } = _ref; 7823 // To avoid a focus loss when removing the last block, assure there is 7824 // always a default block if the last of the blocks have been removed. 7825 const count = select.getBlockCount(); 7826 7827 if (count > 0) { 7828 return; 7829 } // If there's an custom appender, don't insert default block. 7830 // We have to remember to manually move the focus elsewhere to 7831 // prevent it from being lost though. 7832 7833 7834 const { 7835 __unstableHasCustomAppender 7836 } = select.getSettings(); 7837 7838 if (__unstableHasCustomAppender) { 7839 return; 7840 } 7841 7842 dispatch.insertDefaultBlock(); 7843 }; 7844 /** 7845 * Action that resets blocks state to the specified array of blocks, taking precedence 7846 * over any other content reflected as an edit in state. 7847 * 7848 * @param {Array} blocks Array of blocks. 7849 */ 7850 7851 7852 const resetBlocks = blocks => _ref2 => { 7853 let { 7854 dispatch 7855 } = _ref2; 7856 dispatch({ 7857 type: 'RESET_BLOCKS', 7858 blocks 7859 }); 7860 dispatch(validateBlocksToTemplate(blocks)); 7861 }; 7862 /** 7863 * Block validity is a function of blocks state (at the point of a 7864 * reset) and the template setting. As a compromise to its placement 7865 * across distinct parts of state, it is implemented here as a side- 7866 * effect of the block reset action. 7867 * 7868 * @param {Array} blocks Array of blocks. 7869 */ 7870 7871 const validateBlocksToTemplate = blocks => _ref3 => { 7872 let { 7873 select, 7874 dispatch 7875 } = _ref3; 7876 const template = select.getTemplate(); 7877 const templateLock = select.getTemplateLock(); // Unlocked templates are considered always valid because they act 7878 // as default values only. 7879 7880 const isBlocksValidToTemplate = !template || templateLock !== 'all' || (0,external_wp_blocks_namespaceObject.doBlocksMatchTemplate)(blocks, template); // Update if validity has changed. 7881 7882 const isValidTemplate = select.isValidTemplate(); 7883 7884 if (isBlocksValidToTemplate !== isValidTemplate) { 7885 dispatch.setTemplateValidity(isBlocksValidToTemplate); 7886 return isBlocksValidToTemplate; 7887 } 7888 }; 7889 /** 7890 * A block selection object. 7891 * 7892 * @typedef {Object} WPBlockSelection 7893 * 7894 * @property {string} clientId A block client ID. 7895 * @property {string} attributeKey A block attribute key. 7896 * @property {number} offset An attribute value offset, based on the rich 7897 * text value. See `wp.richText.create`. 7898 */ 7899 7900 /** 7901 * A selection object. 7902 * 7903 * @typedef {Object} WPSelection 7904 * 7905 * @property {WPBlockSelection} start The selection start. 7906 * @property {WPBlockSelection} end The selection end. 7907 */ 7908 7909 /* eslint-disable jsdoc/valid-types */ 7910 7911 /** 7912 * Returns an action object used in signalling that selection state should be 7913 * reset to the specified selection. 7914 * 7915 * @param {WPBlockSelection} selectionStart The selection start. 7916 * @param {WPBlockSelection} selectionEnd The selection end. 7917 * @param {0|-1|null} initialPosition Initial block position. 7918 * 7919 * @return {Object} Action object. 7920 */ 7921 7922 function resetSelection(selectionStart, selectionEnd, initialPosition) { 7923 /* eslint-enable jsdoc/valid-types */ 7924 return { 7925 type: 'RESET_SELECTION', 7926 selectionStart, 7927 selectionEnd, 7928 initialPosition 7929 }; 7930 } 7931 /** 7932 * Returns an action object used in signalling that blocks have been received. 7933 * Unlike resetBlocks, these should be appended to the existing known set, not 7934 * replacing. 7935 * 7936 * @deprecated 7937 * 7938 * @param {Object[]} blocks Array of block objects. 7939 * 7940 * @return {Object} Action object. 7941 */ 7942 7943 function receiveBlocks(blocks) { 7944 external_wp_deprecated_default()('wp.data.dispatch( "core/block-editor" ).receiveBlocks', { 7945 since: '5.9', 7946 alternative: 'resetBlocks or insertBlocks' 7947 }); 7948 return { 7949 type: 'RECEIVE_BLOCKS', 7950 blocks 7951 }; 7952 } 7953 /** 7954 * Action that updates attributes of multiple blocks with the specified client IDs. 7955 * 7956 * @param {string|string[]} clientIds Block client IDs. 7957 * @param {Object} attributes Block attributes to be merged. Should be keyed by clientIds if 7958 * uniqueByBlock is true. 7959 * @param {boolean} uniqueByBlock true if each block in clientIds array has a unique set of attributes 7960 * @return {Object} Action object. 7961 */ 7962 7963 function updateBlockAttributes(clientIds, attributes) { 7964 let uniqueByBlock = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 7965 return { 7966 type: 'UPDATE_BLOCK_ATTRIBUTES', 7967 clientIds: (0,external_lodash_namespaceObject.castArray)(clientIds), 7968 attributes, 7969 uniqueByBlock 7970 }; 7971 } 7972 /** 7973 * Action that updates the block with the specified client ID. 7974 * 7975 * @param {string} clientId Block client ID. 7976 * @param {Object} updates Block attributes to be merged. 7977 * 7978 * @return {Object} Action object. 7979 */ 7980 7981 function updateBlock(clientId, updates) { 7982 return { 7983 type: 'UPDATE_BLOCK', 7984 clientId, 7985 updates 7986 }; 7987 } 7988 /* eslint-disable jsdoc/valid-types */ 7989 7990 /** 7991 * Returns an action object used in signalling that the block with the 7992 * specified client ID has been selected, optionally accepting a position 7993 * value reflecting its selection directionality. An initialPosition of -1 7994 * reflects a reverse selection. 7995 * 7996 * @param {string} clientId Block client ID. 7997 * @param {0|-1|null} initialPosition Optional initial position. Pass as -1 to 7998 * reflect reverse selection. 7999 * 8000 * @return {Object} Action object. 8001 */ 8002 8003 function selectBlock(clientId) { 8004 let initialPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; 8005 8006 /* eslint-enable jsdoc/valid-types */ 8007 return { 8008 type: 'SELECT_BLOCK', 8009 initialPosition, 8010 clientId 8011 }; 8012 } 8013 /** 8014 * Yields action objects used in signalling that the block preceding the given 8015 * clientId should be selected. 8016 * 8017 * @param {string} clientId Block client ID. 8018 */ 8019 8020 const selectPreviousBlock = clientId => _ref4 => { 8021 let { 8022 select, 8023 dispatch 8024 } = _ref4; 8025 const previousBlockClientId = select.getPreviousBlockClientId(clientId); 8026 8027 if (previousBlockClientId) { 8028 dispatch.selectBlock(previousBlockClientId, -1); 8029 } 8030 }; 8031 /** 8032 * Yields action objects used in signalling that the block following the given 8033 * clientId should be selected. 8034 * 8035 * @param {string} clientId Block client ID. 8036 */ 8037 8038 const selectNextBlock = clientId => _ref5 => { 8039 let { 8040 select, 8041 dispatch 8042 } = _ref5; 8043 const nextBlockClientId = select.getNextBlockClientId(clientId); 8044 8045 if (nextBlockClientId) { 8046 dispatch.selectBlock(nextBlockClientId); 8047 } 8048 }; 8049 /** 8050 * Action that starts block multi-selection. 8051 * 8052 * @return {Object} Action object. 8053 */ 8054 8055 function startMultiSelect() { 8056 return { 8057 type: 'START_MULTI_SELECT' 8058 }; 8059 } 8060 /** 8061 * Action that stops block multi-selection. 8062 * 8063 * @return {Object} Action object. 8064 */ 8065 8066 function stopMultiSelect() { 8067 return { 8068 type: 'STOP_MULTI_SELECT' 8069 }; 8070 } 8071 /** 8072 * Action that changes block multi-selection. 8073 * 8074 * @param {string} start First block of the multi selection. 8075 * @param {string} end Last block of the multiselection. 8076 * @param {number|null} __experimentalInitialPosition Optional initial position. Pass as null to skip focus within editor canvas. 8077 */ 8078 8079 const multiSelect = function (start, end) { 8080 let __experimentalInitialPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; 8081 8082 return _ref6 => { 8083 let { 8084 select, 8085 dispatch 8086 } = _ref6; 8087 const startBlockRootClientId = select.getBlockRootClientId(start); 8088 const endBlockRootClientId = select.getBlockRootClientId(end); // Only allow block multi-selections at the same level. 8089 8090 if (startBlockRootClientId !== endBlockRootClientId) { 8091 return; 8092 } 8093 8094 dispatch({ 8095 type: 'MULTI_SELECT', 8096 start, 8097 end, 8098 initialPosition: __experimentalInitialPosition 8099 }); 8100 const blockCount = select.getSelectedBlockCount(); 8101 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.sprintf)( 8102 /* translators: %s: number of selected blocks */ 8103 (0,external_wp_i18n_namespaceObject._n)('%s block selected.', '%s blocks selected.', blockCount), blockCount), 'assertive'); 8104 }; 8105 }; 8106 /** 8107 * Action that clears the block selection. 8108 * 8109 * @return {Object} Action object. 8110 */ 8111 8112 function clearSelectedBlock() { 8113 return { 8114 type: 'CLEAR_SELECTED_BLOCK' 8115 }; 8116 } 8117 /** 8118 * Action that enables or disables block selection. 8119 * 8120 * @param {boolean} [isSelectionEnabled=true] Whether block selection should 8121 * be enabled. 8122 * 8123 * @return {Object} Action object. 8124 */ 8125 8126 function toggleSelection() { 8127 let isSelectionEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; 8128 return { 8129 type: 'TOGGLE_SELECTION', 8130 isSelectionEnabled 8131 }; 8132 } 8133 8134 function getBlocksWithDefaultStylesApplied(blocks, blockEditorSettings) { 8135 var _blockEditorSettings$, _blockEditorSettings$2; 8136 8137 const preferredStyleVariations = (_blockEditorSettings$ = blockEditorSettings === null || blockEditorSettings === void 0 ? void 0 : (_blockEditorSettings$2 = blockEditorSettings.__experimentalPreferredStyleVariations) === null || _blockEditorSettings$2 === void 0 ? void 0 : _blockEditorSettings$2.value) !== null && _blockEditorSettings$ !== void 0 ? _blockEditorSettings$ : {}; 8138 return blocks.map(block => { 8139 var _block$attributes; 8140 8141 const blockName = block.name; 8142 8143 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, 'defaultStylePicker', true)) { 8144 return block; 8145 } 8146 8147 if (!preferredStyleVariations[blockName]) { 8148 return block; 8149 } 8150 8151 const className = (_block$attributes = block.attributes) === null || _block$attributes === void 0 ? void 0 : _block$attributes.className; 8152 8153 if (className !== null && className !== void 0 && className.includes('is-style-')) { 8154 return block; 8155 } 8156 8157 const { 8158 attributes = {} 8159 } = block; 8160 const blockStyle = preferredStyleVariations[blockName]; 8161 return { ...block, 8162 attributes: { ...attributes, 8163 className: `$className || ''} is-style-$blockStyle}`.trim() 8164 } 8165 }; 8166 }); 8167 } 8168 /* eslint-disable jsdoc/valid-types */ 8169 8170 /** 8171 * Action that replaces given blocks with one or more replacement blocks. 8172 * 8173 * @param {(string|string[])} clientIds Block client ID(s) to replace. 8174 * @param {(Object|Object[])} blocks Replacement block(s). 8175 * @param {number} indexToSelect Index of replacement block to select. 8176 * @param {0|-1|null} initialPosition Index of caret after in the selected block after the operation. 8177 * @param {?Object} meta Optional Meta values to be passed to the action object. 8178 * 8179 * @return {Object} Action object. 8180 */ 8181 8182 8183 const replaceBlocks = function (clientIds, blocks, indexToSelect) { 8184 let initialPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; 8185 let meta = arguments.length > 4 ? arguments[4] : undefined; 8186 return _ref7 => { 8187 let { 8188 select, 8189 dispatch 8190 } = _ref7; 8191 8192 /* eslint-enable jsdoc/valid-types */ 8193 clientIds = (0,external_lodash_namespaceObject.castArray)(clientIds); 8194 blocks = getBlocksWithDefaultStylesApplied((0,external_lodash_namespaceObject.castArray)(blocks), select.getSettings()); 8195 const rootClientId = select.getBlockRootClientId((0,external_lodash_namespaceObject.first)(clientIds)); // Replace is valid if the new blocks can be inserted in the root block. 8196 8197 for (let index = 0; index < blocks.length; index++) { 8198 const block = blocks[index]; 8199 const canInsertBlock = select.canInsertBlockType(block.name, rootClientId); 8200 8201 if (!canInsertBlock) { 8202 return; 8203 } 8204 } 8205 8206 dispatch({ 8207 type: 'REPLACE_BLOCKS', 8208 clientIds, 8209 blocks, 8210 time: Date.now(), 8211 indexToSelect, 8212 initialPosition, 8213 meta 8214 }); 8215 dispatch(ensureDefaultBlock()); 8216 }; 8217 }; 8218 /** 8219 * Action that replaces a single block with one or more replacement blocks. 8220 * 8221 * @param {(string|string[])} clientId Block client ID to replace. 8222 * @param {(Object|Object[])} block Replacement block(s). 8223 * 8224 * @return {Object} Action object. 8225 */ 8226 8227 function replaceBlock(clientId, block) { 8228 return replaceBlocks(clientId, block); 8229 } 8230 /** 8231 * Higher-order action creator which, given the action type to dispatch creates 8232 * an action creator for managing block movement. 8233 * 8234 * @param {string} type Action type to dispatch. 8235 * 8236 * @return {Function} Action creator. 8237 */ 8238 8239 const createOnMove = type => (clientIds, rootClientId) => _ref8 => { 8240 let { 8241 select, 8242 dispatch 8243 } = _ref8; 8244 // If one of the blocks is locked or the parent is locked, we cannot move any block. 8245 const canMoveBlocks = select.canMoveBlocks(clientIds, rootClientId); 8246 8247 if (!canMoveBlocks) { 8248 return; 8249 } 8250 8251 dispatch({ 8252 type, 8253 clientIds: (0,external_lodash_namespaceObject.castArray)(clientIds), 8254 rootClientId 8255 }); 8256 }; 8257 8258 const moveBlocksDown = createOnMove('MOVE_BLOCKS_DOWN'); 8259 const moveBlocksUp = createOnMove('MOVE_BLOCKS_UP'); 8260 /** 8261 * Action that moves given blocks to a new position. 8262 * 8263 * @param {?string} clientIds The client IDs of the blocks. 8264 * @param {?string} fromRootClientId Root client ID source. 8265 * @param {?string} toRootClientId Root client ID destination. 8266 * @param {number} index The index to move the blocks to. 8267 */ 8268 8269 const moveBlocksToPosition = function (clientIds) { 8270 let fromRootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 8271 let toRootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; 8272 let index = arguments.length > 3 ? arguments[3] : undefined; 8273 return _ref9 => { 8274 let { 8275 select, 8276 dispatch 8277 } = _ref9; 8278 const canMoveBlocks = select.canMoveBlocks(clientIds, fromRootClientId); // If one of the blocks is locked or the parent is locked, we cannot move any block. 8279 8280 if (!canMoveBlocks) { 8281 return; 8282 } // If moving inside the same root block the move is always possible. 8283 8284 8285 if (fromRootClientId !== toRootClientId) { 8286 const canRemoveBlocks = select.canRemoveBlocks(clientIds, fromRootClientId); // If we're moving to another block, it means we're deleting blocks from 8287 // the original block, so we need to check if removing is possible. 8288 8289 if (!canRemoveBlocks) { 8290 return; 8291 } 8292 8293 const canInsertBlocks = select.canInsertBlocks(clientIds, toRootClientId); // If moving to other parent block, the move is possible if we can insert a block of the same type inside the new parent block. 8294 8295 if (!canInsertBlocks) { 8296 return; 8297 } 8298 } 8299 8300 dispatch({ 8301 type: 'MOVE_BLOCKS_TO_POSITION', 8302 fromRootClientId, 8303 toRootClientId, 8304 clientIds, 8305 index 8306 }); 8307 }; 8308 }; 8309 /** 8310 * Action that moves given block to a new position. 8311 * 8312 * @param {?string} clientId The client ID of the block. 8313 * @param {?string} fromRootClientId Root client ID source. 8314 * @param {?string} toRootClientId Root client ID destination. 8315 * @param {number} index The index to move the block to. 8316 */ 8317 8318 function moveBlockToPosition(clientId) { 8319 let fromRootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 8320 let toRootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; 8321 let index = arguments.length > 3 ? arguments[3] : undefined; 8322 return moveBlocksToPosition([clientId], fromRootClientId, toRootClientId, index); 8323 } 8324 /** 8325 * Action that inserts a single block, optionally at a specific index respective a root block list. 8326 * 8327 * @param {Object} block Block object to insert. 8328 * @param {?number} index Index at which block should be inserted. 8329 * @param {?string} rootClientId Optional root client ID of block list on which to insert. 8330 * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true. 8331 * @param {?Object} meta Optional Meta values to be passed to the action object. 8332 * 8333 * @return {Object} Action object. 8334 */ 8335 8336 function insertBlock(block, index, rootClientId, updateSelection, meta) { 8337 return insertBlocks([block], index, rootClientId, updateSelection, 0, meta); 8338 } 8339 /* eslint-disable jsdoc/valid-types */ 8340 8341 /** 8342 * Action that inserts an array of blocks, optionally at a specific index respective a root block list. 8343 * 8344 * @param {Object[]} blocks Block objects to insert. 8345 * @param {?number} index Index at which block should be inserted. 8346 * @param {?string} rootClientId Optional root client ID of block list on which to insert. 8347 * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true. 8348 * @param {0|-1|null} initialPosition Initial focus position. Setting it to null prevent focusing the inserted block. 8349 * @param {?Object} meta Optional Meta values to be passed to the action object. 8350 * @return {Object} Action object. 8351 */ 8352 8353 const insertBlocks = function (blocks, index, rootClientId) { 8354 let updateSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; 8355 let initialPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; 8356 let meta = arguments.length > 5 ? arguments[5] : undefined; 8357 return _ref10 => { 8358 let { 8359 select, 8360 dispatch 8361 } = _ref10; 8362 8363 /* eslint-enable jsdoc/valid-types */ 8364 if ((0,external_lodash_namespaceObject.isObject)(initialPosition)) { 8365 meta = initialPosition; 8366 initialPosition = 0; 8367 external_wp_deprecated_default()("meta argument in wp.data.dispatch('core/block-editor')", { 8368 since: '5.8', 8369 hint: 'The meta argument is now the 6th argument of the function' 8370 }); 8371 } 8372 8373 blocks = getBlocksWithDefaultStylesApplied((0,external_lodash_namespaceObject.castArray)(blocks), select.getSettings()); 8374 const allowedBlocks = []; 8375 8376 for (const block of blocks) { 8377 const isValid = select.canInsertBlockType(block.name, rootClientId); 8378 8379 if (isValid) { 8380 allowedBlocks.push(block); 8381 } 8382 } 8383 8384 if (allowedBlocks.length) { 8385 dispatch({ 8386 type: 'INSERT_BLOCKS', 8387 blocks: allowedBlocks, 8388 index, 8389 rootClientId, 8390 time: Date.now(), 8391 updateSelection, 8392 initialPosition: updateSelection ? initialPosition : null, 8393 meta 8394 }); 8395 } 8396 }; 8397 }; 8398 /** 8399 * Action that shows the insertion point. 8400 * 8401 * @param {?string} rootClientId Optional root client ID of block list on 8402 * which to insert. 8403 * @param {?number} index Index at which block should be inserted. 8404 * @param {Object} __unstableOptions Whether or not to show an inserter button. 8405 * 8406 * @return {Object} Action object. 8407 */ 8408 8409 function showInsertionPoint(rootClientId, index) { 8410 let __unstableOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; 8411 8412 const { 8413 __unstableWithInserter 8414 } = __unstableOptions; 8415 return { 8416 type: 'SHOW_INSERTION_POINT', 8417 rootClientId, 8418 index, 8419 __unstableWithInserter 8420 }; 8421 } 8422 /** 8423 * Action that hides the insertion point. 8424 * 8425 * @return {Object} Action object. 8426 */ 8427 8428 function hideInsertionPoint() { 8429 return { 8430 type: 'HIDE_INSERTION_POINT' 8431 }; 8432 } 8433 /** 8434 * Action that resets the template validity. 8435 * 8436 * @param {boolean} isValid template validity flag. 8437 * 8438 * @return {Object} Action object. 8439 */ 8440 8441 function setTemplateValidity(isValid) { 8442 return { 8443 type: 'SET_TEMPLATE_VALIDITY', 8444 isValid 8445 }; 8446 } 8447 /** 8448 * Action that synchronizes the template with the list of blocks. 8449 * 8450 * @return {Object} Action object. 8451 */ 8452 8453 const synchronizeTemplate = () => _ref11 => { 8454 let { 8455 select, 8456 dispatch 8457 } = _ref11; 8458 dispatch({ 8459 type: 'SYNCHRONIZE_TEMPLATE' 8460 }); 8461 const blocks = select.getBlocks(); 8462 const template = select.getTemplate(); 8463 const updatedBlockList = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(blocks, template); 8464 dispatch.resetBlocks(updatedBlockList); 8465 }; 8466 /** 8467 * Delete the current selection. 8468 * 8469 * @param {boolean} isForward 8470 */ 8471 8472 const __unstableDeleteSelection = isForward => _ref12 => { 8473 let { 8474 registry, 8475 select, 8476 dispatch 8477 } = _ref12; 8478 const selectionAnchor = select.getSelectionStart(); 8479 const selectionFocus = select.getSelectionEnd(); 8480 if (selectionAnchor.clientId === selectionFocus.clientId) return; // It's not mergeable if there's no rich text selection. 8481 8482 if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') return false; 8483 const anchorRootClientId = select.getBlockRootClientId(selectionAnchor.clientId); 8484 const focusRootClientId = select.getBlockRootClientId(selectionFocus.clientId); // It's not mergeable if the selection doesn't start and end in the same 8485 // block list. Maybe in the future it should be allowed. 8486 8487 if (anchorRootClientId !== focusRootClientId) { 8488 return; 8489 } 8490 8491 const blockOrder = select.getBlockOrder(anchorRootClientId); 8492 const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId); 8493 const focusIndex = blockOrder.indexOf(selectionFocus.clientId); // Reassign selection start and end based on order. 8494 8495 let selectionStart, selectionEnd; 8496 8497 if (anchorIndex > focusIndex) { 8498 selectionStart = selectionFocus; 8499 selectionEnd = selectionAnchor; 8500 } else { 8501 selectionStart = selectionAnchor; 8502 selectionEnd = selectionFocus; 8503 } 8504 8505 const targetSelection = isForward ? selectionEnd : selectionStart; 8506 const targetBlock = select.getBlock(targetSelection.clientId); 8507 const targetBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(targetBlock.name); 8508 8509 if (!targetBlockType.merge) { 8510 return; 8511 } 8512 8513 const selectionA = selectionStart; 8514 const selectionB = selectionEnd; 8515 const blockA = select.getBlock(selectionA.clientId); 8516 const blockAType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockA.name); 8517 const blockB = select.getBlock(selectionB.clientId); 8518 const blockBType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockB.name); 8519 const htmlA = blockA.attributes[selectionA.attributeKey]; 8520 const htmlB = blockB.attributes[selectionB.attributeKey]; 8521 const attributeDefinitionA = blockAType.attributes[selectionA.attributeKey]; 8522 const attributeDefinitionB = blockBType.attributes[selectionB.attributeKey]; 8523 let valueA = (0,external_wp_richText_namespaceObject.create)({ 8524 html: htmlA, 8525 ...mapRichTextSettings(attributeDefinitionA) 8526 }); 8527 let valueB = (0,external_wp_richText_namespaceObject.create)({ 8528 html: htmlB, 8529 ...mapRichTextSettings(attributeDefinitionB) 8530 }); // A robust way to retain selection position through various transforms 8531 // is to insert a special character at the position and then recover it. 8532 8533 const START_OF_SELECTED_AREA = '\u0086'; 8534 valueA = (0,external_wp_richText_namespaceObject.remove)(valueA, selectionA.offset, valueA.text.length); 8535 valueB = (0,external_wp_richText_namespaceObject.insert)(valueB, START_OF_SELECTED_AREA, 0, selectionB.offset); // Clone the blocks so we don't manipulate the original. 8536 8537 const cloneA = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockA, { 8538 [selectionA.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({ 8539 value: valueA, 8540 ...mapRichTextSettings(attributeDefinitionA) 8541 }) 8542 }); 8543 const cloneB = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockB, { 8544 [selectionB.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({ 8545 value: valueB, 8546 ...mapRichTextSettings(attributeDefinitionB) 8547 }) 8548 }); 8549 const followingBlock = isForward ? cloneA : cloneB; // We can only merge blocks with similar types 8550 // thus, we transform the block to merge first 8551 8552 const blocksWithTheSameType = blockA.name === blockB.name ? [followingBlock] : (0,external_wp_blocks_namespaceObject.switchToBlockType)(followingBlock, targetBlockType.name); // If the block types can not match, do nothing 8553 8554 if (!blocksWithTheSameType || !blocksWithTheSameType.length) { 8555 return; 8556 } 8557 8558 let updatedAttributes; 8559 8560 if (isForward) { 8561 const blockToMerge = blocksWithTheSameType.pop(); 8562 updatedAttributes = targetBlockType.merge(blockToMerge.attributes, cloneB.attributes); 8563 } else { 8564 const blockToMerge = blocksWithTheSameType.shift(); 8565 updatedAttributes = targetBlockType.merge(cloneA.attributes, blockToMerge.attributes); 8566 } 8567 8568 const newAttributeKey = (0,external_lodash_namespaceObject.findKey)(updatedAttributes, v => typeof v === 'string' && v.indexOf(START_OF_SELECTED_AREA) !== -1); 8569 const convertedHtml = updatedAttributes[newAttributeKey]; 8570 const convertedValue = (0,external_wp_richText_namespaceObject.create)({ 8571 html: convertedHtml, 8572 ...mapRichTextSettings(targetBlockType.attributes[newAttributeKey]) 8573 }); 8574 const newOffset = convertedValue.text.indexOf(START_OF_SELECTED_AREA); 8575 const newValue = (0,external_wp_richText_namespaceObject.remove)(convertedValue, newOffset, newOffset + 1); 8576 const newHtml = (0,external_wp_richText_namespaceObject.toHTMLString)({ 8577 value: newValue, 8578 ...mapRichTextSettings(targetBlockType.attributes[newAttributeKey]) 8579 }); 8580 updatedAttributes[newAttributeKey] = newHtml; 8581 const selectedBlockClientIds = select.getSelectedBlockClientIds(); 8582 const replacement = [...(isForward ? blocksWithTheSameType : []), { // Preserve the original client ID. 8583 ...targetBlock, 8584 attributes: { ...targetBlock.attributes, 8585 ...updatedAttributes 8586 } 8587 }, ...(isForward ? [] : blocksWithTheSameType)]; 8588 registry.batch(() => { 8589 dispatch.selectionChange(targetBlock.clientId, newAttributeKey, newOffset, newOffset); 8590 dispatch.replaceBlocks(selectedBlockClientIds, replacement, 0, // If we don't pass the `indexToSelect` it will default to the last block. 8591 select.getSelectedBlocksInitialCaretPosition()); 8592 }); 8593 }; 8594 /** 8595 * Split the current selection. 8596 */ 8597 8598 const __unstableSplitSelection = () => _ref13 => { 8599 let { 8600 select, 8601 dispatch 8602 } = _ref13; 8603 const selectionAnchor = select.getSelectionStart(); 8604 const selectionFocus = select.getSelectionEnd(); 8605 if (selectionAnchor.clientId === selectionFocus.clientId) return; // Can't split if the selection is not set. 8606 8607 if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') return; 8608 const anchorRootClientId = select.getBlockRootClientId(selectionAnchor.clientId); 8609 const focusRootClientId = select.getBlockRootClientId(selectionFocus.clientId); // It's not splittable if the selection doesn't start and end in the same 8610 // block list. Maybe in the future it should be allowed. 8611 8612 if (anchorRootClientId !== focusRootClientId) { 8613 return; 8614 } 8615 8616 const blockOrder = select.getBlockOrder(anchorRootClientId); 8617 const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId); 8618 const focusIndex = blockOrder.indexOf(selectionFocus.clientId); // Reassign selection start and end based on order. 8619 8620 let selectionStart, selectionEnd; 8621 8622 if (anchorIndex > focusIndex) { 8623 selectionStart = selectionFocus; 8624 selectionEnd = selectionAnchor; 8625 } else { 8626 selectionStart = selectionAnchor; 8627 selectionEnd = selectionFocus; 8628 } 8629 8630 const selectionA = selectionStart; 8631 const selectionB = selectionEnd; 8632 const blockA = select.getBlock(selectionA.clientId); 8633 const blockAType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockA.name); 8634 const blockB = select.getBlock(selectionB.clientId); 8635 const blockBType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockB.name); 8636 const htmlA = blockA.attributes[selectionA.attributeKey]; 8637 const htmlB = blockB.attributes[selectionB.attributeKey]; 8638 const attributeDefinitionA = blockAType.attributes[selectionA.attributeKey]; 8639 const attributeDefinitionB = blockBType.attributes[selectionB.attributeKey]; 8640 let valueA = (0,external_wp_richText_namespaceObject.create)({ 8641 html: htmlA, 8642 ...mapRichTextSettings(attributeDefinitionA) 8643 }); 8644 let valueB = (0,external_wp_richText_namespaceObject.create)({ 8645 html: htmlB, 8646 ...mapRichTextSettings(attributeDefinitionB) 8647 }); 8648 valueA = (0,external_wp_richText_namespaceObject.remove)(valueA, selectionA.offset, valueA.text.length); 8649 valueB = (0,external_wp_richText_namespaceObject.remove)(valueB, 0, selectionB.offset); 8650 dispatch.replaceBlocks(select.getSelectedBlockClientIds(), [{ // Preserve the original client ID. 8651 ...blockA, 8652 attributes: { ...blockA.attributes, 8653 [selectionA.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({ 8654 value: valueA, 8655 ...mapRichTextSettings(attributeDefinitionA) 8656 }) 8657 } 8658 }, (0,external_wp_blocks_namespaceObject.createBlock)((0,external_wp_blocks_namespaceObject.getDefaultBlockName)()), { // Preserve the original client ID. 8659 ...blockB, 8660 attributes: { ...blockB.attributes, 8661 [selectionB.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({ 8662 value: valueB, 8663 ...mapRichTextSettings(attributeDefinitionB) 8664 }) 8665 } 8666 }], 1, // If we don't pass the `indexToSelect` it will default to the last block. 8667 select.getSelectedBlocksInitialCaretPosition()); 8668 }; 8669 /** 8670 * Expand the selection to cover the entire blocks, removing partial selection. 8671 */ 8672 8673 const __unstableExpandSelection = () => _ref14 => { 8674 let { 8675 select, 8676 dispatch 8677 } = _ref14; 8678 const selectionAnchor = select.getSelectionStart(); 8679 const selectionFocus = select.getSelectionEnd(); 8680 dispatch.selectionChange({ 8681 start: { 8682 clientId: selectionAnchor.clientId 8683 }, 8684 end: { 8685 clientId: selectionFocus.clientId 8686 } 8687 }); 8688 }; 8689 /** 8690 * Action that merges two blocks. 8691 * 8692 * @param {string} firstBlockClientId Client ID of the first block to merge. 8693 * @param {string} secondBlockClientId Client ID of the second block to merge. 8694 */ 8695 8696 const mergeBlocks = (firstBlockClientId, secondBlockClientId) => _ref15 => { 8697 let { 8698 select, 8699 dispatch 8700 } = _ref15; 8701 const blocks = [firstBlockClientId, secondBlockClientId]; 8702 dispatch({ 8703 type: 'MERGE_BLOCKS', 8704 blocks 8705 }); 8706 const [clientIdA, clientIdB] = blocks; 8707 const blockA = select.getBlock(clientIdA); 8708 const blockAType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockA.name); // Only focus the previous block if it's not mergeable. 8709 8710 if (blockAType && !blockAType.merge) { 8711 dispatch.selectBlock(blockA.clientId); 8712 return; 8713 } 8714 8715 const blockB = select.getBlock(clientIdB); 8716 const blockBType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockB.name); 8717 const { 8718 clientId, 8719 attributeKey, 8720 offset 8721 } = select.getSelectionStart(); 8722 const selectedBlockType = clientId === clientIdA ? blockAType : blockBType; 8723 const attributeDefinition = selectedBlockType.attributes[attributeKey]; 8724 const canRestoreTextSelection = (clientId === clientIdA || clientId === clientIdB) && attributeKey !== undefined && offset !== undefined && // We cannot restore text selection if the RichText identifier 8725 // is not a defined block attribute key. This can be the case if the 8726 // fallback intance ID is used to store selection (and no RichText 8727 // identifier is set), or when the identifier is wrong. 8728 !!attributeDefinition; 8729 8730 if (!attributeDefinition) { 8731 if (typeof attributeKey === 'number') { 8732 window.console.error(`RichText needs an identifier prop that is the block attribute key of the attribute it controls. Its type is expected to be a string, but was $typeof attributeKey}`); 8733 } else { 8734 window.console.error('The RichText identifier prop does not match any attributes defined by the block.'); 8735 } 8736 } // A robust way to retain selection position through various transforms 8737 // is to insert a special character at the position and then recover it. 8738 8739 8740 const START_OF_SELECTED_AREA = '\u0086'; // Clone the blocks so we don't insert the character in a "live" block. 8741 8742 const cloneA = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockA); 8743 const cloneB = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockB); 8744 8745 if (canRestoreTextSelection) { 8746 const selectedBlock = clientId === clientIdA ? cloneA : cloneB; 8747 const html = selectedBlock.attributes[attributeKey]; 8748 const value = (0,external_wp_richText_namespaceObject.insert)((0,external_wp_richText_namespaceObject.create)({ 8749 html, 8750 ...mapRichTextSettings(attributeDefinition) 8751 }), START_OF_SELECTED_AREA, offset, offset); 8752 selectedBlock.attributes[attributeKey] = (0,external_wp_richText_namespaceObject.toHTMLString)({ 8753 value, 8754 ...mapRichTextSettings(attributeDefinition) 8755 }); 8756 } // We can only merge blocks with similar types 8757 // thus, we transform the block to merge first. 8758 8759 8760 const blocksWithTheSameType = blockA.name === blockB.name ? [cloneB] : (0,external_wp_blocks_namespaceObject.switchToBlockType)(cloneB, blockA.name); // If the block types can not match, do nothing. 8761 8762 if (!blocksWithTheSameType || !blocksWithTheSameType.length) { 8763 return; 8764 } // Calling the merge to update the attributes and remove the block to be merged. 8765 8766 8767 const updatedAttributes = blockAType.merge(cloneA.attributes, blocksWithTheSameType[0].attributes); 8768 8769 if (canRestoreTextSelection) { 8770 const newAttributeKey = (0,external_lodash_namespaceObject.findKey)(updatedAttributes, v => typeof v === 'string' && v.indexOf(START_OF_SELECTED_AREA) !== -1); 8771 const convertedHtml = updatedAttributes[newAttributeKey]; 8772 const convertedValue = (0,external_wp_richText_namespaceObject.create)({ 8773 html: convertedHtml, 8774 ...mapRichTextSettings(blockAType.attributes[newAttributeKey]) 8775 }); 8776 const newOffset = convertedValue.text.indexOf(START_OF_SELECTED_AREA); 8777 const newValue = (0,external_wp_richText_namespaceObject.remove)(convertedValue, newOffset, newOffset + 1); 8778 const newHtml = (0,external_wp_richText_namespaceObject.toHTMLString)({ 8779 value: newValue, 8780 ...mapRichTextSettings(blockAType.attributes[newAttributeKey]) 8781 }); 8782 updatedAttributes[newAttributeKey] = newHtml; 8783 dispatch.selectionChange(blockA.clientId, newAttributeKey, newOffset, newOffset); 8784 } 8785 8786 dispatch.replaceBlocks([blockA.clientId, blockB.clientId], [{ ...blockA, 8787 attributes: { ...blockA.attributes, 8788 ...updatedAttributes 8789 } 8790 }, ...blocksWithTheSameType.slice(1)], 0 // If we don't pass the `indexToSelect` it will default to the last block. 8791 ); 8792 }; 8793 /** 8794 * Yields action objects used in signalling that the blocks corresponding to 8795 * the set of specified client IDs are to be removed. 8796 * 8797 * @param {string|string[]} clientIds Client IDs of blocks to remove. 8798 * @param {boolean} selectPrevious True if the previous block should be 8799 * selected when a block is removed. 8800 */ 8801 8802 const removeBlocks = function (clientIds) { 8803 let selectPrevious = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; 8804 return _ref16 => { 8805 let { 8806 select, 8807 dispatch 8808 } = _ref16; 8809 8810 if (!clientIds || !clientIds.length) { 8811 return; 8812 } 8813 8814 clientIds = (0,external_lodash_namespaceObject.castArray)(clientIds); 8815 const rootClientId = select.getBlockRootClientId(clientIds[0]); 8816 const canRemoveBlocks = select.canRemoveBlocks(clientIds, rootClientId); 8817 8818 if (!canRemoveBlocks) { 8819 return; 8820 } 8821 8822 if (selectPrevious) { 8823 dispatch.selectPreviousBlock(clientIds[0]); 8824 } 8825 8826 dispatch({ 8827 type: 'REMOVE_BLOCKS', 8828 clientIds 8829 }); // To avoid a focus loss when removing the last block, assure there is 8830 // always a default block if the last of the blocks have been removed. 8831 8832 dispatch(ensureDefaultBlock()); 8833 }; 8834 }; 8835 /** 8836 * Returns an action object used in signalling that the block with the 8837 * specified client ID is to be removed. 8838 * 8839 * @param {string} clientId Client ID of block to remove. 8840 * @param {boolean} selectPrevious True if the previous block should be 8841 * selected when a block is removed. 8842 * 8843 * @return {Object} Action object. 8844 */ 8845 8846 function removeBlock(clientId, selectPrevious) { 8847 return removeBlocks([clientId], selectPrevious); 8848 } 8849 /* eslint-disable jsdoc/valid-types */ 8850 8851 /** 8852 * Returns an action object used in signalling that the inner blocks with the 8853 * specified client ID should be replaced. 8854 * 8855 * @param {string} rootClientId Client ID of the block whose InnerBlocks will re replaced. 8856 * @param {Object[]} blocks Block objects to insert as new InnerBlocks 8857 * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to false. 8858 * @param {0|-1|null} initialPosition Initial block position. 8859 * @return {Object} Action object. 8860 */ 8861 8862 function replaceInnerBlocks(rootClientId, blocks) { 8863 let updateSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 8864 let initialPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; 8865 8866 /* eslint-enable jsdoc/valid-types */ 8867 return { 8868 type: 'REPLACE_INNER_BLOCKS', 8869 rootClientId, 8870 blocks, 8871 updateSelection, 8872 initialPosition: updateSelection ? initialPosition : null, 8873 time: Date.now() 8874 }; 8875 } 8876 /** 8877 * Returns an action object used to toggle the block editing mode between 8878 * visual and HTML modes. 8879 * 8880 * @param {string} clientId Block client ID. 8881 * 8882 * @return {Object} Action object. 8883 */ 8884 8885 function toggleBlockMode(clientId) { 8886 return { 8887 type: 'TOGGLE_BLOCK_MODE', 8888 clientId 8889 }; 8890 } 8891 /** 8892 * Returns an action object used in signalling that the user has begun to type. 8893 * 8894 * @return {Object} Action object. 8895 */ 8896 8897 function startTyping() { 8898 return { 8899 type: 'START_TYPING' 8900 }; 8901 } 8902 /** 8903 * Returns an action object used in signalling that the user has stopped typing. 8904 * 8905 * @return {Object} Action object. 8906 */ 8907 8908 function stopTyping() { 8909 return { 8910 type: 'STOP_TYPING' 8911 }; 8912 } 8913 /** 8914 * Returns an action object used in signalling that the user has begun to drag blocks. 8915 * 8916 * @param {string[]} clientIds An array of client ids being dragged 8917 * 8918 * @return {Object} Action object. 8919 */ 8920 8921 function startDraggingBlocks() { 8922 let clientIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; 8923 return { 8924 type: 'START_DRAGGING_BLOCKS', 8925 clientIds 8926 }; 8927 } 8928 /** 8929 * Returns an action object used in signalling that the user has stopped dragging blocks. 8930 * 8931 * @return {Object} Action object. 8932 */ 8933 8934 function stopDraggingBlocks() { 8935 return { 8936 type: 'STOP_DRAGGING_BLOCKS' 8937 }; 8938 } 8939 /** 8940 * Returns an action object used in signalling that the caret has entered formatted text. 8941 * 8942 * @return {Object} Action object. 8943 */ 8944 8945 function enterFormattedText() { 8946 return { 8947 type: 'ENTER_FORMATTED_TEXT' 8948 }; 8949 } 8950 /** 8951 * Returns an action object used in signalling that the user caret has exited formatted text. 8952 * 8953 * @return {Object} Action object. 8954 */ 8955 8956 function exitFormattedText() { 8957 return { 8958 type: 'EXIT_FORMATTED_TEXT' 8959 }; 8960 } 8961 /** 8962 * Action that changes the position of the user caret. 8963 * 8964 * @param {string|WPSelection} clientId The selected block client ID. 8965 * @param {string} attributeKey The selected block attribute key. 8966 * @param {number} startOffset The start offset. 8967 * @param {number} endOffset The end offset. 8968 * 8969 * @return {Object} Action object. 8970 */ 8971 8972 function selectionChange(clientId, attributeKey, startOffset, endOffset) { 8973 if (typeof clientId === 'string') { 8974 return { 8975 type: 'SELECTION_CHANGE', 8976 clientId, 8977 attributeKey, 8978 startOffset, 8979 endOffset 8980 }; 8981 } 8982 8983 return { 8984 type: 'SELECTION_CHANGE', 8985 ...clientId 8986 }; 8987 } 8988 /** 8989 * Action that adds a new block of the default type to the block list. 8990 * 8991 * @param {?Object} attributes Optional attributes of the block to assign. 8992 * @param {?string} rootClientId Optional root client ID of block list on which 8993 * to append. 8994 * @param {?number} index Optional index where to insert the default block. 8995 */ 8996 8997 const insertDefaultBlock = (attributes, rootClientId, index) => _ref17 => { 8998 let { 8999 dispatch 9000 } = _ref17; 9001 // Abort if there is no default block type (if it has been unregistered). 9002 const defaultBlockName = (0,external_wp_blocks_namespaceObject.getDefaultBlockName)(); 9003 9004 if (!defaultBlockName) { 9005 return; 9006 } 9007 9008 const block = (0,external_wp_blocks_namespaceObject.createBlock)(defaultBlockName, attributes); 9009 return dispatch.insertBlock(block, index, rootClientId); 9010 }; 9011 /** 9012 * Action that changes the nested settings of a given block. 9013 * 9014 * @param {string} clientId Client ID of the block whose nested setting are 9015 * being received. 9016 * @param {Object} settings Object with the new settings for the nested block. 9017 * 9018 * @return {Object} Action object 9019 */ 9020 9021 function updateBlockListSettings(clientId, settings) { 9022 return { 9023 type: 'UPDATE_BLOCK_LIST_SETTINGS', 9024 clientId, 9025 settings 9026 }; 9027 } 9028 /** 9029 * Action that updates the block editor settings. 9030 * 9031 * @param {Object} settings Updated settings 9032 * 9033 * @return {Object} Action object 9034 */ 9035 9036 function updateSettings(settings) { 9037 return { 9038 type: 'UPDATE_SETTINGS', 9039 settings 9040 }; 9041 } 9042 /** 9043 * Action that signals that a temporary reusable block has been saved 9044 * in order to switch its temporary id with the real id. 9045 * 9046 * @param {string} id Reusable block's id. 9047 * @param {string} updatedId Updated block's id. 9048 * 9049 * @return {Object} Action object. 9050 */ 9051 9052 function __unstableSaveReusableBlock(id, updatedId) { 9053 return { 9054 type: 'SAVE_REUSABLE_BLOCK_SUCCESS', 9055 id, 9056 updatedId 9057 }; 9058 } 9059 /** 9060 * Action that marks the last block change explicitly as persistent. 9061 * 9062 * @return {Object} Action object. 9063 */ 9064 9065 function __unstableMarkLastChangeAsPersistent() { 9066 return { 9067 type: 'MARK_LAST_CHANGE_AS_PERSISTENT' 9068 }; 9069 } 9070 /** 9071 * Action that signals that the next block change should be marked explicitly as not persistent. 9072 * 9073 * @return {Object} Action object. 9074 */ 9075 9076 function __unstableMarkNextChangeAsNotPersistent() { 9077 return { 9078 type: 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT' 9079 }; 9080 } 9081 /** 9082 * Action that marks the last block change as an automatic change, meaning it was not 9083 * performed by the user, and can be undone using the `Escape` and `Backspace` keys. 9084 * This action must be called after the change was made, and any actions that are a 9085 * consequence of it, so it is recommended to be called at the next idle period to ensure all 9086 * selection changes have been recorded. 9087 */ 9088 9089 const __unstableMarkAutomaticChange = () => _ref18 => { 9090 let { 9091 dispatch 9092 } = _ref18; 9093 dispatch({ 9094 type: 'MARK_AUTOMATIC_CHANGE' 9095 }); 9096 const { 9097 requestIdleCallback = cb => setTimeout(cb, 100) 9098 } = window; 9099 requestIdleCallback(() => { 9100 dispatch({ 9101 type: 'MARK_AUTOMATIC_CHANGE_FINAL' 9102 }); 9103 }); 9104 }; 9105 /** 9106 * Action that enables or disables the navigation mode. 9107 * 9108 * @param {string} isNavigationMode Enable/Disable navigation mode. 9109 */ 9110 9111 const setNavigationMode = function () { 9112 let isNavigationMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; 9113 return _ref19 => { 9114 let { 9115 dispatch 9116 } = _ref19; 9117 dispatch({ 9118 type: 'SET_NAVIGATION_MODE', 9119 isNavigationMode 9120 }); 9121 9122 if (isNavigationMode) { 9123 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('You are currently in navigation mode. Navigate blocks using the Tab key and Arrow keys. Use Left and Right Arrow keys to move between nesting levels. To exit navigation mode and edit the selected block, press Enter.')); 9124 } else { 9125 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('You are currently in edit mode. To return to the navigation mode, press Escape.')); 9126 } 9127 }; 9128 }; 9129 /** 9130 * Action that enables or disables the block moving mode. 9131 * 9132 * @param {string|null} hasBlockMovingClientId Enable/Disable block moving mode. 9133 */ 9134 9135 const setBlockMovingClientId = function () { 9136 let hasBlockMovingClientId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 9137 return _ref20 => { 9138 let { 9139 dispatch 9140 } = _ref20; 9141 dispatch({ 9142 type: 'SET_BLOCK_MOVING_MODE', 9143 hasBlockMovingClientId 9144 }); 9145 9146 if (hasBlockMovingClientId) { 9147 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Use the Tab key and Arrow keys to choose new block location. Use Left and Right Arrow keys to move between nesting levels. Once location is selected press Enter or Space to move the block.')); 9148 } 9149 }; 9150 }; 9151 /** 9152 * Action that duplicates a list of blocks. 9153 * 9154 * @param {string[]} clientIds 9155 * @param {boolean} updateSelection 9156 */ 9157 9158 const duplicateBlocks = function (clientIds) { 9159 let updateSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; 9160 return _ref21 => { 9161 let { 9162 select, 9163 dispatch 9164 } = _ref21; 9165 9166 if (!clientIds || !clientIds.length) { 9167 return; 9168 } // Return early if blocks don't exist. 9169 9170 9171 const blocks = select.getBlocksByClientId(clientIds); 9172 9173 if ((0,external_lodash_namespaceObject.some)(blocks, block => !block)) { 9174 return; 9175 } // Return early if blocks don't support multiple usage. 9176 9177 9178 const blockNames = blocks.map(block => block.name); 9179 9180 if (blockNames.some(blockName => !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, 'multiple', true))) { 9181 return; 9182 } 9183 9184 const rootClientId = select.getBlockRootClientId(clientIds[0]); 9185 const lastSelectedIndex = select.getBlockIndex((0,external_lodash_namespaceObject.last)((0,external_lodash_namespaceObject.castArray)(clientIds))); 9186 const clonedBlocks = blocks.map(block => (0,external_wp_blocks_namespaceObject.__experimentalCloneSanitizedBlock)(block)); 9187 dispatch.insertBlocks(clonedBlocks, lastSelectedIndex + 1, rootClientId, updateSelection); 9188 9189 if (clonedBlocks.length > 1 && updateSelection) { 9190 dispatch.multiSelect((0,external_lodash_namespaceObject.first)(clonedBlocks).clientId, (0,external_lodash_namespaceObject.last)(clonedBlocks).clientId); 9191 } 9192 9193 return clonedBlocks.map(block => block.clientId); 9194 }; 9195 }; 9196 /** 9197 * Action that inserts an empty block before a given block. 9198 * 9199 * @param {string} clientId 9200 */ 9201 9202 const insertBeforeBlock = clientId => _ref22 => { 9203 let { 9204 select, 9205 dispatch 9206 } = _ref22; 9207 9208 if (!clientId) { 9209 return; 9210 } 9211 9212 const rootClientId = select.getBlockRootClientId(clientId); 9213 const isLocked = select.getTemplateLock(rootClientId); 9214 9215 if (isLocked) { 9216 return; 9217 } 9218 9219 const firstSelectedIndex = select.getBlockIndex(clientId); 9220 return dispatch.insertDefaultBlock({}, rootClientId, firstSelectedIndex); 9221 }; 9222 /** 9223 * Action that inserts an empty block after a given block. 9224 * 9225 * @param {string} clientId 9226 */ 9227 9228 const insertAfterBlock = clientId => _ref23 => { 9229 let { 9230 select, 9231 dispatch 9232 } = _ref23; 9233 9234 if (!clientId) { 9235 return; 9236 } 9237 9238 const rootClientId = select.getBlockRootClientId(clientId); 9239 const isLocked = select.getTemplateLock(rootClientId); 9240 9241 if (isLocked) { 9242 return; 9243 } 9244 9245 const firstSelectedIndex = select.getBlockIndex(clientId); 9246 return dispatch.insertDefaultBlock({}, rootClientId, firstSelectedIndex + 1); 9247 }; 9248 /** 9249 * Action that toggles the highlighted block state. 9250 * 9251 * @param {string} clientId The block's clientId. 9252 * @param {boolean} isHighlighted The highlight state. 9253 */ 9254 9255 function toggleBlockHighlight(clientId, isHighlighted) { 9256 return { 9257 type: 'TOGGLE_BLOCK_HIGHLIGHT', 9258 clientId, 9259 isHighlighted 9260 }; 9261 } 9262 /** 9263 * Action that "flashes" the block with a given `clientId` by rhythmically highlighting it. 9264 * 9265 * @param {string} clientId Target block client ID. 9266 */ 9267 9268 const flashBlock = clientId => async _ref24 => { 9269 let { 9270 dispatch 9271 } = _ref24; 9272 dispatch(toggleBlockHighlight(clientId, true)); 9273 await new Promise(resolve => setTimeout(resolve, 150)); 9274 dispatch(toggleBlockHighlight(clientId, false)); 9275 }; 9276 /** 9277 * Action that sets whether a block has controlled inner blocks. 9278 * 9279 * @param {string} clientId The block's clientId. 9280 * @param {boolean} hasControlledInnerBlocks True if the block's inner blocks are controlled. 9281 */ 9282 9283 function setHasControlledInnerBlocks(clientId, hasControlledInnerBlocks) { 9284 return { 9285 type: 'SET_HAS_CONTROLLED_INNER_BLOCKS', 9286 hasControlledInnerBlocks, 9287 clientId 9288 }; 9289 } 9290 9291 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/constants.js 9292 const STORE_NAME = 'core/block-editor'; 9293 9294 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/index.js 9295 /** 9296 * WordPress dependencies 9297 */ 9298 9299 /** 9300 * Internal dependencies 9301 */ 9302 9303 9304 9305 9306 9307 /** 9308 * Block editor data store configuration. 9309 * 9310 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore 9311 * 9312 * @type {Object} 9313 */ 9314 9315 const storeConfig = { 9316 reducer: reducer, 9317 selectors: selectors_namespaceObject, 9318 actions: actions_namespaceObject 9319 }; 9320 /** 9321 * Store definition for the block editor namespace. 9322 * 9323 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore 9324 * 9325 * @type {Object} 9326 */ 9327 9328 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { ...storeConfig, 9329 persist: ['preferences'] 9330 }); // Ideally we'd use register instead of register stores. 9331 9332 (0,external_wp_data_namespaceObject.registerStore)(STORE_NAME, { ...storeConfig, 9333 persist: ['preferences'] 9334 }); 9335 9336 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/context.js 9337 /** 9338 * WordPress dependencies 9339 */ 9340 9341 const DEFAULT_BLOCK_EDIT_CONTEXT = { 9342 name: '', 9343 isSelected: false 9344 }; 9345 const Context = (0,external_wp_element_namespaceObject.createContext)(DEFAULT_BLOCK_EDIT_CONTEXT); 9346 const { 9347 Provider 9348 } = Context; 9349 9350 /** 9351 * A hook that returns the block edit context. 9352 * 9353 * @return {Object} Block edit context 9354 */ 9355 9356 function useBlockEditContext() { 9357 return (0,external_wp_element_namespaceObject.useContext)(Context); 9358 } 9359 9360 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-display-block-controls/index.js 9361 /** 9362 * WordPress dependencies 9363 */ 9364 9365 /** 9366 * Internal dependencies 9367 */ 9368 9369 9370 9371 function useDisplayBlockControls() { 9372 const { 9373 isSelected, 9374 clientId, 9375 name 9376 } = useBlockEditContext(); 9377 return (0,external_wp_data_namespaceObject.useSelect)(select => { 9378 if (isSelected) { 9379 return true; 9380 } 9381 9382 const { 9383 getBlockName, 9384 isFirstMultiSelectedBlock, 9385 getMultiSelectedBlockClientIds 9386 } = select(store); 9387 9388 if (isFirstMultiSelectedBlock(clientId)) { 9389 return getMultiSelectedBlockClientIds().every(id => getBlockName(id) === name); 9390 } 9391 9392 return false; 9393 }, [clientId, isSelected, name]); 9394 } 9395 9396 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/hook.js 9397 /** 9398 * WordPress dependencies 9399 */ 9400 9401 9402 /** 9403 * Internal dependencies 9404 */ 9405 9406 9407 9408 9409 9410 function useBlockControlsFill(group, shareWithChildBlocks) { 9411 const isDisplayed = useDisplayBlockControls(); 9412 const { 9413 clientId 9414 } = useBlockEditContext(); 9415 const isParentDisplayed = (0,external_wp_data_namespaceObject.useSelect)(select => { 9416 const { 9417 getBlockName, 9418 hasSelectedInnerBlock 9419 } = select(store); 9420 const { 9421 hasBlockSupport 9422 } = select(external_wp_blocks_namespaceObject.store); 9423 return shareWithChildBlocks && hasBlockSupport(getBlockName(clientId), '__experimentalExposeControlsToChildren', false) && hasSelectedInnerBlock(clientId); 9424 }, [shareWithChildBlocks, clientId]); 9425 9426 if (isDisplayed) { 9427 var _groups$group; 9428 9429 return (_groups$group = block_controls_groups[group]) === null || _groups$group === void 0 ? void 0 : _groups$group.Fill; 9430 } 9431 9432 if (isParentDisplayed) { 9433 return block_controls_groups.parent.Fill; 9434 } 9435 9436 return null; 9437 } 9438 9439 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/fill.js 9440 9441 9442 /** 9443 * External dependencies 9444 */ 9445 9446 /** 9447 * WordPress dependencies 9448 */ 9449 9450 9451 /** 9452 * Internal dependencies 9453 */ 9454 9455 9456 function BlockControlsFill(_ref) { 9457 let { 9458 group = 'default', 9459 controls, 9460 children, 9461 __experimentalShareWithChildBlocks = false 9462 } = _ref; 9463 const Fill = useBlockControlsFill(group, __experimentalShareWithChildBlocks); 9464 9465 if (!Fill) { 9466 return null; 9467 } 9468 9469 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, { 9470 document: document 9471 }, (0,external_wp_element_namespaceObject.createElement)(Fill, null, fillProps => { 9472 // Children passed to BlockControlsFill will not have access to any 9473 // React Context whose Provider is part of the BlockControlsSlot tree. 9474 // So we re-create the Provider in this subtree. 9475 const value = !(0,external_lodash_namespaceObject.isEmpty)(fillProps) ? fillProps : null; 9476 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolbarContext.Provider, { 9477 value: value 9478 }, group === 'default' && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, { 9479 controls: controls 9480 }), children); 9481 })); 9482 } 9483 9484 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/slot.js 9485 9486 9487 9488 /** 9489 * WordPress dependencies 9490 */ 9491 9492 9493 /** 9494 * Internal dependencies 9495 */ 9496 9497 9498 function BlockControlsSlot(_ref) { 9499 let { 9500 group = 'default', 9501 ...props 9502 } = _ref; 9503 const accessibleToolbarState = (0,external_wp_element_namespaceObject.useContext)(external_wp_components_namespaceObject.__experimentalToolbarContext); 9504 const Slot = block_controls_groups[group].Slot; 9505 const slot = (0,external_wp_components_namespaceObject.__experimentalUseSlot)(Slot.__unstableName); 9506 const hasFills = Boolean(slot.fills && slot.fills.length); 9507 9508 if (!hasFills) { 9509 return null; 9510 } 9511 9512 if (group === 'default') { 9513 return (0,external_wp_element_namespaceObject.createElement)(Slot, _extends({}, props, { 9514 bubblesVirtually: true, 9515 fillProps: accessibleToolbarState 9516 })); 9517 } 9518 9519 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(Slot, _extends({}, props, { 9520 bubblesVirtually: true, 9521 fillProps: accessibleToolbarState 9522 }))); 9523 } 9524 9525 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/index.js 9526 9527 9528 9529 /** 9530 * Internal dependencies 9531 */ 9532 9533 9534 const BlockControls = BlockControlsFill; 9535 BlockControls.Slot = BlockControlsSlot; // This is just here for backward compatibility. 9536 9537 const BlockFormatControls = props => { 9538 return (0,external_wp_element_namespaceObject.createElement)(BlockControlsFill, _extends({ 9539 group: "inline" 9540 }, props)); 9541 }; 9542 9543 BlockFormatControls.Slot = props => { 9544 return (0,external_wp_element_namespaceObject.createElement)(BlockControlsSlot, _extends({ 9545 group: "inline" 9546 }, props)); 9547 }; 9548 9549 /* harmony default export */ var block_controls = (BlockControls); 9550 9551 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/align-none.js 9552 9553 9554 /** 9555 * WordPress dependencies 9556 */ 9557 9558 const alignNone = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 9559 xmlns: "http://www.w3.org/2000/svg", 9560 viewBox: "0 0 24 24" 9561 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 9562 d: "M5 15h14V9H5v6zm0 4.8h14v-1.5H5v1.5zM5 4.2v1.5h14V4.2H5z" 9563 })); 9564 /* harmony default export */ var align_none = (alignNone); 9565 9566 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/position-left.js 9567 9568 9569 /** 9570 * WordPress dependencies 9571 */ 9572 9573 const positionLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 9574 xmlns: "http://www.w3.org/2000/svg", 9575 viewBox: "0 0 24 24" 9576 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 9577 d: "M4 9v6h14V9H4zm8-4.8H4v1.5h8V4.2zM4 19.8h8v-1.5H4v1.5z" 9578 })); 9579 /* harmony default export */ var position_left = (positionLeft); 9580 9581 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/position-center.js 9582 9583 9584 /** 9585 * WordPress dependencies 9586 */ 9587 9588 const positionCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 9589 xmlns: "http://www.w3.org/2000/svg", 9590 viewBox: "0 0 24 24" 9591 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 9592 d: "M7 9v6h10V9H7zM5 19.8h14v-1.5H5v1.5zM5 4.3v1.5h14V4.3H5z" 9593 })); 9594 /* harmony default export */ var position_center = (positionCenter); 9595 9596 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/position-right.js 9597 9598 9599 /** 9600 * WordPress dependencies 9601 */ 9602 9603 const positionRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 9604 xmlns: "http://www.w3.org/2000/svg", 9605 viewBox: "0 0 24 24" 9606 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 9607 d: "M6 15h14V9H6v6zm6-10.8v1.5h8V4.2h-8zm0 15.6h8v-1.5h-8v1.5z" 9608 })); 9609 /* harmony default export */ var position_right = (positionRight); 9610 9611 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/stretch-wide.js 9612 9613 9614 /** 9615 * WordPress dependencies 9616 */ 9617 9618 const stretchWide = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 9619 xmlns: "http://www.w3.org/2000/svg", 9620 viewBox: "0 0 24 24" 9621 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 9622 d: "M5 9v6h14V9H5zm11-4.8H8v1.5h8V4.2zM8 19.8h8v-1.5H8v1.5z" 9623 })); 9624 /* harmony default export */ var stretch_wide = (stretchWide); 9625 9626 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/stretch-full-width.js 9627 9628 9629 /** 9630 * WordPress dependencies 9631 */ 9632 9633 const stretchFullWidth = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 9634 xmlns: "http://www.w3.org/2000/svg", 9635 viewBox: "0 0 24 24" 9636 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 9637 d: "M5 4v11h14V4H5zm3 15.8h8v-1.5H8v1.5z" 9638 })); 9639 /* harmony default export */ var stretch_full_width = (stretchFullWidth); 9640 9641 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-left.js 9642 9643 9644 /** 9645 * WordPress dependencies 9646 */ 9647 9648 const justifyLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 9649 xmlns: "http://www.w3.org/2000/svg", 9650 viewBox: "0 0 24 24" 9651 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 9652 d: "M9 9v6h11V9H9zM4 20h1.5V4H4v16z" 9653 })); 9654 /* harmony default export */ var justify_left = (justifyLeft); 9655 9656 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-center.js 9657 9658 9659 /** 9660 * WordPress dependencies 9661 */ 9662 9663 const justifyCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 9664 xmlns: "http://www.w3.org/2000/svg", 9665 viewBox: "0 0 24 24" 9666 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 9667 d: "M20 9h-7.2V4h-1.6v5H4v6h7.2v5h1.6v-5H20z" 9668 })); 9669 /* harmony default export */ var justify_center = (justifyCenter); 9670 9671 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-right.js 9672 9673 9674 /** 9675 * WordPress dependencies 9676 */ 9677 9678 const justifyRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 9679 xmlns: "http://www.w3.org/2000/svg", 9680 viewBox: "0 0 24 24" 9681 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 9682 d: "M4 15h11V9H4v6zM18.5 4v16H20V4h-1.5z" 9683 })); 9684 /* harmony default export */ var justify_right = (justifyRight); 9685 9686 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-space-between.js 9687 9688 9689 /** 9690 * WordPress dependencies 9691 */ 9692 9693 const justifySpaceBetween = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 9694 xmlns: "http://www.w3.org/2000/svg", 9695 viewBox: "0 0 24 24" 9696 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 9697 d: "M9 15h6V9H9v6zm-5 5h1.5V4H4v16zM18.5 4v16H20V4h-1.5z" 9698 })); 9699 /* harmony default export */ var justify_space_between = (justifySpaceBetween); 9700 9701 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/arrow-right.js 9702 9703 9704 /** 9705 * WordPress dependencies 9706 */ 9707 9708 const arrowRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 9709 xmlns: "http://www.w3.org/2000/svg", 9710 viewBox: "0 0 24 24" 9711 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 9712 d: "M14.3 6.7l-1.1 1.1 4 4H4v1.5h13.3l-4.1 4.4 1.1 1.1 5.8-6.3z" 9713 })); 9714 /* harmony default export */ var arrow_right = (arrowRight); 9715 9716 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/arrow-down.js 9717 9718 9719 /** 9720 * WordPress dependencies 9721 */ 9722 9723 const arrowDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 9724 xmlns: "http://www.w3.org/2000/svg", 9725 viewBox: "0 0 24 24" 9726 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 9727 d: "M16.2 13.2l-4 4V4h-1.5v13.3l-4.5-4.1-1 1.1 6.2 5.8 5.8-5.8-1-1.1z" 9728 })); 9729 /* harmony default export */ var arrow_down = (arrowDown); 9730 9731 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/layouts/utils.js 9732 /** 9733 * Utility to generate the proper CSS selector for layout styles. 9734 * 9735 * @param {string|string[]} selectors - CSS selectors 9736 * @param {boolean} append - string to append. 9737 * 9738 * @return {string} - CSS selector. 9739 */ 9740 function appendSelectors(selectors) { 9741 let append = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 9742 // Ideally we shouldn't need the `.editor-styles-wrapper` increased specificity here 9743 // The problem though is that we have a `.editor-styles-wrapper p { margin: reset; }` style 9744 // it's used to reset the default margin added by wp-admin to paragraphs 9745 // so we need this to be higher speficity otherwise, it won't be applied to paragraphs inside containers 9746 // When the post editor is fully iframed, this extra classname could be removed. 9747 return selectors.split(',').map(subselector => `.editor-styles-wrapper $subselector} $append}`).join(','); 9748 } 9749 9750 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/block-refs-provider.js 9751 9752 9753 /** 9754 * WordPress dependencies 9755 */ 9756 9757 const BlockRefs = (0,external_wp_element_namespaceObject.createContext)({ 9758 refs: new Map(), 9759 callbacks: new Map() 9760 }); 9761 function BlockRefsProvider(_ref) { 9762 let { 9763 children 9764 } = _ref; 9765 const value = (0,external_wp_element_namespaceObject.useMemo)(() => ({ 9766 refs: new Map(), 9767 callbacks: new Map() 9768 }), []); 9769 return (0,external_wp_element_namespaceObject.createElement)(BlockRefs.Provider, { 9770 value: value 9771 }, children); 9772 } 9773 9774 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-refs.js 9775 /** 9776 * WordPress dependencies 9777 */ 9778 9779 9780 /** 9781 * Internal dependencies 9782 */ 9783 9784 9785 /** @typedef {import('@wordpress/element').RefCallback} RefCallback */ 9786 9787 /** @typedef {import('@wordpress/element').RefObject} RefObject */ 9788 9789 /** 9790 * Provides a ref to the BlockRefs context. 9791 * 9792 * @param {string} clientId The client ID of the element ref. 9793 * 9794 * @return {RefCallback} Ref callback. 9795 */ 9796 9797 function useBlockRefProvider(clientId) { 9798 const { 9799 refs, 9800 callbacks 9801 } = (0,external_wp_element_namespaceObject.useContext)(BlockRefs); 9802 const ref = (0,external_wp_element_namespaceObject.useRef)(); 9803 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 9804 refs.set(ref, clientId); 9805 return () => { 9806 refs.delete(ref); 9807 }; 9808 }, [clientId]); 9809 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => { 9810 // Update the ref in the provider. 9811 ref.current = element; // Call any update functions. 9812 9813 callbacks.forEach((id, setElement) => { 9814 if (clientId === id) { 9815 setElement(element); 9816 } 9817 }); 9818 }, [clientId]); 9819 } 9820 /** 9821 * Gets a ref pointing to the current block element. Continues to return a 9822 * stable ref even if the block client ID changes. 9823 * 9824 * @param {string} clientId The client ID to get a ref for. 9825 * 9826 * @return {RefObject} A ref containing the element. 9827 */ 9828 9829 function useBlockRef(clientId) { 9830 const { 9831 refs 9832 } = (0,external_wp_element_namespaceObject.useContext)(BlockRefs); 9833 const freshClientId = (0,external_wp_element_namespaceObject.useRef)(); 9834 freshClientId.current = clientId; // Always return an object, even if no ref exists for a given client ID, so 9835 // that `current` works at a later point. 9836 9837 return (0,external_wp_element_namespaceObject.useMemo)(() => ({ 9838 get current() { 9839 let element = null; // Multiple refs may be created for a single block. Find the 9840 // first that has an element set. 9841 9842 for (const [ref, id] of refs.entries()) { 9843 if (id === freshClientId.current && ref.current) { 9844 element = ref.current; 9845 } 9846 } 9847 9848 return element; 9849 } 9850 9851 }), []); 9852 } 9853 /** 9854 * Return the element for a given client ID. Updates whenever the element 9855 * changes, becomes available, or disappears. 9856 * 9857 * @param {string} clientId The client ID to an element for. 9858 * 9859 * @return {Element|null} The block's wrapper element. 9860 */ 9861 9862 9863 function useBlockElement(clientId) { 9864 const { 9865 callbacks 9866 } = (0,external_wp_element_namespaceObject.useContext)(BlockRefs); 9867 const ref = useBlockRef(clientId); 9868 const [element, setElement] = (0,external_wp_element_namespaceObject.useState)(null); 9869 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 9870 if (!clientId) { 9871 return; 9872 } 9873 9874 callbacks.set(setElement, clientId); 9875 return () => { 9876 callbacks.delete(setElement); 9877 }; 9878 }, [clientId]); 9879 return ref.current || element; 9880 } 9881 9882 9883 9884 9885 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-setting/index.js 9886 /** 9887 * External dependencies 9888 */ 9889 9890 /** 9891 * WordPress dependencies 9892 */ 9893 9894 9895 9896 /** 9897 * Internal dependencies 9898 */ 9899 9900 9901 9902 const blockedPaths = ['color', 'border', 'typography', 'spacing']; 9903 const deprecatedFlags = { 9904 'color.palette': settings => settings.colors === undefined ? undefined : settings.colors, 9905 'color.gradients': settings => settings.gradients === undefined ? undefined : settings.gradients, 9906 'color.custom': settings => settings.disableCustomColors === undefined ? undefined : !settings.disableCustomColors, 9907 'color.customGradient': settings => settings.disableCustomGradients === undefined ? undefined : !settings.disableCustomGradients, 9908 'typography.fontSizes': settings => settings.fontSizes === undefined ? undefined : settings.fontSizes, 9909 'typography.customFontSize': settings => settings.disableCustomFontSizes === undefined ? undefined : !settings.disableCustomFontSizes, 9910 'typography.lineHeight': settings => settings.enableCustomLineHeight, 9911 'spacing.units': settings => { 9912 if (settings.enableCustomUnits === undefined) { 9913 return; 9914 } 9915 9916 if (settings.enableCustomUnits === true) { 9917 return ['px', 'em', 'rem', 'vh', 'vw', '%']; 9918 } 9919 9920 return settings.enableCustomUnits; 9921 }, 9922 'spacing.padding': settings => settings.enableCustomSpacing 9923 }; 9924 const prefixedFlags = { 9925 /* 9926 * These were only available in the plugin 9927 * and can be removed when the minimum WordPress version 9928 * for the plugin is 5.9. 9929 */ 9930 'border.customColor': 'border.color', 9931 'border.customStyle': 'border.style', 9932 'border.customWidth': 'border.width', 9933 'typography.customFontStyle': 'typography.fontStyle', 9934 'typography.customFontWeight': 'typography.fontWeight', 9935 'typography.customLetterSpacing': 'typography.letterSpacing', 9936 'typography.customTextDecorations': 'typography.textDecoration', 9937 'typography.customTextTransforms': 'typography.textTransform', 9938 9939 /* 9940 * These were part of WordPress 5.8 and we need to keep them. 9941 */ 9942 'border.customRadius': 'border.radius', 9943 'spacing.customMargin': 'spacing.margin', 9944 'spacing.customPadding': 'spacing.padding', 9945 'typography.customLineHeight': 'typography.lineHeight' 9946 }; 9947 /** 9948 * Remove `custom` prefixes for flags that did not land in 5.8. 9949 * 9950 * This provides continued support for `custom` prefixed properties. It will 9951 * be removed once third party devs have had sufficient time to update themes, 9952 * plugins, etc. 9953 * 9954 * @see https://github.com/WordPress/gutenberg/pull/34485 9955 * 9956 * @param {string} path Path to desired value in settings. 9957 * @return {string} The value for defined setting. 9958 */ 9959 9960 const removeCustomPrefixes = path => { 9961 return prefixedFlags[path] || path; 9962 }; 9963 /** 9964 * Hook that retrieves the editor setting. 9965 * It works with nested objects using by finding the value at path. 9966 * 9967 * @param {string} path The path to the setting. 9968 * @return {any} Returns the value defined for the setting. 9969 * @example 9970 * ```js 9971 * const isEnabled = useSetting( 'typography.dropCap' ); 9972 * ``` 9973 */ 9974 9975 9976 function useSetting(path) { 9977 const { 9978 name: blockName 9979 } = useBlockEditContext(); 9980 const setting = (0,external_wp_data_namespaceObject.useSelect)(select => { 9981 var _get; 9982 9983 if (blockedPaths.includes(path)) { 9984 // eslint-disable-next-line no-console 9985 console.warn('Top level useSetting paths are disabled. Please use a subpath to query the information needed.'); 9986 return undefined; 9987 } 9988 9989 const settings = select(store).getSettings(); // 1 - Use __experimental features, if available. 9990 // We cascade to the all value if the block one is not available. 9991 9992 const normalizedPath = removeCustomPrefixes(path); 9993 const defaultsPath = `__experimentalFeatures.$normalizedPath}`; 9994 const blockPath = `__experimentalFeatures.blocks.$blockName}.$normalizedPath}`; 9995 const experimentalFeaturesResult = (_get = (0,external_lodash_namespaceObject.get)(settings, blockPath)) !== null && _get !== void 0 ? _get : (0,external_lodash_namespaceObject.get)(settings, defaultsPath); 9996 9997 if (experimentalFeaturesResult !== undefined) { 9998 if (external_wp_blocks_namespaceObject.__EXPERIMENTAL_PATHS_WITH_MERGE[normalizedPath]) { 9999 var _ref, _experimentalFeatures; 10000 10001 return (_ref = (_experimentalFeatures = experimentalFeaturesResult.custom) !== null && _experimentalFeatures !== void 0 ? _experimentalFeatures : experimentalFeaturesResult.theme) !== null && _ref !== void 0 ? _ref : experimentalFeaturesResult.default; 10002 } 10003 10004 return experimentalFeaturesResult; 10005 } // 2 - Use deprecated settings, otherwise. 10006 10007 10008 const deprecatedSettingsValue = deprecatedFlags[normalizedPath] ? deprecatedFlags[normalizedPath](settings) : undefined; 10009 10010 if (deprecatedSettingsValue !== undefined) { 10011 return deprecatedSettingsValue; 10012 } // 3 - Fall back for typography.dropCap: 10013 // This is only necessary to support typography.dropCap. 10014 // when __experimentalFeatures are not present (core without plugin). 10015 // To remove when __experimentalFeatures are ported to core. 10016 10017 10018 return normalizedPath === 'typography.dropCap' ? true : undefined; 10019 }, [blockName, path]); 10020 return setting; 10021 } 10022 10023 ;// CONCATENATED MODULE: external ["wp","warning"] 10024 var external_wp_warning_namespaceObject = window["wp"]["warning"]; 10025 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/groups.js 10026 /** 10027 * WordPress dependencies 10028 */ 10029 10030 const InspectorControlsDefault = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControls'); 10031 const InspectorControlsAdvanced = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorAdvancedControls'); 10032 const InspectorControlsBorder = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControlsBorder'); 10033 const InspectorControlsColor = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControlsColor'); 10034 const InspectorControlsDimensions = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControlsDimensions'); 10035 const InspectorControlsTypography = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControlsTypography'); 10036 const groups_groups = { 10037 default: InspectorControlsDefault, 10038 advanced: InspectorControlsAdvanced, 10039 border: InspectorControlsBorder, 10040 color: InspectorControlsColor, 10041 dimensions: InspectorControlsDimensions, 10042 typography: InspectorControlsTypography 10043 }; 10044 /* harmony default export */ var inspector_controls_groups = (groups_groups); 10045 10046 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/fill.js 10047 10048 10049 /** 10050 * External dependencies 10051 */ 10052 10053 /** 10054 * WordPress dependencies 10055 */ 10056 10057 10058 10059 /** 10060 * Internal dependencies 10061 */ 10062 10063 10064 10065 function InspectorControlsFill(_ref) { 10066 var _groups$group; 10067 10068 let { 10069 __experimentalGroup: group = 'default', 10070 children 10071 } = _ref; 10072 const isDisplayed = useDisplayBlockControls(); 10073 const Fill = (_groups$group = inspector_controls_groups[group]) === null || _groups$group === void 0 ? void 0 : _groups$group.Fill; 10074 10075 if (!Fill) { 10076 typeof process !== "undefined" && process.env && "production" !== "production" ? 0 : void 0; 10077 return null; 10078 } 10079 10080 if (!isDisplayed) { 10081 return null; 10082 } 10083 10084 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, { 10085 document: document 10086 }, (0,external_wp_element_namespaceObject.createElement)(Fill, null, fillProps => { 10087 // Children passed to InspectorControlsFill will not have 10088 // access to any React Context whose Provider is part of 10089 // the InspectorControlsSlot tree. So we re-create the 10090 // Provider in this subtree. 10091 const value = !(0,external_lodash_namespaceObject.isEmpty)(fillProps) ? fillProps : null; 10092 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelContext.Provider, { 10093 value: value 10094 }, children); 10095 })); 10096 } 10097 10098 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/utils.js 10099 /** 10100 * External dependencies 10101 */ 10102 10103 /** 10104 * WordPress dependencies 10105 */ 10106 10107 10108 /** 10109 * Removed falsy values from nested object. 10110 * 10111 * @param {*} object 10112 * @return {*} Object cleaned from falsy values 10113 */ 10114 10115 const cleanEmptyObject = object => { 10116 if (!(0,external_lodash_namespaceObject.isObject)(object) || Array.isArray(object)) { 10117 return object; 10118 } 10119 10120 const cleanedNestedObjects = (0,external_lodash_namespaceObject.pickBy)((0,external_lodash_namespaceObject.mapValues)(object, cleanEmptyObject), external_lodash_namespaceObject.identity); 10121 return (0,external_lodash_namespaceObject.isEmpty)(cleanedNestedObjects) ? undefined : cleanedNestedObjects; 10122 }; 10123 function immutableSet(object, path, value) { 10124 return (0,external_lodash_namespaceObject.setWith)(object ? (0,external_lodash_namespaceObject.clone)(object) : {}, path, value, external_lodash_namespaceObject.clone); 10125 } 10126 function transformStyles(activeSupports, migrationPaths, result, source, index, results) { 10127 var _source$; 10128 10129 // If there are no active supports return early. 10130 if ((0,external_lodash_namespaceObject.every)(activeSupports, isActive => !isActive)) { 10131 return result; 10132 } // If the condition verifies we are probably in the presence of a wrapping transform 10133 // e.g: nesting paragraphs in a group or columns and in that case the styles should not be transformed. 10134 10135 10136 if (results.length === 1 && result.innerBlocks.length === source.length) { 10137 return result; 10138 } // For cases where we have a transform from one block to multiple blocks 10139 // or multiple blocks to one block we apply the styles of the first source block 10140 // to the result(s). 10141 10142 10143 let referenceBlockAttributes = (_source$ = source[0]) === null || _source$ === void 0 ? void 0 : _source$.attributes; // If we are in presence of transform between more than one block in the source 10144 // that has more than one block in the result 10145 // we apply the styles on source N to the result N, 10146 // if source N does not exists we do nothing. 10147 10148 if (results.length > 1 && source.length > 1) { 10149 if (source[index]) { 10150 var _source$index; 10151 10152 referenceBlockAttributes = (_source$index = source[index]) === null || _source$index === void 0 ? void 0 : _source$index.attributes; 10153 } else { 10154 return result; 10155 } 10156 } 10157 10158 let returnBlock = result; 10159 (0,external_lodash_namespaceObject.forEach)(activeSupports, (isActive, support) => { 10160 if (isActive) { 10161 migrationPaths[support].forEach(path => { 10162 const styleValue = (0,external_lodash_namespaceObject.get)(referenceBlockAttributes, path); 10163 10164 if (styleValue) { 10165 returnBlock = { ...returnBlock, 10166 attributes: immutableSet(returnBlock.attributes, path, styleValue) 10167 }; 10168 } 10169 }); 10170 } 10171 }); 10172 return returnBlock; 10173 } 10174 /** 10175 * Check whether serialization of specific block support feature or set should 10176 * be skipped. 10177 * 10178 * @param {string|Object} blockType Block name or block type object. 10179 * @param {string} featureSet Name of block support feature set. 10180 * @param {string} feature Name of the individual feature to check. 10181 * 10182 * @return {boolean} Whether serialization should occur. 10183 */ 10184 10185 function shouldSkipSerialization(blockType, featureSet, feature) { 10186 const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, featureSet); 10187 const skipSerialization = support === null || support === void 0 ? void 0 : support.__experimentalSkipSerialization; 10188 10189 if (Array.isArray(skipSerialization)) { 10190 return skipSerialization.includes(feature); 10191 } 10192 10193 return skipSerialization; 10194 } 10195 10196 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/block-support-tools-panel.js 10197 10198 10199 /** 10200 * WordPress dependencies 10201 */ 10202 10203 10204 10205 /** 10206 * Internal dependencies 10207 */ 10208 10209 10210 10211 function BlockSupportToolsPanel(_ref) { 10212 let { 10213 children, 10214 group, 10215 label 10216 } = _ref; 10217 const { 10218 updateBlockAttributes 10219 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 10220 const { 10221 getBlockAttributes, 10222 getMultiSelectedBlockClientIds, 10223 getSelectedBlockClientId, 10224 hasMultiSelection 10225 } = (0,external_wp_data_namespaceObject.useSelect)(store); 10226 const panelId = getSelectedBlockClientId(); 10227 const resetAll = (0,external_wp_element_namespaceObject.useCallback)(function () { 10228 let resetFilters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; 10229 const newAttributes = {}; 10230 const clientIds = hasMultiSelection() ? getMultiSelectedBlockClientIds() : [panelId]; 10231 clientIds.forEach(clientId => { 10232 const { 10233 style 10234 } = getBlockAttributes(clientId); 10235 let newBlockAttributes = { 10236 style 10237 }; 10238 resetFilters.forEach(resetFilter => { 10239 newBlockAttributes = { ...newBlockAttributes, 10240 ...resetFilter(newBlockAttributes) 10241 }; 10242 }); // Enforce a cleaned style object. 10243 10244 newBlockAttributes = { ...newBlockAttributes, 10245 style: cleanEmptyObject(newBlockAttributes.style) 10246 }; 10247 newAttributes[clientId] = newBlockAttributes; 10248 }); 10249 updateBlockAttributes(clientIds, newAttributes, true); 10250 }, [cleanEmptyObject, getBlockAttributes, getMultiSelectedBlockClientIds, hasMultiSelection, panelId, updateBlockAttributes]); 10251 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanel, { 10252 className: `$group}-block-support-panel`, 10253 label: label, 10254 resetAll: resetAll, 10255 key: panelId, 10256 panelId: panelId, 10257 hasInnerWrapper: true, 10258 shouldRenderPlaceholderItems: true // Required to maintain fills ordering. 10259 , 10260 __experimentalFirstVisibleItemClass: "first", 10261 __experimentalLastVisibleItemClass: "last" 10262 }, children); 10263 } 10264 10265 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/block-support-slot-container.js 10266 10267 10268 10269 /** 10270 * WordPress dependencies 10271 */ 10272 10273 10274 function BlockSupportSlotContainer(_ref) { 10275 let { 10276 Slot, 10277 ...props 10278 } = _ref; 10279 const toolsPanelContext = (0,external_wp_element_namespaceObject.useContext)(external_wp_components_namespaceObject.__experimentalToolsPanelContext); 10280 return (0,external_wp_element_namespaceObject.createElement)(Slot, _extends({}, props, { 10281 fillProps: toolsPanelContext, 10282 bubblesVirtually: true 10283 })); 10284 } 10285 10286 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/slot.js 10287 10288 10289 10290 /** 10291 * WordPress dependencies 10292 */ 10293 10294 10295 /** 10296 * Internal dependencies 10297 */ 10298 10299 10300 10301 10302 function InspectorControlsSlot(_ref) { 10303 var _groups$group; 10304 10305 let { 10306 __experimentalGroup: group = 'default', 10307 label, 10308 ...props 10309 } = _ref; 10310 const Slot = (_groups$group = inspector_controls_groups[group]) === null || _groups$group === void 0 ? void 0 : _groups$group.Slot; 10311 const slot = (0,external_wp_components_namespaceObject.__experimentalUseSlot)(Slot === null || Slot === void 0 ? void 0 : Slot.__unstableName); 10312 10313 if (!Slot || !slot) { 10314 typeof process !== "undefined" && process.env && "production" !== "production" ? 0 : void 0; 10315 return null; 10316 } 10317 10318 const hasFills = Boolean(slot.fills && slot.fills.length); 10319 10320 if (!hasFills) { 10321 return null; 10322 } 10323 10324 if (label) { 10325 return (0,external_wp_element_namespaceObject.createElement)(BlockSupportToolsPanel, { 10326 group: group, 10327 label: label 10328 }, (0,external_wp_element_namespaceObject.createElement)(BlockSupportSlotContainer, _extends({}, props, { 10329 Slot: Slot 10330 }))); 10331 } 10332 10333 return (0,external_wp_element_namespaceObject.createElement)(Slot, _extends({}, props, { 10334 bubblesVirtually: true 10335 })); 10336 } 10337 10338 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/index.js 10339 10340 10341 10342 /** 10343 * Internal dependencies 10344 */ 10345 10346 10347 const InspectorControls = InspectorControlsFill; 10348 InspectorControls.Slot = InspectorControlsSlot; // This is just here for backward compatibility. 10349 10350 const InspectorAdvancedControls = props => { 10351 return (0,external_wp_element_namespaceObject.createElement)(InspectorControlsFill, _extends({}, props, { 10352 __experimentalGroup: "advanced" 10353 })); 10354 }; 10355 10356 InspectorAdvancedControls.Slot = props => { 10357 return (0,external_wp_element_namespaceObject.createElement)(InspectorControlsSlot, _extends({}, props, { 10358 __experimentalGroup: "advanced" 10359 })); 10360 }; 10361 10362 InspectorAdvancedControls.slotName = 'InspectorAdvancedControls'; 10363 /** 10364 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inspector-controls/README.md 10365 */ 10366 10367 /* harmony default export */ var inspector_controls = (InspectorControls); 10368 10369 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/margin.js 10370 10371 10372 /** 10373 * WordPress dependencies 10374 */ 10375 10376 10377 10378 10379 /** 10380 * Internal dependencies 10381 */ 10382 10383 10384 10385 10386 /** 10387 * Determines if there is margin support. 10388 * 10389 * @param {string|Object} blockType Block name or Block Type object. 10390 * 10391 * @return {boolean} Whether there is support. 10392 */ 10393 10394 function hasMarginSupport(blockType) { 10395 const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, SPACING_SUPPORT_KEY); 10396 return !!(true === support || support !== null && support !== void 0 && support.margin); 10397 } 10398 /** 10399 * Checks if there is a current value in the margin block support attributes. 10400 * 10401 * @param {Object} props Block props. 10402 * @return {boolean} Whether or not the block has a margin value set. 10403 */ 10404 10405 function hasMarginValue(props) { 10406 var _props$attributes$sty, _props$attributes$sty2; 10407 10408 return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.spacing) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.margin) !== undefined; 10409 } 10410 /** 10411 * Resets the margin block support attributes. This can be used when disabling 10412 * the margin support controls for a block via a `ToolsPanel`. 10413 * 10414 * @param {Object} props Block props. 10415 * @param {Object} props.attributes Block's attributes. 10416 * @param {Object} props.setAttributes Function to set block's attributes. 10417 */ 10418 10419 function resetMargin(_ref) { 10420 let { 10421 attributes = {}, 10422 setAttributes 10423 } = _ref; 10424 const { 10425 style 10426 } = attributes; 10427 setAttributes({ 10428 style: cleanEmptyObject({ ...style, 10429 spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing), 10430 margin: undefined 10431 } 10432 }) 10433 }); 10434 } 10435 /** 10436 * Custom hook that checks if margin settings have been disabled. 10437 * 10438 * @param {string} name The name of the block. 10439 * 10440 * @return {boolean} Whether margin setting is disabled. 10441 */ 10442 10443 function useIsMarginDisabled() { 10444 let { 10445 name: blockName 10446 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 10447 const isDisabled = !useSetting('spacing.margin'); 10448 const isInvalid = !useIsDimensionsSupportValid(blockName, 'margin'); 10449 return !hasMarginSupport(blockName) || isDisabled || isInvalid; 10450 } 10451 /** 10452 * Inspector control panel containing the margin related configuration 10453 * 10454 * @param {Object} props Block props. 10455 * 10456 * @return {WPElement} Margin edit element. 10457 */ 10458 10459 function MarginEdit(props) { 10460 var _style$spacing; 10461 10462 const { 10463 name: blockName, 10464 attributes: { 10465 style 10466 }, 10467 setAttributes 10468 } = props; 10469 const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({ 10470 availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw'] 10471 }); 10472 const sides = useCustomSides(blockName, 'margin'); 10473 const splitOnAxis = sides && sides.some(side => AXIAL_SIDES.includes(side)); 10474 10475 if (useIsMarginDisabled(props)) { 10476 return null; 10477 } 10478 10479 const onChange = next => { 10480 const newStyle = { ...style, 10481 spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing), 10482 margin: next 10483 } 10484 }; 10485 setAttributes({ 10486 style: cleanEmptyObject(newStyle) 10487 }); 10488 }; 10489 10490 const onChangeShowVisualizer = next => { 10491 const newStyle = { ...style, 10492 visualizers: { 10493 margin: next 10494 } 10495 }; 10496 setAttributes({ 10497 style: cleanEmptyObject(newStyle) 10498 }); 10499 }; 10500 10501 return external_wp_element_namespaceObject.Platform.select({ 10502 web: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, { 10503 values: style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.margin, 10504 onChange: onChange, 10505 onChangeShowVisualizer: onChangeShowVisualizer, 10506 label: (0,external_wp_i18n_namespaceObject.__)('Margin'), 10507 sides: sides, 10508 units: units, 10509 allowReset: false, 10510 splitOnAxis: splitOnAxis 10511 })), 10512 native: null 10513 }); 10514 } 10515 10516 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/padding.js 10517 10518 10519 /** 10520 * WordPress dependencies 10521 */ 10522 10523 10524 10525 10526 /** 10527 * Internal dependencies 10528 */ 10529 10530 10531 10532 10533 /** 10534 * Determines if there is padding support. 10535 * 10536 * @param {string|Object} blockType Block name or Block Type object. 10537 * 10538 * @return {boolean} Whether there is support. 10539 */ 10540 10541 function hasPaddingSupport(blockType) { 10542 const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, SPACING_SUPPORT_KEY); 10543 return !!(true === support || support !== null && support !== void 0 && support.padding); 10544 } 10545 /** 10546 * Checks if there is a current value in the padding block support attributes. 10547 * 10548 * @param {Object} props Block props. 10549 * @return {boolean} Whether or not the block has a padding value set. 10550 */ 10551 10552 function hasPaddingValue(props) { 10553 var _props$attributes$sty, _props$attributes$sty2; 10554 10555 return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.spacing) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.padding) !== undefined; 10556 } 10557 /** 10558 * Resets the padding block support attributes. This can be used when disabling 10559 * the padding support controls for a block via a `ToolsPanel`. 10560 * 10561 * @param {Object} props Block props. 10562 * @param {Object} props.attributes Block's attributes. 10563 * @param {Object} props.setAttributes Function to set block's attributes. 10564 */ 10565 10566 function resetPadding(_ref) { 10567 let { 10568 attributes = {}, 10569 setAttributes 10570 } = _ref; 10571 const { 10572 style 10573 } = attributes; 10574 setAttributes({ 10575 style: cleanEmptyObject({ ...style, 10576 spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing), 10577 padding: undefined 10578 } 10579 }) 10580 }); 10581 } 10582 /** 10583 * Custom hook that checks if padding settings have been disabled. 10584 * 10585 * @param {string} name The name of the block. 10586 * 10587 * @return {boolean} Whether padding setting is disabled. 10588 */ 10589 10590 function useIsPaddingDisabled() { 10591 let { 10592 name: blockName 10593 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 10594 const isDisabled = !useSetting('spacing.padding'); 10595 const isInvalid = !useIsDimensionsSupportValid(blockName, 'padding'); 10596 return !hasPaddingSupport(blockName) || isDisabled || isInvalid; 10597 } 10598 /** 10599 * Inspector control panel containing the padding related configuration 10600 * 10601 * @param {Object} props 10602 * 10603 * @return {WPElement} Padding edit element. 10604 */ 10605 10606 function PaddingEdit(props) { 10607 var _style$spacing; 10608 10609 const { 10610 name: blockName, 10611 attributes: { 10612 style 10613 }, 10614 setAttributes 10615 } = props; 10616 const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({ 10617 availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw'] 10618 }); 10619 const sides = useCustomSides(blockName, 'padding'); 10620 const splitOnAxis = sides && sides.some(side => AXIAL_SIDES.includes(side)); 10621 10622 if (useIsPaddingDisabled(props)) { 10623 return null; 10624 } 10625 10626 const onChange = next => { 10627 const newStyle = { ...style, 10628 spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing), 10629 padding: next 10630 } 10631 }; 10632 setAttributes({ 10633 style: cleanEmptyObject(newStyle) 10634 }); 10635 }; 10636 10637 const onChangeShowVisualizer = next => { 10638 const newStyle = { ...style, 10639 visualizers: { 10640 padding: next 10641 } 10642 }; 10643 setAttributes({ 10644 style: cleanEmptyObject(newStyle) 10645 }); 10646 }; 10647 10648 return external_wp_element_namespaceObject.Platform.select({ 10649 web: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, { 10650 values: style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.padding, 10651 onChange: onChange, 10652 onChangeShowVisualizer: onChangeShowVisualizer, 10653 label: (0,external_wp_i18n_namespaceObject.__)('Padding'), 10654 sides: sides, 10655 units: units, 10656 allowReset: false, 10657 splitOnAxis: splitOnAxis 10658 })), 10659 native: null 10660 }); 10661 } 10662 10663 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/dimensions.js 10664 10665 10666 /** 10667 * WordPress dependencies 10668 */ 10669 10670 10671 10672 10673 /** 10674 * Internal dependencies 10675 */ 10676 10677 10678 10679 10680 10681 const SPACING_SUPPORT_KEY = 'spacing'; 10682 const ALL_SIDES = ['top', 'right', 'bottom', 'left']; 10683 const AXIAL_SIDES = ['vertical', 'horizontal']; 10684 /** 10685 * Inspector controls for dimensions support. 10686 * 10687 * @param {Object} props Block props. 10688 * 10689 * @return {WPElement} Inspector controls for spacing support features. 10690 */ 10691 10692 function DimensionsPanel(props) { 10693 const isGapDisabled = useIsGapDisabled(props); 10694 const isPaddingDisabled = useIsPaddingDisabled(props); 10695 const isMarginDisabled = useIsMarginDisabled(props); 10696 const isDisabled = useIsDimensionsDisabled(props); 10697 const isSupported = hasDimensionsSupport(props.name); 10698 10699 if (isDisabled || !isSupported) { 10700 return null; 10701 } 10702 10703 const defaultSpacingControls = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, [SPACING_SUPPORT_KEY, '__experimentalDefaultControls']); 10704 10705 const createResetAllFilter = attribute => newAttributes => { 10706 var _newAttributes$style; 10707 10708 return { ...newAttributes, 10709 style: { ...newAttributes.style, 10710 spacing: { ...((_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : _newAttributes$style.spacing), 10711 [attribute]: undefined 10712 } 10713 } 10714 }; 10715 }; 10716 10717 return (0,external_wp_element_namespaceObject.createElement)(inspector_controls, { 10718 __experimentalGroup: "dimensions" 10719 }, !isPaddingDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, { 10720 hasValue: () => hasPaddingValue(props), 10721 label: (0,external_wp_i18n_namespaceObject.__)('Padding'), 10722 onDeselect: () => resetPadding(props), 10723 resetAllFilter: createResetAllFilter('padding'), 10724 isShownByDefault: defaultSpacingControls === null || defaultSpacingControls === void 0 ? void 0 : defaultSpacingControls.padding, 10725 panelId: props.clientId 10726 }, (0,external_wp_element_namespaceObject.createElement)(PaddingEdit, props)), !isMarginDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, { 10727 hasValue: () => hasMarginValue(props), 10728 label: (0,external_wp_i18n_namespaceObject.__)('Margin'), 10729 onDeselect: () => resetMargin(props), 10730 resetAllFilter: createResetAllFilter('margin'), 10731 isShownByDefault: defaultSpacingControls === null || defaultSpacingControls === void 0 ? void 0 : defaultSpacingControls.margin, 10732 panelId: props.clientId 10733 }, (0,external_wp_element_namespaceObject.createElement)(MarginEdit, props)), !isGapDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, { 10734 hasValue: () => hasGapValue(props), 10735 label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'), 10736 onDeselect: () => resetGap(props), 10737 resetAllFilter: createResetAllFilter('blockGap'), 10738 isShownByDefault: defaultSpacingControls === null || defaultSpacingControls === void 0 ? void 0 : defaultSpacingControls.blockGap, 10739 panelId: props.clientId 10740 }, (0,external_wp_element_namespaceObject.createElement)(GapEdit, props))); 10741 } 10742 /** 10743 * Determine whether there is dimensions related block support. 10744 * 10745 * @param {string} blockName Block name. 10746 * 10747 * @return {boolean} Whether there is support. 10748 */ 10749 10750 function hasDimensionsSupport(blockName) { 10751 if (external_wp_element_namespaceObject.Platform.OS !== 'web') { 10752 return false; 10753 } 10754 10755 return hasGapSupport(blockName) || hasPaddingSupport(blockName) || hasMarginSupport(blockName); 10756 } 10757 /** 10758 * Determines whether dimensions support has been disabled. 10759 * 10760 * @param {Object} props Block properties. 10761 * 10762 * @return {boolean} If spacing support is completely disabled. 10763 */ 10764 10765 const useIsDimensionsDisabled = function () { 10766 let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 10767 const gapDisabled = useIsGapDisabled(props); 10768 const paddingDisabled = useIsPaddingDisabled(props); 10769 const marginDisabled = useIsMarginDisabled(props); 10770 return gapDisabled && paddingDisabled && marginDisabled; 10771 }; 10772 /** 10773 * Custom hook to retrieve which padding/margin is supported 10774 * e.g. top, right, bottom or left. 10775 * 10776 * Sides are opted into by default. It is only if a specific side is set to 10777 * false that it is omitted. 10778 * 10779 * @param {string} blockName Block name. 10780 * @param {string} feature The feature custom sides relate to e.g. padding or margins. 10781 * 10782 * @return {Object} Sides supporting custom margin. 10783 */ 10784 10785 10786 function useCustomSides(blockName, feature) { 10787 const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, SPACING_SUPPORT_KEY); // Skip when setting is boolean as theme isn't setting arbitrary sides. 10788 10789 if (!support || typeof support[feature] === 'boolean') { 10790 return; 10791 } 10792 10793 return support[feature]; 10794 } 10795 /** 10796 * Custom hook to determine whether the sides configured in the 10797 * block support are valid. A dimension property cannot declare 10798 * support for a mix of axial and individual sides. 10799 * 10800 * @param {string} blockName Block name. 10801 * @param {string} feature The feature custom sides relate to e.g. padding or margins. 10802 * 10803 * @return {boolean} If the feature has a valid configuration of sides. 10804 */ 10805 10806 function useIsDimensionsSupportValid(blockName, feature) { 10807 const sides = useCustomSides(blockName, feature); 10808 10809 if (sides && sides.some(side => ALL_SIDES.includes(side)) && sides.some(side => AXIAL_SIDES.includes(side))) { 10810 // eslint-disable-next-line no-console 10811 console.warn(`The $feature} support for the "$blockName}" block can not be configured to support both axial and arbitrary sides.`); 10812 return false; 10813 } 10814 10815 return true; 10816 } 10817 10818 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/gap.js 10819 10820 10821 /** 10822 * WordPress dependencies 10823 */ 10824 10825 10826 10827 10828 /** 10829 * Internal dependencies 10830 */ 10831 10832 10833 10834 10835 10836 /** 10837 * Determines if there is gap support. 10838 * 10839 * @param {string|Object} blockType Block name or Block Type object. 10840 * @return {boolean} Whether there is support. 10841 */ 10842 10843 function hasGapSupport(blockType) { 10844 const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, SPACING_SUPPORT_KEY); 10845 return !!(true === support || support !== null && support !== void 0 && support.blockGap); 10846 } 10847 /** 10848 * Checks if there is a current value in the gap block support attributes. 10849 * 10850 * @param {Object} props Block props. 10851 * @return {boolean} Whether or not the block has a gap value set. 10852 */ 10853 10854 function hasGapValue(props) { 10855 var _props$attributes$sty, _props$attributes$sty2; 10856 10857 return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.spacing) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.blockGap) !== undefined; 10858 } 10859 /** 10860 * Returns a BoxControl object value from a given blockGap style value. 10861 * The string check is for backwards compatibility before Gutenberg supported 10862 * split gap values (row and column) and the value was a string n + unit. 10863 * 10864 * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}. 10865 * @return {Object|null} A value to pass to the BoxControl component. 10866 */ 10867 10868 function getGapBoxControlValueFromStyle(blockGapValue) { 10869 if (!blockGapValue) { 10870 return null; 10871 } 10872 10873 const isValueString = typeof blockGapValue === 'string'; 10874 return { 10875 top: isValueString ? blockGapValue : blockGapValue === null || blockGapValue === void 0 ? void 0 : blockGapValue.top, 10876 left: isValueString ? blockGapValue : blockGapValue === null || blockGapValue === void 0 ? void 0 : blockGapValue.left 10877 }; 10878 } 10879 /** 10880 * Returns a CSS value for the `gap` property from a given blockGap style. 10881 * 10882 * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}. 10883 * @param {string?} defaultValue A default gap value. 10884 * @return {string|null} The concatenated gap value (row and column). 10885 */ 10886 10887 function getGapCSSValue(blockGapValue) { 10888 let defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0'; 10889 const blockGapBoxControlValue = getGapBoxControlValueFromStyle(blockGapValue); 10890 10891 if (!blockGapBoxControlValue) { 10892 return null; 10893 } 10894 10895 const row = (blockGapBoxControlValue === null || blockGapBoxControlValue === void 0 ? void 0 : blockGapBoxControlValue.top) || defaultValue; 10896 const column = (blockGapBoxControlValue === null || blockGapBoxControlValue === void 0 ? void 0 : blockGapBoxControlValue.left) || defaultValue; 10897 return row === column ? row : `$row} $column}`; 10898 } 10899 /** 10900 * Resets the gap block support attribute. This can be used when disabling 10901 * the gap support controls for a block via a progressive discovery panel. 10902 * 10903 * @param {Object} props Block props. 10904 * @param {Object} props.attributes Block's attributes. 10905 * @param {Object} props.setAttributes Function to set block's attributes. 10906 */ 10907 10908 function resetGap(_ref) { 10909 let { 10910 attributes = {}, 10911 setAttributes 10912 } = _ref; 10913 const { 10914 style 10915 } = attributes; 10916 setAttributes({ 10917 style: { ...style, 10918 spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing), 10919 blockGap: undefined 10920 } 10921 } 10922 }); 10923 } 10924 /** 10925 * Custom hook that checks if gap settings have been disabled. 10926 * 10927 * @param {string} name The name of the block. 10928 * @return {boolean} Whether the gap setting is disabled. 10929 */ 10930 10931 function useIsGapDisabled() { 10932 let { 10933 name: blockName 10934 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 10935 const isDisabled = !useSetting('spacing.blockGap'); 10936 return !hasGapSupport(blockName) || isDisabled; 10937 } 10938 /** 10939 * Inspector control panel containing the gap related configuration 10940 * 10941 * @param {Object} props 10942 * 10943 * @return {WPElement} Gap edit element. 10944 */ 10945 10946 function GapEdit(props) { 10947 var _style$spacing; 10948 10949 const { 10950 clientId, 10951 attributes: { 10952 style 10953 }, 10954 name: blockName, 10955 setAttributes 10956 } = props; 10957 const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({ 10958 availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw'] 10959 }); 10960 const sides = useCustomSides(blockName, 'blockGap'); 10961 const ref = useBlockRef(clientId); 10962 10963 if (useIsGapDisabled(props)) { 10964 return null; 10965 } 10966 10967 const splitOnAxis = sides && sides.some(side => AXIAL_SIDES.includes(side)); 10968 10969 const onChange = next => { 10970 var _window; 10971 10972 let blockGap = next; // If splitOnAxis activated we need to return a BoxControl object to the BoxControl component. 10973 10974 if (!!next && splitOnAxis) { 10975 blockGap = { ...getGapBoxControlValueFromStyle(next) 10976 }; 10977 } 10978 10979 const newStyle = { ...style, 10980 spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing), 10981 blockGap 10982 } 10983 }; 10984 setAttributes({ 10985 style: cleanEmptyObject(newStyle) 10986 }); // In Safari, changing the `gap` CSS value on its own will not trigger the layout 10987 // to be recalculated / re-rendered. To force the updated gap to re-render, here 10988 // we replace the block's node with itself. 10989 10990 const isSafari = ((_window = window) === null || _window === void 0 ? void 0 : _window.navigator.userAgent) && window.navigator.userAgent.includes('Safari') && !window.navigator.userAgent.includes('Chrome ') && !window.navigator.userAgent.includes('Chromium '); 10991 10992 if (ref.current && isSafari) { 10993 var _ref$current$parentNo; 10994 10995 (_ref$current$parentNo = ref.current.parentNode) === null || _ref$current$parentNo === void 0 ? void 0 : _ref$current$parentNo.replaceChild(ref.current, ref.current); 10996 } 10997 }; 10998 10999 const gapValue = getGapBoxControlValueFromStyle(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap); // The BoxControl component expects a full complement of side values. 11000 // Gap row and column values translate to top/bottom and left/right respectively. 11001 11002 const boxControlGapValue = splitOnAxis ? { ...gapValue, 11003 right: gapValue === null || gapValue === void 0 ? void 0 : gapValue.left, 11004 bottom: gapValue === null || gapValue === void 0 ? void 0 : gapValue.top 11005 } : gapValue === null || gapValue === void 0 ? void 0 : gapValue.top; 11006 return external_wp_element_namespaceObject.Platform.select({ 11007 web: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, splitOnAxis ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, { 11008 label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'), 11009 min: 0, 11010 onChange: onChange, 11011 units: units, 11012 sides: sides, 11013 values: boxControlGapValue, 11014 allowReset: false, 11015 splitOnAxis: splitOnAxis 11016 }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, { 11017 label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'), 11018 __unstableInputWidth: "80px", 11019 min: 0, 11020 onChange: onChange, 11021 units: units // Default to `row` for combined values. 11022 , 11023 value: boxControlGapValue 11024 })), 11025 native: null 11026 }); 11027 } 11028 11029 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-control/icons.js 11030 11031 11032 /** 11033 * WordPress dependencies 11034 */ 11035 11036 const alignBottom = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, { 11037 xmlns: "http://www.w3.org/2000/svg", 11038 viewBox: "0 0 24 24" 11039 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, { 11040 d: "M15 4H9v11h6V4zM4 18.5V20h16v-1.5H4z" 11041 })); 11042 const alignCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, { 11043 xmlns: "http://www.w3.org/2000/svg", 11044 viewBox: "0 0 24 24" 11045 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, { 11046 d: "M20 11h-5V4H9v7H4v1.5h5V20h6v-7.5h5z" 11047 })); 11048 const alignTop = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, { 11049 xmlns: "http://www.w3.org/2000/svg", 11050 viewBox: "0 0 24 24" 11051 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, { 11052 d: "M9 20h6V9H9v11zM4 4v1.5h16V4H4z" 11053 })); 11054 11055 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-control/ui.js 11056 11057 11058 11059 /** 11060 * WordPress dependencies 11061 */ 11062 11063 11064 /** 11065 * Internal dependencies 11066 */ 11067 11068 11069 const BLOCK_ALIGNMENTS_CONTROLS = { 11070 top: { 11071 icon: alignTop, 11072 title: (0,external_wp_i18n_namespaceObject._x)('Align top', 'Block vertical alignment setting') 11073 }, 11074 center: { 11075 icon: alignCenter, 11076 title: (0,external_wp_i18n_namespaceObject._x)('Align middle', 'Block vertical alignment setting') 11077 }, 11078 bottom: { 11079 icon: alignBottom, 11080 title: (0,external_wp_i18n_namespaceObject._x)('Align bottom', 'Block vertical alignment setting') 11081 } 11082 }; 11083 const DEFAULT_CONTROLS = ['top', 'center', 'bottom']; 11084 const DEFAULT_CONTROL = 'top'; 11085 const POPOVER_PROPS = { 11086 isAlternate: true 11087 }; 11088 11089 function BlockVerticalAlignmentUI(_ref) { 11090 let { 11091 value, 11092 onChange, 11093 controls = DEFAULT_CONTROLS, 11094 isCollapsed = true, 11095 isToolbar 11096 } = _ref; 11097 11098 function applyOrUnset(align) { 11099 return () => onChange(value === align ? undefined : align); 11100 } 11101 11102 const activeAlignment = BLOCK_ALIGNMENTS_CONTROLS[value]; 11103 const defaultAlignmentControl = BLOCK_ALIGNMENTS_CONTROLS[DEFAULT_CONTROL]; 11104 const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu; 11105 const extraProps = isToolbar ? { 11106 isCollapsed 11107 } : {}; 11108 return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({ 11109 popoverProps: POPOVER_PROPS, 11110 icon: activeAlignment ? activeAlignment.icon : defaultAlignmentControl.icon, 11111 label: (0,external_wp_i18n_namespaceObject._x)('Change vertical alignment', 'Block vertical alignment setting label'), 11112 controls: controls.map(control => { 11113 return { ...BLOCK_ALIGNMENTS_CONTROLS[control], 11114 isActive: value === control, 11115 role: isCollapsed ? 'menuitemradio' : undefined, 11116 onClick: applyOrUnset(control) 11117 }; 11118 }) 11119 }, extraProps)); 11120 } 11121 /** 11122 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-vertical-alignment-toolbar/README.md 11123 */ 11124 11125 11126 /* harmony default export */ var ui = (BlockVerticalAlignmentUI); 11127 11128 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-control/index.js 11129 11130 11131 11132 /** 11133 * Internal dependencies 11134 */ 11135 11136 11137 const BlockVerticalAlignmentControl = props => { 11138 return (0,external_wp_element_namespaceObject.createElement)(ui, _extends({}, props, { 11139 isToolbar: false 11140 })); 11141 }; 11142 11143 const BlockVerticalAlignmentToolbar = props => { 11144 return (0,external_wp_element_namespaceObject.createElement)(ui, _extends({}, props, { 11145 isToolbar: true 11146 })); 11147 }; 11148 /** 11149 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-vertical-alignment-control/README.md 11150 */ 11151 11152 11153 11154 11155 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/justify-content-control/ui.js 11156 11157 11158 11159 /** 11160 * WordPress dependencies 11161 */ 11162 11163 11164 11165 const icons = { 11166 left: justify_left, 11167 center: justify_center, 11168 right: justify_right, 11169 'space-between': justify_space_between 11170 }; 11171 11172 function JustifyContentUI(_ref) { 11173 let { 11174 allowedControls = ['left', 'center', 'right', 'space-between'], 11175 isCollapsed = true, 11176 onChange, 11177 value, 11178 popoverProps, 11179 isToolbar 11180 } = _ref; 11181 11182 // If the control is already selected we want a click 11183 // again on the control to deselect the item, so we 11184 // call onChange( undefined ) 11185 const handleClick = next => { 11186 if (next === value) { 11187 onChange(undefined); 11188 } else { 11189 onChange(next); 11190 } 11191 }; 11192 11193 const icon = value ? icons[value] : icons.left; 11194 const allControls = [{ 11195 name: 'left', 11196 icon: justify_left, 11197 title: (0,external_wp_i18n_namespaceObject.__)('Justify items left'), 11198 isActive: 'left' === value, 11199 onClick: () => handleClick('left') 11200 }, { 11201 name: 'center', 11202 icon: justify_center, 11203 title: (0,external_wp_i18n_namespaceObject.__)('Justify items center'), 11204 isActive: 'center' === value, 11205 onClick: () => handleClick('center') 11206 }, { 11207 name: 'right', 11208 icon: justify_right, 11209 title: (0,external_wp_i18n_namespaceObject.__)('Justify items right'), 11210 isActive: 'right' === value, 11211 onClick: () => handleClick('right') 11212 }, { 11213 name: 'space-between', 11214 icon: justify_space_between, 11215 title: (0,external_wp_i18n_namespaceObject.__)('Space between items'), 11216 isActive: 'space-between' === value, 11217 onClick: () => handleClick('space-between') 11218 }]; 11219 const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu; 11220 const extraProps = isToolbar ? { 11221 isCollapsed 11222 } : {}; 11223 return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({ 11224 icon: icon, 11225 popoverProps: popoverProps, 11226 label: (0,external_wp_i18n_namespaceObject.__)('Change items justification'), 11227 controls: allControls.filter(elem => allowedControls.includes(elem.name)) 11228 }, extraProps)); 11229 } 11230 11231 /* harmony default export */ var justify_content_control_ui = (JustifyContentUI); 11232 11233 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/justify-content-control/index.js 11234 11235 11236 11237 /** 11238 * Internal dependencies 11239 */ 11240 11241 11242 const JustifyContentControl = props => { 11243 return (0,external_wp_element_namespaceObject.createElement)(justify_content_control_ui, _extends({}, props, { 11244 isToolbar: false 11245 })); 11246 }; 11247 11248 const JustifyToolbar = props => { 11249 return (0,external_wp_element_namespaceObject.createElement)(justify_content_control_ui, _extends({}, props, { 11250 isToolbar: true 11251 })); 11252 }; 11253 /** 11254 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/justify-content-control/README.md 11255 */ 11256 11257 11258 11259 11260 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/layouts/flex.js 11261 11262 11263 /** 11264 * WordPress dependencies 11265 */ 11266 11267 11268 11269 /** 11270 * Internal dependencies 11271 */ 11272 11273 11274 11275 11276 11277 // Used with the default, horizontal flex orientation. 11278 11279 const justifyContentMap = { 11280 left: 'flex-start', 11281 right: 'flex-end', 11282 center: 'center', 11283 'space-between': 'space-between' 11284 }; // Used with the vertical (column) flex orientation. 11285 11286 const alignItemsMap = { 11287 left: 'flex-start', 11288 right: 'flex-end', 11289 center: 'center' 11290 }; 11291 const verticalAlignmentMap = { 11292 top: 'flex-start', 11293 center: 'center', 11294 bottom: 'flex-end' 11295 }; 11296 const flexWrapOptions = ['wrap', 'nowrap']; 11297 /* harmony default export */ var flex = ({ 11298 name: 'flex', 11299 label: (0,external_wp_i18n_namespaceObject.__)('Flex'), 11300 inspectorControls: function FlexLayoutInspectorControls(_ref) { 11301 let { 11302 layout = {}, 11303 onChange, 11304 layoutBlockSupport = {} 11305 } = _ref; 11306 const { 11307 allowOrientation = true 11308 } = layoutBlockSupport; 11309 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(FlexLayoutJustifyContentControl, { 11310 layout: layout, 11311 onChange: onChange 11312 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, allowOrientation && (0,external_wp_element_namespaceObject.createElement)(OrientationControl, { 11313 layout: layout, 11314 onChange: onChange 11315 }))), (0,external_wp_element_namespaceObject.createElement)(FlexWrapControl, { 11316 layout: layout, 11317 onChange: onChange 11318 })); 11319 }, 11320 toolBarControls: function FlexLayoutToolbarControls(_ref2) { 11321 let { 11322 layout = {}, 11323 onChange, 11324 layoutBlockSupport 11325 } = _ref2; 11326 11327 if (layoutBlockSupport !== null && layoutBlockSupport !== void 0 && layoutBlockSupport.allowSwitching) { 11328 return null; 11329 } 11330 11331 const { 11332 allowVerticalAlignment = true 11333 } = layoutBlockSupport; 11334 return (0,external_wp_element_namespaceObject.createElement)(block_controls, { 11335 group: "block", 11336 __experimentalShareWithChildBlocks: true 11337 }, (0,external_wp_element_namespaceObject.createElement)(FlexLayoutJustifyContentControl, { 11338 layout: layout, 11339 onChange: onChange, 11340 isToolbar: true 11341 }), allowVerticalAlignment && (layout === null || layout === void 0 ? void 0 : layout.orientation) !== 'vertical' && (0,external_wp_element_namespaceObject.createElement)(FlexLayoutVerticalAlignmentControl, { 11342 layout: layout, 11343 onChange: onChange, 11344 isToolbar: true 11345 })); 11346 }, 11347 save: function FlexLayoutStyle(_ref3) { 11348 var _style$spacing, _style$spacing2; 11349 11350 let { 11351 selector, 11352 layout, 11353 style, 11354 blockName 11355 } = _ref3; 11356 const { 11357 orientation = 'horizontal' 11358 } = layout; 11359 const blockGapSupport = useSetting('spacing.blockGap'); 11360 const hasBlockGapStylesSupport = blockGapSupport !== null; // If a block's block.json skips serialization for spacing or spacing.blockGap, 11361 // don't apply the user-defined value to the styles. 11362 11363 const blockGapValue = style !== null && style !== void 0 && (_style$spacing = style.spacing) !== null && _style$spacing !== void 0 && _style$spacing.blockGap && !shouldSkipSerialization(blockName, 'spacing', 'blockGap') ? getGapCSSValue(style === null || style === void 0 ? void 0 : (_style$spacing2 = style.spacing) === null || _style$spacing2 === void 0 ? void 0 : _style$spacing2.blockGap, '0.5em') : 'var( --wp--style--block-gap, 0.5em )'; 11364 const justifyContent = justifyContentMap[layout.justifyContent] || justifyContentMap.left; 11365 const flexWrap = flexWrapOptions.includes(layout.flexWrap) ? layout.flexWrap : 'wrap'; 11366 const verticalAlignment = verticalAlignmentMap[layout.verticalAlignment] || verticalAlignmentMap.center; 11367 const rowOrientation = ` 11368 flex-direction: row; 11369 align-items: $verticalAlignment}; 11370 justify-content: $justifyContent}; 11371 `; 11372 const alignItems = alignItemsMap[layout.justifyContent] || alignItemsMap.left; 11373 const columnOrientation = ` 11374 flex-direction: column; 11375 align-items: $alignItems}; 11376 `; 11377 return (0,external_wp_element_namespaceObject.createElement)("style", null, ` 11378 $appendSelectors(selector)} { 11379 display: flex; 11380 flex-wrap: $flexWrap}; 11381 gap: $hasBlockGapStylesSupport ? blockGapValue : '0.5em'}; 11382 $orientation === 'horizontal' ? rowOrientation : columnOrientation} 11383 } 11384 11385 $appendSelectors(selector, '> *')} { 11386 margin: 0; 11387 } 11388 `); 11389 }, 11390 11391 getOrientation(layout) { 11392 const { 11393 orientation = 'horizontal' 11394 } = layout; 11395 return orientation; 11396 }, 11397 11398 getAlignments() { 11399 return []; 11400 } 11401 11402 }); 11403 11404 function FlexLayoutVerticalAlignmentControl(_ref4) { 11405 let { 11406 layout, 11407 onChange, 11408 isToolbar = false 11409 } = _ref4; 11410 const { 11411 verticalAlignment = verticalAlignmentMap.center 11412 } = layout; 11413 11414 const onVerticalAlignmentChange = value => { 11415 onChange({ ...layout, 11416 verticalAlignment: value 11417 }); 11418 }; 11419 11420 if (isToolbar) { 11421 return (0,external_wp_element_namespaceObject.createElement)(BlockVerticalAlignmentControl, { 11422 onChange: onVerticalAlignmentChange, 11423 value: verticalAlignment 11424 }); 11425 } 11426 11427 const verticalAlignmentOptions = [{ 11428 value: 'flex-start', 11429 label: (0,external_wp_i18n_namespaceObject.__)('Align items top') 11430 }, { 11431 value: 'center', 11432 label: (0,external_wp_i18n_namespaceObject.__)('Align items center') 11433 }, { 11434 value: 'flex-end', 11435 label: (0,external_wp_i18n_namespaceObject.__)('Align items bottom') 11436 }]; 11437 return (0,external_wp_element_namespaceObject.createElement)("fieldset", { 11438 className: "block-editor-hooks__flex-layout-vertical-alignment-control" 11439 }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_i18n_namespaceObject.__)('Vertical alignment')), (0,external_wp_element_namespaceObject.createElement)("div", null, verticalAlignmentOptions.map((value, icon, label) => { 11440 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 11441 key: value, 11442 label: label, 11443 icon: icon, 11444 isPressed: verticalAlignment === value, 11445 onClick: () => onVerticalAlignmentChange(value) 11446 }); 11447 }))); 11448 } 11449 11450 function FlexLayoutJustifyContentControl(_ref5) { 11451 let { 11452 layout, 11453 onChange, 11454 isToolbar = false 11455 } = _ref5; 11456 const { 11457 justifyContent = 'left', 11458 orientation = 'horizontal' 11459 } = layout; 11460 11461 const onJustificationChange = value => { 11462 onChange({ ...layout, 11463 justifyContent: value 11464 }); 11465 }; 11466 11467 const allowedControls = ['left', 'center', 'right']; 11468 11469 if (orientation === 'horizontal') { 11470 allowedControls.push('space-between'); 11471 } 11472 11473 if (isToolbar) { 11474 return (0,external_wp_element_namespaceObject.createElement)(JustifyContentControl, { 11475 allowedControls: allowedControls, 11476 value: justifyContent, 11477 onChange: onJustificationChange, 11478 popoverProps: { 11479 position: 'bottom right', 11480 isAlternate: true 11481 } 11482 }); 11483 } 11484 11485 const justificationOptions = [{ 11486 value: 'left', 11487 icon: justify_left, 11488 label: (0,external_wp_i18n_namespaceObject.__)('Justify items left') 11489 }, { 11490 value: 'center', 11491 icon: justify_center, 11492 label: (0,external_wp_i18n_namespaceObject.__)('Justify items center') 11493 }, { 11494 value: 'right', 11495 icon: justify_right, 11496 label: (0,external_wp_i18n_namespaceObject.__)('Justify items right') 11497 }]; 11498 11499 if (orientation === 'horizontal') { 11500 justificationOptions.push({ 11501 value: 'space-between', 11502 icon: justify_space_between, 11503 label: (0,external_wp_i18n_namespaceObject.__)('Space between items') 11504 }); 11505 } 11506 11507 return (0,external_wp_element_namespaceObject.createElement)("fieldset", { 11508 className: "block-editor-hooks__flex-layout-justification-controls" 11509 }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_i18n_namespaceObject.__)('Justification')), (0,external_wp_element_namespaceObject.createElement)("div", null, justificationOptions.map(_ref6 => { 11510 let { 11511 value, 11512 icon, 11513 label 11514 } = _ref6; 11515 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 11516 key: value, 11517 label: label, 11518 icon: icon, 11519 isPressed: justifyContent === value, 11520 onClick: () => onJustificationChange(value) 11521 }); 11522 }))); 11523 } 11524 11525 function FlexWrapControl(_ref7) { 11526 let { 11527 layout, 11528 onChange 11529 } = _ref7; 11530 const { 11531 flexWrap = 'wrap' 11532 } = layout; 11533 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, { 11534 label: (0,external_wp_i18n_namespaceObject.__)('Allow to wrap to multiple lines'), 11535 onChange: value => { 11536 onChange({ ...layout, 11537 flexWrap: value ? 'wrap' : 'nowrap' 11538 }); 11539 }, 11540 checked: flexWrap === 'wrap' 11541 }); 11542 } 11543 11544 function OrientationControl(_ref8) { 11545 let { 11546 layout, 11547 onChange 11548 } = _ref8; 11549 const { 11550 orientation = 'horizontal' 11551 } = layout; 11552 return (0,external_wp_element_namespaceObject.createElement)("fieldset", { 11553 className: "block-editor-hooks__flex-layout-orientation-controls" 11554 }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_i18n_namespaceObject.__)('Orientation')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 11555 label: 'horizontal', 11556 icon: arrow_right, 11557 isPressed: orientation === 'horizontal', 11558 onClick: () => onChange({ ...layout, 11559 orientation: 'horizontal' 11560 }) 11561 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 11562 label: 'vertical', 11563 icon: arrow_down, 11564 isPressed: orientation === 'vertical', 11565 onClick: () => onChange({ ...layout, 11566 orientation: 'vertical' 11567 }) 11568 })); 11569 } 11570 11571 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js 11572 /** 11573 * WordPress dependencies 11574 */ 11575 11576 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */ 11577 11578 /** 11579 * Return an SVG icon. 11580 * 11581 * @param {IconProps} props icon is the SVG component to render 11582 * size is a number specifiying the icon size in pixels 11583 * Other props will be passed to wrapped SVG component 11584 * 11585 * @return {JSX.Element} Icon component 11586 */ 11587 11588 function Icon(_ref) { 11589 let { 11590 icon, 11591 size = 24, 11592 ...props 11593 } = _ref; 11594 return (0,external_wp_element_namespaceObject.cloneElement)(icon, { 11595 width: size, 11596 height: size, 11597 ...props 11598 }); 11599 } 11600 11601 /* harmony default export */ var build_module_icon = (Icon); 11602 11603 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/layouts/flow.js 11604 11605 11606 /** 11607 * WordPress dependencies 11608 */ 11609 11610 11611 11612 /** 11613 * Internal dependencies 11614 */ 11615 11616 11617 11618 11619 11620 /* harmony default export */ var flow = ({ 11621 name: 'default', 11622 label: (0,external_wp_i18n_namespaceObject.__)('Flow'), 11623 inspectorControls: function DefaultLayoutInspectorControls(_ref) { 11624 let { 11625 layout, 11626 onChange 11627 } = _ref; 11628 const { 11629 wideSize, 11630 contentSize 11631 } = layout; 11632 const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({ 11633 availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw'] 11634 }); 11635 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", { 11636 className: "block-editor-hooks__layout-controls" 11637 }, (0,external_wp_element_namespaceObject.createElement)("div", { 11638 className: "block-editor-hooks__layout-controls-unit" 11639 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, { 11640 label: (0,external_wp_i18n_namespaceObject.__)('Content'), 11641 labelPosition: "top", 11642 __unstableInputWidth: "80px", 11643 value: contentSize || wideSize || '', 11644 onChange: nextWidth => { 11645 nextWidth = 0 > parseFloat(nextWidth) ? '0' : nextWidth; 11646 onChange({ ...layout, 11647 contentSize: nextWidth 11648 }); 11649 }, 11650 units: units 11651 }), (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { 11652 icon: position_center 11653 })), (0,external_wp_element_namespaceObject.createElement)("div", { 11654 className: "block-editor-hooks__layout-controls-unit" 11655 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, { 11656 label: (0,external_wp_i18n_namespaceObject.__)('Wide'), 11657 labelPosition: "top", 11658 __unstableInputWidth: "80px", 11659 value: wideSize || contentSize || '', 11660 onChange: nextWidth => { 11661 nextWidth = 0 > parseFloat(nextWidth) ? '0' : nextWidth; 11662 onChange({ ...layout, 11663 wideSize: nextWidth 11664 }); 11665 }, 11666 units: units 11667 }), (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { 11668 icon: stretch_wide 11669 }))), (0,external_wp_element_namespaceObject.createElement)("div", { 11670 className: "block-editor-hooks__layout-controls-reset" 11671 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 11672 variant: "secondary", 11673 isSmall: true, 11674 disabled: !contentSize && !wideSize, 11675 onClick: () => onChange({ 11676 contentSize: undefined, 11677 wideSize: undefined, 11678 inherit: false 11679 }) 11680 }, (0,external_wp_i18n_namespaceObject.__)('Reset'))), (0,external_wp_element_namespaceObject.createElement)("p", { 11681 className: "block-editor-hooks__layout-controls-helptext" 11682 }, (0,external_wp_i18n_namespaceObject.__)('Customize the width for all elements that are assigned to the center or wide columns.'))); 11683 }, 11684 toolBarControls: function DefaultLayoutToolbarControls() { 11685 return null; 11686 }, 11687 save: function DefaultLayoutStyle(_ref2) { 11688 var _style$spacing; 11689 11690 let { 11691 selector, 11692 layout = {}, 11693 style, 11694 blockName 11695 } = _ref2; 11696 const { 11697 contentSize, 11698 wideSize 11699 } = layout; 11700 const blockGapSupport = useSetting('spacing.blockGap'); 11701 const hasBlockGapStylesSupport = blockGapSupport !== null; 11702 const blockGapStyleValue = getGapBoxControlValueFromStyle(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap); // If a block's block.json skips serialization for spacing or 11703 // spacing.blockGap, don't apply the user-defined value to the styles. 11704 11705 const blockGapValue = blockGapStyleValue !== null && blockGapStyleValue !== void 0 && blockGapStyleValue.top && !shouldSkipSerialization(blockName, 'spacing', 'blockGap') ? blockGapStyleValue === null || blockGapStyleValue === void 0 ? void 0 : blockGapStyleValue.top : 'var( --wp--style--block-gap )'; 11706 let output = !!contentSize || !!wideSize ? ` 11707 $appendSelectors(selector, '> :where(:not(.alignleft):not(.alignright))')} { 11708 max-width: $contentSize !== null && contentSize !== void 0 ? contentSize : wideSize}; 11709 margin-left: auto !important; 11710 margin-right: auto !important; 11711 } 11712 $appendSelectors(selector, '> .alignwide')} { 11713 max-width: $wideSize !== null && wideSize !== void 0 ? wideSize : contentSize}; 11714 } 11715 $appendSelectors(selector, '> .alignfull')} { 11716 max-width: none; 11717 } 11718 ` : ''; 11719 output += ` 11720 $appendSelectors(selector, '> .alignleft')} { 11721 float: left; 11722 margin-inline-start: 0; 11723 margin-inline-end: 2em; 11724 } 11725 $appendSelectors(selector, '> .alignright')} { 11726 float: right; 11727 margin-inline-start: 2em; 11728 margin-inline-end: 0; 11729 } 11730 11731 $appendSelectors(selector, '> .aligncenter')} { 11732 margin-left: auto !important; 11733 margin-right: auto !important; 11734 } 11735 `; 11736 11737 if (hasBlockGapStylesSupport) { 11738 output += ` 11739 $appendSelectors(selector, '> *')} { 11740 margin-block-start: 0; 11741 margin-block-end: 0; 11742 } 11743 $appendSelectors(selector, '> * + *')} { 11744 margin-block-start: $blockGapValue}; 11745 } 11746 `; 11747 } 11748 11749 return (0,external_wp_element_namespaceObject.createElement)("style", null, output); 11750 }, 11751 11752 getOrientation() { 11753 return 'vertical'; 11754 }, 11755 11756 getAlignments(layout) { 11757 const alignmentInfo = getAlignmentsInfo(layout); 11758 11759 if (layout.alignments !== undefined) { 11760 if (!layout.alignments.includes('none')) { 11761 layout.alignments.unshift('none'); 11762 } 11763 11764 return layout.alignments.map(alignment => ({ 11765 name: alignment, 11766 info: alignmentInfo[alignment] 11767 })); 11768 } 11769 11770 const { 11771 contentSize, 11772 wideSize 11773 } = layout; 11774 const alignments = [{ 11775 name: 'left' 11776 }, { 11777 name: 'center' 11778 }, { 11779 name: 'right' 11780 }]; 11781 11782 if (contentSize) { 11783 alignments.unshift({ 11784 name: 'full' 11785 }); 11786 } 11787 11788 if (wideSize) { 11789 alignments.unshift({ 11790 name: 'wide', 11791 info: alignmentInfo.wide 11792 }); 11793 } 11794 11795 alignments.unshift({ 11796 name: 'none', 11797 info: alignmentInfo.none 11798 }); 11799 return alignments; 11800 } 11801 11802 }); 11803 /** 11804 * Helper method to assign contextual info to clarify 11805 * alignment settings. 11806 * 11807 * Besides checking if `contentSize` and `wideSize` have a 11808 * value, we now show this information only if their values 11809 * are not a `css var`. This needs to change when parsing 11810 * css variables land. 11811 * 11812 * @see https://github.com/WordPress/gutenberg/pull/34710#issuecomment-918000752 11813 * 11814 * @param {Object} layout The layout object. 11815 * @return {Object} An object with contextual info per alignment. 11816 */ 11817 11818 function getAlignmentsInfo(layout) { 11819 const { 11820 contentSize, 11821 wideSize 11822 } = layout; 11823 const alignmentInfo = {}; 11824 const sizeRegex = /^(?!0)\d+(px|em|rem|vw|vh|%)?$/i; 11825 11826 if (sizeRegex.test(contentSize)) { 11827 // translators: %s: container size (i.e. 600px etc) 11828 alignmentInfo.none = (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Max %s wide'), contentSize); 11829 } 11830 11831 if (sizeRegex.test(wideSize)) { 11832 // translators: %s: container size (i.e. 600px etc) 11833 alignmentInfo.wide = (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Max %s wide'), wideSize); 11834 } 11835 11836 return alignmentInfo; 11837 } 11838 11839 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/layouts/index.js 11840 /** 11841 * Internal dependencies 11842 */ 11843 11844 11845 const layoutTypes = [flow, flex]; 11846 /** 11847 * Retrieves a layout type by name. 11848 * 11849 * @param {string} name - The name of the layout type. 11850 * @return {Object} Layout type. 11851 */ 11852 11853 function getLayoutType() { 11854 let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; 11855 return layoutTypes.find(layoutType => layoutType.name === name); 11856 } 11857 /** 11858 * Retrieves the available layout types. 11859 * 11860 * @return {Array} Layout types. 11861 */ 11862 11863 function getLayoutTypes() { 11864 return layoutTypes; 11865 } 11866 11867 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/layout.js 11868 11869 11870 11871 /** 11872 * WordPress dependencies 11873 */ 11874 11875 /** 11876 * Internal dependencies 11877 */ 11878 11879 11880 const defaultLayout = { 11881 type: 'default' 11882 }; 11883 const Layout = (0,external_wp_element_namespaceObject.createContext)(defaultLayout); 11884 /** 11885 * Allows to define the layout. 11886 */ 11887 11888 const LayoutProvider = Layout.Provider; 11889 /** 11890 * React hook used to retrieve the layout config. 11891 */ 11892 11893 function useLayout() { 11894 return (0,external_wp_element_namespaceObject.useContext)(Layout); 11895 } 11896 function LayoutStyle(_ref) { 11897 let { 11898 layout = {}, 11899 ...props 11900 } = _ref; 11901 const layoutType = getLayoutType(layout.type); 11902 11903 if (layoutType) { 11904 return (0,external_wp_element_namespaceObject.createElement)(layoutType.save, _extends({ 11905 layout: layout 11906 }, props)); 11907 } 11908 11909 return null; 11910 } 11911 11912 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-control/use-available-alignments.js 11913 /** 11914 * WordPress dependencies 11915 */ 11916 11917 /** 11918 * Internal dependencies 11919 */ 11920 11921 11922 11923 11924 const use_available_alignments_DEFAULT_CONTROLS = ['none', 'left', 'center', 'right', 'wide', 'full']; 11925 const WIDE_CONTROLS = ['wide', 'full']; 11926 function useAvailableAlignments() { 11927 let controls = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : use_available_alignments_DEFAULT_CONTROLS; 11928 11929 // Always add the `none` option if not exists. 11930 if (!controls.includes('none')) { 11931 controls = ['none', ...controls]; 11932 } 11933 11934 const { 11935 wideControlsEnabled = false, 11936 themeSupportsLayout 11937 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 11938 const { 11939 getSettings 11940 } = select(store); 11941 const settings = getSettings(); 11942 return { 11943 wideControlsEnabled: settings.alignWide, 11944 themeSupportsLayout: settings.supportsLayout 11945 }; 11946 }, []); 11947 const layout = useLayout(); 11948 const layoutType = getLayoutType(layout === null || layout === void 0 ? void 0 : layout.type); 11949 const layoutAlignments = layoutType.getAlignments(layout); 11950 11951 if (themeSupportsLayout) { 11952 const alignments = layoutAlignments.filter(_ref => { 11953 let { 11954 name: alignmentName 11955 } = _ref; 11956 return controls.includes(alignmentName); 11957 }); // While we treat `none` as an alignment, we shouldn't return it if no 11958 // other alignments exist. 11959 11960 if (alignments.length === 1 && alignments[0].name === 'none') { 11961 return []; 11962 } 11963 11964 return alignments; 11965 } // Starting here, it's the fallback for themes not supporting the layout config. 11966 11967 11968 if (layoutType.name !== 'default') { 11969 return []; 11970 } 11971 11972 const { 11973 alignments: availableAlignments = use_available_alignments_DEFAULT_CONTROLS 11974 } = layout; 11975 const enabledControls = controls.filter(control => (layout.alignments || // Ignore the global wideAlignment check if the layout explicitely defines alignments. 11976 wideControlsEnabled || !WIDE_CONTROLS.includes(control)) && availableAlignments.includes(control)).map(enabledControl => ({ 11977 name: enabledControl 11978 })); // While we treat `none` as an alignment, we shouldn't return it if no 11979 // other alignments exist. 11980 11981 if (enabledControls.length === 1 && enabledControls[0].name === 'none') { 11982 return []; 11983 } 11984 11985 return enabledControls; 11986 } 11987 11988 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-control/ui.js 11989 11990 11991 11992 /** 11993 * External dependencies 11994 */ 11995 11996 /** 11997 * WordPress dependencies 11998 */ 11999 12000 12001 12002 12003 12004 /** 12005 * Internal dependencies 12006 */ 12007 12008 12009 const ui_BLOCK_ALIGNMENTS_CONTROLS = { 12010 none: { 12011 icon: align_none, 12012 title: (0,external_wp_i18n_namespaceObject._x)('None', 'Alignment option') 12013 }, 12014 left: { 12015 icon: position_left, 12016 title: (0,external_wp_i18n_namespaceObject.__)('Align left') 12017 }, 12018 center: { 12019 icon: position_center, 12020 title: (0,external_wp_i18n_namespaceObject.__)('Align center') 12021 }, 12022 right: { 12023 icon: position_right, 12024 title: (0,external_wp_i18n_namespaceObject.__)('Align right') 12025 }, 12026 wide: { 12027 icon: stretch_wide, 12028 title: (0,external_wp_i18n_namespaceObject.__)('Wide width') 12029 }, 12030 full: { 12031 icon: stretch_full_width, 12032 title: (0,external_wp_i18n_namespaceObject.__)('Full width') 12033 } 12034 }; 12035 const ui_DEFAULT_CONTROL = 'none'; 12036 const ui_POPOVER_PROPS = { 12037 isAlternate: true 12038 }; 12039 12040 function BlockAlignmentUI(_ref) { 12041 let { 12042 value, 12043 onChange, 12044 controls, 12045 isToolbar, 12046 isCollapsed = true 12047 } = _ref; 12048 const enabledControls = useAvailableAlignments(controls); 12049 const hasEnabledControls = !!enabledControls.length; 12050 12051 if (!hasEnabledControls) { 12052 return null; 12053 } 12054 12055 function onChangeAlignment(align) { 12056 onChange([value, 'none'].includes(align) ? undefined : align); 12057 } 12058 12059 const activeAlignmentControl = ui_BLOCK_ALIGNMENTS_CONTROLS[value]; 12060 const defaultAlignmentControl = ui_BLOCK_ALIGNMENTS_CONTROLS[ui_DEFAULT_CONTROL]; 12061 const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu; 12062 const commonProps = { 12063 popoverProps: ui_POPOVER_PROPS, 12064 icon: activeAlignmentControl ? activeAlignmentControl.icon : defaultAlignmentControl.icon, 12065 label: (0,external_wp_i18n_namespaceObject.__)('Align'), 12066 toggleProps: { 12067 describedBy: (0,external_wp_i18n_namespaceObject.__)('Change alignment') 12068 } 12069 }; 12070 const extraProps = isToolbar || external_wp_element_namespaceObject.Platform.isNative ? { 12071 isCollapsed: isToolbar ? isCollapsed : undefined, 12072 controls: enabledControls.map(_ref2 => { 12073 let { 12074 name: controlName 12075 } = _ref2; 12076 return { ...ui_BLOCK_ALIGNMENTS_CONTROLS[controlName], 12077 isActive: value === controlName || !value && controlName === 'none', 12078 role: isCollapsed ? 'menuitemradio' : undefined, 12079 onClick: () => onChangeAlignment(controlName) 12080 }; 12081 }) 12082 } : { 12083 children: _ref3 => { 12084 let { 12085 onClose 12086 } = _ref3; 12087 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, { 12088 className: "block-editor-block-alignment-control__menu-group" 12089 }, enabledControls.map(_ref4 => { 12090 let { 12091 name: controlName, 12092 info 12093 } = _ref4; 12094 const { 12095 icon, 12096 title 12097 } = ui_BLOCK_ALIGNMENTS_CONTROLS[controlName]; // If no value is provided, mark as selected the `none` option. 12098 12099 const isSelected = controlName === value || !value && controlName === 'none'; 12100 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 12101 key: controlName, 12102 icon: icon, 12103 iconPosition: "left", 12104 className: classnames_default()('components-dropdown-menu__menu-item', { 12105 'is-active': isSelected 12106 }), 12107 isSelected: isSelected, 12108 onClick: () => { 12109 onChangeAlignment(controlName); 12110 onClose(); 12111 }, 12112 role: "menuitemradio", 12113 info: info 12114 }, title); 12115 }))); 12116 } 12117 }; 12118 return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({}, commonProps, extraProps)); 12119 } 12120 12121 /* harmony default export */ var block_alignment_control_ui = (BlockAlignmentUI); 12122 12123 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-control/index.js 12124 12125 12126 12127 /** 12128 * Internal dependencies 12129 */ 12130 12131 12132 const BlockAlignmentControl = props => { 12133 return (0,external_wp_element_namespaceObject.createElement)(block_alignment_control_ui, _extends({}, props, { 12134 isToolbar: false 12135 })); 12136 }; 12137 12138 const BlockAlignmentToolbar = props => { 12139 return (0,external_wp_element_namespaceObject.createElement)(block_alignment_control_ui, _extends({}, props, { 12140 isToolbar: true 12141 })); 12142 }; 12143 /** 12144 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-alignment-control/README.md 12145 */ 12146 12147 12148 12149 12150 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/align.js 12151 12152 12153 12154 /** 12155 * External dependencies 12156 */ 12157 12158 12159 /** 12160 * WordPress dependencies 12161 */ 12162 12163 12164 12165 12166 /** 12167 * Internal dependencies 12168 */ 12169 12170 12171 12172 /** 12173 * An array which includes all possible valid alignments, 12174 * used to validate if an alignment is valid or not. 12175 * 12176 * @constant 12177 * @type {string[]} 12178 */ 12179 12180 const ALL_ALIGNMENTS = ['left', 'center', 'right', 'wide', 'full']; 12181 /** 12182 * An array which includes all wide alignments. 12183 * In order for this alignments to be valid they need to be supported by the block, 12184 * and by the theme. 12185 * 12186 * @constant 12187 * @type {string[]} 12188 */ 12189 12190 const WIDE_ALIGNMENTS = ['wide', 'full']; 12191 /** 12192 * Returns the valid alignments. 12193 * Takes into consideration the aligns supported by a block, if the block supports wide controls or not and if theme supports wide controls or not. 12194 * Exported just for testing purposes, not exported outside the module. 12195 * 12196 * @param {?boolean|string[]} blockAlign Aligns supported by the block. 12197 * @param {?boolean} hasWideBlockSupport True if block supports wide alignments. And False otherwise. 12198 * @param {?boolean} hasWideEnabled True if theme supports wide alignments. And False otherwise. 12199 * 12200 * @return {string[]} Valid alignments. 12201 */ 12202 12203 function getValidAlignments(blockAlign) { 12204 let hasWideBlockSupport = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; 12205 let hasWideEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; 12206 let validAlignments; 12207 12208 if (Array.isArray(blockAlign)) { 12209 validAlignments = ALL_ALIGNMENTS.filter(value => blockAlign.includes(value)); 12210 } else if (blockAlign === true) { 12211 // `true` includes all alignments... 12212 validAlignments = [...ALL_ALIGNMENTS]; 12213 } else { 12214 validAlignments = []; 12215 } 12216 12217 if (!hasWideEnabled || blockAlign === true && !hasWideBlockSupport) { 12218 return (0,external_lodash_namespaceObject.without)(validAlignments, ...WIDE_ALIGNMENTS); 12219 } 12220 12221 return validAlignments; 12222 } 12223 /** 12224 * Filters registered block settings, extending attributes to include `align`. 12225 * 12226 * @param {Object} settings Original block settings. 12227 * 12228 * @return {Object} Filtered block settings. 12229 */ 12230 12231 function addAttribute(settings) { 12232 // Allow blocks to specify their own attribute definition with default values if needed. 12233 if ((0,external_lodash_namespaceObject.has)(settings.attributes, ['align', 'type'])) { 12234 return settings; 12235 } 12236 12237 if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'align')) { 12238 // Gracefully handle if settings.attributes is undefined. 12239 settings.attributes = { ...settings.attributes, 12240 align: { 12241 type: 'string', 12242 // Allow for '' since it is used by updateAlignment function 12243 // in withToolbarControls for special cases with defined default values. 12244 enum: [...ALL_ALIGNMENTS, ''] 12245 } 12246 }; 12247 } 12248 12249 return settings; 12250 } 12251 /** 12252 * Override the default edit UI to include new toolbar controls for block 12253 * alignment, if block defines support. 12254 * 12255 * @param {Function} BlockEdit Original component. 12256 * 12257 * @return {Function} Wrapped component. 12258 */ 12259 12260 const withToolbarControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { 12261 const { 12262 name: blockName 12263 } = props; // Compute the block valid alignments by taking into account, 12264 // if the theme supports wide alignments or not and the layout's 12265 // availble alignments. We do that for conditionally rendering 12266 // Slot. 12267 12268 const blockAllowedAlignments = getValidAlignments((0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, 'align'), (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, 'alignWide', true)); 12269 const validAlignments = useAvailableAlignments(blockAllowedAlignments).map(_ref => { 12270 let { 12271 name 12272 } = _ref; 12273 return name; 12274 }); 12275 12276 const updateAlignment = nextAlign => { 12277 if (!nextAlign) { 12278 var _blockType$attributes, _blockType$attributes2; 12279 12280 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(props.name); 12281 const blockDefaultAlign = blockType === null || blockType === void 0 ? void 0 : (_blockType$attributes = blockType.attributes) === null || _blockType$attributes === void 0 ? void 0 : (_blockType$attributes2 = _blockType$attributes.align) === null || _blockType$attributes2 === void 0 ? void 0 : _blockType$attributes2.default; 12282 12283 if (blockDefaultAlign) { 12284 nextAlign = ''; 12285 } 12286 } 12287 12288 props.setAttributes({ 12289 align: nextAlign 12290 }); 12291 }; 12292 12293 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !!validAlignments.length && (0,external_wp_element_namespaceObject.createElement)(block_controls, { 12294 group: "block", 12295 __experimentalShareWithChildBlocks: true 12296 }, (0,external_wp_element_namespaceObject.createElement)(BlockAlignmentControl, { 12297 value: props.attributes.align, 12298 onChange: updateAlignment, 12299 controls: validAlignments 12300 })), (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props)); 12301 }, 'withToolbarControls'); 12302 /** 12303 * Override the default block element to add alignment wrapper props. 12304 * 12305 * @param {Function} BlockListBlock Original component. 12306 * 12307 * @return {Function} Wrapped component. 12308 */ 12309 12310 const withDataAlign = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => { 12311 const { 12312 name, 12313 attributes 12314 } = props; 12315 const { 12316 align 12317 } = attributes; 12318 const blockAllowedAlignments = getValidAlignments((0,external_wp_blocks_namespaceObject.getBlockSupport)(name, 'align'), (0,external_wp_blocks_namespaceObject.hasBlockSupport)(name, 'alignWide', true)); 12319 const validAlignments = useAvailableAlignments(blockAllowedAlignments); // If an alignment is not assigned, there's no need to go through the 12320 // effort to validate or assign its value. 12321 12322 if (align === undefined) { 12323 return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props); 12324 } 12325 12326 let wrapperProps = props.wrapperProps; 12327 12328 if (validAlignments.some(alignment => alignment.name === align)) { 12329 wrapperProps = { ...wrapperProps, 12330 'data-align': align 12331 }; 12332 } 12333 12334 return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, { 12335 wrapperProps: wrapperProps 12336 })); 12337 }); 12338 /** 12339 * Override props assigned to save component to inject alignment class name if 12340 * block supports it. 12341 * 12342 * @param {Object} props Additional props applied to save element. 12343 * @param {Object} blockType Block type. 12344 * @param {Object} attributes Block attributes. 12345 * 12346 * @return {Object} Filtered props applied to save element. 12347 */ 12348 12349 function addAssignedAlign(props, blockType, attributes) { 12350 const { 12351 align 12352 } = attributes; 12353 const blockAlign = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, 'align'); 12354 const hasWideBlockSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'alignWide', true); // Compute valid alignments without taking into account if 12355 // the theme supports wide alignments or not. 12356 // This way changing themes does not impact the block save. 12357 12358 const isAlignValid = getValidAlignments(blockAlign, hasWideBlockSupport).includes(align); 12359 12360 if (isAlignValid) { 12361 props.className = classnames_default()(`align$align}`, props.className); 12362 } 12363 12364 return props; 12365 } 12366 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/align/addAttribute', addAttribute); 12367 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/align/with-data-align', withDataAlign); 12368 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/align/with-toolbar-controls', withToolbarControls); 12369 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/align/addAssignedAlign', addAssignedAlign); 12370 12371 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/lock.js 12372 /** 12373 * External dependencies 12374 */ 12375 12376 /** 12377 * WordPress dependencies 12378 */ 12379 12380 12381 /** 12382 * Filters registered block settings, extending attributes to include `lock`. 12383 * 12384 * @param {Object} settings Original block settings. 12385 * 12386 * @return {Object} Filtered block settings. 12387 */ 12388 12389 function lock_addAttribute(settings) { 12390 // Allow blocks to specify their own attribute definition with default values if needed. 12391 if ((0,external_lodash_namespaceObject.has)(settings.attributes, ['lock', 'type'])) { 12392 return settings; 12393 } // Gracefully handle if settings.attributes is undefined. 12394 12395 12396 settings.attributes = { ...settings.attributes, 12397 lock: { 12398 type: 'object' 12399 } 12400 }; 12401 return settings; 12402 } 12403 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/lock/addAttribute', lock_addAttribute); 12404 12405 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/anchor.js 12406 12407 12408 /** 12409 * External dependencies 12410 */ 12411 12412 /** 12413 * WordPress dependencies 12414 */ 12415 12416 12417 12418 12419 12420 12421 12422 /** 12423 * Internal dependencies 12424 */ 12425 12426 12427 /** 12428 * Regular expression matching invalid anchor characters for replacement. 12429 * 12430 * @type {RegExp} 12431 */ 12432 12433 const ANCHOR_REGEX = /[\s#]/g; 12434 const ANCHOR_SCHEMA = { 12435 type: 'string', 12436 source: 'attribute', 12437 attribute: 'id', 12438 selector: '*' 12439 }; 12440 /** 12441 * Filters registered block settings, extending attributes with anchor using ID 12442 * of the first node. 12443 * 12444 * @param {Object} settings Original block settings. 12445 * 12446 * @return {Object} Filtered block settings. 12447 */ 12448 12449 function anchor_addAttribute(settings) { 12450 // Allow blocks to specify their own attribute definition with default values if needed. 12451 if ((0,external_lodash_namespaceObject.has)(settings.attributes, ['anchor', 'type'])) { 12452 return settings; 12453 } 12454 12455 if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'anchor')) { 12456 // Gracefully handle if settings.attributes is undefined. 12457 settings.attributes = { ...settings.attributes, 12458 anchor: ANCHOR_SCHEMA 12459 }; 12460 } 12461 12462 return settings; 12463 } 12464 /** 12465 * Override the default edit UI to include a new block inspector control for 12466 * assigning the anchor ID, if block supports anchor. 12467 * 12468 * @param {WPComponent} BlockEdit Original component. 12469 * 12470 * @return {WPComponent} Wrapped component. 12471 */ 12472 12473 const withInspectorControl = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => { 12474 return props => { 12475 const hasAnchor = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(props.name, 'anchor'); 12476 12477 if (hasAnchor && props.isSelected) { 12478 const isWeb = external_wp_element_namespaceObject.Platform.OS === 'web'; 12479 const textControl = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { 12480 className: "html-anchor-control", 12481 label: (0,external_wp_i18n_namespaceObject.__)('HTML anchor'), 12482 help: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'), isWeb && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, { 12483 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/page-jumps/') 12484 }, (0,external_wp_i18n_namespaceObject.__)('Learn more about anchors'))), 12485 value: props.attributes.anchor || '', 12486 placeholder: !isWeb ? (0,external_wp_i18n_namespaceObject.__)('Add an anchor') : null, 12487 onChange: nextValue => { 12488 nextValue = nextValue.replace(ANCHOR_REGEX, '-'); 12489 props.setAttributes({ 12490 anchor: nextValue 12491 }); 12492 }, 12493 autoCapitalize: "none", 12494 autoComplete: "off" 12495 }); 12496 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), isWeb && (0,external_wp_element_namespaceObject.createElement)(inspector_controls, { 12497 __experimentalGroup: "advanced" 12498 }, textControl), !isWeb && props.name === 'core/heading' && (0,external_wp_element_namespaceObject.createElement)(inspector_controls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, { 12499 title: (0,external_wp_i18n_namespaceObject.__)('Heading settings') 12500 }, textControl))); 12501 } 12502 12503 return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props); 12504 }; 12505 }, 'withInspectorControl'); 12506 /** 12507 * Override props assigned to save component to inject anchor ID, if block 12508 * supports anchor. This is only applied if the block's save result is an 12509 * element and not a markup string. 12510 * 12511 * @param {Object} extraProps Additional props applied to save element. 12512 * @param {Object} blockType Block type. 12513 * @param {Object} attributes Current block attributes. 12514 * 12515 * @return {Object} Filtered props applied to save element. 12516 */ 12517 12518 function addSaveProps(extraProps, blockType, attributes) { 12519 if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'anchor')) { 12520 extraProps.id = attributes.anchor === '' ? null : attributes.anchor; 12521 } 12522 12523 return extraProps; 12524 } 12525 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/anchor/attribute', anchor_addAttribute); 12526 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/anchor/with-inspector-control', withInspectorControl); 12527 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/anchor/save-props', addSaveProps); 12528 12529 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/custom-class-name.js 12530 12531 12532 /** 12533 * External dependencies 12534 */ 12535 12536 /** 12537 * WordPress dependencies 12538 */ 12539 12540 12541 12542 12543 12544 12545 /** 12546 * Internal dependencies 12547 */ 12548 12549 12550 /** 12551 * Filters registered block settings, extending attributes with anchor using ID 12552 * of the first node. 12553 * 12554 * @param {Object} settings Original block settings. 12555 * 12556 * @return {Object} Filtered block settings. 12557 */ 12558 12559 function custom_class_name_addAttribute(settings) { 12560 if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'customClassName', true)) { 12561 // Gracefully handle if settings.attributes is undefined. 12562 settings.attributes = { ...settings.attributes, 12563 className: { 12564 type: 'string' 12565 } 12566 }; 12567 } 12568 12569 return settings; 12570 } 12571 /** 12572 * Override the default edit UI to include a new block inspector control for 12573 * assigning the custom class name, if block supports custom class name. 12574 * 12575 * @param {WPComponent} BlockEdit Original component. 12576 * 12577 * @return {WPComponent} Wrapped component. 12578 */ 12579 12580 const custom_class_name_withInspectorControl = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => { 12581 return props => { 12582 const hasCustomClassName = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(props.name, 'customClassName', true); 12583 12584 if (hasCustomClassName && props.isSelected) { 12585 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), (0,external_wp_element_namespaceObject.createElement)(inspector_controls, { 12586 __experimentalGroup: "advanced" 12587 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { 12588 autoComplete: "off", 12589 label: (0,external_wp_i18n_namespaceObject.__)('Additional CSS class(es)'), 12590 value: props.attributes.className || '', 12591 onChange: nextValue => { 12592 props.setAttributes({ 12593 className: nextValue !== '' ? nextValue : undefined 12594 }); 12595 }, 12596 help: (0,external_wp_i18n_namespaceObject.__)('Separate multiple classes with spaces.') 12597 }))); 12598 } 12599 12600 return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props); 12601 }; 12602 }, 'withInspectorControl'); 12603 /** 12604 * Override props assigned to save component to inject anchor ID, if block 12605 * supports anchor. This is only applied if the block's save result is an 12606 * element and not a markup string. 12607 * 12608 * @param {Object} extraProps Additional props applied to save element. 12609 * @param {Object} blockType Block type. 12610 * @param {Object} attributes Current block attributes. 12611 * 12612 * @return {Object} Filtered props applied to save element. 12613 */ 12614 12615 function custom_class_name_addSaveProps(extraProps, blockType, attributes) { 12616 if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'customClassName', true) && attributes.className) { 12617 extraProps.className = classnames_default()(extraProps.className, attributes.className); 12618 } 12619 12620 return extraProps; 12621 } 12622 function addTransforms(result, source, index, results) { 12623 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(result.name, 'customClassName', true)) { 12624 return result; 12625 } // If the condition verifies we are probably in the presence of a wrapping transform 12626 // e.g: nesting paragraphs in a group or columns and in that case the class should not be kept. 12627 12628 12629 if (results.length === 1 && result.innerBlocks.length === source.length) { 12630 return result; 12631 } // If we are transforming one block to multiple blocks or multiple blocks to one block, 12632 // we ignore the class during the transform. 12633 12634 12635 if (results.length === 1 && source.length > 1 || results.length > 1 && source.length === 1) { 12636 return result; 12637 } // If we are in presence of transform between one or more block in the source 12638 // that have one or more blocks in the result 12639 // we apply the class on source N to the result N, 12640 // if source N does not exists we do nothing. 12641 12642 12643 if (source[index]) { 12644 var _source$index; 12645 12646 const originClassName = (_source$index = source[index]) === null || _source$index === void 0 ? void 0 : _source$index.attributes.className; 12647 12648 if (originClassName) { 12649 return { ...result, 12650 attributes: { ...result.attributes, 12651 className: originClassName 12652 } 12653 }; 12654 } 12655 } 12656 12657 return result; 12658 } 12659 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/custom-class-name/attribute', custom_class_name_addAttribute); 12660 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/custom-class-name/with-inspector-control', custom_class_name_withInspectorControl); 12661 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/custom-class-name/save-props', custom_class_name_addSaveProps); 12662 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.switchToBlockType.transformedBlock', 'core/color/addTransforms', addTransforms); 12663 12664 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/generated-class-name.js 12665 /** 12666 * External dependencies 12667 */ 12668 12669 /** 12670 * WordPress dependencies 12671 */ 12672 12673 12674 12675 /** 12676 * Override props assigned to save component to inject generated className if 12677 * block supports it. This is only applied if the block's save result is an 12678 * element and not a markup string. 12679 * 12680 * @param {Object} extraProps Additional props applied to save element. 12681 * @param {Object} blockType Block type. 12682 * 12683 * @return {Object} Filtered props applied to save element. 12684 */ 12685 12686 function addGeneratedClassName(extraProps, blockType) { 12687 // Adding the generated className. 12688 if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'className', true)) { 12689 if (typeof extraProps.className === 'string') { 12690 // We have some extra classes and want to add the default classname 12691 // We use uniq to prevent duplicate classnames. 12692 extraProps.className = (0,external_lodash_namespaceObject.uniq)([(0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(blockType.name), ...extraProps.className.split(' ')]).join(' ').trim(); 12693 } else { 12694 // There is no string in the className variable, 12695 // so we just dump the default name in there. 12696 extraProps.className = (0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(blockType.name); 12697 } 12698 } 12699 12700 return extraProps; 12701 } 12702 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/generated-class-name/save-props', addGeneratedClassName); 12703 12704 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/utils.js 12705 /** 12706 * External dependencies 12707 */ 12708 12709 /** 12710 * Internal dependencies 12711 */ 12712 12713 function generateBoxRules(style, options, path, ruleKey) { 12714 const boxStyle = (0,external_lodash_namespaceObject.get)(style, path); 12715 12716 if (!boxStyle) { 12717 return []; 12718 } 12719 12720 const rules = []; 12721 12722 if (typeof boxStyle === 'string') { 12723 rules.push({ 12724 selector: options.selector, 12725 key: ruleKey, 12726 value: boxStyle 12727 }); 12728 } else { 12729 const sideRules = ['top', 'right', 'bottom', 'left'].reduce((acc, side) => { 12730 const value = (0,external_lodash_namespaceObject.get)(boxStyle, [side]); 12731 12732 if (value) { 12733 acc.push({ 12734 selector: options.selector, 12735 key: `$ruleKey}${(0,external_lodash_namespaceObject.upperFirst)(side)}`, 12736 value 12737 }); 12738 } 12739 12740 return acc; 12741 }, []); 12742 rules.push(...sideRules); 12743 } 12744 12745 return rules; 12746 } 12747 12748 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/padding.js 12749 /** 12750 * Internal dependencies 12751 */ 12752 12753 const padding = { 12754 name: 'padding', 12755 generate: (style, options) => { 12756 return generateBoxRules(style, options, ['spacing', 'padding'], 'padding'); 12757 } 12758 }; 12759 /* harmony default export */ var styles_padding = (padding); 12760 12761 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/margin.js 12762 /** 12763 * Internal dependencies 12764 */ 12765 12766 const margin = { 12767 name: 'margin', 12768 generate: (style, options) => { 12769 return generateBoxRules(style, options, ['spacing', 'margin'], 'margin'); 12770 } 12771 }; 12772 /* harmony default export */ var styles_margin = (margin); 12773 12774 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/index.js 12775 /** 12776 * Internal dependencies 12777 */ 12778 12779 12780 const styleDefinitions = [styles_margin, styles_padding]; 12781 12782 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/index.js 12783 /** 12784 * External dependencies 12785 */ 12786 12787 /** 12788 * Internal dependencies 12789 */ 12790 12791 12792 /** 12793 * Generates a stylesheet for a given style object and selector. 12794 * 12795 * @param style Style object. 12796 * @param options Options object with settings to adjust how the styles are generated. 12797 * 12798 * @return generated stylesheet. 12799 */ 12800 12801 function generate(style, options) { 12802 const rules = getCSSRules(style, options); 12803 const groupedRules = groupBy(rules, 'selector'); 12804 const selectorRules = Object.keys(groupedRules).reduce((acc, subSelector) => { 12805 acc.push(`$subSelector} { $groupedRules[subSelector].map(rule => `$kebabCase(rule.key)}: $rule.value};`).join(' ')} }`); 12806 return acc; 12807 }, []); 12808 return selectorRules.join('\n'); 12809 } 12810 /** 12811 * Returns a JSON representation of the generated CSS rules. 12812 * 12813 * @param style Style object. 12814 * @param options Options object with settings to adjust how the styles are generated. 12815 * 12816 * @return generated styles. 12817 */ 12818 12819 function getCSSRules(style, options) { 12820 const rules = []; 12821 styleDefinitions.forEach(definition => { 12822 rules.push(...definition.generate(style, options)); 12823 }); 12824 return rules; 12825 } 12826 12827 ;// CONCATENATED MODULE: external ["wp","dom"] 12828 var external_wp_dom_namespaceObject = window["wp"]["dom"]; 12829 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-context/index.js 12830 12831 12832 /** 12833 * WordPress dependencies 12834 */ 12835 12836 /** @typedef {import('react').ReactNode} ReactNode */ 12837 12838 /** 12839 * @typedef BlockContextProviderProps 12840 * 12841 * @property {Record<string,*>} value Context value to merge with current 12842 * value. 12843 * @property {ReactNode} children Component children. 12844 */ 12845 12846 /** @type {import('react').Context<Record<string,*>>} */ 12847 12848 const block_context_Context = (0,external_wp_element_namespaceObject.createContext)({}); 12849 /** 12850 * Component which merges passed value with current consumed block context. 12851 * 12852 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-context/README.md 12853 * 12854 * @param {BlockContextProviderProps} props 12855 */ 12856 12857 function BlockContextProvider(_ref) { 12858 let { 12859 value, 12860 children 12861 } = _ref; 12862 const context = (0,external_wp_element_namespaceObject.useContext)(block_context_Context); 12863 const nextValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...context, 12864 ...value 12865 }), [context, value]); 12866 return (0,external_wp_element_namespaceObject.createElement)(block_context_Context.Provider, { 12867 value: nextValue, 12868 children: children 12869 }); 12870 } 12871 /* harmony default export */ var block_context = (block_context_Context); 12872 12873 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/edit.js 12874 12875 12876 12877 /** 12878 * External dependencies 12879 */ 12880 12881 12882 /** 12883 * WordPress dependencies 12884 */ 12885 12886 12887 12888 12889 /** 12890 * Internal dependencies 12891 */ 12892 12893 12894 /** 12895 * Default value used for blocks which do not define their own context needs, 12896 * used to guarantee that a block's `context` prop will always be an object. It 12897 * is assigned as a constant since it is always expected to be an empty object, 12898 * and in order to avoid unnecessary React reconciliations of a changing object. 12899 * 12900 * @type {{}} 12901 */ 12902 12903 const DEFAULT_BLOCK_CONTEXT = {}; 12904 const Edit = props => { 12905 const { 12906 attributes = {}, 12907 name 12908 } = props; 12909 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name); 12910 const blockContext = (0,external_wp_element_namespaceObject.useContext)(block_context); // Assign context values using the block type's declared context needs. 12911 12912 const context = (0,external_wp_element_namespaceObject.useMemo)(() => { 12913 return blockType && blockType.usesContext ? (0,external_lodash_namespaceObject.pick)(blockContext, blockType.usesContext) : DEFAULT_BLOCK_CONTEXT; 12914 }, [blockType, blockContext]); 12915 12916 if (!blockType) { 12917 return null; 12918 } // `edit` and `save` are functions or components describing the markup 12919 // with which a block is displayed. If `blockType` is valid, assign 12920 // them preferentially as the render value for the block. 12921 12922 12923 const Component = blockType.edit || blockType.save; 12924 12925 if (blockType.apiVersion > 1) { 12926 return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({}, props, { 12927 context: context 12928 })); 12929 } // Generate a class name for the block's editable form. 12930 12931 12932 const generatedClassName = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'className', true) ? (0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(name) : null; 12933 const className = classnames_default()(generatedClassName, attributes.className); 12934 return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({}, props, { 12935 context: context, 12936 className: className 12937 })); 12938 }; 12939 /* harmony default export */ var edit = ((0,external_wp_components_namespaceObject.withFilters)('editor.BlockEdit')(Edit)); 12940 12941 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/index.js 12942 12943 12944 /** 12945 * WordPress dependencies 12946 */ 12947 12948 /** 12949 * Internal dependencies 12950 */ 12951 12952 12953 12954 /** 12955 * The `useBlockEditContext` hook provides information about the block this hook is being used in. 12956 * It returns an object with the `name`, `isSelected` state, and the `clientId` of the block. 12957 * It is useful if you want to create custom hooks that need access to the current blocks clientId 12958 * but don't want to rely on the data getting passed in as a parameter. 12959 * 12960 * @return {Object} Block edit context 12961 */ 12962 12963 12964 function BlockEdit(props) { 12965 const { 12966 name, 12967 isSelected, 12968 clientId 12969 } = props; 12970 const context = { 12971 name, 12972 isSelected, 12973 clientId 12974 }; 12975 return (0,external_wp_element_namespaceObject.createElement)(Provider // It is important to return the same object if props haven't 12976 // changed to avoid unnecessary rerenders. 12977 // See https://reactjs.org/docs/context.html#caveats. 12978 , { 12979 value: (0,external_wp_element_namespaceObject.useMemo)(() => context, Object.values(context)) 12980 }, (0,external_wp_element_namespaceObject.createElement)(edit, props)); 12981 } 12982 12983 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/more-horizontal.js 12984 12985 12986 /** 12987 * WordPress dependencies 12988 */ 12989 12990 const moreHorizontal = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 12991 xmlns: "http://www.w3.org/2000/svg", 12992 viewBox: "0 0 24 24" 12993 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 12994 d: "M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z" 12995 })); 12996 /* harmony default export */ var more_horizontal = (moreHorizontal); 12997 12998 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/warning/index.js 12999 13000 13001 /** 13002 * External dependencies 13003 */ 13004 13005 /** 13006 * WordPress dependencies 13007 */ 13008 13009 13010 13011 13012 13013 13014 function Warning(_ref) { 13015 let { 13016 className, 13017 actions, 13018 children, 13019 secondaryActions 13020 } = _ref; 13021 return (0,external_wp_element_namespaceObject.createElement)("div", { 13022 className: classnames_default()(className, 'block-editor-warning') 13023 }, (0,external_wp_element_namespaceObject.createElement)("div", { 13024 className: "block-editor-warning__contents" 13025 }, (0,external_wp_element_namespaceObject.createElement)("p", { 13026 className: "block-editor-warning__message" 13027 }, children), (external_wp_element_namespaceObject.Children.count(actions) > 0 || secondaryActions) && (0,external_wp_element_namespaceObject.createElement)("div", { 13028 className: "block-editor-warning__actions" 13029 }, external_wp_element_namespaceObject.Children.count(actions) > 0 && external_wp_element_namespaceObject.Children.map(actions, (action, i) => (0,external_wp_element_namespaceObject.createElement)("span", { 13030 key: i, 13031 className: "block-editor-warning__action" 13032 }, action)), secondaryActions && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 13033 className: "block-editor-warning__secondary", 13034 icon: more_horizontal, 13035 label: (0,external_wp_i18n_namespaceObject.__)('More options'), 13036 popoverProps: { 13037 position: 'bottom left', 13038 className: 'block-editor-warning__dropdown' 13039 }, 13040 noIcons: true 13041 }, () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, secondaryActions.map((item, pos) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 13042 onClick: item.onClick, 13043 key: pos 13044 }, item.title))))))); 13045 } 13046 /** 13047 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md 13048 */ 13049 13050 13051 /* harmony default export */ var warning = (Warning); 13052 13053 // EXTERNAL MODULE: ./node_modules/diff/lib/diff/character.js 13054 var character = __webpack_require__(1973); 13055 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-compare/block-view.js 13056 13057 13058 /** 13059 * WordPress dependencies 13060 */ 13061 13062 13063 13064 function BlockView(_ref) { 13065 let { 13066 title, 13067 rawContent, 13068 renderedContent, 13069 action, 13070 actionText, 13071 className 13072 } = _ref; 13073 return (0,external_wp_element_namespaceObject.createElement)("div", { 13074 className: className 13075 }, (0,external_wp_element_namespaceObject.createElement)("div", { 13076 className: "block-editor-block-compare__content" 13077 }, (0,external_wp_element_namespaceObject.createElement)("h2", { 13078 className: "block-editor-block-compare__heading" 13079 }, title), (0,external_wp_element_namespaceObject.createElement)("div", { 13080 className: "block-editor-block-compare__html" 13081 }, rawContent), (0,external_wp_element_namespaceObject.createElement)("div", { 13082 className: "block-editor-block-compare__preview edit-post-visual-editor" 13083 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, (0,external_wp_dom_namespaceObject.safeHTML)(renderedContent)))), (0,external_wp_element_namespaceObject.createElement)("div", { 13084 className: "block-editor-block-compare__action" 13085 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 13086 variant: "secondary", 13087 tabIndex: "0", 13088 onClick: action 13089 }, actionText))); 13090 } 13091 13092 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-compare/index.js 13093 13094 13095 /** 13096 * External dependencies 13097 */ 13098 13099 // diff doesn't tree-shake correctly, so we import from the individual 13100 // module here, to avoid including too much of the library 13101 13102 13103 /** 13104 * WordPress dependencies 13105 */ 13106 13107 13108 13109 /** 13110 * Internal dependencies 13111 */ 13112 13113 13114 13115 function BlockCompare(_ref) { 13116 let { 13117 block, 13118 onKeep, 13119 onConvert, 13120 convertor, 13121 convertButtonText 13122 } = _ref; 13123 13124 function getDifference(originalContent, newContent) { 13125 const difference = (0,character/* diffChars */.Kx)(originalContent, newContent); 13126 return difference.map((item, pos) => { 13127 const classes = classnames_default()({ 13128 'block-editor-block-compare__added': item.added, 13129 'block-editor-block-compare__removed': item.removed 13130 }); 13131 return (0,external_wp_element_namespaceObject.createElement)("span", { 13132 key: pos, 13133 className: classes 13134 }, item.value); 13135 }); 13136 } 13137 13138 function getConvertedContent(convertedBlock) { 13139 // The convertor may return an array of items or a single item. 13140 const newBlocks = (0,external_lodash_namespaceObject.castArray)(convertedBlock); // Get converted block details. 13141 13142 const newContent = newBlocks.map(item => (0,external_wp_blocks_namespaceObject.getSaveContent)(item.name, item.attributes, item.innerBlocks)); 13143 return newContent.join(''); 13144 } 13145 13146 const converted = getConvertedContent(convertor(block)); 13147 const difference = getDifference(block.originalContent, converted); 13148 return (0,external_wp_element_namespaceObject.createElement)("div", { 13149 className: "block-editor-block-compare__wrapper" 13150 }, (0,external_wp_element_namespaceObject.createElement)(BlockView, { 13151 title: (0,external_wp_i18n_namespaceObject.__)('Current'), 13152 className: "block-editor-block-compare__current", 13153 action: onKeep, 13154 actionText: (0,external_wp_i18n_namespaceObject.__)('Convert to HTML'), 13155 rawContent: block.originalContent, 13156 renderedContent: block.originalContent 13157 }), (0,external_wp_element_namespaceObject.createElement)(BlockView, { 13158 title: (0,external_wp_i18n_namespaceObject.__)('After Conversion'), 13159 className: "block-editor-block-compare__converted", 13160 action: onConvert, 13161 actionText: convertButtonText, 13162 rawContent: difference, 13163 renderedContent: converted 13164 })); 13165 } 13166 13167 /* harmony default export */ var block_compare = (BlockCompare); 13168 13169 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-invalid-warning.js 13170 13171 13172 /** 13173 * WordPress dependencies 13174 */ 13175 13176 13177 13178 13179 13180 13181 /** 13182 * Internal dependencies 13183 */ 13184 13185 13186 13187 13188 function BlockInvalidWarning(_ref) { 13189 let { 13190 convertToHTML, 13191 convertToBlocks, 13192 convertToClassic, 13193 attemptBlockRecovery, 13194 block 13195 } = _ref; 13196 const hasHTMLBlock = !!(0,external_wp_blocks_namespaceObject.getBlockType)('core/html'); 13197 const [compare, setCompare] = (0,external_wp_element_namespaceObject.useState)(false); 13198 const onCompare = (0,external_wp_element_namespaceObject.useCallback)(() => setCompare(true), []); 13199 const onCompareClose = (0,external_wp_element_namespaceObject.useCallback)(() => setCompare(false), []); // We memo the array here to prevent the children components from being updated unexpectedly. 13200 13201 const hiddenActions = (0,external_wp_element_namespaceObject.useMemo)(() => [{ 13202 // translators: Button to fix block content 13203 title: (0,external_wp_i18n_namespaceObject._x)('Resolve', 'imperative verb'), 13204 onClick: onCompare 13205 }, hasHTMLBlock && { 13206 title: (0,external_wp_i18n_namespaceObject.__)('Convert to HTML'), 13207 onClick: convertToHTML 13208 }, { 13209 title: (0,external_wp_i18n_namespaceObject.__)('Convert to Classic Block'), 13210 onClick: convertToClassic 13211 }].filter(Boolean), [onCompare, convertToHTML, convertToClassic]); 13212 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(warning, { 13213 actions: [(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 13214 key: "recover", 13215 onClick: attemptBlockRecovery, 13216 variant: "primary" 13217 }, (0,external_wp_i18n_namespaceObject.__)('Attempt Block Recovery'))], 13218 secondaryActions: hiddenActions 13219 }, (0,external_wp_i18n_namespaceObject.__)('This block contains unexpected or invalid content.')), compare && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { 13220 title: // translators: Dialog title to fix block content 13221 (0,external_wp_i18n_namespaceObject.__)('Resolve Block'), 13222 onRequestClose: onCompareClose, 13223 className: "block-editor-block-compare" 13224 }, (0,external_wp_element_namespaceObject.createElement)(block_compare, { 13225 block: block, 13226 onKeep: convertToHTML, 13227 onConvert: convertToBlocks, 13228 convertor: blockToBlocks, 13229 convertButtonText: (0,external_wp_i18n_namespaceObject.__)('Convert to Blocks') 13230 }))); 13231 } 13232 13233 const blockToClassic = block => (0,external_wp_blocks_namespaceObject.createBlock)('core/freeform', { 13234 content: block.originalContent 13235 }); 13236 13237 const blockToHTML = block => (0,external_wp_blocks_namespaceObject.createBlock)('core/html', { 13238 content: block.originalContent 13239 }); 13240 13241 const blockToBlocks = block => (0,external_wp_blocks_namespaceObject.rawHandler)({ 13242 HTML: block.originalContent 13243 }); 13244 13245 const recoverBlock = _ref2 => { 13246 let { 13247 name, 13248 attributes, 13249 innerBlocks 13250 } = _ref2; 13251 return (0,external_wp_blocks_namespaceObject.createBlock)(name, attributes, innerBlocks); 13252 }; 13253 13254 /* harmony default export */ var block_invalid_warning = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, _ref3) => { 13255 let { 13256 clientId 13257 } = _ref3; 13258 return { 13259 block: select(store).getBlock(clientId) 13260 }; 13261 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref4) => { 13262 let { 13263 block 13264 } = _ref4; 13265 const { 13266 replaceBlock 13267 } = dispatch(store); 13268 return { 13269 convertToClassic() { 13270 replaceBlock(block.clientId, blockToClassic(block)); 13271 }, 13272 13273 convertToHTML() { 13274 replaceBlock(block.clientId, blockToHTML(block)); 13275 }, 13276 13277 convertToBlocks() { 13278 replaceBlock(block.clientId, blockToBlocks(block)); 13279 }, 13280 13281 attemptBlockRecovery() { 13282 replaceBlock(block.clientId, recoverBlock(block)); 13283 } 13284 13285 }; 13286 })])(BlockInvalidWarning)); 13287 13288 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-crash-warning.js 13289 13290 13291 /** 13292 * WordPress dependencies 13293 */ 13294 13295 /** 13296 * Internal dependencies 13297 */ 13298 13299 13300 const block_crash_warning_warning = (0,external_wp_element_namespaceObject.createElement)(warning, { 13301 className: "block-editor-block-list__block-crash-warning" 13302 }, (0,external_wp_i18n_namespaceObject.__)('This block has encountered an error and cannot be previewed.')); 13303 /* harmony default export */ var block_crash_warning = (() => block_crash_warning_warning); 13304 13305 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-crash-boundary.js 13306 /** 13307 * WordPress dependencies 13308 */ 13309 13310 13311 class BlockCrashBoundary extends external_wp_element_namespaceObject.Component { 13312 constructor() { 13313 super(...arguments); 13314 this.state = { 13315 hasError: false 13316 }; 13317 } 13318 13319 componentDidCatch() { 13320 this.setState({ 13321 hasError: true 13322 }); 13323 } 13324 13325 render() { 13326 if (this.state.hasError) { 13327 return this.props.fallback; 13328 } 13329 13330 return this.props.children; 13331 } 13332 13333 } 13334 13335 /* harmony default export */ var block_crash_boundary = (BlockCrashBoundary); 13336 13337 // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js 13338 var lib = __webpack_require__(773); 13339 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-html.js 13340 13341 13342 /** 13343 * External dependencies 13344 */ 13345 13346 /** 13347 * WordPress dependencies 13348 */ 13349 13350 13351 13352 13353 /** 13354 * Internal dependencies 13355 */ 13356 13357 13358 13359 function BlockHTML(_ref) { 13360 let { 13361 clientId 13362 } = _ref; 13363 const [html, setHtml] = (0,external_wp_element_namespaceObject.useState)(''); 13364 const block = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlock(clientId), [clientId]); 13365 const { 13366 updateBlock 13367 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 13368 13369 const onChange = () => { 13370 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name); 13371 13372 if (!blockType) { 13373 return; 13374 } 13375 13376 const attributes = (0,external_wp_blocks_namespaceObject.getBlockAttributes)(blockType, html, block.attributes); // If html is empty we reset the block to the default HTML and mark it as valid to avoid triggering an error 13377 13378 const content = html ? html : (0,external_wp_blocks_namespaceObject.getSaveContent)(blockType, attributes); 13379 const [isValid] = html ? (0,external_wp_blocks_namespaceObject.validateBlock)({ ...block, 13380 attributes, 13381 originalContent: content 13382 }) : [true]; 13383 updateBlock(clientId, { 13384 attributes, 13385 originalContent: content, 13386 isValid 13387 }); // Ensure the state is updated if we reset so it displays the default content. 13388 13389 if (!html) { 13390 setHtml({ 13391 content 13392 }); 13393 } 13394 }; 13395 13396 (0,external_wp_element_namespaceObject.useEffect)(() => { 13397 setHtml((0,external_wp_blocks_namespaceObject.getBlockContent)(block)); 13398 }, [block]); 13399 return (0,external_wp_element_namespaceObject.createElement)(lib/* default */.Z, { 13400 className: "block-editor-block-list__block-html-textarea", 13401 value: html, 13402 onBlur: onChange, 13403 onChange: event => setHtml(event.target.value) 13404 }); 13405 } 13406 13407 /* harmony default export */ var block_html = (BlockHTML); 13408 13409 ;// CONCATENATED MODULE: ./node_modules/@react-spring/rafz/dist/react-spring-rafz.esm.js 13410 let updateQueue = makeQueue(); 13411 const raf = fn => schedule(fn, updateQueue); 13412 let writeQueue = makeQueue(); 13413 13414 raf.write = fn => schedule(fn, writeQueue); 13415 13416 let onStartQueue = makeQueue(); 13417 13418 raf.onStart = fn => schedule(fn, onStartQueue); 13419 13420 let onFrameQueue = makeQueue(); 13421 13422 raf.onFrame = fn => schedule(fn, onFrameQueue); 13423 13424 let onFinishQueue = makeQueue(); 13425 13426 raf.onFinish = fn => schedule(fn, onFinishQueue); 13427 13428 let timeouts = []; 13429 13430 raf.setTimeout = (handler, ms) => { 13431 let time = raf.now() + ms; 13432 13433 let cancel = () => { 13434 let i = timeouts.findIndex(t => t.cancel == cancel); 13435 if (~i) timeouts.splice(i, 1); 13436 pendingCount -= ~i ? 1 : 0; 13437 }; 13438 13439 let timeout = { 13440 time, 13441 handler, 13442 cancel 13443 }; 13444 timeouts.splice(findTimeout(time), 0, timeout); 13445 pendingCount += 1; 13446 start(); 13447 return timeout; 13448 }; 13449 13450 let findTimeout = time => ~(~timeouts.findIndex(t => t.time > time) || ~timeouts.length); 13451 13452 raf.cancel = fn => { 13453 onStartQueue.delete(fn); 13454 onFrameQueue.delete(fn); 13455 updateQueue.delete(fn); 13456 writeQueue.delete(fn); 13457 onFinishQueue.delete(fn); 13458 }; 13459 13460 raf.sync = fn => { 13461 sync = true; 13462 raf.batchedUpdates(fn); 13463 sync = false; 13464 }; 13465 13466 raf.throttle = fn => { 13467 let lastArgs; 13468 13469 function queuedFn() { 13470 try { 13471 fn(...lastArgs); 13472 } finally { 13473 lastArgs = null; 13474 } 13475 } 13476 13477 function throttled(...args) { 13478 lastArgs = args; 13479 raf.onStart(queuedFn); 13480 } 13481 13482 throttled.handler = fn; 13483 13484 throttled.cancel = () => { 13485 onStartQueue.delete(queuedFn); 13486 lastArgs = null; 13487 }; 13488 13489 return throttled; 13490 }; 13491 13492 let nativeRaf = typeof window != 'undefined' ? window.requestAnimationFrame : () => {}; 13493 13494 raf.use = impl => nativeRaf = impl; 13495 13496 raf.now = typeof performance != 'undefined' ? () => performance.now() : Date.now; 13497 13498 raf.batchedUpdates = fn => fn(); 13499 13500 raf.catch = console.error; 13501 raf.frameLoop = 'always'; 13502 13503 raf.advance = () => { 13504 if (raf.frameLoop !== 'demand') { 13505 console.warn('Cannot call the manual advancement of rafz whilst frameLoop is not set as demand'); 13506 } else { 13507 update(); 13508 } 13509 }; 13510 13511 let ts = -1; 13512 let pendingCount = 0; 13513 let sync = false; 13514 13515 function schedule(fn, queue) { 13516 if (sync) { 13517 queue.delete(fn); 13518 fn(0); 13519 } else { 13520 queue.add(fn); 13521 start(); 13522 } 13523 } 13524 13525 function start() { 13526 if (ts < 0) { 13527 ts = 0; 13528 13529 if (raf.frameLoop !== 'demand') { 13530 nativeRaf(loop); 13531 } 13532 } 13533 } 13534 13535 function stop() { 13536 ts = -1; 13537 } 13538 13539 function loop() { 13540 if (~ts) { 13541 nativeRaf(loop); 13542 raf.batchedUpdates(update); 13543 } 13544 } 13545 13546 function update() { 13547 let prevTs = ts; 13548 ts = raf.now(); 13549 let count = findTimeout(ts); 13550 13551 if (count) { 13552 eachSafely(timeouts.splice(0, count), t => t.handler()); 13553 pendingCount -= count; 13554 } 13555 13556 onStartQueue.flush(); 13557 updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667); 13558 onFrameQueue.flush(); 13559 writeQueue.flush(); 13560 onFinishQueue.flush(); 13561 13562 if (!pendingCount) { 13563 stop(); 13564 } 13565 } 13566 13567 function makeQueue() { 13568 let next = new Set(); 13569 let current = next; 13570 return { 13571 add(fn) { 13572 pendingCount += current == next && !next.has(fn) ? 1 : 0; 13573 next.add(fn); 13574 }, 13575 13576 delete(fn) { 13577 pendingCount -= current == next && next.has(fn) ? 1 : 0; 13578 return next.delete(fn); 13579 }, 13580 13581 flush(arg) { 13582 if (current.size) { 13583 next = new Set(); 13584 pendingCount -= current.size; 13585 eachSafely(current, fn => fn(arg) && next.add(fn)); 13586 pendingCount += next.size; 13587 current = next; 13588 } 13589 } 13590 13591 }; 13592 } 13593 13594 function eachSafely(values, each) { 13595 values.forEach(value => { 13596 try { 13597 each(value); 13598 } catch (e) { 13599 raf.catch(e); 13600 } 13601 }); 13602 } 13603 13604 const __raf = { 13605 count() { 13606 return pendingCount; 13607 }, 13608 13609 isRunning() { 13610 return ts >= 0; 13611 }, 13612 13613 clear() { 13614 ts = -1; 13615 timeouts = []; 13616 onStartQueue = makeQueue(); 13617 updateQueue = makeQueue(); 13618 onFrameQueue = makeQueue(); 13619 writeQueue = makeQueue(); 13620 onFinishQueue = makeQueue(); 13621 pendingCount = 0; 13622 } 13623 13624 }; 13625 13626 13627 13628 // EXTERNAL MODULE: external "React" 13629 var external_React_ = __webpack_require__(9196); 13630 var external_React_default = /*#__PURE__*/__webpack_require__.n(external_React_); 13631 ;// CONCATENATED MODULE: ./node_modules/@react-spring/shared/dist/react-spring-shared.esm.js 13632 13633 13634 13635 13636 13637 function noop() {} 13638 const defineHidden = (obj, key, value) => Object.defineProperty(obj, key, { 13639 value, 13640 writable: true, 13641 configurable: true 13642 }); 13643 const react_spring_shared_esm_is = { 13644 arr: Array.isArray, 13645 obj: a => !!a && a.constructor.name === 'Object', 13646 fun: a => typeof a === 'function', 13647 str: a => typeof a === 'string', 13648 num: a => typeof a === 'number', 13649 und: a => a === undefined 13650 }; 13651 function isEqual(a, b) { 13652 if (react_spring_shared_esm_is.arr(a)) { 13653 if (!react_spring_shared_esm_is.arr(b) || a.length !== b.length) return false; 13654 13655 for (let i = 0; i < a.length; i++) { 13656 if (a[i] !== b[i]) return false; 13657 } 13658 13659 return true; 13660 } 13661 13662 return a === b; 13663 } 13664 const react_spring_shared_esm_each = (obj, fn) => obj.forEach(fn); 13665 function eachProp(obj, fn, ctx) { 13666 if (react_spring_shared_esm_is.arr(obj)) { 13667 for (let i = 0; i < obj.length; i++) { 13668 fn.call(ctx, obj[i], `$i}`); 13669 } 13670 13671 return; 13672 } 13673 13674 for (const key in obj) { 13675 if (obj.hasOwnProperty(key)) { 13676 fn.call(ctx, obj[key], key); 13677 } 13678 } 13679 } 13680 const react_spring_shared_esm_toArray = a => react_spring_shared_esm_is.und(a) ? [] : react_spring_shared_esm_is.arr(a) ? a : [a]; 13681 function flush(queue, iterator) { 13682 if (queue.size) { 13683 const items = Array.from(queue); 13684 queue.clear(); 13685 react_spring_shared_esm_each(items, iterator); 13686 } 13687 } 13688 const flushCalls = (queue, ...args) => flush(queue, fn => fn(...args)); 13689 const isSSR = () => typeof window === 'undefined' || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent); 13690 13691 let createStringInterpolator$1; 13692 let to; 13693 let colors$1 = null; 13694 let skipAnimation = false; 13695 let willAdvance = noop; 13696 const react_spring_shared_esm_assign = globals => { 13697 if (globals.to) to = globals.to; 13698 if (globals.now) raf.now = globals.now; 13699 if (globals.colors !== undefined) colors$1 = globals.colors; 13700 if (globals.skipAnimation != null) skipAnimation = globals.skipAnimation; 13701 if (globals.createStringInterpolator) createStringInterpolator$1 = globals.createStringInterpolator; 13702 if (globals.requestAnimationFrame) raf.use(globals.requestAnimationFrame); 13703 if (globals.batchedUpdates) raf.batchedUpdates = globals.batchedUpdates; 13704 if (globals.willAdvance) willAdvance = globals.willAdvance; 13705 if (globals.frameLoop) raf.frameLoop = globals.frameLoop; 13706 }; 13707 13708 var globals = /*#__PURE__*/Object.freeze({ 13709 __proto__: null, 13710 get createStringInterpolator () { return createStringInterpolator$1; }, 13711 get to () { return to; }, 13712 get colors () { return colors$1; }, 13713 get skipAnimation () { return skipAnimation; }, 13714 get willAdvance () { return willAdvance; }, 13715 assign: react_spring_shared_esm_assign 13716 }); 13717 13718 const startQueue = new Set(); 13719 let currentFrame = []; 13720 let prevFrame = []; 13721 let priority = 0; 13722 const frameLoop = { 13723 get idle() { 13724 return !startQueue.size && !currentFrame.length; 13725 }, 13726 13727 start(animation) { 13728 if (priority > animation.priority) { 13729 startQueue.add(animation); 13730 raf.onStart(flushStartQueue); 13731 } else { 13732 startSafely(animation); 13733 raf(advance); 13734 } 13735 }, 13736 13737 advance, 13738 13739 sort(animation) { 13740 if (priority) { 13741 raf.onFrame(() => frameLoop.sort(animation)); 13742 } else { 13743 const prevIndex = currentFrame.indexOf(animation); 13744 13745 if (~prevIndex) { 13746 currentFrame.splice(prevIndex, 1); 13747 startUnsafely(animation); 13748 } 13749 } 13750 }, 13751 13752 clear() { 13753 currentFrame = []; 13754 startQueue.clear(); 13755 } 13756 13757 }; 13758 13759 function flushStartQueue() { 13760 startQueue.forEach(startSafely); 13761 startQueue.clear(); 13762 raf(advance); 13763 } 13764 13765 function startSafely(animation) { 13766 if (!currentFrame.includes(animation)) startUnsafely(animation); 13767 } 13768 13769 function startUnsafely(animation) { 13770 currentFrame.splice(findIndex(currentFrame, other => other.priority > animation.priority), 0, animation); 13771 } 13772 13773 function advance(dt) { 13774 const nextFrame = prevFrame; 13775 13776 for (let i = 0; i < currentFrame.length; i++) { 13777 const animation = currentFrame[i]; 13778 priority = animation.priority; 13779 13780 if (!animation.idle) { 13781 willAdvance(animation); 13782 animation.advance(dt); 13783 13784 if (!animation.idle) { 13785 nextFrame.push(animation); 13786 } 13787 } 13788 } 13789 13790 priority = 0; 13791 prevFrame = currentFrame; 13792 prevFrame.length = 0; 13793 currentFrame = nextFrame; 13794 return currentFrame.length > 0; 13795 } 13796 13797 function findIndex(arr, test) { 13798 const index = arr.findIndex(test); 13799 return index < 0 ? arr.length : index; 13800 } 13801 13802 const colors = { 13803 transparent: 0x00000000, 13804 aliceblue: 0xf0f8ffff, 13805 antiquewhite: 0xfaebd7ff, 13806 aqua: 0x00ffffff, 13807 aquamarine: 0x7fffd4ff, 13808 azure: 0xf0ffffff, 13809 beige: 0xf5f5dcff, 13810 bisque: 0xffe4c4ff, 13811 black: 0x000000ff, 13812 blanchedalmond: 0xffebcdff, 13813 blue: 0x0000ffff, 13814 blueviolet: 0x8a2be2ff, 13815 brown: 0xa52a2aff, 13816 burlywood: 0xdeb887ff, 13817 burntsienna: 0xea7e5dff, 13818 cadetblue: 0x5f9ea0ff, 13819 chartreuse: 0x7fff00ff, 13820 chocolate: 0xd2691eff, 13821 coral: 0xff7f50ff, 13822 cornflowerblue: 0x6495edff, 13823 cornsilk: 0xfff8dcff, 13824 crimson: 0xdc143cff, 13825 cyan: 0x00ffffff, 13826 darkblue: 0x00008bff, 13827 darkcyan: 0x008b8bff, 13828 darkgoldenrod: 0xb8860bff, 13829 darkgray: 0xa9a9a9ff, 13830 darkgreen: 0x006400ff, 13831 darkgrey: 0xa9a9a9ff, 13832 darkkhaki: 0xbdb76bff, 13833 darkmagenta: 0x8b008bff, 13834 darkolivegreen: 0x556b2fff, 13835 darkorange: 0xff8c00ff, 13836 darkorchid: 0x9932ccff, 13837 darkred: 0x8b0000ff, 13838 darksalmon: 0xe9967aff, 13839 darkseagreen: 0x8fbc8fff, 13840 darkslateblue: 0x483d8bff, 13841 darkslategray: 0x2f4f4fff, 13842 darkslategrey: 0x2f4f4fff, 13843 darkturquoise: 0x00ced1ff, 13844 darkviolet: 0x9400d3ff, 13845 deeppink: 0xff1493ff, 13846 deepskyblue: 0x00bfffff, 13847 dimgray: 0x696969ff, 13848 dimgrey: 0x696969ff, 13849 dodgerblue: 0x1e90ffff, 13850 firebrick: 0xb22222ff, 13851 floralwhite: 0xfffaf0ff, 13852 forestgreen: 0x228b22ff, 13853 fuchsia: 0xff00ffff, 13854 gainsboro: 0xdcdcdcff, 13855 ghostwhite: 0xf8f8ffff, 13856 gold: 0xffd700ff, 13857 goldenrod: 0xdaa520ff, 13858 gray: 0x808080ff, 13859 green: 0x008000ff, 13860 greenyellow: 0xadff2fff, 13861 grey: 0x808080ff, 13862 honeydew: 0xf0fff0ff, 13863 hotpink: 0xff69b4ff, 13864 indianred: 0xcd5c5cff, 13865 indigo: 0x4b0082ff, 13866 ivory: 0xfffff0ff, 13867 khaki: 0xf0e68cff, 13868 lavender: 0xe6e6faff, 13869 lavenderblush: 0xfff0f5ff, 13870 lawngreen: 0x7cfc00ff, 13871 lemonchiffon: 0xfffacdff, 13872 lightblue: 0xadd8e6ff, 13873 lightcoral: 0xf08080ff, 13874 lightcyan: 0xe0ffffff, 13875 lightgoldenrodyellow: 0xfafad2ff, 13876 lightgray: 0xd3d3d3ff, 13877 lightgreen: 0x90ee90ff, 13878 lightgrey: 0xd3d3d3ff, 13879 lightpink: 0xffb6c1ff, 13880 lightsalmon: 0xffa07aff, 13881 lightseagreen: 0x20b2aaff, 13882 lightskyblue: 0x87cefaff, 13883 lightslategray: 0x778899ff, 13884 lightslategrey: 0x778899ff, 13885 lightsteelblue: 0xb0c4deff, 13886 lightyellow: 0xffffe0ff, 13887 lime: 0x00ff00ff, 13888 limegreen: 0x32cd32ff, 13889 linen: 0xfaf0e6ff, 13890 magenta: 0xff00ffff, 13891 maroon: 0x800000ff, 13892 mediumaquamarine: 0x66cdaaff, 13893 mediumblue: 0x0000cdff, 13894 mediumorchid: 0xba55d3ff, 13895 mediumpurple: 0x9370dbff, 13896 mediumseagreen: 0x3cb371ff, 13897 mediumslateblue: 0x7b68eeff, 13898 mediumspringgreen: 0x00fa9aff, 13899 mediumturquoise: 0x48d1ccff, 13900 mediumvioletred: 0xc71585ff, 13901 midnightblue: 0x191970ff, 13902 mintcream: 0xf5fffaff, 13903 mistyrose: 0xffe4e1ff, 13904 moccasin: 0xffe4b5ff, 13905 navajowhite: 0xffdeadff, 13906 navy: 0x000080ff, 13907 oldlace: 0xfdf5e6ff, 13908 olive: 0x808000ff, 13909 olivedrab: 0x6b8e23ff, 13910 orange: 0xffa500ff, 13911 orangered: 0xff4500ff, 13912 orchid: 0xda70d6ff, 13913 palegoldenrod: 0xeee8aaff, 13914 palegreen: 0x98fb98ff, 13915 paleturquoise: 0xafeeeeff, 13916 palevioletred: 0xdb7093ff, 13917 papayawhip: 0xffefd5ff, 13918 peachpuff: 0xffdab9ff, 13919 peru: 0xcd853fff, 13920 pink: 0xffc0cbff, 13921 plum: 0xdda0ddff, 13922 powderblue: 0xb0e0e6ff, 13923 purple: 0x800080ff, 13924 rebeccapurple: 0x663399ff, 13925 red: 0xff0000ff, 13926 rosybrown: 0xbc8f8fff, 13927 royalblue: 0x4169e1ff, 13928 saddlebrown: 0x8b4513ff, 13929 salmon: 0xfa8072ff, 13930 sandybrown: 0xf4a460ff, 13931 seagreen: 0x2e8b57ff, 13932 seashell: 0xfff5eeff, 13933 sienna: 0xa0522dff, 13934 silver: 0xc0c0c0ff, 13935 skyblue: 0x87ceebff, 13936 slateblue: 0x6a5acdff, 13937 slategray: 0x708090ff, 13938 slategrey: 0x708090ff, 13939 snow: 0xfffafaff, 13940 springgreen: 0x00ff7fff, 13941 steelblue: 0x4682b4ff, 13942 tan: 0xd2b48cff, 13943 teal: 0x008080ff, 13944 thistle: 0xd8bfd8ff, 13945 tomato: 0xff6347ff, 13946 turquoise: 0x40e0d0ff, 13947 violet: 0xee82eeff, 13948 wheat: 0xf5deb3ff, 13949 white: 0xffffffff, 13950 whitesmoke: 0xf5f5f5ff, 13951 yellow: 0xffff00ff, 13952 yellowgreen: 0x9acd32ff 13953 }; 13954 13955 const NUMBER = '[-+]?\\d*\\.?\\d+'; 13956 const PERCENTAGE = NUMBER + '%'; 13957 13958 function call(...parts) { 13959 return '\\(\\s*(' + parts.join(')\\s*,\\s*(') + ')\\s*\\)'; 13960 } 13961 13962 const rgb = new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER)); 13963 const rgba = new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER)); 13964 const hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE)); 13965 const hsla = new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER)); 13966 const hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/; 13967 const hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/; 13968 const hex6 = /^#([0-9a-fA-F]{6})$/; 13969 const hex8 = /^#([0-9a-fA-F]{8})$/; 13970 13971 function normalizeColor(color) { 13972 let match; 13973 13974 if (typeof color === 'number') { 13975 return color >>> 0 === color && color >= 0 && color <= 0xffffffff ? color : null; 13976 } 13977 13978 if (match = hex6.exec(color)) return parseInt(match[1] + 'ff', 16) >>> 0; 13979 13980 if (colors$1 && colors$1[color] !== undefined) { 13981 return colors$1[color]; 13982 } 13983 13984 if (match = rgb.exec(color)) { 13985 return (parse255(match[1]) << 24 | parse255(match[2]) << 16 | parse255(match[3]) << 8 | 0x000000ff) >>> 0; 13986 } 13987 13988 if (match = rgba.exec(color)) { 13989 return (parse255(match[1]) << 24 | parse255(match[2]) << 16 | parse255(match[3]) << 8 | parse1(match[4])) >>> 0; 13990 } 13991 13992 if (match = hex3.exec(color)) { 13993 return parseInt(match[1] + match[1] + match[2] + match[2] + match[3] + match[3] + 'ff', 16) >>> 0; 13994 } 13995 13996 if (match = hex8.exec(color)) return parseInt(match[1], 16) >>> 0; 13997 13998 if (match = hex4.exec(color)) { 13999 return parseInt(match[1] + match[1] + match[2] + match[2] + match[3] + match[3] + match[4] + match[4], 16) >>> 0; 14000 } 14001 14002 if (match = hsl.exec(color)) { 14003 return (hslToRgb(parse360(match[1]), parsePercentage(match[2]), parsePercentage(match[3])) | 0x000000ff) >>> 0; 14004 } 14005 14006 if (match = hsla.exec(color)) { 14007 return (hslToRgb(parse360(match[1]), parsePercentage(match[2]), parsePercentage(match[3])) | parse1(match[4])) >>> 0; 14008 } 14009 14010 return null; 14011 } 14012 14013 function hue2rgb(p, q, t) { 14014 if (t < 0) t += 1; 14015 if (t > 1) t -= 1; 14016 if (t < 1 / 6) return p + (q - p) * 6 * t; 14017 if (t < 1 / 2) return q; 14018 if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6; 14019 return p; 14020 } 14021 14022 function hslToRgb(h, s, l) { 14023 const q = l < 0.5 ? l * (1 + s) : l + s - l * s; 14024 const p = 2 * l - q; 14025 const r = hue2rgb(p, q, h + 1 / 3); 14026 const g = hue2rgb(p, q, h); 14027 const b = hue2rgb(p, q, h - 1 / 3); 14028 return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b * 255) << 8; 14029 } 14030 14031 function parse255(str) { 14032 const int = parseInt(str, 10); 14033 if (int < 0) return 0; 14034 if (int > 255) return 255; 14035 return int; 14036 } 14037 14038 function parse360(str) { 14039 const int = parseFloat(str); 14040 return (int % 360 + 360) % 360 / 360; 14041 } 14042 14043 function parse1(str) { 14044 const num = parseFloat(str); 14045 if (num < 0) return 0; 14046 if (num > 1) return 255; 14047 return Math.round(num * 255); 14048 } 14049 14050 function parsePercentage(str) { 14051 const int = parseFloat(str); 14052 if (int < 0) return 0; 14053 if (int > 100) return 1; 14054 return int / 100; 14055 } 14056 14057 function colorToRgba(input) { 14058 let int32Color = normalizeColor(input); 14059 if (int32Color === null) return input; 14060 int32Color = int32Color || 0; 14061 let r = (int32Color & 0xff000000) >>> 24; 14062 let g = (int32Color & 0x00ff0000) >>> 16; 14063 let b = (int32Color & 0x0000ff00) >>> 8; 14064 let a = (int32Color & 0x000000ff) / 255; 14065 return `rgba($r}, $g}, $b}, $a})`; 14066 } 14067 14068 const createInterpolator = (range, output, extrapolate) => { 14069 if (react_spring_shared_esm_is.fun(range)) { 14070 return range; 14071 } 14072 14073 if (react_spring_shared_esm_is.arr(range)) { 14074 return createInterpolator({ 14075 range, 14076 output: output, 14077 extrapolate 14078 }); 14079 } 14080 14081 if (react_spring_shared_esm_is.str(range.output[0])) { 14082 return createStringInterpolator$1(range); 14083 } 14084 14085 const config = range; 14086 const outputRange = config.output; 14087 const inputRange = config.range || [0, 1]; 14088 const extrapolateLeft = config.extrapolateLeft || config.extrapolate || 'extend'; 14089 const extrapolateRight = config.extrapolateRight || config.extrapolate || 'extend'; 14090 14091 const easing = config.easing || (t => t); 14092 14093 return input => { 14094 const range = findRange(input, inputRange); 14095 return interpolate(input, inputRange[range], inputRange[range + 1], outputRange[range], outputRange[range + 1], easing, extrapolateLeft, extrapolateRight, config.map); 14096 }; 14097 }; 14098 14099 function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) { 14100 let result = map ? map(input) : input; 14101 14102 if (result < inputMin) { 14103 if (extrapolateLeft === 'identity') return result;else if (extrapolateLeft === 'clamp') result = inputMin; 14104 } 14105 14106 if (result > inputMax) { 14107 if (extrapolateRight === 'identity') return result;else if (extrapolateRight === 'clamp') result = inputMax; 14108 } 14109 14110 if (outputMin === outputMax) return outputMin; 14111 if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax; 14112 if (inputMin === -Infinity) result = -result;else if (inputMax === Infinity) result = result - inputMin;else result = (result - inputMin) / (inputMax - inputMin); 14113 result = easing(result); 14114 if (outputMin === -Infinity) result = -result;else if (outputMax === Infinity) result = result + outputMin;else result = result * (outputMax - outputMin) + outputMin; 14115 return result; 14116 } 14117 14118 function findRange(input, inputRange) { 14119 for (var i = 1; i < inputRange.length - 1; ++i) if (inputRange[i] >= input) break; 14120 14121 return i - 1; 14122 } 14123 14124 function react_spring_shared_esm_extends() { 14125 react_spring_shared_esm_extends = Object.assign || function (target) { 14126 for (var i = 1; i < arguments.length; i++) { 14127 var source = arguments[i]; 14128 14129 for (var key in source) { 14130 if (Object.prototype.hasOwnProperty.call(source, key)) { 14131 target[key] = source[key]; 14132 } 14133 } 14134 } 14135 14136 return target; 14137 }; 14138 14139 return react_spring_shared_esm_extends.apply(this, arguments); 14140 } 14141 14142 const $get = Symbol.for('FluidValue.get'); 14143 const $observers = Symbol.for('FluidValue.observers'); 14144 14145 const hasFluidValue = arg => Boolean(arg && arg[$get]); 14146 14147 const getFluidValue = arg => arg && arg[$get] ? arg[$get]() : arg; 14148 14149 const getFluidObservers = target => target[$observers] || null; 14150 14151 function callFluidObserver(observer, event) { 14152 if (observer.eventObserved) { 14153 observer.eventObserved(event); 14154 } else { 14155 observer(event); 14156 } 14157 } 14158 14159 function callFluidObservers(target, event) { 14160 let observers = target[$observers]; 14161 14162 if (observers) { 14163 observers.forEach(observer => { 14164 callFluidObserver(observer, event); 14165 }); 14166 } 14167 } 14168 14169 class FluidValue { 14170 constructor(get) { 14171 this[$get] = void 0; 14172 this[$observers] = void 0; 14173 14174 if (!get && !(get = this.get)) { 14175 throw Error('Unknown getter'); 14176 } 14177 14178 setFluidGetter(this, get); 14179 } 14180 14181 } 14182 14183 const setFluidGetter = (target, get) => setHidden(target, $get, get); 14184 14185 function addFluidObserver(target, observer) { 14186 if (target[$get]) { 14187 let observers = target[$observers]; 14188 14189 if (!observers) { 14190 setHidden(target, $observers, observers = new Set()); 14191 } 14192 14193 if (!observers.has(observer)) { 14194 observers.add(observer); 14195 14196 if (target.observerAdded) { 14197 target.observerAdded(observers.size, observer); 14198 } 14199 } 14200 } 14201 14202 return observer; 14203 } 14204 14205 function removeFluidObserver(target, observer) { 14206 let observers = target[$observers]; 14207 14208 if (observers && observers.has(observer)) { 14209 const count = observers.size - 1; 14210 14211 if (count) { 14212 observers.delete(observer); 14213 } else { 14214 target[$observers] = null; 14215 } 14216 14217 if (target.observerRemoved) { 14218 target.observerRemoved(count, observer); 14219 } 14220 } 14221 } 14222 14223 const setHidden = (target, key, value) => Object.defineProperty(target, key, { 14224 value, 14225 writable: true, 14226 configurable: true 14227 }); 14228 14229 const numberRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g; 14230 const colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi; 14231 const unitRegex = new RegExp(`($numberRegex.source})(%|[a-z]+)`, 'i'); 14232 const rgbaRegex = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi; 14233 const cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/; 14234 14235 const variableToRgba = input => { 14236 const [token, fallback] = parseCSSVariable(input); 14237 14238 if (!token || isSSR()) { 14239 return input; 14240 } 14241 14242 const value = window.getComputedStyle(document.documentElement).getPropertyValue(token); 14243 14244 if (value) { 14245 return value.trim(); 14246 } else if (fallback && fallback.startsWith('--')) { 14247 const _value = window.getComputedStyle(document.documentElement).getPropertyValue(fallback); 14248 14249 if (_value) { 14250 return _value; 14251 } else { 14252 return input; 14253 } 14254 } else if (fallback && cssVariableRegex.test(fallback)) { 14255 return variableToRgba(fallback); 14256 } else if (fallback) { 14257 return fallback; 14258 } 14259 14260 return input; 14261 }; 14262 14263 const parseCSSVariable = current => { 14264 const match = cssVariableRegex.exec(current); 14265 if (!match) return [,]; 14266 const [, token, fallback] = match; 14267 return [token, fallback]; 14268 }; 14269 14270 let namedColorRegex; 14271 14272 const rgbaRound = (_, p1, p2, p3, p4) => `rgba($Math.round(p1)}, $Math.round(p2)}, $Math.round(p3)}, $p4})`; 14273 14274 const createStringInterpolator = config => { 14275 if (!namedColorRegex) namedColorRegex = colors$1 ? new RegExp(`($Object.keys(colors$1).join('|')})(?!\\w)`, 'g') : /^\b$/; 14276 const output = config.output.map(value => { 14277 return getFluidValue(value).replace(cssVariableRegex, variableToRgba).replace(colorRegex, colorToRgba).replace(namedColorRegex, colorToRgba); 14278 }); 14279 const keyframes = output.map(value => value.match(numberRegex).map(Number)); 14280 const outputRanges = keyframes[0].map((_, i) => keyframes.map(values => { 14281 if (!(i in values)) { 14282 throw Error('The arity of each "output" value must be equal'); 14283 } 14284 14285 return values[i]; 14286 })); 14287 const interpolators = outputRanges.map(output => createInterpolator(react_spring_shared_esm_extends({}, config, { 14288 output 14289 }))); 14290 return input => { 14291 var _output$find; 14292 14293 const missingUnit = !unitRegex.test(output[0]) && ((_output$find = output.find(value => unitRegex.test(value))) == null ? void 0 : _output$find.replace(numberRegex, '')); 14294 let i = 0; 14295 return output[0].replace(numberRegex, () => `$interpolators[i++](input)}$missingUnit || ''}`).replace(rgbaRegex, rgbaRound); 14296 }; 14297 }; 14298 14299 const prefix = 'react-spring: '; 14300 14301 const once = fn => { 14302 const func = fn; 14303 let called = false; 14304 14305 if (typeof func != 'function') { 14306 throw new TypeError(`$prefix}once requires a function parameter`); 14307 } 14308 14309 return (...args) => { 14310 if (!called) { 14311 func(...args); 14312 called = true; 14313 } 14314 }; 14315 }; 14316 14317 const warnInterpolate = once(console.warn); 14318 function react_spring_shared_esm_deprecateInterpolate() { 14319 warnInterpolate(`$prefix}The "interpolate" function is deprecated in v9 (use "to" instead)`); 14320 } 14321 const warnDirectCall = once(console.warn); 14322 function deprecateDirectCall() { 14323 warnDirectCall(`$prefix}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`); 14324 } 14325 14326 function isAnimatedString(value) { 14327 return react_spring_shared_esm_is.str(value) && (value[0] == '#' || /\d/.test(value) || !isSSR() && cssVariableRegex.test(value) || value in (colors$1 || {})); 14328 } 14329 14330 const react_spring_shared_esm_useOnce = effect => (0,external_React_.useEffect)(effect, emptyDeps); 14331 const emptyDeps = []; 14332 14333 function react_spring_shared_esm_useForceUpdate() { 14334 const update = (0,external_React_.useState)()[1]; 14335 const mounted = (0,external_React_.useState)(makeMountedRef)[0]; 14336 react_spring_shared_esm_useOnce(mounted.unmount); 14337 return () => { 14338 if (mounted.current) { 14339 update({}); 14340 } 14341 }; 14342 } 14343 14344 function makeMountedRef() { 14345 const mounted = { 14346 current: true, 14347 unmount: () => () => { 14348 mounted.current = false; 14349 } 14350 }; 14351 return mounted; 14352 } 14353 14354 function useMemoOne(getResult, inputs) { 14355 const [initial] = (0,external_React_.useState)(() => ({ 14356 inputs, 14357 result: getResult() 14358 })); 14359 const committed = (0,external_React_.useRef)(); 14360 const prevCache = committed.current; 14361 let cache = prevCache; 14362 14363 if (cache) { 14364 const useCache = Boolean(inputs && cache.inputs && areInputsEqual(inputs, cache.inputs)); 14365 14366 if (!useCache) { 14367 cache = { 14368 inputs, 14369 result: getResult() 14370 }; 14371 } 14372 } else { 14373 cache = initial; 14374 } 14375 14376 (0,external_React_.useEffect)(() => { 14377 committed.current = cache; 14378 14379 if (prevCache == initial) { 14380 initial.inputs = initial.result = undefined; 14381 } 14382 }, [cache]); 14383 return cache.result; 14384 } 14385 14386 function areInputsEqual(next, prev) { 14387 if (next.length !== prev.length) { 14388 return false; 14389 } 14390 14391 for (let i = 0; i < next.length; i++) { 14392 if (next[i] !== prev[i]) { 14393 return false; 14394 } 14395 } 14396 14397 return true; 14398 } 14399 14400 function react_spring_shared_esm_usePrev(value) { 14401 const prevRef = (0,external_React_.useRef)(); 14402 (0,external_React_.useEffect)(() => { 14403 prevRef.current = value; 14404 }); 14405 return prevRef.current; 14406 } 14407 14408 const react_spring_shared_esm_useLayoutEffect = typeof window !== 'undefined' && window.document && window.document.createElement ? external_React_.useLayoutEffect : external_React_.useEffect; 14409 14410 14411 14412 ;// CONCATENATED MODULE: ./node_modules/@react-spring/animated/dist/react-spring-animated.esm.js 14413 14414 14415 14416 14417 const $node = Symbol.for('Animated:node'); 14418 const isAnimated = value => !!value && value[$node] === value; 14419 const getAnimated = owner => owner && owner[$node]; 14420 const setAnimated = (owner, node) => defineHidden(owner, $node, node); 14421 const getPayload = owner => owner && owner[$node] && owner[$node].getPayload(); 14422 class Animated { 14423 constructor() { 14424 this.payload = void 0; 14425 setAnimated(this, this); 14426 } 14427 14428 getPayload() { 14429 return this.payload || []; 14430 } 14431 14432 } 14433 14434 class AnimatedValue extends Animated { 14435 constructor(_value) { 14436 super(); 14437 this.done = true; 14438 this.elapsedTime = void 0; 14439 this.lastPosition = void 0; 14440 this.lastVelocity = void 0; 14441 this.v0 = void 0; 14442 this.durationProgress = 0; 14443 this._value = _value; 14444 14445 if (react_spring_shared_esm_is.num(this._value)) { 14446 this.lastPosition = this._value; 14447 } 14448 } 14449 14450 static create(value) { 14451 return new AnimatedValue(value); 14452 } 14453 14454 getPayload() { 14455 return [this]; 14456 } 14457 14458 getValue() { 14459 return this._value; 14460 } 14461 14462 setValue(value, step) { 14463 if (react_spring_shared_esm_is.num(value)) { 14464 this.lastPosition = value; 14465 14466 if (step) { 14467 value = Math.round(value / step) * step; 14468 14469 if (this.done) { 14470 this.lastPosition = value; 14471 } 14472 } 14473 } 14474 14475 if (this._value === value) { 14476 return false; 14477 } 14478 14479 this._value = value; 14480 return true; 14481 } 14482 14483 reset() { 14484 const { 14485 done 14486 } = this; 14487 this.done = false; 14488 14489 if (react_spring_shared_esm_is.num(this._value)) { 14490 this.elapsedTime = 0; 14491 this.durationProgress = 0; 14492 this.lastPosition = this._value; 14493 if (done) this.lastVelocity = null; 14494 this.v0 = null; 14495 } 14496 } 14497 14498 } 14499 14500 class AnimatedString extends AnimatedValue { 14501 constructor(value) { 14502 super(0); 14503 this._string = null; 14504 this._toString = void 0; 14505 this._toString = createInterpolator({ 14506 output: [value, value] 14507 }); 14508 } 14509 14510 static create(value) { 14511 return new AnimatedString(value); 14512 } 14513 14514 getValue() { 14515 let value = this._string; 14516 return value == null ? this._string = this._toString(this._value) : value; 14517 } 14518 14519 setValue(value) { 14520 if (react_spring_shared_esm_is.str(value)) { 14521 if (value == this._string) { 14522 return false; 14523 } 14524 14525 this._string = value; 14526 this._value = 1; 14527 } else if (super.setValue(value)) { 14528 this._string = null; 14529 } else { 14530 return false; 14531 } 14532 14533 return true; 14534 } 14535 14536 reset(goal) { 14537 if (goal) { 14538 this._toString = createInterpolator({ 14539 output: [this.getValue(), goal] 14540 }); 14541 } 14542 14543 this._value = 0; 14544 super.reset(); 14545 } 14546 14547 } 14548 14549 const TreeContext = { 14550 dependencies: null 14551 }; 14552 14553 class AnimatedObject extends Animated { 14554 constructor(source) { 14555 super(); 14556 this.source = source; 14557 this.setValue(source); 14558 } 14559 14560 getValue(animated) { 14561 const values = {}; 14562 eachProp(this.source, (source, key) => { 14563 if (isAnimated(source)) { 14564 values[key] = source.getValue(animated); 14565 } else if (hasFluidValue(source)) { 14566 values[key] = getFluidValue(source); 14567 } else if (!animated) { 14568 values[key] = source; 14569 } 14570 }); 14571 return values; 14572 } 14573 14574 setValue(source) { 14575 this.source = source; 14576 this.payload = this._makePayload(source); 14577 } 14578 14579 reset() { 14580 if (this.payload) { 14581 react_spring_shared_esm_each(this.payload, node => node.reset()); 14582 } 14583 } 14584 14585 _makePayload(source) { 14586 if (source) { 14587 const payload = new Set(); 14588 eachProp(source, this._addToPayload, payload); 14589 return Array.from(payload); 14590 } 14591 } 14592 14593 _addToPayload(source) { 14594 if (TreeContext.dependencies && hasFluidValue(source)) { 14595 TreeContext.dependencies.add(source); 14596 } 14597 14598 const payload = getPayload(source); 14599 14600 if (payload) { 14601 react_spring_shared_esm_each(payload, node => this.add(node)); 14602 } 14603 } 14604 14605 } 14606 14607 class AnimatedArray extends AnimatedObject { 14608 constructor(source) { 14609 super(source); 14610 } 14611 14612 static create(source) { 14613 return new AnimatedArray(source); 14614 } 14615 14616 getValue() { 14617 return this.source.map(node => node.getValue()); 14618 } 14619 14620 setValue(source) { 14621 const payload = this.getPayload(); 14622 14623 if (source.length == payload.length) { 14624 return payload.map((node, i) => node.setValue(source[i])).some(Boolean); 14625 } 14626 14627 super.setValue(source.map(makeAnimated)); 14628 return true; 14629 } 14630 14631 } 14632 14633 function makeAnimated(value) { 14634 const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue; 14635 return nodeType.create(value); 14636 } 14637 14638 function getAnimatedType(value) { 14639 const parentNode = getAnimated(value); 14640 return parentNode ? parentNode.constructor : react_spring_shared_esm_is.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue; 14641 } 14642 14643 function react_spring_animated_esm_extends() { 14644 react_spring_animated_esm_extends = Object.assign || function (target) { 14645 for (var i = 1; i < arguments.length; i++) { 14646 var source = arguments[i]; 14647 14648 for (var key in source) { 14649 if (Object.prototype.hasOwnProperty.call(source, key)) { 14650 target[key] = source[key]; 14651 } 14652 } 14653 } 14654 14655 return target; 14656 }; 14657 14658 return react_spring_animated_esm_extends.apply(this, arguments); 14659 } 14660 14661 const withAnimated = (Component, host) => { 14662 const hasInstance = !react_spring_shared_esm_is.fun(Component) || Component.prototype && Component.prototype.isReactComponent; 14663 return (0,external_React_.forwardRef)((givenProps, givenRef) => { 14664 const instanceRef = (0,external_React_.useRef)(null); 14665 const ref = hasInstance && (0,external_React_.useCallback)(value => { 14666 instanceRef.current = updateRef(givenRef, value); 14667 }, [givenRef]); 14668 const [props, deps] = getAnimatedState(givenProps, host); 14669 const forceUpdate = react_spring_shared_esm_useForceUpdate(); 14670 14671 const callback = () => { 14672 const instance = instanceRef.current; 14673 14674 if (hasInstance && !instance) { 14675 return; 14676 } 14677 14678 const didUpdate = instance ? host.applyAnimatedValues(instance, props.getValue(true)) : false; 14679 14680 if (didUpdate === false) { 14681 forceUpdate(); 14682 } 14683 }; 14684 14685 const observer = new PropsObserver(callback, deps); 14686 const observerRef = (0,external_React_.useRef)(); 14687 react_spring_shared_esm_useLayoutEffect(() => { 14688 const lastObserver = observerRef.current; 14689 observerRef.current = observer; 14690 react_spring_shared_esm_each(deps, dep => addFluidObserver(dep, observer)); 14691 14692 if (lastObserver) { 14693 react_spring_shared_esm_each(lastObserver.deps, dep => removeFluidObserver(dep, lastObserver)); 14694 raf.cancel(lastObserver.update); 14695 } 14696 }); 14697 (0,external_React_.useEffect)(callback, []); 14698 react_spring_shared_esm_useOnce(() => () => { 14699 const observer = observerRef.current; 14700 react_spring_shared_esm_each(observer.deps, dep => removeFluidObserver(dep, observer)); 14701 }); 14702 const usedProps = host.getComponentProps(props.getValue()); 14703 return external_React_.createElement(Component, react_spring_animated_esm_extends({}, usedProps, { 14704 ref: ref 14705 })); 14706 }); 14707 }; 14708 14709 class PropsObserver { 14710 constructor(update, deps) { 14711 this.update = update; 14712 this.deps = deps; 14713 } 14714 14715 eventObserved(event) { 14716 if (event.type == 'change') { 14717 raf.write(this.update); 14718 } 14719 } 14720 14721 } 14722 14723 function getAnimatedState(props, host) { 14724 const dependencies = new Set(); 14725 TreeContext.dependencies = dependencies; 14726 if (props.style) props = react_spring_animated_esm_extends({}, props, { 14727 style: host.createAnimatedStyle(props.style) 14728 }); 14729 props = new AnimatedObject(props); 14730 TreeContext.dependencies = null; 14731 return [props, dependencies]; 14732 } 14733 14734 function updateRef(ref, value) { 14735 if (ref) { 14736 if (react_spring_shared_esm_is.fun(ref)) ref(value);else ref.current = value; 14737 } 14738 14739 return value; 14740 } 14741 14742 const cacheKey = Symbol.for('AnimatedComponent'); 14743 const createHost = (components, { 14744 applyAnimatedValues: _applyAnimatedValues = () => false, 14745 createAnimatedStyle: _createAnimatedStyle = style => new AnimatedObject(style), 14746 getComponentProps: _getComponentProps = props => props 14747 } = {}) => { 14748 const hostConfig = { 14749 applyAnimatedValues: _applyAnimatedValues, 14750 createAnimatedStyle: _createAnimatedStyle, 14751 getComponentProps: _getComponentProps 14752 }; 14753 14754 const animated = Component => { 14755 const displayName = getDisplayName(Component) || 'Anonymous'; 14756 14757 if (react_spring_shared_esm_is.str(Component)) { 14758 Component = animated[Component] || (animated[Component] = withAnimated(Component, hostConfig)); 14759 } else { 14760 Component = Component[cacheKey] || (Component[cacheKey] = withAnimated(Component, hostConfig)); 14761 } 14762 14763 Component.displayName = `Animated($displayName})`; 14764 return Component; 14765 }; 14766 14767 eachProp(components, (Component, key) => { 14768 if (react_spring_shared_esm_is.arr(components)) { 14769 key = getDisplayName(Component); 14770 } 14771 14772 animated[key] = animated(Component); 14773 }); 14774 return { 14775 animated 14776 }; 14777 }; 14778 14779 const getDisplayName = arg => react_spring_shared_esm_is.str(arg) ? arg : arg && react_spring_shared_esm_is.str(arg.displayName) ? arg.displayName : react_spring_shared_esm_is.fun(arg) && arg.name || null; 14780 14781 14782 14783 ;// CONCATENATED MODULE: ./node_modules/@react-spring/core/dist/react-spring-core.esm.js 14784 14785 14786 14787 14788 14789 14790 14791 14792 function react_spring_core_esm_extends() { 14793 react_spring_core_esm_extends = Object.assign || function (target) { 14794 for (var i = 1; i < arguments.length; i++) { 14795 var source = arguments[i]; 14796 14797 for (var key in source) { 14798 if (Object.prototype.hasOwnProperty.call(source, key)) { 14799 target[key] = source[key]; 14800 } 14801 } 14802 } 14803 14804 return target; 14805 }; 14806 14807 return react_spring_core_esm_extends.apply(this, arguments); 14808 } 14809 14810 function callProp(value, ...args) { 14811 return react_spring_shared_esm_is.fun(value) ? value(...args) : value; 14812 } 14813 const matchProp = (value, key) => value === true || !!(key && value && (react_spring_shared_esm_is.fun(value) ? value(key) : react_spring_shared_esm_toArray(value).includes(key))); 14814 const resolveProp = (prop, key) => react_spring_shared_esm_is.obj(prop) ? key && prop[key] : prop; 14815 const getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : undefined; 14816 14817 const noopTransform = value => value; 14818 14819 const getDefaultProps = (props, transform = noopTransform) => { 14820 let keys = DEFAULT_PROPS; 14821 14822 if (props.default && props.default !== true) { 14823 props = props.default; 14824 keys = Object.keys(props); 14825 } 14826 14827 const defaults = {}; 14828 14829 for (const key of keys) { 14830 const value = transform(props[key], key); 14831 14832 if (!react_spring_shared_esm_is.und(value)) { 14833 defaults[key] = value; 14834 } 14835 } 14836 14837 return defaults; 14838 }; 14839 const DEFAULT_PROPS = ['config', 'onProps', 'onStart', 'onChange', 'onPause', 'onResume', 'onRest']; 14840 const RESERVED_PROPS = { 14841 config: 1, 14842 from: 1, 14843 to: 1, 14844 ref: 1, 14845 loop: 1, 14846 reset: 1, 14847 pause: 1, 14848 cancel: 1, 14849 reverse: 1, 14850 immediate: 1, 14851 default: 1, 14852 delay: 1, 14853 onProps: 1, 14854 onStart: 1, 14855 onChange: 1, 14856 onPause: 1, 14857 onResume: 1, 14858 onRest: 1, 14859 onResolve: 1, 14860 items: 1, 14861 trail: 1, 14862 sort: 1, 14863 expires: 1, 14864 initial: 1, 14865 enter: 1, 14866 update: 1, 14867 leave: 1, 14868 children: 1, 14869 onDestroyed: 1, 14870 keys: 1, 14871 callId: 1, 14872 parentId: 1 14873 }; 14874 14875 function getForwardProps(props) { 14876 const forward = {}; 14877 let count = 0; 14878 eachProp(props, (value, prop) => { 14879 if (!RESERVED_PROPS[prop]) { 14880 forward[prop] = value; 14881 count++; 14882 } 14883 }); 14884 14885 if (count) { 14886 return forward; 14887 } 14888 } 14889 14890 function inferTo(props) { 14891 const to = getForwardProps(props); 14892 14893 if (to) { 14894 const out = { 14895 to 14896 }; 14897 eachProp(props, (val, key) => key in to || (out[key] = val)); 14898 return out; 14899 } 14900 14901 return react_spring_core_esm_extends({}, props); 14902 } 14903 function computeGoal(value) { 14904 value = getFluidValue(value); 14905 return react_spring_shared_esm_is.arr(value) ? value.map(computeGoal) : isAnimatedString(value) ? globals.createStringInterpolator({ 14906 range: [0, 1], 14907 output: [value, value] 14908 })(1) : value; 14909 } 14910 function hasProps(props) { 14911 for (const _ in props) return true; 14912 14913 return false; 14914 } 14915 function isAsyncTo(to) { 14916 return react_spring_shared_esm_is.fun(to) || react_spring_shared_esm_is.arr(to) && react_spring_shared_esm_is.obj(to[0]); 14917 } 14918 function detachRefs(ctrl, ref) { 14919 var _ctrl$ref; 14920 14921 (_ctrl$ref = ctrl.ref) == null ? void 0 : _ctrl$ref.delete(ctrl); 14922 ref == null ? void 0 : ref.delete(ctrl); 14923 } 14924 function replaceRef(ctrl, ref) { 14925 if (ref && ctrl.ref !== ref) { 14926 var _ctrl$ref2; 14927 14928 (_ctrl$ref2 = ctrl.ref) == null ? void 0 : _ctrl$ref2.delete(ctrl); 14929 ref.add(ctrl); 14930 ctrl.ref = ref; 14931 } 14932 } 14933 14934 function useChain(refs, timeSteps, timeFrame = 1000) { 14935 useLayoutEffect(() => { 14936 if (timeSteps) { 14937 let prevDelay = 0; 14938 each(refs, (ref, i) => { 14939 const controllers = ref.current; 14940 14941 if (controllers.length) { 14942 let delay = timeFrame * timeSteps[i]; 14943 if (isNaN(delay)) delay = prevDelay;else prevDelay = delay; 14944 each(controllers, ctrl => { 14945 each(ctrl.queue, props => { 14946 const memoizedDelayProp = props.delay; 14947 14948 props.delay = key => delay + callProp(memoizedDelayProp || 0, key); 14949 }); 14950 }); 14951 ref.start(); 14952 } 14953 }); 14954 } else { 14955 let p = Promise.resolve(); 14956 each(refs, ref => { 14957 const controllers = ref.current; 14958 14959 if (controllers.length) { 14960 const queues = controllers.map(ctrl => { 14961 const q = ctrl.queue; 14962 ctrl.queue = []; 14963 return q; 14964 }); 14965 p = p.then(() => { 14966 each(controllers, (ctrl, i) => each(queues[i] || [], update => ctrl.queue.push(update))); 14967 return Promise.all(ref.start()); 14968 }); 14969 } 14970 }); 14971 } 14972 }); 14973 } 14974 14975 const config = { 14976 default: { 14977 tension: 170, 14978 friction: 26 14979 }, 14980 gentle: { 14981 tension: 120, 14982 friction: 14 14983 }, 14984 wobbly: { 14985 tension: 180, 14986 friction: 12 14987 }, 14988 stiff: { 14989 tension: 210, 14990 friction: 20 14991 }, 14992 slow: { 14993 tension: 280, 14994 friction: 60 14995 }, 14996 molasses: { 14997 tension: 280, 14998 friction: 120 14999 } 15000 }; 15001 const c1 = 1.70158; 15002 const c2 = c1 * 1.525; 15003 const c3 = c1 + 1; 15004 const c4 = 2 * Math.PI / 3; 15005 const c5 = 2 * Math.PI / 4.5; 15006 15007 const bounceOut = x => { 15008 const n1 = 7.5625; 15009 const d1 = 2.75; 15010 15011 if (x < 1 / d1) { 15012 return n1 * x * x; 15013 } else if (x < 2 / d1) { 15014 return n1 * (x -= 1.5 / d1) * x + 0.75; 15015 } else if (x < 2.5 / d1) { 15016 return n1 * (x -= 2.25 / d1) * x + 0.9375; 15017 } else { 15018 return n1 * (x -= 2.625 / d1) * x + 0.984375; 15019 } 15020 }; 15021 15022 const easings = { 15023 linear: x => x, 15024 easeInQuad: x => x * x, 15025 easeOutQuad: x => 1 - (1 - x) * (1 - x), 15026 easeInOutQuad: x => x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2, 15027 easeInCubic: x => x * x * x, 15028 easeOutCubic: x => 1 - Math.pow(1 - x, 3), 15029 easeInOutCubic: x => x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2, 15030 easeInQuart: x => x * x * x * x, 15031 easeOutQuart: x => 1 - Math.pow(1 - x, 4), 15032 easeInOutQuart: x => x < 0.5 ? 8 * x * x * x * x : 1 - Math.pow(-2 * x + 2, 4) / 2, 15033 easeInQuint: x => x * x * x * x * x, 15034 easeOutQuint: x => 1 - Math.pow(1 - x, 5), 15035 easeInOutQuint: x => x < 0.5 ? 16 * x * x * x * x * x : 1 - Math.pow(-2 * x + 2, 5) / 2, 15036 easeInSine: x => 1 - Math.cos(x * Math.PI / 2), 15037 easeOutSine: x => Math.sin(x * Math.PI / 2), 15038 easeInOutSine: x => -(Math.cos(Math.PI * x) - 1) / 2, 15039 easeInExpo: x => x === 0 ? 0 : Math.pow(2, 10 * x - 10), 15040 easeOutExpo: x => x === 1 ? 1 : 1 - Math.pow(2, -10 * x), 15041 easeInOutExpo: x => x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? Math.pow(2, 20 * x - 10) / 2 : (2 - Math.pow(2, -20 * x + 10)) / 2, 15042 easeInCirc: x => 1 - Math.sqrt(1 - Math.pow(x, 2)), 15043 easeOutCirc: x => Math.sqrt(1 - Math.pow(x - 1, 2)), 15044 easeInOutCirc: x => x < 0.5 ? (1 - Math.sqrt(1 - Math.pow(2 * x, 2))) / 2 : (Math.sqrt(1 - Math.pow(-2 * x + 2, 2)) + 1) / 2, 15045 easeInBack: x => c3 * x * x * x - c1 * x * x, 15046 easeOutBack: x => 1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2), 15047 easeInOutBack: x => x < 0.5 ? Math.pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2) / 2 : (Math.pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2, 15048 easeInElastic: x => x === 0 ? 0 : x === 1 ? 1 : -Math.pow(2, 10 * x - 10) * Math.sin((x * 10 - 10.75) * c4), 15049 easeOutElastic: x => x === 0 ? 0 : x === 1 ? 1 : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1, 15050 easeInOutElastic: x => x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2 : Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5) / 2 + 1, 15051 easeInBounce: x => 1 - bounceOut(1 - x), 15052 easeOutBounce: bounceOut, 15053 easeInOutBounce: x => x < 0.5 ? (1 - bounceOut(1 - 2 * x)) / 2 : (1 + bounceOut(2 * x - 1)) / 2 15054 }; 15055 15056 const defaults = react_spring_core_esm_extends({}, config.default, { 15057 mass: 1, 15058 damping: 1, 15059 easing: easings.linear, 15060 clamp: false 15061 }); 15062 15063 class AnimationConfig { 15064 constructor() { 15065 this.tension = void 0; 15066 this.friction = void 0; 15067 this.frequency = void 0; 15068 this.damping = void 0; 15069 this.mass = void 0; 15070 this.velocity = 0; 15071 this.restVelocity = void 0; 15072 this.precision = void 0; 15073 this.progress = void 0; 15074 this.duration = void 0; 15075 this.easing = void 0; 15076 this.clamp = void 0; 15077 this.bounce = void 0; 15078 this.decay = void 0; 15079 this.round = void 0; 15080 Object.assign(this, defaults); 15081 } 15082 15083 } 15084 function mergeConfig(config, newConfig, defaultConfig) { 15085 if (defaultConfig) { 15086 defaultConfig = react_spring_core_esm_extends({}, defaultConfig); 15087 sanitizeConfig(defaultConfig, newConfig); 15088 newConfig = react_spring_core_esm_extends({}, defaultConfig, newConfig); 15089 } 15090 15091 sanitizeConfig(config, newConfig); 15092 Object.assign(config, newConfig); 15093 15094 for (const key in defaults) { 15095 if (config[key] == null) { 15096 config[key] = defaults[key]; 15097 } 15098 } 15099 15100 let { 15101 mass, 15102 frequency, 15103 damping 15104 } = config; 15105 15106 if (!react_spring_shared_esm_is.und(frequency)) { 15107 if (frequency < 0.01) frequency = 0.01; 15108 if (damping < 0) damping = 0; 15109 config.tension = Math.pow(2 * Math.PI / frequency, 2) * mass; 15110 config.friction = 4 * Math.PI * damping * mass / frequency; 15111 } 15112 15113 return config; 15114 } 15115 15116 function sanitizeConfig(config, props) { 15117 if (!react_spring_shared_esm_is.und(props.decay)) { 15118 config.duration = undefined; 15119 } else { 15120 const isTensionConfig = !react_spring_shared_esm_is.und(props.tension) || !react_spring_shared_esm_is.und(props.friction); 15121 15122 if (isTensionConfig || !react_spring_shared_esm_is.und(props.frequency) || !react_spring_shared_esm_is.und(props.damping) || !react_spring_shared_esm_is.und(props.mass)) { 15123 config.duration = undefined; 15124 config.decay = undefined; 15125 } 15126 15127 if (isTensionConfig) { 15128 config.frequency = undefined; 15129 } 15130 } 15131 } 15132 15133 const emptyArray = []; 15134 class Animation { 15135 constructor() { 15136 this.changed = false; 15137 this.values = emptyArray; 15138 this.toValues = null; 15139 this.fromValues = emptyArray; 15140 this.to = void 0; 15141 this.from = void 0; 15142 this.config = new AnimationConfig(); 15143 this.immediate = false; 15144 } 15145 15146 } 15147 15148 function scheduleProps(callId, { 15149 key, 15150 props, 15151 defaultProps, 15152 state, 15153 actions 15154 }) { 15155 return new Promise((resolve, reject) => { 15156 var _props$cancel; 15157 15158 let delay; 15159 let timeout; 15160 let cancel = matchProp((_props$cancel = props.cancel) != null ? _props$cancel : defaultProps == null ? void 0 : defaultProps.cancel, key); 15161 15162 if (cancel) { 15163 onStart(); 15164 } else { 15165 if (!react_spring_shared_esm_is.und(props.pause)) { 15166 state.paused = matchProp(props.pause, key); 15167 } 15168 15169 let pause = defaultProps == null ? void 0 : defaultProps.pause; 15170 15171 if (pause !== true) { 15172 pause = state.paused || matchProp(pause, key); 15173 } 15174 15175 delay = callProp(props.delay || 0, key); 15176 15177 if (pause) { 15178 state.resumeQueue.add(onResume); 15179 actions.pause(); 15180 } else { 15181 actions.resume(); 15182 onResume(); 15183 } 15184 } 15185 15186 function onPause() { 15187 state.resumeQueue.add(onResume); 15188 state.timeouts.delete(timeout); 15189 timeout.cancel(); 15190 delay = timeout.time - raf.now(); 15191 } 15192 15193 function onResume() { 15194 if (delay > 0 && !globals.skipAnimation) { 15195 state.delayed = true; 15196 timeout = raf.setTimeout(onStart, delay); 15197 state.pauseQueue.add(onPause); 15198 state.timeouts.add(timeout); 15199 } else { 15200 onStart(); 15201 } 15202 } 15203 15204 function onStart() { 15205 if (state.delayed) { 15206 state.delayed = false; 15207 } 15208 15209 state.pauseQueue.delete(onPause); 15210 state.timeouts.delete(timeout); 15211 15212 if (callId <= (state.cancelId || 0)) { 15213 cancel = true; 15214 } 15215 15216 try { 15217 actions.start(react_spring_core_esm_extends({}, props, { 15218 callId, 15219 cancel 15220 }), resolve); 15221 } catch (err) { 15222 reject(err); 15223 } 15224 } 15225 }); 15226 } 15227 15228 const getCombinedResult = (target, results) => results.length == 1 ? results[0] : results.some(result => result.cancelled) ? getCancelledResult(target.get()) : results.every(result => result.noop) ? getNoopResult(target.get()) : getFinishedResult(target.get(), results.every(result => result.finished)); 15229 const getNoopResult = value => ({ 15230 value, 15231 noop: true, 15232 finished: true, 15233 cancelled: false 15234 }); 15235 const getFinishedResult = (value, finished, cancelled = false) => ({ 15236 value, 15237 finished, 15238 cancelled 15239 }); 15240 const getCancelledResult = value => ({ 15241 value, 15242 cancelled: true, 15243 finished: false 15244 }); 15245 15246 function runAsync(to, props, state, target) { 15247 const { 15248 callId, 15249 parentId, 15250 onRest 15251 } = props; 15252 const { 15253 asyncTo: prevTo, 15254 promise: prevPromise 15255 } = state; 15256 15257 if (!parentId && to === prevTo && !props.reset) { 15258 return prevPromise; 15259 } 15260 15261 return state.promise = (async () => { 15262 state.asyncId = callId; 15263 state.asyncTo = to; 15264 const defaultProps = getDefaultProps(props, (value, key) => key === 'onRest' ? undefined : value); 15265 let preventBail; 15266 let bail; 15267 const bailPromise = new Promise((resolve, reject) => (preventBail = resolve, bail = reject)); 15268 15269 const bailIfEnded = bailSignal => { 15270 const bailResult = callId <= (state.cancelId || 0) && getCancelledResult(target) || callId !== state.asyncId && getFinishedResult(target, false); 15271 15272 if (bailResult) { 15273 bailSignal.result = bailResult; 15274 bail(bailSignal); 15275 throw bailSignal; 15276 } 15277 }; 15278 15279 const animate = (arg1, arg2) => { 15280 const bailSignal = new BailSignal(); 15281 const skipAnimationSignal = new SkipAniamtionSignal(); 15282 return (async () => { 15283 if (globals.skipAnimation) { 15284 stopAsync(state); 15285 skipAnimationSignal.result = getFinishedResult(target, false); 15286 bail(skipAnimationSignal); 15287 throw skipAnimationSignal; 15288 } 15289 15290 bailIfEnded(bailSignal); 15291 const props = react_spring_shared_esm_is.obj(arg1) ? react_spring_core_esm_extends({}, arg1) : react_spring_core_esm_extends({}, arg2, { 15292 to: arg1 15293 }); 15294 props.parentId = callId; 15295 eachProp(defaultProps, (value, key) => { 15296 if (react_spring_shared_esm_is.und(props[key])) { 15297 props[key] = value; 15298 } 15299 }); 15300 const result = await target.start(props); 15301 bailIfEnded(bailSignal); 15302 15303 if (state.paused) { 15304 await new Promise(resume => { 15305 state.resumeQueue.add(resume); 15306 }); 15307 } 15308 15309 return result; 15310 })(); 15311 }; 15312 15313 let result; 15314 15315 if (globals.skipAnimation) { 15316 stopAsync(state); 15317 return getFinishedResult(target, false); 15318 } 15319 15320 try { 15321 let animating; 15322 15323 if (react_spring_shared_esm_is.arr(to)) { 15324 animating = (async queue => { 15325 for (const props of queue) { 15326 await animate(props); 15327 } 15328 })(to); 15329 } else { 15330 animating = Promise.resolve(to(animate, target.stop.bind(target))); 15331 } 15332 15333 await Promise.all([animating.then(preventBail), bailPromise]); 15334 result = getFinishedResult(target.get(), true, false); 15335 } catch (err) { 15336 if (err instanceof BailSignal) { 15337 result = err.result; 15338 } else if (err instanceof SkipAniamtionSignal) { 15339 result = err.result; 15340 } else { 15341 throw err; 15342 } 15343 } finally { 15344 if (callId == state.asyncId) { 15345 state.asyncId = parentId; 15346 state.asyncTo = parentId ? prevTo : undefined; 15347 state.promise = parentId ? prevPromise : undefined; 15348 } 15349 } 15350 15351 if (react_spring_shared_esm_is.fun(onRest)) { 15352 raf.batchedUpdates(() => { 15353 onRest(result, target, target.item); 15354 }); 15355 } 15356 15357 return result; 15358 })(); 15359 } 15360 function stopAsync(state, cancelId) { 15361 flush(state.timeouts, t => t.cancel()); 15362 state.pauseQueue.clear(); 15363 state.resumeQueue.clear(); 15364 state.asyncId = state.asyncTo = state.promise = undefined; 15365 if (cancelId) state.cancelId = cancelId; 15366 } 15367 class BailSignal extends Error { 15368 constructor() { 15369 super('An async animation has been interrupted. You see this error because you ' + 'forgot to use `await` or `.catch(...)` on its returned promise.'); 15370 this.result = void 0; 15371 } 15372 15373 } 15374 class SkipAniamtionSignal extends Error { 15375 constructor() { 15376 super('SkipAnimationSignal'); 15377 this.result = void 0; 15378 } 15379 15380 } 15381 15382 const isFrameValue = value => value instanceof FrameValue; 15383 let nextId$1 = 1; 15384 class FrameValue extends FluidValue { 15385 constructor(...args) { 15386 super(...args); 15387 this.id = nextId$1++; 15388 this.key = void 0; 15389 this._priority = 0; 15390 } 15391 15392 get priority() { 15393 return this._priority; 15394 } 15395 15396 set priority(priority) { 15397 if (this._priority != priority) { 15398 this._priority = priority; 15399 15400 this._onPriorityChange(priority); 15401 } 15402 } 15403 15404 get() { 15405 const node = getAnimated(this); 15406 return node && node.getValue(); 15407 } 15408 15409 to(...args) { 15410 return globals.to(this, args); 15411 } 15412 15413 interpolate(...args) { 15414 react_spring_shared_esm_deprecateInterpolate(); 15415 return globals.to(this, args); 15416 } 15417 15418 toJSON() { 15419 return this.get(); 15420 } 15421 15422 observerAdded(count) { 15423 if (count == 1) this._attach(); 15424 } 15425 15426 observerRemoved(count) { 15427 if (count == 0) this._detach(); 15428 } 15429 15430 _attach() {} 15431 15432 _detach() {} 15433 15434 _onChange(value, idle = false) { 15435 callFluidObservers(this, { 15436 type: 'change', 15437 parent: this, 15438 value, 15439 idle 15440 }); 15441 } 15442 15443 _onPriorityChange(priority) { 15444 if (!this.idle) { 15445 frameLoop.sort(this); 15446 } 15447 15448 callFluidObservers(this, { 15449 type: 'priority', 15450 parent: this, 15451 priority 15452 }); 15453 } 15454 15455 } 15456 15457 const $P = Symbol.for('SpringPhase'); 15458 const HAS_ANIMATED = 1; 15459 const IS_ANIMATING = 2; 15460 const IS_PAUSED = 4; 15461 const hasAnimated = target => (target[$P] & HAS_ANIMATED) > 0; 15462 const isAnimating = target => (target[$P] & IS_ANIMATING) > 0; 15463 const isPaused = target => (target[$P] & IS_PAUSED) > 0; 15464 const setActiveBit = (target, active) => active ? target[$P] |= IS_ANIMATING | HAS_ANIMATED : target[$P] &= ~IS_ANIMATING; 15465 const setPausedBit = (target, paused) => paused ? target[$P] |= IS_PAUSED : target[$P] &= ~IS_PAUSED; 15466 15467 class SpringValue extends FrameValue { 15468 constructor(arg1, arg2) { 15469 super(); 15470 this.key = void 0; 15471 this.animation = new Animation(); 15472 this.queue = void 0; 15473 this.defaultProps = {}; 15474 this._state = { 15475 paused: false, 15476 delayed: false, 15477 pauseQueue: new Set(), 15478 resumeQueue: new Set(), 15479 timeouts: new Set() 15480 }; 15481 this._pendingCalls = new Set(); 15482 this._lastCallId = 0; 15483 this._lastToId = 0; 15484 this._memoizedDuration = 0; 15485 15486 if (!react_spring_shared_esm_is.und(arg1) || !react_spring_shared_esm_is.und(arg2)) { 15487 const props = react_spring_shared_esm_is.obj(arg1) ? react_spring_core_esm_extends({}, arg1) : react_spring_core_esm_extends({}, arg2, { 15488 from: arg1 15489 }); 15490 15491 if (react_spring_shared_esm_is.und(props.default)) { 15492 props.default = true; 15493 } 15494 15495 this.start(props); 15496 } 15497 } 15498 15499 get idle() { 15500 return !(isAnimating(this) || this._state.asyncTo) || isPaused(this); 15501 } 15502 15503 get goal() { 15504 return getFluidValue(this.animation.to); 15505 } 15506 15507 get velocity() { 15508 const node = getAnimated(this); 15509 return node instanceof AnimatedValue ? node.lastVelocity || 0 : node.getPayload().map(node => node.lastVelocity || 0); 15510 } 15511 15512 get hasAnimated() { 15513 return hasAnimated(this); 15514 } 15515 15516 get isAnimating() { 15517 return isAnimating(this); 15518 } 15519 15520 get isPaused() { 15521 return isPaused(this); 15522 } 15523 15524 get isDelayed() { 15525 return this._state.delayed; 15526 } 15527 15528 advance(dt) { 15529 let idle = true; 15530 let changed = false; 15531 const anim = this.animation; 15532 let { 15533 config, 15534 toValues 15535 } = anim; 15536 const payload = getPayload(anim.to); 15537 15538 if (!payload && hasFluidValue(anim.to)) { 15539 toValues = react_spring_shared_esm_toArray(getFluidValue(anim.to)); 15540 } 15541 15542 anim.values.forEach((node, i) => { 15543 if (node.done) return; 15544 const to = node.constructor == AnimatedString ? 1 : payload ? payload[i].lastPosition : toValues[i]; 15545 let finished = anim.immediate; 15546 let position = to; 15547 15548 if (!finished) { 15549 position = node.lastPosition; 15550 15551 if (config.tension <= 0) { 15552 node.done = true; 15553 return; 15554 } 15555 15556 let elapsed = node.elapsedTime += dt; 15557 const from = anim.fromValues[i]; 15558 const v0 = node.v0 != null ? node.v0 : node.v0 = react_spring_shared_esm_is.arr(config.velocity) ? config.velocity[i] : config.velocity; 15559 let velocity; 15560 15561 if (!react_spring_shared_esm_is.und(config.duration)) { 15562 let p = 1; 15563 15564 if (config.duration > 0) { 15565 if (this._memoizedDuration !== config.duration) { 15566 this._memoizedDuration = config.duration; 15567 15568 if (node.durationProgress > 0) { 15569 node.elapsedTime = config.duration * node.durationProgress; 15570 elapsed = node.elapsedTime += dt; 15571 } 15572 } 15573 15574 p = (config.progress || 0) + elapsed / this._memoizedDuration; 15575 p = p > 1 ? 1 : p < 0 ? 0 : p; 15576 node.durationProgress = p; 15577 } 15578 15579 position = from + config.easing(p) * (to - from); 15580 velocity = (position - node.lastPosition) / dt; 15581 finished = p == 1; 15582 } else if (config.decay) { 15583 const decay = config.decay === true ? 0.998 : config.decay; 15584 const e = Math.exp(-(1 - decay) * elapsed); 15585 position = from + v0 / (1 - decay) * (1 - e); 15586 finished = Math.abs(node.lastPosition - position) < 0.1; 15587 velocity = v0 * e; 15588 } else { 15589 velocity = node.lastVelocity == null ? v0 : node.lastVelocity; 15590 const precision = config.precision || (from == to ? 0.005 : Math.min(1, Math.abs(to - from) * 0.001)); 15591 const restVelocity = config.restVelocity || precision / 10; 15592 const bounceFactor = config.clamp ? 0 : config.bounce; 15593 const canBounce = !react_spring_shared_esm_is.und(bounceFactor); 15594 const isGrowing = from == to ? node.v0 > 0 : from < to; 15595 let isMoving; 15596 let isBouncing = false; 15597 const step = 1; 15598 const numSteps = Math.ceil(dt / step); 15599 15600 for (let n = 0; n < numSteps; ++n) { 15601 isMoving = Math.abs(velocity) > restVelocity; 15602 15603 if (!isMoving) { 15604 finished = Math.abs(to - position) <= precision; 15605 15606 if (finished) { 15607 break; 15608 } 15609 } 15610 15611 if (canBounce) { 15612 isBouncing = position == to || position > to == isGrowing; 15613 15614 if (isBouncing) { 15615 velocity = -velocity * bounceFactor; 15616 position = to; 15617 } 15618 } 15619 15620 const springForce = -config.tension * 0.000001 * (position - to); 15621 const dampingForce = -config.friction * 0.001 * velocity; 15622 const acceleration = (springForce + dampingForce) / config.mass; 15623 velocity = velocity + acceleration * step; 15624 position = position + velocity * step; 15625 } 15626 } 15627 15628 node.lastVelocity = velocity; 15629 15630 if (Number.isNaN(position)) { 15631 console.warn(`Got NaN while animating:`, this); 15632 finished = true; 15633 } 15634 } 15635 15636 if (payload && !payload[i].done) { 15637 finished = false; 15638 } 15639 15640 if (finished) { 15641 node.done = true; 15642 } else { 15643 idle = false; 15644 } 15645 15646 if (node.setValue(position, config.round)) { 15647 changed = true; 15648 } 15649 }); 15650 const node = getAnimated(this); 15651 const currVal = node.getValue(); 15652 15653 if (idle) { 15654 const finalVal = getFluidValue(anim.to); 15655 15656 if ((currVal !== finalVal || changed) && !config.decay) { 15657 node.setValue(finalVal); 15658 15659 this._onChange(finalVal); 15660 } else if (changed && config.decay) { 15661 this._onChange(currVal); 15662 } 15663 15664 this._stop(); 15665 } else if (changed) { 15666 this._onChange(currVal); 15667 } 15668 } 15669 15670 set(value) { 15671 raf.batchedUpdates(() => { 15672 this._stop(); 15673 15674 this._focus(value); 15675 15676 this._set(value); 15677 }); 15678 return this; 15679 } 15680 15681 pause() { 15682 this._update({ 15683 pause: true 15684 }); 15685 } 15686 15687 resume() { 15688 this._update({ 15689 pause: false 15690 }); 15691 } 15692 15693 finish() { 15694 if (isAnimating(this)) { 15695 const { 15696 to, 15697 config 15698 } = this.animation; 15699 raf.batchedUpdates(() => { 15700 this._onStart(); 15701 15702 if (!config.decay) { 15703 this._set(to, false); 15704 } 15705 15706 this._stop(); 15707 }); 15708 } 15709 15710 return this; 15711 } 15712 15713 update(props) { 15714 const queue = this.queue || (this.queue = []); 15715 queue.push(props); 15716 return this; 15717 } 15718 15719 start(to, arg2) { 15720 let queue; 15721 15722 if (!react_spring_shared_esm_is.und(to)) { 15723 queue = [react_spring_shared_esm_is.obj(to) ? to : react_spring_core_esm_extends({}, arg2, { 15724 to 15725 })]; 15726 } else { 15727 queue = this.queue || []; 15728 this.queue = []; 15729 } 15730 15731 return Promise.all(queue.map(props => { 15732 const up = this._update(props); 15733 15734 return up; 15735 })).then(results => getCombinedResult(this, results)); 15736 } 15737 15738 stop(cancel) { 15739 const { 15740 to 15741 } = this.animation; 15742 15743 this._focus(this.get()); 15744 15745 stopAsync(this._state, cancel && this._lastCallId); 15746 raf.batchedUpdates(() => this._stop(to, cancel)); 15747 return this; 15748 } 15749 15750 reset() { 15751 this._update({ 15752 reset: true 15753 }); 15754 } 15755 15756 eventObserved(event) { 15757 if (event.type == 'change') { 15758 this._start(); 15759 } else if (event.type == 'priority') { 15760 this.priority = event.priority + 1; 15761 } 15762 } 15763 15764 _prepareNode(props) { 15765 const key = this.key || ''; 15766 let { 15767 to, 15768 from 15769 } = props; 15770 to = react_spring_shared_esm_is.obj(to) ? to[key] : to; 15771 15772 if (to == null || isAsyncTo(to)) { 15773 to = undefined; 15774 } 15775 15776 from = react_spring_shared_esm_is.obj(from) ? from[key] : from; 15777 15778 if (from == null) { 15779 from = undefined; 15780 } 15781 15782 const range = { 15783 to, 15784 from 15785 }; 15786 15787 if (!hasAnimated(this)) { 15788 if (props.reverse) [to, from] = [from, to]; 15789 from = getFluidValue(from); 15790 15791 if (!react_spring_shared_esm_is.und(from)) { 15792 this._set(from); 15793 } else if (!getAnimated(this)) { 15794 this._set(to); 15795 } 15796 } 15797 15798 return range; 15799 } 15800 15801 _update(_ref, isLoop) { 15802 let props = react_spring_core_esm_extends({}, _ref); 15803 15804 const { 15805 key, 15806 defaultProps 15807 } = this; 15808 if (props.default) Object.assign(defaultProps, getDefaultProps(props, (value, prop) => /^on/.test(prop) ? resolveProp(value, key) : value)); 15809 mergeActiveFn(this, props, 'onProps'); 15810 sendEvent(this, 'onProps', props, this); 15811 15812 const range = this._prepareNode(props); 15813 15814 if (Object.isFrozen(this)) { 15815 throw Error('Cannot animate a `SpringValue` object that is frozen. ' + 'Did you forget to pass your component to `animated(...)` before animating its props?'); 15816 } 15817 15818 const state = this._state; 15819 return scheduleProps(++this._lastCallId, { 15820 key, 15821 props, 15822 defaultProps, 15823 state, 15824 actions: { 15825 pause: () => { 15826 if (!isPaused(this)) { 15827 setPausedBit(this, true); 15828 flushCalls(state.pauseQueue); 15829 sendEvent(this, 'onPause', getFinishedResult(this, checkFinished(this, this.animation.to)), this); 15830 } 15831 }, 15832 resume: () => { 15833 if (isPaused(this)) { 15834 setPausedBit(this, false); 15835 15836 if (isAnimating(this)) { 15837 this._resume(); 15838 } 15839 15840 flushCalls(state.resumeQueue); 15841 sendEvent(this, 'onResume', getFinishedResult(this, checkFinished(this, this.animation.to)), this); 15842 } 15843 }, 15844 start: this._merge.bind(this, range) 15845 } 15846 }).then(result => { 15847 if (props.loop && result.finished && !(isLoop && result.noop)) { 15848 const nextProps = createLoopUpdate(props); 15849 15850 if (nextProps) { 15851 return this._update(nextProps, true); 15852 } 15853 } 15854 15855 return result; 15856 }); 15857 } 15858 15859 _merge(range, props, resolve) { 15860 if (props.cancel) { 15861 this.stop(true); 15862 return resolve(getCancelledResult(this)); 15863 } 15864 15865 const hasToProp = !react_spring_shared_esm_is.und(range.to); 15866 const hasFromProp = !react_spring_shared_esm_is.und(range.from); 15867 15868 if (hasToProp || hasFromProp) { 15869 if (props.callId > this._lastToId) { 15870 this._lastToId = props.callId; 15871 } else { 15872 return resolve(getCancelledResult(this)); 15873 } 15874 } 15875 15876 const { 15877 key, 15878 defaultProps, 15879 animation: anim 15880 } = this; 15881 const { 15882 to: prevTo, 15883 from: prevFrom 15884 } = anim; 15885 let { 15886 to = prevTo, 15887 from = prevFrom 15888 } = range; 15889 15890 if (hasFromProp && !hasToProp && (!props.default || react_spring_shared_esm_is.und(to))) { 15891 to = from; 15892 } 15893 15894 if (props.reverse) [to, from] = [from, to]; 15895 const hasFromChanged = !isEqual(from, prevFrom); 15896 15897 if (hasFromChanged) { 15898 anim.from = from; 15899 } 15900 15901 from = getFluidValue(from); 15902 const hasToChanged = !isEqual(to, prevTo); 15903 15904 if (hasToChanged) { 15905 this._focus(to); 15906 } 15907 15908 const hasAsyncTo = isAsyncTo(props.to); 15909 const { 15910 config 15911 } = anim; 15912 const { 15913 decay, 15914 velocity 15915 } = config; 15916 15917 if (hasToProp || hasFromProp) { 15918 config.velocity = 0; 15919 } 15920 15921 if (props.config && !hasAsyncTo) { 15922 mergeConfig(config, callProp(props.config, key), props.config !== defaultProps.config ? callProp(defaultProps.config, key) : void 0); 15923 } 15924 15925 let node = getAnimated(this); 15926 15927 if (!node || react_spring_shared_esm_is.und(to)) { 15928 return resolve(getFinishedResult(this, true)); 15929 } 15930 15931 const reset = react_spring_shared_esm_is.und(props.reset) ? hasFromProp && !props.default : !react_spring_shared_esm_is.und(from) && matchProp(props.reset, key); 15932 const value = reset ? from : this.get(); 15933 const goal = computeGoal(to); 15934 const isAnimatable = react_spring_shared_esm_is.num(goal) || react_spring_shared_esm_is.arr(goal) || isAnimatedString(goal); 15935 const immediate = !hasAsyncTo && (!isAnimatable || matchProp(defaultProps.immediate || props.immediate, key)); 15936 15937 if (hasToChanged) { 15938 const nodeType = getAnimatedType(to); 15939 15940 if (nodeType !== node.constructor) { 15941 if (immediate) { 15942 node = this._set(goal); 15943 } else throw Error(`Cannot animate between $node.constructor.name} and $nodeType.name}, as the "to" prop suggests`); 15944 } 15945 } 15946 15947 const goalType = node.constructor; 15948 let started = hasFluidValue(to); 15949 let finished = false; 15950 15951 if (!started) { 15952 const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged; 15953 15954 if (hasToChanged || hasValueChanged) { 15955 finished = isEqual(computeGoal(value), goal); 15956 started = !finished; 15957 } 15958 15959 if (!isEqual(anim.immediate, immediate) && !immediate || !isEqual(config.decay, decay) || !isEqual(config.velocity, velocity)) { 15960 started = true; 15961 } 15962 } 15963 15964 if (finished && isAnimating(this)) { 15965 if (anim.changed && !reset) { 15966 started = true; 15967 } else if (!started) { 15968 this._stop(prevTo); 15969 } 15970 } 15971 15972 if (!hasAsyncTo) { 15973 if (started || hasFluidValue(prevTo)) { 15974 anim.values = node.getPayload(); 15975 anim.toValues = hasFluidValue(to) ? null : goalType == AnimatedString ? [1] : react_spring_shared_esm_toArray(goal); 15976 } 15977 15978 if (anim.immediate != immediate) { 15979 anim.immediate = immediate; 15980 15981 if (!immediate && !reset) { 15982 this._set(prevTo); 15983 } 15984 } 15985 15986 if (started) { 15987 const { 15988 onRest 15989 } = anim; 15990 react_spring_shared_esm_each(ACTIVE_EVENTS, type => mergeActiveFn(this, props, type)); 15991 const result = getFinishedResult(this, checkFinished(this, prevTo)); 15992 flushCalls(this._pendingCalls, result); 15993 15994 this._pendingCalls.add(resolve); 15995 15996 if (anim.changed) raf.batchedUpdates(() => { 15997 anim.changed = !reset; 15998 onRest == null ? void 0 : onRest(result, this); 15999 16000 if (reset) { 16001 callProp(defaultProps.onRest, result); 16002 } else { 16003 anim.onStart == null ? void 0 : anim.onStart(result, this); 16004 } 16005 }); 16006 } 16007 } 16008 16009 if (reset) { 16010 this._set(value); 16011 } 16012 16013 if (hasAsyncTo) { 16014 resolve(runAsync(props.to, props, this._state, this)); 16015 } else if (started) { 16016 this._start(); 16017 } else if (isAnimating(this) && !hasToChanged) { 16018 this._pendingCalls.add(resolve); 16019 } else { 16020 resolve(getNoopResult(value)); 16021 } 16022 } 16023 16024 _focus(value) { 16025 const anim = this.animation; 16026 16027 if (value !== anim.to) { 16028 if (getFluidObservers(this)) { 16029 this._detach(); 16030 } 16031 16032 anim.to = value; 16033 16034 if (getFluidObservers(this)) { 16035 this._attach(); 16036 } 16037 } 16038 } 16039 16040 _attach() { 16041 let priority = 0; 16042 const { 16043 to 16044 } = this.animation; 16045 16046 if (hasFluidValue(to)) { 16047 addFluidObserver(to, this); 16048 16049 if (isFrameValue(to)) { 16050 priority = to.priority + 1; 16051 } 16052 } 16053 16054 this.priority = priority; 16055 } 16056 16057 _detach() { 16058 const { 16059 to 16060 } = this.animation; 16061 16062 if (hasFluidValue(to)) { 16063 removeFluidObserver(to, this); 16064 } 16065 } 16066 16067 _set(arg, idle = true) { 16068 const value = getFluidValue(arg); 16069 16070 if (!react_spring_shared_esm_is.und(value)) { 16071 const oldNode = getAnimated(this); 16072 16073 if (!oldNode || !isEqual(value, oldNode.getValue())) { 16074 const nodeType = getAnimatedType(value); 16075 16076 if (!oldNode || oldNode.constructor != nodeType) { 16077 setAnimated(this, nodeType.create(value)); 16078 } else { 16079 oldNode.setValue(value); 16080 } 16081 16082 if (oldNode) { 16083 raf.batchedUpdates(() => { 16084 this._onChange(value, idle); 16085 }); 16086 } 16087 } 16088 } 16089 16090 return getAnimated(this); 16091 } 16092 16093 _onStart() { 16094 const anim = this.animation; 16095 16096 if (!anim.changed) { 16097 anim.changed = true; 16098 sendEvent(this, 'onStart', getFinishedResult(this, checkFinished(this, anim.to)), this); 16099 } 16100 } 16101 16102 _onChange(value, idle) { 16103 if (!idle) { 16104 this._onStart(); 16105 16106 callProp(this.animation.onChange, value, this); 16107 } 16108 16109 callProp(this.defaultProps.onChange, value, this); 16110 16111 super._onChange(value, idle); 16112 } 16113 16114 _start() { 16115 const anim = this.animation; 16116 getAnimated(this).reset(getFluidValue(anim.to)); 16117 16118 if (!anim.immediate) { 16119 anim.fromValues = anim.values.map(node => node.lastPosition); 16120 } 16121 16122 if (!isAnimating(this)) { 16123 setActiveBit(this, true); 16124 16125 if (!isPaused(this)) { 16126 this._resume(); 16127 } 16128 } 16129 } 16130 16131 _resume() { 16132 if (globals.skipAnimation) { 16133 this.finish(); 16134 } else { 16135 frameLoop.start(this); 16136 } 16137 } 16138 16139 _stop(goal, cancel) { 16140 if (isAnimating(this)) { 16141 setActiveBit(this, false); 16142 const anim = this.animation; 16143 react_spring_shared_esm_each(anim.values, node => { 16144 node.done = true; 16145 }); 16146 16147 if (anim.toValues) { 16148 anim.onChange = anim.onPause = anim.onResume = undefined; 16149 } 16150 16151 callFluidObservers(this, { 16152 type: 'idle', 16153 parent: this 16154 }); 16155 const result = cancel ? getCancelledResult(this.get()) : getFinishedResult(this.get(), checkFinished(this, goal != null ? goal : anim.to)); 16156 flushCalls(this._pendingCalls, result); 16157 16158 if (anim.changed) { 16159 anim.changed = false; 16160 sendEvent(this, 'onRest', result, this); 16161 } 16162 } 16163 } 16164 16165 } 16166 16167 function checkFinished(target, to) { 16168 const goal = computeGoal(to); 16169 const value = computeGoal(target.get()); 16170 return isEqual(value, goal); 16171 } 16172 16173 function createLoopUpdate(props, loop = props.loop, to = props.to) { 16174 let loopRet = callProp(loop); 16175 16176 if (loopRet) { 16177 const overrides = loopRet !== true && inferTo(loopRet); 16178 const reverse = (overrides || props).reverse; 16179 const reset = !overrides || overrides.reset; 16180 return createUpdate(react_spring_core_esm_extends({}, props, { 16181 loop, 16182 default: false, 16183 pause: undefined, 16184 to: !reverse || isAsyncTo(to) ? to : undefined, 16185 from: reset ? props.from : undefined, 16186 reset 16187 }, overrides)); 16188 } 16189 } 16190 function createUpdate(props) { 16191 const { 16192 to, 16193 from 16194 } = props = inferTo(props); 16195 const keys = new Set(); 16196 if (react_spring_shared_esm_is.obj(to)) findDefined(to, keys); 16197 if (react_spring_shared_esm_is.obj(from)) findDefined(from, keys); 16198 props.keys = keys.size ? Array.from(keys) : null; 16199 return props; 16200 } 16201 function declareUpdate(props) { 16202 const update = createUpdate(props); 16203 16204 if (react_spring_shared_esm_is.und(update.default)) { 16205 update.default = getDefaultProps(update); 16206 } 16207 16208 return update; 16209 } 16210 16211 function findDefined(values, keys) { 16212 eachProp(values, (value, key) => value != null && keys.add(key)); 16213 } 16214 16215 const ACTIVE_EVENTS = ['onStart', 'onRest', 'onChange', 'onPause', 'onResume']; 16216 16217 function mergeActiveFn(target, props, type) { 16218 target.animation[type] = props[type] !== getDefaultProp(props, type) ? resolveProp(props[type], target.key) : undefined; 16219 } 16220 16221 function sendEvent(target, type, ...args) { 16222 var _target$animation$typ, _target$animation, _target$defaultProps$, _target$defaultProps; 16223 16224 (_target$animation$typ = (_target$animation = target.animation)[type]) == null ? void 0 : _target$animation$typ.call(_target$animation, ...args); 16225 (_target$defaultProps$ = (_target$defaultProps = target.defaultProps)[type]) == null ? void 0 : _target$defaultProps$.call(_target$defaultProps, ...args); 16226 } 16227 16228 const BATCHED_EVENTS = ['onStart', 'onChange', 'onRest']; 16229 let nextId = 1; 16230 class Controller { 16231 constructor(props, flush) { 16232 this.id = nextId++; 16233 this.springs = {}; 16234 this.queue = []; 16235 this.ref = void 0; 16236 this._flush = void 0; 16237 this._initialProps = void 0; 16238 this._lastAsyncId = 0; 16239 this._active = new Set(); 16240 this._changed = new Set(); 16241 this._started = false; 16242 this._item = void 0; 16243 this._state = { 16244 paused: false, 16245 pauseQueue: new Set(), 16246 resumeQueue: new Set(), 16247 timeouts: new Set() 16248 }; 16249 this._events = { 16250 onStart: new Map(), 16251 onChange: new Map(), 16252 onRest: new Map() 16253 }; 16254 this._onFrame = this._onFrame.bind(this); 16255 16256 if (flush) { 16257 this._flush = flush; 16258 } 16259 16260 if (props) { 16261 this.start(react_spring_core_esm_extends({ 16262 default: true 16263 }, props)); 16264 } 16265 } 16266 16267 get idle() { 16268 return !this._state.asyncTo && Object.values(this.springs).every(spring => { 16269 return spring.idle && !spring.isDelayed && !spring.isPaused; 16270 }); 16271 } 16272 16273 get item() { 16274 return this._item; 16275 } 16276 16277 set item(item) { 16278 this._item = item; 16279 } 16280 16281 get() { 16282 const values = {}; 16283 this.each((spring, key) => values[key] = spring.get()); 16284 return values; 16285 } 16286 16287 set(values) { 16288 for (const key in values) { 16289 const value = values[key]; 16290 16291 if (!react_spring_shared_esm_is.und(value)) { 16292 this.springs[key].set(value); 16293 } 16294 } 16295 } 16296 16297 update(props) { 16298 if (props) { 16299 this.queue.push(createUpdate(props)); 16300 } 16301 16302 return this; 16303 } 16304 16305 start(props) { 16306 let { 16307 queue 16308 } = this; 16309 16310 if (props) { 16311 queue = react_spring_shared_esm_toArray(props).map(createUpdate); 16312 } else { 16313 this.queue = []; 16314 } 16315 16316 if (this._flush) { 16317 return this._flush(this, queue); 16318 } 16319 16320 prepareKeys(this, queue); 16321 return flushUpdateQueue(this, queue); 16322 } 16323 16324 stop(arg, keys) { 16325 if (arg !== !!arg) { 16326 keys = arg; 16327 } 16328 16329 if (keys) { 16330 const springs = this.springs; 16331 react_spring_shared_esm_each(react_spring_shared_esm_toArray(keys), key => springs[key].stop(!!arg)); 16332 } else { 16333 stopAsync(this._state, this._lastAsyncId); 16334 this.each(spring => spring.stop(!!arg)); 16335 } 16336 16337 return this; 16338 } 16339 16340 pause(keys) { 16341 if (react_spring_shared_esm_is.und(keys)) { 16342 this.start({ 16343 pause: true 16344 }); 16345 } else { 16346 const springs = this.springs; 16347 react_spring_shared_esm_each(react_spring_shared_esm_toArray(keys), key => springs[key].pause()); 16348 } 16349 16350 return this; 16351 } 16352 16353 resume(keys) { 16354 if (react_spring_shared_esm_is.und(keys)) { 16355 this.start({ 16356 pause: false 16357 }); 16358 } else { 16359 const springs = this.springs; 16360 react_spring_shared_esm_each(react_spring_shared_esm_toArray(keys), key => springs[key].resume()); 16361 } 16362 16363 return this; 16364 } 16365 16366 each(iterator) { 16367 eachProp(this.springs, iterator); 16368 } 16369 16370 _onFrame() { 16371 const { 16372 onStart, 16373 onChange, 16374 onRest 16375 } = this._events; 16376 const active = this._active.size > 0; 16377 const changed = this._changed.size > 0; 16378 16379 if (active && !this._started || changed && !this._started) { 16380 this._started = true; 16381 flush(onStart, ([onStart, result]) => { 16382 result.value = this.get(); 16383 onStart(result, this, this._item); 16384 }); 16385 } 16386 16387 const idle = !active && this._started; 16388 const values = changed || idle && onRest.size ? this.get() : null; 16389 16390 if (changed && onChange.size) { 16391 flush(onChange, ([onChange, result]) => { 16392 result.value = values; 16393 onChange(result, this, this._item); 16394 }); 16395 } 16396 16397 if (idle) { 16398 this._started = false; 16399 flush(onRest, ([onRest, result]) => { 16400 result.value = values; 16401 onRest(result, this, this._item); 16402 }); 16403 } 16404 } 16405 16406 eventObserved(event) { 16407 if (event.type == 'change') { 16408 this._changed.add(event.parent); 16409 16410 if (!event.idle) { 16411 this._active.add(event.parent); 16412 } 16413 } else if (event.type == 'idle') { 16414 this._active.delete(event.parent); 16415 } else return; 16416 16417 raf.onFrame(this._onFrame); 16418 } 16419 16420 } 16421 function flushUpdateQueue(ctrl, queue) { 16422 return Promise.all(queue.map(props => flushUpdate(ctrl, props))).then(results => getCombinedResult(ctrl, results)); 16423 } 16424 async function flushUpdate(ctrl, props, isLoop) { 16425 const { 16426 keys, 16427 to, 16428 from, 16429 loop, 16430 onRest, 16431 onResolve 16432 } = props; 16433 const defaults = react_spring_shared_esm_is.obj(props.default) && props.default; 16434 16435 if (loop) { 16436 props.loop = false; 16437 } 16438 16439 if (to === false) props.to = null; 16440 if (from === false) props.from = null; 16441 const asyncTo = react_spring_shared_esm_is.arr(to) || react_spring_shared_esm_is.fun(to) ? to : undefined; 16442 16443 if (asyncTo) { 16444 props.to = undefined; 16445 props.onRest = undefined; 16446 16447 if (defaults) { 16448 defaults.onRest = undefined; 16449 } 16450 } else { 16451 react_spring_shared_esm_each(BATCHED_EVENTS, key => { 16452 const handler = props[key]; 16453 16454 if (react_spring_shared_esm_is.fun(handler)) { 16455 const queue = ctrl['_events'][key]; 16456 16457 props[key] = ({ 16458 finished, 16459 cancelled 16460 }) => { 16461 const result = queue.get(handler); 16462 16463 if (result) { 16464 if (!finished) result.finished = false; 16465 if (cancelled) result.cancelled = true; 16466 } else { 16467 queue.set(handler, { 16468 value: null, 16469 finished: finished || false, 16470 cancelled: cancelled || false 16471 }); 16472 } 16473 }; 16474 16475 if (defaults) { 16476 defaults[key] = props[key]; 16477 } 16478 } 16479 }); 16480 } 16481 16482 const state = ctrl['_state']; 16483 16484 if (props.pause === !state.paused) { 16485 state.paused = props.pause; 16486 flushCalls(props.pause ? state.pauseQueue : state.resumeQueue); 16487 } else if (state.paused) { 16488 props.pause = true; 16489 } 16490 16491 const promises = (keys || Object.keys(ctrl.springs)).map(key => ctrl.springs[key].start(props)); 16492 const cancel = props.cancel === true || getDefaultProp(props, 'cancel') === true; 16493 16494 if (asyncTo || cancel && state.asyncId) { 16495 promises.push(scheduleProps(++ctrl['_lastAsyncId'], { 16496 props, 16497 state, 16498 actions: { 16499 pause: noop, 16500 resume: noop, 16501 16502 start(props, resolve) { 16503 if (cancel) { 16504 stopAsync(state, ctrl['_lastAsyncId']); 16505 resolve(getCancelledResult(ctrl)); 16506 } else { 16507 props.onRest = onRest; 16508 resolve(runAsync(asyncTo, props, state, ctrl)); 16509 } 16510 } 16511 16512 } 16513 })); 16514 } 16515 16516 if (state.paused) { 16517 await new Promise(resume => { 16518 state.resumeQueue.add(resume); 16519 }); 16520 } 16521 16522 const result = getCombinedResult(ctrl, await Promise.all(promises)); 16523 16524 if (loop && result.finished && !(isLoop && result.noop)) { 16525 const nextProps = createLoopUpdate(props, loop, to); 16526 16527 if (nextProps) { 16528 prepareKeys(ctrl, [nextProps]); 16529 return flushUpdate(ctrl, nextProps, true); 16530 } 16531 } 16532 16533 if (onResolve) { 16534 raf.batchedUpdates(() => onResolve(result, ctrl, ctrl.item)); 16535 } 16536 16537 return result; 16538 } 16539 function getSprings(ctrl, props) { 16540 const springs = react_spring_core_esm_extends({}, ctrl.springs); 16541 16542 if (props) { 16543 react_spring_shared_esm_each(react_spring_shared_esm_toArray(props), props => { 16544 if (react_spring_shared_esm_is.und(props.keys)) { 16545 props = createUpdate(props); 16546 } 16547 16548 if (!react_spring_shared_esm_is.obj(props.to)) { 16549 props = react_spring_core_esm_extends({}, props, { 16550 to: undefined 16551 }); 16552 } 16553 16554 prepareSprings(springs, props, key => { 16555 return createSpring(key); 16556 }); 16557 }); 16558 } 16559 16560 setSprings(ctrl, springs); 16561 return springs; 16562 } 16563 function setSprings(ctrl, springs) { 16564 eachProp(springs, (spring, key) => { 16565 if (!ctrl.springs[key]) { 16566 ctrl.springs[key] = spring; 16567 addFluidObserver(spring, ctrl); 16568 } 16569 }); 16570 } 16571 16572 function createSpring(key, observer) { 16573 const spring = new SpringValue(); 16574 spring.key = key; 16575 16576 if (observer) { 16577 addFluidObserver(spring, observer); 16578 } 16579 16580 return spring; 16581 } 16582 16583 function prepareSprings(springs, props, create) { 16584 if (props.keys) { 16585 react_spring_shared_esm_each(props.keys, key => { 16586 const spring = springs[key] || (springs[key] = create(key)); 16587 spring['_prepareNode'](props); 16588 }); 16589 } 16590 } 16591 16592 function prepareKeys(ctrl, queue) { 16593 react_spring_shared_esm_each(queue, props => { 16594 prepareSprings(ctrl.springs, props, key => { 16595 return createSpring(key, ctrl); 16596 }); 16597 }); 16598 } 16599 16600 function _objectWithoutPropertiesLoose(source, excluded) { 16601 if (source == null) return {}; 16602 var target = {}; 16603 var sourceKeys = Object.keys(source); 16604 var key, i; 16605 16606 for (i = 0; i < sourceKeys.length; i++) { 16607 key = sourceKeys[i]; 16608 if (excluded.indexOf(key) >= 0) continue; 16609 target[key] = source[key]; 16610 } 16611 16612 return target; 16613 } 16614 16615 const _excluded$3 = ["children"]; 16616 const SpringContext = _ref => { 16617 let { 16618 children 16619 } = _ref, 16620 props = _objectWithoutPropertiesLoose(_ref, _excluded$3); 16621 16622 const inherited = (0,external_React_.useContext)(ctx); 16623 const pause = props.pause || !!inherited.pause, 16624 immediate = props.immediate || !!inherited.immediate; 16625 props = useMemoOne(() => ({ 16626 pause, 16627 immediate 16628 }), [pause, immediate]); 16629 const { 16630 Provider 16631 } = ctx; 16632 return external_React_.createElement(Provider, { 16633 value: props 16634 }, children); 16635 }; 16636 const ctx = makeContext(SpringContext, {}); 16637 SpringContext.Provider = ctx.Provider; 16638 SpringContext.Consumer = ctx.Consumer; 16639 16640 function makeContext(target, init) { 16641 Object.assign(target, external_React_.createContext(init)); 16642 target.Provider._context = target; 16643 target.Consumer._context = target; 16644 return target; 16645 } 16646 16647 const SpringRef = () => { 16648 const current = []; 16649 16650 const SpringRef = function SpringRef(props) { 16651 deprecateDirectCall(); 16652 const results = []; 16653 react_spring_shared_esm_each(current, (ctrl, i) => { 16654 if (react_spring_shared_esm_is.und(props)) { 16655 results.push(ctrl.start()); 16656 } else { 16657 const update = _getProps(props, ctrl, i); 16658 16659 if (update) { 16660 results.push(ctrl.start(update)); 16661 } 16662 } 16663 }); 16664 return results; 16665 }; 16666 16667 SpringRef.current = current; 16668 16669 SpringRef.add = function (ctrl) { 16670 if (!current.includes(ctrl)) { 16671 current.push(ctrl); 16672 } 16673 }; 16674 16675 SpringRef.delete = function (ctrl) { 16676 const i = current.indexOf(ctrl); 16677 if (~i) current.splice(i, 1); 16678 }; 16679 16680 SpringRef.pause = function () { 16681 react_spring_shared_esm_each(current, ctrl => ctrl.pause(...arguments)); 16682 return this; 16683 }; 16684 16685 SpringRef.resume = function () { 16686 react_spring_shared_esm_each(current, ctrl => ctrl.resume(...arguments)); 16687 return this; 16688 }; 16689 16690 SpringRef.set = function (values) { 16691 react_spring_shared_esm_each(current, ctrl => ctrl.set(values)); 16692 }; 16693 16694 SpringRef.start = function (props) { 16695 const results = []; 16696 react_spring_shared_esm_each(current, (ctrl, i) => { 16697 if (react_spring_shared_esm_is.und(props)) { 16698 results.push(ctrl.start()); 16699 } else { 16700 const update = this._getProps(props, ctrl, i); 16701 16702 if (update) { 16703 results.push(ctrl.start(update)); 16704 } 16705 } 16706 }); 16707 return results; 16708 }; 16709 16710 SpringRef.stop = function () { 16711 react_spring_shared_esm_each(current, ctrl => ctrl.stop(...arguments)); 16712 return this; 16713 }; 16714 16715 SpringRef.update = function (props) { 16716 react_spring_shared_esm_each(current, (ctrl, i) => ctrl.update(this._getProps(props, ctrl, i))); 16717 return this; 16718 }; 16719 16720 const _getProps = function _getProps(arg, ctrl, index) { 16721 return react_spring_shared_esm_is.fun(arg) ? arg(index, ctrl) : arg; 16722 }; 16723 16724 SpringRef._getProps = _getProps; 16725 return SpringRef; 16726 }; 16727 16728 function useSprings(length, props, deps) { 16729 const propsFn = react_spring_shared_esm_is.fun(props) && props; 16730 if (propsFn && !deps) deps = []; 16731 const ref = (0,external_React_.useMemo)(() => propsFn || arguments.length == 3 ? SpringRef() : void 0, []); 16732 const layoutId = (0,external_React_.useRef)(0); 16733 const forceUpdate = react_spring_shared_esm_useForceUpdate(); 16734 const state = (0,external_React_.useMemo)(() => ({ 16735 ctrls: [], 16736 queue: [], 16737 16738 flush(ctrl, updates) { 16739 const springs = getSprings(ctrl, updates); 16740 const canFlushSync = layoutId.current > 0 && !state.queue.length && !Object.keys(springs).some(key => !ctrl.springs[key]); 16741 return canFlushSync ? flushUpdateQueue(ctrl, updates) : new Promise(resolve => { 16742 setSprings(ctrl, springs); 16743 state.queue.push(() => { 16744 resolve(flushUpdateQueue(ctrl, updates)); 16745 }); 16746 forceUpdate(); 16747 }); 16748 } 16749 16750 }), []); 16751 const ctrls = (0,external_React_.useRef)([...state.ctrls]); 16752 const updates = []; 16753 const prevLength = react_spring_shared_esm_usePrev(length) || 0; 16754 (0,external_React_.useMemo)(() => { 16755 react_spring_shared_esm_each(ctrls.current.slice(length, prevLength), ctrl => { 16756 detachRefs(ctrl, ref); 16757 ctrl.stop(true); 16758 }); 16759 ctrls.current.length = length; 16760 declareUpdates(prevLength, length); 16761 }, [length]); 16762 (0,external_React_.useMemo)(() => { 16763 declareUpdates(0, Math.min(prevLength, length)); 16764 }, deps); 16765 16766 function declareUpdates(startIndex, endIndex) { 16767 for (let i = startIndex; i < endIndex; i++) { 16768 const ctrl = ctrls.current[i] || (ctrls.current[i] = new Controller(null, state.flush)); 16769 const update = propsFn ? propsFn(i, ctrl) : props[i]; 16770 16771 if (update) { 16772 updates[i] = declareUpdate(update); 16773 } 16774 } 16775 } 16776 16777 const springs = ctrls.current.map((ctrl, i) => getSprings(ctrl, updates[i])); 16778 const context = (0,external_React_.useContext)(SpringContext); 16779 const prevContext = react_spring_shared_esm_usePrev(context); 16780 const hasContext = context !== prevContext && hasProps(context); 16781 react_spring_shared_esm_useLayoutEffect(() => { 16782 layoutId.current++; 16783 state.ctrls = ctrls.current; 16784 const { 16785 queue 16786 } = state; 16787 16788 if (queue.length) { 16789 state.queue = []; 16790 react_spring_shared_esm_each(queue, cb => cb()); 16791 } 16792 16793 react_spring_shared_esm_each(ctrls.current, (ctrl, i) => { 16794 ref == null ? void 0 : ref.add(ctrl); 16795 16796 if (hasContext) { 16797 ctrl.start({ 16798 default: context 16799 }); 16800 } 16801 16802 const update = updates[i]; 16803 16804 if (update) { 16805 replaceRef(ctrl, update.ref); 16806 16807 if (ctrl.ref) { 16808 ctrl.queue.push(update); 16809 } else { 16810 ctrl.start(update); 16811 } 16812 } 16813 }); 16814 }); 16815 react_spring_shared_esm_useOnce(() => () => { 16816 react_spring_shared_esm_each(state.ctrls, ctrl => ctrl.stop(true)); 16817 }); 16818 const values = springs.map(x => react_spring_core_esm_extends({}, x)); 16819 return ref ? [values, ref] : values; 16820 } 16821 16822 function useSpring(props, deps) { 16823 const isFn = react_spring_shared_esm_is.fun(props); 16824 const [[values], ref] = useSprings(1, isFn ? props : [props], isFn ? deps || [] : deps); 16825 return isFn || arguments.length == 2 ? [values, ref] : values; 16826 } 16827 16828 const initSpringRef = () => SpringRef(); 16829 16830 const useSpringRef = () => useState(initSpringRef)[0]; 16831 16832 function useTrail(length, propsArg, deps) { 16833 var _passedRef; 16834 16835 const propsFn = is.fun(propsArg) && propsArg; 16836 if (propsFn && !deps) deps = []; 16837 let reverse = true; 16838 let passedRef = undefined; 16839 const result = useSprings(length, (i, ctrl) => { 16840 const props = propsFn ? propsFn(i, ctrl) : propsArg; 16841 passedRef = props.ref; 16842 reverse = reverse && props.reverse; 16843 return props; 16844 }, deps || [{}]); 16845 const ref = (_passedRef = passedRef) != null ? _passedRef : result[1]; 16846 useLayoutEffect(() => { 16847 each(ref.current, (ctrl, i) => { 16848 const parent = ref.current[i + (reverse ? 1 : -1)]; 16849 16850 if (parent) { 16851 ctrl.start({ 16852 to: parent.springs 16853 }); 16854 } else { 16855 ctrl.start(); 16856 } 16857 }); 16858 }, deps); 16859 16860 if (propsFn || arguments.length == 3) { 16861 ref['_getProps'] = (propsArg, ctrl, i) => { 16862 const props = is.fun(propsArg) ? propsArg(i, ctrl) : propsArg; 16863 16864 if (props) { 16865 const parent = ref.current[i + (props.reverse ? 1 : -1)]; 16866 if (parent) props.to = parent.springs; 16867 return props; 16868 } 16869 }; 16870 16871 return result; 16872 } 16873 16874 ref['start'] = propsArg => { 16875 const results = []; 16876 each(ref.current, (ctrl, i) => { 16877 const props = is.fun(propsArg) ? propsArg(i, ctrl) : propsArg; 16878 const parent = ref.current[i + (reverse ? 1 : -1)]; 16879 16880 if (parent) { 16881 results.push(ctrl.start(react_spring_core_esm_extends({}, props, { 16882 to: parent.springs 16883 }))); 16884 } else { 16885 results.push(ctrl.start(react_spring_core_esm_extends({}, props))); 16886 } 16887 }); 16888 return results; 16889 }; 16890 16891 return result[0]; 16892 } 16893 16894 let TransitionPhase; 16895 16896 (function (TransitionPhase) { 16897 TransitionPhase["MOUNT"] = "mount"; 16898 TransitionPhase["ENTER"] = "enter"; 16899 TransitionPhase["UPDATE"] = "update"; 16900 TransitionPhase["LEAVE"] = "leave"; 16901 })(TransitionPhase || (TransitionPhase = {})); 16902 16903 function useTransition(data, props, deps) { 16904 const propsFn = is.fun(props) && props; 16905 const { 16906 reset, 16907 sort, 16908 trail = 0, 16909 expires = true, 16910 exitBeforeEnter = false, 16911 onDestroyed, 16912 ref: propsRef, 16913 config: propsConfig 16914 } = propsFn ? propsFn() : props; 16915 const ref = useMemo(() => propsFn || arguments.length == 3 ? SpringRef() : void 0, []); 16916 const items = toArray(data); 16917 const transitions = []; 16918 const usedTransitions = useRef(null); 16919 const prevTransitions = reset ? null : usedTransitions.current; 16920 useLayoutEffect(() => { 16921 usedTransitions.current = transitions; 16922 }); 16923 useOnce(() => () => { 16924 each(usedTransitions.current, t => { 16925 if (t.expired) { 16926 clearTimeout(t.expirationId); 16927 } 16928 16929 detachRefs(t.ctrl, ref); 16930 t.ctrl.stop(true); 16931 }); 16932 }); 16933 const keys = getKeys(items, propsFn ? propsFn() : props, prevTransitions); 16934 const expired = reset && usedTransitions.current || []; 16935 useLayoutEffect(() => each(expired, ({ 16936 ctrl, 16937 item, 16938 key 16939 }) => { 16940 detachRefs(ctrl, ref); 16941 callProp(onDestroyed, item, key); 16942 })); 16943 const reused = []; 16944 if (prevTransitions) each(prevTransitions, (t, i) => { 16945 if (t.expired) { 16946 clearTimeout(t.expirationId); 16947 expired.push(t); 16948 } else { 16949 i = reused[i] = keys.indexOf(t.key); 16950 if (~i) transitions[i] = t; 16951 } 16952 }); 16953 each(items, (item, i) => { 16954 if (!transitions[i]) { 16955 transitions[i] = { 16956 key: keys[i], 16957 item, 16958 phase: TransitionPhase.MOUNT, 16959 ctrl: new Controller() 16960 }; 16961 transitions[i].ctrl.item = item; 16962 } 16963 }); 16964 16965 if (reused.length) { 16966 let i = -1; 16967 const { 16968 leave 16969 } = propsFn ? propsFn() : props; 16970 each(reused, (keyIndex, prevIndex) => { 16971 const t = prevTransitions[prevIndex]; 16972 16973 if (~keyIndex) { 16974 i = transitions.indexOf(t); 16975 transitions[i] = react_spring_core_esm_extends({}, t, { 16976 item: items[keyIndex] 16977 }); 16978 } else if (leave) { 16979 transitions.splice(++i, 0, t); 16980 } 16981 }); 16982 } 16983 16984 if (is.fun(sort)) { 16985 transitions.sort((a, b) => sort(a.item, b.item)); 16986 } 16987 16988 let delay = -trail; 16989 const forceUpdate = useForceUpdate(); 16990 const defaultProps = getDefaultProps(props); 16991 const changes = new Map(); 16992 const exitingTransitions = useRef(new Map()); 16993 const forceChange = useRef(false); 16994 each(transitions, (t, i) => { 16995 const key = t.key; 16996 const prevPhase = t.phase; 16997 const p = propsFn ? propsFn() : props; 16998 let to; 16999 let phase; 17000 let propsDelay = callProp(p.delay || 0, key); 17001 17002 if (prevPhase == TransitionPhase.MOUNT) { 17003 to = p.enter; 17004 phase = TransitionPhase.ENTER; 17005 } else { 17006 const isLeave = keys.indexOf(key) < 0; 17007 17008 if (prevPhase != TransitionPhase.LEAVE) { 17009 if (isLeave) { 17010 to = p.leave; 17011 phase = TransitionPhase.LEAVE; 17012 } else if (to = p.update) { 17013 phase = TransitionPhase.UPDATE; 17014 } else return; 17015 } else if (!isLeave) { 17016 to = p.enter; 17017 phase = TransitionPhase.ENTER; 17018 } else return; 17019 } 17020 17021 to = callProp(to, t.item, i); 17022 to = is.obj(to) ? inferTo(to) : { 17023 to 17024 }; 17025 17026 if (!to.config) { 17027 const config = propsConfig || defaultProps.config; 17028 to.config = callProp(config, t.item, i, phase); 17029 } 17030 17031 delay += trail; 17032 17033 const payload = react_spring_core_esm_extends({}, defaultProps, { 17034 delay: propsDelay + delay, 17035 ref: propsRef, 17036 immediate: p.immediate, 17037 reset: false 17038 }, to); 17039 17040 if (phase == TransitionPhase.ENTER && is.und(payload.from)) { 17041 const _p = propsFn ? propsFn() : props; 17042 17043 const from = is.und(_p.initial) || prevTransitions ? _p.from : _p.initial; 17044 payload.from = callProp(from, t.item, i); 17045 } 17046 17047 const { 17048 onResolve 17049 } = payload; 17050 17051 payload.onResolve = result => { 17052 callProp(onResolve, result); 17053 const transitions = usedTransitions.current; 17054 const t = transitions.find(t => t.key === key); 17055 if (!t) return; 17056 17057 if (result.cancelled && t.phase != TransitionPhase.UPDATE) { 17058 return; 17059 } 17060 17061 if (t.ctrl.idle) { 17062 const idle = transitions.every(t => t.ctrl.idle); 17063 17064 if (t.phase == TransitionPhase.LEAVE) { 17065 const expiry = callProp(expires, t.item); 17066 17067 if (expiry !== false) { 17068 const expiryMs = expiry === true ? 0 : expiry; 17069 t.expired = true; 17070 17071 if (!idle && expiryMs > 0) { 17072 if (expiryMs <= 0x7fffffff) t.expirationId = setTimeout(forceUpdate, expiryMs); 17073 return; 17074 } 17075 } 17076 } 17077 17078 if (idle && transitions.some(t => t.expired)) { 17079 exitingTransitions.current.delete(t); 17080 17081 if (exitBeforeEnter) { 17082 forceChange.current = true; 17083 } 17084 17085 forceUpdate(); 17086 } 17087 } 17088 }; 17089 17090 const springs = getSprings(t.ctrl, payload); 17091 17092 if (phase === TransitionPhase.LEAVE && exitBeforeEnter) { 17093 exitingTransitions.current.set(t, { 17094 phase, 17095 springs, 17096 payload 17097 }); 17098 } else { 17099 changes.set(t, { 17100 phase, 17101 springs, 17102 payload 17103 }); 17104 } 17105 }); 17106 const context = useContext(SpringContext); 17107 const prevContext = usePrev(context); 17108 const hasContext = context !== prevContext && hasProps(context); 17109 useLayoutEffect(() => { 17110 if (hasContext) { 17111 each(transitions, t => { 17112 t.ctrl.start({ 17113 default: context 17114 }); 17115 }); 17116 } 17117 }, [context]); 17118 each(changes, (_, t) => { 17119 if (exitingTransitions.current.size) { 17120 const ind = transitions.findIndex(state => state.key === t.key); 17121 transitions.splice(ind, 1); 17122 } 17123 }); 17124 useLayoutEffect(() => { 17125 each(exitingTransitions.current.size ? exitingTransitions.current : changes, ({ 17126 phase, 17127 payload 17128 }, t) => { 17129 const { 17130 ctrl 17131 } = t; 17132 t.phase = phase; 17133 ref == null ? void 0 : ref.add(ctrl); 17134 17135 if (hasContext && phase == TransitionPhase.ENTER) { 17136 ctrl.start({ 17137 default: context 17138 }); 17139 } 17140 17141 if (payload) { 17142 replaceRef(ctrl, payload.ref); 17143 17144 if (ctrl.ref && !forceChange.current) { 17145 ctrl.update(payload); 17146 } else { 17147 ctrl.start(payload); 17148 17149 if (forceChange.current) { 17150 forceChange.current = false; 17151 } 17152 } 17153 } 17154 }); 17155 }, reset ? void 0 : deps); 17156 17157 const renderTransitions = render => React.createElement(React.Fragment, null, transitions.map((t, i) => { 17158 const { 17159 springs 17160 } = changes.get(t) || t.ctrl; 17161 const elem = render(react_spring_core_esm_extends({}, springs), t.item, t, i); 17162 return elem && elem.type ? React.createElement(elem.type, react_spring_core_esm_extends({}, elem.props, { 17163 key: is.str(t.key) || is.num(t.key) ? t.key : t.ctrl.id, 17164 ref: elem.ref 17165 })) : elem; 17166 })); 17167 17168 return ref ? [renderTransitions, ref] : renderTransitions; 17169 } 17170 let nextKey = 1; 17171 17172 function getKeys(items, { 17173 key, 17174 keys = key 17175 }, prevTransitions) { 17176 if (keys === null) { 17177 const reused = new Set(); 17178 return items.map(item => { 17179 const t = prevTransitions && prevTransitions.find(t => t.item === item && t.phase !== TransitionPhase.LEAVE && !reused.has(t)); 17180 17181 if (t) { 17182 reused.add(t); 17183 return t.key; 17184 } 17185 17186 return nextKey++; 17187 }); 17188 } 17189 17190 return is.und(keys) ? items : is.fun(keys) ? items.map(keys) : toArray(keys); 17191 } 17192 17193 const _excluded$2 = (/* unused pure expression or super */ null && (["children"])); 17194 function Spring(_ref) { 17195 let { 17196 children 17197 } = _ref, 17198 props = _objectWithoutPropertiesLoose(_ref, _excluded$2); 17199 17200 return children(useSpring(props)); 17201 } 17202 17203 const _excluded$1 = (/* unused pure expression or super */ null && (["items", "children"])); 17204 function Trail(_ref) { 17205 let { 17206 items, 17207 children 17208 } = _ref, 17209 props = _objectWithoutPropertiesLoose(_ref, _excluded$1); 17210 17211 const trails = useTrail(items.length, props); 17212 return items.map((item, index) => { 17213 const result = children(item, index); 17214 return is.fun(result) ? result(trails[index]) : result; 17215 }); 17216 } 17217 17218 const _excluded = (/* unused pure expression or super */ null && (["items", "children"])); 17219 function Transition(_ref) { 17220 let { 17221 items, 17222 children 17223 } = _ref, 17224 props = _objectWithoutPropertiesLoose(_ref, _excluded); 17225 17226 return useTransition(items, props)(children); 17227 } 17228 17229 class Interpolation extends FrameValue { 17230 constructor(source, args) { 17231 super(); 17232 this.key = void 0; 17233 this.idle = true; 17234 this.calc = void 0; 17235 this._active = new Set(); 17236 this.source = source; 17237 this.calc = createInterpolator(...args); 17238 17239 const value = this._get(); 17240 17241 const nodeType = getAnimatedType(value); 17242 setAnimated(this, nodeType.create(value)); 17243 } 17244 17245 advance(_dt) { 17246 const value = this._get(); 17247 17248 const oldValue = this.get(); 17249 17250 if (!isEqual(value, oldValue)) { 17251 getAnimated(this).setValue(value); 17252 17253 this._onChange(value, this.idle); 17254 } 17255 17256 if (!this.idle && checkIdle(this._active)) { 17257 becomeIdle(this); 17258 } 17259 } 17260 17261 _get() { 17262 const inputs = react_spring_shared_esm_is.arr(this.source) ? this.source.map(getFluidValue) : react_spring_shared_esm_toArray(getFluidValue(this.source)); 17263 return this.calc(...inputs); 17264 } 17265 17266 _start() { 17267 if (this.idle && !checkIdle(this._active)) { 17268 this.idle = false; 17269 react_spring_shared_esm_each(getPayload(this), node => { 17270 node.done = false; 17271 }); 17272 17273 if (globals.skipAnimation) { 17274 raf.batchedUpdates(() => this.advance()); 17275 becomeIdle(this); 17276 } else { 17277 frameLoop.start(this); 17278 } 17279 } 17280 } 17281 17282 _attach() { 17283 let priority = 1; 17284 react_spring_shared_esm_each(react_spring_shared_esm_toArray(this.source), source => { 17285 if (hasFluidValue(source)) { 17286 addFluidObserver(source, this); 17287 } 17288 17289 if (isFrameValue(source)) { 17290 if (!source.idle) { 17291 this._active.add(source); 17292 } 17293 17294 priority = Math.max(priority, source.priority + 1); 17295 } 17296 }); 17297 this.priority = priority; 17298 17299 this._start(); 17300 } 17301 17302 _detach() { 17303 react_spring_shared_esm_each(react_spring_shared_esm_toArray(this.source), source => { 17304 if (hasFluidValue(source)) { 17305 removeFluidObserver(source, this); 17306 } 17307 }); 17308 17309 this._active.clear(); 17310 17311 becomeIdle(this); 17312 } 17313 17314 eventObserved(event) { 17315 if (event.type == 'change') { 17316 if (event.idle) { 17317 this.advance(); 17318 } else { 17319 this._active.add(event.parent); 17320 17321 this._start(); 17322 } 17323 } else if (event.type == 'idle') { 17324 this._active.delete(event.parent); 17325 } else if (event.type == 'priority') { 17326 this.priority = react_spring_shared_esm_toArray(this.source).reduce((highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1), 0); 17327 } 17328 } 17329 17330 } 17331 17332 function isIdle(source) { 17333 return source.idle !== false; 17334 } 17335 17336 function checkIdle(active) { 17337 return !active.size || Array.from(active).every(isIdle); 17338 } 17339 17340 function becomeIdle(self) { 17341 if (!self.idle) { 17342 self.idle = true; 17343 react_spring_shared_esm_each(getPayload(self), node => { 17344 node.done = true; 17345 }); 17346 callFluidObservers(self, { 17347 type: 'idle', 17348 parent: self 17349 }); 17350 } 17351 } 17352 17353 const react_spring_core_esm_to = (source, ...args) => new Interpolation(source, args); 17354 const react_spring_core_esm_interpolate = (source, ...args) => (deprecateInterpolate(), new Interpolation(source, args)); 17355 17356 globals.assign({ 17357 createStringInterpolator: createStringInterpolator, 17358 to: (source, args) => new Interpolation(source, args) 17359 }); 17360 const react_spring_core_esm_update = frameLoop.advance; 17361 17362 17363 17364 ;// CONCATENATED MODULE: external "ReactDOM" 17365 var external_ReactDOM_namespaceObject = window["ReactDOM"]; 17366 ;// CONCATENATED MODULE: ./node_modules/@react-spring/web/dist/react-spring-web.esm.js 17367 17368 17369 17370 17371 17372 17373 function react_spring_web_esm_objectWithoutPropertiesLoose(source, excluded) { 17374 if (source == null) return {}; 17375 var target = {}; 17376 var sourceKeys = Object.keys(source); 17377 var key, i; 17378 17379 for (i = 0; i < sourceKeys.length; i++) { 17380 key = sourceKeys[i]; 17381 if (excluded.indexOf(key) >= 0) continue; 17382 target[key] = source[key]; 17383 } 17384 17385 return target; 17386 } 17387 17388 const react_spring_web_esm_excluded$2 = ["style", "children", "scrollTop", "scrollLeft"]; 17389 const isCustomPropRE = /^--/; 17390 17391 function dangerousStyleValue(name, value) { 17392 if (value == null || typeof value === 'boolean' || value === '') return ''; 17393 if (typeof value === 'number' && value !== 0 && !isCustomPropRE.test(name) && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) return value + 'px'; 17394 return ('' + value).trim(); 17395 } 17396 17397 const attributeCache = {}; 17398 function applyAnimatedValues(instance, props) { 17399 if (!instance.nodeType || !instance.setAttribute) { 17400 return false; 17401 } 17402 17403 const isFilterElement = instance.nodeName === 'filter' || instance.parentNode && instance.parentNode.nodeName === 'filter'; 17404 17405 const _ref = props, 17406 { 17407 style, 17408 children, 17409 scrollTop, 17410 scrollLeft 17411 } = _ref, 17412 attributes = react_spring_web_esm_objectWithoutPropertiesLoose(_ref, react_spring_web_esm_excluded$2); 17413 17414 const values = Object.values(attributes); 17415 const names = Object.keys(attributes).map(name => isFilterElement || instance.hasAttribute(name) ? name : attributeCache[name] || (attributeCache[name] = name.replace(/([A-Z])/g, n => '-' + n.toLowerCase()))); 17416 17417 if (children !== void 0) { 17418 instance.textContent = children; 17419 } 17420 17421 for (let name in style) { 17422 if (style.hasOwnProperty(name)) { 17423 const value = dangerousStyleValue(name, style[name]); 17424 17425 if (isCustomPropRE.test(name)) { 17426 instance.style.setProperty(name, value); 17427 } else { 17428 instance.style[name] = value; 17429 } 17430 } 17431 } 17432 17433 names.forEach((name, i) => { 17434 instance.setAttribute(name, values[i]); 17435 }); 17436 17437 if (scrollTop !== void 0) { 17438 instance.scrollTop = scrollTop; 17439 } 17440 17441 if (scrollLeft !== void 0) { 17442 instance.scrollLeft = scrollLeft; 17443 } 17444 } 17445 let isUnitlessNumber = { 17446 animationIterationCount: true, 17447 borderImageOutset: true, 17448 borderImageSlice: true, 17449 borderImageWidth: true, 17450 boxFlex: true, 17451 boxFlexGroup: true, 17452 boxOrdinalGroup: true, 17453 columnCount: true, 17454 columns: true, 17455 flex: true, 17456 flexGrow: true, 17457 flexPositive: true, 17458 flexShrink: true, 17459 flexNegative: true, 17460 flexOrder: true, 17461 gridRow: true, 17462 gridRowEnd: true, 17463 gridRowSpan: true, 17464 gridRowStart: true, 17465 gridColumn: true, 17466 gridColumnEnd: true, 17467 gridColumnSpan: true, 17468 gridColumnStart: true, 17469 fontWeight: true, 17470 lineClamp: true, 17471 lineHeight: true, 17472 opacity: true, 17473 order: true, 17474 orphans: true, 17475 tabSize: true, 17476 widows: true, 17477 zIndex: true, 17478 zoom: true, 17479 fillOpacity: true, 17480 floodOpacity: true, 17481 stopOpacity: true, 17482 strokeDasharray: true, 17483 strokeDashoffset: true, 17484 strokeMiterlimit: true, 17485 strokeOpacity: true, 17486 strokeWidth: true 17487 }; 17488 17489 const prefixKey = (prefix, key) => prefix + key.charAt(0).toUpperCase() + key.substring(1); 17490 17491 const prefixes = ['Webkit', 'Ms', 'Moz', 'O']; 17492 isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => { 17493 prefixes.forEach(prefix => acc[prefixKey(prefix, prop)] = acc[prop]); 17494 return acc; 17495 }, isUnitlessNumber); 17496 17497 const react_spring_web_esm_excluded$1 = ["x", "y", "z"]; 17498 const domTransforms = /^(matrix|translate|scale|rotate|skew)/; 17499 const pxTransforms = /^(translate)/; 17500 const degTransforms = /^(rotate|skew)/; 17501 17502 const addUnit = (value, unit) => react_spring_shared_esm_is.num(value) && value !== 0 ? value + unit : value; 17503 17504 const isValueIdentity = (value, id) => react_spring_shared_esm_is.arr(value) ? value.every(v => isValueIdentity(v, id)) : react_spring_shared_esm_is.num(value) ? value === id : parseFloat(value) === id; 17505 17506 class AnimatedStyle extends AnimatedObject { 17507 constructor(_ref) { 17508 let { 17509 x, 17510 y, 17511 z 17512 } = _ref, 17513 style = react_spring_web_esm_objectWithoutPropertiesLoose(_ref, react_spring_web_esm_excluded$1); 17514 17515 const inputs = []; 17516 const transforms = []; 17517 17518 if (x || y || z) { 17519 inputs.push([x || 0, y || 0, z || 0]); 17520 transforms.push(xyz => [`translate3d($xyz.map(v => addUnit(v, 'px')).join(',')})`, isValueIdentity(xyz, 0)]); 17521 } 17522 17523 eachProp(style, (value, key) => { 17524 if (key === 'transform') { 17525 inputs.push([value || '']); 17526 transforms.push(transform => [transform, transform === '']); 17527 } else if (domTransforms.test(key)) { 17528 delete style[key]; 17529 if (react_spring_shared_esm_is.und(value)) return; 17530 const unit = pxTransforms.test(key) ? 'px' : degTransforms.test(key) ? 'deg' : ''; 17531 inputs.push(react_spring_shared_esm_toArray(value)); 17532 transforms.push(key === 'rotate3d' ? ([x, y, z, deg]) => [`rotate3d($x},$y},$z},$addUnit(deg, unit)})`, isValueIdentity(deg, 0)] : input => [`$key}($input.map(v => addUnit(v, unit)).join(',')})`, isValueIdentity(input, key.startsWith('scale') ? 1 : 0)]); 17533 } 17534 }); 17535 17536 if (inputs.length) { 17537 style.transform = new FluidTransform(inputs, transforms); 17538 } 17539 17540 super(style); 17541 } 17542 17543 } 17544 17545 class FluidTransform extends FluidValue { 17546 constructor(inputs, transforms) { 17547 super(); 17548 this._value = null; 17549 this.inputs = inputs; 17550 this.transforms = transforms; 17551 } 17552 17553 get() { 17554 return this._value || (this._value = this._get()); 17555 } 17556 17557 _get() { 17558 let transform = ''; 17559 let identity = true; 17560 react_spring_shared_esm_each(this.inputs, (input, i) => { 17561 const arg1 = getFluidValue(input[0]); 17562 const [t, id] = this.transforms[i](react_spring_shared_esm_is.arr(arg1) ? arg1 : input.map(getFluidValue)); 17563 transform += ' ' + t; 17564 identity = identity && id; 17565 }); 17566 return identity ? 'none' : transform; 17567 } 17568 17569 observerAdded(count) { 17570 if (count == 1) react_spring_shared_esm_each(this.inputs, input => react_spring_shared_esm_each(input, value => hasFluidValue(value) && addFluidObserver(value, this))); 17571 } 17572 17573 observerRemoved(count) { 17574 if (count == 0) react_spring_shared_esm_each(this.inputs, input => react_spring_shared_esm_each(input, value => hasFluidValue(value) && removeFluidObserver(value, this))); 17575 } 17576 17577 eventObserved(event) { 17578 if (event.type == 'change') { 17579 this._value = null; 17580 } 17581 17582 callFluidObservers(this, event); 17583 } 17584 17585 } 17586 17587 const primitives = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr', 'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan']; 17588 17589 const react_spring_web_esm_excluded = ["scrollTop", "scrollLeft"]; 17590 globals.assign({ 17591 batchedUpdates: external_ReactDOM_namespaceObject.unstable_batchedUpdates, 17592 createStringInterpolator: createStringInterpolator, 17593 colors: colors 17594 }); 17595 const host = createHost(primitives, { 17596 applyAnimatedValues, 17597 createAnimatedStyle: style => new AnimatedStyle(style), 17598 getComponentProps: _ref => { 17599 let props = react_spring_web_esm_objectWithoutPropertiesLoose(_ref, react_spring_web_esm_excluded); 17600 17601 return props; 17602 } 17603 }); 17604 const animated = host.animated; 17605 17606 17607 17608 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-moving-animation/index.js 17609 /** 17610 * External dependencies 17611 */ 17612 17613 /** 17614 * WordPress dependencies 17615 */ 17616 17617 17618 17619 17620 /** 17621 * Simple reducer used to increment a counter. 17622 * 17623 * @param {number} state Previous counter value. 17624 * @return {number} New state value. 17625 */ 17626 17627 const counterReducer = state => state + 1; 17628 17629 const getAbsolutePosition = element => { 17630 return { 17631 top: element.offsetTop, 17632 left: element.offsetLeft 17633 }; 17634 }; 17635 /** 17636 * Hook used to compute the styles required to move a div into a new position. 17637 * 17638 * The way this animation works is the following: 17639 * - It first renders the element as if there was no animation. 17640 * - It takes a snapshot of the position of the block to use it 17641 * as a destination point for the animation. 17642 * - It restores the element to the previous position using a CSS transform 17643 * - It uses the "resetAnimation" flag to reset the animation 17644 * from the beginning in order to animate to the new destination point. 17645 * 17646 * @param {Object} $1 Options 17647 * @param {boolean} $1.isSelected Whether it's the current block or not. 17648 * @param {boolean} $1.adjustScrolling Adjust the scroll position to the current block. 17649 * @param {boolean} $1.enableAnimation Enable/Disable animation. 17650 * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes. 17651 */ 17652 17653 17654 function useMovingAnimation(_ref) { 17655 let { 17656 isSelected, 17657 adjustScrolling, 17658 enableAnimation, 17659 triggerAnimationOnChange 17660 } = _ref; 17661 const ref = (0,external_wp_element_namespaceObject.useRef)(); 17662 const prefersReducedMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)() || !enableAnimation; 17663 const [triggeredAnimation, triggerAnimation] = (0,external_wp_element_namespaceObject.useReducer)(counterReducer, 0); 17664 const [finishedAnimation, endAnimation] = (0,external_wp_element_namespaceObject.useReducer)(counterReducer, 0); 17665 const [transform, setTransform] = (0,external_wp_element_namespaceObject.useState)({ 17666 x: 0, 17667 y: 0 17668 }); 17669 const previous = (0,external_wp_element_namespaceObject.useMemo)(() => ref.current ? getAbsolutePosition(ref.current) : null, [triggerAnimationOnChange]); // Calculate the previous position of the block relative to the viewport and 17670 // return a function to maintain that position by scrolling. 17671 17672 const preserveScrollPosition = (0,external_wp_element_namespaceObject.useMemo)(() => { 17673 if (!adjustScrolling || !ref.current) { 17674 return () => {}; 17675 } 17676 17677 const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(ref.current); 17678 17679 if (!scrollContainer) { 17680 return () => {}; 17681 } 17682 17683 const prevRect = ref.current.getBoundingClientRect(); 17684 return () => { 17685 const blockRect = ref.current.getBoundingClientRect(); 17686 const diff = blockRect.top - prevRect.top; 17687 17688 if (diff) { 17689 scrollContainer.scrollTop += diff; 17690 } 17691 }; 17692 }, [triggerAnimationOnChange, adjustScrolling]); 17693 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 17694 if (triggeredAnimation) { 17695 endAnimation(); 17696 } 17697 }, [triggeredAnimation]); 17698 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 17699 if (!previous) { 17700 return; 17701 } 17702 17703 if (prefersReducedMotion) { 17704 // If the animation is disabled and the scroll needs to be adjusted, 17705 // just move directly to the final scroll position. 17706 preserveScrollPosition(); 17707 return; 17708 } 17709 17710 ref.current.style.transform = ''; 17711 const destination = getAbsolutePosition(ref.current); 17712 triggerAnimation(); 17713 setTransform({ 17714 x: Math.round(previous.left - destination.left), 17715 y: Math.round(previous.top - destination.top) 17716 }); 17717 }, [triggerAnimationOnChange]); // Only called when either the x or y value changes. 17718 17719 function onFrameChange(_ref2) { 17720 let { 17721 x, 17722 y 17723 } = _ref2; 17724 17725 if (!ref.current) { 17726 return; 17727 } 17728 17729 const isMoving = x === 0 && y === 0; 17730 ref.current.style.transformOrigin = isMoving ? '' : 'center'; 17731 ref.current.style.transform = isMoving ? '' : `translate3d($x}px,$y}px,0)`; 17732 ref.current.style.zIndex = !isSelected || isMoving ? '' : '1'; 17733 preserveScrollPosition(); 17734 } // Called for every frame computed by useSpring. 17735 17736 17737 function onChange(_ref3) { 17738 let { 17739 value 17740 } = _ref3; 17741 let { 17742 x, 17743 y 17744 } = value; 17745 x = Math.round(x); 17746 y = Math.round(y); 17747 17748 if (x !== onChange.x || y !== onChange.y) { 17749 onFrameChange({ 17750 x, 17751 y 17752 }); 17753 onChange.x = x; 17754 onChange.y = y; 17755 } 17756 } 17757 17758 onChange.x = 0; 17759 onChange.y = 0; 17760 useSpring({ 17761 from: { 17762 x: transform.x, 17763 y: transform.y 17764 }, 17765 to: { 17766 x: 0, 17767 y: 0 17768 }, 17769 reset: triggeredAnimation !== finishedAnimation, 17770 config: { 17771 mass: 5, 17772 tension: 2000, 17773 friction: 200 17774 }, 17775 immediate: prefersReducedMotion, 17776 onChange 17777 }); 17778 return ref; 17779 } 17780 17781 /* harmony default export */ var use_moving_animation = (useMovingAnimation); 17782 17783 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/dom.js 17784 const BLOCK_SELECTOR = '.block-editor-block-list__block'; 17785 const APPENDER_SELECTOR = '.block-list-appender'; 17786 const BLOCK_APPENDER_CLASS = '.block-editor-button-block-appender'; 17787 /** 17788 * Returns true if two elements are contained within the same block. 17789 * 17790 * @param {Element} a First element. 17791 * @param {Element} b Second element. 17792 * 17793 * @return {boolean} Whether elements are in the same block. 17794 */ 17795 17796 function isInSameBlock(a, b) { 17797 return a.closest(BLOCK_SELECTOR) === b.closest(BLOCK_SELECTOR); 17798 } 17799 /** 17800 * Returns true if an element is considered part of the block and not its inner 17801 * blocks or appender. 17802 * 17803 * @param {Element} blockElement Block container element. 17804 * @param {Element} element Element. 17805 * 17806 * @return {boolean} Whether an element is considered part of the block and not 17807 * its inner blocks or appender. 17808 */ 17809 17810 function isInsideRootBlock(blockElement, element) { 17811 const parentBlock = element.closest([BLOCK_SELECTOR, APPENDER_SELECTOR, BLOCK_APPENDER_CLASS].join(',')); 17812 return parentBlock === blockElement; 17813 } 17814 /** 17815 * Finds the block client ID given any DOM node inside the block. 17816 * 17817 * @param {Node?} node DOM node. 17818 * 17819 * @return {string|undefined} Client ID or undefined if the node is not part of 17820 * a block. 17821 */ 17822 17823 function getBlockClientId(node) { 17824 while (node && node.nodeType !== node.ELEMENT_NODE) { 17825 node = node.parentNode; 17826 } 17827 17828 if (!node) { 17829 return; 17830 } 17831 17832 const elementNode = 17833 /** @type {Element} */ 17834 node; 17835 const blockNode = elementNode.closest(BLOCK_SELECTOR); 17836 17837 if (!blockNode) { 17838 return; 17839 } 17840 17841 return blockNode.id.slice('block-'.length); 17842 } 17843 17844 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-focus-first-element.js 17845 /** 17846 * External dependencies 17847 */ 17848 17849 /** 17850 * WordPress dependencies 17851 */ 17852 17853 17854 17855 17856 /** 17857 * Internal dependencies 17858 */ 17859 17860 17861 17862 /** @typedef {import('@wordpress/element').RefObject} RefObject */ 17863 17864 /** 17865 * Returns the initial position if the block needs to be focussed, `undefined` 17866 * otherwise. The initial position is either 0 (start) or -1 (end). 17867 * 17868 * @param {string} clientId Block client ID. 17869 * 17870 * @return {number} The initial position, either 0 (start) or -1 (end). 17871 */ 17872 17873 function useInitialPosition(clientId) { 17874 return (0,external_wp_data_namespaceObject.useSelect)(select => { 17875 const { 17876 getSelectedBlocksInitialCaretPosition, 17877 isNavigationMode, 17878 isBlockSelected 17879 } = select(store); 17880 17881 if (!isBlockSelected(clientId)) { 17882 return; 17883 } 17884 17885 if (isNavigationMode()) { 17886 return; 17887 } // If there's no initial position, return 0 to focus the start. 17888 17889 17890 return getSelectedBlocksInitialCaretPosition(); 17891 }, [clientId]); 17892 } 17893 /** 17894 * Transitions focus to the block or inner tabbable when the block becomes 17895 * selected and an initial position is set. 17896 * 17897 * @param {string} clientId Block client ID. 17898 * 17899 * @return {RefObject} React ref with the block element. 17900 */ 17901 17902 17903 function useFocusFirstElement(clientId) { 17904 const ref = (0,external_wp_element_namespaceObject.useRef)(); 17905 const initialPosition = useInitialPosition(clientId); 17906 const { 17907 isBlockSelected, 17908 isMultiSelecting 17909 } = (0,external_wp_data_namespaceObject.useSelect)(store); 17910 (0,external_wp_element_namespaceObject.useEffect)(() => { 17911 // Check if the block is still selected at the time this effect runs. 17912 if (!isBlockSelected(clientId) || isMultiSelecting()) { 17913 return; 17914 } 17915 17916 if (initialPosition === undefined || initialPosition === null) { 17917 return; 17918 } 17919 17920 if (!ref.current) { 17921 return; 17922 } 17923 17924 const { 17925 ownerDocument 17926 } = ref.current; // Do not focus the block if it already contains the active element. 17927 17928 if (ref.current.contains(ownerDocument.activeElement)) { 17929 return; 17930 } // Find all tabbables within node. 17931 17932 17933 const textInputs = external_wp_dom_namespaceObject.focus.tabbable.find(ref.current).filter(node => (0,external_wp_dom_namespaceObject.isTextField)(node)); // If reversed (e.g. merge via backspace), use the last in the set of 17934 // tabbables. 17935 17936 const isReverse = -1 === initialPosition; 17937 const target = (isReverse ? external_lodash_namespaceObject.last : external_lodash_namespaceObject.first)(textInputs) || ref.current; 17938 17939 if (!isInsideRootBlock(ref.current, target)) { 17940 ref.current.focus(); 17941 return; 17942 } // Check to see if element is focussable before a generic caret insert. 17943 17944 17945 if (!ref.current.getAttribute('contenteditable')) { 17946 const focusElement = external_wp_dom_namespaceObject.focus.tabbable.findNext(ref.current); // Make sure focusElement is valid, contained in the same block, and a form field. 17947 17948 if (focusElement && isInsideRootBlock(ref.current, focusElement) && (0,external_wp_dom_namespaceObject.isFormElement)(focusElement)) { 17949 focusElement.focus(); 17950 return; 17951 } 17952 } 17953 17954 (0,external_wp_dom_namespaceObject.placeCaretAtHorizontalEdge)(target, isReverse); 17955 }, [initialPosition, clientId]); 17956 return ref; 17957 } 17958 17959 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-is-hovered.js 17960 /** 17961 * WordPress dependencies 17962 */ 17963 17964 17965 /** 17966 * Internal dependencies 17967 */ 17968 17969 17970 17971 function listener(event) { 17972 if (event.defaultPrevented) { 17973 return; 17974 } 17975 17976 const action = event.type === 'mouseover' ? 'add' : 'remove'; 17977 event.preventDefault(); 17978 event.currentTarget.classList[action]('is-hovered'); 17979 } 17980 /** 17981 * Adds `is-hovered` class when the block is hovered and in navigation or 17982 * outline mode. 17983 */ 17984 17985 17986 function useIsHovered() { 17987 const isEnabled = (0,external_wp_data_namespaceObject.useSelect)(select => { 17988 const { 17989 isNavigationMode, 17990 getSettings 17991 } = select(store); 17992 return isNavigationMode() || getSettings().outlineMode; 17993 }, []); 17994 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 17995 if (isEnabled) { 17996 node.addEventListener('mouseout', listener); 17997 node.addEventListener('mouseover', listener); 17998 return () => { 17999 node.removeEventListener('mouseout', listener); 18000 node.removeEventListener('mouseover', listener); // Remove class in case it lingers. 18001 18002 node.classList.remove('is-hovered'); 18003 }; 18004 } 18005 }, [isEnabled]); 18006 } 18007 18008 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-class-names.js 18009 /** 18010 * External dependencies 18011 */ 18012 18013 /** 18014 * WordPress dependencies 18015 */ 18016 18017 18018 18019 /** 18020 * Internal dependencies 18021 */ 18022 18023 18024 /** 18025 * Returns the class names used for the different states of the block. 18026 * 18027 * @param {string} clientId The block client ID. 18028 * 18029 * @return {string} The class names. 18030 */ 18031 18032 function useBlockClassNames(clientId) { 18033 return (0,external_wp_data_namespaceObject.useSelect)(select => { 18034 const { 18035 isBlockBeingDragged, 18036 isBlockHighlighted, 18037 isBlockSelected, 18038 isBlockMultiSelected, 18039 getBlockName, 18040 getSettings, 18041 hasSelectedInnerBlock, 18042 isTyping, 18043 __experimentalGetActiveBlockIdByBlockNames: getActiveBlockIdByBlockNames 18044 } = select(store); 18045 const { 18046 __experimentalSpotlightEntityBlocks: spotlightEntityBlocks, 18047 outlineMode 18048 } = getSettings(); 18049 const isDragging = isBlockBeingDragged(clientId); 18050 const isSelected = isBlockSelected(clientId); 18051 const name = getBlockName(clientId); 18052 const checkDeep = true; // "ancestor" is the more appropriate label due to "deep" check. 18053 18054 const isAncestorOfSelectedBlock = hasSelectedInnerBlock(clientId, checkDeep); 18055 const activeEntityBlockId = getActiveBlockIdByBlockNames(spotlightEntityBlocks); 18056 return classnames_default()({ 18057 'is-selected': isSelected, 18058 'is-highlighted': isBlockHighlighted(clientId), 18059 'is-multi-selected': isBlockMultiSelected(clientId), 18060 'is-reusable': (0,external_wp_blocks_namespaceObject.isReusableBlock)((0,external_wp_blocks_namespaceObject.getBlockType)(name)), 18061 'is-dragging': isDragging, 18062 'has-child-selected': isAncestorOfSelectedBlock, 18063 'has-active-entity': activeEntityBlockId, 18064 // Determine if there is an active entity area to spotlight. 18065 'is-active-entity': activeEntityBlockId === clientId, 18066 'remove-outline': isSelected && outlineMode && isTyping() 18067 }); 18068 }, [clientId]); 18069 } 18070 18071 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-default-class-name.js 18072 /** 18073 * WordPress dependencies 18074 */ 18075 18076 18077 /** 18078 * Internal dependencies 18079 */ 18080 18081 18082 /** 18083 * Returns the default class name if the block is a light block and it supports 18084 * `className`. 18085 * 18086 * @param {string} clientId The block client ID. 18087 * 18088 * @return {string} The class name, e.g. `wp-block-paragraph`. 18089 */ 18090 18091 function useBlockDefaultClassName(clientId) { 18092 return (0,external_wp_data_namespaceObject.useSelect)(select => { 18093 const name = select(store).getBlockName(clientId); 18094 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name); 18095 const hasLightBlockWrapper = (blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) > 1; 18096 18097 if (!hasLightBlockWrapper) { 18098 return; 18099 } 18100 18101 return (0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(name); 18102 }, [clientId]); 18103 } 18104 18105 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-custom-class-name.js 18106 /** 18107 * WordPress dependencies 18108 */ 18109 18110 18111 /** 18112 * Internal dependencies 18113 */ 18114 18115 18116 /** 18117 * Returns the custom class name if the block is a light block. 18118 * 18119 * @param {string} clientId The block client ID. 18120 * 18121 * @return {string} The custom class name. 18122 */ 18123 18124 function useBlockCustomClassName(clientId) { 18125 // It's good for this to be a separate selector because it will be executed 18126 // on every attribute change, while the other selectors are not re-evaluated 18127 // as much. 18128 return (0,external_wp_data_namespaceObject.useSelect)(select => { 18129 const { 18130 getBlockName, 18131 getBlockAttributes 18132 } = select(store); 18133 const attributes = getBlockAttributes(clientId); 18134 18135 if (!(attributes !== null && attributes !== void 0 && attributes.className)) { 18136 return; 18137 } 18138 18139 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(getBlockName(clientId)); 18140 const hasLightBlockWrapper = (blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) > 1; 18141 18142 if (!hasLightBlockWrapper) { 18143 return; 18144 } 18145 18146 return attributes.className; 18147 }, [clientId]); 18148 } 18149 18150 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-moving-mode-class-names.js 18151 /** 18152 * External dependencies 18153 */ 18154 18155 /** 18156 * WordPress dependencies 18157 */ 18158 18159 18160 /** 18161 * Internal dependencies 18162 */ 18163 18164 18165 /** 18166 * Returns the class names used for block moving mode. 18167 * 18168 * @param {string} clientId The block client ID to insert above. 18169 * 18170 * @return {string} The class names. 18171 */ 18172 18173 function useBlockMovingModeClassNames(clientId) { 18174 return (0,external_wp_data_namespaceObject.useSelect)(select => { 18175 const { 18176 hasBlockMovingClientId, 18177 canInsertBlockType, 18178 getBlockName, 18179 getBlockRootClientId, 18180 isBlockSelected 18181 } = select(store); // The classes are only relevant for the selected block. Avoid 18182 // re-rendering all blocks! 18183 18184 if (!isBlockSelected(clientId)) { 18185 return; 18186 } 18187 18188 const movingClientId = hasBlockMovingClientId(); 18189 18190 if (!movingClientId) { 18191 return; 18192 } 18193 18194 return classnames_default()('is-block-moving-mode', { 18195 'can-insert-moving-block': canInsertBlockType(getBlockName(movingClientId), getBlockRootClientId(clientId)) 18196 }); 18197 }, [clientId]); 18198 } 18199 18200 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-focus-handler.js 18201 /** 18202 * WordPress dependencies 18203 */ 18204 18205 18206 /** 18207 * Internal dependencies 18208 */ 18209 18210 18211 18212 /** 18213 * Selects the block if it receives focus. 18214 * 18215 * @param {string} clientId Block client ID. 18216 */ 18217 18218 function useFocusHandler(clientId) { 18219 const { 18220 isBlockSelected 18221 } = (0,external_wp_data_namespaceObject.useSelect)(store); 18222 const { 18223 selectBlock, 18224 selectionChange 18225 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 18226 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 18227 /** 18228 * Marks the block as selected when focused and not already 18229 * selected. This specifically handles the case where block does not 18230 * set focus on its own (via `setFocus`), typically if there is no 18231 * focusable input in the block. 18232 * 18233 * @param {FocusEvent} event Focus event. 18234 */ 18235 function onFocus(event) { 18236 // When the whole editor is editable, let writing flow handle 18237 // selection. 18238 if (node.parentElement.closest('[contenteditable="true"]')) { 18239 return; 18240 } // Check synchronously because a non-selected block might be 18241 // getting data through `useSelect` asynchronously. 18242 18243 18244 if (isBlockSelected(clientId)) { 18245 // Potentially change selection away from rich text. 18246 if (!event.target.isContentEditable) { 18247 selectionChange(clientId); 18248 } 18249 18250 return; 18251 } // If an inner block is focussed, that block is resposible for 18252 // setting the selected block. 18253 18254 18255 if (!isInsideRootBlock(node, event.target)) { 18256 return; 18257 } 18258 18259 selectBlock(clientId); 18260 } 18261 18262 node.addEventListener('focusin', onFocus); 18263 return () => { 18264 node.removeEventListener('focusin', onFocus); 18265 }; 18266 }, [isBlockSelected, selectBlock]); 18267 } 18268 18269 ;// CONCATENATED MODULE: external ["wp","keycodes"] 18270 var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"]; 18271 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js 18272 /** 18273 * WordPress dependencies 18274 */ 18275 18276 18277 18278 18279 /** 18280 * Internal dependencies 18281 */ 18282 18283 18284 /** 18285 * Adds block behaviour: 18286 * - Removes the block on BACKSPACE. 18287 * - Inserts a default block on ENTER. 18288 * - Disables dragging of block contents. 18289 * 18290 * @param {string} clientId Block client ID. 18291 */ 18292 18293 function useEventHandlers(clientId) { 18294 const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isBlockSelected(clientId), [clientId]); 18295 const { 18296 getBlockRootClientId, 18297 getBlockIndex 18298 } = (0,external_wp_data_namespaceObject.useSelect)(store); 18299 const { 18300 insertDefaultBlock, 18301 removeBlock 18302 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 18303 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 18304 if (!isSelected) { 18305 return; 18306 } 18307 /** 18308 * Interprets keydown event intent to remove or insert after block if 18309 * key event occurs on wrapper node. This can occur when the block has 18310 * no text fields of its own, particularly after initial insertion, to 18311 * allow for easy deletion and continuous writing flow to add additional 18312 * content. 18313 * 18314 * @param {KeyboardEvent} event Keydown event. 18315 */ 18316 18317 18318 function onKeyDown(event) { 18319 const { 18320 keyCode, 18321 target 18322 } = event; 18323 18324 if (keyCode !== external_wp_keycodes_namespaceObject.ENTER && keyCode !== external_wp_keycodes_namespaceObject.BACKSPACE && keyCode !== external_wp_keycodes_namespaceObject.DELETE) { 18325 return; 18326 } 18327 18328 if (target !== node || (0,external_wp_dom_namespaceObject.isTextField)(target)) { 18329 return; 18330 } 18331 18332 event.preventDefault(); 18333 18334 if (keyCode === external_wp_keycodes_namespaceObject.ENTER) { 18335 insertDefaultBlock({}, getBlockRootClientId(clientId), getBlockIndex(clientId) + 1); 18336 } else { 18337 removeBlock(clientId); 18338 } 18339 } 18340 /** 18341 * Prevents default dragging behavior within a block. To do: we must 18342 * handle this in the future and clean up the drag target. 18343 * 18344 * @param {DragEvent} event Drag event. 18345 */ 18346 18347 18348 function onDragStart(event) { 18349 event.preventDefault(); 18350 } 18351 18352 node.addEventListener('keydown', onKeyDown); 18353 node.addEventListener('dragstart', onDragStart); 18354 return () => { 18355 node.removeEventListener('keydown', onKeyDown); 18356 node.removeEventListener('dragstart', onDragStart); 18357 }; 18358 }, [clientId, isSelected, getBlockRootClientId, getBlockIndex, insertDefaultBlock, removeBlock]); 18359 } 18360 18361 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-nav-mode-exit.js 18362 /** 18363 * WordPress dependencies 18364 */ 18365 18366 18367 /** 18368 * Internal dependencies 18369 */ 18370 18371 18372 /** 18373 * Allows navigation mode to be exited by clicking in the selected block. 18374 * 18375 * @param {string} clientId Block client ID. 18376 */ 18377 18378 function useNavModeExit(clientId) { 18379 const { 18380 isNavigationMode, 18381 isBlockSelected 18382 } = (0,external_wp_data_namespaceObject.useSelect)(store); 18383 const { 18384 setNavigationMode, 18385 selectBlock 18386 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 18387 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 18388 function onMouseDown(event) { 18389 // Don't select a block if it's already handled by a child 18390 // block. 18391 if (isNavigationMode() && !event.defaultPrevented) { 18392 // Prevent focus from moving to the block. 18393 event.preventDefault(); // When clicking on a selected block, exit navigation mode. 18394 18395 if (isBlockSelected(clientId)) { 18396 setNavigationMode(false); 18397 } else { 18398 selectBlock(clientId); 18399 } 18400 } 18401 } 18402 18403 node.addEventListener('mousedown', onMouseDown); 18404 return () => { 18405 node.addEventListener('mousedown', onMouseDown); 18406 }; 18407 }, [clientId, isNavigationMode, isBlockSelected, setNavigationMode]); 18408 } 18409 18410 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-intersection-observer.js 18411 /** 18412 * WordPress dependencies 18413 */ 18414 18415 18416 /** 18417 * Internal dependencies 18418 */ 18419 18420 18421 function useIntersectionObserver() { 18422 const observer = (0,external_wp_element_namespaceObject.useContext)(IntersectionObserver); 18423 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 18424 if (observer) { 18425 observer.observe(node); 18426 return () => { 18427 observer.unobserve(node); 18428 }; 18429 } 18430 }, [observer]); 18431 } 18432 18433 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/index.js 18434 /** 18435 * External dependencies 18436 */ 18437 18438 /** 18439 * WordPress dependencies 18440 */ 18441 18442 18443 18444 18445 18446 18447 18448 /** 18449 * Internal dependencies 18450 */ 18451 18452 18453 18454 18455 18456 18457 18458 18459 18460 18461 18462 18463 18464 18465 18466 18467 /** 18468 * If the block count exceeds the threshold, we disable the reordering animation 18469 * to avoid laginess. 18470 */ 18471 18472 const BLOCK_ANIMATION_THRESHOLD = 200; 18473 /** 18474 * This hook is used to lightly mark an element as a block element. The element 18475 * should be the outermost element of a block. Call this hook and pass the 18476 * returned props to the element to mark as a block. If you define a ref for the 18477 * element, it is important to pass the ref to this hook, which the hook in turn 18478 * will pass to the component through the props it returns. Optionally, you can 18479 * also pass any other props through this hook, and they will be merged and 18480 * returned. 18481 * 18482 * @param {Object} props Optional. Props to pass to the element. Must contain 18483 * the ref if one is defined. 18484 * @param {Object} options Options for internal use only. 18485 * @param {boolean} options.__unstableIsHtml 18486 * 18487 * @return {Object} Props to pass to the element to mark as a block. 18488 */ 18489 18490 function useBlockProps() { 18491 let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 18492 let { 18493 __unstableIsHtml 18494 } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 18495 const { 18496 clientId, 18497 className, 18498 wrapperProps = {}, 18499 isAligned 18500 } = (0,external_wp_element_namespaceObject.useContext)(BlockListBlockContext); 18501 const { 18502 index, 18503 mode, 18504 name, 18505 blockApiVersion, 18506 blockTitle, 18507 isPartOfSelection, 18508 adjustScrolling, 18509 enableAnimation 18510 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 18511 const { 18512 getBlockIndex, 18513 getBlockMode, 18514 getBlockName, 18515 isTyping, 18516 getGlobalBlockCount, 18517 isBlockSelected, 18518 isBlockMultiSelected, 18519 isAncestorMultiSelected, 18520 isFirstMultiSelectedBlock 18521 } = select(store); 18522 const isSelected = isBlockSelected(clientId); 18523 const isPartOfMultiSelection = isBlockMultiSelected(clientId) || isAncestorMultiSelected(clientId); 18524 const blockName = getBlockName(clientId); 18525 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName); 18526 return { 18527 index: getBlockIndex(clientId), 18528 mode: getBlockMode(clientId), 18529 name: blockName, 18530 blockApiVersion: (blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) || 1, 18531 blockTitle: blockType === null || blockType === void 0 ? void 0 : blockType.title, 18532 isPartOfSelection: isSelected || isPartOfMultiSelection, 18533 adjustScrolling: isSelected || isFirstMultiSelectedBlock(clientId), 18534 enableAnimation: !isTyping() && getGlobalBlockCount() <= BLOCK_ANIMATION_THRESHOLD 18535 }; 18536 }, [clientId]); // translators: %s: Type of block (i.e. Text, Image etc) 18537 18538 const blockLabel = (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Block: %s'), blockTitle); 18539 const htmlSuffix = mode === 'html' && !__unstableIsHtml ? '-visual' : ''; 18540 const mergedRefs = (0,external_wp_compose_namespaceObject.useMergeRefs)([props.ref, useFocusFirstElement(clientId), useBlockRefProvider(clientId), useFocusHandler(clientId), useEventHandlers(clientId), useNavModeExit(clientId), useIsHovered(), useIntersectionObserver(), use_moving_animation({ 18541 isSelected: isPartOfSelection, 18542 adjustScrolling, 18543 enableAnimation, 18544 triggerAnimationOnChange: index 18545 })]); 18546 const blockEditContext = useBlockEditContext(); // Ensures it warns only inside the `edit` implementation for the block. 18547 18548 if (blockApiVersion < 2 && clientId === blockEditContext.clientId) { 18549 typeof process !== "undefined" && process.env && "production" !== "production" ? 0 : void 0; 18550 } 18551 18552 return { ...wrapperProps, 18553 ...props, 18554 ref: mergedRefs, 18555 id: `block-$clientId}$htmlSuffix}`, 18556 tabIndex: 0, 18557 role: 'document', 18558 'aria-label': blockLabel, 18559 'data-block': clientId, 18560 'data-type': name, 18561 'data-title': blockTitle, 18562 className: classnames_default()( // The wp-block className is important for editor styles. 18563 classnames_default()('block-editor-block-list__block', { 18564 'wp-block': !isAligned 18565 }), className, props.className, wrapperProps.className, useBlockClassNames(clientId), useBlockDefaultClassName(clientId), useBlockCustomClassName(clientId), useBlockMovingModeClassNames(clientId)), 18566 style: { ...wrapperProps.style, 18567 ...props.style 18568 } 18569 }; 18570 } 18571 /** 18572 * Call within a save function to get the props for the block wrapper. 18573 * 18574 * @param {Object} props Optional. Props to pass to the element. 18575 */ 18576 18577 useBlockProps.save = external_wp_blocks_namespaceObject.__unstableGetBlockProps; 18578 18579 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block.js 18580 18581 18582 /** 18583 * External dependencies 18584 */ 18585 18586 18587 /** 18588 * WordPress dependencies 18589 */ 18590 18591 18592 18593 18594 18595 18596 18597 /** 18598 * Internal dependencies 18599 */ 18600 18601 18602 18603 18604 18605 18606 18607 18608 const BlockListBlockContext = (0,external_wp_element_namespaceObject.createContext)(); 18609 /** 18610 * Merges wrapper props with special handling for classNames and styles. 18611 * 18612 * @param {Object} propsA 18613 * @param {Object} propsB 18614 * 18615 * @return {Object} Merged props. 18616 */ 18617 18618 function mergeWrapperProps(propsA, propsB) { 18619 const newProps = { ...propsA, 18620 ...propsB 18621 }; 18622 18623 if (propsA && propsB && propsA.className && propsB.className) { 18624 newProps.className = classnames_default()(propsA.className, propsB.className); 18625 } 18626 18627 if (propsA && propsB && propsA.style && propsB.style) { 18628 newProps.style = { ...propsA.style, 18629 ...propsB.style 18630 }; 18631 } 18632 18633 return newProps; 18634 } 18635 18636 function Block(_ref) { 18637 let { 18638 children, 18639 isHtml, 18640 ...props 18641 } = _ref; 18642 return (0,external_wp_element_namespaceObject.createElement)("div", useBlockProps(props, { 18643 __unstableIsHtml: isHtml 18644 }), children); 18645 } 18646 18647 function BlockListBlock(_ref2) { 18648 var _wrapperProps; 18649 18650 let { 18651 block: { 18652 __unstableBlockSource 18653 }, 18654 mode, 18655 isLocked, 18656 canRemove, 18657 clientId, 18658 isSelected, 18659 isSelectionEnabled, 18660 className, 18661 name, 18662 isValid, 18663 attributes, 18664 wrapperProps, 18665 setAttributes, 18666 onReplace, 18667 onInsertBlocksAfter, 18668 onMerge, 18669 toggleSelection 18670 } = _ref2; 18671 const themeSupportsLayout = (0,external_wp_data_namespaceObject.useSelect)(select => { 18672 const { 18673 getSettings 18674 } = select(store); 18675 return getSettings().supportsLayout; 18676 }, []); 18677 const { 18678 removeBlock 18679 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 18680 const onRemove = (0,external_wp_element_namespaceObject.useCallback)(() => removeBlock(clientId), [clientId]); // We wrap the BlockEdit component in a div that hides it when editing in 18681 // HTML mode. This allows us to render all of the ancillary pieces 18682 // (InspectorControls, etc.) which are inside `BlockEdit` but not 18683 // `BlockHTML`, even in HTML mode. 18684 18685 let blockEdit = (0,external_wp_element_namespaceObject.createElement)(BlockEdit, { 18686 name: name, 18687 isSelected: isSelected, 18688 attributes: attributes, 18689 setAttributes: setAttributes, 18690 insertBlocksAfter: isLocked ? undefined : onInsertBlocksAfter, 18691 onReplace: canRemove ? onReplace : undefined, 18692 onRemove: canRemove ? onRemove : undefined, 18693 mergeBlocks: canRemove ? onMerge : undefined, 18694 clientId: clientId, 18695 isSelectionEnabled: isSelectionEnabled, 18696 toggleSelection: toggleSelection 18697 }); 18698 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name); // Determine whether the block has props to apply to the wrapper. 18699 18700 if (blockType !== null && blockType !== void 0 && blockType.getEditWrapperProps) { 18701 wrapperProps = mergeWrapperProps(wrapperProps, blockType.getEditWrapperProps(attributes)); 18702 } 18703 18704 const isAligned = wrapperProps && !!wrapperProps['data-align'] && !themeSupportsLayout; // For aligned blocks, provide a wrapper element so the block can be 18705 // positioned relative to the block column. 18706 // This is only kept for classic themes that don't support layout 18707 // Historically we used to rely on extra divs and data-align to 18708 // provide the alignments styles in the editor. 18709 // Due to the differences between frontend and backend, we migrated 18710 // to the layout feature, and we're now aligning the markup of frontend 18711 // and backend. 18712 18713 if (isAligned) { 18714 blockEdit = (0,external_wp_element_namespaceObject.createElement)("div", { 18715 className: "wp-block", 18716 "data-align": wrapperProps['data-align'] 18717 }, blockEdit); 18718 } 18719 18720 let block; 18721 18722 if (!isValid) { 18723 const saveContent = __unstableBlockSource ? (0,external_wp_blocks_namespaceObject.serializeRawBlock)(__unstableBlockSource) : (0,external_wp_blocks_namespaceObject.getSaveContent)(blockType, attributes); 18724 block = (0,external_wp_element_namespaceObject.createElement)(Block, { 18725 className: "has-warning" 18726 }, (0,external_wp_element_namespaceObject.createElement)(block_invalid_warning, { 18727 clientId: clientId 18728 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, (0,external_wp_dom_namespaceObject.safeHTML)(saveContent))); 18729 } else if (mode === 'html') { 18730 // Render blockEdit so the inspector controls don't disappear. 18731 // See #8969. 18732 block = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", { 18733 style: { 18734 display: 'none' 18735 } 18736 }, blockEdit), (0,external_wp_element_namespaceObject.createElement)(Block, { 18737 isHtml: true 18738 }, (0,external_wp_element_namespaceObject.createElement)(block_html, { 18739 clientId: clientId 18740 }))); 18741 } else if ((blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) > 1) { 18742 block = blockEdit; 18743 } else { 18744 block = (0,external_wp_element_namespaceObject.createElement)(Block, wrapperProps, blockEdit); 18745 } 18746 18747 const value = { 18748 clientId, 18749 className: (_wrapperProps = wrapperProps) !== null && _wrapperProps !== void 0 && _wrapperProps['data-align'] && themeSupportsLayout ? classnames_default()(className, `align$wrapperProps['data-align']}`) : className, 18750 wrapperProps: (0,external_lodash_namespaceObject.omit)(wrapperProps, ['data-align']), 18751 isAligned 18752 }; 18753 const memoizedValue = (0,external_wp_element_namespaceObject.useMemo)(() => value, Object.values(value)); 18754 return (0,external_wp_element_namespaceObject.createElement)(BlockListBlockContext.Provider, { 18755 value: memoizedValue 18756 }, (0,external_wp_element_namespaceObject.createElement)(block_crash_boundary, { 18757 fallback: (0,external_wp_element_namespaceObject.createElement)(Block, { 18758 className: "has-warning" 18759 }, (0,external_wp_element_namespaceObject.createElement)(block_crash_warning, null)) 18760 }, block)); 18761 } 18762 18763 const applyWithSelect = (0,external_wp_data_namespaceObject.withSelect)((select, _ref3) => { 18764 let { 18765 clientId, 18766 rootClientId 18767 } = _ref3; 18768 const { 18769 isBlockSelected, 18770 getBlockMode, 18771 isSelectionEnabled, 18772 getTemplateLock, 18773 __unstableGetBlockWithoutInnerBlocks, 18774 canRemoveBlock, 18775 canMoveBlock 18776 } = select(store); 18777 18778 const block = __unstableGetBlockWithoutInnerBlocks(clientId); 18779 18780 const isSelected = isBlockSelected(clientId); 18781 const templateLock = getTemplateLock(rootClientId); 18782 const canRemove = canRemoveBlock(clientId, rootClientId); 18783 const canMove = canMoveBlock(clientId, rootClientId); // The fallback to `{}` is a temporary fix. 18784 // This function should never be called when a block is not present in 18785 // the state. It happens now because the order in withSelect rendering 18786 // is not correct. 18787 18788 const { 18789 name, 18790 attributes, 18791 isValid 18792 } = block || {}; // Do not add new properties here, use `useSelect` instead to avoid 18793 // leaking new props to the public API (editor.BlockListBlock filter). 18794 18795 return { 18796 mode: getBlockMode(clientId), 18797 isSelectionEnabled: isSelectionEnabled(), 18798 isLocked: !!templateLock, 18799 canRemove, 18800 canMove, 18801 // Users of the editor.BlockListBlock filter used to be able to 18802 // access the block prop. 18803 // Ideally these blocks would rely on the clientId prop only. 18804 // This is kept for backward compatibility reasons. 18805 block, 18806 name, 18807 attributes, 18808 isValid, 18809 isSelected 18810 }; 18811 }); 18812 const applyWithDispatch = (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps, _ref4) => { 18813 let { 18814 select 18815 } = _ref4; 18816 const { 18817 updateBlockAttributes, 18818 insertBlocks, 18819 mergeBlocks, 18820 replaceBlocks, 18821 toggleSelection, 18822 __unstableMarkLastChangeAsPersistent 18823 } = dispatch(store); // Do not add new properties here, use `useDispatch` instead to avoid 18824 // leaking new props to the public API (editor.BlockListBlock filter). 18825 18826 return { 18827 setAttributes(newAttributes) { 18828 const { 18829 getMultiSelectedBlockClientIds 18830 } = select(store); 18831 const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds(); 18832 const { 18833 clientId 18834 } = ownProps; 18835 const clientIds = multiSelectedBlockClientIds.length ? multiSelectedBlockClientIds : [clientId]; 18836 updateBlockAttributes(clientIds, newAttributes); 18837 }, 18838 18839 onInsertBlocks(blocks, index) { 18840 const { 18841 rootClientId 18842 } = ownProps; 18843 insertBlocks(blocks, index, rootClientId); 18844 }, 18845 18846 onInsertBlocksAfter(blocks) { 18847 const { 18848 clientId, 18849 rootClientId 18850 } = ownProps; 18851 const { 18852 getBlockIndex 18853 } = select(store); 18854 const index = getBlockIndex(clientId); 18855 insertBlocks(blocks, index + 1, rootClientId); 18856 }, 18857 18858 onMerge(forward) { 18859 const { 18860 clientId 18861 } = ownProps; 18862 const { 18863 getPreviousBlockClientId, 18864 getNextBlockClientId 18865 } = select(store); 18866 18867 if (forward) { 18868 const nextBlockClientId = getNextBlockClientId(clientId); 18869 18870 if (nextBlockClientId) { 18871 mergeBlocks(clientId, nextBlockClientId); 18872 } 18873 } else { 18874 const previousBlockClientId = getPreviousBlockClientId(clientId); 18875 18876 if (previousBlockClientId) { 18877 mergeBlocks(previousBlockClientId, clientId); 18878 } 18879 } 18880 }, 18881 18882 onReplace(blocks, indexToSelect, initialPosition) { 18883 if (blocks.length && !(0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)(blocks[blocks.length - 1])) { 18884 __unstableMarkLastChangeAsPersistent(); 18885 } 18886 18887 replaceBlocks([ownProps.clientId], blocks, indexToSelect, initialPosition); 18888 }, 18889 18890 toggleSelection(selectionEnabled) { 18891 toggleSelection(selectionEnabled); 18892 } 18893 18894 }; 18895 }); 18896 /* harmony default export */ var block = ((0,external_wp_compose_namespaceObject.compose)(external_wp_compose_namespaceObject.pure, applyWithSelect, applyWithDispatch, // Block is sometimes not mounted at the right time, causing it be undefined 18897 // see issue for more info 18898 // https://github.com/WordPress/gutenberg/issues/17013 18899 (0,external_wp_compose_namespaceObject.ifCondition)(_ref5 => { 18900 let { 18901 block 18902 } = _ref5; 18903 return !!block; 18904 }), (0,external_wp_components_namespaceObject.withFilters)('editor.BlockListBlock'))(BlockListBlock)); 18905 18906 ;// CONCATENATED MODULE: external ["wp","htmlEntities"] 18907 var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; 18908 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plus.js 18909 18910 18911 /** 18912 * WordPress dependencies 18913 */ 18914 18915 const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 18916 xmlns: "http://www.w3.org/2000/svg", 18917 viewBox: "0 0 24 24" 18918 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 18919 d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z" 18920 })); 18921 /* harmony default export */ var library_plus = (plus); 18922 18923 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/tips.js 18924 18925 18926 /** 18927 * WordPress dependencies 18928 */ 18929 18930 18931 18932 const globalTips = [(0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('While writing, you can press <kbd>/</kbd> to quickly insert new blocks.'), { 18933 kbd: (0,external_wp_element_namespaceObject.createElement)("kbd", null) 18934 }), (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('Indent a list by pressing <kbd>space</kbd> at the beginning of a line.'), { 18935 kbd: (0,external_wp_element_namespaceObject.createElement)("kbd", null) 18936 }), (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('Outdent a list by pressing <kbd>backspace</kbd> at the beginning of a line.'), { 18937 kbd: (0,external_wp_element_namespaceObject.createElement)("kbd", null) 18938 }), (0,external_wp_i18n_namespaceObject.__)('Drag files into the editor to automatically insert media blocks.'), (0,external_wp_i18n_namespaceObject.__)("Change a block's type by pressing the block icon on the toolbar.")]; 18939 18940 function Tips() { 18941 const [randomIndex] = (0,external_wp_element_namespaceObject.useState)( // Disable Reason: I'm not generating an HTML id. 18942 // eslint-disable-next-line no-restricted-syntax 18943 Math.floor(Math.random() * globalTips.length)); 18944 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tip, null, globalTips[randomIndex]); 18945 } 18946 18947 /* harmony default export */ var tips = (Tips); 18948 18949 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/block-default.js 18950 18951 18952 /** 18953 * WordPress dependencies 18954 */ 18955 18956 const blockDefault = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 18957 xmlns: "http://www.w3.org/2000/svg", 18958 viewBox: "0 0 24 24" 18959 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 18960 d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" 18961 })); 18962 /* harmony default export */ var block_default = (blockDefault); 18963 18964 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-icon/index.js 18965 18966 18967 /** 18968 * External dependencies 18969 */ 18970 18971 /** 18972 * WordPress dependencies 18973 */ 18974 18975 18976 18977 18978 18979 function BlockIcon(_ref) { 18980 var _icon; 18981 18982 let { 18983 icon, 18984 showColors = false, 18985 className 18986 } = _ref; 18987 18988 if (((_icon = icon) === null || _icon === void 0 ? void 0 : _icon.src) === 'block-default') { 18989 icon = { 18990 src: block_default 18991 }; 18992 } 18993 18994 const renderedIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, { 18995 icon: icon && icon.src ? icon.src : icon 18996 }); 18997 const style = showColors ? { 18998 backgroundColor: icon && icon.background, 18999 color: icon && icon.foreground 19000 } : {}; 19001 return (0,external_wp_element_namespaceObject.createElement)("span", { 19002 style: style, 19003 className: classnames_default()('block-editor-block-icon', className, { 19004 'has-colors': showColors 19005 }) 19006 }, renderedIcon); 19007 } 19008 /** 19009 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-icon/README.md 19010 */ 19011 19012 19013 /* harmony default export */ var block_icon = ((0,external_wp_element_namespaceObject.memo)(BlockIcon)); 19014 19015 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-card/index.js 19016 19017 19018 /** 19019 * WordPress dependencies 19020 */ 19021 19022 /** 19023 * Internal dependencies 19024 */ 19025 19026 19027 19028 function BlockCard(_ref) { 19029 let { 19030 title, 19031 icon, 19032 description, 19033 blockType 19034 } = _ref; 19035 19036 if (blockType) { 19037 external_wp_deprecated_default()('`blockType` property in `BlockCard component`', { 19038 since: '5.7', 19039 alternative: '`title, icon and description` properties' 19040 }); 19041 ({ 19042 title, 19043 icon, 19044 description 19045 } = blockType); 19046 } 19047 19048 return (0,external_wp_element_namespaceObject.createElement)("div", { 19049 className: "block-editor-block-card" 19050 }, (0,external_wp_element_namespaceObject.createElement)(block_icon, { 19051 icon: icon, 19052 showColors: true 19053 }), (0,external_wp_element_namespaceObject.createElement)("div", { 19054 className: "block-editor-block-card__content" 19055 }, (0,external_wp_element_namespaceObject.createElement)("h2", { 19056 className: "block-editor-block-card__title" 19057 }, title), (0,external_wp_element_namespaceObject.createElement)("span", { 19058 className: "block-editor-block-card__description" 19059 }, description))); 19060 } 19061 19062 /* harmony default export */ var block_card = (BlockCard); 19063 19064 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/with-registry-provider.js 19065 19066 19067 19068 /** 19069 * WordPress dependencies 19070 */ 19071 19072 19073 19074 /** 19075 * Internal dependencies 19076 */ 19077 19078 19079 19080 const withRegistryProvider = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => { 19081 return (0,external_wp_data_namespaceObject.withRegistry)(_ref => { 19082 let { 19083 useSubRegistry = true, 19084 registry, 19085 ...props 19086 } = _ref; 19087 19088 if (!useSubRegistry) { 19089 return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({ 19090 registry: registry 19091 }, props)); 19092 } 19093 19094 const [subRegistry, setSubRegistry] = (0,external_wp_element_namespaceObject.useState)(null); 19095 (0,external_wp_element_namespaceObject.useEffect)(() => { 19096 const newRegistry = (0,external_wp_data_namespaceObject.createRegistry)({}, registry); 19097 newRegistry.registerStore(STORE_NAME, storeConfig); 19098 setSubRegistry(newRegistry); 19099 }, [registry]); 19100 19101 if (!subRegistry) { 19102 return null; 19103 } 19104 19105 return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.RegistryProvider, { 19106 value: subRegistry 19107 }, (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({ 19108 registry: subRegistry 19109 }, props))); 19110 }); 19111 }, 'withRegistryProvider'); 19112 /* harmony default export */ var with_registry_provider = (withRegistryProvider); 19113 19114 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/use-block-sync.js 19115 /** 19116 * External dependencies 19117 */ 19118 19119 /** 19120 * WordPress dependencies 19121 */ 19122 19123 19124 19125 19126 /** 19127 * Internal dependencies 19128 */ 19129 19130 19131 /** 19132 * A function to call when the block value has been updated in the block-editor 19133 * store. 19134 * 19135 * @callback onBlockUpdate 19136 * @param {Object[]} blocks The updated blocks. 19137 * @param {Object} options The updated block options, such as selectionStart 19138 * and selectionEnd. 19139 */ 19140 19141 /** 19142 * useBlockSync is a side effect which handles bidirectional sync between the 19143 * block-editor store and a controlling data source which provides blocks. This 19144 * is most commonly used by the BlockEditorProvider to synchronize the contents 19145 * of the block-editor store with the root entity, like a post. 19146 * 19147 * Another example would be the template part block, which provides blocks from 19148 * a separate entity data source than a root entity. This hook syncs edits to 19149 * the template part in the block editor back to the entity and vice-versa. 19150 * 19151 * Here are some of its basic functions: 19152 * - Initalizes the block-editor store for the given clientID to the blocks 19153 * given via props. 19154 * - Adds incoming changes (like undo) to the block-editor store. 19155 * - Adds outgoing changes (like editing content) to the controlling entity, 19156 * determining if a change should be considered persistent or not. 19157 * - Handles edge cases and race conditions which occur in those operations. 19158 * - Ignores changes which happen to other entities (like nested inner block 19159 * controllers. 19160 * - Passes selection state from the block-editor store to the controlling entity. 19161 * 19162 * @param {Object} props Props for the block sync hook 19163 * @param {string} props.clientId The client ID of the inner block controller. 19164 * If none is passed, then it is assumed to be a 19165 * root controller rather than an inner block 19166 * controller. 19167 * @param {Object[]} props.value The control value for the blocks. This value 19168 * is used to initalize the block-editor store 19169 * and for resetting the blocks to incoming 19170 * changes like undo. 19171 * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo. 19172 * @param {onBlockUpdate} props.onChange Function to call when a persistent 19173 * change has been made in the block-editor blocks 19174 * for the given clientId. For example, after 19175 * this function is called, an entity is marked 19176 * dirty because it has changes to save. 19177 * @param {onBlockUpdate} props.onInput Function to call when a non-persistent 19178 * change has been made in the block-editor blocks 19179 * for the given clientId. When this is called, 19180 * controlling sources do not become dirty. 19181 */ 19182 19183 function useBlockSync(_ref) { 19184 let { 19185 clientId = null, 19186 value: controlledBlocks, 19187 selection: controlledSelection, 19188 onChange = external_lodash_namespaceObject.noop, 19189 onInput = external_lodash_namespaceObject.noop 19190 } = _ref; 19191 const registry = (0,external_wp_data_namespaceObject.useRegistry)(); 19192 const { 19193 resetBlocks, 19194 resetSelection, 19195 replaceInnerBlocks, 19196 setHasControlledInnerBlocks, 19197 __unstableMarkNextChangeAsNotPersistent 19198 } = registry.dispatch(store); 19199 const { 19200 getBlockName, 19201 getBlocks 19202 } = registry.select(store); 19203 const isControlled = (0,external_wp_data_namespaceObject.useSelect)(select => { 19204 return !clientId || select(store).areInnerBlocksControlled(clientId); 19205 }, [clientId]); 19206 const pendingChanges = (0,external_wp_element_namespaceObject.useRef)({ 19207 incoming: null, 19208 outgoing: [] 19209 }); 19210 const subscribed = (0,external_wp_element_namespaceObject.useRef)(false); 19211 19212 const setControlledBlocks = () => { 19213 if (!controlledBlocks) { 19214 return; 19215 } // We don't need to persist this change because we only replace 19216 // controlled inner blocks when the change was caused by an entity, 19217 // and so it would already be persisted. 19218 19219 19220 __unstableMarkNextChangeAsNotPersistent(); 19221 19222 if (clientId) { 19223 // It is important to batch here because otherwise, 19224 // as soon as `setHasControlledInnerBlocks` is called 19225 // the effect to restore might be triggered 19226 // before the actual blocks get set properly in state. 19227 registry.batch(() => { 19228 setHasControlledInnerBlocks(clientId, true); 19229 const storeBlocks = controlledBlocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block)); 19230 19231 if (subscribed.current) { 19232 pendingChanges.current.incoming = storeBlocks; 19233 } 19234 19235 __unstableMarkNextChangeAsNotPersistent(); 19236 19237 replaceInnerBlocks(clientId, storeBlocks); 19238 }); 19239 } else { 19240 if (subscribed.current) { 19241 pendingChanges.current.incoming = controlledBlocks; 19242 } 19243 19244 resetBlocks(controlledBlocks); 19245 } 19246 }; // Add a subscription to the block-editor registry to detect when changes 19247 // have been made. This lets us inform the data source of changes. This 19248 // is an effect so that the subscriber can run synchronously without 19249 // waiting for React renders for changes. 19250 19251 19252 const onInputRef = (0,external_wp_element_namespaceObject.useRef)(onInput); 19253 const onChangeRef = (0,external_wp_element_namespaceObject.useRef)(onChange); 19254 (0,external_wp_element_namespaceObject.useEffect)(() => { 19255 onInputRef.current = onInput; 19256 onChangeRef.current = onChange; 19257 }, [onInput, onChange]); // Determine if blocks need to be reset when they change. 19258 19259 (0,external_wp_element_namespaceObject.useEffect)(() => { 19260 if (pendingChanges.current.outgoing.includes(controlledBlocks)) { 19261 // Skip block reset if the value matches expected outbound sync 19262 // triggered by this component by a preceding change detection. 19263 // Only skip if the value matches expectation, since a reset should 19264 // still occur if the value is modified (not equal by reference), 19265 // to allow that the consumer may apply modifications to reflect 19266 // back on the editor. 19267 if ((0,external_lodash_namespaceObject.last)(pendingChanges.current.outgoing) === controlledBlocks) { 19268 pendingChanges.current.outgoing = []; 19269 } 19270 } else if (getBlocks(clientId) !== controlledBlocks) { 19271 // Reset changing value in all other cases than the sync described 19272 // above. Since this can be reached in an update following an out- 19273 // bound sync, unset the outbound value to avoid considering it in 19274 // subsequent renders. 19275 pendingChanges.current.outgoing = []; 19276 setControlledBlocks(); 19277 19278 if (controlledSelection) { 19279 resetSelection(controlledSelection.selectionStart, controlledSelection.selectionEnd, controlledSelection.initialPosition); 19280 } 19281 } 19282 }, [controlledBlocks, clientId]); 19283 (0,external_wp_element_namespaceObject.useEffect)(() => { 19284 // When the block becomes uncontrolled, it means its inner state has been reset 19285 // we need to take the blocks again from the external value property. 19286 if (!isControlled) { 19287 pendingChanges.current.outgoing = []; 19288 setControlledBlocks(); 19289 } 19290 }, [isControlled]); 19291 (0,external_wp_element_namespaceObject.useEffect)(() => { 19292 const { 19293 getSelectionStart, 19294 getSelectionEnd, 19295 getSelectedBlocksInitialCaretPosition, 19296 isLastBlockChangePersistent, 19297 __unstableIsLastBlockChangeIgnored, 19298 areInnerBlocksControlled 19299 } = registry.select(store); 19300 let blocks = getBlocks(clientId); 19301 let isPersistent = isLastBlockChangePersistent(); 19302 let previousAreBlocksDifferent = false; 19303 subscribed.current = true; 19304 const unsubscribe = registry.subscribe(() => { 19305 // Sometimes, when changing block lists, lingering subscriptions 19306 // might trigger before they are cleaned up. If the block for which 19307 // the subscription runs is no longer in the store, this would clear 19308 // its parent entity's block list. To avoid this, we bail out if 19309 // the subscription is triggering for a block (`clientId !== null`) 19310 // and its block name can't be found because it's not on the list. 19311 // (`getBlockName( clientId ) === null`). 19312 if (clientId !== null && getBlockName(clientId) === null) return; // When RESET_BLOCKS on parent blocks get called, the controlled blocks 19313 // can reset to uncontrolled, in these situations, it means we need to populate 19314 // the blocks again from the external blocks (the value property here) 19315 // and we should stop triggering onChange 19316 19317 const isStillControlled = !clientId || areInnerBlocksControlled(clientId); 19318 19319 if (!isStillControlled) { 19320 return; 19321 } 19322 19323 const newIsPersistent = isLastBlockChangePersistent(); 19324 const newBlocks = getBlocks(clientId); 19325 const areBlocksDifferent = newBlocks !== blocks; 19326 blocks = newBlocks; 19327 19328 if (areBlocksDifferent && (pendingChanges.current.incoming || __unstableIsLastBlockChangeIgnored())) { 19329 pendingChanges.current.incoming = null; 19330 isPersistent = newIsPersistent; 19331 return; 19332 } // Since we often dispatch an action to mark the previous action as 19333 // persistent, we need to make sure that the blocks changed on the 19334 // previous action before committing the change. 19335 19336 19337 const didPersistenceChange = previousAreBlocksDifferent && !areBlocksDifferent && newIsPersistent && !isPersistent; 19338 19339 if (areBlocksDifferent || didPersistenceChange) { 19340 isPersistent = newIsPersistent; // We know that onChange/onInput will update controlledBlocks. 19341 // We need to be aware that it was caused by an outgoing change 19342 // so that we do not treat it as an incoming change later on, 19343 // which would cause a block reset. 19344 19345 pendingChanges.current.outgoing.push(blocks); // Inform the controlling entity that changes have been made to 19346 // the block-editor store they should be aware about. 19347 19348 const updateParent = isPersistent ? onChangeRef.current : onInputRef.current; 19349 updateParent(blocks, { 19350 selection: { 19351 selectionStart: getSelectionStart(), 19352 selectionEnd: getSelectionEnd(), 19353 initialPosition: getSelectedBlocksInitialCaretPosition() 19354 } 19355 }); 19356 } 19357 19358 previousAreBlocksDifferent = areBlocksDifferent; 19359 }); 19360 return () => unsubscribe(); 19361 }, [registry, clientId]); 19362 } 19363 19364 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/index.js 19365 19366 19367 /** 19368 * WordPress dependencies 19369 */ 19370 19371 19372 /** 19373 * Internal dependencies 19374 */ 19375 19376 19377 19378 19379 19380 /** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */ 19381 19382 function BlockEditorProvider(props) { 19383 const { 19384 children, 19385 settings 19386 } = props; 19387 const { 19388 updateSettings 19389 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 19390 (0,external_wp_element_namespaceObject.useEffect)(() => { 19391 updateSettings(settings); 19392 }, [settings]); // Syncs the entity provider with changes in the block-editor store. 19393 19394 useBlockSync(props); 19395 return (0,external_wp_element_namespaceObject.createElement)(BlockRefsProvider, null, children); 19396 } 19397 19398 /* harmony default export */ var provider = (with_registry_provider(BlockEditorProvider)); 19399 19400 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/live.js 19401 19402 19403 /** 19404 * WordPress dependencies 19405 */ 19406 19407 /** 19408 * Internal dependencies 19409 */ 19410 19411 19412 function LiveBlockPreview(_ref) { 19413 let { 19414 onClick 19415 } = _ref; 19416 return (0,external_wp_element_namespaceObject.createElement)("div", { 19417 tabIndex: 0, 19418 role: "button", 19419 onClick: onClick, 19420 onKeyPress: onClick 19421 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Disabled, null, (0,external_wp_element_namespaceObject.createElement)(BlockList, null))); 19422 } 19423 19424 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-selection-clearer/index.js 19425 19426 19427 19428 /** 19429 * WordPress dependencies 19430 */ 19431 19432 19433 /** 19434 * Internal dependencies 19435 */ 19436 19437 19438 /** 19439 * Pass the returned ref callback to an element that should clear block 19440 * selection. Selection will only be cleared if the element is clicked directly, 19441 * not if a child element is clicked. 19442 * 19443 * @return {import('react').RefCallback} Ref callback. 19444 */ 19445 19446 function useBlockSelectionClearer() { 19447 const { 19448 hasSelectedBlock, 19449 hasMultiSelection 19450 } = (0,external_wp_data_namespaceObject.useSelect)(store); 19451 const { 19452 clearSelectedBlock 19453 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 19454 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 19455 function onMouseDown(event) { 19456 if (!hasSelectedBlock() && !hasMultiSelection()) { 19457 return; 19458 } // Only handle clicks on the element, not the children. 19459 19460 19461 if (event.target !== node) { 19462 return; 19463 } 19464 19465 clearSelectedBlock(); 19466 } 19467 19468 node.addEventListener('mousedown', onMouseDown); 19469 return () => { 19470 node.removeEventListener('mousedown', onMouseDown); 19471 }; 19472 }, [hasSelectedBlock, hasMultiSelection, clearSelectedBlock]); 19473 } 19474 function BlockSelectionClearer(props) { 19475 return (0,external_wp_element_namespaceObject.createElement)("div", _extends({ 19476 ref: useBlockSelectionClearer() 19477 }, props)); 19478 } 19479 19480 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-multi-selection.js 19481 /** 19482 * External dependencies 19483 */ 19484 19485 /** 19486 * WordPress dependencies 19487 */ 19488 19489 19490 19491 /** 19492 * Internal dependencies 19493 */ 19494 19495 19496 19497 19498 function selector(select) { 19499 const { 19500 isMultiSelecting, 19501 getMultiSelectedBlockClientIds, 19502 hasMultiSelection, 19503 getSelectedBlockClientId, 19504 getSelectedBlocksInitialCaretPosition, 19505 __unstableIsFullySelected 19506 } = select(store); 19507 return { 19508 isMultiSelecting: isMultiSelecting(), 19509 multiSelectedBlockClientIds: getMultiSelectedBlockClientIds(), 19510 hasMultiSelection: hasMultiSelection(), 19511 selectedBlockClientId: getSelectedBlockClientId(), 19512 initialPosition: getSelectedBlocksInitialCaretPosition(), 19513 isFullSelection: __unstableIsFullySelected() 19514 }; 19515 } 19516 19517 function useMultiSelection() { 19518 const { 19519 initialPosition, 19520 isMultiSelecting, 19521 multiSelectedBlockClientIds, 19522 hasMultiSelection, 19523 selectedBlockClientId, 19524 isFullSelection 19525 } = (0,external_wp_data_namespaceObject.useSelect)(selector, []); 19526 const selectedRef = useBlockRef(selectedBlockClientId); // These must be in the right DOM order. 19527 19528 const startRef = useBlockRef((0,external_lodash_namespaceObject.first)(multiSelectedBlockClientIds)); 19529 const endRef = useBlockRef((0,external_lodash_namespaceObject.last)(multiSelectedBlockClientIds)); 19530 /** 19531 * When the component updates, and there is multi selection, we need to 19532 * select the entire block contents. 19533 */ 19534 19535 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 19536 const { 19537 ownerDocument 19538 } = node; 19539 const { 19540 defaultView 19541 } = ownerDocument; // Allow initialPosition to bypass focus behavior. This is useful 19542 // for the list view or other areas where we don't want to transfer 19543 // focus to the editor canvas. 19544 19545 if (initialPosition === undefined || initialPosition === null) { 19546 return; 19547 } 19548 19549 if (!hasMultiSelection || isMultiSelecting) { 19550 if (!selectedBlockClientId || isMultiSelecting) { 19551 return; 19552 } 19553 19554 const selection = defaultView.getSelection(); 19555 19556 if (selection.rangeCount && !selection.isCollapsed) { 19557 const blockNode = selectedRef.current; 19558 const { 19559 startContainer, 19560 endContainer 19561 } = selection.getRangeAt(0); 19562 19563 if (!!blockNode && (!blockNode.contains(startContainer) || !blockNode.contains(endContainer))) { 19564 selection.removeAllRanges(); 19565 } 19566 } 19567 19568 return; 19569 } 19570 19571 const { 19572 length 19573 } = multiSelectedBlockClientIds; 19574 19575 if (length < 2) { 19576 return; 19577 } 19578 19579 if (!isFullSelection) { 19580 return; 19581 } // Allow cross contentEditable selection by temporarily making 19582 // all content editable. We can't rely on using the store and 19583 // React because re-rending happens too slowly. We need to be 19584 // able to select across instances immediately. 19585 19586 19587 node.contentEditable = true; // For some browsers, like Safari, it is important that focus happens 19588 // BEFORE selection. 19589 19590 node.focus(); // The block refs might not be immediately available 19591 // when dragging blocks into another block. 19592 19593 if (!startRef.current || !endRef.current) { 19594 return; 19595 } 19596 19597 const selection = defaultView.getSelection(); 19598 const range = ownerDocument.createRange(); // These must be in the right DOM order. 19599 19600 range.setStartBefore(startRef.current); 19601 range.setEndAfter(endRef.current); 19602 selection.removeAllRanges(); 19603 selection.addRange(range); 19604 }, [hasMultiSelection, isMultiSelecting, multiSelectedBlockClientIds, selectedBlockClientId, initialPosition, isFullSelection]); 19605 } 19606 19607 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-tab-nav.js 19608 19609 19610 /** 19611 * WordPress dependencies 19612 */ 19613 19614 19615 19616 19617 19618 /** 19619 * Internal dependencies 19620 */ 19621 19622 19623 function useTabNav() { 19624 const container = (0,external_wp_element_namespaceObject.useRef)(); 19625 const focusCaptureBeforeRef = (0,external_wp_element_namespaceObject.useRef)(); 19626 const focusCaptureAfterRef = (0,external_wp_element_namespaceObject.useRef)(); 19627 const lastFocus = (0,external_wp_element_namespaceObject.useRef)(); 19628 const { 19629 hasMultiSelection, 19630 getSelectedBlockClientId, 19631 getBlockCount 19632 } = (0,external_wp_data_namespaceObject.useSelect)(store); 19633 const { 19634 setNavigationMode 19635 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 19636 const isNavigationMode = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isNavigationMode(), []); // Don't allow tabbing to this element in Navigation mode. 19637 19638 const focusCaptureTabIndex = !isNavigationMode ? '0' : undefined; // Reference that holds the a flag for enabling or disabling 19639 // capturing on the focus capture elements. 19640 19641 const noCapture = (0,external_wp_element_namespaceObject.useRef)(); 19642 19643 function onFocusCapture(event) { 19644 // Do not capture incoming focus if set by us in WritingFlow. 19645 if (noCapture.current) { 19646 noCapture.current = null; 19647 } else if (hasMultiSelection()) { 19648 container.current.focus(); 19649 } else if (getSelectedBlockClientId()) { 19650 lastFocus.current.focus(); 19651 } else { 19652 setNavigationMode(true); 19653 const isBefore = // eslint-disable-next-line no-bitwise 19654 event.target.compareDocumentPosition(container.current) & event.target.DOCUMENT_POSITION_FOLLOWING; 19655 const action = isBefore ? 'findNext' : 'findPrevious'; 19656 external_wp_dom_namespaceObject.focus.tabbable[action](event.target).focus(); 19657 } 19658 } 19659 19660 const before = (0,external_wp_element_namespaceObject.createElement)("div", { 19661 ref: focusCaptureBeforeRef, 19662 tabIndex: focusCaptureTabIndex, 19663 onFocus: onFocusCapture 19664 }); 19665 const after = (0,external_wp_element_namespaceObject.createElement)("div", { 19666 ref: focusCaptureAfterRef, 19667 tabIndex: focusCaptureTabIndex, 19668 onFocus: onFocusCapture 19669 }); 19670 const ref = (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 19671 function onKeyDown(event) { 19672 if (event.defaultPrevented) { 19673 return; 19674 } 19675 19676 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !hasMultiSelection()) { 19677 event.preventDefault(); 19678 setNavigationMode(true); 19679 return; 19680 } // In Edit mode, Tab should focus the first tabbable element after 19681 // the content, which is normally the sidebar (with block controls) 19682 // and Shift+Tab should focus the first tabbable element before the 19683 // content, which is normally the block toolbar. 19684 // Arrow keys can be used, and Tab and arrow keys can be used in 19685 // Navigation mode (press Esc), to navigate through blocks. 19686 19687 19688 if (event.keyCode !== external_wp_keycodes_namespaceObject.TAB) { 19689 return; 19690 } 19691 19692 const isShift = event.shiftKey; 19693 const direction = isShift ? 'findPrevious' : 'findNext'; 19694 19695 if (!hasMultiSelection() && !getSelectedBlockClientId()) { 19696 // Preserve the behaviour of entering navigation mode when 19697 // tabbing into the content without a block selection. 19698 // `onFocusCapture` already did this previously, but we need to 19699 // do it again here because after clearing block selection, 19700 // focus land on the writing flow container and pressing Tab 19701 // will no longer send focus through the focus capture element. 19702 if (event.target === node) setNavigationMode(true); 19703 return; 19704 } // Allow tabbing from the block wrapper to a form element, 19705 // and between form elements rendered in a block, 19706 // such as inside a placeholder. Form elements are generally 19707 // meant to be UI rather than part of the content. Ideally 19708 // these are not rendered in the content and perhaps in the 19709 // future they can be rendered in an iframe or shadow DOM. 19710 19711 19712 if (((0,external_wp_dom_namespaceObject.isFormElement)(event.target) || event.target.getAttribute('data-block') === getSelectedBlockClientId()) && (0,external_wp_dom_namespaceObject.isFormElement)(external_wp_dom_namespaceObject.focus.tabbable[direction](event.target))) { 19713 return; 19714 } 19715 19716 const next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef; // Disable focus capturing on the focus capture element, so it 19717 // doesn't refocus this block and so it allows default behaviour 19718 // (moving focus to the next tabbable element). 19719 19720 noCapture.current = true; // Focusing the focus capture element, which is located above and 19721 // below the editor, should not scroll the page all the way up or 19722 // down. 19723 19724 next.current.focus({ 19725 preventScroll: true 19726 }); 19727 } 19728 19729 function onFocusOut(event) { 19730 lastFocus.current = event.target; 19731 const { 19732 ownerDocument 19733 } = node; // If focus disappears due to there being no blocks, move focus to 19734 // the writing flow wrapper. 19735 19736 if (!event.relatedTarget && ownerDocument.activeElement === ownerDocument.body && getBlockCount() === 0) { 19737 node.focus(); 19738 } 19739 } // When tabbing back to an element in block list, this event handler prevents scrolling if the 19740 // focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph 19741 // when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the 19742 // top or bottom of the document. 19743 // 19744 // Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this 19745 // earlier in the keypress handler, and call focus( { preventScroll: true } ) instead. 19746 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters 19747 19748 19749 function preventScrollOnTab(event) { 19750 var _event$target; 19751 19752 if (event.keyCode !== external_wp_keycodes_namespaceObject.TAB) { 19753 return; 19754 } 19755 19756 if (((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.getAttribute('role')) === 'region') { 19757 return; 19758 } 19759 19760 if (container.current === event.target) { 19761 return; 19762 } 19763 19764 const isShift = event.shiftKey; 19765 const direction = isShift ? 'findPrevious' : 'findNext'; 19766 const target = external_wp_dom_namespaceObject.focus.tabbable[direction](event.target); // Only do something when the next tabbable is a focus capture div (before/after) 19767 19768 if (target === focusCaptureBeforeRef.current || target === focusCaptureAfterRef.current) { 19769 event.preventDefault(); 19770 target.focus({ 19771 preventScroll: true 19772 }); 19773 } 19774 } 19775 19776 const { 19777 ownerDocument 19778 } = node; 19779 const { 19780 defaultView 19781 } = ownerDocument; 19782 defaultView.addEventListener('keydown', preventScrollOnTab); 19783 node.addEventListener('keydown', onKeyDown); 19784 node.addEventListener('focusout', onFocusOut); 19785 return () => { 19786 defaultView.removeEventListener('keydown', preventScrollOnTab); 19787 node.removeEventListener('keydown', onKeyDown); 19788 node.removeEventListener('focusout', onFocusOut); 19789 }; 19790 }, []); 19791 const mergedRefs = (0,external_wp_compose_namespaceObject.useMergeRefs)([container, ref]); 19792 return [before, mergedRefs, after]; 19793 } 19794 19795 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-arrow-nav.js 19796 /** 19797 * External dependencies 19798 */ 19799 19800 /** 19801 * WordPress dependencies 19802 */ 19803 19804 19805 19806 19807 19808 /** 19809 * Internal dependencies 19810 */ 19811 19812 19813 19814 /** 19815 * Returns true if the element should consider edge navigation upon a keyboard 19816 * event of the given directional key code, or false otherwise. 19817 * 19818 * @param {Element} element HTML element to test. 19819 * @param {number} keyCode KeyboardEvent keyCode to test. 19820 * @param {boolean} hasModifier Whether a modifier is pressed. 19821 * 19822 * @return {boolean} Whether element should consider edge navigation. 19823 */ 19824 19825 function isNavigationCandidate(element, keyCode, hasModifier) { 19826 const isVertical = keyCode === external_wp_keycodes_namespaceObject.UP || keyCode === external_wp_keycodes_namespaceObject.DOWN; // Currently, all elements support unmodified vertical navigation. 19827 19828 if (isVertical && !hasModifier) { 19829 return true; 19830 } // Native inputs should not navigate horizontally. 19831 19832 19833 const { 19834 tagName 19835 } = element; 19836 return tagName !== 'INPUT' && tagName !== 'TEXTAREA'; 19837 } 19838 /** 19839 * Returns the optimal tab target from the given focused element in the desired 19840 * direction. A preference is made toward text fields, falling back to the block 19841 * focus stop if no other candidates exist for the block. 19842 * 19843 * @param {Element} target Currently focused text field. 19844 * @param {boolean} isReverse True if considering as the first field. 19845 * @param {Element} containerElement Element containing all blocks. 19846 * @param {boolean} onlyVertical Whether to only consider tabbable elements 19847 * that are visually above or under the 19848 * target. 19849 * 19850 * @return {?Element} Optimal tab target, if one exists. 19851 */ 19852 19853 function getClosestTabbable(target, isReverse, containerElement, onlyVertical) { 19854 // Since the current focus target is not guaranteed to be a text field, find 19855 // all focusables. Tabbability is considered later. 19856 let focusableNodes = external_wp_dom_namespaceObject.focus.focusable.find(containerElement); 19857 19858 if (isReverse) { 19859 focusableNodes = (0,external_lodash_namespaceObject.reverse)(focusableNodes); 19860 } // Consider as candidates those focusables after the current target. It's 19861 // assumed this can only be reached if the target is focusable (on its 19862 // keydown event), so no need to verify it exists in the set. 19863 19864 19865 focusableNodes = focusableNodes.slice(focusableNodes.indexOf(target) + 1); 19866 let targetRect; 19867 19868 if (onlyVertical) { 19869 targetRect = target.getBoundingClientRect(); 19870 } 19871 19872 function isTabCandidate(node) { 19873 // Not a candidate if the node is not tabbable. 19874 if (!external_wp_dom_namespaceObject.focus.tabbable.isTabbableIndex(node)) { 19875 return false; 19876 } // Skip focusable elements such as links within content editable nodes. 19877 19878 19879 if (node.isContentEditable && node.contentEditable !== 'true') { 19880 return false; 19881 } 19882 19883 if (onlyVertical) { 19884 const nodeRect = node.getBoundingClientRect(); 19885 19886 if (nodeRect.left >= targetRect.right || nodeRect.right <= targetRect.left) { 19887 return false; 19888 } 19889 } 19890 19891 return true; 19892 } 19893 19894 return (0,external_lodash_namespaceObject.find)(focusableNodes, isTabCandidate); 19895 } 19896 function useArrowNav() { 19897 const { 19898 getSelectedBlockClientId, 19899 getMultiSelectedBlocksEndClientId, 19900 getPreviousBlockClientId, 19901 getNextBlockClientId, 19902 getSettings, 19903 hasMultiSelection 19904 } = (0,external_wp_data_namespaceObject.useSelect)(store); 19905 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 19906 // Here a DOMRect is stored while moving the caret vertically so 19907 // vertical position of the start position can be restored. This is to 19908 // recreate browser behaviour across blocks. 19909 let verticalRect; 19910 19911 function onMouseDown() { 19912 verticalRect = null; 19913 } 19914 /** 19915 * Returns true if the given target field is the last in its block which 19916 * can be considered for tab transition. For example, in a block with 19917 * two text fields, this would return true when reversing from the first 19918 * of the two fields, but false when reversing from the second. 19919 * 19920 * @param {Element} target Currently focused text field. 19921 * @param {boolean} isReverse True if considering as the first field. 19922 * 19923 * @return {boolean} Whether field is at edge for tab transition. 19924 */ 19925 19926 19927 function isTabbableEdge(target, isReverse) { 19928 const closestTabbable = getClosestTabbable(target, isReverse, node); 19929 return !closestTabbable || !isInSameBlock(target, closestTabbable); 19930 } 19931 19932 function onKeyDown(event) { 19933 const { 19934 keyCode, 19935 target 19936 } = event; 19937 const isUp = keyCode === external_wp_keycodes_namespaceObject.UP; 19938 const isDown = keyCode === external_wp_keycodes_namespaceObject.DOWN; 19939 const isLeft = keyCode === external_wp_keycodes_namespaceObject.LEFT; 19940 const isRight = keyCode === external_wp_keycodes_namespaceObject.RIGHT; 19941 const isReverse = isUp || isLeft; 19942 const isHorizontal = isLeft || isRight; 19943 const isVertical = isUp || isDown; 19944 const isNav = isHorizontal || isVertical; 19945 const isShift = event.shiftKey; 19946 const hasModifier = isShift || event.ctrlKey || event.altKey || event.metaKey; 19947 const isNavEdge = isVertical ? external_wp_dom_namespaceObject.isVerticalEdge : external_wp_dom_namespaceObject.isHorizontalEdge; 19948 const { 19949 ownerDocument 19950 } = node; 19951 const { 19952 defaultView 19953 } = ownerDocument; 19954 19955 if (hasMultiSelection()) { 19956 return; 19957 } // When presing any key other than up or down, the initial vertical 19958 // position must ALWAYS be reset. The vertical position is saved so 19959 // it can be restored as well as possible on sebsequent vertical 19960 // arrow key presses. It may not always be possible to restore the 19961 // exact same position (such as at an empty line), so it wouldn't be 19962 // good to compute the position right before any vertical arrow key 19963 // press. 19964 19965 19966 if (!isVertical) { 19967 verticalRect = null; 19968 } else if (!verticalRect) { 19969 verticalRect = (0,external_wp_dom_namespaceObject.computeCaretRect)(defaultView); 19970 } // Abort if navigation has already been handled (e.g. RichText 19971 // inline boundaries). 19972 19973 19974 if (event.defaultPrevented) { 19975 return; 19976 } 19977 19978 if (!isNav) { 19979 return; 19980 } // Abort if our current target is not a candidate for navigation 19981 // (e.g. preserve native input behaviors). 19982 19983 19984 if (!isNavigationCandidate(target, keyCode, hasModifier)) { 19985 return; 19986 } // In the case of RTL scripts, right means previous and left means 19987 // next, which is the exact reverse of LTR. 19988 19989 19990 const isReverseDir = (0,external_wp_dom_namespaceObject.isRTL)(target) ? !isReverse : isReverse; 19991 const { 19992 keepCaretInsideBlock 19993 } = getSettings(); 19994 const selectedBlockClientId = getSelectedBlockClientId(); 19995 19996 if (isShift) { 19997 const selectionEndClientId = getMultiSelectedBlocksEndClientId(); 19998 const selectionBeforeEndClientId = getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId); 19999 const selectionAfterEndClientId = getNextBlockClientId(selectionEndClientId || selectedBlockClientId); 20000 20001 if ( // Ensure that there is a target block. 20002 (isReverse && selectionBeforeEndClientId || !isReverse && selectionAfterEndClientId) && isTabbableEdge(target, isReverse) && isNavEdge(target, isReverse)) { 20003 node.contentEditable = true; // Firefox doesn't automatically move focus. 20004 20005 node.focus(); 20006 } 20007 } else if (isVertical && (0,external_wp_dom_namespaceObject.isVerticalEdge)(target, isReverse) && !keepCaretInsideBlock) { 20008 const closestTabbable = getClosestTabbable(target, isReverse, node, true); 20009 20010 if (closestTabbable) { 20011 (0,external_wp_dom_namespaceObject.placeCaretAtVerticalEdge)(closestTabbable, isReverse, verticalRect); 20012 event.preventDefault(); 20013 } 20014 } else if (isHorizontal && defaultView.getSelection().isCollapsed && (0,external_wp_dom_namespaceObject.isHorizontalEdge)(target, isReverseDir) && !keepCaretInsideBlock) { 20015 const closestTabbable = getClosestTabbable(target, isReverseDir, node); 20016 (0,external_wp_dom_namespaceObject.placeCaretAtHorizontalEdge)(closestTabbable, isReverse); 20017 event.preventDefault(); 20018 } 20019 } 20020 20021 node.addEventListener('mousedown', onMouseDown); 20022 node.addEventListener('keydown', onKeyDown); 20023 return () => { 20024 node.removeEventListener('mousedown', onMouseDown); 20025 node.removeEventListener('keydown', onKeyDown); 20026 }; 20027 }, []); 20028 } 20029 20030 ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"] 20031 var external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"]; 20032 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-select-all.js 20033 /** 20034 * External dependencies 20035 */ 20036 20037 /** 20038 * WordPress dependencies 20039 */ 20040 20041 20042 20043 20044 20045 /** 20046 * Internal dependencies 20047 */ 20048 20049 20050 function useSelectAll() { 20051 const { 20052 getBlockOrder, 20053 getSelectedBlockClientIds, 20054 getBlockRootClientId 20055 } = (0,external_wp_data_namespaceObject.useSelect)(store); 20056 const { 20057 multiSelect 20058 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 20059 const isMatch = (0,external_wp_keyboardShortcuts_namespaceObject.__unstableUseShortcutEventMatch)(); 20060 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 20061 function onKeyDown(event) { 20062 if (!isMatch('core/block-editor/select-all', event)) { 20063 return; 20064 } 20065 20066 const selectedClientIds = getSelectedBlockClientIds(); 20067 20068 if (selectedClientIds.length < 2 && !(0,external_wp_dom_namespaceObject.isEntirelySelected)(event.target)) { 20069 return; 20070 } 20071 20072 const [firstSelectedClientId] = selectedClientIds; 20073 const rootClientId = getBlockRootClientId(firstSelectedClientId); 20074 let blockClientIds = getBlockOrder(rootClientId); // If we have selected all sibling nested blocks, try selecting up a 20075 // level. See: https://github.com/WordPress/gutenberg/pull/31859/ 20076 20077 if (selectedClientIds.length === blockClientIds.length) { 20078 blockClientIds = getBlockOrder(getBlockRootClientId(rootClientId)); 20079 } 20080 20081 const firstClientId = (0,external_lodash_namespaceObject.first)(blockClientIds); 20082 const lastClientId = (0,external_lodash_namespaceObject.last)(blockClientIds); 20083 20084 if (firstClientId === lastClientId) { 20085 return; 20086 } 20087 20088 multiSelect(firstClientId, lastClientId); 20089 event.preventDefault(); 20090 } 20091 20092 node.addEventListener('keydown', onKeyDown); 20093 return () => { 20094 node.removeEventListener('keydown', onKeyDown); 20095 }; 20096 }, []); 20097 } 20098 20099 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-drag-selection.js 20100 /** 20101 * WordPress dependencies 20102 */ 20103 20104 20105 /** 20106 * Internal dependencies 20107 */ 20108 20109 20110 /** 20111 * Sets the `contenteditable` wrapper element to `value`. 20112 * 20113 * @param {HTMLElement} node Block element. 20114 * @param {boolean} value `contentEditable` value (true or false) 20115 */ 20116 20117 function setContentEditableWrapper(node, value) { 20118 node.contentEditable = value; // Firefox doesn't automatically move focus. 20119 20120 if (value) node.focus(); 20121 } 20122 /** 20123 * Sets a multi-selection based on the native selection across blocks. 20124 */ 20125 20126 20127 function useDragSelection() { 20128 const { 20129 startMultiSelect, 20130 stopMultiSelect 20131 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 20132 const { 20133 isSelectionEnabled, 20134 hasMultiSelection 20135 } = (0,external_wp_data_namespaceObject.useSelect)(store); 20136 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 20137 const { 20138 ownerDocument 20139 } = node; 20140 const { 20141 defaultView 20142 } = ownerDocument; 20143 let anchorElement; 20144 let rafId; 20145 20146 function onMouseUp() { 20147 stopMultiSelect(); // Equivalent to attaching the listener once. 20148 20149 defaultView.removeEventListener('mouseup', onMouseUp); // The browser selection won't have updated yet at this point, 20150 // so wait until the next animation frame to get the browser 20151 // selection. 20152 20153 rafId = defaultView.requestAnimationFrame(() => { 20154 if (hasMultiSelection()) { 20155 return; 20156 } // If the selection is complete (on mouse up), and no 20157 // multiple blocks have been selected, set focus back to the 20158 // anchor element. if the anchor element contains the 20159 // selection. Additionally, the contentEditable wrapper can 20160 // now be disabled again. 20161 20162 20163 setContentEditableWrapper(node, false); 20164 const selection = defaultView.getSelection(); 20165 20166 if (selection.rangeCount) { 20167 const { 20168 commonAncestorContainer 20169 } = selection.getRangeAt(0); 20170 20171 if (anchorElement.contains(commonAncestorContainer)) { 20172 anchorElement.focus(); 20173 } 20174 } 20175 }); 20176 } 20177 20178 function onMouseLeave(_ref) { 20179 let { 20180 buttons, 20181 target 20182 } = _ref; 20183 20184 // The primary button must be pressed to initiate selection. 20185 // See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons 20186 if (buttons !== 1) { 20187 return; 20188 } // Check the attribute, not the contentEditable attribute. All 20189 // child elements of the content editable wrapper are editable 20190 // and return true for this property. We only want to start 20191 // multi selecting when the mouse leaves the wrapper. 20192 20193 20194 if (!target.getAttribute('contenteditable')) { 20195 return; 20196 } 20197 20198 if (!isSelectionEnabled()) { 20199 return; 20200 } 20201 20202 anchorElement = ownerDocument.activeElement; 20203 startMultiSelect(); // `onSelectionStart` is called after `mousedown` and 20204 // `mouseleave` (from a block). The selection ends when 20205 // `mouseup` happens anywhere in the window. 20206 20207 defaultView.addEventListener('mouseup', onMouseUp); // Allow cross contentEditable selection by temporarily making 20208 // all content editable. We can't rely on using the store and 20209 // React because re-rending happens too slowly. We need to be 20210 // able to select across instances immediately. 20211 20212 setContentEditableWrapper(node, true); 20213 } 20214 20215 node.addEventListener('mouseout', onMouseLeave); 20216 return () => { 20217 node.removeEventListener('mouseout', onMouseLeave); 20218 defaultView.removeEventListener('mouseup', onMouseUp); 20219 defaultView.cancelAnimationFrame(rafId); 20220 }; 20221 }, [startMultiSelect, stopMultiSelect, isSelectionEnabled, hasMultiSelection]); 20222 } 20223 20224 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-selection-observer.js 20225 /** 20226 * WordPress dependencies 20227 */ 20228 20229 20230 /** 20231 * Internal dependencies 20232 */ 20233 20234 20235 20236 /** 20237 * Extract the selection start node from the selection. When the anchor node is 20238 * not a text node, the selection offset is the index of a child node. 20239 * 20240 * @param {Selection} selection The selection. 20241 * 20242 * @return {Element} The selection start node. 20243 */ 20244 20245 function extractSelectionStartNode(selection) { 20246 const { 20247 anchorNode, 20248 anchorOffset 20249 } = selection; 20250 20251 if (anchorNode.nodeType === anchorNode.TEXT_NODE) { 20252 return anchorNode; 20253 } 20254 20255 return anchorNode.childNodes[anchorOffset]; 20256 } 20257 /** 20258 * Extract the selection end node from the selection. When the focus node is not 20259 * a text node, the selection offset is the index of a child node. The selection 20260 * reaches up to but excluding that child node. 20261 * 20262 * @param {Selection} selection The selection. 20263 * 20264 * @return {Element} The selection start node. 20265 */ 20266 20267 20268 function extractSelectionEndNode(selection) { 20269 const { 20270 focusNode, 20271 focusOffset 20272 } = selection; 20273 20274 if (focusNode.nodeType === focusNode.TEXT_NODE) { 20275 return focusNode; 20276 } 20277 20278 return focusNode.childNodes[focusOffset - 1]; 20279 } 20280 20281 function findDepth(a, b) { 20282 let depth = 0; 20283 20284 while (a[depth] === b[depth]) { 20285 depth++; 20286 } 20287 20288 return depth; 20289 } 20290 /** 20291 * Sets the `contenteditable` wrapper element to `value`. 20292 * 20293 * @param {HTMLElement} node Block element. 20294 * @param {boolean} value `contentEditable` value (true or false) 20295 */ 20296 20297 20298 function use_selection_observer_setContentEditableWrapper(node, value) { 20299 node.contentEditable = value; // Firefox doesn't automatically move focus. 20300 20301 if (value) node.focus(); 20302 } 20303 /** 20304 * Sets a multi-selection based on the native selection across blocks. 20305 */ 20306 20307 20308 function useSelectionObserver() { 20309 const { 20310 multiSelect, 20311 selectBlock, 20312 selectionChange 20313 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 20314 const { 20315 getBlockParents, 20316 getBlockSelectionStart 20317 } = (0,external_wp_data_namespaceObject.useSelect)(store); 20318 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 20319 const { 20320 ownerDocument 20321 } = node; 20322 const { 20323 defaultView 20324 } = ownerDocument; 20325 20326 function onSelectionChange(event) { 20327 const selection = defaultView.getSelection(); // If no selection is found, end multi selection and disable the 20328 // contentEditable wrapper. 20329 20330 if (!selection.rangeCount) { 20331 use_selection_observer_setContentEditableWrapper(node, false); 20332 return; 20333 } // If selection is collapsed and we haven't used `shift+click`, 20334 // end multi selection and disable the contentEditable wrapper. 20335 // We have to check about `shift+click` case because elements 20336 // that don't support text selection might be involved, and we might 20337 // update the clientIds to multi-select blocks. 20338 // For now we check if the event is a `mouse` event. 20339 20340 20341 const isClickShift = event.shiftKey && event.type === 'mouseup'; 20342 20343 if (selection.isCollapsed && !isClickShift) { 20344 use_selection_observer_setContentEditableWrapper(node, false); 20345 return; 20346 } 20347 20348 let startClientId = getBlockClientId(extractSelectionStartNode(selection)); 20349 let endClientId = getBlockClientId(extractSelectionEndNode(selection)); // If the selection has changed and we had pressed `shift+click`, 20350 // we need to check if in an element that doesn't support 20351 // text selection has been clicked. 20352 20353 if (isClickShift) { 20354 const selectedClientId = getBlockSelectionStart(); 20355 const clickedClientId = getBlockClientId(event.target); // `endClientId` is not defined if we end the selection by clicking a non-selectable block. 20356 // We need to check if there was already a selection with a non-selectable focusNode. 20357 20358 const focusNodeIsNonSelectable = clickedClientId !== endClientId; 20359 20360 if (startClientId === endClientId && selection.isCollapsed || !endClientId || focusNodeIsNonSelectable) { 20361 endClientId = clickedClientId; 20362 } // Handle the case when we have a non-selectable block 20363 // selected and click another one. 20364 20365 20366 if (startClientId !== selectedClientId) { 20367 startClientId = selectedClientId; 20368 } 20369 } // If the selection did not involve a block, return. 20370 20371 20372 if (startClientId === undefined && endClientId === undefined) { 20373 use_selection_observer_setContentEditableWrapper(node, false); 20374 return; 20375 } 20376 20377 const isSingularSelection = startClientId === endClientId; 20378 20379 if (isSingularSelection) { 20380 selectBlock(startClientId); 20381 } else { 20382 const startPath = [...getBlockParents(startClientId), startClientId]; 20383 const endPath = [...getBlockParents(endClientId), endClientId]; 20384 const depth = findDepth(startPath, endPath); 20385 multiSelect(startPath[depth], endPath[depth]); 20386 } 20387 } 20388 20389 function addListeners() { 20390 ownerDocument.addEventListener('selectionchange', onSelectionChange); 20391 defaultView.addEventListener('mouseup', onSelectionChange); 20392 } 20393 20394 function removeListeners() { 20395 ownerDocument.removeEventListener('selectionchange', onSelectionChange); 20396 defaultView.removeEventListener('mouseup', onSelectionChange); 20397 } 20398 20399 function resetListeners() { 20400 removeListeners(); 20401 addListeners(); 20402 } 20403 20404 addListeners(); // We must allow rich text to set selection first. This ensures that 20405 // our `selectionchange` listener is always reset to be called after 20406 // the rich text one. 20407 20408 node.addEventListener('focusin', resetListeners); 20409 return () => { 20410 removeListeners(); 20411 node.removeEventListener('focusin', resetListeners); 20412 }; 20413 }, [multiSelect, selectBlock, selectionChange, getBlockParents]); 20414 } 20415 20416 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-click-selection.js 20417 /** 20418 * WordPress dependencies 20419 */ 20420 20421 20422 /** 20423 * Internal dependencies 20424 */ 20425 20426 20427 20428 function useClickSelection() { 20429 const { 20430 selectBlock 20431 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 20432 const { 20433 isSelectionEnabled, 20434 getBlockSelectionStart, 20435 hasMultiSelection 20436 } = (0,external_wp_data_namespaceObject.useSelect)(store); 20437 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 20438 function onMouseDown(event) { 20439 // The main button. 20440 // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button 20441 if (!isSelectionEnabled() || event.button !== 0) { 20442 return; 20443 } 20444 20445 const startClientId = getBlockSelectionStart(); 20446 const clickedClientId = getBlockClientId(event.target); 20447 20448 if (event.shiftKey) { 20449 if (startClientId !== clickedClientId) { 20450 node.contentEditable = true; // Firefox doesn't automatically move focus. 20451 20452 node.focus(); 20453 } 20454 } else if (hasMultiSelection()) { 20455 // Allow user to escape out of a multi-selection to a 20456 // singular selection of a block via click. This is handled 20457 // here since focus handling excludes blocks when there is 20458 // multiselection, as focus can be incurred by starting a 20459 // multiselection (focus moved to first block's multi- 20460 // controls). 20461 selectBlock(clickedClientId); 20462 } 20463 } 20464 20465 node.addEventListener('mousedown', onMouseDown); 20466 return () => { 20467 node.removeEventListener('mousedown', onMouseDown); 20468 }; 20469 }, [selectBlock, isSelectionEnabled, getBlockSelectionStart, hasMultiSelection]); 20470 } 20471 20472 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-input.js 20473 /** 20474 * WordPress dependencies 20475 */ 20476 20477 20478 20479 20480 /** 20481 * Internal dependencies 20482 */ 20483 20484 20485 /** 20486 * Handles input for selections across blocks. 20487 */ 20488 20489 function useInput() { 20490 const { 20491 __unstableIsFullySelected, 20492 getSelectedBlockClientIds, 20493 __unstableIsSelectionMergeable, 20494 hasMultiSelection 20495 } = (0,external_wp_data_namespaceObject.useSelect)(store); 20496 const { 20497 replaceBlocks, 20498 __unstableSplitSelection, 20499 removeBlocks, 20500 __unstableDeleteSelection, 20501 __unstableExpandSelection 20502 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 20503 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 20504 function onKeyDown(event) { 20505 if (event.defaultPrevented) { 20506 return; 20507 } 20508 20509 if (!hasMultiSelection()) { 20510 return; 20511 } 20512 20513 if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) { 20514 node.contentEditable = false; 20515 event.preventDefault(); 20516 20517 if (__unstableIsFullySelected()) { 20518 replaceBlocks(getSelectedBlockClientIds(), (0,external_wp_blocks_namespaceObject.createBlock)((0,external_wp_blocks_namespaceObject.getDefaultBlockName)())); 20519 } else { 20520 __unstableSplitSelection(); 20521 } 20522 } else if (event.keyCode === external_wp_keycodes_namespaceObject.BACKSPACE || event.keyCode === external_wp_keycodes_namespaceObject.DELETE) { 20523 node.contentEditable = false; 20524 event.preventDefault(); 20525 20526 if (__unstableIsFullySelected()) { 20527 removeBlocks(getSelectedBlockClientIds()); 20528 } else if (__unstableIsSelectionMergeable()) { 20529 __unstableDeleteSelection(event.keyCode === external_wp_keycodes_namespaceObject.DELETE); 20530 } else { 20531 __unstableExpandSelection(); 20532 } 20533 } else if ( // If key.length is longer than 1, it's a control key that doesn't 20534 // input anything. 20535 event.key.length === 1 && !(event.metaKey || event.ctrlKey)) { 20536 node.contentEditable = false; 20537 20538 if (__unstableIsSelectionMergeable()) { 20539 __unstableDeleteSelection(event.keyCode === external_wp_keycodes_namespaceObject.DELETE); 20540 } else { 20541 event.preventDefault(); // Safari does not stop default behaviour with either 20542 // event.preventDefault() or node.contentEditable = false, so 20543 // remove the selection to stop browser manipulation. 20544 20545 node.ownerDocument.defaultView.getSelection().removeAllRanges(); 20546 } 20547 } 20548 } 20549 20550 function onCompositionStart(event) { 20551 if (!hasMultiSelection()) { 20552 return; 20553 } 20554 20555 node.contentEditable = false; 20556 20557 if (__unstableIsSelectionMergeable()) { 20558 __unstableDeleteSelection(); 20559 } else { 20560 event.preventDefault(); // Safari does not stop default behaviour with either 20561 // event.preventDefault() or node.contentEditable = false, so 20562 // remove the selection to stop browser manipulation. 20563 20564 node.ownerDocument.defaultView.getSelection().removeAllRanges(); 20565 } 20566 } 20567 20568 node.addEventListener('keydown', onKeyDown); 20569 node.addEventListener('compositionstart', onCompositionStart); 20570 return () => { 20571 node.removeEventListener('keydown', onKeyDown); 20572 node.removeEventListener('compositionstart', onCompositionStart); 20573 }; 20574 }, []); 20575 } 20576 20577 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/index.js 20578 20579 20580 20581 /** 20582 * External dependencies 20583 */ 20584 20585 /** 20586 * WordPress dependencies 20587 */ 20588 20589 20590 20591 20592 20593 /** 20594 * Internal dependencies 20595 */ 20596 20597 20598 20599 20600 20601 20602 20603 20604 20605 20606 function useWritingFlow() { 20607 const [before, ref, after] = useTabNav(); 20608 const hasMultiSelection = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).hasMultiSelection(), []); 20609 return [before, (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, useInput(), useDragSelection(), useSelectionObserver(), useClickSelection(), useMultiSelection(), useSelectAll(), useArrowNav(), (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 20610 node.tabIndex = -1; 20611 node.contentEditable = hasMultiSelection; 20612 20613 if (!hasMultiSelection) { 20614 return; 20615 } 20616 20617 node.setAttribute('aria-label', (0,external_wp_i18n_namespaceObject.__)('Multiple selected blocks')); 20618 return () => { 20619 node.removeAttribute('aria-label'); 20620 }; 20621 }, [hasMultiSelection])]), after]; 20622 } 20623 20624 function WritingFlow(_ref, forwardedRef) { 20625 let { 20626 children, 20627 ...props 20628 } = _ref; 20629 const [before, ref, after] = useWritingFlow(); 20630 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, before, (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, props, { 20631 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, forwardedRef]), 20632 className: classnames_default()(props.className, 'block-editor-writing-flow') 20633 }), children), after); 20634 } 20635 /** 20636 * Handles selection and navigation across blocks. This component should be 20637 * wrapped around BlockList. 20638 * 20639 * @param {Object} props Component properties. 20640 * @param {WPElement} props.children Children to be rendered. 20641 */ 20642 20643 20644 /* harmony default export */ var writing_flow = ((0,external_wp_element_namespaceObject.forwardRef)(WritingFlow)); 20645 20646 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/iframe/index.js 20647 20648 20649 20650 /** 20651 * External dependencies 20652 */ 20653 20654 /** 20655 * WordPress dependencies 20656 */ 20657 20658 20659 20660 20661 20662 /** 20663 * Internal dependencies 20664 */ 20665 20666 20667 20668 const BODY_CLASS_NAME = 'editor-styles-wrapper'; 20669 const BLOCK_PREFIX = 'wp-block'; 20670 /** 20671 * Clones stylesheets targetting the editor canvas to the given document. A 20672 * stylesheet is considered targetting the editor a canvas if it contains the 20673 * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors. 20674 * 20675 * Ideally, this hook should be removed in the future and styles should be added 20676 * explicitly as editor styles. 20677 * 20678 * @param {Document} doc The document to append cloned stylesheets to. 20679 */ 20680 20681 function styleSheetsCompat(doc) { 20682 // Search the document for stylesheets targetting the editor canvas. 20683 Array.from(document.styleSheets).forEach(styleSheet => { 20684 try { 20685 // May fail for external styles. 20686 // eslint-disable-next-line no-unused-expressions 20687 styleSheet.cssRules; 20688 } catch (e) { 20689 return; 20690 } 20691 20692 const { 20693 ownerNode, 20694 cssRules 20695 } = styleSheet; 20696 20697 if (!cssRules) { 20698 return; 20699 } // Generally, ignore inline styles. We add inline styles belonging to a 20700 // stylesheet later, which may or may not match the selectors. 20701 20702 20703 if (ownerNode.tagName !== 'LINK') { 20704 return; 20705 } // Don't try to add the reset styles, which were removed as a dependency 20706 // from `edit-blocks` for the iframe since we don't need to reset admin 20707 // styles. 20708 20709 20710 if (ownerNode.id === 'wp-reset-editor-styles-css') { 20711 return; 20712 } 20713 20714 const isMatch = Array.from(cssRules).find(_ref => { 20715 let { 20716 selectorText 20717 } = _ref; 20718 return selectorText && (selectorText.includes(`.$BODY_CLASS_NAME}`) || selectorText.includes(`.$BLOCK_PREFIX}`)); 20719 }); 20720 20721 if (isMatch && !doc.getElementById(ownerNode.id)) { 20722 // Display warning once we have a way to add style dependencies to the editor. 20723 // See: https://github.com/WordPress/gutenberg/pull/37466. 20724 doc.head.appendChild(ownerNode.cloneNode(true)); // Add inline styles belonging to the stylesheet. 20725 20726 const inlineCssId = ownerNode.id.replace('-css', '-inline-css'); 20727 const inlineCssElement = document.getElementById(inlineCssId); 20728 20729 if (inlineCssElement) { 20730 doc.head.appendChild(inlineCssElement.cloneNode(true)); 20731 } 20732 } 20733 }); 20734 } 20735 /** 20736 * Bubbles some event types (keydown, keypress, and dragover) to parent document 20737 * document to ensure that the keyboard shortcuts and drag and drop work. 20738 * 20739 * Ideally, we should remove event bubbling in the future. Keyboard shortcuts 20740 * should be context dependent, e.g. actions on blocks like Cmd+A should not 20741 * work globally outside the block editor. 20742 * 20743 * @param {Document} doc Document to attach listeners to. 20744 */ 20745 20746 20747 function bubbleEvents(doc) { 20748 const { 20749 defaultView 20750 } = doc; 20751 const { 20752 frameElement 20753 } = defaultView; 20754 20755 function bubbleEvent(event) { 20756 const prototype = Object.getPrototypeOf(event); 20757 const constructorName = prototype.constructor.name; 20758 const Constructor = window[constructorName]; 20759 const init = {}; 20760 20761 for (const key in event) { 20762 init[key] = event[key]; 20763 } 20764 20765 if (event instanceof defaultView.MouseEvent) { 20766 const rect = frameElement.getBoundingClientRect(); 20767 init.clientX += rect.left; 20768 init.clientY += rect.top; 20769 } 20770 20771 const newEvent = new Constructor(event.type, init); 20772 const cancelled = !frameElement.dispatchEvent(newEvent); 20773 20774 if (cancelled) { 20775 event.preventDefault(); 20776 } 20777 } 20778 20779 const eventTypes = ['dragover']; 20780 20781 for (const name of eventTypes) { 20782 doc.addEventListener(name, bubbleEvent); 20783 } 20784 } 20785 20786 function useParsedAssets(html) { 20787 return (0,external_wp_element_namespaceObject.useMemo)(() => { 20788 const doc = document.implementation.createHTMLDocument(''); 20789 doc.body.innerHTML = html; 20790 return Array.from(doc.body.children); 20791 }, [html]); 20792 } 20793 20794 async function loadScript(head, _ref2) { 20795 let { 20796 id, 20797 src 20798 } = _ref2; 20799 return new Promise((resolve, reject) => { 20800 const script = head.ownerDocument.createElement('script'); 20801 script.id = id; 20802 20803 if (src) { 20804 script.src = src; 20805 20806 script.onload = () => resolve(); 20807 20808 script.onerror = () => reject(); 20809 } else { 20810 resolve(); 20811 } 20812 20813 head.appendChild(script); 20814 }); 20815 } 20816 20817 function Iframe(_ref3, ref) { 20818 let { 20819 contentRef, 20820 children, 20821 head, 20822 tabIndex = 0, 20823 assets, 20824 ...props 20825 } = _ref3; 20826 const [, forceRender] = (0,external_wp_element_namespaceObject.useReducer)(() => ({})); 20827 const [iframeDocument, setIframeDocument] = (0,external_wp_element_namespaceObject.useState)(); 20828 const [bodyClasses, setBodyClasses] = (0,external_wp_element_namespaceObject.useState)([]); 20829 const styles = useParsedAssets(assets === null || assets === void 0 ? void 0 : assets.styles); 20830 const scripts = useParsedAssets(assets === null || assets === void 0 ? void 0 : assets.scripts); 20831 const clearerRef = useBlockSelectionClearer(); 20832 const [before, writingFlowRef, after] = useWritingFlow(); 20833 const setRef = (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 20834 function setDocumentIfReady() { 20835 const { 20836 contentDocument, 20837 ownerDocument 20838 } = node; 20839 const { 20840 readyState, 20841 documentElement 20842 } = contentDocument; 20843 20844 if (readyState !== 'interactive' && readyState !== 'complete') { 20845 return false; 20846 } 20847 20848 bubbleEvents(contentDocument); 20849 setIframeDocument(contentDocument); 20850 clearerRef(documentElement); // Ideally ALL classes that are added through get_body_class should 20851 // be added in the editor too, which we'll somehow have to get from 20852 // the server in the future (which will run the PHP filters). 20853 20854 setBodyClasses(Array.from(ownerDocument.body.classList).filter(name => name.startsWith('admin-color-') || name.startsWith('post-type-') || name === 'wp-embed-responsive')); 20855 contentDocument.dir = ownerDocument.dir; 20856 documentElement.removeChild(contentDocument.head); 20857 documentElement.removeChild(contentDocument.body); 20858 return true; 20859 } // Document set with srcDoc is not immediately ready. 20860 20861 20862 node.addEventListener('load', setDocumentIfReady); 20863 return () => node.removeEventListener('load', setDocumentIfReady); 20864 }, []); 20865 const headRef = (0,external_wp_compose_namespaceObject.useRefEffect)(element => { 20866 scripts.reduce((promise, script) => promise.then(() => loadScript(element, script)), Promise.resolve()).finally(() => { 20867 // When script are loaded, re-render blocks to allow them 20868 // to initialise. 20869 forceRender(); 20870 }); 20871 }, []); 20872 const bodyRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([contentRef, clearerRef, writingFlowRef]); 20873 (0,external_wp_element_namespaceObject.useEffect)(() => { 20874 if (iframeDocument) { 20875 styleSheetsCompat(iframeDocument); 20876 } 20877 }, [iframeDocument]); 20878 head = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("style", null, 'body{margin:0}'), styles.map(_ref4 => { 20879 let { 20880 tagName, 20881 href, 20882 id, 20883 rel, 20884 media, 20885 textContent 20886 } = _ref4; 20887 const TagName = tagName.toLowerCase(); 20888 20889 if (TagName === 'style') { 20890 return (0,external_wp_element_namespaceObject.createElement)(TagName, { 20891 id, 20892 key: id 20893 }, textContent); 20894 } 20895 20896 return (0,external_wp_element_namespaceObject.createElement)(TagName, { 20897 href, 20898 id, 20899 rel, 20900 media, 20901 key: id 20902 }); 20903 }), head); 20904 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, tabIndex >= 0 && before, (0,external_wp_element_namespaceObject.createElement)("iframe", _extends({}, props, { 20905 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, setRef]), 20906 tabIndex: tabIndex // Correct doctype is required to enable rendering in standards mode 20907 , 20908 srcDoc: "<!doctype html>", 20909 title: (0,external_wp_i18n_namespaceObject.__)('Editor canvas') 20910 }), iframeDocument && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("head", { 20911 ref: headRef 20912 }, head), (0,external_wp_element_namespaceObject.createElement)("body", { 20913 ref: bodyRef, 20914 className: classnames_default()(BODY_CLASS_NAME, ...bodyClasses) 20915 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, { 20916 document: iframeDocument 20917 }, children))), iframeDocument.documentElement)), tabIndex >= 0 && after); 20918 } 20919 20920 /* harmony default export */ var iframe = ((0,external_wp_element_namespaceObject.forwardRef)(Iframe)); 20921 20922 ;// CONCATENATED MODULE: ./node_modules/colord/index.mjs 20923 var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},e=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},u=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},a=function(r){return{r:e(r.r,0,255),g:e(r.g,0,255),b:e(r.b,0,255),a:e(r.a)}},o=function(r){return{r:n(r.r),g:n(r.g),b:n(r.b),a:n(r.a,3)}},i=/^#([0-9a-f]{3,8})$/i,s=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},h=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,a=Math.max(t,n,e),o=a-Math.min(t,n,e),i=o?a===t?(n-e)/o:a===n?2+(e-t)/o:4+(t-n)/o:0;return{h:60*(i<0?i+6:i),s:a?o/a*100:0,v:a/255*100,a:u}},b=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var a=Math.floor(t),o=e*(1-n),i=e*(1-(t-a)*n),s=e*(1-(1-t+a)*n),h=a%6;return{r:255*[e,i,o,o,s,e][h],g:255*[s,e,e,i,o,o][h],b:255*[o,o,s,e,e,i][h],a:u}},g=function(r){return{h:u(r.h),s:e(r.s,0,100),l:e(r.l,0,100),a:e(r.a)}},d=function(r){return{h:n(r.h),s:n(r.s),l:n(r.l),a:n(r.a,3)}},f=function(r){return b((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},c=function(r){return{h:(t=h(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},l=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,p=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y={string:[[function(r){var t=i.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?n(parseInt(r[3]+r[3],16)/255,2):1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?n(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=v.exec(r)||m.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(t){var n=l.exec(t)||p.exec(t);if(!n)return null;var e,u,a=g({h:(e=n[1],u=n[2],void 0===u&&(u="deg"),Number(e)*(r[u]||1)),s:Number(n[3]),l:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return f(a)},"hsl"]],object:[[function(r){var n=r.r,e=r.g,u=r.b,o=r.a,i=void 0===o?1:o;return t(n)&&t(e)&&t(u)?a({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},"rgb"],[function(r){var n=r.h,e=r.s,u=r.l,a=r.a,o=void 0===a?1:a;if(!t(n)||!t(e)||!t(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(o)});return f(i)},"hsl"],[function(r){var n=r.h,a=r.s,o=r.v,i=r.a,s=void 0===i?1:i;if(!t(n)||!t(a)||!t(o))return null;var h=function(r){return{h:u(r.h),s:e(r.s,0,100),v:e(r.v,0,100),a:e(r.a)}}({h:Number(n),s:Number(a),v:Number(o),a:Number(s)});return b(h)},"hsv"]]},N=function(r,t){for(var n=0;n<t.length;n++){var e=t[n][0](r);if(e)return[e,t[n][1]]}return[null,void 0]},x=function(r){return"string"==typeof r?N(r.trim(),y.string):"object"==typeof r&&null!==r?N(r,y.object):[null,void 0]},I=function(r){return x(r)[1]},M=function(r,t){var n=c(r);return{h:n.h,s:e(n.s+100*t,0,100),l:n.l,a:n.a}},H=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},$=function(r,t){var n=c(r);return{h:n.h,s:n.s,l:e(n.l+100*t,0,100),a:n.a}},j=function(){function r(r){this.parsed=x(r)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return n(H(this.rgba),2)},r.prototype.isDark=function(){return H(this.rgba)<.5},r.prototype.isLight=function(){return H(this.rgba)>=.5},r.prototype.toHex=function(){return r=o(this.rgba),t=r.r,e=r.g,u=r.b,i=(a=r.a)<1?s(n(255*a)):"","#"+s(t)+s(e)+s(u)+i;var r,t,e,u,a,i},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return r=o(this.rgba),t=r.r,n=r.g,e=r.b,(u=r.a)<1?"rgba("+t+", "+n+", "+e+", "+u+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,u},r.prototype.toHsl=function(){return d(c(this.rgba))},r.prototype.toHslString=function(){return r=d(c(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u},r.prototype.toHsv=function(){return r=h(this.rgba),{h:n(r.h),s:n(r.s),v:n(r.v),a:n(r.a,3)};var r},r.prototype.invert=function(){return w({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,-r))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),w($(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),w($(this.rgba,-r))},r.prototype.rotate=function(r){return void 0===r&&(r=15),this.hue(this.hue()+r)},r.prototype.alpha=function(r){return"number"==typeof r?w({r:(t=this.rgba).r,g:t.g,b:t.b,a:r}):n(this.rgba.a,3);var t},r.prototype.hue=function(r){var t=c(this.rgba);return"number"==typeof r?w({h:r,s:t.s,l:t.l,a:t.a}):n(t.h)},r.prototype.isEqual=function(r){return this.toHex()===w(r).toHex()},r}(),w=function(r){return r instanceof j?r:new j(r)},S=[],k=function(r){r.forEach(function(r){S.indexOf(r)<0&&(r(j,y),S.push(r))})},E=function(){return new j({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})}; 20924 20925 ;// CONCATENATED MODULE: ./node_modules/colord/plugins/names.mjs 20926 /* harmony default export */ function names(e,f){var a={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var d in a)r[a[d]]=d;var l={};e.prototype.toName=function(f){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var d,i,n=r[this.toHex()];if(n)return n;if(null==f?void 0:f.closest){var o=this.toRgb(),t=1/0,b="black";if(!l.length)for(var c in a)l[c]=new e(a[c]).toRgb();for(var g in a){var u=(d=o,i=l[g],Math.pow(d.r-i.r,2)+Math.pow(d.g-i.g,2)+Math.pow(d.b-i.b,2));u<t&&(t=u,b=g)}return b}};f.string.push([function(f){var r=f.toLowerCase(),d="transparent"===r?"#0000":a[r];return d?new e(d).toRgb():null},"name"])} 20927 20928 ;// CONCATENATED MODULE: ./node_modules/colord/plugins/a11y.mjs 20929 var a11y_o=function(o){var t=o/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},a11y_t=function(t){return.2126*a11y_o(t.r)+.7152*a11y_o(t.g)+.0722*a11y_o(t.b)};/* harmony default export */ function a11y(o){o.prototype.luminance=function(){return o=a11y_t(this.rgba),void 0===(r=2)&&(r=0),void 0===n&&(n=Math.pow(10,r)),Math.round(n*o)/n+0;var o,r,n},o.prototype.contrast=function(r){void 0===r&&(r="#FFF");var n,a,i,e,v,u,d,c=r instanceof o?r:new o(r);return e=this.rgba,v=c.toRgb(),u=a11y_t(e),d=a11y_t(v),n=u>d?(u+.05)/(d+.05):(d+.05)/(u+.05),void 0===(a=2)&&(a=0),void 0===i&&(i=Math.pow(10,a)),Math.floor(i*n)/i+0},o.prototype.isReadable=function(o,t){return void 0===o&&(o="#FFF"),void 0===t&&(t={}),this.contrast(o)>=(e=void 0===(i=(r=t).size)?"normal":i,"AAA"===(a=void 0===(n=r.level)?"AA":n)&&"normal"===e?7:"AA"===a&&"large"===e?3:4.5);var r,n,a,i,e}} 20930 20931 // EXTERNAL MODULE: ./node_modules/traverse/index.js 20932 var traverse = __webpack_require__(3124); 20933 var traverse_default = /*#__PURE__*/__webpack_require__.n(traverse); 20934 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/parse.js 20935 /* eslint-disable @wordpress/no-unused-vars-before-return */ 20936 // Adapted from https://github.com/reworkcss/css 20937 // because we needed to remove source map support. 20938 // http://www.w3.org/TR/CSS21/grammar.htm 20939 // https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027 20940 const commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g; 20941 /* harmony default export */ function parse(css, options) { 20942 options = options || {}; 20943 /** 20944 * Positional. 20945 */ 20946 20947 let lineno = 1; 20948 let column = 1; 20949 /** 20950 * Update lineno and column based on `str`. 20951 */ 20952 20953 function updatePosition(str) { 20954 const lines = str.match(/\n/g); 20955 20956 if (lines) { 20957 lineno += lines.length; 20958 } 20959 20960 const i = str.lastIndexOf('\n'); // eslint-disable-next-line no-bitwise 20961 20962 column = ~i ? str.length - i : column + str.length; 20963 } 20964 /** 20965 * Mark position and patch `node.position`. 20966 */ 20967 20968 20969 function position() { 20970 const start = { 20971 line: lineno, 20972 column 20973 }; 20974 return function (node) { 20975 node.position = new Position(start); 20976 whitespace(); 20977 return node; 20978 }; 20979 } 20980 /** 20981 * Store position information for a node 20982 */ 20983 20984 20985 function Position(start) { 20986 this.start = start; 20987 this.end = { 20988 line: lineno, 20989 column 20990 }; 20991 this.source = options.source; 20992 } 20993 /** 20994 * Non-enumerable source string 20995 */ 20996 20997 20998 Position.prototype.content = css; 20999 /** 21000 * Error `msg`. 21001 */ 21002 21003 const errorsList = []; 21004 21005 function error(msg) { 21006 const err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg); 21007 err.reason = msg; 21008 err.filename = options.source; 21009 err.line = lineno; 21010 err.column = column; 21011 err.source = css; 21012 21013 if (options.silent) { 21014 errorsList.push(err); 21015 } else { 21016 throw err; 21017 } 21018 } 21019 /** 21020 * Parse stylesheet. 21021 */ 21022 21023 21024 function stylesheet() { 21025 const rulesList = rules(); 21026 return { 21027 type: 'stylesheet', 21028 stylesheet: { 21029 source: options.source, 21030 rules: rulesList, 21031 parsingErrors: errorsList 21032 } 21033 }; 21034 } 21035 /** 21036 * Opening brace. 21037 */ 21038 21039 21040 function open() { 21041 return match(/^{\s*/); 21042 } 21043 /** 21044 * Closing brace. 21045 */ 21046 21047 21048 function close() { 21049 return match(/^}/); 21050 } 21051 /** 21052 * Parse ruleset. 21053 */ 21054 21055 21056 function rules() { 21057 let node; 21058 const accumulator = []; 21059 whitespace(); 21060 comments(accumulator); 21061 21062 while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) { 21063 if (node !== false) { 21064 accumulator.push(node); 21065 comments(accumulator); 21066 } 21067 } 21068 21069 return accumulator; 21070 } 21071 /** 21072 * Match `re` and return captures. 21073 */ 21074 21075 21076 function match(re) { 21077 const m = re.exec(css); 21078 21079 if (!m) { 21080 return; 21081 } 21082 21083 const str = m[0]; 21084 updatePosition(str); 21085 css = css.slice(str.length); 21086 return m; 21087 } 21088 /** 21089 * Parse whitespace. 21090 */ 21091 21092 21093 function whitespace() { 21094 match(/^\s*/); 21095 } 21096 /** 21097 * Parse comments; 21098 */ 21099 21100 21101 function comments(accumulator) { 21102 let c; 21103 accumulator = accumulator || []; // eslint-disable-next-line no-cond-assign 21104 21105 while (c = comment()) { 21106 if (c !== false) { 21107 accumulator.push(c); 21108 } 21109 } 21110 21111 return accumulator; 21112 } 21113 /** 21114 * Parse comment. 21115 */ 21116 21117 21118 function comment() { 21119 const pos = position(); 21120 21121 if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) { 21122 return; 21123 } 21124 21125 let i = 2; 21126 21127 while ('' !== css.charAt(i) && ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) { 21128 ++i; 21129 } 21130 21131 i += 2; 21132 21133 if ('' === css.charAt(i - 1)) { 21134 return error('End of comment missing'); 21135 } 21136 21137 const str = css.slice(2, i - 2); 21138 column += 2; 21139 updatePosition(str); 21140 css = css.slice(i); 21141 column += 2; 21142 return pos({ 21143 type: 'comment', 21144 comment: str 21145 }); 21146 } 21147 /** 21148 * Parse selector. 21149 */ 21150 21151 21152 function selector() { 21153 const m = match(/^([^{]+)/); 21154 21155 if (!m) { 21156 return; 21157 } // FIXME: Remove all comments from selectors http://ostermiller.org/findcomment.html 21158 21159 21160 return trim(m[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '').replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (matched) { 21161 return matched.replace(/,/g, '\u200C'); 21162 }).split(/\s*(?![^(]*\)),\s*/).map(function (s) { 21163 return s.replace(/\u200C/g, ','); 21164 }); 21165 } 21166 /** 21167 * Parse declaration. 21168 */ 21169 21170 21171 function declaration() { 21172 const pos = position(); // prop. 21173 21174 let prop = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/); 21175 21176 if (!prop) { 21177 return; 21178 } 21179 21180 prop = trim(prop[0]); // : 21181 21182 if (!match(/^:\s*/)) { 21183 return error("property missing ':'"); 21184 } // val. 21185 21186 21187 const val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/); 21188 const ret = pos({ 21189 type: 'declaration', 21190 property: prop.replace(commentre, ''), 21191 value: val ? trim(val[0]).replace(commentre, '') : '' 21192 }); // ; 21193 21194 match(/^[;\s]*/); 21195 return ret; 21196 } 21197 /** 21198 * Parse declarations. 21199 */ 21200 21201 21202 function declarations() { 21203 const decls = []; 21204 21205 if (!open()) { 21206 return error("missing '{'"); 21207 } 21208 21209 comments(decls); // declarations. 21210 21211 let decl; // eslint-disable-next-line no-cond-assign 21212 21213 while (decl = declaration()) { 21214 if (decl !== false) { 21215 decls.push(decl); 21216 comments(decls); 21217 } 21218 } 21219 21220 if (!close()) { 21221 return error("missing '}'"); 21222 } 21223 21224 return decls; 21225 } 21226 /** 21227 * Parse keyframe. 21228 */ 21229 21230 21231 function keyframe() { 21232 let m; 21233 const vals = []; 21234 const pos = position(); // eslint-disable-next-line no-cond-assign 21235 21236 while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) { 21237 vals.push(m[1]); 21238 match(/^,\s*/); 21239 } 21240 21241 if (!vals.length) { 21242 return; 21243 } 21244 21245 return pos({ 21246 type: 'keyframe', 21247 values: vals, 21248 declarations: declarations() 21249 }); 21250 } 21251 /** 21252 * Parse keyframes. 21253 */ 21254 21255 21256 function atkeyframes() { 21257 const pos = position(); 21258 let m = match(/^@([-\w]+)?keyframes\s*/); 21259 21260 if (!m) { 21261 return; 21262 } 21263 21264 const vendor = m[1]; // identifier 21265 21266 m = match(/^([-\w]+)\s*/); 21267 21268 if (!m) { 21269 return error('@keyframes missing name'); 21270 } 21271 21272 const name = m[1]; 21273 21274 if (!open()) { 21275 return error("@keyframes missing '{'"); 21276 } 21277 21278 let frame; 21279 let frames = comments(); // eslint-disable-next-line no-cond-assign 21280 21281 while (frame = keyframe()) { 21282 frames.push(frame); 21283 frames = frames.concat(comments()); 21284 } 21285 21286 if (!close()) { 21287 return error("@keyframes missing '}'"); 21288 } 21289 21290 return pos({ 21291 type: 'keyframes', 21292 name, 21293 vendor, 21294 keyframes: frames 21295 }); 21296 } 21297 /** 21298 * Parse supports. 21299 */ 21300 21301 21302 function atsupports() { 21303 const pos = position(); 21304 const m = match(/^@supports *([^{]+)/); 21305 21306 if (!m) { 21307 return; 21308 } 21309 21310 const supports = trim(m[1]); 21311 21312 if (!open()) { 21313 return error("@supports missing '{'"); 21314 } 21315 21316 const style = comments().concat(rules()); 21317 21318 if (!close()) { 21319 return error("@supports missing '}'"); 21320 } 21321 21322 return pos({ 21323 type: 'supports', 21324 supports, 21325 rules: style 21326 }); 21327 } 21328 /** 21329 * Parse host. 21330 */ 21331 21332 21333 function athost() { 21334 const pos = position(); 21335 const m = match(/^@host\s*/); 21336 21337 if (!m) { 21338 return; 21339 } 21340 21341 if (!open()) { 21342 return error("@host missing '{'"); 21343 } 21344 21345 const style = comments().concat(rules()); 21346 21347 if (!close()) { 21348 return error("@host missing '}'"); 21349 } 21350 21351 return pos({ 21352 type: 'host', 21353 rules: style 21354 }); 21355 } 21356 /** 21357 * Parse media. 21358 */ 21359 21360 21361 function atmedia() { 21362 const pos = position(); 21363 const m = match(/^@media *([^{]+)/); 21364 21365 if (!m) { 21366 return; 21367 } 21368 21369 const media = trim(m[1]); 21370 21371 if (!open()) { 21372 return error("@media missing '{'"); 21373 } 21374 21375 const style = comments().concat(rules()); 21376 21377 if (!close()) { 21378 return error("@media missing '}'"); 21379 } 21380 21381 return pos({ 21382 type: 'media', 21383 media, 21384 rules: style 21385 }); 21386 } 21387 /** 21388 * Parse custom-media. 21389 */ 21390 21391 21392 function atcustommedia() { 21393 const pos = position(); 21394 const m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/); 21395 21396 if (!m) { 21397 return; 21398 } 21399 21400 return pos({ 21401 type: 'custom-media', 21402 name: trim(m[1]), 21403 media: trim(m[2]) 21404 }); 21405 } 21406 /** 21407 * Parse paged media. 21408 */ 21409 21410 21411 function atpage() { 21412 const pos = position(); 21413 const m = match(/^@page */); 21414 21415 if (!m) { 21416 return; 21417 } 21418 21419 const sel = selector() || []; 21420 21421 if (!open()) { 21422 return error("@page missing '{'"); 21423 } 21424 21425 let decls = comments(); // declarations. 21426 21427 let decl; // eslint-disable-next-line no-cond-assign 21428 21429 while (decl = declaration()) { 21430 decls.push(decl); 21431 decls = decls.concat(comments()); 21432 } 21433 21434 if (!close()) { 21435 return error("@page missing '}'"); 21436 } 21437 21438 return pos({ 21439 type: 'page', 21440 selectors: sel, 21441 declarations: decls 21442 }); 21443 } 21444 /** 21445 * Parse document. 21446 */ 21447 21448 21449 function atdocument() { 21450 const pos = position(); 21451 const m = match(/^@([-\w]+)?document *([^{]+)/); 21452 21453 if (!m) { 21454 return; 21455 } 21456 21457 const vendor = trim(m[1]); 21458 const doc = trim(m[2]); 21459 21460 if (!open()) { 21461 return error("@document missing '{'"); 21462 } 21463 21464 const style = comments().concat(rules()); 21465 21466 if (!close()) { 21467 return error("@document missing '}'"); 21468 } 21469 21470 return pos({ 21471 type: 'document', 21472 document: doc, 21473 vendor, 21474 rules: style 21475 }); 21476 } 21477 /** 21478 * Parse font-face. 21479 */ 21480 21481 21482 function atfontface() { 21483 const pos = position(); 21484 const m = match(/^@font-face\s*/); 21485 21486 if (!m) { 21487 return; 21488 } 21489 21490 if (!open()) { 21491 return error("@font-face missing '{'"); 21492 } 21493 21494 let decls = comments(); // declarations. 21495 21496 let decl; // eslint-disable-next-line no-cond-assign 21497 21498 while (decl = declaration()) { 21499 decls.push(decl); 21500 decls = decls.concat(comments()); 21501 } 21502 21503 if (!close()) { 21504 return error("@font-face missing '}'"); 21505 } 21506 21507 return pos({ 21508 type: 'font-face', 21509 declarations: decls 21510 }); 21511 } 21512 /** 21513 * Parse import 21514 */ 21515 21516 21517 const atimport = _compileAtrule('import'); 21518 /** 21519 * Parse charset 21520 */ 21521 21522 21523 const atcharset = _compileAtrule('charset'); 21524 /** 21525 * Parse namespace 21526 */ 21527 21528 21529 const atnamespace = _compileAtrule('namespace'); 21530 /** 21531 * Parse non-block at-rules 21532 */ 21533 21534 21535 function _compileAtrule(name) { 21536 const re = new RegExp('^@' + name + '\\s*([^;]+);'); 21537 return function () { 21538 const pos = position(); 21539 const m = match(re); 21540 21541 if (!m) { 21542 return; 21543 } 21544 21545 const ret = { 21546 type: name 21547 }; 21548 ret[name] = m[1].trim(); 21549 return pos(ret); 21550 }; 21551 } 21552 /** 21553 * Parse at rule. 21554 */ 21555 21556 21557 function atrule() { 21558 if (css[0] !== '@') { 21559 return; 21560 } 21561 21562 return atkeyframes() || atmedia() || atcustommedia() || atsupports() || atimport() || atcharset() || atnamespace() || atdocument() || atpage() || athost() || atfontface(); 21563 } 21564 /** 21565 * Parse rule. 21566 */ 21567 21568 21569 function rule() { 21570 const pos = position(); 21571 const sel = selector(); 21572 21573 if (!sel) { 21574 return error('selector missing'); 21575 } 21576 21577 comments(); 21578 return pos({ 21579 type: 'rule', 21580 selectors: sel, 21581 declarations: declarations() 21582 }); 21583 } 21584 21585 return addParent(stylesheet()); 21586 } 21587 /** 21588 * Trim `str`. 21589 */ 21590 21591 function trim(str) { 21592 return str ? str.replace(/^\s+|\s+$/g, '') : ''; 21593 } 21594 /** 21595 * Adds non-enumerable parent node reference to each node. 21596 */ 21597 21598 21599 function addParent(obj, parent) { 21600 const isNode = obj && typeof obj.type === 'string'; 21601 const childParent = isNode ? obj : parent; 21602 21603 for (const k in obj) { 21604 const value = obj[k]; 21605 21606 if (Array.isArray(value)) { 21607 value.forEach(function (v) { 21608 addParent(v, childParent); 21609 }); 21610 } else if (value && typeof value === 'object') { 21611 addParent(value, childParent); 21612 } 21613 } 21614 21615 if (isNode) { 21616 Object.defineProperty(obj, 'parent', { 21617 configurable: true, 21618 writable: true, 21619 enumerable: false, 21620 value: parent || null 21621 }); 21622 } 21623 21624 return obj; 21625 } 21626 /* eslint-enable @wordpress/no-unused-vars-before-return */ 21627 21628 // EXTERNAL MODULE: ./node_modules/inherits/inherits_browser.js 21629 var inherits_browser = __webpack_require__(8575); 21630 var inherits_browser_default = /*#__PURE__*/__webpack_require__.n(inherits_browser); 21631 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/compiler.js 21632 // Adapted from https://github.com/reworkcss/css 21633 // because we needed to remove source map support. 21634 21635 /** 21636 * Expose `Compiler`. 21637 */ 21638 /* harmony default export */ var compiler = (Compiler); 21639 /** 21640 * Initialize a compiler. 21641 */ 21642 21643 function Compiler(opts) { 21644 this.options = opts || {}; 21645 } 21646 /** 21647 * Emit `str` 21648 */ 21649 21650 21651 Compiler.prototype.emit = function (str) { 21652 return str; 21653 }; 21654 /** 21655 * Visit `node`. 21656 */ 21657 21658 21659 Compiler.prototype.visit = function (node) { 21660 return this[node.type](node); 21661 }; 21662 /** 21663 * Map visit over array of `nodes`, optionally using a `delim` 21664 */ 21665 21666 21667 Compiler.prototype.mapVisit = function (nodes, delim) { 21668 let buf = ''; 21669 delim = delim || ''; 21670 21671 for (let i = 0, length = nodes.length; i < length; i++) { 21672 buf += this.visit(nodes[i]); 21673 21674 if (delim && i < length - 1) { 21675 buf += this.emit(delim); 21676 } 21677 } 21678 21679 return buf; 21680 }; 21681 21682 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/compress.js 21683 // Adapted from https://github.com/reworkcss/css 21684 // because we needed to remove source map support. 21685 21686 /** 21687 * External dependencies 21688 */ 21689 21690 /** 21691 * Internal dependencies 21692 */ 21693 21694 21695 /** 21696 * Expose compiler. 21697 */ 21698 21699 /* harmony default export */ var compress = (compress_Compiler); 21700 /** 21701 * Initialize a new `Compiler`. 21702 */ 21703 21704 function compress_Compiler(options) { 21705 compiler.call(this, options); 21706 } 21707 /** 21708 * Inherit from `Base.prototype`. 21709 */ 21710 21711 21712 inherits_browser_default()(compress_Compiler, compiler); 21713 /** 21714 * Compile `node`. 21715 */ 21716 21717 compress_Compiler.prototype.compile = function (node) { 21718 return node.stylesheet.rules.map(this.visit, this).join(''); 21719 }; 21720 /** 21721 * Visit comment node. 21722 */ 21723 21724 21725 compress_Compiler.prototype.comment = function (node) { 21726 return this.emit('', node.position); 21727 }; 21728 /** 21729 * Visit import node. 21730 */ 21731 21732 21733 compress_Compiler.prototype.import = function (node) { 21734 return this.emit('@import ' + node.import + ';', node.position); 21735 }; 21736 /** 21737 * Visit media node. 21738 */ 21739 21740 21741 compress_Compiler.prototype.media = function (node) { 21742 return this.emit('@media ' + node.media, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}'); 21743 }; 21744 /** 21745 * Visit document node. 21746 */ 21747 21748 21749 compress_Compiler.prototype.document = function (node) { 21750 const doc = '@' + (node.vendor || '') + 'document ' + node.document; 21751 return this.emit(doc, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}'); 21752 }; 21753 /** 21754 * Visit charset node. 21755 */ 21756 21757 21758 compress_Compiler.prototype.charset = function (node) { 21759 return this.emit('@charset ' + node.charset + ';', node.position); 21760 }; 21761 /** 21762 * Visit namespace node. 21763 */ 21764 21765 21766 compress_Compiler.prototype.namespace = function (node) { 21767 return this.emit('@namespace ' + node.namespace + ';', node.position); 21768 }; 21769 /** 21770 * Visit supports node. 21771 */ 21772 21773 21774 compress_Compiler.prototype.supports = function (node) { 21775 return this.emit('@supports ' + node.supports, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}'); 21776 }; 21777 /** 21778 * Visit keyframes node. 21779 */ 21780 21781 21782 compress_Compiler.prototype.keyframes = function (node) { 21783 return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position) + this.emit('{') + this.mapVisit(node.keyframes) + this.emit('}'); 21784 }; 21785 /** 21786 * Visit keyframe node. 21787 */ 21788 21789 21790 compress_Compiler.prototype.keyframe = function (node) { 21791 const decls = node.declarations; 21792 return this.emit(node.values.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}'); 21793 }; 21794 /** 21795 * Visit page node. 21796 */ 21797 21798 21799 compress_Compiler.prototype.page = function (node) { 21800 const sel = node.selectors.length ? node.selectors.join(', ') : ''; 21801 return this.emit('@page ' + sel, node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}'); 21802 }; 21803 /** 21804 * Visit font-face node. 21805 */ 21806 21807 21808 compress_Compiler.prototype['font-face'] = function (node) { 21809 return this.emit('@font-face', node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}'); 21810 }; 21811 /** 21812 * Visit host node. 21813 */ 21814 21815 21816 compress_Compiler.prototype.host = function (node) { 21817 return this.emit('@host', node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}'); 21818 }; 21819 /** 21820 * Visit custom-media node. 21821 */ 21822 21823 21824 compress_Compiler.prototype['custom-media'] = function (node) { 21825 return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position); 21826 }; 21827 /** 21828 * Visit rule node. 21829 */ 21830 21831 21832 compress_Compiler.prototype.rule = function (node) { 21833 const decls = node.declarations; 21834 21835 if (!decls.length) { 21836 return ''; 21837 } 21838 21839 return this.emit(node.selectors.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}'); 21840 }; 21841 /** 21842 * Visit declaration node. 21843 */ 21844 21845 21846 compress_Compiler.prototype.declaration = function (node) { 21847 return this.emit(node.property + ':' + node.value, node.position) + this.emit(';'); 21848 }; 21849 21850 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/identity.js 21851 /* eslint-disable @wordpress/no-unused-vars-before-return */ 21852 // Adapted from https://github.com/reworkcss/css 21853 // because we needed to remove source map support. 21854 21855 /** 21856 * External dependencies 21857 */ 21858 21859 /** 21860 * Internal dependencies 21861 */ 21862 21863 21864 /** 21865 * Expose compiler. 21866 */ 21867 21868 /* harmony default export */ var identity = (identity_Compiler); 21869 /** 21870 * Initialize a new `Compiler`. 21871 */ 21872 21873 function identity_Compiler(options) { 21874 options = options || {}; 21875 compiler.call(this, options); 21876 this.indentation = options.indent; 21877 } 21878 /** 21879 * Inherit from `Base.prototype`. 21880 */ 21881 21882 21883 inherits_browser_default()(identity_Compiler, compiler); 21884 /** 21885 * Compile `node`. 21886 */ 21887 21888 identity_Compiler.prototype.compile = function (node) { 21889 return this.stylesheet(node); 21890 }; 21891 /** 21892 * Visit stylesheet node. 21893 */ 21894 21895 21896 identity_Compiler.prototype.stylesheet = function (node) { 21897 return this.mapVisit(node.stylesheet.rules, '\n\n'); 21898 }; 21899 /** 21900 * Visit comment node. 21901 */ 21902 21903 21904 identity_Compiler.prototype.comment = function (node) { 21905 return this.emit(this.indent() + '/*' + node.comment + '*/', node.position); 21906 }; 21907 /** 21908 * Visit import node. 21909 */ 21910 21911 21912 identity_Compiler.prototype.import = function (node) { 21913 return this.emit('@import ' + node.import + ';', node.position); 21914 }; 21915 /** 21916 * Visit media node. 21917 */ 21918 21919 21920 identity_Compiler.prototype.media = function (node) { 21921 return this.emit('@media ' + node.media, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}'); 21922 }; 21923 /** 21924 * Visit document node. 21925 */ 21926 21927 21928 identity_Compiler.prototype.document = function (node) { 21929 const doc = '@' + (node.vendor || '') + 'document ' + node.document; 21930 return this.emit(doc, node.position) + this.emit(' ' + ' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}'); 21931 }; 21932 /** 21933 * Visit charset node. 21934 */ 21935 21936 21937 identity_Compiler.prototype.charset = function (node) { 21938 return this.emit('@charset ' + node.charset + ';', node.position); 21939 }; 21940 /** 21941 * Visit namespace node. 21942 */ 21943 21944 21945 identity_Compiler.prototype.namespace = function (node) { 21946 return this.emit('@namespace ' + node.namespace + ';', node.position); 21947 }; 21948 /** 21949 * Visit supports node. 21950 */ 21951 21952 21953 identity_Compiler.prototype.supports = function (node) { 21954 return this.emit('@supports ' + node.supports, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}'); 21955 }; 21956 /** 21957 * Visit keyframes node. 21958 */ 21959 21960 21961 identity_Compiler.prototype.keyframes = function (node) { 21962 return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.keyframes, '\n') + this.emit(this.indent(-1) + '}'); 21963 }; 21964 /** 21965 * Visit keyframe node. 21966 */ 21967 21968 21969 identity_Compiler.prototype.keyframe = function (node) { 21970 const decls = node.declarations; 21971 return this.emit(this.indent()) + this.emit(node.values.join(', '), node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(decls, '\n') + this.emit(this.indent(-1) + '\n' + this.indent() + '}\n'); 21972 }; 21973 /** 21974 * Visit page node. 21975 */ 21976 21977 21978 identity_Compiler.prototype.page = function (node) { 21979 const sel = node.selectors.length ? node.selectors.join(', ') + ' ' : ''; 21980 return this.emit('@page ' + sel, node.position) + this.emit('{\n') + this.emit(this.indent(1)) + this.mapVisit(node.declarations, '\n') + this.emit(this.indent(-1)) + this.emit('\n}'); 21981 }; 21982 /** 21983 * Visit font-face node. 21984 */ 21985 21986 21987 identity_Compiler.prototype['font-face'] = function (node) { 21988 return this.emit('@font-face ', node.position) + this.emit('{\n') + this.emit(this.indent(1)) + this.mapVisit(node.declarations, '\n') + this.emit(this.indent(-1)) + this.emit('\n}'); 21989 }; 21990 /** 21991 * Visit host node. 21992 */ 21993 21994 21995 identity_Compiler.prototype.host = function (node) { 21996 return this.emit('@host', node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}'); 21997 }; 21998 /** 21999 * Visit custom-media node. 22000 */ 22001 22002 22003 identity_Compiler.prototype['custom-media'] = function (node) { 22004 return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position); 22005 }; 22006 /** 22007 * Visit rule node. 22008 */ 22009 22010 22011 identity_Compiler.prototype.rule = function (node) { 22012 const indent = this.indent(); 22013 const decls = node.declarations; 22014 22015 if (!decls.length) { 22016 return ''; 22017 } 22018 22019 return this.emit(node.selectors.map(function (s) { 22020 return indent + s; 22021 }).join(',\n'), node.position) + this.emit(' {\n') + this.emit(this.indent(1)) + this.mapVisit(decls, '\n') + this.emit(this.indent(-1)) + this.emit('\n' + this.indent() + '}'); 22022 }; 22023 /** 22024 * Visit declaration node. 22025 */ 22026 22027 22028 identity_Compiler.prototype.declaration = function (node) { 22029 return this.emit(this.indent()) + this.emit(node.property + ': ' + node.value, node.position) + this.emit(';'); 22030 }; 22031 /** 22032 * Increase, decrease or return current indentation. 22033 */ 22034 22035 22036 identity_Compiler.prototype.indent = function (level) { 22037 this.level = this.level || 1; 22038 22039 if (null !== level) { 22040 this.level += level; 22041 return ''; 22042 } 22043 22044 return Array(this.level).join(this.indentation || ' '); 22045 }; 22046 /* eslint-enable @wordpress/no-unused-vars-before-return */ 22047 22048 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/index.js 22049 // Adapted from https://github.com/reworkcss/css 22050 // because we needed to remove source map support. 22051 22052 /** 22053 * Internal dependencies 22054 */ 22055 22056 22057 /** 22058 * Stringfy the given AST `node`. 22059 * 22060 * Options: 22061 * 22062 * - `compress` space-optimized output 22063 * - `sourcemap` return an object with `.code` and `.map` 22064 * 22065 * @param {Object} node 22066 * @param {Object} [options] 22067 * @return {string} 22068 */ 22069 22070 /* harmony default export */ function stringify(node, options) { 22071 options = options || {}; 22072 const compiler = options.compress ? new compress(options) : new identity(options); 22073 const code = compiler.compile(node); 22074 return code; 22075 } 22076 22077 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/traverse.js 22078 /** 22079 * External dependencies 22080 */ 22081 22082 /** 22083 * Internal dependencies 22084 */ 22085 22086 22087 22088 function traverseCSS(css, callback) { 22089 try { 22090 const parsed = parse(css); 22091 const updated = traverse_default().map(parsed, function (node) { 22092 if (!node) { 22093 return node; 22094 } 22095 22096 const updatedNode = callback(node); 22097 return this.update(updatedNode); 22098 }); 22099 return stringify(updated); 22100 } catch (err) { 22101 // eslint-disable-next-line no-console 22102 console.warn('Error while traversing the CSS: ' + err); 22103 return null; 22104 } 22105 } 22106 22107 /* harmony default export */ var transform_styles_traverse = (traverseCSS); 22108 22109 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/transforms/url-rewrite.js 22110 /** 22111 * Return `true` if the given path is http/https. 22112 * 22113 * @param {string} filePath path 22114 * 22115 * @return {boolean} is remote path. 22116 */ 22117 function isRemotePath(filePath) { 22118 return /^(?:https?:)?\/\//.test(filePath); 22119 } 22120 /** 22121 * Return `true` if the given filePath is an absolute url. 22122 * 22123 * @param {string} filePath path 22124 * 22125 * @return {boolean} is absolute path. 22126 */ 22127 22128 22129 function isAbsolutePath(filePath) { 22130 return /^\/(?!\/)/.test(filePath); 22131 } 22132 /** 22133 * Whether or not the url should be inluded. 22134 * 22135 * @param {Object} meta url meta info 22136 * 22137 * @return {boolean} is valid. 22138 */ 22139 22140 22141 function isValidURL(meta) { 22142 // Ignore hashes or data uris. 22143 if (meta.value.indexOf('data:') === 0 || meta.value.indexOf('#') === 0) { 22144 return false; 22145 } 22146 22147 if (isAbsolutePath(meta.value)) { 22148 return false; 22149 } // Do not handle the http/https urls if `includeRemote` is false. 22150 22151 22152 if (isRemotePath(meta.value)) { 22153 return false; 22154 } 22155 22156 return true; 22157 } 22158 /** 22159 * Get the absolute path of the url, relative to the basePath 22160 * 22161 * @param {string} str the url 22162 * @param {string} baseURL base URL 22163 * 22164 * @return {string} the full path to the file 22165 */ 22166 22167 22168 function getResourcePath(str, baseURL) { 22169 return new URL(str, baseURL).toString(); 22170 } 22171 /** 22172 * Process the single `url()` pattern 22173 * 22174 * @param {string} baseURL the base URL for relative URLs. 22175 * 22176 * @return {Promise} the Promise. 22177 */ 22178 22179 22180 function processURL(baseURL) { 22181 return meta => ({ ...meta, 22182 newUrl: 'url(' + meta.before + meta.quote + getResourcePath(meta.value, baseURL) + meta.quote + meta.after + ')' 22183 }); 22184 } 22185 /** 22186 * Get all `url()`s, and return the meta info 22187 * 22188 * @param {string} value decl.value. 22189 * 22190 * @return {Array} the urls. 22191 */ 22192 22193 22194 function getURLs(value) { 22195 const reg = /url\((\s*)(['"]?)(.+?)\2(\s*)\)/g; 22196 let match; 22197 const URLs = []; 22198 22199 while ((match = reg.exec(value)) !== null) { 22200 const meta = { 22201 source: match[0], 22202 before: match[1], 22203 quote: match[2], 22204 value: match[3], 22205 after: match[4] 22206 }; 22207 22208 if (isValidURL(meta)) { 22209 URLs.push(meta); 22210 } 22211 } 22212 22213 return URLs; 22214 } 22215 /** 22216 * Replace the raw value's `url()` segment to the new value 22217 * 22218 * @param {string} raw the raw value. 22219 * @param {Array} URLs the URLs to replace. 22220 * 22221 * @return {string} the new value. 22222 */ 22223 22224 22225 function replaceURLs(raw, URLs) { 22226 URLs.forEach(item => { 22227 raw = raw.replace(item.source, item.newUrl); 22228 }); 22229 return raw; 22230 } 22231 22232 const rewrite = rootURL => node => { 22233 if (node.type === 'declaration') { 22234 const updatedURLs = getURLs(node.value).map(processURL(rootURL)); 22235 return { ...node, 22236 value: replaceURLs(node.value, updatedURLs) 22237 }; 22238 } 22239 22240 return node; 22241 }; 22242 22243 /* harmony default export */ var url_rewrite = (rewrite); 22244 22245 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/transforms/wrap.js 22246 /** 22247 * @constant string IS_ROOT_TAG Regex to check if the selector is a root tag selector. 22248 */ 22249 const IS_ROOT_TAG = /^(body|html|:root).*$/; 22250 /** 22251 * Creates a callback to modify selectors so they only apply within a certain 22252 * namespace. 22253 * 22254 * @param {string} namespace Namespace to prefix selectors with. 22255 * @param {string[]} ignore Selectors to not prefix. 22256 * 22257 * @return {(node: Object) => Object} Callback to wrap selectors. 22258 */ 22259 22260 const wrap = function (namespace) { 22261 let ignore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; 22262 return node => { 22263 /** 22264 * Updates selector if necessary. 22265 * 22266 * @param {string} selector Selector to modify. 22267 * 22268 * @return {string} Updated selector. 22269 */ 22270 const updateSelector = selector => { 22271 if (ignore.includes(selector.trim())) { 22272 return selector; 22273 } // Anything other than a root tag is always prefixed. 22274 22275 22276 { 22277 if (!selector.match(IS_ROOT_TAG)) { 22278 return namespace + ' ' + selector; 22279 } 22280 } // HTML and Body elements cannot be contained within our container so lets extract their styles. 22281 22282 return selector.replace(/^(body|html|:root)/, namespace); 22283 }; 22284 22285 if (node.type === 'rule') { 22286 return { ...node, 22287 selectors: node.selectors.map(updateSelector) 22288 }; 22289 } 22290 22291 return node; 22292 }; 22293 }; 22294 22295 /* harmony default export */ var transforms_wrap = (wrap); 22296 22297 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/index.js 22298 /** 22299 * External dependencies 22300 */ 22301 22302 /** 22303 * WordPress dependencies 22304 */ 22305 22306 22307 /** 22308 * Internal dependencies 22309 */ 22310 22311 22312 22313 22314 /** 22315 * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed. 22316 * 22317 * @param {Array} styles CSS rules. 22318 * @param {string} wrapperClassName Wrapper Class Name. 22319 * @return {Array} converted rules. 22320 */ 22321 22322 const transform_styles_transformStyles = function (styles) { 22323 let wrapperClassName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 22324 return (0,external_lodash_namespaceObject.map)(styles, _ref => { 22325 let { 22326 css, 22327 baseURL 22328 } = _ref; 22329 const transforms = []; 22330 22331 if (wrapperClassName) { 22332 transforms.push(transforms_wrap(wrapperClassName)); 22333 } 22334 22335 if (baseURL) { 22336 transforms.push(url_rewrite(baseURL)); 22337 } 22338 22339 if (transforms.length) { 22340 return transform_styles_traverse(css, (0,external_wp_compose_namespaceObject.compose)(transforms)); 22341 } 22342 22343 return css; 22344 }); 22345 }; 22346 22347 /* harmony default export */ var transform_styles = (transform_styles_transformStyles); 22348 22349 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/editor-styles/index.js 22350 22351 22352 /** 22353 * External dependencies 22354 */ 22355 22356 22357 22358 /** 22359 * WordPress dependencies 22360 */ 22361 22362 22363 /** 22364 * Internal dependencies 22365 */ 22366 22367 22368 const EDITOR_STYLES_SELECTOR = '.editor-styles-wrapper'; 22369 k([names, a11y]); 22370 22371 function useDarkThemeBodyClassName(styles) { 22372 return (0,external_wp_element_namespaceObject.useCallback)(node => { 22373 if (!node) { 22374 return; 22375 } 22376 22377 const { 22378 ownerDocument 22379 } = node; 22380 const { 22381 defaultView, 22382 body 22383 } = ownerDocument; 22384 const canvas = ownerDocument.querySelector(EDITOR_STYLES_SELECTOR); 22385 let backgroundColor; 22386 22387 if (!canvas) { 22388 // The real .editor-styles-wrapper element might not exist in the 22389 // DOM, so calculate the background color by creating a fake 22390 // wrapper. 22391 const tempCanvas = ownerDocument.createElement('div'); 22392 tempCanvas.classList.add('editor-styles-wrapper'); 22393 body.appendChild(tempCanvas); 22394 backgroundColor = defaultView.getComputedStyle(tempCanvas, null).getPropertyValue('background-color'); 22395 body.removeChild(tempCanvas); 22396 } else { 22397 backgroundColor = defaultView.getComputedStyle(canvas, null).getPropertyValue('background-color'); 22398 } 22399 22400 const colordBackgroundColor = w(backgroundColor); // If background is transparent, it should be treated as light color. 22401 22402 if (colordBackgroundColor.luminance() > 0.5 || colordBackgroundColor.alpha() === 0) { 22403 body.classList.remove('is-dark-theme'); 22404 } else { 22405 body.classList.add('is-dark-theme'); 22406 } 22407 }, [styles]); 22408 } 22409 22410 function EditorStyles(_ref) { 22411 let { 22412 styles 22413 } = _ref; 22414 const transformedStyles = (0,external_wp_element_namespaceObject.useMemo)(() => transform_styles(styles, EDITOR_STYLES_SELECTOR), [styles]); 22415 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("style", { 22416 ref: useDarkThemeBodyClassName(styles) 22417 }), transformedStyles.map((css, index) => (0,external_wp_element_namespaceObject.createElement)("style", { 22418 key: index 22419 }, css))); 22420 } 22421 22422 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/auto.js 22423 22424 22425 /** 22426 * WordPress dependencies 22427 */ 22428 22429 22430 22431 22432 /** 22433 * Internal dependencies 22434 */ 22435 22436 22437 22438 22439 // This is used to avoid rendering the block list if the sizes change. 22440 22441 let MemoizedBlockList; 22442 const MAX_HEIGHT = 2000; 22443 22444 function AutoBlockPreview(_ref) { 22445 let { 22446 viewportWidth, 22447 __experimentalPadding, 22448 __experimentalMinHeight 22449 } = _ref; 22450 const [containerResizeListener, { 22451 width: containerWidth 22452 }] = (0,external_wp_compose_namespaceObject.useResizeObserver)(); 22453 const [contentResizeListener, { 22454 height: contentHeight 22455 }] = (0,external_wp_compose_namespaceObject.useResizeObserver)(); 22456 const { 22457 styles, 22458 assets 22459 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 22460 const settings = select(store).getSettings(); 22461 return { 22462 styles: settings.styles, 22463 assets: settings.__unstableResolvedAssets 22464 }; 22465 }, []); // Avoid scrollbars for pattern previews. 22466 22467 const editorStyles = (0,external_wp_element_namespaceObject.useMemo)(() => { 22468 if (styles) { 22469 return [...styles, { 22470 css: 'body{height:auto;overflow:hidden;}', 22471 __unstableType: 'presets' 22472 }]; 22473 } 22474 22475 return styles; 22476 }, [styles]); // Initialize on render instead of module top level, to avoid circular dependency issues. 22477 22478 MemoizedBlockList = MemoizedBlockList || (0,external_wp_compose_namespaceObject.pure)(BlockList); 22479 const scale = containerWidth / viewportWidth; 22480 return (0,external_wp_element_namespaceObject.createElement)("div", { 22481 className: "block-editor-block-preview__container" 22482 }, containerResizeListener, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Disabled, { 22483 className: "block-editor-block-preview__content", 22484 style: { 22485 transform: `scale($scale})`, 22486 height: contentHeight * scale, 22487 maxHeight: contentHeight > MAX_HEIGHT ? MAX_HEIGHT * scale : undefined, 22488 minHeight: __experimentalMinHeight 22489 } 22490 }, (0,external_wp_element_namespaceObject.createElement)(iframe, { 22491 head: (0,external_wp_element_namespaceObject.createElement)(EditorStyles, { 22492 styles: editorStyles 22493 }), 22494 assets: assets, 22495 contentRef: (0,external_wp_compose_namespaceObject.useRefEffect)(bodyElement => { 22496 const { 22497 ownerDocument: { 22498 documentElement 22499 } 22500 } = bodyElement; 22501 documentElement.classList.add('block-editor-block-preview__content-iframe'); 22502 documentElement.style.position = 'absolute'; 22503 documentElement.style.width = '100%'; 22504 bodyElement.style.padding = __experimentalPadding + 'px'; // necessary for contentResizeListener to work. 22505 22506 bodyElement.style.position = 'relative'; 22507 }, []), 22508 "aria-hidden": true, 22509 tabIndex: -1, 22510 style: { 22511 position: 'absolute', 22512 width: viewportWidth, 22513 height: contentHeight, 22514 pointerEvents: 'none', 22515 // This is a catch-all max-height for patterns. 22516 // See: https://github.com/WordPress/gutenberg/pull/38175. 22517 maxHeight: MAX_HEIGHT, 22518 minHeight: scale < 1 && __experimentalMinHeight ? __experimentalMinHeight / scale : __experimentalMinHeight 22519 } 22520 }, contentResizeListener, (0,external_wp_element_namespaceObject.createElement)(MemoizedBlockList, { 22521 renderAppender: false 22522 })))); 22523 } 22524 22525 /* harmony default export */ var auto = (AutoBlockPreview); 22526 22527 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/index.js 22528 22529 22530 /** 22531 * External dependencies 22532 */ 22533 22534 22535 /** 22536 * WordPress dependencies 22537 */ 22538 22539 22540 22541 22542 /** 22543 * Internal dependencies 22544 */ 22545 22546 22547 22548 22549 22550 22551 function BlockPreview(_ref) { 22552 let { 22553 blocks, 22554 __experimentalPadding = 0, 22555 viewportWidth = 1200, 22556 __experimentalLive = false, 22557 __experimentalOnClick, 22558 __experimentalMinHeight 22559 } = _ref; 22560 const originalSettings = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings(), []); 22561 const settings = (0,external_wp_element_namespaceObject.useMemo)(() => { 22562 const _settings = { ...originalSettings 22563 }; 22564 _settings.__experimentalBlockPatterns = []; 22565 return _settings; 22566 }, [originalSettings]); 22567 const renderedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_lodash_namespaceObject.castArray)(blocks), [blocks]); 22568 22569 if (!blocks || blocks.length === 0) { 22570 return null; 22571 } 22572 22573 return (0,external_wp_element_namespaceObject.createElement)(provider, { 22574 value: renderedBlocks, 22575 settings: settings 22576 }, __experimentalLive ? (0,external_wp_element_namespaceObject.createElement)(LiveBlockPreview, { 22577 onClick: __experimentalOnClick 22578 }) : (0,external_wp_element_namespaceObject.createElement)(auto, { 22579 viewportWidth: viewportWidth, 22580 __experimentalPadding: __experimentalPadding, 22581 __experimentalMinHeight: __experimentalMinHeight 22582 })); 22583 } 22584 /** 22585 * BlockPreview renders a preview of a block or array of blocks. 22586 * 22587 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md 22588 * 22589 * @param {Object} preview options for how the preview should be shown 22590 * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed. 22591 * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700. 22592 * 22593 * @return {WPComponent} The component to be rendered. 22594 */ 22595 22596 /* harmony default export */ var block_preview = ((0,external_wp_element_namespaceObject.memo)(BlockPreview)); 22597 /** 22598 * This hook is used to lightly mark an element as a block preview wrapper 22599 * element. Call this hook and pass the returned props to the element to mark as 22600 * a block preview wrapper, automatically rendering inner blocks as children. If 22601 * you define a ref for the element, it is important to pass the ref to this 22602 * hook, which the hook in turn will pass to the component through the props it 22603 * returns. Optionally, you can also pass any other props through this hook, and 22604 * they will be merged and returned. 22605 * 22606 * @param {Object} options Preview options. 22607 * @param {WPBlock[]} options.blocks Block objects. 22608 * @param {Object} options.props Optional. Props to pass to the element. Must contain 22609 * the ref if one is defined. 22610 * @param {Object} options.__experimentalLayout Layout settings to be used in the preview. 22611 * 22612 */ 22613 22614 function useBlockPreview(_ref2) { 22615 let { 22616 blocks, 22617 props = {}, 22618 __experimentalLayout 22619 } = _ref2; 22620 const originalSettings = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings(), []); 22621 const disabledRef = (0,external_wp_compose_namespaceObject.__experimentalUseDisabled)(); 22622 const ref = (0,external_wp_compose_namespaceObject.useMergeRefs)([props.ref, disabledRef]); 22623 const settings = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...originalSettings, 22624 __experimentalBlockPatterns: [] 22625 }), [originalSettings]); 22626 const renderedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_lodash_namespaceObject.castArray)(blocks), [blocks]); 22627 const children = (0,external_wp_element_namespaceObject.createElement)(provider, { 22628 value: renderedBlocks, 22629 settings: settings 22630 }, (0,external_wp_element_namespaceObject.createElement)(BlockListItems, { 22631 renderAppender: false, 22632 __experimentalLayout: __experimentalLayout 22633 })); 22634 return { ...props, 22635 ref, 22636 className: classnames_default()(props.className, 'block-editor-block-preview__live-content', 'components-disabled'), 22637 children: blocks !== null && blocks !== void 0 && blocks.length ? children : null 22638 }; 22639 } 22640 22641 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/preview-panel.js 22642 22643 22644 /** 22645 * WordPress dependencies 22646 */ 22647 22648 22649 /** 22650 * Internal dependencies 22651 */ 22652 22653 22654 22655 22656 function InserterPreviewPanel(_ref) { 22657 var _hoveredItemBlockType, _hoveredItemBlockType2; 22658 22659 let { 22660 item 22661 } = _ref; 22662 const { 22663 name, 22664 title, 22665 icon, 22666 description, 22667 initialAttributes 22668 } = item; 22669 const hoveredItemBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name); 22670 const isReusable = (0,external_wp_blocks_namespaceObject.isReusableBlock)(item); 22671 return (0,external_wp_element_namespaceObject.createElement)("div", { 22672 className: "block-editor-inserter__preview-container" 22673 }, (0,external_wp_element_namespaceObject.createElement)("div", { 22674 className: "block-editor-inserter__preview" 22675 }, isReusable || hoveredItemBlockType !== null && hoveredItemBlockType !== void 0 && hoveredItemBlockType.example ? (0,external_wp_element_namespaceObject.createElement)("div", { 22676 className: "block-editor-inserter__preview-content" 22677 }, (0,external_wp_element_namespaceObject.createElement)(block_preview, { 22678 __experimentalPadding: 16, 22679 viewportWidth: (_hoveredItemBlockType = (_hoveredItemBlockType2 = hoveredItemBlockType.example) === null || _hoveredItemBlockType2 === void 0 ? void 0 : _hoveredItemBlockType2.viewportWidth) !== null && _hoveredItemBlockType !== void 0 ? _hoveredItemBlockType : 500, 22680 blocks: hoveredItemBlockType.example ? (0,external_wp_blocks_namespaceObject.getBlockFromExample)(item.name, { 22681 attributes: { ...hoveredItemBlockType.example.attributes, 22682 ...initialAttributes 22683 }, 22684 innerBlocks: hoveredItemBlockType.example.innerBlocks 22685 }) : (0,external_wp_blocks_namespaceObject.createBlock)(name, initialAttributes) 22686 })) : (0,external_wp_element_namespaceObject.createElement)("div", { 22687 className: "block-editor-inserter__preview-content-missing" 22688 }, (0,external_wp_i18n_namespaceObject.__)('No Preview Available.'))), !isReusable && (0,external_wp_element_namespaceObject.createElement)(block_card, { 22689 title: title, 22690 icon: icon, 22691 description: description 22692 })); 22693 } 22694 22695 /* harmony default export */ var preview_panel = (InserterPreviewPanel); 22696 22697 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/context.js 22698 /** 22699 * WordPress dependencies 22700 */ 22701 22702 const InserterListboxContext = (0,external_wp_element_namespaceObject.createContext)(); 22703 /* harmony default export */ var context = (InserterListboxContext); 22704 22705 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/item.js 22706 22707 22708 22709 /** 22710 * WordPress dependencies 22711 */ 22712 22713 22714 /** 22715 * Internal dependencies 22716 */ 22717 22718 22719 22720 function InserterListboxItem(_ref, ref) { 22721 let { 22722 isFirst, 22723 as: Component, 22724 children, 22725 ...props 22726 } = _ref; 22727 const state = (0,external_wp_element_namespaceObject.useContext)(context); 22728 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({ 22729 ref: ref, 22730 state: state, 22731 role: "option" // Use the CompositeItem `focusable` prop over Button's 22732 // isFocusable. The latter was shown to cause an issue 22733 // with tab order in the inserter list. 22734 , 22735 focusable: true 22736 }, props), htmlProps => { 22737 const propsWithTabIndex = { ...htmlProps, 22738 tabIndex: isFirst ? 0 : htmlProps.tabIndex 22739 }; 22740 22741 if (Component) { 22742 return (0,external_wp_element_namespaceObject.createElement)(Component, propsWithTabIndex, children); 22743 } 22744 22745 if (typeof children === 'function') { 22746 return children(propsWithTabIndex); 22747 } 22748 22749 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, propsWithTabIndex, children); 22750 }); 22751 } 22752 22753 /* harmony default export */ var inserter_listbox_item = ((0,external_wp_element_namespaceObject.forwardRef)(InserterListboxItem)); 22754 22755 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/drag-handle.js 22756 22757 22758 /** 22759 * WordPress dependencies 22760 */ 22761 22762 const dragHandle = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 22763 width: "24", 22764 height: "24", 22765 xmlns: "http://www.w3.org/2000/svg", 22766 viewBox: "0 0 24 24" 22767 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 22768 d: "M8 7h2V5H8v2zm0 6h2v-2H8v2zm0 6h2v-2H8v2zm6-14v2h2V5h-2zm0 8h2v-2h-2v2zm0 6h2v-2h-2v2z" 22769 })); 22770 /* harmony default export */ var drag_handle = (dragHandle); 22771 22772 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/draggable-chip.js 22773 22774 22775 /** 22776 * WordPress dependencies 22777 */ 22778 22779 22780 22781 /** 22782 * Internal dependencies 22783 */ 22784 22785 22786 function BlockDraggableChip(_ref) { 22787 let { 22788 count, 22789 icon 22790 } = _ref; 22791 return (0,external_wp_element_namespaceObject.createElement)("div", { 22792 className: "block-editor-block-draggable-chip-wrapper" 22793 }, (0,external_wp_element_namespaceObject.createElement)("div", { 22794 className: "block-editor-block-draggable-chip" 22795 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, { 22796 justify: "center", 22797 className: "block-editor-block-draggable-chip__content" 22798 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, icon ? (0,external_wp_element_namespaceObject.createElement)(block_icon, { 22799 icon: icon 22800 }) : (0,external_wp_i18n_namespaceObject.sprintf)( 22801 /* translators: %d: Number of blocks. */ 22802 (0,external_wp_i18n_namespaceObject._n)('%d block', '%d blocks', count), count)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(block_icon, { 22803 icon: drag_handle 22804 }))))); 22805 } 22806 22807 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-draggable-blocks/index.js 22808 22809 22810 /** 22811 * WordPress dependencies 22812 */ 22813 22814 /** 22815 * Internal dependencies 22816 */ 22817 22818 22819 22820 const InserterDraggableBlocks = _ref => { 22821 let { 22822 isEnabled, 22823 blocks, 22824 icon, 22825 children 22826 } = _ref; 22827 const transferData = { 22828 type: 'inserter', 22829 blocks 22830 }; 22831 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Draggable, { 22832 __experimentalTransferDataType: "wp-blocks", 22833 transferData: transferData, 22834 __experimentalDragComponent: (0,external_wp_element_namespaceObject.createElement)(BlockDraggableChip, { 22835 count: blocks.length, 22836 icon: icon 22837 }) 22838 }, _ref2 => { 22839 let { 22840 onDraggableStart, 22841 onDraggableEnd 22842 } = _ref2; 22843 return children({ 22844 draggable: isEnabled, 22845 onDragStart: isEnabled ? onDraggableStart : undefined, 22846 onDragEnd: isEnabled ? onDraggableEnd : undefined 22847 }); 22848 }); 22849 }; 22850 22851 /* harmony default export */ var inserter_draggable_blocks = (InserterDraggableBlocks); 22852 22853 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-list-item/index.js 22854 22855 22856 22857 /** 22858 * External dependencies 22859 */ 22860 22861 /** 22862 * WordPress dependencies 22863 */ 22864 22865 22866 22867 22868 /** 22869 * Internal dependencies 22870 */ 22871 22872 22873 22874 22875 /** 22876 * Return true if platform is MacOS. 22877 * 22878 * @param {Object} _window window object by default; used for DI testing. 22879 * 22880 * @return {boolean} True if MacOS; false otherwise. 22881 */ 22882 22883 function isAppleOS() { 22884 let _window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window; 22885 22886 const { 22887 platform 22888 } = _window.navigator; 22889 return platform.indexOf('Mac') !== -1 || ['iPad', 'iPhone'].includes(platform); 22890 } 22891 22892 function InserterListItem(_ref) { 22893 let { 22894 className, 22895 isFirst, 22896 item, 22897 onSelect, 22898 onHover, 22899 isDraggable, 22900 ...props 22901 } = _ref; 22902 const isDragging = (0,external_wp_element_namespaceObject.useRef)(false); 22903 const itemIconStyle = item.icon ? { 22904 backgroundColor: item.icon.background, 22905 color: item.icon.foreground 22906 } : {}; 22907 const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => { 22908 return [(0,external_wp_blocks_namespaceObject.createBlock)(item.name, item.initialAttributes, (0,external_wp_blocks_namespaceObject.createBlocksFromInnerBlocksTemplate)(item.innerBlocks))]; 22909 }, [item.name, item.initialAttributes, item.initialAttributes]); 22910 return (0,external_wp_element_namespaceObject.createElement)(inserter_draggable_blocks, { 22911 isEnabled: isDraggable && !item.disabled, 22912 blocks: blocks, 22913 icon: item.icon 22914 }, _ref2 => { 22915 let { 22916 draggable, 22917 onDragStart, 22918 onDragEnd 22919 } = _ref2; 22920 return (0,external_wp_element_namespaceObject.createElement)("div", { 22921 className: "block-editor-block-types-list__list-item", 22922 draggable: draggable, 22923 onDragStart: event => { 22924 isDragging.current = true; 22925 22926 if (onDragStart) { 22927 onHover(null); 22928 onDragStart(event); 22929 } 22930 }, 22931 onDragEnd: event => { 22932 isDragging.current = false; 22933 22934 if (onDragEnd) { 22935 onDragEnd(event); 22936 } 22937 } 22938 }, (0,external_wp_element_namespaceObject.createElement)(inserter_listbox_item, _extends({ 22939 isFirst: isFirst, 22940 className: classnames_default()('block-editor-block-types-list__item', className), 22941 disabled: item.isDisabled, 22942 onClick: event => { 22943 event.preventDefault(); 22944 onSelect(item, isAppleOS() ? event.metaKey : event.ctrlKey); 22945 onHover(null); 22946 }, 22947 onKeyDown: event => { 22948 const { 22949 keyCode 22950 } = event; 22951 22952 if (keyCode === external_wp_keycodes_namespaceObject.ENTER) { 22953 event.preventDefault(); 22954 onSelect(item, isAppleOS() ? event.metaKey : event.ctrlKey); 22955 onHover(null); 22956 } 22957 }, 22958 onFocus: () => { 22959 if (isDragging.current) { 22960 return; 22961 } 22962 22963 onHover(item); 22964 }, 22965 onMouseEnter: () => { 22966 if (isDragging.current) { 22967 return; 22968 } 22969 22970 onHover(item); 22971 }, 22972 onMouseLeave: () => onHover(null), 22973 onBlur: () => onHover(null) 22974 }, props), (0,external_wp_element_namespaceObject.createElement)("span", { 22975 className: "block-editor-block-types-list__item-icon", 22976 style: itemIconStyle 22977 }, (0,external_wp_element_namespaceObject.createElement)(block_icon, { 22978 icon: item.icon, 22979 showColors: true 22980 })), (0,external_wp_element_namespaceObject.createElement)("span", { 22981 className: "block-editor-block-types-list__item-title" 22982 }, item.title))); 22983 }); 22984 } 22985 22986 /* harmony default export */ var inserter_list_item = ((0,external_wp_element_namespaceObject.memo)(InserterListItem)); 22987 22988 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/group.js 22989 22990 22991 22992 /** 22993 * WordPress dependencies 22994 */ 22995 22996 22997 22998 22999 function InserterListboxGroup(props, ref) { 23000 const [shouldSpeak, setShouldSpeak] = (0,external_wp_element_namespaceObject.useState)(false); 23001 (0,external_wp_element_namespaceObject.useEffect)(() => { 23002 if (shouldSpeak) { 23003 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to move through blocks')); 23004 } 23005 }, [shouldSpeak]); 23006 return (0,external_wp_element_namespaceObject.createElement)("div", _extends({ 23007 ref: ref, 23008 role: "listbox", 23009 "aria-orientation": "horizontal", 23010 onFocus: () => { 23011 setShouldSpeak(true); 23012 }, 23013 onBlur: event => { 23014 const focusingOutsideGroup = !event.currentTarget.contains(event.relatedTarget); 23015 23016 if (focusingOutsideGroup) { 23017 setShouldSpeak(false); 23018 } 23019 } 23020 }, props)); 23021 } 23022 23023 /* harmony default export */ var group = ((0,external_wp_element_namespaceObject.forwardRef)(InserterListboxGroup)); 23024 23025 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/row.js 23026 23027 23028 23029 /** 23030 * WordPress dependencies 23031 */ 23032 23033 23034 /** 23035 * Internal dependencies 23036 */ 23037 23038 23039 23040 function InserterListboxRow(props, ref) { 23041 const state = (0,external_wp_element_namespaceObject.useContext)(context); 23042 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeGroup, _extends({ 23043 state: state, 23044 role: "presentation", 23045 ref: ref 23046 }, props)); 23047 } 23048 23049 /* harmony default export */ var inserter_listbox_row = ((0,external_wp_element_namespaceObject.forwardRef)(InserterListboxRow)); 23050 23051 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-types-list/index.js 23052 23053 23054 /** 23055 * WordPress dependencies 23056 */ 23057 23058 /** 23059 * Internal dependencies 23060 */ 23061 23062 23063 23064 23065 function chunk(array, size) { 23066 const chunks = []; 23067 23068 for (let i = 0, j = array.length; i < j; i += size) { 23069 chunks.push(array.slice(i, i + size)); 23070 } 23071 23072 return chunks; 23073 } 23074 23075 function BlockTypesList(_ref) { 23076 let { 23077 items = [], 23078 onSelect, 23079 onHover = () => {}, 23080 children, 23081 label, 23082 isDraggable = true 23083 } = _ref; 23084 return (0,external_wp_element_namespaceObject.createElement)(group, { 23085 className: "block-editor-block-types-list", 23086 "aria-label": label 23087 }, chunk(items, 3).map((row, i) => (0,external_wp_element_namespaceObject.createElement)(inserter_listbox_row, { 23088 key: i 23089 }, row.map((item, j) => (0,external_wp_element_namespaceObject.createElement)(inserter_list_item, { 23090 key: item.id, 23091 item: item, 23092 className: (0,external_wp_blocks_namespaceObject.getBlockMenuDefaultClassName)(item.id), 23093 onSelect: onSelect, 23094 onHover: onHover, 23095 isDraggable: isDraggable, 23096 isFirst: i === 0 && j === 0 23097 })))), children); 23098 } 23099 23100 /* harmony default export */ var block_types_list = (BlockTypesList); 23101 23102 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/panel.js 23103 23104 23105 /** 23106 * WordPress dependencies 23107 */ 23108 23109 23110 function InserterPanel(_ref) { 23111 let { 23112 title, 23113 icon, 23114 children 23115 } = _ref; 23116 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", { 23117 className: "block-editor-inserter__panel-header" 23118 }, (0,external_wp_element_namespaceObject.createElement)("h2", { 23119 className: "block-editor-inserter__panel-title" 23120 }, title), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, { 23121 icon: icon 23122 })), (0,external_wp_element_namespaceObject.createElement)("div", { 23123 className: "block-editor-inserter__panel-content" 23124 }, children)); 23125 } 23126 23127 /* harmony default export */ var panel = (InserterPanel); 23128 23129 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/hooks/use-block-types-state.js 23130 /** 23131 * WordPress dependencies 23132 */ 23133 23134 23135 23136 /** 23137 * Internal dependencies 23138 */ 23139 23140 23141 /** 23142 * Retrieves the block types inserter state. 23143 * 23144 * @param {string=} rootClientId Insertion's root client ID. 23145 * @param {Function} onInsert function called when inserter a list of blocks. 23146 * @return {Array} Returns the block types state. (block types, categories, collections, onSelect handler) 23147 */ 23148 23149 const useBlockTypesState = (rootClientId, onInsert) => { 23150 const { 23151 categories, 23152 collections, 23153 items 23154 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 23155 const { 23156 getInserterItems 23157 } = select(store); 23158 const { 23159 getCategories, 23160 getCollections 23161 } = select(external_wp_blocks_namespaceObject.store); 23162 return { 23163 categories: getCategories(), 23164 collections: getCollections(), 23165 items: getInserterItems(rootClientId) 23166 }; 23167 }, [rootClientId]); 23168 const onSelectItem = (0,external_wp_element_namespaceObject.useCallback)((_ref, shouldFocusBlock) => { 23169 let { 23170 name, 23171 initialAttributes, 23172 innerBlocks 23173 } = _ref; 23174 const insertedBlock = (0,external_wp_blocks_namespaceObject.createBlock)(name, initialAttributes, (0,external_wp_blocks_namespaceObject.createBlocksFromInnerBlocksTemplate)(innerBlocks)); 23175 onInsert(insertedBlock, undefined, shouldFocusBlock); 23176 }, [onInsert]); 23177 return [items, categories, collections, onSelectItem]; 23178 }; 23179 23180 /* harmony default export */ var use_block_types_state = (useBlockTypesState); 23181 23182 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/index.js 23183 23184 23185 /** 23186 * WordPress dependencies 23187 */ 23188 23189 /** 23190 * Internal dependencies 23191 */ 23192 23193 23194 23195 23196 23197 23198 function InserterListbox(_ref) { 23199 let { 23200 children 23201 } = _ref; 23202 const compositeState = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)({ 23203 shift: true, 23204 wrap: 'horizontal' 23205 }); 23206 return (0,external_wp_element_namespaceObject.createElement)(context.Provider, { 23207 value: compositeState 23208 }, children); 23209 } 23210 23211 /* harmony default export */ var inserter_listbox = (InserterListbox); 23212 23213 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-types-tab.js 23214 23215 23216 /** 23217 * External dependencies 23218 */ 23219 23220 /** 23221 * WordPress dependencies 23222 */ 23223 23224 23225 23226 23227 /** 23228 * Internal dependencies 23229 */ 23230 23231 23232 23233 23234 23235 23236 const getBlockNamespace = item => item.name.split('/')[0]; 23237 23238 const MAX_SUGGESTED_ITEMS = 6; 23239 /** 23240 * Shared reference to an empty array for cases where it is important to avoid 23241 * returning a new array reference on every invocation and rerendering the component. 23242 * 23243 * @type {Array} 23244 */ 23245 23246 const block_types_tab_EMPTY_ARRAY = []; 23247 function BlockTypesTab(_ref) { 23248 let { 23249 rootClientId, 23250 onInsert, 23251 onHover, 23252 showMostUsedBlocks 23253 } = _ref; 23254 const [items, categories, collections, onSelectItem] = use_block_types_state(rootClientId, onInsert); 23255 const suggestedItems = (0,external_wp_element_namespaceObject.useMemo)(() => { 23256 return (0,external_lodash_namespaceObject.orderBy)(items, ['frecency'], ['desc']).slice(0, MAX_SUGGESTED_ITEMS); 23257 }, [items]); 23258 const uncategorizedItems = (0,external_wp_element_namespaceObject.useMemo)(() => { 23259 return items.filter(item => !item.category); 23260 }, [items]); 23261 const itemsPerCategory = (0,external_wp_element_namespaceObject.useMemo)(() => { 23262 return (0,external_lodash_namespaceObject.flow)(itemList => itemList.filter(item => item.category && item.category !== 'reusable'), itemList => (0,external_lodash_namespaceObject.groupBy)(itemList, 'category'))(items); 23263 }, [items]); 23264 const itemsPerCollection = (0,external_wp_element_namespaceObject.useMemo)(() => { 23265 // Create a new Object to avoid mutating collection. 23266 const result = { ...collections 23267 }; 23268 Object.keys(collections).forEach(namespace => { 23269 result[namespace] = items.filter(item => getBlockNamespace(item) === namespace); 23270 23271 if (result[namespace].length === 0) { 23272 delete result[namespace]; 23273 } 23274 }); 23275 return result; 23276 }, [items, collections]); // Hide block preview on unmount. 23277 23278 (0,external_wp_element_namespaceObject.useEffect)(() => () => onHover(null), []); 23279 /** 23280 * The inserter contains a big number of blocks and opening it is a costful operation. 23281 * The rendering is the most costful part of it, in order to improve the responsiveness 23282 * of the "opening" action, these lazy lists allow us to render the inserter category per category, 23283 * once all the categories are rendered, we start rendering the collections and the uncategorized block types. 23284 */ 23285 23286 const currentlyRenderedCategories = (0,external_wp_compose_namespaceObject.useAsyncList)(categories); 23287 const didRenderAllCategories = categories.length === currentlyRenderedCategories.length; // Async List requires an array. 23288 23289 const collectionEntries = (0,external_wp_element_namespaceObject.useMemo)(() => { 23290 return Object.entries(collections); 23291 }, [collections]); 23292 const currentlyRenderedCollections = (0,external_wp_compose_namespaceObject.useAsyncList)(didRenderAllCategories ? collectionEntries : block_types_tab_EMPTY_ARRAY); 23293 return (0,external_wp_element_namespaceObject.createElement)(inserter_listbox, null, (0,external_wp_element_namespaceObject.createElement)("div", null, showMostUsedBlocks && !!suggestedItems.length && (0,external_wp_element_namespaceObject.createElement)(panel, { 23294 title: (0,external_wp_i18n_namespaceObject._x)('Most used', 'blocks') 23295 }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, { 23296 items: suggestedItems, 23297 onSelect: onSelectItem, 23298 onHover: onHover, 23299 label: (0,external_wp_i18n_namespaceObject._x)('Most used', 'blocks') 23300 })), (0,external_lodash_namespaceObject.map)(currentlyRenderedCategories, category => { 23301 const categoryItems = itemsPerCategory[category.slug]; 23302 23303 if (!categoryItems || !categoryItems.length) { 23304 return null; 23305 } 23306 23307 return (0,external_wp_element_namespaceObject.createElement)(panel, { 23308 key: category.slug, 23309 title: category.title, 23310 icon: category.icon 23311 }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, { 23312 items: categoryItems, 23313 onSelect: onSelectItem, 23314 onHover: onHover, 23315 label: category.title 23316 })); 23317 }), didRenderAllCategories && uncategorizedItems.length > 0 && (0,external_wp_element_namespaceObject.createElement)(panel, { 23318 className: "block-editor-inserter__uncategorized-blocks-panel", 23319 title: (0,external_wp_i18n_namespaceObject.__)('Uncategorized') 23320 }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, { 23321 items: uncategorizedItems, 23322 onSelect: onSelectItem, 23323 onHover: onHover, 23324 label: (0,external_wp_i18n_namespaceObject.__)('Uncategorized') 23325 })), (0,external_lodash_namespaceObject.map)(currentlyRenderedCollections, _ref2 => { 23326 let [namespace, collection] = _ref2; 23327 const collectionItems = itemsPerCollection[namespace]; 23328 23329 if (!collectionItems || !collectionItems.length) { 23330 return null; 23331 } 23332 23333 return (0,external_wp_element_namespaceObject.createElement)(panel, { 23334 key: namespace, 23335 title: collection.title, 23336 icon: collection.icon 23337 }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, { 23338 items: collectionItems, 23339 onSelect: onSelectItem, 23340 onHover: onHover, 23341 label: collection.title 23342 })); 23343 }))); 23344 } 23345 /* harmony default export */ var block_types_tab = (BlockTypesTab); 23346 23347 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/pattern-panel.js 23348 23349 23350 /** 23351 * External dependencies 23352 */ 23353 23354 /** 23355 * WordPress dependencies 23356 */ 23357 23358 23359 23360 23361 23362 function PatternInserterPanel(_ref) { 23363 let { 23364 selectedCategory, 23365 patternCategories, 23366 onClickCategory, 23367 openPatternExplorer 23368 } = _ref; 23369 const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); 23370 23371 const categoryOptions = () => { 23372 const options = []; 23373 patternCategories.map(patternCategory => { 23374 return options.push({ 23375 value: patternCategory.name, 23376 label: patternCategory.label 23377 }); 23378 }); 23379 return options; 23380 }; 23381 23382 const onChangeSelect = selected => { 23383 onClickCategory(patternCategories.find(patternCategory => selected === patternCategory.name)); 23384 }; 23385 23386 const className = classnames_default()('block-editor-inserter__panel-header', 'block-editor-inserter__panel-header-patterns'); // In iOS-based mobile devices, the onBlur will fire when selecting an option 23387 // from a Select element. To prevent closing the useDialog on iOS devices, we 23388 // stop propagating the onBlur event if there is no relatedTarget, which means 23389 // that the user most likely did not click on an element within the editor canvas. 23390 23391 const onBlur = event => { 23392 if (!(event !== null && event !== void 0 && event.relatedTarget)) { 23393 event.stopPropagation(); 23394 } 23395 }; 23396 23397 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, { 23398 justify: "space-between", 23399 align: "start", 23400 gap: "4", 23401 className: className 23402 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, { 23403 isBlock: true 23404 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, { 23405 className: "block-editor-inserter__panel-dropdown", 23406 label: (0,external_wp_i18n_namespaceObject.__)('Filter patterns'), 23407 hideLabelFromVision: true, 23408 value: selectedCategory.name, 23409 onChange: onChangeSelect, 23410 onBlur: onBlur, 23411 options: categoryOptions() 23412 })), !isMobile && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 23413 variant: "secondary", 23414 className: "block-editor-inserter__patterns-explorer-expand", 23415 label: (0,external_wp_i18n_namespaceObject.__)('Explore all patterns'), 23416 onClick: () => openPatternExplorer() 23417 }, (0,external_wp_i18n_namespaceObject._x)('Explore', 'Label for showing all block patterns')))); 23418 } 23419 23420 /* harmony default export */ var pattern_panel = (PatternInserterPanel); 23421 23422 ;// CONCATENATED MODULE: external ["wp","notices"] 23423 var external_wp_notices_namespaceObject = window["wp"]["notices"]; 23424 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/hooks/use-patterns-state.js 23425 /** 23426 * External dependencies 23427 */ 23428 23429 /** 23430 * WordPress dependencies 23431 */ 23432 23433 23434 23435 23436 23437 23438 /** 23439 * Internal dependencies 23440 */ 23441 23442 23443 /** 23444 * Retrieves the block patterns inserter state. 23445 * 23446 * @param {Function} onInsert function called when inserter a list of blocks. 23447 * @param {string=} rootClientId Insertion's root client ID. 23448 * 23449 * @return {Array} Returns the patterns state. (patterns, categories, onSelect handler) 23450 */ 23451 23452 const usePatternsState = (onInsert, rootClientId) => { 23453 const { 23454 patternCategories, 23455 patterns 23456 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 23457 const { 23458 __experimentalGetAllowedPatterns, 23459 getSettings 23460 } = select(store); 23461 return { 23462 patterns: __experimentalGetAllowedPatterns(rootClientId), 23463 patternCategories: getSettings().__experimentalBlockPatternCategories 23464 }; 23465 }, [rootClientId]); 23466 const { 23467 createSuccessNotice 23468 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 23469 const onClickPattern = (0,external_wp_element_namespaceObject.useCallback)((pattern, blocks) => { 23470 onInsert((0,external_lodash_namespaceObject.map)(blocks, block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block)), pattern.name); 23471 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( 23472 /* translators: %s: block pattern title. */ 23473 (0,external_wp_i18n_namespaceObject.__)('Block pattern "%s" inserted.'), pattern.title), { 23474 type: 'snackbar' 23475 }); 23476 }, []); 23477 return [patterns, patternCategories, onClickPattern]; 23478 }; 23479 23480 /* harmony default export */ var use_patterns_state = (usePatternsState); 23481 23482 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-patterns-list/index.js 23483 23484 23485 23486 /** 23487 * WordPress dependencies 23488 */ 23489 23490 23491 23492 /** 23493 * Internal dependencies 23494 */ 23495 23496 23497 23498 23499 function BlockPattern(_ref) { 23500 let { 23501 isDraggable, 23502 pattern, 23503 onClick, 23504 composite 23505 } = _ref; 23506 const { 23507 blocks, 23508 viewportWidth 23509 } = pattern; 23510 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockPattern); 23511 const descriptionId = `block-editor-block-patterns-list__item-description-$instanceId}`; 23512 return (0,external_wp_element_namespaceObject.createElement)(inserter_draggable_blocks, { 23513 isEnabled: isDraggable, 23514 blocks: blocks 23515 }, _ref2 => { 23516 let { 23517 draggable, 23518 onDragStart, 23519 onDragEnd 23520 } = _ref2; 23521 return (0,external_wp_element_namespaceObject.createElement)("div", { 23522 className: "block-editor-block-patterns-list__list-item", 23523 "aria-label": pattern.title, 23524 "aria-describedby": pattern.description ? descriptionId : undefined, 23525 draggable: draggable, 23526 onDragStart: onDragStart, 23527 onDragEnd: onDragEnd 23528 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({ 23529 role: "option", 23530 as: "div" 23531 }, composite, { 23532 className: "block-editor-block-patterns-list__item", 23533 onClick: () => onClick(pattern, blocks) 23534 }), (0,external_wp_element_namespaceObject.createElement)(block_preview, { 23535 blocks: blocks, 23536 viewportWidth: viewportWidth 23537 }), (0,external_wp_element_namespaceObject.createElement)("div", { 23538 className: "block-editor-block-patterns-list__item-title" 23539 }, pattern.title), !!pattern.description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 23540 id: descriptionId 23541 }, pattern.description))); 23542 }); 23543 } 23544 23545 function BlockPatternPlaceholder() { 23546 return (0,external_wp_element_namespaceObject.createElement)("div", { 23547 className: "block-editor-block-patterns-list__item is-placeholder" 23548 }); 23549 } 23550 23551 function BlockPatternList(_ref3) { 23552 let { 23553 isDraggable, 23554 blockPatterns, 23555 shownPatterns, 23556 onClickPattern, 23557 orientation, 23558 label = (0,external_wp_i18n_namespaceObject.__)('Block Patterns') 23559 } = _ref3; 23560 const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)({ 23561 orientation 23562 }); 23563 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, { 23564 role: "listbox", 23565 className: "block-editor-block-patterns-list", 23566 "aria-label": label 23567 }), blockPatterns.map(pattern => { 23568 const isShown = shownPatterns.includes(pattern); 23569 return isShown ? (0,external_wp_element_namespaceObject.createElement)(BlockPattern, { 23570 key: pattern.name, 23571 pattern: pattern, 23572 onClick: onClickPattern, 23573 isDraggable: isDraggable, 23574 composite: composite 23575 }) : (0,external_wp_element_namespaceObject.createElement)(BlockPatternPlaceholder, { 23576 key: pattern.name 23577 }); 23578 })); 23579 } 23580 23581 /* harmony default export */ var block_patterns_list = (BlockPatternList); 23582 23583 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-patterns-explorer/sidebar.js 23584 23585 23586 /** 23587 * WordPress dependencies 23588 */ 23589 23590 23591 23592 function PatternCategoriesList(_ref) { 23593 let { 23594 selectedCategory, 23595 patternCategories, 23596 onClickCategory 23597 } = _ref; 23598 const baseClassName = 'block-editor-block-patterns-explorer__sidebar'; 23599 return (0,external_wp_element_namespaceObject.createElement)("div", { 23600 className: `$baseClassName}__categories-list` 23601 }, patternCategories.map(_ref2 => { 23602 let { 23603 name, 23604 label 23605 } = _ref2; 23606 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 23607 key: name, 23608 label: label, 23609 className: `$baseClassName}__categories-list__item`, 23610 isPressed: selectedCategory === name, 23611 onClick: () => { 23612 onClickCategory(name); 23613 } 23614 }, label); 23615 })); 23616 } 23617 23618 function PatternsExplorerSearch(_ref3) { 23619 let { 23620 filterValue, 23621 setFilterValue 23622 } = _ref3; 23623 const baseClassName = 'block-editor-block-patterns-explorer__search'; 23624 return (0,external_wp_element_namespaceObject.createElement)("div", { 23625 className: baseClassName 23626 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, { 23627 onChange: setFilterValue, 23628 value: filterValue, 23629 label: (0,external_wp_i18n_namespaceObject.__)('Search for patterns'), 23630 placeholder: (0,external_wp_i18n_namespaceObject.__)('Search') 23631 })); 23632 } 23633 23634 function PatternExplorerSidebar(_ref4) { 23635 let { 23636 selectedCategory, 23637 patternCategories, 23638 onClickCategory, 23639 filterValue, 23640 setFilterValue 23641 } = _ref4; 23642 const baseClassName = 'block-editor-block-patterns-explorer__sidebar'; 23643 return (0,external_wp_element_namespaceObject.createElement)("div", { 23644 className: baseClassName 23645 }, (0,external_wp_element_namespaceObject.createElement)(PatternsExplorerSearch, { 23646 filterValue: filterValue, 23647 setFilterValue: setFilterValue 23648 }), !filterValue && (0,external_wp_element_namespaceObject.createElement)(PatternCategoriesList, { 23649 selectedCategory: selectedCategory, 23650 patternCategories: patternCategories, 23651 onClickCategory: onClickCategory 23652 })); 23653 } 23654 23655 /* harmony default export */ var sidebar = (PatternExplorerSidebar); 23656 23657 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/no-results.js 23658 23659 23660 /** 23661 * WordPress dependencies 23662 */ 23663 23664 23665 23666 function InserterNoResults() { 23667 return (0,external_wp_element_namespaceObject.createElement)("div", { 23668 className: "block-editor-inserter__no-results" 23669 }, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { 23670 className: "block-editor-inserter__no-results-icon", 23671 icon: block_default 23672 }), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('No results found.'))); 23673 } 23674 23675 /* harmony default export */ var no_results = (InserterNoResults); 23676 23677 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/hooks/use-insertion-point.js 23678 /** 23679 * External dependencies 23680 */ 23681 23682 /** 23683 * WordPress dependencies 23684 */ 23685 23686 23687 23688 23689 23690 23691 /** 23692 * Internal dependencies 23693 */ 23694 23695 23696 /** 23697 * @typedef WPInserterConfig 23698 * 23699 * @property {string=} rootClientId If set, insertion will be into the 23700 * block with this ID. 23701 * @property {number=} insertionIndex If set, insertion will be into this 23702 * explicit position. 23703 * @property {string=} clientId If set, insertion will be after the 23704 * block with this ID. 23705 * @property {boolean=} isAppender Whether the inserter is an appender 23706 * or not. 23707 * @property {Function=} onSelect Called after insertion. 23708 */ 23709 23710 /** 23711 * Returns the insertion point state given the inserter config. 23712 * 23713 * @param {WPInserterConfig} config Inserter Config. 23714 * @return {Array} Insertion Point State (rootClientID, onInsertBlocks and onToggle). 23715 */ 23716 23717 function useInsertionPoint(_ref) { 23718 let { 23719 rootClientId = '', 23720 insertionIndex, 23721 clientId, 23722 isAppender, 23723 onSelect, 23724 shouldFocusBlock = true 23725 } = _ref; 23726 const { 23727 getSelectedBlock 23728 } = (0,external_wp_data_namespaceObject.useSelect)(store); 23729 const { 23730 destinationRootClientId, 23731 destinationIndex 23732 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 23733 const { 23734 getSelectedBlockClientId, 23735 getBlockRootClientId, 23736 getBlockIndex, 23737 getBlockOrder 23738 } = select(store); 23739 const selectedBlockClientId = getSelectedBlockClientId(); 23740 let _destinationRootClientId = rootClientId; 23741 23742 let _destinationIndex; 23743 23744 if (insertionIndex !== undefined) { 23745 // Insert into a specific index. 23746 _destinationIndex = insertionIndex; 23747 } else if (clientId) { 23748 // Insert after a specific client ID. 23749 _destinationIndex = getBlockIndex(clientId); 23750 } else if (!isAppender && selectedBlockClientId) { 23751 _destinationRootClientId = getBlockRootClientId(selectedBlockClientId); 23752 _destinationIndex = getBlockIndex(selectedBlockClientId) + 1; 23753 } else { 23754 // Insert at the end of the list. 23755 _destinationIndex = getBlockOrder(_destinationRootClientId).length; 23756 } 23757 23758 return { 23759 destinationRootClientId: _destinationRootClientId, 23760 destinationIndex: _destinationIndex 23761 }; 23762 }, [rootClientId, insertionIndex, clientId, isAppender]); 23763 const { 23764 replaceBlocks, 23765 insertBlocks, 23766 showInsertionPoint, 23767 hideInsertionPoint 23768 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 23769 const onInsertBlocks = (0,external_wp_element_namespaceObject.useCallback)(function (blocks, meta) { 23770 let shouldForceFocusBlock = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 23771 const selectedBlock = getSelectedBlock(); 23772 23773 if (!isAppender && selectedBlock && (0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)(selectedBlock)) { 23774 replaceBlocks(selectedBlock.clientId, blocks, null, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta); 23775 } else { 23776 insertBlocks(blocks, destinationIndex, destinationRootClientId, true, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta); 23777 } 23778 23779 const message = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %d: the name of the block that has been added 23780 (0,external_wp_i18n_namespaceObject._n)('%d block added.', '%d blocks added.', (0,external_lodash_namespaceObject.castArray)(blocks).length), (0,external_lodash_namespaceObject.castArray)(blocks).length); 23781 (0,external_wp_a11y_namespaceObject.speak)(message); 23782 23783 if (onSelect) { 23784 onSelect(); 23785 } 23786 }, [isAppender, getSelectedBlock, replaceBlocks, insertBlocks, destinationRootClientId, destinationIndex, onSelect, shouldFocusBlock]); 23787 const onToggleInsertionPoint = (0,external_wp_element_namespaceObject.useCallback)(show => { 23788 if (show) { 23789 showInsertionPoint(destinationRootClientId, destinationIndex); 23790 } else { 23791 hideInsertionPoint(); 23792 } 23793 }, [showInsertionPoint, hideInsertionPoint, destinationRootClientId, destinationIndex]); 23794 return [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint]; 23795 } 23796 23797 /* harmony default export */ var use_insertion_point = (useInsertionPoint); 23798 23799 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/search-items.js 23800 /** 23801 * External dependencies 23802 */ 23803 // Default search helpers. 23804 23805 const defaultGetName = item => item.name || ''; 23806 23807 const defaultGetTitle = item => item.title; 23808 23809 const defaultGetDescription = item => item.description || ''; 23810 23811 const defaultGetKeywords = item => item.keywords || []; 23812 23813 const defaultGetCategory = item => item.category; 23814 23815 const defaultGetCollection = () => null; 23816 /** 23817 * Sanitizes the search input string. 23818 * 23819 * @param {string} input The search input to normalize. 23820 * 23821 * @return {string} The normalized search input. 23822 */ 23823 23824 23825 function normalizeSearchInput() { 23826 let input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 23827 // Disregard diacritics. 23828 // Input: "média" 23829 input = (0,external_lodash_namespaceObject.deburr)(input); // Accommodate leading slash, matching autocomplete expectations. 23830 // Input: "/media" 23831 23832 input = input.replace(/^\//, ''); // Lowercase. 23833 // Input: "MEDIA" 23834 23835 input = input.toLowerCase(); 23836 return input; 23837 } 23838 /** 23839 * Converts the search term into a list of normalized terms. 23840 * 23841 * @param {string} input The search term to normalize. 23842 * 23843 * @return {string[]} The normalized list of search terms. 23844 */ 23845 23846 23847 const getNormalizedSearchTerms = function () { 23848 let input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 23849 // Extract words. 23850 return (0,external_lodash_namespaceObject.words)(normalizeSearchInput(input)); 23851 }; 23852 23853 const removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => { 23854 return (0,external_lodash_namespaceObject.differenceWith)(unmatchedTerms, getNormalizedSearchTerms(unprocessedTerms), (unmatchedTerm, unprocessedTerm) => unprocessedTerm.includes(unmatchedTerm)); 23855 }; 23856 23857 const searchBlockItems = (items, categories, collections, searchInput) => { 23858 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput); 23859 23860 if (normalizedSearchTerms.length === 0) { 23861 return items; 23862 } 23863 23864 const config = { 23865 getCategory: item => { 23866 var _find; 23867 23868 return (_find = (0,external_lodash_namespaceObject.find)(categories, { 23869 slug: item.category 23870 })) === null || _find === void 0 ? void 0 : _find.title; 23871 }, 23872 getCollection: item => { 23873 var _collections$item$nam; 23874 23875 return (_collections$item$nam = collections[item.name.split('/')[0]]) === null || _collections$item$nam === void 0 ? void 0 : _collections$item$nam.title; 23876 } 23877 }; 23878 return searchItems(items, searchInput, config); 23879 }; 23880 /** 23881 * Filters an item list given a search term. 23882 * 23883 * @param {Array} items Item list 23884 * @param {string} searchInput Search input. 23885 * @param {Object} config Search Config. 23886 * 23887 * @return {Array} Filtered item list. 23888 */ 23889 23890 const searchItems = function () { 23891 let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; 23892 let searchInput = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 23893 let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; 23894 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput); 23895 23896 if (normalizedSearchTerms.length === 0) { 23897 return items; 23898 } 23899 23900 const rankedItems = items.map(item => { 23901 return [item, getItemSearchRank(item, searchInput, config)]; 23902 }).filter(_ref => { 23903 let [, rank] = _ref; 23904 return rank > 0; 23905 }); 23906 rankedItems.sort((_ref2, _ref3) => { 23907 let [, rank1] = _ref2; 23908 let [, rank2] = _ref3; 23909 return rank2 - rank1; 23910 }); 23911 return rankedItems.map(_ref4 => { 23912 let [item] = _ref4; 23913 return item; 23914 }); 23915 }; 23916 /** 23917 * Get the search rank for a given item and a specific search term. 23918 * The better the match, the higher the rank. 23919 * If the rank equals 0, it should be excluded from the results. 23920 * 23921 * @param {Object} item Item to filter. 23922 * @param {string} searchTerm Search term. 23923 * @param {Object} config Search Config. 23924 * 23925 * @return {number} Search Rank. 23926 */ 23927 23928 function getItemSearchRank(item, searchTerm) { 23929 let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; 23930 const { 23931 getName = defaultGetName, 23932 getTitle = defaultGetTitle, 23933 getDescription = defaultGetDescription, 23934 getKeywords = defaultGetKeywords, 23935 getCategory = defaultGetCategory, 23936 getCollection = defaultGetCollection 23937 } = config; 23938 const name = getName(item); 23939 const title = getTitle(item); 23940 const description = getDescription(item); 23941 const keywords = getKeywords(item); 23942 const category = getCategory(item); 23943 const collection = getCollection(item); 23944 const normalizedSearchInput = normalizeSearchInput(searchTerm); 23945 const normalizedTitle = normalizeSearchInput(title); 23946 let rank = 0; // Prefers exact matches 23947 // Then prefers if the beginning of the title matches the search term 23948 // name, keywords, categories, collection, variations match come later. 23949 23950 if (normalizedSearchInput === normalizedTitle) { 23951 rank += 30; 23952 } else if (normalizedTitle.startsWith(normalizedSearchInput)) { 23953 rank += 20; 23954 } else { 23955 const terms = [name, title, description, ...keywords, category, collection].join(' '); 23956 const normalizedSearchTerms = (0,external_lodash_namespaceObject.words)(normalizedSearchInput); 23957 const unmatchedTerms = removeMatchingTerms(normalizedSearchTerms, terms); 23958 23959 if (unmatchedTerms.length === 0) { 23960 rank += 10; 23961 } 23962 } // Give a better rank to "core" namespaced items. 23963 23964 23965 if (rank !== 0 && name.startsWith('core/')) { 23966 const isCoreBlockVariation = name !== item.id; // Give a bit better rank to "core" blocks over "core" block variations. 23967 23968 rank += isCoreBlockVariation ? 1 : 2; 23969 } 23970 23971 return rank; 23972 } 23973 23974 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-patterns-explorer/patterns-list.js 23975 23976 23977 /** 23978 * WordPress dependencies 23979 */ 23980 23981 23982 23983 23984 23985 /** 23986 * Internal dependencies 23987 */ 23988 23989 23990 23991 23992 23993 23994 23995 const INITIAL_INSERTER_RESULTS = 2; 23996 23997 function PatternsListHeader(_ref) { 23998 let { 23999 filterValue, 24000 filteredBlockPatternsLength 24001 } = _ref; 24002 24003 if (!filterValue) { 24004 return null; 24005 } 24006 24007 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { 24008 level: 2, 24009 lineHeight: '48px', 24010 className: "block-editor-block-patterns-explorer__search-results-count" 24011 }, (0,external_wp_i18n_namespaceObject.sprintf)( 24012 /* translators: %d: number of patterns. %s: block pattern search query */ 24013 (0,external_wp_i18n_namespaceObject._n)('%1$d pattern found for "%2$s"', '%1$d patterns found for "%2$s"', filteredBlockPatternsLength), filteredBlockPatternsLength, filterValue)); 24014 } 24015 24016 function PatternList(_ref2) { 24017 let { 24018 filterValue, 24019 selectedCategory, 24020 patternCategories 24021 } = _ref2; 24022 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500); 24023 const [destinationRootClientId, onInsertBlocks] = use_insertion_point({ 24024 shouldFocusBlock: true 24025 }); 24026 const [allPatterns,, onSelectBlockPattern] = use_patterns_state(onInsertBlocks, destinationRootClientId); 24027 const registeredPatternCategories = (0,external_wp_element_namespaceObject.useMemo)(() => patternCategories.map(patternCategory => patternCategory.name), [patternCategories]); 24028 const filteredBlockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => { 24029 if (!filterValue) { 24030 return allPatterns.filter(pattern => { 24031 var _pattern$categories, _pattern$categories2; 24032 24033 return selectedCategory === 'uncategorized' ? !((_pattern$categories = pattern.categories) !== null && _pattern$categories !== void 0 && _pattern$categories.length) || pattern.categories.every(category => !registeredPatternCategories.includes(category)) : (_pattern$categories2 = pattern.categories) === null || _pattern$categories2 === void 0 ? void 0 : _pattern$categories2.includes(selectedCategory); 24034 }); 24035 } 24036 24037 return searchItems(allPatterns, filterValue); 24038 }, [filterValue, selectedCategory, allPatterns]); // Announce search results on change. 24039 24040 (0,external_wp_element_namespaceObject.useEffect)(() => { 24041 if (!filterValue) { 24042 return; 24043 } 24044 24045 const count = filteredBlockPatterns.length; 24046 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)( 24047 /* translators: %d: number of results. */ 24048 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count); 24049 debouncedSpeak(resultsFoundMessage); 24050 }, [filterValue, debouncedSpeak]); 24051 const currentShownPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(filteredBlockPatterns, { 24052 step: INITIAL_INSERTER_RESULTS 24053 }); 24054 const hasItems = !!(filteredBlockPatterns !== null && filteredBlockPatterns !== void 0 && filteredBlockPatterns.length); 24055 return (0,external_wp_element_namespaceObject.createElement)("div", { 24056 className: "block-editor-block-patterns-explorer__list" 24057 }, hasItems && (0,external_wp_element_namespaceObject.createElement)(PatternsListHeader, { 24058 filterValue: filterValue, 24059 filteredBlockPatternsLength: filteredBlockPatterns.length 24060 }), (0,external_wp_element_namespaceObject.createElement)(inserter_listbox, null, !hasItems && (0,external_wp_element_namespaceObject.createElement)(no_results, null), hasItems && (0,external_wp_element_namespaceObject.createElement)(block_patterns_list, { 24061 shownPatterns: currentShownPatterns, 24062 blockPatterns: filteredBlockPatterns, 24063 onClickPattern: onSelectBlockPattern, 24064 isDraggable: false 24065 }))); 24066 } 24067 24068 /* harmony default export */ var patterns_list = (PatternList); 24069 24070 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-patterns-explorer/explorer.js 24071 24072 24073 /** 24074 * WordPress dependencies 24075 */ 24076 24077 24078 24079 /** 24080 * Internal dependencies 24081 */ 24082 24083 24084 24085 24086 function PatternsExplorer(_ref) { 24087 let { 24088 initialCategory, 24089 patternCategories 24090 } = _ref; 24091 const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)(''); 24092 const [selectedCategory, setSelectedCategory] = (0,external_wp_element_namespaceObject.useState)(initialCategory === null || initialCategory === void 0 ? void 0 : initialCategory.name); 24093 return (0,external_wp_element_namespaceObject.createElement)("div", { 24094 className: "block-editor-block-patterns-explorer" 24095 }, (0,external_wp_element_namespaceObject.createElement)(sidebar, { 24096 selectedCategory: selectedCategory, 24097 patternCategories: patternCategories, 24098 onClickCategory: setSelectedCategory, 24099 filterValue: filterValue, 24100 setFilterValue: setFilterValue 24101 }), (0,external_wp_element_namespaceObject.createElement)(patterns_list, { 24102 filterValue: filterValue, 24103 selectedCategory: selectedCategory, 24104 patternCategories: patternCategories 24105 })); 24106 } 24107 24108 function PatternsExplorerModal(_ref2) { 24109 let { 24110 onModalClose, 24111 ...restProps 24112 } = _ref2; 24113 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { 24114 title: (0,external_wp_i18n_namespaceObject.__)('Patterns'), 24115 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'), 24116 onRequestClose: onModalClose, 24117 isFullScreen: true 24118 }, (0,external_wp_element_namespaceObject.createElement)(PatternsExplorer, restProps)); 24119 } 24120 24121 /* harmony default export */ var explorer = (PatternsExplorerModal); 24122 24123 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-patterns-tab.js 24124 24125 24126 /** 24127 * WordPress dependencies 24128 */ 24129 24130 24131 24132 /** 24133 * Internal dependencies 24134 */ 24135 24136 24137 24138 24139 24140 24141 function BlockPatternsCategory(_ref) { 24142 let { 24143 rootClientId, 24144 onInsert, 24145 selectedCategory, 24146 populatedCategories 24147 } = _ref; 24148 const [allPatterns,, onClick] = use_patterns_state(onInsert, rootClientId); 24149 const getPatternIndex = (0,external_wp_element_namespaceObject.useCallback)(pattern => { 24150 var _pattern$categories; 24151 24152 if (!((_pattern$categories = pattern.categories) !== null && _pattern$categories !== void 0 && _pattern$categories.length)) { 24153 return Infinity; 24154 } 24155 24156 const indexedCategories = populatedCategories.reduce((accumulator, _ref2, index) => { 24157 let { 24158 name 24159 } = _ref2; 24160 accumulator[name] = index; 24161 return accumulator; 24162 }, {}); 24163 return Math.min(...pattern.categories.map(cat => indexedCategories[cat] !== undefined ? indexedCategories[cat] : Infinity)); 24164 }, [populatedCategories]); 24165 const currentCategoryPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => allPatterns.filter(pattern => { 24166 var _pattern$categories2; 24167 24168 return selectedCategory.name === 'uncategorized' ? getPatternIndex(pattern) === Infinity : (_pattern$categories2 = pattern.categories) === null || _pattern$categories2 === void 0 ? void 0 : _pattern$categories2.includes(selectedCategory.name); 24169 }), [allPatterns, selectedCategory]); // Ordering the patterns is important for the async rendering. 24170 24171 const orderedPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => { 24172 return currentCategoryPatterns.sort((a, b) => { 24173 return getPatternIndex(a) - getPatternIndex(b); 24174 }); 24175 }, [currentCategoryPatterns, getPatternIndex]); 24176 const currentShownPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(orderedPatterns); 24177 24178 if (!currentCategoryPatterns.length) { 24179 return null; 24180 } 24181 24182 return (0,external_wp_element_namespaceObject.createElement)("div", { 24183 className: "block-editor-inserter__panel-content" 24184 }, (0,external_wp_element_namespaceObject.createElement)(block_patterns_list, { 24185 shownPatterns: currentShownPatterns, 24186 blockPatterns: currentCategoryPatterns, 24187 onClickPattern: onClick, 24188 label: selectedCategory.label, 24189 orientation: "vertical", 24190 isDraggable: true 24191 })); 24192 } 24193 24194 function BlockPatternsTabs(_ref3) { 24195 let { 24196 rootClientId, 24197 onInsert, 24198 onClickCategory, 24199 selectedCategory 24200 } = _ref3; 24201 const [showPatternsExplorer, setShowPatternsExplorer] = (0,external_wp_element_namespaceObject.useState)(false); 24202 const [allPatterns, allCategories] = use_patterns_state(); 24203 const hasRegisteredCategory = (0,external_wp_element_namespaceObject.useCallback)(pattern => { 24204 if (!pattern.categories || !pattern.categories.length) { 24205 return false; 24206 } 24207 24208 return pattern.categories.some(cat => allCategories.some(category => category.name === cat)); 24209 }, [allCategories]); // Remove any empty categories. 24210 24211 const populatedCategories = (0,external_wp_element_namespaceObject.useMemo)(() => { 24212 const categories = allCategories.filter(category => allPatterns.some(pattern => { 24213 var _pattern$categories3; 24214 24215 return (_pattern$categories3 = pattern.categories) === null || _pattern$categories3 === void 0 ? void 0 : _pattern$categories3.includes(category.name); 24216 })).sort((_ref4, _ref5) => { 24217 let { 24218 name: currentName 24219 } = _ref4; 24220 let { 24221 name: nextName 24222 } = _ref5; 24223 24224 if (![currentName, nextName].includes('featured')) { 24225 return 0; 24226 } 24227 24228 return currentName === 'featured' ? -1 : 1; 24229 }); 24230 24231 if (allPatterns.some(pattern => !hasRegisteredCategory(pattern)) && !categories.find(category => category.name === 'uncategorized')) { 24232 categories.push({ 24233 name: 'uncategorized', 24234 label: (0,external_wp_i18n_namespaceObject._x)('Uncategorized') 24235 }); 24236 } 24237 24238 return categories; 24239 }, [allPatterns, allCategories]); 24240 const patternCategory = selectedCategory ? selectedCategory : populatedCategories[0]; 24241 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(pattern_panel, { 24242 selectedCategory: patternCategory, 24243 patternCategories: populatedCategories, 24244 onClickCategory: onClickCategory, 24245 openPatternExplorer: () => setShowPatternsExplorer(true) 24246 }), !showPatternsExplorer && (0,external_wp_element_namespaceObject.createElement)(BlockPatternsCategory, { 24247 rootClientId: rootClientId, 24248 onInsert: onInsert, 24249 selectedCategory: patternCategory, 24250 populatedCategories: populatedCategories 24251 }), showPatternsExplorer && (0,external_wp_element_namespaceObject.createElement)(explorer, { 24252 initialCategory: patternCategory, 24253 patternCategories: populatedCategories, 24254 onModalClose: () => setShowPatternsExplorer(false) 24255 })); 24256 } 24257 24258 /* harmony default export */ var block_patterns_tab = (BlockPatternsTabs); 24259 24260 ;// CONCATENATED MODULE: external ["wp","url"] 24261 var external_wp_url_namespaceObject = window["wp"]["url"]; 24262 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/reusable-blocks-tab.js 24263 24264 24265 /** 24266 * WordPress dependencies 24267 */ 24268 24269 24270 24271 /** 24272 * Internal dependencies 24273 */ 24274 24275 24276 24277 24278 24279 24280 function ReusableBlocksList(_ref) { 24281 let { 24282 onHover, 24283 onInsert, 24284 rootClientId 24285 } = _ref; 24286 const [items,,, onSelectItem] = use_block_types_state(rootClientId, onInsert); 24287 const filteredItems = (0,external_wp_element_namespaceObject.useMemo)(() => { 24288 return items.filter(_ref2 => { 24289 let { 24290 category 24291 } = _ref2; 24292 return category === 'reusable'; 24293 }); 24294 }, [items]); 24295 24296 if (filteredItems.length === 0) { 24297 return (0,external_wp_element_namespaceObject.createElement)(no_results, null); 24298 } 24299 24300 return (0,external_wp_element_namespaceObject.createElement)(panel, { 24301 title: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks') 24302 }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, { 24303 items: filteredItems, 24304 onSelect: onSelectItem, 24305 onHover: onHover, 24306 label: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks') 24307 })); 24308 } // The unwrapped component is only exported for use by unit tests. 24309 24310 /** 24311 * List of reusable blocks shown in the "Reusable" tab of the inserter. 24312 * 24313 * @param {Object} props Component props. 24314 * @param {?string} props.rootClientId Client id of block to insert into. 24315 * @param {Function} props.onInsert Callback to run when item is inserted. 24316 * @param {Function} props.onHover Callback to run when item is hovered. 24317 * 24318 * @return {WPComponent} The component. 24319 */ 24320 24321 24322 function ReusableBlocksTab(_ref3) { 24323 let { 24324 rootClientId, 24325 onInsert, 24326 onHover 24327 } = _ref3; 24328 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(ReusableBlocksList, { 24329 onHover: onHover, 24330 onInsert: onInsert, 24331 rootClientId: rootClientId 24332 }), (0,external_wp_element_namespaceObject.createElement)("div", { 24333 className: "block-editor-inserter__manage-reusable-blocks-container" 24334 }, (0,external_wp_element_namespaceObject.createElement)("a", { 24335 className: "block-editor-inserter__manage-reusable-blocks", 24336 href: (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', { 24337 post_type: 'wp_block' 24338 }) 24339 }, (0,external_wp_i18n_namespaceObject.__)('Manage Reusable blocks')))); 24340 } 24341 /* harmony default export */ var reusable_blocks_tab = (ReusableBlocksTab); 24342 24343 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-menu-extension/index.js 24344 /** 24345 * WordPress dependencies 24346 */ 24347 24348 const { 24349 Fill: __unstableInserterMenuExtension, 24350 Slot 24351 } = (0,external_wp_components_namespaceObject.createSlotFill)('__unstableInserterMenuExtension'); 24352 __unstableInserterMenuExtension.Slot = Slot; 24353 /* harmony default export */ var inserter_menu_extension = (__unstableInserterMenuExtension); 24354 24355 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/search-results.js 24356 24357 24358 /** 24359 * External dependencies 24360 */ 24361 24362 /** 24363 * WordPress dependencies 24364 */ 24365 24366 24367 24368 24369 24370 24371 /** 24372 * Internal dependencies 24373 */ 24374 24375 24376 24377 24378 24379 24380 24381 24382 24383 24384 24385 const search_results_INITIAL_INSERTER_RESULTS = 9; 24386 /** 24387 * Shared reference to an empty array for cases where it is important to avoid 24388 * returning a new array reference on every invocation and rerendering the component. 24389 * 24390 * @type {Array} 24391 */ 24392 24393 const search_results_EMPTY_ARRAY = []; 24394 24395 function InserterSearchResults(_ref) { 24396 let { 24397 filterValue, 24398 onSelect, 24399 onHover, 24400 rootClientId, 24401 clientId, 24402 isAppender, 24403 __experimentalInsertionIndex, 24404 maxBlockPatterns, 24405 maxBlockTypes, 24406 showBlockDirectory = false, 24407 isDraggable = true, 24408 shouldFocusBlock = true, 24409 prioritizePatterns 24410 } = _ref; 24411 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500); 24412 const [destinationRootClientId, onInsertBlocks] = use_insertion_point({ 24413 onSelect, 24414 rootClientId, 24415 clientId, 24416 isAppender, 24417 insertionIndex: __experimentalInsertionIndex, 24418 shouldFocusBlock 24419 }); 24420 const [blockTypes, blockTypeCategories, blockTypeCollections, onSelectBlockType] = use_block_types_state(destinationRootClientId, onInsertBlocks); 24421 const [patterns,, onSelectBlockPattern] = use_patterns_state(onInsertBlocks, destinationRootClientId); 24422 const filteredBlockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => { 24423 if (maxBlockPatterns === 0) { 24424 return []; 24425 } 24426 24427 const results = searchItems(patterns, filterValue); 24428 return maxBlockPatterns !== undefined ? results.slice(0, maxBlockPatterns) : results; 24429 }, [filterValue, patterns, maxBlockPatterns]); 24430 let maxBlockTypesToShow = maxBlockTypes; 24431 24432 if (prioritizePatterns && filteredBlockPatterns.length > 2) { 24433 maxBlockTypesToShow = 0; 24434 } 24435 24436 const filteredBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => { 24437 if (maxBlockTypesToShow === 0) { 24438 return []; 24439 } 24440 24441 const results = searchBlockItems((0,external_lodash_namespaceObject.orderBy)(blockTypes, ['frecency'], ['desc']), blockTypeCategories, blockTypeCollections, filterValue); 24442 return maxBlockTypesToShow !== undefined ? results.slice(0, maxBlockTypesToShow) : results; 24443 }, [filterValue, blockTypes, blockTypeCategories, blockTypeCollections, maxBlockTypes]); // Announce search results on change. 24444 24445 (0,external_wp_element_namespaceObject.useEffect)(() => { 24446 if (!filterValue) { 24447 return; 24448 } 24449 24450 const count = filteredBlockTypes.length + filteredBlockPatterns.length; 24451 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)( 24452 /* translators: %d: number of results. */ 24453 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count); 24454 debouncedSpeak(resultsFoundMessage); 24455 }, [filterValue, debouncedSpeak]); 24456 const currentShownBlockTypes = (0,external_wp_compose_namespaceObject.useAsyncList)(filteredBlockTypes, { 24457 step: search_results_INITIAL_INSERTER_RESULTS 24458 }); 24459 const currentShownPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(currentShownBlockTypes.length === filteredBlockTypes.length ? filteredBlockPatterns : search_results_EMPTY_ARRAY); 24460 const hasItems = !(0,external_lodash_namespaceObject.isEmpty)(filteredBlockTypes) || !(0,external_lodash_namespaceObject.isEmpty)(filteredBlockPatterns); 24461 const blocksUI = !!filteredBlockTypes.length && (0,external_wp_element_namespaceObject.createElement)(panel, { 24462 title: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Blocks')) 24463 }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, { 24464 items: currentShownBlockTypes, 24465 onSelect: onSelectBlockType, 24466 onHover: onHover, 24467 label: (0,external_wp_i18n_namespaceObject.__)('Blocks'), 24468 isDraggable: isDraggable 24469 })); 24470 const patternsUI = !!filteredBlockPatterns.length && (0,external_wp_element_namespaceObject.createElement)(panel, { 24471 title: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Block Patterns')) 24472 }, (0,external_wp_element_namespaceObject.createElement)("div", { 24473 className: "block-editor-inserter__quick-inserter-patterns" 24474 }, (0,external_wp_element_namespaceObject.createElement)(block_patterns_list, { 24475 shownPatterns: currentShownPatterns, 24476 blockPatterns: filteredBlockPatterns, 24477 onClickPattern: onSelectBlockPattern, 24478 isDraggable: isDraggable 24479 }))); 24480 return (0,external_wp_element_namespaceObject.createElement)(inserter_listbox, null, !showBlockDirectory && !hasItems && (0,external_wp_element_namespaceObject.createElement)(no_results, null), prioritizePatterns ? patternsUI : blocksUI, !!filteredBlockTypes.length && !!filteredBlockPatterns.length && (0,external_wp_element_namespaceObject.createElement)("div", { 24481 className: "block-editor-inserter__quick-inserter-separator" 24482 }), prioritizePatterns ? blocksUI : patternsUI, showBlockDirectory && (0,external_wp_element_namespaceObject.createElement)(inserter_menu_extension.Slot, { 24483 fillProps: { 24484 onSelect: onSelectBlockType, 24485 onHover, 24486 filterValue, 24487 hasItems, 24488 rootClientId: destinationRootClientId 24489 } 24490 }, fills => { 24491 if (fills.length) { 24492 return fills; 24493 } 24494 24495 if (!hasItems) { 24496 return (0,external_wp_element_namespaceObject.createElement)(no_results, null); 24497 } 24498 24499 return null; 24500 })); 24501 } 24502 24503 /* harmony default export */ var search_results = (InserterSearchResults); 24504 24505 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/tabs.js 24506 24507 24508 /** 24509 * WordPress dependencies 24510 */ 24511 24512 24513 24514 const blocksTab = { 24515 name: 'blocks', 24516 24517 /* translators: Blocks tab title in the block inserter. */ 24518 title: (0,external_wp_i18n_namespaceObject.__)('Blocks') 24519 }; 24520 const patternsTab = { 24521 name: 'patterns', 24522 24523 /* translators: Patterns tab title in the block inserter. */ 24524 title: (0,external_wp_i18n_namespaceObject.__)('Patterns') 24525 }; 24526 const reusableBlocksTab = { 24527 name: 'reusable', 24528 24529 /* translators: Reusable blocks tab title in the block inserter. */ 24530 title: (0,external_wp_i18n_namespaceObject.__)('Reusable') 24531 }; 24532 24533 function InserterTabs(_ref) { 24534 let { 24535 children, 24536 showPatterns = false, 24537 showReusableBlocks = false, 24538 onSelect 24539 } = _ref; 24540 const tabs = (0,external_wp_element_namespaceObject.useMemo)(() => { 24541 const tempTabs = [blocksTab]; 24542 24543 if (showPatterns) { 24544 tempTabs.push(patternsTab); 24545 } 24546 24547 if (showReusableBlocks) { 24548 tempTabs.push(reusableBlocksTab); 24549 } 24550 24551 return tempTabs; 24552 }, [blocksTab, showPatterns, patternsTab, showReusableBlocks, reusableBlocksTab]); 24553 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, { 24554 className: "block-editor-inserter__tabs", 24555 tabs: tabs, 24556 onSelect: onSelect 24557 }, children); 24558 } 24559 24560 /* harmony default export */ var tabs = (InserterTabs); 24561 24562 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/menu.js 24563 24564 24565 /** 24566 * WordPress dependencies 24567 */ 24568 24569 24570 24571 24572 /** 24573 * Internal dependencies 24574 */ 24575 24576 24577 24578 24579 24580 24581 24582 24583 24584 24585 24586 function InserterMenu(_ref, ref) { 24587 let { 24588 rootClientId, 24589 clientId, 24590 isAppender, 24591 __experimentalInsertionIndex, 24592 onSelect, 24593 showInserterHelpPanel, 24594 showMostUsedBlocks, 24595 __experimentalFilterValue = '', 24596 shouldFocusBlock = true 24597 } = _ref; 24598 const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)(__experimentalFilterValue); 24599 const [hoveredItem, setHoveredItem] = (0,external_wp_element_namespaceObject.useState)(null); 24600 const [selectedPatternCategory, setSelectedPatternCategory] = (0,external_wp_element_namespaceObject.useState)(null); 24601 const [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint] = use_insertion_point({ 24602 rootClientId, 24603 clientId, 24604 isAppender, 24605 insertionIndex: __experimentalInsertionIndex, 24606 shouldFocusBlock 24607 }); 24608 const { 24609 showPatterns, 24610 hasReusableBlocks 24611 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 24612 var _getSettings$__experi; 24613 24614 const { 24615 __experimentalGetAllowedPatterns, 24616 getSettings 24617 } = select(store); 24618 return { 24619 showPatterns: !!__experimentalGetAllowedPatterns(destinationRootClientId).length, 24620 hasReusableBlocks: !!((_getSettings$__experi = getSettings().__experimentalReusableBlocks) !== null && _getSettings$__experi !== void 0 && _getSettings$__experi.length) 24621 }; 24622 }, [destinationRootClientId]); 24623 const onInsert = (0,external_wp_element_namespaceObject.useCallback)((blocks, meta, shouldForceFocusBlock) => { 24624 onInsertBlocks(blocks, meta, shouldForceFocusBlock); 24625 onSelect(); 24626 }, [onInsertBlocks, onSelect]); 24627 const onInsertPattern = (0,external_wp_element_namespaceObject.useCallback)((blocks, patternName) => { 24628 onInsertBlocks(blocks, { 24629 patternName 24630 }); 24631 onSelect(); 24632 }, [onInsertBlocks, onSelect]); 24633 const onHover = (0,external_wp_element_namespaceObject.useCallback)(item => { 24634 onToggleInsertionPoint(!!item); 24635 setHoveredItem(item); 24636 }, [onToggleInsertionPoint, setHoveredItem]); 24637 const onClickPatternCategory = (0,external_wp_element_namespaceObject.useCallback)(patternCategory => { 24638 setSelectedPatternCategory(patternCategory); 24639 }, [setSelectedPatternCategory]); 24640 const blocksTab = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", { 24641 className: "block-editor-inserter__block-list" 24642 }, (0,external_wp_element_namespaceObject.createElement)(block_types_tab, { 24643 rootClientId: destinationRootClientId, 24644 onInsert: onInsert, 24645 onHover: onHover, 24646 showMostUsedBlocks: showMostUsedBlocks 24647 })), showInserterHelpPanel && (0,external_wp_element_namespaceObject.createElement)("div", { 24648 className: "block-editor-inserter__tips" 24649 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 24650 as: "h2" 24651 }, (0,external_wp_i18n_namespaceObject.__)('A tip for using the block editor')), (0,external_wp_element_namespaceObject.createElement)(tips, null))), [destinationRootClientId, onInsert, onHover, filterValue, showMostUsedBlocks, showInserterHelpPanel]); 24652 const patternsTab = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_element_namespaceObject.createElement)(block_patterns_tab, { 24653 rootClientId: destinationRootClientId, 24654 onInsert: onInsertPattern, 24655 onClickCategory: onClickPatternCategory, 24656 selectedCategory: selectedPatternCategory 24657 }), [destinationRootClientId, onInsertPattern, onClickPatternCategory, selectedPatternCategory]); 24658 const reusableBlocksTab = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_element_namespaceObject.createElement)(reusable_blocks_tab, { 24659 rootClientId: destinationRootClientId, 24660 onInsert: onInsert, 24661 onHover: onHover 24662 }), [destinationRootClientId, onInsert, onHover]); 24663 const getCurrentTab = (0,external_wp_element_namespaceObject.useCallback)(tab => { 24664 if (tab.name === 'blocks') { 24665 return blocksTab; 24666 } else if (tab.name === 'patterns') { 24667 return patternsTab; 24668 } 24669 24670 return reusableBlocksTab; 24671 }, [blocksTab, patternsTab, reusableBlocksTab]); 24672 const searchRef = (0,external_wp_element_namespaceObject.useRef)(); 24673 (0,external_wp_element_namespaceObject.useImperativeHandle)(ref, () => ({ 24674 focusSearch: () => { 24675 searchRef.current.focus(); 24676 } 24677 })); 24678 return (0,external_wp_element_namespaceObject.createElement)("div", { 24679 className: "block-editor-inserter__menu" 24680 }, (0,external_wp_element_namespaceObject.createElement)("div", { 24681 className: "block-editor-inserter__main-area" 24682 }, (0,external_wp_element_namespaceObject.createElement)("div", { 24683 className: "block-editor-inserter__content" 24684 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, { 24685 className: "block-editor-inserter__search", 24686 onChange: value => { 24687 if (hoveredItem) setHoveredItem(null); 24688 setFilterValue(value); 24689 }, 24690 value: filterValue, 24691 label: (0,external_wp_i18n_namespaceObject.__)('Search for blocks and patterns'), 24692 placeholder: (0,external_wp_i18n_namespaceObject.__)('Search'), 24693 ref: searchRef 24694 }), !!filterValue && (0,external_wp_element_namespaceObject.createElement)(search_results, { 24695 filterValue: filterValue, 24696 onSelect: onSelect, 24697 onHover: onHover, 24698 rootClientId: rootClientId, 24699 clientId: clientId, 24700 isAppender: isAppender, 24701 __experimentalInsertionIndex: __experimentalInsertionIndex, 24702 showBlockDirectory: true, 24703 shouldFocusBlock: shouldFocusBlock 24704 }), !filterValue && (showPatterns || hasReusableBlocks) && (0,external_wp_element_namespaceObject.createElement)(tabs, { 24705 showPatterns: showPatterns, 24706 showReusableBlocks: hasReusableBlocks 24707 }, getCurrentTab), !filterValue && !showPatterns && !hasReusableBlocks && blocksTab)), showInserterHelpPanel && hoveredItem && (0,external_wp_element_namespaceObject.createElement)(preview_panel, { 24708 item: hoveredItem 24709 })); 24710 } 24711 24712 /* harmony default export */ var menu = ((0,external_wp_element_namespaceObject.forwardRef)(InserterMenu)); 24713 24714 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/quick-inserter.js 24715 24716 24717 /** 24718 * External dependencies 24719 */ 24720 24721 /** 24722 * WordPress dependencies 24723 */ 24724 24725 24726 24727 24728 24729 /** 24730 * Internal dependencies 24731 */ 24732 24733 24734 24735 24736 24737 24738 const SEARCH_THRESHOLD = 6; 24739 const SHOWN_BLOCK_TYPES = 6; 24740 const SHOWN_BLOCK_PATTERNS = 2; 24741 const SHOWN_BLOCK_PATTERNS_WITH_PRIORITIZATION = 4; 24742 function QuickInserter(_ref) { 24743 let { 24744 onSelect, 24745 rootClientId, 24746 clientId, 24747 isAppender, 24748 prioritizePatterns 24749 } = _ref; 24750 const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)(''); 24751 const [destinationRootClientId, onInsertBlocks] = use_insertion_point({ 24752 onSelect, 24753 rootClientId, 24754 clientId, 24755 isAppender 24756 }); 24757 const [blockTypes] = use_block_types_state(destinationRootClientId, onInsertBlocks); 24758 const [patterns] = use_patterns_state(onInsertBlocks, destinationRootClientId); 24759 const { 24760 setInserterIsOpened, 24761 insertionIndex 24762 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 24763 const { 24764 getSettings, 24765 getBlockIndex, 24766 getBlockCount 24767 } = select(store); 24768 const settings = getSettings(); 24769 const index = getBlockIndex(clientId); 24770 const blockCount = getBlockCount(); 24771 return { 24772 setInserterIsOpened: settings.__experimentalSetIsInserterOpened, 24773 insertionIndex: index === -1 ? blockCount : index 24774 }; 24775 }, [clientId]); 24776 const showPatterns = patterns.length && (!!filterValue || prioritizePatterns); 24777 const showSearch = showPatterns && patterns.length > SEARCH_THRESHOLD || blockTypes.length > SEARCH_THRESHOLD; 24778 (0,external_wp_element_namespaceObject.useEffect)(() => { 24779 if (setInserterIsOpened) { 24780 setInserterIsOpened(false); 24781 } 24782 }, [setInserterIsOpened]); // When clicking Browse All select the appropriate block so as 24783 // the insertion point can work as expected. 24784 24785 const onBrowseAll = () => { 24786 setInserterIsOpened({ 24787 rootClientId, 24788 insertionIndex, 24789 filterValue 24790 }); 24791 }; 24792 24793 let maxBlockPatterns = 0; 24794 24795 if (showPatterns) { 24796 maxBlockPatterns = prioritizePatterns ? SHOWN_BLOCK_PATTERNS_WITH_PRIORITIZATION : SHOWN_BLOCK_PATTERNS; 24797 } 24798 24799 return (0,external_wp_element_namespaceObject.createElement)("div", { 24800 className: classnames_default()('block-editor-inserter__quick-inserter', { 24801 'has-search': showSearch, 24802 'has-expand': setInserterIsOpened 24803 }) 24804 }, showSearch && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, { 24805 className: "block-editor-inserter__search", 24806 value: filterValue, 24807 onChange: value => { 24808 setFilterValue(value); 24809 }, 24810 label: (0,external_wp_i18n_namespaceObject.__)('Search for blocks and patterns'), 24811 placeholder: (0,external_wp_i18n_namespaceObject.__)('Search') 24812 }), (0,external_wp_element_namespaceObject.createElement)("div", { 24813 className: "block-editor-inserter__quick-inserter-results" 24814 }, (0,external_wp_element_namespaceObject.createElement)(search_results, { 24815 filterValue: filterValue, 24816 onSelect: onSelect, 24817 rootClientId: rootClientId, 24818 clientId: clientId, 24819 isAppender: isAppender, 24820 maxBlockPatterns: maxBlockPatterns, 24821 maxBlockTypes: SHOWN_BLOCK_TYPES, 24822 isDraggable: false, 24823 prioritizePatterns: prioritizePatterns 24824 })), setInserterIsOpened && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 24825 className: "block-editor-inserter__quick-inserter-expand", 24826 onClick: onBrowseAll, 24827 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Browse all. This will open the main inserter panel in the editor toolbar.') 24828 }, (0,external_wp_i18n_namespaceObject.__)('Browse all'))); 24829 } 24830 24831 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/index.js 24832 24833 24834 24835 /** 24836 * External dependencies 24837 */ 24838 24839 24840 /** 24841 * WordPress dependencies 24842 */ 24843 24844 24845 24846 24847 24848 24849 24850 24851 24852 /** 24853 * Internal dependencies 24854 */ 24855 24856 24857 24858 24859 24860 const defaultRenderToggle = _ref => { 24861 let { 24862 onToggle, 24863 disabled, 24864 isOpen, 24865 blockTitle, 24866 hasSingleBlockType, 24867 toggleProps = {}, 24868 prioritizePatterns 24869 } = _ref; 24870 let label; 24871 24872 if (hasSingleBlockType) { 24873 label = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of the block when there is only one 24874 (0,external_wp_i18n_namespaceObject._x)('Add %s', 'directly add the only allowed block'), blockTitle); 24875 } else if (prioritizePatterns) { 24876 label = (0,external_wp_i18n_namespaceObject.__)('Add pattern'); 24877 } else { 24878 label = (0,external_wp_i18n_namespaceObject._x)('Add block', 'Generic label for block inserter button'); 24879 } 24880 24881 const { 24882 onClick, 24883 ...rest 24884 } = toggleProps; // Handle both onClick functions from the toggle and the parent component. 24885 24886 function handleClick(event) { 24887 if (onToggle) { 24888 onToggle(event); 24889 } 24890 24891 if (onClick) { 24892 onClick(event); 24893 } 24894 } 24895 24896 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({ 24897 icon: library_plus, 24898 label: label, 24899 tooltipPosition: "bottom", 24900 onClick: handleClick, 24901 className: "block-editor-inserter__toggle", 24902 "aria-haspopup": !hasSingleBlockType ? 'true' : false, 24903 "aria-expanded": !hasSingleBlockType ? isOpen : false, 24904 disabled: disabled 24905 }, rest)); 24906 }; 24907 24908 class Inserter extends external_wp_element_namespaceObject.Component { 24909 constructor() { 24910 super(...arguments); 24911 this.onToggle = this.onToggle.bind(this); 24912 this.renderToggle = this.renderToggle.bind(this); 24913 this.renderContent = this.renderContent.bind(this); 24914 } 24915 24916 onToggle(isOpen) { 24917 const { 24918 onToggle 24919 } = this.props; // Surface toggle callback to parent component. 24920 24921 if (onToggle) { 24922 onToggle(isOpen); 24923 } 24924 } 24925 /** 24926 * Render callback to display Dropdown toggle element. 24927 * 24928 * @param {Object} options 24929 * @param {Function} options.onToggle Callback to invoke when toggle is 24930 * pressed. 24931 * @param {boolean} options.isOpen Whether dropdown is currently open. 24932 * 24933 * @return {WPElement} Dropdown toggle element. 24934 */ 24935 24936 24937 renderToggle(_ref2) { 24938 let { 24939 onToggle, 24940 isOpen 24941 } = _ref2; 24942 const { 24943 disabled, 24944 blockTitle, 24945 hasSingleBlockType, 24946 directInsertBlock, 24947 toggleProps, 24948 hasItems, 24949 renderToggle = defaultRenderToggle, 24950 prioritizePatterns 24951 } = this.props; 24952 return renderToggle({ 24953 onToggle, 24954 isOpen, 24955 disabled: disabled || !hasItems, 24956 blockTitle, 24957 hasSingleBlockType, 24958 directInsertBlock, 24959 toggleProps, 24960 prioritizePatterns 24961 }); 24962 } 24963 /** 24964 * Render callback to display Dropdown content element. 24965 * 24966 * @param {Object} options 24967 * @param {Function} options.onClose Callback to invoke when dropdown is 24968 * closed. 24969 * 24970 * @return {WPElement} Dropdown content element. 24971 */ 24972 24973 24974 renderContent(_ref3) { 24975 let { 24976 onClose 24977 } = _ref3; 24978 const { 24979 rootClientId, 24980 clientId, 24981 isAppender, 24982 showInserterHelpPanel, 24983 // This prop is experimental to give some time for the quick inserter to mature 24984 // Feel free to make them stable after a few releases. 24985 __experimentalIsQuick: isQuick, 24986 prioritizePatterns 24987 } = this.props; 24988 24989 if (isQuick) { 24990 return (0,external_wp_element_namespaceObject.createElement)(QuickInserter, { 24991 onSelect: () => { 24992 onClose(); 24993 }, 24994 rootClientId: rootClientId, 24995 clientId: clientId, 24996 isAppender: isAppender, 24997 prioritizePatterns: prioritizePatterns 24998 }); 24999 } 25000 25001 return (0,external_wp_element_namespaceObject.createElement)(menu, { 25002 onSelect: () => { 25003 onClose(); 25004 }, 25005 rootClientId: rootClientId, 25006 clientId: clientId, 25007 isAppender: isAppender, 25008 showInserterHelpPanel: showInserterHelpPanel 25009 }); 25010 } 25011 25012 render() { 25013 const { 25014 position, 25015 hasSingleBlockType, 25016 directInsertBlock, 25017 insertOnlyAllowedBlock, 25018 __experimentalIsQuick: isQuick, 25019 onSelectOrClose 25020 } = this.props; 25021 25022 if (hasSingleBlockType || directInsertBlock) { 25023 return this.renderToggle({ 25024 onToggle: insertOnlyAllowedBlock 25025 }); 25026 } 25027 25028 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, { 25029 className: "block-editor-inserter", 25030 contentClassName: classnames_default()('block-editor-inserter__popover', { 25031 'is-quick': isQuick 25032 }), 25033 position: position, 25034 onToggle: this.onToggle, 25035 expandOnMobile: true, 25036 headerTitle: (0,external_wp_i18n_namespaceObject.__)('Add a block'), 25037 renderToggle: this.renderToggle, 25038 renderContent: this.renderContent, 25039 onClose: onSelectOrClose 25040 }); 25041 } 25042 25043 } 25044 25045 /* harmony default export */ var inserter = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, _ref4) => { 25046 let { 25047 clientId, 25048 rootClientId 25049 } = _ref4; 25050 const { 25051 getBlockRootClientId, 25052 hasInserterItems, 25053 __experimentalGetAllowedBlocks, 25054 __experimentalGetDirectInsertBlock, 25055 getBlockIndex, 25056 getBlockCount, 25057 getSettings 25058 } = select(store); 25059 const { 25060 getBlockVariations 25061 } = select(external_wp_blocks_namespaceObject.store); 25062 rootClientId = rootClientId || getBlockRootClientId(clientId) || undefined; 25063 25064 const allowedBlocks = __experimentalGetAllowedBlocks(rootClientId); 25065 25066 const directInsertBlock = __experimentalGetDirectInsertBlock(rootClientId); 25067 25068 const index = getBlockIndex(clientId); 25069 const blockCount = getBlockCount(); 25070 const settings = getSettings(); 25071 const hasSingleBlockType = (0,external_lodash_namespaceObject.size)(allowedBlocks) === 1 && (0,external_lodash_namespaceObject.size)(getBlockVariations(allowedBlocks[0].name, 'inserter')) === 0; 25072 let allowedBlockType = false; 25073 25074 if (hasSingleBlockType) { 25075 allowedBlockType = allowedBlocks[0]; 25076 } 25077 25078 return { 25079 hasItems: hasInserterItems(rootClientId), 25080 hasSingleBlockType, 25081 blockTitle: allowedBlockType ? allowedBlockType.title : '', 25082 allowedBlockType, 25083 directInsertBlock, 25084 rootClientId, 25085 prioritizePatterns: settings.__experimentalPreferPatternsOnRoot && !rootClientId && index > 0 && (index < blockCount || blockCount === 0) 25086 }; 25087 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps, _ref5) => { 25088 let { 25089 select 25090 } = _ref5; 25091 return { 25092 insertOnlyAllowedBlock() { 25093 const { 25094 rootClientId, 25095 clientId, 25096 isAppender, 25097 hasSingleBlockType, 25098 allowedBlockType, 25099 directInsertBlock, 25100 onSelectOrClose 25101 } = ownProps; 25102 25103 if (!hasSingleBlockType && !directInsertBlock) { 25104 return; 25105 } 25106 25107 function getAdjacentBlockAttributes(attributesToCopy) { 25108 const { 25109 getBlock, 25110 getPreviousBlockClientId 25111 } = select(store); 25112 25113 if (!attributesToCopy || !clientId && !rootClientId) { 25114 return {}; 25115 } 25116 25117 const result = {}; 25118 let adjacentAttributes = {}; // If there is no clientId, then attempt to get attributes 25119 // from the last block within innerBlocks of the root block. 25120 25121 if (!clientId) { 25122 var _parentBlock$innerBlo; 25123 25124 const parentBlock = getBlock(rootClientId); 25125 25126 if (parentBlock !== null && parentBlock !== void 0 && (_parentBlock$innerBlo = parentBlock.innerBlocks) !== null && _parentBlock$innerBlo !== void 0 && _parentBlock$innerBlo.length) { 25127 const lastInnerBlock = parentBlock.innerBlocks[parentBlock.innerBlocks.length - 1]; 25128 25129 if (directInsertBlock && (directInsertBlock === null || directInsertBlock === void 0 ? void 0 : directInsertBlock.name) === lastInnerBlock.name) { 25130 adjacentAttributes = lastInnerBlock.attributes; 25131 } 25132 } 25133 } else { 25134 // Otherwise, attempt to get attributes from the 25135 // previous block relative to the current clientId. 25136 const currentBlock = getBlock(clientId); 25137 const previousBlock = getBlock(getPreviousBlockClientId(clientId)); 25138 25139 if ((currentBlock === null || currentBlock === void 0 ? void 0 : currentBlock.name) === (previousBlock === null || previousBlock === void 0 ? void 0 : previousBlock.name)) { 25140 adjacentAttributes = (previousBlock === null || previousBlock === void 0 ? void 0 : previousBlock.attributes) || {}; 25141 } 25142 } // Copy over only those attributes flagged to be copied. 25143 25144 25145 attributesToCopy.forEach(attribute => { 25146 if (adjacentAttributes.hasOwnProperty(attribute)) { 25147 result[attribute] = adjacentAttributes[attribute]; 25148 } 25149 }); 25150 return result; 25151 } 25152 25153 function getInsertionIndex() { 25154 const { 25155 getBlockIndex, 25156 getBlockSelectionEnd, 25157 getBlockOrder, 25158 getBlockRootClientId 25159 } = select(store); // If the clientId is defined, we insert at the position of the block. 25160 25161 if (clientId) { 25162 return getBlockIndex(clientId); 25163 } // If there a selected block, we insert after the selected block. 25164 25165 25166 const end = getBlockSelectionEnd(); 25167 25168 if (!isAppender && end && getBlockRootClientId(end) === rootClientId) { 25169 return getBlockIndex(end) + 1; 25170 } // Otherwise, we insert at the end of the current rootClientId. 25171 25172 25173 return getBlockOrder(rootClientId).length; 25174 } 25175 25176 const { 25177 insertBlock 25178 } = dispatch(store); 25179 let blockToInsert; // Attempt to augment the directInsertBlock with attributes from an adjacent block. 25180 // This ensures styling from nearby blocks is preserved in the newly inserted block. 25181 // See: https://github.com/WordPress/gutenberg/issues/37904 25182 25183 if (directInsertBlock) { 25184 const newAttributes = getAdjacentBlockAttributes(directInsertBlock.attributesToCopy); 25185 blockToInsert = (0,external_wp_blocks_namespaceObject.createBlock)(directInsertBlock.name, { ...(directInsertBlock.attributes || {}), 25186 ...newAttributes 25187 }); 25188 } else { 25189 blockToInsert = (0,external_wp_blocks_namespaceObject.createBlock)(allowedBlockType.name); 25190 } 25191 25192 insertBlock(blockToInsert, getInsertionIndex(), rootClientId); 25193 25194 if (onSelectOrClose) { 25195 onSelectOrClose(); 25196 } 25197 25198 const message = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of the block that has been added 25199 (0,external_wp_i18n_namespaceObject.__)('%s block added'), allowedBlockType.title); 25200 (0,external_wp_a11y_namespaceObject.speak)(message); 25201 } 25202 25203 }; 25204 }), // The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as 25205 // a way to detect the global Inserter. 25206 (0,external_wp_compose_namespaceObject.ifCondition)(_ref6 => { 25207 let { 25208 hasItems, 25209 isAppender, 25210 rootClientId, 25211 clientId 25212 } = _ref6; 25213 return hasItems || !isAppender && !rootClientId && !clientId; 25214 })])(Inserter)); 25215 25216 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/default-block-appender/index.js 25217 25218 25219 /** 25220 * External dependencies 25221 */ 25222 25223 /** 25224 * WordPress dependencies 25225 */ 25226 25227 25228 25229 25230 25231 25232 /** 25233 * Internal dependencies 25234 */ 25235 25236 25237 25238 /** 25239 * Zero width non-breaking space, used as padding for the paragraph when it is 25240 * empty. 25241 */ 25242 25243 const ZWNBSP = '\ufeff'; 25244 function DefaultBlockAppender(_ref) { 25245 let { 25246 isLocked, 25247 onAppend, 25248 showPrompt, 25249 placeholder, 25250 rootClientId 25251 } = _ref; 25252 25253 if (isLocked) { 25254 return null; 25255 } 25256 25257 const value = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Type / to choose a block'); 25258 25259 return (0,external_wp_element_namespaceObject.createElement)("div", { 25260 "data-root-client-id": rootClientId || '', 25261 className: classnames_default()('block-editor-default-block-appender', { 25262 'has-visible-prompt': showPrompt 25263 }) 25264 }, (0,external_wp_element_namespaceObject.createElement)("p", { 25265 tabIndex: "0" // We want this element to be styled as a paragraph by themes. 25266 // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role 25267 , 25268 role: "button", 25269 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Add default block') // A wrapping container for this one already has the wp-block className. 25270 , 25271 className: "block-editor-default-block-appender__content", 25272 onKeyDown: event => { 25273 if (external_wp_keycodes_namespaceObject.ENTER === event.keyCode || external_wp_keycodes_namespaceObject.SPACE === event.keyCode) { 25274 onAppend(); 25275 } 25276 }, 25277 onClick: () => onAppend(), 25278 onFocus: () => { 25279 if (showPrompt) { 25280 onAppend(); 25281 } 25282 } 25283 }, showPrompt ? value : ZWNBSP), (0,external_wp_element_namespaceObject.createElement)(inserter, { 25284 rootClientId: rootClientId, 25285 position: "bottom right", 25286 isAppender: true, 25287 __experimentalIsQuick: true 25288 })); 25289 } 25290 /* harmony default export */ var default_block_appender = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, ownProps) => { 25291 const { 25292 getBlockCount, 25293 getSettings, 25294 getTemplateLock 25295 } = select(store); 25296 const isEmpty = !getBlockCount(ownProps.rootClientId); 25297 const { 25298 bodyPlaceholder 25299 } = getSettings(); 25300 return { 25301 showPrompt: isEmpty, 25302 isLocked: !!getTemplateLock(ownProps.rootClientId), 25303 placeholder: bodyPlaceholder 25304 }; 25305 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps) => { 25306 const { 25307 insertDefaultBlock, 25308 startTyping 25309 } = dispatch(store); 25310 return { 25311 onAppend() { 25312 const { 25313 rootClientId 25314 } = ownProps; 25315 insertDefaultBlock(undefined, rootClientId); 25316 startTyping(); 25317 } 25318 25319 }; 25320 }))(DefaultBlockAppender)); 25321 25322 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/button-block-appender/index.js 25323 25324 25325 /** 25326 * External dependencies 25327 */ 25328 25329 /** 25330 * WordPress dependencies 25331 */ 25332 25333 25334 25335 25336 25337 25338 /** 25339 * Internal dependencies 25340 */ 25341 25342 25343 25344 function ButtonBlockAppender(_ref, ref) { 25345 let { 25346 rootClientId, 25347 className, 25348 onFocus, 25349 tabIndex 25350 } = _ref; 25351 return (0,external_wp_element_namespaceObject.createElement)(inserter, { 25352 position: "bottom center", 25353 rootClientId: rootClientId, 25354 __experimentalIsQuick: true, 25355 renderToggle: _ref2 => { 25356 let { 25357 onToggle, 25358 disabled, 25359 isOpen, 25360 blockTitle, 25361 hasSingleBlockType 25362 } = _ref2; 25363 let label; 25364 25365 if (hasSingleBlockType) { 25366 label = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of the block when there is only one 25367 (0,external_wp_i18n_namespaceObject._x)('Add %s', 'directly add the only allowed block'), blockTitle); 25368 } else { 25369 label = (0,external_wp_i18n_namespaceObject._x)('Add block', 'Generic label for block inserter button'); 25370 } 25371 25372 const isToggleButton = !hasSingleBlockType; 25373 let inserterButton = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 25374 ref: ref, 25375 onFocus: onFocus, 25376 tabIndex: tabIndex, 25377 className: classnames_default()(className, 'block-editor-button-block-appender'), 25378 onClick: onToggle, 25379 "aria-haspopup": isToggleButton ? 'true' : undefined, 25380 "aria-expanded": isToggleButton ? isOpen : undefined, 25381 disabled: disabled, 25382 label: label 25383 }, !hasSingleBlockType && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 25384 as: "span" 25385 }, label), (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { 25386 icon: library_plus 25387 })); 25388 25389 if (isToggleButton || hasSingleBlockType) { 25390 inserterButton = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, { 25391 text: label 25392 }, inserterButton); 25393 } 25394 25395 return inserterButton; 25396 }, 25397 isAppender: true 25398 }); 25399 } 25400 /** 25401 * Use `ButtonBlockAppender` instead. 25402 * 25403 * @deprecated 25404 */ 25405 25406 25407 const ButtonBlockerAppender = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => { 25408 external_wp_deprecated_default()(`wp.blockEditor.ButtonBlockerAppender`, { 25409 alternative: 'wp.blockEditor.ButtonBlockAppender', 25410 since: '5.9' 25411 }); 25412 return ButtonBlockAppender(props, ref); 25413 }); 25414 /** 25415 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/button-block-appender/README.md 25416 */ 25417 25418 /* harmony default export */ var button_block_appender = ((0,external_wp_element_namespaceObject.forwardRef)(ButtonBlockAppender)); 25419 25420 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list-appender/index.js 25421 25422 25423 /** 25424 * External dependencies 25425 */ 25426 25427 /** 25428 * WordPress dependencies 25429 */ 25430 25431 25432 25433 /** 25434 * Internal dependencies 25435 */ 25436 25437 25438 25439 25440 25441 function BlockListAppender(_ref) { 25442 let { 25443 rootClientId, 25444 canInsertDefaultBlock, 25445 isLocked, 25446 renderAppender: CustomAppender, 25447 className, 25448 selectedBlockClientId, 25449 tagName: TagName = 'div' 25450 } = _ref; 25451 25452 if (isLocked || CustomAppender === false) { 25453 return null; 25454 } 25455 25456 let appender; 25457 25458 if (CustomAppender) { 25459 // Prefer custom render prop if provided. 25460 appender = (0,external_wp_element_namespaceObject.createElement)(CustomAppender, null); 25461 } else { 25462 const isParentSelected = selectedBlockClientId === rootClientId || !rootClientId && !selectedBlockClientId; 25463 25464 if (!isParentSelected) { 25465 return null; 25466 } 25467 25468 if (canInsertDefaultBlock) { 25469 // Render the default block appender when renderAppender has not been 25470 // provided and the context supports use of the default appender. 25471 appender = (0,external_wp_element_namespaceObject.createElement)(default_block_appender, { 25472 rootClientId: rootClientId 25473 }); 25474 } else { 25475 // Fallback in the case no renderAppender has been provided and the 25476 // default block can't be inserted. 25477 appender = (0,external_wp_element_namespaceObject.createElement)(button_block_appender, { 25478 rootClientId: rootClientId, 25479 className: "block-list-appender__toggle" 25480 }); 25481 } 25482 } 25483 25484 return (0,external_wp_element_namespaceObject.createElement)(TagName // A `tabIndex` is used on the wrapping `div` element in order to 25485 // force a focus event to occur when an appender `button` element 25486 // is clicked. In some browsers (Firefox, Safari), button clicks do 25487 // not emit a focus event, which could cause this event to propagate 25488 // unexpectedly. The `tabIndex` ensures that the interaction is 25489 // captured as a focus, without also adding an extra tab stop. 25490 // 25491 // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus 25492 , { 25493 tabIndex: -1, 25494 className: classnames_default()('block-list-appender wp-block', className) // Needed in case the whole editor is content editable (for multi 25495 // selection). It fixes an edge case where ArrowDown and ArrowRight 25496 // should collapse the selection to the end of that selection and 25497 // not into the appender. 25498 , 25499 contentEditable: false // The appender exists to let you add the first Paragraph before 25500 // any is inserted. To that end, this appender should visually be 25501 // presented as a block. That means theme CSS should style it as if 25502 // it were an empty paragraph block. That means a `wp-block` class to 25503 // ensure the width is correct, and a [data-block] attribute to ensure 25504 // the correct margin is applied, especially for classic themes which 25505 // have commonly targeted that attribute for margins. 25506 , 25507 "data-block": true 25508 }, appender); 25509 } 25510 25511 /* harmony default export */ var block_list_appender = ((0,external_wp_data_namespaceObject.withSelect)((select, _ref2) => { 25512 let { 25513 rootClientId 25514 } = _ref2; 25515 const { 25516 canInsertBlockType, 25517 getTemplateLock, 25518 getSelectedBlockClientId 25519 } = select(store); 25520 return { 25521 isLocked: !!getTemplateLock(rootClientId), 25522 canInsertDefaultBlock: canInsertBlockType((0,external_wp_blocks_namespaceObject.getDefaultBlockName)(), rootClientId), 25523 selectedBlockClientId: getSelectedBlockClientId() 25524 }; 25525 })(BlockListAppender)); 25526 25527 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/use-popover-scroll.js 25528 /** 25529 * WordPress dependencies 25530 */ 25531 25532 /** 25533 * Allow scrolling "through" popovers over the canvas. This is only called for 25534 * as long as the pointer is over a popover. Do not use React events because it 25535 * will bubble through portals. 25536 * 25537 * @param {Object} scrollableRef 25538 */ 25539 25540 function usePopoverScroll(scrollableRef) { 25541 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 25542 if (!scrollableRef) { 25543 return; 25544 } 25545 25546 function onWheel(event) { 25547 const { 25548 deltaX, 25549 deltaY 25550 } = event; 25551 scrollableRef.current.scrollBy(deltaX, deltaY); 25552 } // Tell the browser that we do not call event.preventDefault 25553 // See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners 25554 25555 25556 const options = { 25557 passive: true 25558 }; 25559 node.addEventListener('wheel', onWheel, options); 25560 return () => { 25561 node.removeEventListener('wheel', onWheel, options); 25562 }; 25563 }, [scrollableRef]); 25564 } 25565 25566 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/insertion-point.js 25567 25568 25569 /** 25570 * External dependencies 25571 */ 25572 25573 /** 25574 * WordPress dependencies 25575 */ 25576 25577 25578 25579 25580 25581 25582 /** 25583 * Internal dependencies 25584 */ 25585 25586 25587 25588 25589 25590 const InsertionPointOpenRef = (0,external_wp_element_namespaceObject.createContext)(); 25591 25592 function InsertionPointPopover(_ref) { 25593 let { 25594 __unstablePopoverSlot, 25595 __unstableContentRef 25596 } = _ref; 25597 const { 25598 selectBlock, 25599 hideInsertionPoint 25600 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 25601 const openRef = (0,external_wp_element_namespaceObject.useContext)(InsertionPointOpenRef); 25602 const ref = (0,external_wp_element_namespaceObject.useRef)(); 25603 const { 25604 orientation, 25605 previousClientId, 25606 nextClientId, 25607 rootClientId, 25608 isInserterShown 25609 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 25610 var _getBlockListSettings; 25611 25612 const { 25613 getBlockOrder, 25614 getBlockListSettings, 25615 getBlockInsertionPoint, 25616 isBlockBeingDragged, 25617 getPreviousBlockClientId, 25618 getNextBlockClientId 25619 } = select(store); 25620 const insertionPoint = getBlockInsertionPoint(); 25621 const order = getBlockOrder(insertionPoint.rootClientId); 25622 25623 if (!order.length) { 25624 return {}; 25625 } 25626 25627 let _previousClientId = order[insertionPoint.index - 1]; 25628 let _nextClientId = order[insertionPoint.index]; 25629 25630 while (isBlockBeingDragged(_previousClientId)) { 25631 _previousClientId = getPreviousBlockClientId(_previousClientId); 25632 } 25633 25634 while (isBlockBeingDragged(_nextClientId)) { 25635 _nextClientId = getNextBlockClientId(_nextClientId); 25636 } 25637 25638 return { 25639 previousClientId: _previousClientId, 25640 nextClientId: _nextClientId, 25641 orientation: ((_getBlockListSettings = getBlockListSettings(insertionPoint.rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical', 25642 rootClientId: insertionPoint.rootClientId, 25643 isInserterShown: insertionPoint === null || insertionPoint === void 0 ? void 0 : insertionPoint.__unstableWithInserter 25644 }; 25645 }, []); 25646 const previousElement = useBlockElement(previousClientId); 25647 const nextElement = useBlockElement(nextClientId); 25648 const isVertical = orientation === 'vertical'; 25649 const style = (0,external_wp_element_namespaceObject.useMemo)(() => { 25650 if (!previousElement && !nextElement) { 25651 return {}; 25652 } 25653 25654 const previousRect = previousElement ? previousElement.getBoundingClientRect() : null; 25655 const nextRect = nextElement ? nextElement.getBoundingClientRect() : null; 25656 25657 if (isVertical) { 25658 return { 25659 width: previousElement ? previousElement.offsetWidth : nextElement.offsetWidth, 25660 height: nextRect && previousRect ? nextRect.top - previousRect.bottom : 0 25661 }; 25662 } 25663 25664 let width = 0; 25665 25666 if (previousRect && nextRect) { 25667 width = (0,external_wp_i18n_namespaceObject.isRTL)() ? previousRect.left - nextRect.right : nextRect.left - previousRect.right; 25668 } 25669 25670 return { 25671 width, 25672 height: previousElement ? previousElement.offsetHeight : nextElement.offsetHeight 25673 }; 25674 }, [previousElement, nextElement]); 25675 const getAnchorRect = (0,external_wp_element_namespaceObject.useCallback)(() => { 25676 if (!previousElement && !nextElement) { 25677 return {}; 25678 } 25679 25680 const { 25681 ownerDocument 25682 } = previousElement || nextElement; 25683 const previousRect = previousElement ? previousElement.getBoundingClientRect() : null; 25684 const nextRect = nextElement ? nextElement.getBoundingClientRect() : null; 25685 25686 if (isVertical) { 25687 if ((0,external_wp_i18n_namespaceObject.isRTL)()) { 25688 return { 25689 top: previousRect ? previousRect.bottom : nextRect.top, 25690 left: previousRect ? previousRect.right : nextRect.right, 25691 right: previousRect ? previousRect.left : nextRect.left, 25692 bottom: nextRect ? nextRect.top : previousRect.bottom, 25693 ownerDocument 25694 }; 25695 } 25696 25697 return { 25698 top: previousRect ? previousRect.bottom : nextRect.top, 25699 left: previousRect ? previousRect.left : nextRect.left, 25700 right: previousRect ? previousRect.right : nextRect.right, 25701 bottom: nextRect ? nextRect.top : previousRect.bottom, 25702 ownerDocument 25703 }; 25704 } 25705 25706 if ((0,external_wp_i18n_namespaceObject.isRTL)()) { 25707 return { 25708 top: previousRect ? previousRect.top : nextRect.top, 25709 left: previousRect ? previousRect.left : nextRect.right, 25710 right: nextRect ? nextRect.right : previousRect.left, 25711 bottom: previousRect ? previousRect.bottom : nextRect.bottom, 25712 ownerDocument 25713 }; 25714 } 25715 25716 return { 25717 top: previousRect ? previousRect.top : nextRect.top, 25718 left: previousRect ? previousRect.right : nextRect.left, 25719 right: nextRect ? nextRect.left : previousRect.right, 25720 bottom: previousRect ? previousRect.bottom : nextRect.bottom, 25721 ownerDocument 25722 }; 25723 }, [previousElement, nextElement]); 25724 const popoverScrollRef = usePopoverScroll(__unstableContentRef); 25725 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)(); 25726 const className = classnames_default()('block-editor-block-list__insertion-point', 'is-' + orientation); 25727 25728 function onClick(event) { 25729 if (event.target === ref.current && nextClientId) { 25730 selectBlock(nextClientId, -1); 25731 } 25732 } 25733 25734 function onFocus(event) { 25735 // Only handle click on the wrapper specifically, and not an event 25736 // bubbled from the inserter itself. 25737 if (event.target !== ref.current) { 25738 openRef.current = true; 25739 } 25740 } 25741 25742 function maybeHideInserterPoint(event) { 25743 // Only hide the inserter if it's triggered on the wrapper, 25744 // and the inserter is not open. 25745 if (event.target === ref.current && !openRef.current) { 25746 hideInsertionPoint(); 25747 } 25748 } // Only show the in-between inserter between blocks, so when there's a 25749 // previous and a next element. 25750 25751 25752 const showInsertionPointInserter = previousElement && nextElement && isInserterShown; // Define animation variants for the line element. 25753 25754 const horizontalLine = { 25755 start: { 25756 width: 0, 25757 top: '50%', 25758 bottom: '50%', 25759 x: 0 25760 }, 25761 rest: { 25762 width: 4, 25763 top: 0, 25764 bottom: 0, 25765 x: -2 25766 }, 25767 hover: { 25768 width: 4, 25769 top: 0, 25770 bottom: 0, 25771 x: -2 25772 } 25773 }; 25774 const verticalLine = { 25775 start: { 25776 height: 0, 25777 left: '50%', 25778 right: '50%', 25779 y: 0 25780 }, 25781 rest: { 25782 height: 4, 25783 left: 0, 25784 right: 0, 25785 y: -2 25786 }, 25787 hover: { 25788 height: 4, 25789 left: 0, 25790 right: 0, 25791 y: -2 25792 } 25793 }; 25794 const lineVariants = { 25795 // Initial position starts from the center and invisible. 25796 start: { ...(!isVertical ? horizontalLine.start : verticalLine.start), 25797 opacity: 0 25798 }, 25799 // The line expands to fill the container. If the inserter is visible it 25800 // is delayed so it appears orchestrated. 25801 rest: { ...(!isVertical ? horizontalLine.rest : verticalLine.rest), 25802 opacity: 1, 25803 borderRadius: '2px', 25804 transition: { 25805 delay: showInsertionPointInserter ? 0.4 : 0 25806 } 25807 }, 25808 hover: { ...(!isVertical ? horizontalLine.hover : verticalLine.hover), 25809 opacity: 1, 25810 borderRadius: '2px', 25811 transition: { 25812 delay: 0.4 25813 } 25814 } 25815 }; 25816 const inserterVariants = { 25817 start: { 25818 scale: disableMotion ? 1 : 0 25819 }, 25820 rest: { 25821 scale: 1, 25822 transition: { 25823 delay: 0.2 25824 } 25825 } 25826 }; 25827 /* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */ 25828 // While ideally it would be enough to capture the 25829 // bubbling focus event from the Inserter, due to the 25830 // characteristics of click focusing of `button`s in 25831 // Firefox and Safari, it is not reliable. 25832 // 25833 // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus 25834 25835 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { 25836 ref: popoverScrollRef, 25837 noArrow: true, 25838 animate: false, 25839 getAnchorRect: getAnchorRect, 25840 focusOnMount: false, 25841 className: "block-editor-block-list__insertion-point-popover" // Render in the old slot if needed for backward compatibility, 25842 // otherwise render in place (not in the the default popover slot). 25843 , 25844 __unstableSlotName: __unstablePopoverSlot || null // Forces a remount of the popover when its position changes 25845 // This makes sure the popover doesn't animate from its previous position. 25846 , 25847 key: nextClientId + '--' + rootClientId 25848 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 25849 layout: !disableMotion, 25850 initial: disableMotion ? 'rest' : 'start', 25851 animate: "rest", 25852 whileHover: "hover", 25853 whileTap: "pressed", 25854 exit: "start", 25855 ref: ref, 25856 tabIndex: -1, 25857 onClick: onClick, 25858 onFocus: onFocus, 25859 className: classnames_default()(className, { 25860 'is-with-inserter': showInsertionPointInserter 25861 }), 25862 onHoverEnd: maybeHideInserterPoint, 25863 style: style 25864 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 25865 variants: lineVariants, 25866 className: "block-editor-block-list__insertion-point-indicator" 25867 }), showInsertionPointInserter && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 25868 variants: inserterVariants, 25869 className: classnames_default()('block-editor-block-list__insertion-point-inserter') 25870 }, (0,external_wp_element_namespaceObject.createElement)(inserter, { 25871 position: "bottom center", 25872 clientId: nextClientId, 25873 rootClientId: rootClientId, 25874 __experimentalIsQuick: true, 25875 onToggle: isOpen => { 25876 openRef.current = isOpen; 25877 }, 25878 onSelectOrClose: () => { 25879 openRef.current = false; 25880 } 25881 })))); 25882 /* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */ 25883 } 25884 25885 function InsertionPoint(_ref2) { 25886 let { 25887 children, 25888 __unstablePopoverSlot, 25889 __unstableContentRef 25890 } = _ref2; 25891 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => { 25892 return select(store).isBlockInsertionPointVisible(); 25893 }, []); 25894 return (0,external_wp_element_namespaceObject.createElement)(InsertionPointOpenRef.Provider, { 25895 value: (0,external_wp_element_namespaceObject.useRef)(false) 25896 }, isVisible && (0,external_wp_element_namespaceObject.createElement)(InsertionPointPopover, { 25897 __unstablePopoverSlot: __unstablePopoverSlot, 25898 __unstableContentRef: __unstableContentRef 25899 }), children); 25900 } 25901 25902 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-in-between-inserter.js 25903 /** 25904 * WordPress dependencies 25905 */ 25906 25907 25908 25909 /** 25910 * Internal dependencies 25911 */ 25912 25913 25914 25915 function useInBetweenInserter() { 25916 const openRef = (0,external_wp_element_namespaceObject.useContext)(InsertionPointOpenRef); 25917 const hasReducedUI = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings().hasReducedUI, []); 25918 const { 25919 getBlockListSettings, 25920 getBlockRootClientId, 25921 getBlockIndex, 25922 isBlockInsertionPointVisible, 25923 isMultiSelecting, 25924 getSelectedBlockClientIds, 25925 getTemplateLock 25926 } = (0,external_wp_data_namespaceObject.useSelect)(store); 25927 const { 25928 showInsertionPoint, 25929 hideInsertionPoint 25930 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 25931 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 25932 if (hasReducedUI) { 25933 return; 25934 } 25935 25936 function onMouseMove(event) { 25937 var _getBlockListSettings, _element$parentElemen; 25938 25939 if (openRef.current) { 25940 return; 25941 } 25942 25943 if (isMultiSelecting()) { 25944 return; 25945 } 25946 25947 if (!event.target.classList.contains('block-editor-block-list__layout')) { 25948 if (isBlockInsertionPointVisible()) { 25949 hideInsertionPoint(); 25950 } 25951 25952 return; 25953 } 25954 25955 let rootClientId; 25956 25957 if (!event.target.classList.contains('is-root-container')) { 25958 const blockElement = !!event.target.getAttribute('data-block') ? event.target : event.target.closest('[data-block]'); 25959 rootClientId = blockElement.getAttribute('data-block'); 25960 } // Don't set the insertion point if the template is locked. 25961 25962 25963 if (getTemplateLock(rootClientId)) { 25964 return; 25965 } 25966 25967 const orientation = ((_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical'; 25968 const rect = event.target.getBoundingClientRect(); 25969 const offsetTop = event.clientY - rect.top; 25970 const offsetLeft = event.clientX - rect.left; 25971 const children = Array.from(event.target.children); 25972 let element = children.find(blockEl => { 25973 return blockEl.classList.contains('wp-block') && orientation === 'vertical' && blockEl.offsetTop > offsetTop || blockEl.classList.contains('wp-block') && orientation === 'horizontal' && blockEl.offsetLeft > offsetLeft; 25974 }); 25975 25976 if (!element) { 25977 return; 25978 } // The block may be in an alignment wrapper, so check the first direct 25979 // child if the element has no ID. 25980 25981 25982 if (!element.id) { 25983 element = element.firstElementChild; 25984 25985 if (!element) { 25986 return; 25987 } 25988 } // Don't show the insertion point if a parent block has an "overlay" 25989 // See https://github.com/WordPress/gutenberg/pull/34012#pullrequestreview-727762337 25990 25991 25992 const parentOverlay = (_element$parentElemen = element.parentElement) === null || _element$parentElemen === void 0 ? void 0 : _element$parentElemen.closest('.block-editor-block-content-overlay.overlay-active'); 25993 25994 if (parentOverlay) { 25995 return; 25996 } 25997 25998 const clientId = element.id.slice('block-'.length); 25999 26000 if (!clientId) { 26001 return; 26002 } // Don't show the inserter when hovering above (conflicts with 26003 // block toolbar) or inside selected block(s). 26004 26005 26006 if (getSelectedBlockClientIds().includes(clientId)) { 26007 return; 26008 } 26009 26010 const elementRect = element.getBoundingClientRect(); 26011 26012 if (orientation === 'horizontal' && (event.clientY > elementRect.bottom || event.clientY < elementRect.top) || orientation === 'vertical' && (event.clientX > elementRect.right || event.clientX < elementRect.left)) { 26013 if (isBlockInsertionPointVisible()) { 26014 hideInsertionPoint(); 26015 } 26016 26017 return; 26018 } 26019 26020 const index = getBlockIndex(clientId); // Don't show the in-between inserter before the first block in 26021 // the list (preserves the original behaviour). 26022 26023 if (index === 0) { 26024 if (isBlockInsertionPointVisible()) { 26025 hideInsertionPoint(); 26026 } 26027 26028 return; 26029 } 26030 26031 showInsertionPoint(rootClientId, index, { 26032 __unstableWithInserter: true 26033 }); 26034 } 26035 26036 node.addEventListener('mousemove', onMouseMove); 26037 return () => { 26038 node.removeEventListener('mousemove', onMouseMove); 26039 }; 26040 }, [openRef, getBlockListSettings, getBlockRootClientId, getBlockIndex, isBlockInsertionPointVisible, isMultiSelecting, showInsertionPoint, hideInsertionPoint, getSelectedBlockClientIds]); 26041 } 26042 26043 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/pre-parse-patterns.js 26044 /** 26045 * WordPress dependencies 26046 */ 26047 26048 26049 /** 26050 * Internal dependencies 26051 */ 26052 26053 26054 26055 const requestIdleCallback = (() => { 26056 if (typeof window === 'undefined') { 26057 return callback => { 26058 setTimeout(() => callback(Date.now()), 0); 26059 }; 26060 } 26061 26062 return window.requestIdleCallback || window.requestAnimationFrame; 26063 })(); 26064 26065 const cancelIdleCallback = (() => { 26066 if (typeof window === 'undefined') { 26067 return clearTimeout; 26068 } 26069 26070 return window.cancelIdleCallback || window.cancelAnimationFrame; 26071 })(); 26072 26073 function usePreParsePatterns() { 26074 const patterns = (0,external_wp_data_namespaceObject.useSelect)(_select => _select(store).getSettings().__experimentalBlockPatterns, []); 26075 (0,external_wp_element_namespaceObject.useEffect)(() => { 26076 if (!(patterns !== null && patterns !== void 0 && patterns.length)) { 26077 return; 26078 } 26079 26080 let handle; 26081 let index = -1; 26082 26083 const callback = () => { 26084 index++; 26085 26086 if (index >= patterns.length) { 26087 return; 26088 } 26089 26090 (0,external_wp_data_namespaceObject.select)(store).__experimentalGetParsedPattern(patterns[index].name); 26091 26092 handle = requestIdleCallback(callback); 26093 }; 26094 26095 handle = requestIdleCallback(callback); 26096 return () => cancelIdleCallback(handle); 26097 }, [patterns]); 26098 return null; 26099 } 26100 26101 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-block-display-information/index.js 26102 /** 26103 * WordPress dependencies 26104 */ 26105 26106 26107 /** 26108 * Internal dependencies 26109 */ 26110 26111 26112 /** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */ 26113 26114 /** 26115 * Contains basic block's information for display reasons. 26116 * 26117 * @typedef {Object} WPBlockDisplayInformation 26118 * 26119 * @property {string} title Human-readable block type label. 26120 * @property {WPIcon} icon Block type icon. 26121 * @property {string} description A detailed block type description. 26122 */ 26123 26124 /** 26125 * Hook used to try to find a matching block variation and return 26126 * the appropriate information for display reasons. In order to 26127 * to try to find a match we need to things: 26128 * 1. Block's client id to extract it's current attributes. 26129 * 2. A block variation should have set `isActive` prop to a proper function. 26130 * 26131 * If for any reason a block variaton match cannot be found, 26132 * the returned information come from the Block Type. 26133 * If no blockType is found with the provided clientId, returns null. 26134 * 26135 * @param {string} clientId Block's client id. 26136 * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found. 26137 */ 26138 26139 function useBlockDisplayInformation(clientId) { 26140 return (0,external_wp_data_namespaceObject.useSelect)(select => { 26141 if (!clientId) return null; 26142 const { 26143 getBlockName, 26144 getBlockAttributes 26145 } = select(store); 26146 const { 26147 getBlockType, 26148 getActiveBlockVariation 26149 } = select(external_wp_blocks_namespaceObject.store); 26150 const blockName = getBlockName(clientId); 26151 const blockType = getBlockType(blockName); 26152 if (!blockType) return null; 26153 const attributes = getBlockAttributes(clientId); 26154 const match = getActiveBlockVariation(blockName, attributes); 26155 const blockTypeInfo = { 26156 title: blockType.title, 26157 icon: blockType.icon, 26158 description: blockType.description, 26159 anchor: attributes === null || attributes === void 0 ? void 0 : attributes.anchor 26160 }; 26161 if (!match) return blockTypeInfo; 26162 return { 26163 title: match.title || blockType.title, 26164 icon: match.icon || blockType.icon, 26165 description: match.description || blockType.description 26166 }; 26167 }, [clientId]); 26168 } 26169 26170 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-title/use-block-display-title.js 26171 /** 26172 * External dependencies 26173 */ 26174 26175 /** 26176 * WordPress dependencies 26177 */ 26178 26179 26180 26181 /** 26182 * Internal dependencies 26183 */ 26184 26185 26186 26187 /** 26188 * Returns the block's configured title as a string, or empty if the title 26189 * cannot be determined. 26190 * 26191 * @example 26192 * 26193 * ```js 26194 * useBlockDisplayTitle( 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1', 17 ); 26195 * ``` 26196 * 26197 * @param {string} clientId Client ID of block. 26198 * @param {number|undefined} maximumLength The maximum length that the block title string may be before truncated. 26199 * @return {?string} Block title. 26200 */ 26201 26202 function useBlockDisplayTitle(clientId, maximumLength) { 26203 const { 26204 attributes, 26205 name, 26206 reusableBlockTitle 26207 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 26208 if (!clientId) { 26209 return {}; 26210 } 26211 26212 const { 26213 getBlockName, 26214 getBlockAttributes, 26215 __experimentalGetReusableBlockTitle 26216 } = select(store); 26217 const blockName = getBlockName(clientId); 26218 26219 if (!blockName) { 26220 return {}; 26221 } 26222 26223 const isReusable = (0,external_wp_blocks_namespaceObject.isReusableBlock)((0,external_wp_blocks_namespaceObject.getBlockType)(blockName)); 26224 return { 26225 attributes: getBlockAttributes(clientId), 26226 name: blockName, 26227 reusableBlockTitle: isReusable && __experimentalGetReusableBlockTitle(getBlockAttributes(clientId).ref) 26228 }; 26229 }, [clientId]); 26230 const blockInformation = useBlockDisplayInformation(clientId); 26231 26232 if (!name || !blockInformation) { 26233 return null; 26234 } 26235 26236 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name); 26237 const blockLabel = blockType ? (0,external_wp_blocks_namespaceObject.__experimentalGetBlockLabel)(blockType, attributes) : null; 26238 const label = reusableBlockTitle || blockLabel; // Label will fallback to the title if no label is defined for the current 26239 // label context. If the label is defined we prioritize it over a 26240 // possible block variation title match. 26241 26242 const blockTitle = label && label !== blockType.title ? label : blockInformation.title; 26243 26244 if (maximumLength && maximumLength > 0) { 26245 return (0,external_lodash_namespaceObject.truncate)(blockTitle, { 26246 length: maximumLength 26247 }); 26248 } 26249 26250 return blockTitle; 26251 } 26252 26253 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-title/index.js 26254 /** 26255 * Internal dependencies 26256 */ 26257 26258 /** 26259 * Renders the block's configured title as a string, or empty if the title 26260 * cannot be determined. 26261 * 26262 * @example 26263 * 26264 * ```jsx 26265 * <BlockTitle clientId="afd1cb17-2c08-4e7a-91be-007ba7ddc3a1" maximumLength={ 17 }/> 26266 * ``` 26267 * 26268 * @param {Object} props 26269 * @param {string} props.clientId Client ID of block. 26270 * @param {number|undefined} props.maximumLength The maximum length that the block title string may be before truncated. 26271 * 26272 * @return {JSX.Element} Block title. 26273 */ 26274 26275 function BlockTitle(_ref) { 26276 let { 26277 clientId, 26278 maximumLength 26279 } = _ref; 26280 return useBlockDisplayTitle(clientId, maximumLength); 26281 } 26282 26283 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/use-scroll-when-dragging.js 26284 /** 26285 * WordPress dependencies 26286 */ 26287 26288 26289 const SCROLL_INACTIVE_DISTANCE_PX = 50; 26290 const SCROLL_INTERVAL_MS = 25; 26291 const PIXELS_PER_SECOND_PER_PERCENTAGE = 1000; 26292 const VELOCITY_MULTIPLIER = PIXELS_PER_SECOND_PER_PERCENTAGE * (SCROLL_INTERVAL_MS / 1000); 26293 /** 26294 * React hook that scrolls the scroll container when a block is being dragged. 26295 * 26296 * @return {Function[]} `startScrolling`, `scrollOnDragOver`, `stopScrolling` 26297 * functions to be called in `onDragStart`, `onDragOver` 26298 * and `onDragEnd` events respectively. 26299 */ 26300 26301 function useScrollWhenDragging() { 26302 const dragStartY = (0,external_wp_element_namespaceObject.useRef)(null); 26303 const velocityY = (0,external_wp_element_namespaceObject.useRef)(null); 26304 const scrollParentY = (0,external_wp_element_namespaceObject.useRef)(null); 26305 const scrollEditorInterval = (0,external_wp_element_namespaceObject.useRef)(null); // Clear interval when unmounting. 26306 26307 (0,external_wp_element_namespaceObject.useEffect)(() => () => { 26308 if (scrollEditorInterval.current) { 26309 clearInterval(scrollEditorInterval.current); 26310 scrollEditorInterval.current = null; 26311 } 26312 }, []); 26313 const startScrolling = (0,external_wp_element_namespaceObject.useCallback)(event => { 26314 dragStartY.current = event.clientY; // Find nearest parent(s) to scroll. 26315 26316 scrollParentY.current = (0,external_wp_dom_namespaceObject.getScrollContainer)(event.target); 26317 scrollEditorInterval.current = setInterval(() => { 26318 if (scrollParentY.current && velocityY.current) { 26319 const newTop = scrollParentY.current.scrollTop + velocityY.current; // Setting `behavior: 'smooth'` as a scroll property seems to hurt performance. 26320 // Better to use a small scroll interval. 26321 26322 scrollParentY.current.scroll({ 26323 top: newTop 26324 }); 26325 } 26326 }, SCROLL_INTERVAL_MS); 26327 }, []); 26328 const scrollOnDragOver = (0,external_wp_element_namespaceObject.useCallback)(event => { 26329 if (!scrollParentY.current) { 26330 return; 26331 } 26332 26333 const scrollParentHeight = scrollParentY.current.offsetHeight; 26334 const offsetDragStartPosition = dragStartY.current - scrollParentY.current.offsetTop; 26335 const offsetDragPosition = event.clientY - scrollParentY.current.offsetTop; 26336 26337 if (event.clientY > offsetDragStartPosition) { 26338 // User is dragging downwards. 26339 const moveableDistance = Math.max(scrollParentHeight - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0); 26340 const dragDistance = Math.max(offsetDragPosition - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0); 26341 const distancePercentage = dragDistance / moveableDistance; 26342 velocityY.current = VELOCITY_MULTIPLIER * distancePercentage; 26343 } else if (event.clientY < offsetDragStartPosition) { 26344 // User is dragging upwards. 26345 const moveableDistance = Math.max(offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0); 26346 const dragDistance = Math.max(offsetDragStartPosition - offsetDragPosition - SCROLL_INACTIVE_DISTANCE_PX, 0); 26347 const distancePercentage = dragDistance / moveableDistance; 26348 velocityY.current = -VELOCITY_MULTIPLIER * distancePercentage; 26349 } else { 26350 velocityY.current = 0; 26351 } 26352 }, []); 26353 26354 const stopScrolling = () => { 26355 dragStartY.current = null; 26356 scrollParentY.current = null; 26357 26358 if (scrollEditorInterval.current) { 26359 clearInterval(scrollEditorInterval.current); 26360 scrollEditorInterval.current = null; 26361 } 26362 }; 26363 26364 return [startScrolling, scrollOnDragOver, stopScrolling]; 26365 } 26366 26367 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/index.js 26368 26369 26370 /** 26371 * WordPress dependencies 26372 */ 26373 26374 26375 26376 26377 /** 26378 * Internal dependencies 26379 */ 26380 26381 26382 26383 26384 26385 const BlockDraggable = _ref => { 26386 let { 26387 children, 26388 clientIds, 26389 cloneClassname, 26390 onDragStart, 26391 onDragEnd 26392 } = _ref; 26393 const { 26394 srcRootClientId, 26395 isDraggable, 26396 icon 26397 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 26398 var _getBlockType; 26399 26400 const { 26401 canMoveBlocks, 26402 getBlockRootClientId, 26403 getBlockName 26404 } = select(store); 26405 const rootClientId = getBlockRootClientId(clientIds[0]); 26406 const blockName = getBlockName(clientIds[0]); 26407 return { 26408 srcRootClientId: rootClientId, 26409 isDraggable: canMoveBlocks(clientIds, rootClientId), 26410 icon: (_getBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon 26411 }; 26412 }, [clientIds]); 26413 const isDragging = (0,external_wp_element_namespaceObject.useRef)(false); 26414 const [startScrolling, scrollOnDragOver, stopScrolling] = useScrollWhenDragging(); 26415 const { 26416 startDraggingBlocks, 26417 stopDraggingBlocks 26418 } = (0,external_wp_data_namespaceObject.useDispatch)(store); // Stop dragging blocks if the block draggable is unmounted. 26419 26420 (0,external_wp_element_namespaceObject.useEffect)(() => { 26421 return () => { 26422 if (isDragging.current) { 26423 stopDraggingBlocks(); 26424 } 26425 }; 26426 }, []); 26427 26428 if (!isDraggable) { 26429 return children({ 26430 isDraggable: false 26431 }); 26432 } 26433 26434 const transferData = { 26435 type: 'block', 26436 srcClientIds: clientIds, 26437 srcRootClientId 26438 }; 26439 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Draggable, { 26440 cloneClassname: cloneClassname, 26441 __experimentalTransferDataType: "wp-blocks", 26442 transferData: transferData, 26443 onDragStart: event => { 26444 startDraggingBlocks(clientIds); 26445 isDragging.current = true; 26446 startScrolling(event); 26447 26448 if (onDragStart) { 26449 onDragStart(); 26450 } 26451 }, 26452 onDragOver: scrollOnDragOver, 26453 onDragEnd: () => { 26454 stopDraggingBlocks(); 26455 isDragging.current = false; 26456 stopScrolling(); 26457 26458 if (onDragEnd) { 26459 onDragEnd(); 26460 } 26461 }, 26462 __experimentalDragComponent: (0,external_wp_element_namespaceObject.createElement)(BlockDraggableChip, { 26463 count: clientIds.length, 26464 icon: icon 26465 }) 26466 }, _ref2 => { 26467 let { 26468 onDraggableStart, 26469 onDraggableEnd 26470 } = _ref2; 26471 return children({ 26472 draggable: true, 26473 onDragStart: onDraggableStart, 26474 onDragEnd: onDraggableEnd 26475 }); 26476 }); 26477 }; 26478 26479 /* harmony default export */ var block_draggable = (BlockDraggable); 26480 26481 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/block-selection-button.js 26482 26483 26484 26485 /** 26486 * External dependencies 26487 */ 26488 26489 /** 26490 * WordPress dependencies 26491 */ 26492 26493 26494 26495 26496 26497 26498 26499 26500 26501 26502 /** 26503 * Internal dependencies 26504 */ 26505 26506 26507 26508 26509 26510 26511 /** 26512 * Block selection button component, displaying the label of the block. If the block 26513 * descends from a root block, a button is displayed enabling the user to select 26514 * the root block. 26515 * 26516 * @param {string} props Component props. 26517 * @param {string} props.clientId Client ID of block. 26518 * 26519 * @return {WPComponent} The component to be rendered. 26520 */ 26521 26522 function BlockSelectionButton(_ref) { 26523 let { 26524 clientId, 26525 rootClientId, 26526 blockElement 26527 } = _ref; 26528 const blockInformation = useBlockDisplayInformation(clientId); 26529 const selected = (0,external_wp_data_namespaceObject.useSelect)(select => { 26530 var _getBlockListSettings; 26531 26532 const { 26533 getBlock, 26534 getBlockIndex, 26535 hasBlockMovingClientId, 26536 getBlockListSettings 26537 } = select(store); 26538 const index = getBlockIndex(clientId); 26539 const { 26540 name, 26541 attributes 26542 } = getBlock(clientId); 26543 const blockMovingMode = hasBlockMovingClientId(); 26544 return { 26545 index, 26546 name, 26547 attributes, 26548 blockMovingMode, 26549 orientation: (_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation 26550 }; 26551 }, [clientId, rootClientId]); 26552 const { 26553 index, 26554 name, 26555 attributes, 26556 blockMovingMode, 26557 orientation 26558 } = selected; 26559 const { 26560 setNavigationMode, 26561 removeBlock 26562 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 26563 const ref = (0,external_wp_element_namespaceObject.useRef)(); 26564 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name); 26565 const label = (0,external_wp_blocks_namespaceObject.__experimentalGetAccessibleBlockLabel)(blockType, attributes, index + 1, orientation); // Focus the breadcrumb in navigation mode. 26566 26567 (0,external_wp_element_namespaceObject.useEffect)(() => { 26568 ref.current.focus(); 26569 (0,external_wp_a11y_namespaceObject.speak)(label); 26570 }, [label]); 26571 const { 26572 hasBlockMovingClientId, 26573 getBlockIndex, 26574 getBlockRootClientId, 26575 getClientIdsOfDescendants, 26576 getSelectedBlockClientId, 26577 getMultiSelectedBlocksEndClientId, 26578 getPreviousBlockClientId, 26579 getNextBlockClientId, 26580 isNavigationMode 26581 } = (0,external_wp_data_namespaceObject.useSelect)(store); 26582 const { 26583 selectBlock, 26584 clearSelectedBlock, 26585 setBlockMovingClientId, 26586 moveBlockToPosition 26587 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 26588 26589 function onKeyDown(event) { 26590 const { 26591 keyCode 26592 } = event; 26593 const isUp = keyCode === external_wp_keycodes_namespaceObject.UP; 26594 const isDown = keyCode === external_wp_keycodes_namespaceObject.DOWN; 26595 const isLeft = keyCode === external_wp_keycodes_namespaceObject.LEFT; 26596 const isRight = keyCode === external_wp_keycodes_namespaceObject.RIGHT; 26597 const isTab = keyCode === external_wp_keycodes_namespaceObject.TAB; 26598 const isEscape = keyCode === external_wp_keycodes_namespaceObject.ESCAPE; 26599 const isEnter = keyCode === external_wp_keycodes_namespaceObject.ENTER; 26600 const isSpace = keyCode === external_wp_keycodes_namespaceObject.SPACE; 26601 const isShift = event.shiftKey; 26602 26603 if (keyCode === external_wp_keycodes_namespaceObject.BACKSPACE || keyCode === external_wp_keycodes_namespaceObject.DELETE) { 26604 removeBlock(clientId); 26605 event.preventDefault(); 26606 return; 26607 } 26608 26609 const selectedBlockClientId = getSelectedBlockClientId(); 26610 const selectionEndClientId = getMultiSelectedBlocksEndClientId(); 26611 const selectionBeforeEndClientId = getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId); 26612 const selectionAfterEndClientId = getNextBlockClientId(selectionEndClientId || selectedBlockClientId); 26613 const navigateUp = isTab && isShift || isUp; 26614 const navigateDown = isTab && !isShift || isDown; // Move out of current nesting level (no effect if at root level). 26615 26616 const navigateOut = isLeft; // Move into next nesting level (no effect if the current block has no innerBlocks). 26617 26618 const navigateIn = isRight; 26619 let focusedBlockUid; 26620 26621 if (navigateUp) { 26622 focusedBlockUid = selectionBeforeEndClientId; 26623 } else if (navigateDown) { 26624 focusedBlockUid = selectionAfterEndClientId; 26625 } else if (navigateOut) { 26626 var _getBlockRootClientId; 26627 26628 focusedBlockUid = (_getBlockRootClientId = getBlockRootClientId(selectedBlockClientId)) !== null && _getBlockRootClientId !== void 0 ? _getBlockRootClientId : selectedBlockClientId; 26629 } else if (navigateIn) { 26630 var _getClientIdsOfDescen; 26631 26632 focusedBlockUid = (_getClientIdsOfDescen = getClientIdsOfDescendants([selectedBlockClientId])[0]) !== null && _getClientIdsOfDescen !== void 0 ? _getClientIdsOfDescen : selectedBlockClientId; 26633 } 26634 26635 const startingBlockClientId = hasBlockMovingClientId(); 26636 26637 if (isEscape && isNavigationMode()) { 26638 clearSelectedBlock(); 26639 event.preventDefault(); 26640 } 26641 26642 if (isEscape && startingBlockClientId && !event.defaultPrevented) { 26643 setBlockMovingClientId(null); 26644 event.preventDefault(); 26645 } 26646 26647 if ((isEnter || isSpace) && startingBlockClientId) { 26648 const sourceRoot = getBlockRootClientId(startingBlockClientId); 26649 const destRoot = getBlockRootClientId(selectedBlockClientId); 26650 const sourceBlockIndex = getBlockIndex(startingBlockClientId); 26651 let destinationBlockIndex = getBlockIndex(selectedBlockClientId); 26652 26653 if (sourceBlockIndex < destinationBlockIndex && sourceRoot === destRoot) { 26654 destinationBlockIndex -= 1; 26655 } 26656 26657 moveBlockToPosition(startingBlockClientId, sourceRoot, destRoot, destinationBlockIndex); 26658 selectBlock(startingBlockClientId); 26659 setBlockMovingClientId(null); 26660 } 26661 26662 if (navigateDown || navigateUp || navigateOut || navigateIn) { 26663 if (focusedBlockUid) { 26664 event.preventDefault(); 26665 selectBlock(focusedBlockUid); 26666 } else if (isTab && selectedBlockClientId) { 26667 let nextTabbable; 26668 26669 if (navigateDown) { 26670 nextTabbable = blockElement; 26671 26672 do { 26673 nextTabbable = external_wp_dom_namespaceObject.focus.tabbable.findNext(nextTabbable); 26674 } while (nextTabbable && blockElement.contains(nextTabbable)); 26675 26676 if (!nextTabbable) { 26677 nextTabbable = blockElement.ownerDocument.defaultView.frameElement; 26678 nextTabbable = external_wp_dom_namespaceObject.focus.tabbable.findNext(nextTabbable); 26679 } 26680 } else { 26681 nextTabbable = external_wp_dom_namespaceObject.focus.tabbable.findPrevious(blockElement); 26682 } 26683 26684 if (nextTabbable) { 26685 event.preventDefault(); 26686 nextTabbable.focus(); 26687 clearSelectedBlock(); 26688 } 26689 } 26690 } 26691 } 26692 26693 const classNames = classnames_default()('block-editor-block-list__block-selection-button', { 26694 'is-block-moving-mode': !!blockMovingMode 26695 }); 26696 26697 const dragHandleLabel = (0,external_wp_i18n_namespaceObject.__)('Drag'); 26698 26699 return (0,external_wp_element_namespaceObject.createElement)("div", { 26700 className: classNames 26701 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, { 26702 justify: "center", 26703 className: "block-editor-block-list__block-selection-button__content" 26704 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(block_icon, { 26705 icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon, 26706 showColors: true 26707 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(block_draggable, { 26708 clientIds: [clientId] 26709 }, draggableProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({ 26710 icon: drag_handle, 26711 className: "block-selection-button_drag-handle", 26712 "aria-hidden": "true", 26713 label: dragHandleLabel // Should not be able to tab to drag handle as this 26714 // button can only be used with a pointer device. 26715 , 26716 tabIndex: "-1" 26717 }, draggableProps)))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 26718 ref: ref, 26719 onClick: () => setNavigationMode(false), 26720 onKeyDown: onKeyDown, 26721 label: label, 26722 className: "block-selection-button_select-button" 26723 }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, { 26724 clientId: clientId, 26725 maximumLength: 35 26726 }))))); 26727 } 26728 26729 /* harmony default export */ var block_selection_button = (BlockSelectionButton); 26730 26731 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/navigable-toolbar/index.js 26732 26733 26734 26735 /** 26736 * WordPress dependencies 26737 */ 26738 26739 26740 26741 26742 26743 26744 function hasOnlyToolbarItem(elements) { 26745 const dataProp = 'toolbarItem'; 26746 return !elements.some(element => !(dataProp in element.dataset)); 26747 } 26748 26749 function getAllToolbarItemsIn(container) { 26750 return Array.from(container.querySelectorAll('[data-toolbar-item]')); 26751 } 26752 26753 function hasFocusWithin(container) { 26754 return container.contains(container.ownerDocument.activeElement); 26755 } 26756 26757 function focusFirstTabbableIn(container) { 26758 const [firstTabbable] = external_wp_dom_namespaceObject.focus.tabbable.find(container); 26759 26760 if (firstTabbable) { 26761 firstTabbable.focus(); 26762 } 26763 } 26764 26765 function useIsAccessibleToolbar(ref) { 26766 /* 26767 * By default, we'll assume the starting accessible state of the Toolbar 26768 * is true, as it seems to be the most common case. 26769 * 26770 * Transitioning from an (initial) false to true state causes the 26771 * <Toolbar /> component to mount twice, which is causing undesired 26772 * side-effects. These side-effects appear to only affect certain 26773 * E2E tests. 26774 * 26775 * This was initial discovered in this pull-request: 26776 * https://github.com/WordPress/gutenberg/pull/23425 26777 */ 26778 const initialAccessibleToolbarState = true; // By default, it's gonna render NavigableMenu. If all the tabbable elements 26779 // inside the toolbar are ToolbarItem components (or derived components like 26780 // ToolbarButton), then we can wrap them with the accessible Toolbar 26781 // component. 26782 26783 const [isAccessibleToolbar, setIsAccessibleToolbar] = (0,external_wp_element_namespaceObject.useState)(initialAccessibleToolbarState); 26784 const determineIsAccessibleToolbar = (0,external_wp_element_namespaceObject.useCallback)(() => { 26785 const tabbables = external_wp_dom_namespaceObject.focus.tabbable.find(ref.current); 26786 const onlyToolbarItem = hasOnlyToolbarItem(tabbables); 26787 26788 if (!onlyToolbarItem) { 26789 external_wp_deprecated_default()('Using custom components as toolbar controls', { 26790 since: '5.6', 26791 alternative: 'ToolbarItem, ToolbarButton or ToolbarDropdownMenu components', 26792 link: 'https://developer.wordpress.org/block-editor/components/toolbar-button/#inside-blockcontrols' 26793 }); 26794 } 26795 26796 setIsAccessibleToolbar(onlyToolbarItem); 26797 }, []); 26798 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 26799 // Toolbar buttons may be rendered asynchronously, so we use 26800 // MutationObserver to check if the toolbar subtree has been modified. 26801 const observer = new window.MutationObserver(determineIsAccessibleToolbar); 26802 observer.observe(ref.current, { 26803 childList: true, 26804 subtree: true 26805 }); 26806 return () => observer.disconnect(); 26807 }, [isAccessibleToolbar]); 26808 return isAccessibleToolbar; 26809 } 26810 26811 function useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, defaultIndex, onIndexChange) { 26812 // Make sure we don't use modified versions of this prop. 26813 const [initialFocusOnMount] = (0,external_wp_element_namespaceObject.useState)(focusOnMount); 26814 const [initialIndex] = (0,external_wp_element_namespaceObject.useState)(defaultIndex); 26815 const focusToolbar = (0,external_wp_element_namespaceObject.useCallback)(() => { 26816 focusFirstTabbableIn(ref.current); 26817 }, []); // Focus on toolbar when pressing alt+F10 when the toolbar is visible. 26818 26819 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/block-editor/focus-toolbar', focusToolbar); 26820 (0,external_wp_element_namespaceObject.useEffect)(() => { 26821 if (initialFocusOnMount) { 26822 focusToolbar(); 26823 } 26824 }, [isAccessibleToolbar, initialFocusOnMount, focusToolbar]); 26825 (0,external_wp_element_namespaceObject.useEffect)(() => { 26826 // If initialIndex is passed, we focus on that toolbar item when the 26827 // toolbar gets mounted and initial focus is not forced. 26828 // We have to wait for the next browser paint because block controls aren't 26829 // rendered right away when the toolbar gets mounted. 26830 let raf = 0; 26831 26832 if (initialIndex && !initialFocusOnMount) { 26833 raf = window.requestAnimationFrame(() => { 26834 const items = getAllToolbarItemsIn(ref.current); 26835 const index = initialIndex || 0; 26836 26837 if (items[index] && hasFocusWithin(ref.current)) { 26838 items[index].focus(); 26839 } 26840 }); 26841 } 26842 26843 return () => { 26844 window.cancelAnimationFrame(raf); 26845 if (!onIndexChange || !ref.current) return; // When the toolbar element is unmounted and onIndexChange is passed, we 26846 // pass the focused toolbar item index so it can be hydrated later. 26847 26848 const items = getAllToolbarItemsIn(ref.current); 26849 const index = items.findIndex(item => item.tabIndex === 0); 26850 onIndexChange(index); 26851 }; 26852 }, [initialIndex, initialFocusOnMount]); 26853 } 26854 26855 function NavigableToolbar(_ref) { 26856 let { 26857 children, 26858 focusOnMount, 26859 __experimentalInitialIndex: initialIndex, 26860 __experimentalOnIndexChange: onIndexChange, 26861 ...props 26862 } = _ref; 26863 const ref = (0,external_wp_element_namespaceObject.useRef)(); 26864 const isAccessibleToolbar = useIsAccessibleToolbar(ref); 26865 useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, initialIndex, onIndexChange); 26866 26867 if (isAccessibleToolbar) { 26868 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Toolbar, _extends({ 26869 label: props['aria-label'], 26870 ref: ref 26871 }, props), children); 26872 } 26873 26874 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, _extends({ 26875 orientation: "horizontal", 26876 role: "toolbar", 26877 ref: ref 26878 }, props), children); 26879 } 26880 26881 /* harmony default export */ var navigable_toolbar = (NavigableToolbar); 26882 26883 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-right.js 26884 26885 26886 /** 26887 * WordPress dependencies 26888 */ 26889 26890 const chevronRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 26891 xmlns: "http://www.w3.org/2000/svg", 26892 viewBox: "0 0 24 24" 26893 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 26894 d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" 26895 })); 26896 /* harmony default export */ var chevron_right = (chevronRight); 26897 26898 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-left.js 26899 26900 26901 /** 26902 * WordPress dependencies 26903 */ 26904 26905 const chevronLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 26906 xmlns: "http://www.w3.org/2000/svg", 26907 viewBox: "0 0 24 24" 26908 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 26909 d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" 26910 })); 26911 /* harmony default export */ var chevron_left = (chevronLeft); 26912 26913 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-up.js 26914 26915 26916 /** 26917 * WordPress dependencies 26918 */ 26919 26920 const chevronUp = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 26921 viewBox: "0 0 24 24", 26922 xmlns: "http://www.w3.org/2000/svg" 26923 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 26924 d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z" 26925 })); 26926 /* harmony default export */ var chevron_up = (chevronUp); 26927 26928 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-down.js 26929 26930 26931 /** 26932 * WordPress dependencies 26933 */ 26934 26935 const chevronDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 26936 viewBox: "0 0 24 24", 26937 xmlns: "http://www.w3.org/2000/svg" 26938 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 26939 d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" 26940 })); 26941 /* harmony default export */ var chevron_down = (chevronDown); 26942 26943 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/mover-description.js 26944 /** 26945 * WordPress dependencies 26946 */ 26947 26948 /** 26949 * Return a label for the block movement controls depending on block position. 26950 * 26951 * @param {number} selectedCount Number of blocks selected. 26952 * @param {string} type Block type - in the case of a single block, should 26953 * define its 'type'. I.e. 'Text', 'Heading', 'Image' etc. 26954 * @param {number} firstIndex The index (position - 1) of the first block selected. 26955 * @param {boolean} isFirst This is the first block. 26956 * @param {boolean} isLast This is the last block. 26957 * @param {number} dir Direction of movement (> 0 is considered to be going 26958 * down, < 0 is up). 26959 * @param {string} orientation The orientation of the block movers, vertical or 26960 * horizontal. 26961 * 26962 * @return {string} Label for the block movement controls. 26963 */ 26964 26965 function getBlockMoverDescription(selectedCount, type, firstIndex, isFirst, isLast, dir, orientation) { 26966 const position = firstIndex + 1; 26967 26968 const getMovementDirection = moveDirection => { 26969 if (moveDirection === 'up') { 26970 if (orientation === 'horizontal') { 26971 return (0,external_wp_i18n_namespaceObject.isRTL)() ? 'right' : 'left'; 26972 } 26973 26974 return 'up'; 26975 } else if (moveDirection === 'down') { 26976 if (orientation === 'horizontal') { 26977 return (0,external_wp_i18n_namespaceObject.isRTL)() ? 'left' : 'right'; 26978 } 26979 26980 return 'down'; 26981 } 26982 26983 return null; 26984 }; 26985 26986 if (selectedCount > 1) { 26987 return getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir); 26988 } 26989 26990 if (isFirst && isLast) { 26991 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Type of block (i.e. Text, Image etc) 26992 (0,external_wp_i18n_namespaceObject.__)('Block %s is the only block, and cannot be moved'), type); 26993 } 26994 26995 if (dir > 0 && !isLast) { 26996 // Moving down. 26997 const movementDirection = getMovementDirection('down'); 26998 26999 if (movementDirection === 'down') { 27000 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position 27001 (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d down to position %3$d'), type, position, position + 1); 27002 } 27003 27004 if (movementDirection === 'left') { 27005 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position 27006 (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d left to position %3$d'), type, position, position + 1); 27007 } 27008 27009 if (movementDirection === 'right') { 27010 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position 27011 (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d right to position %3$d'), type, position, position + 1); 27012 } 27013 } 27014 27015 if (dir > 0 && isLast) { 27016 // Moving down, and is the last item. 27017 const movementDirection = getMovementDirection('down'); 27018 27019 if (movementDirection === 'down') { 27020 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc) 27021 (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the end of the content and can’t be moved down'), type); 27022 } 27023 27024 if (movementDirection === 'left') { 27025 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc) 27026 (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the end of the content and can’t be moved left'), type); 27027 } 27028 27029 if (movementDirection === 'right') { 27030 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc) 27031 (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the end of the content and can’t be moved right'), type); 27032 } 27033 } 27034 27035 if (dir < 0 && !isFirst) { 27036 // Moving up. 27037 const movementDirection = getMovementDirection('up'); 27038 27039 if (movementDirection === 'up') { 27040 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position 27041 (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d up to position %3$d'), type, position, position - 1); 27042 } 27043 27044 if (movementDirection === 'left') { 27045 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position 27046 (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d left to position %3$d'), type, position, position - 1); 27047 } 27048 27049 if (movementDirection === 'right') { 27050 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position 27051 (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d right to position %3$d'), type, position, position - 1); 27052 } 27053 } 27054 27055 if (dir < 0 && isFirst) { 27056 // Moving up, and is the first item. 27057 const movementDirection = getMovementDirection('up'); 27058 27059 if (movementDirection === 'up') { 27060 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc) 27061 (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the beginning of the content and can’t be moved up'), type); 27062 } 27063 27064 if (movementDirection === 'left') { 27065 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc) 27066 (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the beginning of the content and can’t be moved left'), type); 27067 } 27068 27069 if (movementDirection === 'right') { 27070 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc) 27071 (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the beginning of the content and can’t be moved right'), type); 27072 } 27073 } 27074 } 27075 /** 27076 * Return a label for the block movement controls depending on block position. 27077 * 27078 * @param {number} selectedCount Number of blocks selected. 27079 * @param {number} firstIndex The index (position - 1) of the first block selected. 27080 * @param {boolean} isFirst This is the first block. 27081 * @param {boolean} isLast This is the last block. 27082 * @param {number} dir Direction of movement (> 0 is considered to be going 27083 * down, < 0 is up). 27084 * 27085 * @return {string} Label for the block movement controls. 27086 */ 27087 27088 function getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir) { 27089 const position = firstIndex + 1; 27090 27091 if (dir < 0 && isFirst) { 27092 return (0,external_wp_i18n_namespaceObject.__)('Blocks cannot be moved up as they are already at the top'); 27093 } 27094 27095 if (dir > 0 && isLast) { 27096 return (0,external_wp_i18n_namespaceObject.__)('Blocks cannot be moved down as they are already at the bottom'); 27097 } 27098 27099 if (dir < 0 && !isFirst) { 27100 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Number of selected blocks, 2: Position of selected blocks 27101 (0,external_wp_i18n_namespaceObject._n)('Move %1$d block from position %2$d up by one place', 'Move %1$d blocks from position %2$d up by one place', selectedCount), selectedCount, position); 27102 } 27103 27104 if (dir > 0 && !isLast) { 27105 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Number of selected blocks, 2: Position of selected blocks 27106 (0,external_wp_i18n_namespaceObject._n)('Move %1$d block from position %2$d down by one place', 'Move %1$d blocks from position %2$d down by one place', selectedCount), selectedCount, position); 27107 } 27108 } 27109 27110 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/button.js 27111 27112 27113 27114 /** 27115 * External dependencies 27116 */ 27117 27118 27119 /** 27120 * WordPress dependencies 27121 */ 27122 27123 27124 27125 27126 27127 27128 27129 /** 27130 * Internal dependencies 27131 */ 27132 27133 27134 27135 27136 27137 const getArrowIcon = (direction, orientation) => { 27138 if (direction === 'up') { 27139 if (orientation === 'horizontal') { 27140 return (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left; 27141 } 27142 27143 return chevron_up; 27144 } else if (direction === 'down') { 27145 if (orientation === 'horizontal') { 27146 return (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right; 27147 } 27148 27149 return chevron_down; 27150 } 27151 27152 return null; 27153 }; 27154 27155 const getMovementDirectionLabel = (moveDirection, orientation) => { 27156 if (moveDirection === 'up') { 27157 if (orientation === 'horizontal') { 27158 return (0,external_wp_i18n_namespaceObject.isRTL)() ? (0,external_wp_i18n_namespaceObject.__)('Move right') : (0,external_wp_i18n_namespaceObject.__)('Move left'); 27159 } 27160 27161 return (0,external_wp_i18n_namespaceObject.__)('Move up'); 27162 } else if (moveDirection === 'down') { 27163 if (orientation === 'horizontal') { 27164 return (0,external_wp_i18n_namespaceObject.isRTL)() ? (0,external_wp_i18n_namespaceObject.__)('Move left') : (0,external_wp_i18n_namespaceObject.__)('Move right'); 27165 } 27166 27167 return (0,external_wp_i18n_namespaceObject.__)('Move down'); 27168 } 27169 27170 return null; 27171 }; 27172 27173 const BlockMoverButton = (0,external_wp_element_namespaceObject.forwardRef)((_ref, ref) => { 27174 let { 27175 clientIds, 27176 direction, 27177 orientation: moverOrientation, 27178 ...props 27179 } = _ref; 27180 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockMoverButton); 27181 const blocksCount = (0,external_lodash_namespaceObject.castArray)(clientIds).length; 27182 const { 27183 blockType, 27184 isDisabled, 27185 rootClientId, 27186 isFirst, 27187 isLast, 27188 firstIndex, 27189 orientation = 'vertical' 27190 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 27191 const { 27192 getBlockIndex, 27193 getBlockRootClientId, 27194 getBlockOrder, 27195 getBlock, 27196 getBlockListSettings 27197 } = select(store); 27198 const normalizedClientIds = (0,external_lodash_namespaceObject.castArray)(clientIds); 27199 const firstClientId = (0,external_lodash_namespaceObject.first)(normalizedClientIds); 27200 const blockRootClientId = getBlockRootClientId(firstClientId); 27201 const firstBlockIndex = getBlockIndex(firstClientId); 27202 const lastBlockIndex = getBlockIndex((0,external_lodash_namespaceObject.last)(normalizedClientIds)); 27203 const blockOrder = getBlockOrder(blockRootClientId); 27204 const block = getBlock(firstClientId); 27205 const isFirstBlock = firstBlockIndex === 0; 27206 const isLastBlock = lastBlockIndex === blockOrder.length - 1; 27207 const { 27208 orientation: blockListOrientation 27209 } = getBlockListSettings(blockRootClientId) || {}; 27210 return { 27211 blockType: block ? (0,external_wp_blocks_namespaceObject.getBlockType)(block.name) : null, 27212 isDisabled: direction === 'up' ? isFirstBlock : isLastBlock, 27213 rootClientId: blockRootClientId, 27214 firstIndex: firstBlockIndex, 27215 isFirst: isFirstBlock, 27216 isLast: isLastBlock, 27217 orientation: moverOrientation || blockListOrientation 27218 }; 27219 }, [clientIds, direction]); 27220 const { 27221 moveBlocksDown, 27222 moveBlocksUp 27223 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 27224 const moverFunction = direction === 'up' ? moveBlocksUp : moveBlocksDown; 27225 27226 const onClick = event => { 27227 moverFunction(clientIds, rootClientId); 27228 27229 if (props.onClick) { 27230 props.onClick(event); 27231 } 27232 }; 27233 27234 const descriptionId = `block-editor-block-mover-button__description-$instanceId}`; 27235 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({ 27236 ref: ref, 27237 className: classnames_default()('block-editor-block-mover-button', `is-$direction}-button`), 27238 icon: getArrowIcon(direction, orientation), 27239 label: getMovementDirectionLabel(direction, orientation), 27240 "aria-describedby": descriptionId 27241 }, props, { 27242 onClick: isDisabled ? null : onClick, 27243 "aria-disabled": isDisabled 27244 })), (0,external_wp_element_namespaceObject.createElement)("span", { 27245 id: descriptionId, 27246 className: "block-editor-block-mover-button__description" 27247 }, getBlockMoverDescription(blocksCount, blockType && blockType.title, firstIndex, isFirst, isLast, direction === 'up' ? -1 : 1, orientation))); 27248 }); 27249 const BlockMoverUpButton = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => { 27250 return (0,external_wp_element_namespaceObject.createElement)(BlockMoverButton, _extends({ 27251 direction: "up", 27252 ref: ref 27253 }, props)); 27254 }); 27255 const BlockMoverDownButton = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => { 27256 return (0,external_wp_element_namespaceObject.createElement)(BlockMoverButton, _extends({ 27257 direction: "down", 27258 ref: ref 27259 }, props)); 27260 }); 27261 27262 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/index.js 27263 27264 27265 27266 /** 27267 * External dependencies 27268 */ 27269 27270 27271 /** 27272 * WordPress dependencies 27273 */ 27274 27275 27276 27277 27278 27279 27280 27281 /** 27282 * Internal dependencies 27283 */ 27284 27285 27286 27287 27288 27289 function BlockMover(_ref) { 27290 let { 27291 isFirst, 27292 isLast, 27293 clientIds, 27294 canMove, 27295 isHidden, 27296 rootClientId, 27297 orientation, 27298 hideDragHandle 27299 } = _ref; 27300 const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false); 27301 27302 const onFocus = () => setIsFocused(true); 27303 27304 const onBlur = () => setIsFocused(false); 27305 27306 if (!canMove || isFirst && isLast && !rootClientId) { 27307 return null; 27308 } 27309 27310 const dragHandleLabel = (0,external_wp_i18n_namespaceObject.__)('Drag'); // We emulate a disabled state because forcefully applying the `disabled` 27311 // attribute on the buttons while it has focus causes the screen to change 27312 // to an unfocused state (body as active element) without firing blur on, 27313 // the rendering parent, leaving it unable to react to focus out. 27314 27315 27316 return (0,external_wp_element_namespaceObject.createElement)("div", { 27317 className: classnames_default()('block-editor-block-mover', { 27318 'is-visible': isFocused || !isHidden, 27319 'is-horizontal': orientation === 'horizontal' 27320 }) 27321 }, !hideDragHandle && (0,external_wp_element_namespaceObject.createElement)(block_draggable, { 27322 clientIds: clientIds, 27323 cloneClassname: "block-editor-block-mover__drag-clone" 27324 }, draggableProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({ 27325 icon: drag_handle, 27326 className: "block-editor-block-mover__drag-handle", 27327 "aria-hidden": "true", 27328 label: dragHandleLabel // Should not be able to tab to drag handle as this 27329 // button can only be used with a pointer device. 27330 , 27331 tabIndex: "-1" 27332 }, draggableProps))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, { 27333 className: "block-editor-block-mover__move-button-container" 27334 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, { 27335 onFocus: onFocus, 27336 onBlur: onBlur 27337 }, itemProps => (0,external_wp_element_namespaceObject.createElement)(BlockMoverUpButton, _extends({ 27338 clientIds: clientIds 27339 }, itemProps))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, { 27340 onFocus: onFocus, 27341 onBlur: onBlur 27342 }, itemProps => (0,external_wp_element_namespaceObject.createElement)(BlockMoverDownButton, _extends({ 27343 clientIds: clientIds 27344 }, itemProps))))); 27345 } 27346 /** 27347 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-mover/README.md 27348 */ 27349 27350 27351 /* harmony default export */ var block_mover = ((0,external_wp_data_namespaceObject.withSelect)((select, _ref2) => { 27352 var _getBlockListSettings; 27353 27354 let { 27355 clientIds 27356 } = _ref2; 27357 const { 27358 getBlock, 27359 getBlockIndex, 27360 getBlockListSettings, 27361 canMoveBlocks, 27362 getBlockOrder, 27363 getBlockRootClientId 27364 } = select(store); 27365 const normalizedClientIds = (0,external_lodash_namespaceObject.castArray)(clientIds); 27366 const firstClientId = (0,external_lodash_namespaceObject.first)(normalizedClientIds); 27367 const block = getBlock(firstClientId); 27368 const rootClientId = getBlockRootClientId((0,external_lodash_namespaceObject.first)(normalizedClientIds)); 27369 const firstIndex = getBlockIndex(firstClientId); 27370 const lastIndex = getBlockIndex((0,external_lodash_namespaceObject.last)(normalizedClientIds)); 27371 const blockOrder = getBlockOrder(rootClientId); 27372 const isFirst = firstIndex === 0; 27373 const isLast = lastIndex === blockOrder.length - 1; 27374 return { 27375 blockType: block ? (0,external_wp_blocks_namespaceObject.getBlockType)(block.name) : null, 27376 canMove: canMoveBlocks(clientIds, rootClientId), 27377 rootClientId, 27378 firstIndex, 27379 isFirst, 27380 isLast, 27381 orientation: (_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation 27382 }; 27383 })(BlockMover)); 27384 27385 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/utils.js 27386 /** 27387 * External dependencies 27388 */ 27389 27390 /** 27391 * WordPress dependencies 27392 */ 27393 27394 27395 const { 27396 clearTimeout: utils_clearTimeout, 27397 setTimeout: utils_setTimeout 27398 } = window; 27399 const DEBOUNCE_TIMEOUT = 200; 27400 /** 27401 * Hook that creates a showMover state, as well as debounced show/hide callbacks. 27402 * 27403 * @param {Object} props Component props. 27404 * @param {Object} props.ref Element reference. 27405 * @param {boolean} props.isFocused Whether the component has current focus. 27406 * @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds. 27407 * @param {Function} [props.onChange=noop] Callback function. 27408 */ 27409 27410 function useDebouncedShowMovers(_ref) { 27411 let { 27412 ref, 27413 isFocused, 27414 debounceTimeout = DEBOUNCE_TIMEOUT, 27415 onChange = external_lodash_namespaceObject.noop 27416 } = _ref; 27417 const [showMovers, setShowMovers] = (0,external_wp_element_namespaceObject.useState)(false); 27418 const timeoutRef = (0,external_wp_element_namespaceObject.useRef)(); 27419 27420 const handleOnChange = nextIsFocused => { 27421 if (ref !== null && ref !== void 0 && ref.current) { 27422 setShowMovers(nextIsFocused); 27423 } 27424 27425 onChange(nextIsFocused); 27426 }; 27427 27428 const getIsHovered = () => { 27429 return (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.matches(':hover'); 27430 }; 27431 27432 const shouldHideMovers = () => { 27433 const isHovered = getIsHovered(); 27434 return !isFocused && !isHovered; 27435 }; 27436 27437 const clearTimeoutRef = () => { 27438 const timeout = timeoutRef.current; 27439 27440 if (timeout && utils_clearTimeout) { 27441 utils_clearTimeout(timeout); 27442 } 27443 }; 27444 27445 const debouncedShowMovers = event => { 27446 if (event) { 27447 event.stopPropagation(); 27448 } 27449 27450 clearTimeoutRef(); 27451 27452 if (!showMovers) { 27453 handleOnChange(true); 27454 } 27455 }; 27456 27457 const debouncedHideMovers = event => { 27458 if (event) { 27459 event.stopPropagation(); 27460 } 27461 27462 clearTimeoutRef(); 27463 timeoutRef.current = utils_setTimeout(() => { 27464 if (shouldHideMovers()) { 27465 handleOnChange(false); 27466 } 27467 }, debounceTimeout); 27468 }; 27469 27470 (0,external_wp_element_namespaceObject.useEffect)(() => () => { 27471 /** 27472 * We need to call the change handler with `isFocused` 27473 * set to false on unmount because we also clear the 27474 * timeout that would handle that. 27475 */ 27476 handleOnChange(false); 27477 clearTimeoutRef(); 27478 }, []); 27479 return { 27480 showMovers, 27481 debouncedShowMovers, 27482 debouncedHideMovers 27483 }; 27484 } 27485 /** 27486 * Hook that provides a showMovers state and gesture events for DOM elements 27487 * that interact with the showMovers state. 27488 * 27489 * @param {Object} props Component props. 27490 * @param {Object} props.ref Element reference. 27491 * @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds. 27492 * @param {Function} [props.onChange=noop] Callback function. 27493 */ 27494 27495 function useShowMoversGestures(_ref2) { 27496 let { 27497 ref, 27498 debounceTimeout = DEBOUNCE_TIMEOUT, 27499 onChange = external_lodash_namespaceObject.noop 27500 } = _ref2; 27501 const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false); 27502 const { 27503 showMovers, 27504 debouncedShowMovers, 27505 debouncedHideMovers 27506 } = useDebouncedShowMovers({ 27507 ref, 27508 debounceTimeout, 27509 isFocused, 27510 onChange 27511 }); 27512 const registerRef = (0,external_wp_element_namespaceObject.useRef)(false); 27513 27514 const isFocusedWithin = () => { 27515 return (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.contains(ref.current.ownerDocument.activeElement); 27516 }; 27517 27518 (0,external_wp_element_namespaceObject.useEffect)(() => { 27519 const node = ref.current; 27520 27521 const handleOnFocus = () => { 27522 if (isFocusedWithin()) { 27523 setIsFocused(true); 27524 debouncedShowMovers(); 27525 } 27526 }; 27527 27528 const handleOnBlur = () => { 27529 if (!isFocusedWithin()) { 27530 setIsFocused(false); 27531 debouncedHideMovers(); 27532 } 27533 }; 27534 /** 27535 * Events are added via DOM events (vs. React synthetic events), 27536 * as the child React components swallow mouse events. 27537 */ 27538 27539 27540 if (node && !registerRef.current) { 27541 node.addEventListener('focus', handleOnFocus, true); 27542 node.addEventListener('blur', handleOnBlur, true); 27543 registerRef.current = true; 27544 } 27545 27546 return () => { 27547 if (node) { 27548 node.removeEventListener('focus', handleOnFocus); 27549 node.removeEventListener('blur', handleOnBlur); 27550 } 27551 }; 27552 }, [ref, registerRef, setIsFocused, debouncedShowMovers, debouncedHideMovers]); 27553 return { 27554 showMovers, 27555 gestures: { 27556 onMouseMove: debouncedShowMovers, 27557 onMouseLeave: debouncedHideMovers 27558 } 27559 }; 27560 } 27561 27562 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-parent-selector/index.js 27563 27564 27565 27566 /** 27567 * WordPress dependencies 27568 */ 27569 27570 27571 27572 27573 27574 /** 27575 * Internal dependencies 27576 */ 27577 27578 27579 27580 27581 27582 /** 27583 * Block parent selector component, displaying the hierarchy of the 27584 * current block selection as a single icon to "go up" a level. 27585 * 27586 * @return {WPComponent} Parent block selector. 27587 */ 27588 27589 function BlockParentSelector() { 27590 const { 27591 selectBlock, 27592 toggleBlockHighlight 27593 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 27594 const { 27595 firstParentClientId, 27596 shouldHide, 27597 hasReducedUI 27598 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 27599 const { 27600 getBlockName, 27601 getBlockParents, 27602 getSelectedBlockClientId, 27603 getSettings 27604 } = select(store); 27605 const { 27606 hasBlockSupport 27607 } = select(external_wp_blocks_namespaceObject.store); 27608 const selectedBlockClientId = getSelectedBlockClientId(); 27609 const parents = getBlockParents(selectedBlockClientId); 27610 const _firstParentClientId = parents[parents.length - 1]; 27611 const parentBlockName = getBlockName(_firstParentClientId); 27612 27613 const _parentBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(parentBlockName); 27614 27615 const settings = getSettings(); 27616 return { 27617 firstParentClientId: _firstParentClientId, 27618 shouldHide: !hasBlockSupport(_parentBlockType, '__experimentalParentSelector', true), 27619 hasReducedUI: settings.hasReducedUI 27620 }; 27621 }, []); 27622 const blockInformation = useBlockDisplayInformation(firstParentClientId); // Allows highlighting the parent block outline when focusing or hovering 27623 // the parent block selector within the child. 27624 27625 const nodeRef = (0,external_wp_element_namespaceObject.useRef)(); 27626 const { 27627 gestures: showMoversGestures 27628 } = useShowMoversGestures({ 27629 ref: nodeRef, 27630 27631 onChange(isFocused) { 27632 if (isFocused && hasReducedUI) { 27633 return; 27634 } 27635 27636 toggleBlockHighlight(firstParentClientId, isFocused); 27637 } 27638 27639 }); 27640 27641 if (shouldHide || firstParentClientId === undefined) { 27642 return null; 27643 } 27644 27645 return (0,external_wp_element_namespaceObject.createElement)("div", _extends({ 27646 className: "block-editor-block-parent-selector", 27647 key: firstParentClientId, 27648 ref: nodeRef 27649 }, showMoversGestures), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 27650 className: "block-editor-block-parent-selector__button", 27651 onClick: () => selectBlock(firstParentClientId), 27652 label: (0,external_wp_i18n_namespaceObject.sprintf)( 27653 /* translators: %s: Name of the block's parent. */ 27654 (0,external_wp_i18n_namespaceObject.__)('Select %s'), blockInformation.title), 27655 showTooltip: true, 27656 icon: (0,external_wp_element_namespaceObject.createElement)(block_icon, { 27657 icon: blockInformation.icon 27658 }) 27659 })); 27660 } 27661 27662 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/copy.js 27663 27664 27665 /** 27666 * WordPress dependencies 27667 */ 27668 27669 const copy = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 27670 xmlns: "http://www.w3.org/2000/svg", 27671 viewBox: "0 0 24 24" 27672 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 27673 d: "M20.2 8v11c0 .7-.6 1.2-1.2 1.2H6v1.5h13c1.5 0 2.7-1.2 2.7-2.8V8zM18 16.4V4.6c0-.9-.7-1.6-1.6-1.6H4.6C3.7 3 3 3.7 3 4.6v11.8c0 .9.7 1.6 1.6 1.6h11.8c.9 0 1.6-.7 1.6-1.6zm-13.5 0V4.6c0-.1.1-.1.1-.1h11.8c.1 0 .1.1.1.1v11.8c0 .1-.1.1-.1.1H4.6l-.1-.1z" 27674 })); 27675 /* harmony default export */ var library_copy = (copy); 27676 27677 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/preview-block-popover.js 27678 27679 27680 /** 27681 * WordPress dependencies 27682 */ 27683 27684 27685 /** 27686 * Internal dependencies 27687 */ 27688 27689 27690 function PreviewBlockPopover(_ref) { 27691 let { 27692 blocks 27693 } = _ref; 27694 return (0,external_wp_element_namespaceObject.createElement)("div", { 27695 className: "block-editor-block-switcher__popover__preview__parent" 27696 }, (0,external_wp_element_namespaceObject.createElement)("div", { 27697 className: "block-editor-block-switcher__popover__preview__container" 27698 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { 27699 className: "block-editor-block-switcher__preview__popover", 27700 position: "bottom right", 27701 focusOnMount: false 27702 }, (0,external_wp_element_namespaceObject.createElement)("div", { 27703 className: "block-editor-block-switcher__preview" 27704 }, (0,external_wp_element_namespaceObject.createElement)("div", { 27705 className: "block-editor-block-switcher__preview-title" 27706 }, (0,external_wp_i18n_namespaceObject.__)('Preview')), (0,external_wp_element_namespaceObject.createElement)(block_preview, { 27707 viewportWidth: 500, 27708 blocks: blocks 27709 }))))); 27710 } 27711 27712 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/block-transformations-menu.js 27713 27714 27715 /** 27716 * WordPress dependencies 27717 */ 27718 27719 27720 27721 27722 /** 27723 * Internal dependencies 27724 */ 27725 27726 27727 27728 27729 const BlockTransformationsMenu = _ref => { 27730 let { 27731 className, 27732 possibleBlockTransformations, 27733 onSelect, 27734 blocks 27735 } = _ref; 27736 const [hoveredTransformItemName, setHoveredTransformItemName] = (0,external_wp_element_namespaceObject.useState)(); 27737 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, { 27738 label: (0,external_wp_i18n_namespaceObject.__)('Transform to'), 27739 className: className 27740 }, hoveredTransformItemName && (0,external_wp_element_namespaceObject.createElement)(PreviewBlockPopover, { 27741 blocks: (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, hoveredTransformItemName) 27742 }), possibleBlockTransformations.map(item => { 27743 const { 27744 name, 27745 icon, 27746 title, 27747 isDisabled 27748 } = item; 27749 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 27750 key: name, 27751 className: (0,external_wp_blocks_namespaceObject.getBlockMenuDefaultClassName)(name), 27752 onClick: event => { 27753 event.preventDefault(); 27754 onSelect(name); 27755 }, 27756 disabled: isDisabled, 27757 onMouseLeave: () => setHoveredTransformItemName(null), 27758 onMouseEnter: () => setHoveredTransformItemName(name) 27759 }, (0,external_wp_element_namespaceObject.createElement)(block_icon, { 27760 icon: icon, 27761 showColors: true 27762 }), title); 27763 })); 27764 }; 27765 27766 /* harmony default export */ var block_transformations_menu = (BlockTransformationsMenu); 27767 27768 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/check.js 27769 27770 27771 /** 27772 * WordPress dependencies 27773 */ 27774 27775 const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 27776 xmlns: "http://www.w3.org/2000/svg", 27777 viewBox: "0 0 24 24" 27778 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 27779 d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z" 27780 })); 27781 /* harmony default export */ var library_check = (check); 27782 27783 ;// CONCATENATED MODULE: external ["wp","tokenList"] 27784 var external_wp_tokenList_namespaceObject = window["wp"]["tokenList"]; 27785 var external_wp_tokenList_default = /*#__PURE__*/__webpack_require__.n(external_wp_tokenList_namespaceObject); 27786 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/utils.js 27787 /** 27788 * External dependencies 27789 */ 27790 27791 /** 27792 * WordPress dependencies 27793 */ 27794 27795 27796 27797 /** 27798 * Returns the active style from the given className. 27799 * 27800 * @param {Array} styles Block style variations. 27801 * @param {string} className Class name 27802 * 27803 * @return {Object?} The active style. 27804 */ 27805 27806 function getActiveStyle(styles, className) { 27807 for (const style of new (external_wp_tokenList_default())(className).values()) { 27808 if (style.indexOf('is-style-') === -1) { 27809 continue; 27810 } 27811 27812 const potentialStyleName = style.substring(9); 27813 const activeStyle = (0,external_lodash_namespaceObject.find)(styles, { 27814 name: potentialStyleName 27815 }); 27816 27817 if (activeStyle) { 27818 return activeStyle; 27819 } 27820 } 27821 27822 return (0,external_lodash_namespaceObject.find)(styles, 'isDefault'); 27823 } 27824 /** 27825 * Replaces the active style in the block's className. 27826 * 27827 * @param {string} className Class name. 27828 * @param {Object?} activeStyle The replaced style. 27829 * @param {Object} newStyle The replacing style. 27830 * 27831 * @return {string} The updated className. 27832 */ 27833 27834 function replaceActiveStyle(className, activeStyle, newStyle) { 27835 const list = new (external_wp_tokenList_default())(className); 27836 27837 if (activeStyle) { 27838 list.remove('is-style-' + activeStyle.name); 27839 } 27840 27841 list.add('is-style-' + newStyle.name); 27842 return list.value; 27843 } 27844 /** 27845 * Returns a collection of styles that can be represented on the frontend. 27846 * The function checks a style collection for a default style. If none is found, it adds one to 27847 * act as a fallback for when there is no active style applied to a block. The default item also serves 27848 * as a switch on the frontend to deactivate non-default styles. 27849 * 27850 * @param {Array} styles Block style variations. 27851 * 27852 * @return {Array<Object?>} The style collection. 27853 */ 27854 27855 function getRenderedStyles(styles) { 27856 if (!styles || styles.length === 0) { 27857 return []; 27858 } 27859 27860 return getDefaultStyle(styles) ? styles : [{ 27861 name: 'default', 27862 label: (0,external_wp_i18n_namespaceObject._x)('Default', 'block style'), 27863 isDefault: true 27864 }, ...styles]; 27865 } 27866 /** 27867 * Returns a style object from a collection of styles where that style object is the default block style. 27868 * 27869 * @param {Array} styles Block style variations. 27870 * 27871 * @return {Object?} The default style object, if found. 27872 */ 27873 27874 function getDefaultStyle(styles) { 27875 return (0,external_lodash_namespaceObject.find)(styles, 'isDefault'); 27876 } 27877 27878 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/use-styles-for-block.js 27879 /** 27880 * WordPress dependencies 27881 */ 27882 27883 27884 27885 /** 27886 * Internal dependencies 27887 */ 27888 27889 27890 27891 /** 27892 * 27893 * @param {WPBlock} block Block object. 27894 * @param {WPBlockType} type Block type settings. 27895 * @return {WPBlock} A generic block ready for styles preview. 27896 */ 27897 27898 function useGenericPreviewBlock(block, type) { 27899 return (0,external_wp_element_namespaceObject.useMemo)(() => { 27900 const example = type === null || type === void 0 ? void 0 : type.example; 27901 const blockName = type === null || type === void 0 ? void 0 : type.name; 27902 27903 if (example && blockName) { 27904 return (0,external_wp_blocks_namespaceObject.getBlockFromExample)(blockName, { 27905 attributes: example.attributes, 27906 innerBlocks: example.innerBlocks 27907 }); 27908 } 27909 27910 if (block) { 27911 return (0,external_wp_blocks_namespaceObject.cloneBlock)(block); 27912 } 27913 }, [type !== null && type !== void 0 && type.example ? block === null || block === void 0 ? void 0 : block.name : block, type]); 27914 } 27915 /** 27916 * @typedef useStylesForBlocksArguments 27917 * @property {string} clientId Block client ID. 27918 * @property {() => void} onSwitch Block style switch callback function. 27919 */ 27920 27921 /** 27922 * 27923 * @param {useStylesForBlocksArguments} useStylesForBlocks arguments. 27924 * @return {Object} Results of the select methods. 27925 */ 27926 27927 27928 function useStylesForBlocks(_ref) { 27929 let { 27930 clientId, 27931 onSwitch 27932 } = _ref; 27933 27934 const selector = select => { 27935 const { 27936 getBlock 27937 } = select(store); 27938 const block = getBlock(clientId); 27939 27940 if (!block) { 27941 return {}; 27942 } 27943 27944 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name); 27945 const { 27946 getBlockStyles 27947 } = select(external_wp_blocks_namespaceObject.store); 27948 return { 27949 block, 27950 blockType, 27951 styles: getBlockStyles(block.name), 27952 className: block.attributes.className || '' 27953 }; 27954 }; 27955 27956 const { 27957 styles, 27958 block, 27959 blockType, 27960 className 27961 } = (0,external_wp_data_namespaceObject.useSelect)(selector, [clientId]); 27962 const { 27963 updateBlockAttributes 27964 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 27965 const stylesToRender = getRenderedStyles(styles); 27966 const activeStyle = getActiveStyle(stylesToRender, className); 27967 const genericPreviewBlock = useGenericPreviewBlock(block, blockType); 27968 27969 const onSelect = style => { 27970 const styleClassName = replaceActiveStyle(className, activeStyle, style); 27971 updateBlockAttributes(clientId, { 27972 className: styleClassName 27973 }); 27974 onSwitch(); 27975 }; 27976 27977 return { 27978 onSelect, 27979 stylesToRender, 27980 activeStyle, 27981 genericPreviewBlock, 27982 className 27983 }; 27984 } 27985 27986 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/menu-items.js 27987 27988 27989 /** 27990 * External dependencies 27991 */ 27992 27993 /** 27994 * WordPress dependencies 27995 */ 27996 27997 27998 27999 /** 28000 * Internal dependencies 28001 */ 28002 28003 28004 function BlockStylesMenuItems(_ref) { 28005 let { 28006 clientId, 28007 onSwitch = external_lodash_namespaceObject.noop 28008 } = _ref; 28009 const { 28010 onSelect, 28011 stylesToRender, 28012 activeStyle 28013 } = useStylesForBlocks({ 28014 clientId, 28015 onSwitch 28016 }); 28017 28018 if (!stylesToRender || stylesToRender.length === 0) { 28019 return null; 28020 } 28021 28022 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, stylesToRender.map(style => { 28023 const menuItemText = style.label || style.name; 28024 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 28025 key: style.name, 28026 icon: activeStyle.name === style.name ? library_check : null, 28027 onClick: () => onSelect(style) 28028 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { 28029 as: "span", 28030 limit: 18, 28031 ellipsizeMode: "tail", 28032 truncate: true 28033 }, menuItemText)); 28034 })); 28035 } 28036 28037 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/block-styles-menu.js 28038 28039 28040 /** 28041 * WordPress dependencies 28042 */ 28043 28044 28045 /** 28046 * Internal dependencies 28047 */ 28048 28049 28050 function BlockStylesMenu(_ref) { 28051 let { 28052 hoveredBlock, 28053 onSwitch 28054 } = _ref; 28055 const { 28056 clientId 28057 } = hoveredBlock; 28058 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, { 28059 label: (0,external_wp_i18n_namespaceObject.__)('Styles'), 28060 className: "block-editor-block-switcher__styles__menugroup" 28061 }, (0,external_wp_element_namespaceObject.createElement)(BlockStylesMenuItems, { 28062 clientId: clientId, 28063 onSwitch: onSwitch 28064 })); 28065 } 28066 28067 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/utils.js 28068 /** 28069 * WordPress dependencies 28070 */ 28071 28072 /** 28073 * Try to find a matching block by a block's name in a provided 28074 * block. We recurse through InnerBlocks and return the reference 28075 * of the matched block (it could be an InnerBlock). 28076 * If no match is found return nothing. 28077 * 28078 * @param {WPBlock} block The block to try to find a match. 28079 * @param {string} selectedBlockName The block's name to use for matching condition. 28080 * @param {Set} consumedBlocks A set holding the previously matched/consumed blocks. 28081 * 28082 * @return {WPBlock?} The matched block if found or nothing(`undefined`). 28083 */ 28084 28085 const getMatchingBlockByName = function (block, selectedBlockName) { 28086 let consumedBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set(); 28087 const { 28088 clientId, 28089 name, 28090 innerBlocks = [] 28091 } = block; // Check if block has been consumed already. 28092 28093 if (consumedBlocks.has(clientId)) return; 28094 if (name === selectedBlockName) return block; // Try to find a matching block from InnerBlocks recursively. 28095 28096 for (const innerBlock of innerBlocks) { 28097 const match = getMatchingBlockByName(innerBlock, selectedBlockName, consumedBlocks); 28098 if (match) return match; 28099 } 28100 }; 28101 /** 28102 * Find and return the block attributes to retain through 28103 * the transformation, based on Block Type's `role:content` 28104 * attributes. If no `role:content` attributes exist, 28105 * return selected block's attributes. 28106 * 28107 * @param {string} name Block type's namespaced name. 28108 * @param {Object} attributes Selected block's attributes. 28109 * @return {Object} The block's attributes to retain. 28110 */ 28111 28112 const getRetainedBlockAttributes = (name, attributes) => { 28113 const contentAttributes = (0,external_wp_blocks_namespaceObject.__experimentalGetBlockAttributesNamesByRole)(name, 'content'); 28114 if (!(contentAttributes !== null && contentAttributes !== void 0 && contentAttributes.length)) return attributes; 28115 return contentAttributes.reduce((_accumulator, attribute) => { 28116 if (attributes[attribute]) _accumulator[attribute] = attributes[attribute]; 28117 return _accumulator; 28118 }, {}); 28119 }; 28120 28121 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/use-transformed-patterns.js 28122 /** 28123 * WordPress dependencies 28124 */ 28125 28126 28127 /** 28128 * Internal dependencies 28129 */ 28130 28131 28132 /** 28133 * Mutate the matched block's attributes by getting 28134 * which block type's attributes to retain and prioritize 28135 * them in the merging of the attributes. 28136 * 28137 * @param {WPBlock} match The matched block. 28138 * @param {WPBlock} selectedBlock The selected block. 28139 * @return {void} 28140 */ 28141 28142 const transformMatchingBlock = (match, selectedBlock) => { 28143 // Get the block attributes to retain through the transformation. 28144 const retainedBlockAttributes = getRetainedBlockAttributes(selectedBlock.name, selectedBlock.attributes); 28145 match.attributes = { ...match.attributes, 28146 ...retainedBlockAttributes 28147 }; 28148 }; 28149 /** 28150 * By providing the selected blocks and pattern's blocks 28151 * find the matching blocks, transform them and return them. 28152 * If not all selected blocks are matched, return nothing. 28153 * 28154 * @param {WPBlock[]} selectedBlocks The selected blocks. 28155 * @param {WPBlock[]} patternBlocks The pattern's blocks. 28156 * @return {WPBlock[]|void} The transformed pattern's blocks or undefined if not all selected blocks have been matched. 28157 */ 28158 28159 const getPatternTransformedBlocks = (selectedBlocks, patternBlocks) => { 28160 // Clone Pattern's blocks to produce new clientIds and be able to mutate the matches. 28161 const _patternBlocks = patternBlocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block)); 28162 /** 28163 * Keep track of the consumed pattern blocks. 28164 * This is needed because we loop the selected blocks 28165 * and for example we may have selected two paragraphs and 28166 * the pattern's blocks could have more `paragraphs`. 28167 */ 28168 28169 28170 const consumedBlocks = new Set(); 28171 28172 for (const selectedBlock of selectedBlocks) { 28173 let isMatch = false; 28174 28175 for (const patternBlock of _patternBlocks) { 28176 const match = getMatchingBlockByName(patternBlock, selectedBlock.name, consumedBlocks); 28177 if (!match) continue; 28178 isMatch = true; 28179 consumedBlocks.add(match.clientId); // We update (mutate) the matching pattern block. 28180 28181 transformMatchingBlock(match, selectedBlock); // No need to loop through other pattern's blocks. 28182 28183 break; 28184 } // Bail eary if a selected block has not been matched. 28185 28186 28187 if (!isMatch) return; 28188 } 28189 28190 return _patternBlocks; 28191 }; 28192 /** 28193 * @typedef {WPBlockPattern & {transformedBlocks: WPBlock[]}} TransformedBlockPattern 28194 */ 28195 28196 /** 28197 * Custom hook that accepts patterns from state and the selected 28198 * blocks and tries to match these with the pattern's blocks. 28199 * If all selected blocks are matched with a Pattern's block, 28200 * we transform them by retaining block's attributes with `role:content`. 28201 * The transformed pattern's blocks are set to a new pattern 28202 * property `transformedBlocks`. 28203 * 28204 * @param {WPBlockPattern[]} patterns Patterns from state. 28205 * @param {WPBlock[]} selectedBlocks The currently selected blocks. 28206 * @return {TransformedBlockPattern[]} Returns the eligible matched patterns with all the selected blocks. 28207 */ 28208 28209 const useTransformedPatterns = (patterns, selectedBlocks) => { 28210 return (0,external_wp_element_namespaceObject.useMemo)(() => patterns.reduce((accumulator, _pattern) => { 28211 const transformedBlocks = getPatternTransformedBlocks(selectedBlocks, _pattern.blocks); 28212 28213 if (transformedBlocks) { 28214 accumulator.push({ ..._pattern, 28215 transformedBlocks 28216 }); 28217 } 28218 28219 return accumulator; 28220 }, []), [patterns, selectedBlocks]); 28221 }; 28222 28223 /* harmony default export */ var use_transformed_patterns = (useTransformedPatterns); 28224 28225 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/pattern-transformations-menu.js 28226 28227 28228 28229 /** 28230 * WordPress dependencies 28231 */ 28232 28233 28234 28235 28236 28237 /** 28238 * Internal dependencies 28239 */ 28240 28241 28242 28243 28244 function PatternTransformationsMenu(_ref) { 28245 let { 28246 blocks, 28247 patterns: statePatterns, 28248 onSelect 28249 } = _ref; 28250 const [showTransforms, setShowTransforms] = (0,external_wp_element_namespaceObject.useState)(false); 28251 const patterns = use_transformed_patterns(statePatterns, blocks); 28252 if (!patterns.length) return null; 28253 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, { 28254 className: "block-editor-block-switcher__pattern__transforms__menugroup" 28255 }, showTransforms && (0,external_wp_element_namespaceObject.createElement)(PreviewPatternsPopover, { 28256 patterns: patterns, 28257 onSelect: onSelect 28258 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 28259 onClick: event => { 28260 event.preventDefault(); 28261 setShowTransforms(!showTransforms); 28262 }, 28263 icon: chevron_right 28264 }, (0,external_wp_i18n_namespaceObject.__)('Patterns'))); 28265 } 28266 28267 function PreviewPatternsPopover(_ref2) { 28268 let { 28269 patterns, 28270 onSelect 28271 } = _ref2; 28272 return (0,external_wp_element_namespaceObject.createElement)("div", { 28273 className: "block-editor-block-switcher__popover__preview__parent" 28274 }, (0,external_wp_element_namespaceObject.createElement)("div", { 28275 className: "block-editor-block-switcher__popover__preview__container" 28276 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { 28277 className: "block-editor-block-switcher__preview__popover", 28278 position: "bottom right" 28279 }, (0,external_wp_element_namespaceObject.createElement)("div", { 28280 className: "block-editor-block-switcher__preview" 28281 }, (0,external_wp_element_namespaceObject.createElement)("div", { 28282 className: "block-editor-block-switcher__preview-title" 28283 }, (0,external_wp_i18n_namespaceObject.__)('Preview')), (0,external_wp_element_namespaceObject.createElement)(BlockPatternsList, { 28284 patterns: patterns, 28285 onSelect: onSelect 28286 }))))); 28287 } 28288 28289 function BlockPatternsList(_ref3) { 28290 let { 28291 patterns, 28292 onSelect 28293 } = _ref3; 28294 const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)(); 28295 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, { 28296 role: "listbox", 28297 className: "block-editor-block-switcher__preview-patterns-container", 28298 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Patterns list') 28299 }), patterns.map(pattern => (0,external_wp_element_namespaceObject.createElement)(pattern_transformations_menu_BlockPattern, { 28300 key: pattern.name, 28301 pattern: pattern, 28302 onSelect: onSelect, 28303 composite: composite 28304 }))); 28305 } 28306 28307 function pattern_transformations_menu_BlockPattern(_ref4) { 28308 let { 28309 pattern, 28310 onSelect, 28311 composite 28312 } = _ref4; 28313 // TODO check pattern/preview width... 28314 const baseClassName = 'block-editor-block-switcher__preview-patterns-container'; 28315 const descriptionId = (0,external_wp_compose_namespaceObject.useInstanceId)(pattern_transformations_menu_BlockPattern, `$baseClassName}-list__item-description`); 28316 return (0,external_wp_element_namespaceObject.createElement)("div", { 28317 className: `$baseClassName}-list__list-item`, 28318 "aria-label": pattern.title, 28319 "aria-describedby": pattern.description ? descriptionId : undefined 28320 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({ 28321 role: "option", 28322 as: "div" 28323 }, composite, { 28324 className: `$baseClassName}-list__item`, 28325 onClick: () => onSelect(pattern.transformedBlocks) 28326 }), (0,external_wp_element_namespaceObject.createElement)(block_preview, { 28327 blocks: pattern.transformedBlocks, 28328 viewportWidth: pattern.viewportWidth || 500 28329 }), (0,external_wp_element_namespaceObject.createElement)("div", { 28330 className: `$baseClassName}-list__item-title` 28331 }, pattern.title)), !!pattern.description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 28332 id: descriptionId 28333 }, pattern.description)); 28334 } 28335 28336 /* harmony default export */ var pattern_transformations_menu = (PatternTransformationsMenu); 28337 28338 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/index.js 28339 28340 28341 /** 28342 * External dependencies 28343 */ 28344 28345 /** 28346 * WordPress dependencies 28347 */ 28348 28349 28350 28351 28352 28353 28354 /** 28355 * Internal dependencies 28356 */ 28357 28358 28359 28360 28361 28362 28363 28364 28365 const BlockSwitcherDropdownMenu = _ref => { 28366 let { 28367 clientIds, 28368 blocks 28369 } = _ref; 28370 const { 28371 replaceBlocks 28372 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 28373 const blockInformation = useBlockDisplayInformation(blocks[0].clientId); 28374 const { 28375 possibleBlockTransformations, 28376 canRemove, 28377 hasBlockStyles, 28378 icon, 28379 blockTitle, 28380 patterns 28381 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 28382 var _getBlockType2; 28383 28384 const { 28385 getBlockRootClientId, 28386 getBlockTransformItems, 28387 __experimentalGetPatternTransformItems 28388 } = select(store); 28389 const { 28390 getBlockStyles, 28391 getBlockType 28392 } = select(external_wp_blocks_namespaceObject.store); 28393 const { 28394 canRemoveBlocks 28395 } = select(store); 28396 const rootClientId = getBlockRootClientId((0,external_lodash_namespaceObject.castArray)(clientIds)[0]); 28397 const [{ 28398 name: firstBlockName 28399 }] = blocks; 28400 28401 const _isSingleBlockSelected = blocks.length === 1; 28402 28403 const styles = _isSingleBlockSelected && getBlockStyles(firstBlockName); 28404 28405 let _icon; 28406 28407 if (_isSingleBlockSelected) { 28408 _icon = blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon; // Take into account active block variations. 28409 } else { 28410 var _getBlockType; 28411 28412 const isSelectionOfSameType = (0,external_lodash_namespaceObject.uniq)(blocks.map(_ref2 => { 28413 let { 28414 name 28415 } = _ref2; 28416 return name; 28417 })).length === 1; // When selection consists of blocks of multiple types, display an 28418 // appropriate icon to communicate the non-uniformity. 28419 28420 _icon = isSelectionOfSameType ? (_getBlockType = getBlockType(firstBlockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon : library_copy; 28421 } 28422 28423 return { 28424 possibleBlockTransformations: getBlockTransformItems(blocks, rootClientId), 28425 canRemove: canRemoveBlocks(clientIds, rootClientId), 28426 hasBlockStyles: !!(styles !== null && styles !== void 0 && styles.length), 28427 icon: _icon, 28428 blockTitle: (_getBlockType2 = getBlockType(firstBlockName)) === null || _getBlockType2 === void 0 ? void 0 : _getBlockType2.title, 28429 patterns: __experimentalGetPatternTransformItems(blocks, rootClientId) 28430 }; 28431 }, [clientIds, blocks, blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon]); 28432 const isReusable = blocks.length === 1 && (0,external_wp_blocks_namespaceObject.isReusableBlock)(blocks[0]); 28433 const isTemplate = blocks.length === 1 && (0,external_wp_blocks_namespaceObject.isTemplatePart)(blocks[0]); // Simple block tranformation based on the `Block Transforms` API. 28434 28435 const onBlockTransform = name => replaceBlocks(clientIds, (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, name)); // Pattern transformation through the `Patterns` API. 28436 28437 28438 const onPatternTransform = transformedBlocks => replaceBlocks(clientIds, transformedBlocks); 28439 28440 const hasPossibleBlockTransformations = !!possibleBlockTransformations.length && canRemove; 28441 const hasPatternTransformation = !!(patterns !== null && patterns !== void 0 && patterns.length) && canRemove; 28442 28443 if (!hasBlockStyles && !hasPossibleBlockTransformations) { 28444 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 28445 disabled: true, 28446 className: "block-editor-block-switcher__no-switcher-icon", 28447 title: blockTitle, 28448 icon: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(block_icon, { 28449 icon: icon, 28450 showColors: true 28451 }), (isReusable || isTemplate) && (0,external_wp_element_namespaceObject.createElement)("span", { 28452 className: "block-editor-block-switcher__toggle-text" 28453 }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, { 28454 clientId: clientIds, 28455 maximumLength: 35 28456 }))) 28457 })); 28458 } 28459 28460 const blockSwitcherLabel = blockTitle; 28461 const blockSwitcherDescription = 1 === blocks.length ? (0,external_wp_i18n_namespaceObject.sprintf)( 28462 /* translators: %s: block title. */ 28463 (0,external_wp_i18n_namespaceObject.__)('%s: Change block type or style'), blockTitle) : (0,external_wp_i18n_namespaceObject.sprintf)( 28464 /* translators: %d: number of blocks. */ 28465 (0,external_wp_i18n_namespaceObject._n)('Change type of %d block', 'Change type of %d blocks', blocks.length), blocks.length); 28466 const showDropDown = hasBlockStyles || hasPossibleBlockTransformations || hasPatternTransformation; 28467 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, null, toggleProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 28468 className: "block-editor-block-switcher", 28469 label: blockSwitcherLabel, 28470 popoverProps: { 28471 position: 'bottom right', 28472 isAlternate: true, 28473 className: 'block-editor-block-switcher__popover' 28474 }, 28475 icon: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(block_icon, { 28476 icon: icon, 28477 className: "block-editor-block-switcher__toggle", 28478 showColors: true 28479 }), (isReusable || isTemplate) && (0,external_wp_element_namespaceObject.createElement)("span", { 28480 className: "block-editor-block-switcher__toggle-text" 28481 }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, { 28482 clientId: clientIds, 28483 maximumLength: 35 28484 }))), 28485 toggleProps: { 28486 describedBy: blockSwitcherDescription, 28487 ...toggleProps 28488 }, 28489 menuProps: { 28490 orientation: 'both' 28491 } 28492 }, _ref3 => { 28493 let { 28494 onClose 28495 } = _ref3; 28496 return showDropDown && (0,external_wp_element_namespaceObject.createElement)("div", { 28497 className: "block-editor-block-switcher__container" 28498 }, hasPatternTransformation && (0,external_wp_element_namespaceObject.createElement)(pattern_transformations_menu, { 28499 blocks: blocks, 28500 patterns: patterns, 28501 onSelect: transformedBlocks => { 28502 onPatternTransform(transformedBlocks); 28503 onClose(); 28504 } 28505 }), hasPossibleBlockTransformations && (0,external_wp_element_namespaceObject.createElement)(block_transformations_menu, { 28506 className: "block-editor-block-switcher__transforms__menugroup", 28507 possibleBlockTransformations: possibleBlockTransformations, 28508 blocks: blocks, 28509 onSelect: name => { 28510 onBlockTransform(name); 28511 onClose(); 28512 } 28513 }), hasBlockStyles && (0,external_wp_element_namespaceObject.createElement)(BlockStylesMenu, { 28514 hoveredBlock: blocks[0], 28515 onSwitch: onClose 28516 })); 28517 }))); 28518 }; 28519 const BlockSwitcher = _ref4 => { 28520 let { 28521 clientIds 28522 } = _ref4; 28523 const blocks = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlocksByClientId(clientIds), [clientIds]); 28524 28525 if (!blocks.length || blocks.some(block => !block)) { 28526 return null; 28527 } 28528 28529 return (0,external_wp_element_namespaceObject.createElement)(BlockSwitcherDropdownMenu, { 28530 clientIds: clientIds, 28531 blocks: blocks 28532 }); 28533 }; 28534 /* harmony default export */ var block_switcher = (BlockSwitcher); 28535 28536 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/block-toolbar-last-item.js 28537 /** 28538 * WordPress dependencies 28539 */ 28540 28541 const { 28542 Fill: __unstableBlockToolbarLastItem, 28543 Slot: block_toolbar_last_item_Slot 28544 } = (0,external_wp_components_namespaceObject.createSlotFill)('__unstableBlockToolbarLastItem'); 28545 __unstableBlockToolbarLastItem.Slot = block_toolbar_last_item_Slot; 28546 /* harmony default export */ var block_toolbar_last_item = (__unstableBlockToolbarLastItem); 28547 28548 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/more-vertical.js 28549 28550 28551 /** 28552 * WordPress dependencies 28553 */ 28554 28555 const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 28556 xmlns: "http://www.w3.org/2000/svg", 28557 viewBox: "0 0 24 24" 28558 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 28559 d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" 28560 })); 28561 /* harmony default export */ var more_vertical = (moreVertical); 28562 28563 ;// CONCATENATED MODULE: external ["wp","blob"] 28564 var external_wp_blob_namespaceObject = window["wp"]["blob"]; 28565 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/pasting.js 28566 /** 28567 * WordPress dependencies 28568 */ 28569 28570 28571 function getPasteEventData(_ref) { 28572 let { 28573 clipboardData 28574 } = _ref; 28575 let plainText = ''; 28576 let html = ''; // IE11 only supports `Text` as an argument for `getData` and will 28577 // otherwise throw an invalid argument error, so we try the standard 28578 // arguments first, then fallback to `Text` if they fail. 28579 28580 try { 28581 plainText = clipboardData.getData('text/plain'); 28582 html = clipboardData.getData('text/html'); 28583 } catch (error1) { 28584 try { 28585 html = clipboardData.getData('Text'); 28586 } catch (error2) { 28587 // Some browsers like UC Browser paste plain text by default and 28588 // don't support clipboardData at all, so allow default 28589 // behaviour. 28590 return; 28591 } 28592 } 28593 28594 const files = (0,external_wp_dom_namespaceObject.getFilesFromDataTransfer)(clipboardData).filter(_ref2 => { 28595 let { 28596 type 28597 } = _ref2; 28598 return /^image\/(?:jpe?g|png|gif|webp)$/.test(type); 28599 }); 28600 28601 if (files.length && !shouldDismissPastedFiles(files, html, plainText)) { 28602 html = files.map(file => `<img src="${(0,external_wp_blob_namespaceObject.createBlobURL)(file)}">`).join(''); 28603 plainText = ''; 28604 } 28605 28606 return { 28607 html, 28608 plainText 28609 }; 28610 } 28611 /** 28612 * Given a collection of DataTransfer files and HTML and plain text strings, 28613 * determine whether the files are to be dismissed in favor of the HTML. 28614 * 28615 * Certain office-type programs, like Microsoft Word or Apple Numbers, 28616 * will, upon copy, generate a screenshot of the content being copied and 28617 * attach it to the clipboard alongside the actual rich text that the user 28618 * sought to copy. In those cases, we should let Gutenberg handle the rich text 28619 * content and not the screenshot, since this allows Gutenberg to insert 28620 * meaningful blocks, like paragraphs, lists or even tables. 28621 * 28622 * @param {File[]} files File objects obtained from a paste event 28623 * @param {string} html HTML content obtained from a paste event 28624 * @return {boolean} True if the files should be dismissed 28625 */ 28626 28627 function shouldDismissPastedFiles(files, html 28628 /*, plainText */ 28629 ) { 28630 // The question is only relevant when there is actual HTML content and when 28631 // there is exactly one image file. 28632 if (html && (files === null || files === void 0 ? void 0 : files.length) === 1 && files[0].type.indexOf('image/') === 0) { 28633 var _html$match; 28634 28635 // A single <img> tag found in the HTML source suggests that the 28636 // content being pasted revolves around an image. Sometimes there are 28637 // other elements found, like <figure>, but we assume that the user's 28638 // intention is to paste the actual image file. 28639 const IMAGE_TAG = /<\s*img\b/gi; 28640 return ((_html$match = html.match(IMAGE_TAG)) === null || _html$match === void 0 ? void 0 : _html$match.length) !== 1; 28641 } 28642 28643 return false; 28644 } 28645 28646 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/copy-handler/index.js 28647 28648 28649 /** 28650 * WordPress dependencies 28651 */ 28652 28653 28654 28655 28656 28657 28658 28659 /** 28660 * Internal dependencies 28661 */ 28662 28663 28664 28665 function useNotifyCopy() { 28666 const { 28667 getBlockName 28668 } = (0,external_wp_data_namespaceObject.useSelect)(store); 28669 const { 28670 getBlockType 28671 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store); 28672 const { 28673 createSuccessNotice 28674 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 28675 return (0,external_wp_element_namespaceObject.useCallback)((eventType, selectedBlockClientIds) => { 28676 let notice = ''; 28677 28678 if (selectedBlockClientIds.length === 1) { 28679 var _getBlockType; 28680 28681 const clientId = selectedBlockClientIds[0]; 28682 const title = (_getBlockType = getBlockType(getBlockName(clientId))) === null || _getBlockType === void 0 ? void 0 : _getBlockType.title; 28683 notice = eventType === 'copy' ? (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: Name of the block being copied, e.g. "Paragraph". 28684 (0,external_wp_i18n_namespaceObject.__)('Copied "%s" to clipboard.'), title) : (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: Name of the block being cut, e.g. "Paragraph". 28685 (0,external_wp_i18n_namespaceObject.__)('Moved "%s" to clipboard.'), title); 28686 } else { 28687 notice = eventType === 'copy' ? (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %d: Number of blocks being copied. 28688 (0,external_wp_i18n_namespaceObject._n)('Copied %d block to clipboard.', 'Copied %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length) : (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %d: Number of blocks being cut. 28689 (0,external_wp_i18n_namespaceObject._n)('Moved %d block to clipboard.', 'Moved %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length); 28690 } 28691 28692 createSuccessNotice(notice, { 28693 type: 'snackbar' 28694 }); 28695 }, []); 28696 } 28697 function useClipboardHandler() { 28698 const { 28699 getBlocksByClientId, 28700 getSelectedBlockClientIds, 28701 hasMultiSelection, 28702 getSettings, 28703 __unstableIsFullySelected, 28704 __unstableIsSelectionCollapsed, 28705 __unstableIsSelectionMergeable, 28706 __unstableGetSelectedBlocksWithPartialSelection 28707 } = (0,external_wp_data_namespaceObject.useSelect)(store); 28708 const { 28709 flashBlock, 28710 removeBlocks, 28711 replaceBlocks, 28712 __unstableDeleteSelection, 28713 __unstableExpandSelection 28714 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 28715 const notifyCopy = useNotifyCopy(); 28716 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 28717 function handler(event) { 28718 const selectedBlockClientIds = getSelectedBlockClientIds(); 28719 28720 if (selectedBlockClientIds.length === 0) { 28721 return; 28722 } // Always handle multiple selected blocks. 28723 28724 28725 if (!hasMultiSelection()) { 28726 const { 28727 target 28728 } = event; 28729 const { 28730 ownerDocument 28731 } = target; // If copying, only consider actual text selection as selection. 28732 // Otherwise, any focus on an input field is considered. 28733 28734 const hasSelection = event.type === 'copy' || event.type === 'cut' ? (0,external_wp_dom_namespaceObject.documentHasUncollapsedSelection)(ownerDocument) : (0,external_wp_dom_namespaceObject.documentHasSelection)(ownerDocument); // Let native copy behaviour take over in input fields. 28735 28736 if (hasSelection) { 28737 return; 28738 } 28739 } 28740 28741 if (!node.contains(event.target.ownerDocument.activeElement)) { 28742 return; 28743 } 28744 28745 const eventDefaultPrevented = event.defaultPrevented; 28746 event.preventDefault(); 28747 28748 const isSelectionMergeable = __unstableIsSelectionMergeable(); 28749 28750 const shouldHandleWholeBlocks = __unstableIsSelectionCollapsed() || __unstableIsFullySelected(); 28751 28752 const expandSelectionIsNeeded = !shouldHandleWholeBlocks && !isSelectionMergeable; 28753 28754 if (event.type === 'copy' || event.type === 'cut') { 28755 if (selectedBlockClientIds.length === 1) { 28756 flashBlock(selectedBlockClientIds[0]); 28757 } // If we have a partial selection that is not mergeable, just 28758 // expand the selection to the whole blocks. 28759 28760 28761 if (expandSelectionIsNeeded) { 28762 __unstableExpandSelection(); 28763 } else { 28764 notifyCopy(event.type, selectedBlockClientIds); 28765 let blocks; // Check if we have partial selection. 28766 28767 if (shouldHandleWholeBlocks) { 28768 blocks = getBlocksByClientId(selectedBlockClientIds); 28769 } else { 28770 const [head, tail] = __unstableGetSelectedBlocksWithPartialSelection(); 28771 28772 const inBetweenBlocks = getBlocksByClientId(selectedBlockClientIds.slice(1, selectedBlockClientIds.length - 1)); 28773 blocks = [head, ...inBetweenBlocks, tail]; 28774 } 28775 28776 const serialized = (0,external_wp_blocks_namespaceObject.serialize)(blocks); 28777 event.clipboardData.setData('text/plain', serialized); 28778 event.clipboardData.setData('text/html', serialized); 28779 } 28780 } 28781 28782 if (event.type === 'cut') { 28783 // We need to also check if at the start we needed to 28784 // expand the selection, as in this point we might have 28785 // programmatically fully selected the blocks above. 28786 if (shouldHandleWholeBlocks && !expandSelectionIsNeeded) { 28787 removeBlocks(selectedBlockClientIds); 28788 } else { 28789 __unstableDeleteSelection(); 28790 } 28791 } else if (event.type === 'paste') { 28792 if (eventDefaultPrevented) { 28793 // This was likely already handled in rich-text/use-paste-handler.js. 28794 return; 28795 } 28796 28797 const { 28798 __experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML 28799 } = getSettings(); 28800 const { 28801 plainText, 28802 html 28803 } = getPasteEventData(event); 28804 const blocks = (0,external_wp_blocks_namespaceObject.pasteHandler)({ 28805 HTML: html, 28806 plainText, 28807 mode: 'BLOCKS', 28808 canUserUseUnfilteredHTML 28809 }); 28810 replaceBlocks(selectedBlockClientIds, blocks, blocks.length - 1, -1); 28811 } 28812 } 28813 28814 node.ownerDocument.addEventListener('copy', handler); 28815 node.ownerDocument.addEventListener('cut', handler); 28816 node.ownerDocument.addEventListener('paste', handler); 28817 return () => { 28818 node.ownerDocument.removeEventListener('copy', handler); 28819 node.ownerDocument.removeEventListener('cut', handler); 28820 node.ownerDocument.removeEventListener('paste', handler); 28821 }; 28822 }, []); 28823 } 28824 28825 function CopyHandler(_ref) { 28826 let { 28827 children 28828 } = _ref; 28829 return (0,external_wp_element_namespaceObject.createElement)("div", { 28830 ref: useClipboardHandler() 28831 }, children); 28832 } 28833 /** 28834 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/copy-handler/README.md 28835 */ 28836 28837 28838 /* harmony default export */ var copy_handler = (CopyHandler); 28839 28840 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-actions/index.js 28841 /** 28842 * External dependencies 28843 */ 28844 28845 /** 28846 * WordPress dependencies 28847 */ 28848 28849 28850 28851 /** 28852 * Internal dependencies 28853 */ 28854 28855 28856 28857 function BlockActions(_ref) { 28858 let { 28859 clientIds, 28860 children, 28861 __experimentalUpdateSelection: updateSelection 28862 } = _ref; 28863 const { 28864 canInsertBlockType, 28865 getBlockRootClientId, 28866 getBlocksByClientId, 28867 canMoveBlocks, 28868 canRemoveBlocks 28869 } = (0,external_wp_data_namespaceObject.useSelect)(store); 28870 const { 28871 getDefaultBlockName, 28872 getGroupingBlockName 28873 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store); 28874 const blocks = getBlocksByClientId(clientIds); 28875 const rootClientId = getBlockRootClientId(clientIds[0]); 28876 const canDuplicate = (0,external_lodash_namespaceObject.every)(blocks, block => { 28877 return !!block && (0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'multiple', true) && canInsertBlockType(block.name, rootClientId); 28878 }); 28879 const canInsertDefaultBlock = canInsertBlockType(getDefaultBlockName(), rootClientId); 28880 const canMove = canMoveBlocks(clientIds, rootClientId); 28881 const canRemove = canRemoveBlocks(clientIds, rootClientId); 28882 const { 28883 removeBlocks, 28884 replaceBlocks, 28885 duplicateBlocks, 28886 insertAfterBlock, 28887 insertBeforeBlock, 28888 flashBlock, 28889 setBlockMovingClientId, 28890 setNavigationMode, 28891 selectBlock 28892 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 28893 const notifyCopy = useNotifyCopy(); 28894 return children({ 28895 canDuplicate, 28896 canInsertDefaultBlock, 28897 canMove, 28898 canRemove, 28899 rootClientId, 28900 blocks, 28901 28902 onDuplicate() { 28903 return duplicateBlocks(clientIds, updateSelection); 28904 }, 28905 28906 onRemove() { 28907 return removeBlocks(clientIds, updateSelection); 28908 }, 28909 28910 onInsertBefore() { 28911 insertBeforeBlock((0,external_lodash_namespaceObject.first)((0,external_lodash_namespaceObject.castArray)(clientIds))); 28912 }, 28913 28914 onInsertAfter() { 28915 insertAfterBlock((0,external_lodash_namespaceObject.last)((0,external_lodash_namespaceObject.castArray)(clientIds))); 28916 }, 28917 28918 onMoveTo() { 28919 setNavigationMode(true); 28920 selectBlock(clientIds[0]); 28921 setBlockMovingClientId(clientIds[0]); 28922 }, 28923 28924 onGroup() { 28925 if (!blocks.length) { 28926 return; 28927 } 28928 28929 const groupingBlockName = getGroupingBlockName(); // Activate the `transform` on `core/group` which does the conversion. 28930 28931 const newBlocks = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, groupingBlockName); 28932 28933 if (!newBlocks) { 28934 return; 28935 } 28936 28937 replaceBlocks(clientIds, newBlocks); 28938 }, 28939 28940 onUngroup() { 28941 if (!blocks.length) { 28942 return; 28943 } 28944 28945 const innerBlocks = blocks[0].innerBlocks; 28946 28947 if (!innerBlocks.length) { 28948 return; 28949 } 28950 28951 replaceBlocks(clientIds, innerBlocks); 28952 }, 28953 28954 onCopy() { 28955 const selectedBlockClientIds = blocks.map(_ref2 => { 28956 let { 28957 clientId 28958 } = _ref2; 28959 return clientId; 28960 }); 28961 28962 if (blocks.length === 1) { 28963 flashBlock(selectedBlockClientIds[0]); 28964 } 28965 28966 notifyCopy('copy', selectedBlockClientIds); 28967 } 28968 28969 }); 28970 } 28971 28972 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-mode-toggle.js 28973 28974 28975 /** 28976 * External dependencies 28977 */ 28978 28979 /** 28980 * WordPress dependencies 28981 */ 28982 28983 28984 28985 28986 28987 28988 /** 28989 * Internal dependencies 28990 */ 28991 28992 28993 function BlockModeToggle(_ref) { 28994 let { 28995 blockType, 28996 mode, 28997 onToggleMode, 28998 small = false, 28999 isCodeEditingEnabled = true 29000 } = _ref; 29001 29002 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'html', true) || !isCodeEditingEnabled) { 29003 return null; 29004 } 29005 29006 const label = mode === 'visual' ? (0,external_wp_i18n_namespaceObject.__)('Edit as HTML') : (0,external_wp_i18n_namespaceObject.__)('Edit visually'); 29007 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 29008 onClick: onToggleMode 29009 }, !small && label); 29010 } 29011 /* harmony default export */ var block_mode_toggle = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, _ref2) => { 29012 let { 29013 clientId 29014 } = _ref2; 29015 const { 29016 getBlock, 29017 getBlockMode, 29018 getSettings 29019 } = select(store); 29020 const block = getBlock(clientId); 29021 const isCodeEditingEnabled = getSettings().codeEditingEnabled; 29022 return { 29023 mode: getBlockMode(clientId), 29024 blockType: block ? (0,external_wp_blocks_namespaceObject.getBlockType)(block.name) : null, 29025 isCodeEditingEnabled 29026 }; 29027 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref3) => { 29028 let { 29029 onToggle = external_lodash_namespaceObject.noop, 29030 clientId 29031 } = _ref3; 29032 return { 29033 onToggleMode() { 29034 dispatch(store).toggleBlockMode(clientId); 29035 onToggle(); 29036 } 29037 29038 }; 29039 })])(BlockModeToggle)); 29040 29041 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-convert-button.js 29042 29043 29044 /** 29045 * WordPress dependencies 29046 */ 29047 29048 29049 function BlockConvertButton(_ref) { 29050 let { 29051 shouldRender, 29052 onClick, 29053 small 29054 } = _ref; 29055 29056 if (!shouldRender) { 29057 return null; 29058 } 29059 29060 const label = (0,external_wp_i18n_namespaceObject.__)('Convert to Blocks'); 29061 29062 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 29063 onClick: onClick 29064 }, !small && label); 29065 } 29066 29067 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-html-convert-button.js 29068 /** 29069 * WordPress dependencies 29070 */ 29071 29072 29073 29074 /** 29075 * Internal dependencies 29076 */ 29077 29078 29079 29080 /* harmony default export */ var block_html_convert_button = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, _ref) => { 29081 let { 29082 clientId 29083 } = _ref; 29084 const block = select(store).getBlock(clientId); 29085 return { 29086 block, 29087 shouldRender: block && block.name === 'core/html' 29088 }; 29089 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref2) => { 29090 let { 29091 block 29092 } = _ref2; 29093 return { 29094 onClick: () => dispatch(store).replaceBlocks(block.clientId, (0,external_wp_blocks_namespaceObject.rawHandler)({ 29095 HTML: (0,external_wp_blocks_namespaceObject.getBlockContent)(block) 29096 })) 29097 }; 29098 }))(BlockConvertButton)); 29099 29100 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-settings-menu-first-item.js 29101 /** 29102 * WordPress dependencies 29103 */ 29104 29105 const { 29106 Fill: __unstableBlockSettingsMenuFirstItem, 29107 Slot: block_settings_menu_first_item_Slot 29108 } = (0,external_wp_components_namespaceObject.createSlotFill)('__unstableBlockSettingsMenuFirstItem'); 29109 __unstableBlockSettingsMenuFirstItem.Slot = block_settings_menu_first_item_Slot; 29110 /* harmony default export */ var block_settings_menu_first_item = (__unstableBlockSettingsMenuFirstItem); 29111 29112 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/convert-to-group-buttons/index.js 29113 29114 29115 /** 29116 * WordPress dependencies 29117 */ 29118 29119 29120 29121 29122 /** 29123 * Internal dependencies 29124 */ 29125 29126 29127 29128 29129 29130 function ConvertToGroupButton(_ref) { 29131 let { 29132 clientIds, 29133 isGroupable, 29134 isUngroupable, 29135 blocksSelection, 29136 groupingBlockName, 29137 onClose = () => {} 29138 } = _ref; 29139 const { 29140 replaceBlocks 29141 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 29142 29143 const onConvertToGroup = () => { 29144 // Activate the `transform` on the Grouping Block which does the conversion. 29145 const newBlocks = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocksSelection, groupingBlockName); 29146 29147 if (newBlocks) { 29148 replaceBlocks(clientIds, newBlocks); 29149 } 29150 }; 29151 29152 const onConvertFromGroup = () => { 29153 const innerBlocks = blocksSelection[0].innerBlocks; 29154 29155 if (!innerBlocks.length) { 29156 return; 29157 } 29158 29159 replaceBlocks(clientIds, innerBlocks); 29160 }; 29161 29162 if (!isGroupable && !isUngroupable) { 29163 return null; 29164 } 29165 29166 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isGroupable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 29167 onClick: () => { 29168 onConvertToGroup(); 29169 onClose(); 29170 } 29171 }, (0,external_wp_i18n_namespaceObject._x)('Group', 'verb')), isUngroupable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 29172 onClick: () => { 29173 onConvertFromGroup(); 29174 onClose(); 29175 } 29176 }, (0,external_wp_i18n_namespaceObject._x)('Ungroup', 'Ungrouping blocks from within a Group block back into individual blocks within the Editor '))); 29177 } 29178 29179 29180 29181 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js 29182 /** 29183 * WordPress dependencies 29184 */ 29185 29186 29187 /** 29188 * Internal dependencies 29189 */ 29190 29191 29192 /** 29193 * Contains the properties `ConvertToGroupButton` component needs. 29194 * 29195 * @typedef {Object} ConvertToGroupButtonProps 29196 * @property {string[]} clientIds An array of the selected client ids. 29197 * @property {boolean} isGroupable Indicates if the selected blocks can be grouped. 29198 * @property {boolean} isUngroupable Indicates if the selected blocks can be ungrouped. 29199 * @property {WPBlock[]} blocksSelection An array of the selected blocks. 29200 * @property {string} groupingBlockName The name of block used for handling grouping interactions. 29201 */ 29202 29203 /** 29204 * Returns the properties `ConvertToGroupButton` component needs to work properly. 29205 * It is used in `BlockSettingsMenuControls` to know if `ConvertToGroupButton` 29206 * should be rendered, to avoid ending up with an empty MenuGroup. 29207 * 29208 * @return {ConvertToGroupButtonProps} Returns the properties needed by `ConvertToGroupButton`. 29209 */ 29210 29211 function useConvertToGroupButtonProps() { 29212 const { 29213 clientIds, 29214 isGroupable, 29215 isUngroupable, 29216 blocksSelection, 29217 groupingBlockName 29218 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 29219 var _blocksSelection$; 29220 29221 const { 29222 getBlockRootClientId, 29223 getBlocksByClientId, 29224 canInsertBlockType, 29225 getSelectedBlockClientIds 29226 } = select(store); 29227 const { 29228 getGroupingBlockName 29229 } = select(external_wp_blocks_namespaceObject.store); 29230 29231 const _clientIds = getSelectedBlockClientIds(); 29232 29233 const _groupingBlockName = getGroupingBlockName(); 29234 29235 const rootClientId = !!(_clientIds !== null && _clientIds !== void 0 && _clientIds.length) ? getBlockRootClientId(_clientIds[0]) : undefined; 29236 const groupingBlockAvailable = canInsertBlockType(_groupingBlockName, rootClientId); 29237 29238 const _blocksSelection = getBlocksByClientId(_clientIds); 29239 29240 const isSingleGroupingBlock = _blocksSelection.length === 1 && ((_blocksSelection$ = _blocksSelection[0]) === null || _blocksSelection$ === void 0 ? void 0 : _blocksSelection$.name) === _groupingBlockName; // Do we have 29241 // 1. Grouping block available to be inserted? 29242 // 2. One or more blocks selected 29243 29244 const _isGroupable = groupingBlockAvailable && _blocksSelection.length; // Do we have a single Group Block selected and does that group have inner blocks? 29245 29246 29247 const _isUngroupable = isSingleGroupingBlock && !!_blocksSelection[0].innerBlocks.length; 29248 29249 return { 29250 clientIds: _clientIds, 29251 isGroupable: _isGroupable, 29252 isUngroupable: _isUngroupable, 29253 blocksSelection: _blocksSelection, 29254 groupingBlockName: _groupingBlockName 29255 }; 29256 }, []); 29257 return { 29258 clientIds, 29259 isGroupable, 29260 isUngroupable, 29261 blocksSelection, 29262 groupingBlockName 29263 }; 29264 } 29265 29266 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/unlock.js 29267 29268 29269 /** 29270 * WordPress dependencies 29271 */ 29272 29273 const unlock = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 29274 viewBox: "0 0 24 24", 29275 xmlns: "http://www.w3.org/2000/svg" 29276 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 29277 d: "M17 10h-1.2V7c0-2.1-1.7-3.8-3.8-3.8-2.1 0-3.8 1.7-3.8 3.8h1.5c0-1.2 1-2.2 2.2-2.2s2.2 1 2.2 2.2v3H7c-.6 0-1 .4-1 1v8c0 .6.4 1 1 1h10c.6 0 1-.4 1-1v-8c0-.6-.4-1-1-1z" 29278 })); 29279 /* harmony default export */ var library_unlock = (unlock); 29280 29281 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/lock.js 29282 29283 29284 /** 29285 * WordPress dependencies 29286 */ 29287 29288 const lock = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 29289 viewBox: "0 0 24 24", 29290 xmlns: "http://www.w3.org/2000/svg" 29291 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 29292 d: "M17 10h-1.2V7c0-2.1-1.7-3.8-3.8-3.8-2.1 0-3.8 1.7-3.8 3.8v3H7c-.6 0-1 .4-1 1v8c0 .6.4 1 1 1h10c.6 0 1-.4 1-1v-8c0-.6-.4-1-1-1zm-2.8 0H9.8V7c0-1.2 1-2.2 2.2-2.2s2.2 1 2.2 2.2v3z" 29293 })); 29294 /* harmony default export */ var library_lock = (lock); 29295 29296 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-lock/use-block-lock.js 29297 /** 29298 * WordPress dependencies 29299 */ 29300 29301 /** 29302 * Internal dependencies 29303 */ 29304 29305 29306 /** 29307 * Return details about the block lock status. 29308 * 29309 * @param {string} clientId The block client Id. 29310 * 29311 * @return {Object} Block lock status 29312 */ 29313 29314 function useBlockLock(clientId) { 29315 return (0,external_wp_data_namespaceObject.useSelect)(select => { 29316 const { 29317 canMoveBlock, 29318 canRemoveBlock, 29319 canLockBlockType, 29320 getBlockName, 29321 getBlockRootClientId 29322 } = select(store); 29323 const rootClientId = getBlockRootClientId(clientId); 29324 const canMove = canMoveBlock(clientId, rootClientId); 29325 const canRemove = canRemoveBlock(clientId, rootClientId); 29326 return { 29327 canMove, 29328 canRemove, 29329 canLock: canLockBlockType(getBlockName(clientId)), 29330 isLocked: !canMove || !canRemove 29331 }; 29332 }, [clientId]); 29333 } 29334 29335 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-lock/modal.js 29336 29337 29338 /** 29339 * WordPress dependencies 29340 */ 29341 29342 29343 29344 29345 29346 29347 /** 29348 * Internal dependencies 29349 */ 29350 29351 29352 29353 29354 function BlockLockModal(_ref) { 29355 let { 29356 clientId, 29357 onClose 29358 } = _ref; 29359 const [lock, setLock] = (0,external_wp_element_namespaceObject.useState)({ 29360 move: false, 29361 remove: false 29362 }); 29363 const { 29364 canMove, 29365 canRemove 29366 } = useBlockLock(clientId); 29367 const { 29368 updateBlockAttributes 29369 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 29370 const blockInformation = useBlockDisplayInformation(clientId); 29371 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockLockModal, 'block-editor-block-lock-modal__options-title'); 29372 (0,external_wp_element_namespaceObject.useEffect)(() => { 29373 setLock({ 29374 move: !canMove, 29375 remove: !canRemove 29376 }); 29377 }, [canMove, canRemove]); 29378 const isAllChecked = Object.values(lock).every(Boolean); 29379 const isMixed = Object.values(lock).some(Boolean) && !isAllChecked; 29380 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { 29381 title: (0,external_wp_i18n_namespaceObject.sprintf)( 29382 /* translators: %s: Name of the block. */ 29383 (0,external_wp_i18n_namespaceObject.__)('Lock %s'), blockInformation.title), 29384 overlayClassName: "block-editor-block-lock-modal", 29385 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'), 29386 onRequestClose: onClose 29387 }, (0,external_wp_element_namespaceObject.createElement)("form", { 29388 onSubmit: event => { 29389 event.preventDefault(); 29390 updateBlockAttributes([clientId], { 29391 lock 29392 }); 29393 onClose(); 29394 } 29395 }, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Choose specific attributes to restrict or lock all available options.')), (0,external_wp_element_namespaceObject.createElement)("div", { 29396 role: "group", 29397 "aria-labelledby": instanceId, 29398 className: "block-editor-block-lock-modal__options" 29399 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 29400 className: "block-editor-block-lock-modal__options-title", 29401 label: (0,external_wp_element_namespaceObject.createElement)("span", { 29402 id: instanceId 29403 }, (0,external_wp_i18n_namespaceObject.__)('Lock all')), 29404 checked: isAllChecked, 29405 indeterminate: isMixed, 29406 onChange: newValue => setLock({ 29407 move: newValue, 29408 remove: newValue 29409 }) 29410 }), (0,external_wp_element_namespaceObject.createElement)("ul", { 29411 className: "block-editor-block-lock-modal__checklist" 29412 }, (0,external_wp_element_namespaceObject.createElement)("li", { 29413 className: "block-editor-block-lock-modal__checklist-item" 29414 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 29415 label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Disable movement'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, { 29416 icon: lock.move ? library_lock : library_unlock 29417 })), 29418 checked: lock.move, 29419 onChange: move => setLock(prevLock => ({ ...prevLock, 29420 move 29421 })) 29422 })), (0,external_wp_element_namespaceObject.createElement)("li", { 29423 className: "block-editor-block-lock-modal__checklist-item" 29424 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 29425 label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Prevent removal'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, { 29426 icon: lock.remove ? library_lock : library_unlock 29427 })), 29428 checked: lock.remove, 29429 onChange: remove => setLock(prevLock => ({ ...prevLock, 29430 remove 29431 })) 29432 })))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, { 29433 className: "block-editor-block-lock-modal__actions", 29434 justify: "flex-end", 29435 expanded: false 29436 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 29437 variant: "tertiary", 29438 onClick: onClose 29439 }, (0,external_wp_i18n_namespaceObject.__)('Cancel'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 29440 variant: "primary", 29441 type: "submit" 29442 }, (0,external_wp_i18n_namespaceObject.__)('Apply')))))); 29443 } 29444 29445 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-lock/menu-item.js 29446 29447 29448 /** 29449 * WordPress dependencies 29450 */ 29451 29452 29453 29454 29455 /** 29456 * Internal dependencies 29457 */ 29458 29459 29460 29461 function BlockLockMenuItem(_ref) { 29462 let { 29463 clientId 29464 } = _ref; 29465 const { 29466 canLock, 29467 isLocked 29468 } = useBlockLock(clientId); 29469 const [isModalOpen, toggleModal] = (0,external_wp_element_namespaceObject.useReducer)(isActive => !isActive, false); 29470 29471 if (!canLock) { 29472 return null; 29473 } 29474 29475 const label = isLocked ? (0,external_wp_i18n_namespaceObject.__)('Unlock') : (0,external_wp_i18n_namespaceObject.__)('Lock'); 29476 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 29477 icon: isLocked ? library_unlock : library_lock, 29478 onClick: toggleModal 29479 }, label), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(BlockLockModal, { 29480 clientId: clientId, 29481 onClose: toggleModal 29482 })); 29483 } 29484 29485 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu-controls/index.js 29486 29487 29488 29489 /** 29490 * External dependencies 29491 */ 29492 29493 /** 29494 * WordPress dependencies 29495 */ 29496 29497 29498 29499 /** 29500 * Internal dependencies 29501 */ 29502 29503 29504 29505 29506 const { 29507 Fill, 29508 Slot: block_settings_menu_controls_Slot 29509 } = (0,external_wp_components_namespaceObject.createSlotFill)('BlockSettingsMenuControls'); 29510 29511 const BlockSettingsMenuControlsSlot = _ref => { 29512 let { 29513 fillProps, 29514 clientIds = null 29515 } = _ref; 29516 const { 29517 selectedBlocks, 29518 selectedClientIds, 29519 canRemove 29520 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 29521 const { 29522 getBlocksByClientId, 29523 getSelectedBlockClientIds, 29524 canRemoveBlocks 29525 } = select(store); 29526 const ids = clientIds !== null ? clientIds : getSelectedBlockClientIds(); 29527 return { 29528 selectedBlocks: (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.compact)(getBlocksByClientId(ids)), block => block.name), 29529 selectedClientIds: ids, 29530 canRemove: canRemoveBlocks(ids) 29531 }; 29532 }, [clientIds]); 29533 const showLockButton = selectedClientIds.length === 1; // Check if current selection of blocks is Groupable or Ungroupable 29534 // and pass this props down to ConvertToGroupButton. 29535 29536 const convertToGroupButtonProps = useConvertToGroupButtonProps(); 29537 const { 29538 isGroupable, 29539 isUngroupable 29540 } = convertToGroupButtonProps; 29541 const showConvertToGroupButton = (isGroupable || isUngroupable) && canRemove; 29542 return (0,external_wp_element_namespaceObject.createElement)(block_settings_menu_controls_Slot, { 29543 fillProps: { ...fillProps, 29544 selectedBlocks, 29545 selectedClientIds 29546 } 29547 }, fills => { 29548 if (!(fills !== null && fills !== void 0 && fills.length) > 0 && !showConvertToGroupButton && !showLockButton) { 29549 return null; 29550 } 29551 29552 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, showLockButton && (0,external_wp_element_namespaceObject.createElement)(BlockLockMenuItem, { 29553 clientId: selectedClientIds[0] 29554 }), fills, showConvertToGroupButton && (0,external_wp_element_namespaceObject.createElement)(ConvertToGroupButton, _extends({}, convertToGroupButtonProps, { 29555 onClose: fillProps === null || fillProps === void 0 ? void 0 : fillProps.onClose 29556 }))); 29557 }); 29558 }; 29559 /** 29560 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-settings-menu-controls/README.md 29561 * 29562 * @param {Object} props Fill props. 29563 * @return {WPElement} Element. 29564 */ 29565 29566 29567 function BlockSettingsMenuControls(_ref2) { 29568 let { ...props 29569 } = _ref2; 29570 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, { 29571 document: document 29572 }, (0,external_wp_element_namespaceObject.createElement)(Fill, props)); 29573 } 29574 29575 BlockSettingsMenuControls.Slot = BlockSettingsMenuControlsSlot; 29576 /* harmony default export */ var block_settings_menu_controls = (BlockSettingsMenuControls); 29577 29578 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-settings-dropdown.js 29579 29580 29581 29582 /** 29583 * External dependencies 29584 */ 29585 29586 /** 29587 * WordPress dependencies 29588 */ 29589 29590 29591 29592 29593 29594 29595 29596 29597 29598 /** 29599 * Internal dependencies 29600 */ 29601 29602 29603 29604 29605 29606 29607 29608 29609 29610 29611 const block_settings_dropdown_POPOVER_PROPS = { 29612 className: 'block-editor-block-settings-menu__popover', 29613 position: 'bottom right', 29614 isAlternate: true 29615 }; 29616 29617 function CopyMenuItem(_ref) { 29618 let { 29619 blocks, 29620 onCopy 29621 } = _ref; 29622 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(() => (0,external_wp_blocks_namespaceObject.serialize)(blocks), onCopy); 29623 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 29624 ref: ref 29625 }, (0,external_wp_i18n_namespaceObject.__)('Copy')); 29626 } 29627 29628 function BlockSettingsDropdown(_ref2) { 29629 let { 29630 clientIds, 29631 __experimentalSelectBlock, 29632 children, 29633 ...props 29634 } = _ref2; 29635 const blockClientIds = (0,external_lodash_namespaceObject.castArray)(clientIds); 29636 const count = blockClientIds.length; 29637 const firstBlockClientId = blockClientIds[0]; 29638 const { 29639 firstParentClientId, 29640 hasReducedUI, 29641 onlyBlock, 29642 parentBlockType, 29643 previousBlockClientId, 29644 nextBlockClientId, 29645 selectedBlockClientIds 29646 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 29647 const { 29648 getBlockCount, 29649 getBlockName, 29650 getBlockParents, 29651 getPreviousBlockClientId, 29652 getNextBlockClientId, 29653 getSelectedBlockClientIds, 29654 getSettings 29655 } = select(store); 29656 const parents = getBlockParents(firstBlockClientId); 29657 const _firstParentClientId = parents[parents.length - 1]; 29658 const parentBlockName = getBlockName(_firstParentClientId); 29659 return { 29660 firstParentClientId: _firstParentClientId, 29661 hasReducedUI: getSettings().hasReducedUI, 29662 onlyBlock: 1 === getBlockCount(), 29663 parentBlockType: (0,external_wp_blocks_namespaceObject.getBlockType)(parentBlockName), 29664 previousBlockClientId: getPreviousBlockClientId(firstBlockClientId), 29665 nextBlockClientId: getNextBlockClientId(firstBlockClientId), 29666 selectedBlockClientIds: getSelectedBlockClientIds() 29667 }; 29668 }, [firstBlockClientId]); 29669 const shortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => { 29670 const { 29671 getShortcutRepresentation 29672 } = select(external_wp_keyboardShortcuts_namespaceObject.store); 29673 return { 29674 duplicate: getShortcutRepresentation('core/block-editor/duplicate'), 29675 remove: getShortcutRepresentation('core/block-editor/remove'), 29676 insertAfter: getShortcutRepresentation('core/block-editor/insert-after'), 29677 insertBefore: getShortcutRepresentation('core/block-editor/insert-before') 29678 }; 29679 }, []); 29680 const { 29681 selectBlock, 29682 toggleBlockHighlight 29683 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 29684 const updateSelectionAfterDuplicate = (0,external_wp_element_namespaceObject.useCallback)(__experimentalSelectBlock ? async clientIdsPromise => { 29685 const ids = await clientIdsPromise; 29686 29687 if (ids && ids[0]) { 29688 __experimentalSelectBlock(ids[0]); 29689 } 29690 } : external_lodash_namespaceObject.noop, [__experimentalSelectBlock]); 29691 const blockTitle = useBlockDisplayTitle(firstBlockClientId, 25); 29692 const updateSelectionAfterRemove = (0,external_wp_element_namespaceObject.useCallback)(__experimentalSelectBlock ? () => { 29693 const blockToSelect = previousBlockClientId || nextBlockClientId; 29694 29695 if (blockToSelect && // From the block options dropdown, it's possible to remove a block that is not selected, 29696 // in this case, it's not necessary to update the selection since the selected block wasn't removed. 29697 selectedBlockClientIds.includes(firstBlockClientId) && // Don't update selection when next/prev block also is in the selection ( and gets removed ), 29698 // In case someone selects all blocks and removes them at once. 29699 !selectedBlockClientIds.includes(blockToSelect)) { 29700 __experimentalSelectBlock(blockToSelect); 29701 } 29702 } : external_lodash_namespaceObject.noop, [__experimentalSelectBlock, previousBlockClientId, nextBlockClientId, selectedBlockClientIds]); 29703 const label = (0,external_wp_i18n_namespaceObject.sprintf)( 29704 /* translators: %s: block name */ 29705 (0,external_wp_i18n_namespaceObject.__)('Remove %s'), blockTitle); 29706 const removeBlockLabel = count === 1 ? label : (0,external_wp_i18n_namespaceObject.__)('Remove blocks'); // Allows highlighting the parent block outline when focusing or hovering 29707 // the parent block selector within the child. 29708 29709 const selectParentButtonRef = (0,external_wp_element_namespaceObject.useRef)(); 29710 const { 29711 gestures: showParentOutlineGestures 29712 } = useShowMoversGestures({ 29713 ref: selectParentButtonRef, 29714 29715 onChange(isFocused) { 29716 if (isFocused && hasReducedUI) { 29717 return; 29718 } 29719 29720 toggleBlockHighlight(firstParentClientId, isFocused); 29721 } 29722 29723 }); 29724 return (0,external_wp_element_namespaceObject.createElement)(BlockActions, { 29725 clientIds: clientIds, 29726 __experimentalUpdateSelection: !__experimentalSelectBlock 29727 }, _ref3 => { 29728 let { 29729 canDuplicate, 29730 canInsertDefaultBlock, 29731 canMove, 29732 canRemove, 29733 onDuplicate, 29734 onInsertAfter, 29735 onInsertBefore, 29736 onRemove, 29737 onCopy, 29738 onMoveTo, 29739 blocks 29740 } = _ref3; 29741 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, _extends({ 29742 icon: more_vertical, 29743 label: (0,external_wp_i18n_namespaceObject.__)('Options'), 29744 className: "block-editor-block-settings-menu", 29745 popoverProps: block_settings_dropdown_POPOVER_PROPS, 29746 noIcons: true 29747 }, props), _ref4 => { 29748 let { 29749 onClose 29750 } = _ref4; 29751 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(block_settings_menu_first_item.Slot, { 29752 fillProps: { 29753 onClose 29754 } 29755 }), firstParentClientId !== undefined && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, _extends({}, showParentOutlineGestures, { 29756 ref: selectParentButtonRef, 29757 icon: (0,external_wp_element_namespaceObject.createElement)(block_icon, { 29758 icon: parentBlockType.icon 29759 }), 29760 onClick: () => selectBlock(firstParentClientId) 29761 }), (0,external_wp_i18n_namespaceObject.sprintf)( 29762 /* translators: %s: Name of the block's parent. */ 29763 (0,external_wp_i18n_namespaceObject.__)('Select parent block (%s)'), parentBlockType.title)), count === 1 && (0,external_wp_element_namespaceObject.createElement)(block_html_convert_button, { 29764 clientId: firstBlockClientId 29765 }), (0,external_wp_element_namespaceObject.createElement)(CopyMenuItem, { 29766 blocks: blocks, 29767 onCopy: onCopy 29768 }), canDuplicate && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 29769 onClick: (0,external_lodash_namespaceObject.flow)(onClose, onDuplicate, updateSelectionAfterDuplicate), 29770 shortcut: shortcuts.duplicate 29771 }, (0,external_wp_i18n_namespaceObject.__)('Duplicate')), canInsertDefaultBlock && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 29772 onClick: (0,external_lodash_namespaceObject.flow)(onClose, onInsertBefore), 29773 shortcut: shortcuts.insertBefore 29774 }, (0,external_wp_i18n_namespaceObject.__)('Insert before')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 29775 onClick: (0,external_lodash_namespaceObject.flow)(onClose, onInsertAfter), 29776 shortcut: shortcuts.insertAfter 29777 }, (0,external_wp_i18n_namespaceObject.__)('Insert after'))), canMove && !onlyBlock && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 29778 onClick: (0,external_lodash_namespaceObject.flow)(onClose, onMoveTo) 29779 }, (0,external_wp_i18n_namespaceObject.__)('Move to')), count === 1 && (0,external_wp_element_namespaceObject.createElement)(block_mode_toggle, { 29780 clientId: firstBlockClientId, 29781 onToggle: onClose 29782 })), (0,external_wp_element_namespaceObject.createElement)(block_settings_menu_controls.Slot, { 29783 fillProps: { 29784 onClose 29785 }, 29786 clientIds: clientIds 29787 }), typeof children === 'function' ? children({ 29788 onClose 29789 }) : external_wp_element_namespaceObject.Children.map(child => (0,external_wp_element_namespaceObject.cloneElement)(child, { 29790 onClose 29791 })), canRemove && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 29792 onClick: (0,external_lodash_namespaceObject.flow)(onClose, onRemove, updateSelectionAfterRemove), 29793 shortcut: shortcuts.remove 29794 }, removeBlockLabel))); 29795 }); 29796 }); 29797 } 29798 /* harmony default export */ var block_settings_dropdown = (BlockSettingsDropdown); 29799 29800 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/index.js 29801 29802 29803 29804 /** 29805 * WordPress dependencies 29806 */ 29807 29808 /** 29809 * Internal dependencies 29810 */ 29811 29812 29813 function BlockSettingsMenu(_ref) { 29814 let { 29815 clientIds, 29816 ...props 29817 } = _ref; 29818 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, null, toggleProps => (0,external_wp_element_namespaceObject.createElement)(block_settings_dropdown, _extends({ 29819 clientIds: clientIds, 29820 toggleProps: toggleProps 29821 }, props)))); 29822 } 29823 /* harmony default export */ var block_settings_menu = (BlockSettingsMenu); 29824 29825 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-lock/toolbar.js 29826 29827 29828 /** 29829 * WordPress dependencies 29830 */ 29831 29832 29833 29834 29835 /** 29836 * Internal dependencies 29837 */ 29838 29839 29840 29841 29842 function BlockLockToolbar(_ref) { 29843 let { 29844 clientId 29845 } = _ref; 29846 const blockInformation = useBlockDisplayInformation(clientId); 29847 const { 29848 canMove, 29849 canRemove, 29850 canLock 29851 } = useBlockLock(clientId); 29852 const [isModalOpen, toggleModal] = (0,external_wp_element_namespaceObject.useReducer)(isActive => !isActive, false); 29853 29854 if (!canLock) { 29855 return null; 29856 } 29857 29858 if (canMove && canRemove) { 29859 return null; 29860 } 29861 29862 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, { 29863 className: "block-editor-block-lock-toolbar" 29864 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 29865 icon: library_lock, 29866 label: (0,external_wp_i18n_namespaceObject.sprintf)( 29867 /* translators: %s: block name */ 29868 (0,external_wp_i18n_namespaceObject.__)('Unlock %s'), blockInformation.title), 29869 onClick: toggleModal 29870 })), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(BlockLockModal, { 29871 clientId: clientId, 29872 onClose: toggleModal 29873 })); 29874 } 29875 29876 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/group.js 29877 29878 29879 /** 29880 * WordPress dependencies 29881 */ 29882 29883 const group_group = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 29884 viewBox: "0 0 24 24", 29885 xmlns: "http://www.w3.org/2000/svg" 29886 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 29887 d: "M18 4h-7c-1.1 0-2 .9-2 2v3H6c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h7c1.1 0 2-.9 2-2v-3h3c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4.5 14c0 .3-.2.5-.5.5H6c-.3 0-.5-.2-.5-.5v-7c0-.3.2-.5.5-.5h3V13c0 1.1.9 2 2 2h2.5v3zm0-4.5H11c-.3 0-.5-.2-.5-.5v-2.5H13c.3 0 .5.2.5.5v2.5zm5-.5c0 .3-.2.5-.5.5h-3V11c0-1.1-.9-2-2-2h-2.5V6c0-.3.2-.5.5-.5h7c.3 0 .5.2.5.5v7z" 29888 })); 29889 /* harmony default export */ var library_group = (group_group); 29890 29891 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/row.js 29892 29893 29894 /** 29895 * WordPress dependencies 29896 */ 29897 29898 const row = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 29899 xmlns: "http://www.w3.org/2000/svg", 29900 viewBox: "0 0 24 24" 29901 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 29902 d: "M9.2 6.5H4V8h5.2c.3 0 .5.2.5.5v7c0 .3-.2.5-.5.5H4v1.5h5.2c1.1 0 2-.9 2-2v-7c0-1.1-.8-2-2-2zM14.8 8H20V6.5h-5.2c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2H20V16h-5.2c-.3 0-.5-.2-.5-.5v-7c-.1-.3.2-.5.5-.5z" 29903 })); 29904 /* harmony default export */ var library_row = (row); 29905 29906 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/stack.js 29907 29908 29909 /** 29910 * WordPress dependencies 29911 */ 29912 29913 const stack = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 29914 xmlns: "http://www.w3.org/2000/svg", 29915 viewBox: "0 0 24 24" 29916 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 29917 d: "M16 4v5.2c0 .3-.2.5-.5.5h-7c-.3.1-.5-.2-.5-.5V4H6.5v5.2c0 1.1.9 2 2 2h7c1.1 0 2-.9 2-2V4H16zm-.5 8.8h-7c-1.1 0-2 .9-2 2V20H8v-5.2c0-.3.2-.5.5-.5h7c.3 0 .5.2.5.5V20h1.5v-5.2c0-1.2-.9-2-2-2z" 29918 })); 29919 /* harmony default export */ var library_stack = (stack); 29920 29921 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/convert-to-group-buttons/toolbar.js 29922 29923 29924 /** 29925 * WordPress dependencies 29926 */ 29927 29928 29929 29930 29931 29932 /** 29933 * Internal dependencies 29934 */ 29935 29936 29937 29938 const layouts = { 29939 group: undefined, 29940 row: { 29941 type: 'flex', 29942 flexWrap: 'nowrap' 29943 }, 29944 stack: { 29945 type: 'flex', 29946 orientation: 'vertical' 29947 } 29948 }; 29949 29950 function BlockGroupToolbar() { 29951 const { 29952 blocksSelection, 29953 clientIds, 29954 groupingBlockName, 29955 isGroupable 29956 } = useConvertToGroupButtonProps(); 29957 const { 29958 replaceBlocks 29959 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 29960 const { 29961 canRemove 29962 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 29963 const { 29964 canRemoveBlocks 29965 } = select(store); 29966 return { 29967 canRemove: canRemoveBlocks(clientIds) 29968 }; 29969 }, [clientIds]); 29970 29971 const onConvertToGroup = function () { 29972 let layout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'group'; 29973 const newBlocks = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocksSelection, groupingBlockName); 29974 29975 if (newBlocks && newBlocks.length > 0) { 29976 // Because the block is not in the store yet we can't use 29977 // updateBlockAttributes so need to manually update attributes. 29978 newBlocks[0].attributes.layout = layouts[layout]; 29979 replaceBlocks(clientIds, newBlocks); 29980 } 29981 }; 29982 29983 const onConvertToRow = () => onConvertToGroup('row'); 29984 29985 const onConvertToStack = () => onConvertToGroup('stack'); // Don't render the button if the current selection cannot be grouped. 29986 // A good example is selecting multiple button blocks within a Buttons block: 29987 // The group block is not a valid child of Buttons, so we should not show the button. 29988 // Any blocks that are locked against removal also cannot be grouped. 29989 29990 29991 if (!isGroupable || !canRemove) { 29992 return null; 29993 } 29994 29995 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 29996 icon: library_group, 29997 label: (0,external_wp_i18n_namespaceObject._x)('Group', 'verb'), 29998 onClick: onConvertToGroup 29999 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 30000 icon: library_row, 30001 label: (0,external_wp_i18n_namespaceObject._x)('Row', 'single horizontal line'), 30002 onClick: onConvertToRow 30003 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 30004 icon: library_stack, 30005 label: (0,external_wp_i18n_namespaceObject._x)('Stack', 'verb'), 30006 onClick: onConvertToStack 30007 })); 30008 } 30009 30010 /* harmony default export */ var toolbar = (BlockGroupToolbar); 30011 30012 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/block-name-context.js 30013 /** 30014 * WordPress dependencies 30015 */ 30016 30017 30018 const __unstableBlockNameContext = (0,external_wp_element_namespaceObject.createContext)(''); 30019 30020 /* harmony default export */ var block_name_context = (__unstableBlockNameContext); 30021 30022 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/index.js 30023 30024 30025 30026 /** 30027 * External dependencies 30028 */ 30029 30030 /** 30031 * WordPress dependencies 30032 */ 30033 30034 30035 30036 30037 30038 30039 /** 30040 * Internal dependencies 30041 */ 30042 30043 30044 30045 30046 30047 30048 30049 30050 30051 30052 30053 30054 30055 const BlockToolbar = _ref => { 30056 let { 30057 hideDragHandle 30058 } = _ref; 30059 const { 30060 blockClientIds, 30061 blockClientId, 30062 blockType, 30063 hasFixedToolbar, 30064 hasReducedUI, 30065 isValid, 30066 isVisual 30067 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 30068 const { 30069 getBlockName, 30070 getBlockMode, 30071 getSelectedBlockClientIds, 30072 isBlockValid, 30073 getBlockRootClientId, 30074 getSettings 30075 } = select(store); 30076 const selectedBlockClientIds = getSelectedBlockClientIds(); 30077 const selectedBlockClientId = selectedBlockClientIds[0]; 30078 const blockRootClientId = getBlockRootClientId(selectedBlockClientId); 30079 const settings = getSettings(); 30080 return { 30081 blockClientIds: selectedBlockClientIds, 30082 blockClientId: selectedBlockClientId, 30083 blockType: selectedBlockClientId && (0,external_wp_blocks_namespaceObject.getBlockType)(getBlockName(selectedBlockClientId)), 30084 hasFixedToolbar: settings.hasFixedToolbar, 30085 hasReducedUI: settings.hasReducedUI, 30086 rootClientId: blockRootClientId, 30087 isValid: selectedBlockClientIds.every(id => isBlockValid(id)), 30088 isVisual: selectedBlockClientIds.every(id => getBlockMode(id) === 'visual') 30089 }; 30090 }, []); // Handles highlighting the current block outline on hover or focus of the 30091 // block type toolbar area. 30092 30093 const { 30094 toggleBlockHighlight 30095 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 30096 const nodeRef = (0,external_wp_element_namespaceObject.useRef)(); 30097 const { 30098 showMovers, 30099 gestures: showMoversGestures 30100 } = useShowMoversGestures({ 30101 ref: nodeRef, 30102 30103 onChange(isFocused) { 30104 if (isFocused && hasReducedUI) { 30105 return; 30106 } 30107 30108 toggleBlockHighlight(blockClientId, isFocused); 30109 } 30110 30111 }); // Account for the cases where the block toolbar is rendered within the 30112 // header area and not contextually to the block. 30113 30114 const displayHeaderToolbar = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<') || hasFixedToolbar; 30115 30116 if (blockType) { 30117 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, '__experimentalToolbar', true)) { 30118 return null; 30119 } 30120 } 30121 30122 const shouldShowMovers = displayHeaderToolbar || showMovers; 30123 30124 if (blockClientIds.length === 0) { 30125 return null; 30126 } 30127 30128 const shouldShowVisualToolbar = isValid && isVisual; 30129 const isMultiToolbar = blockClientIds.length > 1; 30130 const classes = classnames_default()('block-editor-block-toolbar', shouldShowMovers && 'is-showing-movers'); 30131 return (0,external_wp_element_namespaceObject.createElement)("div", { 30132 className: classes 30133 }, !isMultiToolbar && !displayHeaderToolbar && (0,external_wp_element_namespaceObject.createElement)(BlockParentSelector, { 30134 clientIds: blockClientIds 30135 }), (0,external_wp_element_namespaceObject.createElement)("div", _extends({ 30136 ref: nodeRef 30137 }, showMoversGestures), (shouldShowVisualToolbar || isMultiToolbar) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, { 30138 className: "block-editor-block-toolbar__block-controls" 30139 }, (0,external_wp_element_namespaceObject.createElement)(block_switcher, { 30140 clientIds: blockClientIds 30141 }), !isMultiToolbar && (0,external_wp_element_namespaceObject.createElement)(BlockLockToolbar, { 30142 clientId: blockClientIds[0] 30143 }), (0,external_wp_element_namespaceObject.createElement)(block_mover, { 30144 clientIds: blockClientIds, 30145 hideDragHandle: hideDragHandle || hasReducedUI 30146 }))), shouldShowVisualToolbar && isMultiToolbar && (0,external_wp_element_namespaceObject.createElement)(toolbar, null), shouldShowVisualToolbar && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, { 30147 group: "parent", 30148 className: "block-editor-block-toolbar__slot" 30149 }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, { 30150 group: "block", 30151 className: "block-editor-block-toolbar__slot" 30152 }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, { 30153 className: "block-editor-block-toolbar__slot" 30154 }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, { 30155 group: "inline", 30156 className: "block-editor-block-toolbar__slot" 30157 }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, { 30158 group: "other", 30159 className: "block-editor-block-toolbar__slot" 30160 }), (0,external_wp_element_namespaceObject.createElement)(block_name_context.Provider, { 30161 value: blockType === null || blockType === void 0 ? void 0 : blockType.name 30162 }, (0,external_wp_element_namespaceObject.createElement)(block_toolbar_last_item.Slot, null))), (0,external_wp_element_namespaceObject.createElement)(block_settings_menu, { 30163 clientIds: blockClientIds 30164 })); 30165 }; 30166 /** 30167 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md 30168 */ 30169 30170 30171 /* harmony default export */ var block_toolbar = (BlockToolbar); 30172 30173 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/block-contextual-toolbar.js 30174 30175 30176 30177 /** 30178 * External dependencies 30179 */ 30180 30181 /** 30182 * WordPress dependencies 30183 */ 30184 30185 30186 30187 30188 /** 30189 * Internal dependencies 30190 */ 30191 30192 30193 30194 30195 30196 function BlockContextualToolbar(_ref) { 30197 let { 30198 focusOnMount, 30199 isFixed, 30200 ...props 30201 } = _ref; 30202 const { 30203 blockType, 30204 hasParents, 30205 showParentSelector 30206 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 30207 const { 30208 getBlockName, 30209 getBlockParents, 30210 getSelectedBlockClientIds 30211 } = select(store); 30212 const { 30213 getBlockType 30214 } = select(external_wp_blocks_namespaceObject.store); 30215 const selectedBlockClientIds = getSelectedBlockClientIds(); 30216 const selectedBlockClientId = selectedBlockClientIds[0]; 30217 const parents = getBlockParents(selectedBlockClientId); 30218 const firstParentClientId = parents[parents.length - 1]; 30219 const parentBlockName = getBlockName(firstParentClientId); 30220 const parentBlockType = getBlockType(parentBlockName); 30221 return { 30222 blockType: selectedBlockClientId && getBlockType(getBlockName(selectedBlockClientId)), 30223 hasParents: parents.length, 30224 showParentSelector: (0,external_wp_blocks_namespaceObject.hasBlockSupport)(parentBlockType, '__experimentalParentSelector', true) && selectedBlockClientIds.length <= 1 30225 }; 30226 }, []); 30227 30228 if (blockType) { 30229 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, '__experimentalToolbar', true)) { 30230 return null; 30231 } 30232 } // Shifts the toolbar to make room for the parent block selector. 30233 30234 30235 const classes = classnames_default()('block-editor-block-contextual-toolbar', { 30236 'has-parent': hasParents && showParentSelector, 30237 'is-fixed': isFixed 30238 }); 30239 return (0,external_wp_element_namespaceObject.createElement)(navigable_toolbar, _extends({ 30240 focusOnMount: focusOnMount, 30241 className: classes 30242 /* translators: accessibility text for the block toolbar */ 30243 , 30244 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block tools') 30245 }, props), (0,external_wp_element_namespaceObject.createElement)(block_toolbar, { 30246 hideDragHandle: isFixed 30247 })); 30248 } 30249 30250 /* harmony default export */ var block_contextual_toolbar = (BlockContextualToolbar); 30251 30252 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/block-popover.js 30253 30254 30255 /** 30256 * External dependencies 30257 */ 30258 30259 30260 /** 30261 * WordPress dependencies 30262 */ 30263 30264 30265 30266 30267 30268 30269 30270 30271 /** 30272 * Internal dependencies 30273 */ 30274 30275 30276 30277 30278 30279 30280 30281 30282 function block_popover_selector(select) { 30283 const { 30284 isNavigationMode, 30285 isMultiSelecting, 30286 hasMultiSelection, 30287 isTyping, 30288 isCaretWithinFormattedText, 30289 getSettings, 30290 getLastMultiSelectedBlockClientId 30291 } = select(store); 30292 return { 30293 isNavigationMode: isNavigationMode(), 30294 isMultiSelecting: isMultiSelecting(), 30295 isTyping: isTyping(), 30296 isCaretWithinFormattedText: isCaretWithinFormattedText(), 30297 hasMultiSelection: hasMultiSelection(), 30298 hasFixedToolbar: getSettings().hasFixedToolbar, 30299 lastClientId: getLastMultiSelectedBlockClientId() 30300 }; 30301 } 30302 30303 function BlockPopover(_ref) { 30304 let { 30305 clientId, 30306 rootClientId, 30307 isValid, 30308 isEmptyDefaultBlock, 30309 capturingClientId, 30310 __unstablePopoverSlot, 30311 __unstableContentRef 30312 } = _ref; 30313 const { 30314 isNavigationMode, 30315 isMultiSelecting, 30316 isTyping, 30317 isCaretWithinFormattedText, 30318 hasMultiSelection, 30319 hasFixedToolbar, 30320 lastClientId 30321 } = (0,external_wp_data_namespaceObject.useSelect)(block_popover_selector, []); 30322 const isInsertionPointVisible = (0,external_wp_data_namespaceObject.useSelect)(select => { 30323 const { 30324 isBlockInsertionPointVisible, 30325 getBlockInsertionPoint, 30326 getBlockOrder 30327 } = select(store); 30328 30329 if (!isBlockInsertionPointVisible()) { 30330 return false; 30331 } 30332 30333 const insertionPoint = getBlockInsertionPoint(); 30334 const order = getBlockOrder(insertionPoint.rootClientId); 30335 return order[insertionPoint.index] === clientId; 30336 }, [clientId]); 30337 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); 30338 const [isToolbarForced, setIsToolbarForced] = (0,external_wp_element_namespaceObject.useState)(false); 30339 const [isInserterShown, setIsInserterShown] = (0,external_wp_element_namespaceObject.useState)(false); 30340 const { 30341 stopTyping 30342 } = (0,external_wp_data_namespaceObject.useDispatch)(store); // Controls when the side inserter on empty lines should 30343 // be shown, including writing and selection modes. 30344 30345 const showEmptyBlockSideInserter = !isTyping && !isNavigationMode && isEmptyDefaultBlock && isValid; 30346 const shouldShowBreadcrumb = isNavigationMode; 30347 const shouldShowContextualToolbar = !isNavigationMode && !hasFixedToolbar && isLargeViewport && !showEmptyBlockSideInserter && !isMultiSelecting && (!isTyping || isCaretWithinFormattedText); 30348 const canFocusHiddenToolbar = !isNavigationMode && !shouldShowContextualToolbar && !hasFixedToolbar && !isEmptyDefaultBlock; 30349 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/block-editor/focus-toolbar', () => { 30350 setIsToolbarForced(true); 30351 stopTyping(true); 30352 }, { 30353 isDisabled: !canFocusHiddenToolbar 30354 }); 30355 (0,external_wp_element_namespaceObject.useEffect)(() => { 30356 if (!shouldShowContextualToolbar) { 30357 setIsToolbarForced(false); 30358 } 30359 }, [shouldShowContextualToolbar]); // Stores the active toolbar item index so the block toolbar can return focus 30360 // to it when re-mounting. 30361 30362 const initialToolbarItemIndexRef = (0,external_wp_element_namespaceObject.useRef)(); 30363 const selectedElement = useBlockElement(clientId); 30364 const lastSelectedElement = useBlockElement(lastClientId); 30365 const capturingElement = useBlockElement(capturingClientId); 30366 const popoverScrollRef = usePopoverScroll(__unstableContentRef); 30367 30368 if (!shouldShowBreadcrumb && !shouldShowContextualToolbar && !isToolbarForced && !showEmptyBlockSideInserter) { 30369 return null; 30370 } 30371 30372 let node = selectedElement; 30373 30374 if (!node) { 30375 return null; 30376 } 30377 30378 if (capturingClientId) { 30379 node = capturingElement; 30380 } 30381 30382 let anchorRef = node; 30383 30384 if (hasMultiSelection) { 30385 // Wait to render the popover until the bottom reference is available 30386 // as well. 30387 if (!lastSelectedElement) { 30388 return null; 30389 } 30390 30391 anchorRef = { 30392 top: node, 30393 bottom: lastSelectedElement 30394 }; 30395 } 30396 30397 function onFocus() { 30398 setIsInserterShown(true); 30399 } 30400 30401 function onBlur() { 30402 setIsInserterShown(false); 30403 } // Position above the anchor, pop out towards the right, and position in the 30404 // left corner. For the side inserter, pop out towards the left, and 30405 // position in the right corner. 30406 // To do: refactor `Popover` to make this prop clearer. 30407 30408 30409 const popoverPosition = showEmptyBlockSideInserter ? 'top left right' : 'top right left'; 30410 const { 30411 ownerDocument 30412 } = node; 30413 const stickyBoundaryElement = showEmptyBlockSideInserter ? undefined : // The sticky boundary element should be the boundary at which the 30414 // the block toolbar becomes sticky when the block scolls out of view. 30415 // In case of an iframe, this should be the iframe boundary, otherwise 30416 // the scroll container. 30417 ownerDocument.defaultView.frameElement || (0,external_wp_dom_namespaceObject.getScrollContainer)(node) || ownerDocument.body; 30418 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { 30419 ref: popoverScrollRef, 30420 noArrow: true, 30421 animate: false, 30422 position: popoverPosition, 30423 focusOnMount: false, 30424 anchorRef: anchorRef, 30425 className: classnames_default()('block-editor-block-list__block-popover', { 30426 'is-insertion-point-visible': isInsertionPointVisible 30427 }), 30428 __unstableStickyBoundaryElement: stickyBoundaryElement // Render in the old slot if needed for backward compatibility, 30429 // otherwise render in place (not in the the default popover slot). 30430 , 30431 __unstableSlotName: __unstablePopoverSlot || null, 30432 __unstableBoundaryParent: true // Observe movement for block animations (especially horizontal). 30433 , 30434 __unstableObserveElement: node, 30435 shouldAnchorIncludePadding: true // Used to safeguard sticky position behavior against cases where it would permanently 30436 // obscure specific sections of a block. 30437 , 30438 __unstableEditorCanvasWrapper: __unstableContentRef === null || __unstableContentRef === void 0 ? void 0 : __unstableContentRef.current 30439 }, (shouldShowContextualToolbar || isToolbarForced) && (0,external_wp_element_namespaceObject.createElement)("div", { 30440 onFocus: onFocus, 30441 onBlur: onBlur // While ideally it would be enough to capture the 30442 // bubbling focus event from the Inserter, due to the 30443 // characteristics of click focusing of `button`s in 30444 // Firefox and Safari, it is not reliable. 30445 // 30446 // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus 30447 , 30448 tabIndex: -1, 30449 className: classnames_default()('block-editor-block-list__block-popover-inserter', { 30450 'is-visible': isInserterShown 30451 }) 30452 }, (0,external_wp_element_namespaceObject.createElement)(inserter, { 30453 clientId: clientId, 30454 rootClientId: rootClientId, 30455 __experimentalIsQuick: true 30456 })), (shouldShowContextualToolbar || isToolbarForced) && (0,external_wp_element_namespaceObject.createElement)(block_contextual_toolbar // If the toolbar is being shown because of being forced 30457 // it should focus the toolbar right after the mount. 30458 , { 30459 focusOnMount: isToolbarForced, 30460 __experimentalInitialIndex: initialToolbarItemIndexRef.current, 30461 __experimentalOnIndexChange: index => { 30462 initialToolbarItemIndexRef.current = index; 30463 } // Resets the index whenever the active block changes so 30464 // this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169 30465 , 30466 key: clientId 30467 }), shouldShowBreadcrumb && (0,external_wp_element_namespaceObject.createElement)(block_selection_button, { 30468 clientId: clientId, 30469 rootClientId: rootClientId, 30470 blockElement: node 30471 }), showEmptyBlockSideInserter && (0,external_wp_element_namespaceObject.createElement)("div", { 30472 className: "block-editor-block-list__empty-block-inserter" 30473 }, (0,external_wp_element_namespaceObject.createElement)(inserter, { 30474 position: "bottom right", 30475 rootClientId: rootClientId, 30476 clientId: clientId, 30477 __experimentalIsQuick: true 30478 }))); 30479 } 30480 30481 function wrapperSelector(select) { 30482 const { 30483 getSelectedBlockClientId, 30484 getFirstMultiSelectedBlockClientId, 30485 getBlockRootClientId, 30486 getBlock, 30487 getBlockParents, 30488 __experimentalGetBlockListSettingsForBlocks 30489 } = select(store); 30490 const clientId = getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId(); 30491 30492 if (!clientId) { 30493 return; 30494 } 30495 30496 const { 30497 name, 30498 attributes = {}, 30499 isValid 30500 } = getBlock(clientId) || {}; 30501 const blockParentsClientIds = getBlockParents(clientId); // Get Block List Settings for all ancestors of the current Block clientId. 30502 30503 const parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(blockParentsClientIds); // Get the clientId of the topmost parent with the capture toolbars setting. 30504 30505 30506 const capturingClientId = (0,external_lodash_namespaceObject.find)(blockParentsClientIds, parentClientId => { 30507 var _parentBlockListSetti; 30508 30509 return (_parentBlockListSetti = parentBlockListSettings[parentClientId]) === null || _parentBlockListSetti === void 0 ? void 0 : _parentBlockListSetti.__experimentalCaptureToolbars; 30510 }); 30511 return { 30512 clientId, 30513 rootClientId: getBlockRootClientId(clientId), 30514 name, 30515 isValid, 30516 isEmptyDefaultBlock: name && (0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)({ 30517 name, 30518 attributes 30519 }), 30520 capturingClientId 30521 }; 30522 } 30523 30524 function WrappedBlockPopover(_ref2) { 30525 let { 30526 __unstablePopoverSlot, 30527 __unstableContentRef 30528 } = _ref2; 30529 const selected = (0,external_wp_data_namespaceObject.useSelect)(wrapperSelector, []); 30530 30531 if (!selected) { 30532 return null; 30533 } 30534 30535 const { 30536 clientId, 30537 rootClientId, 30538 name, 30539 isValid, 30540 isEmptyDefaultBlock, 30541 capturingClientId 30542 } = selected; 30543 30544 if (!name) { 30545 return null; 30546 } 30547 30548 return (0,external_wp_element_namespaceObject.createElement)(BlockPopover, { 30549 clientId: clientId, 30550 rootClientId: rootClientId, 30551 isValid: isValid, 30552 isEmptyDefaultBlock: isEmptyDefaultBlock, 30553 capturingClientId: capturingClientId, 30554 __unstablePopoverSlot: __unstablePopoverSlot, 30555 __unstableContentRef: __unstableContentRef 30556 }); 30557 } 30558 30559 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/back-compat.js 30560 30561 30562 /** 30563 * WordPress dependencies 30564 */ 30565 30566 30567 30568 /** 30569 * Internal dependencies 30570 */ 30571 30572 30573 30574 function BlockToolsBackCompat(_ref) { 30575 let { 30576 children 30577 } = _ref; 30578 const openRef = (0,external_wp_element_namespaceObject.useContext)(InsertionPointOpenRef); 30579 const isDisabled = (0,external_wp_element_namespaceObject.useContext)(external_wp_components_namespaceObject.Disabled.Context); // If context is set, `BlockTools` is a parent component. 30580 30581 if (openRef || isDisabled) { 30582 return children; 30583 } 30584 30585 external_wp_deprecated_default()('wp.components.Popover.Slot name="block-toolbar"', { 30586 alternative: 'wp.blockEditor.BlockTools', 30587 since: '5.8' 30588 }); 30589 return (0,external_wp_element_namespaceObject.createElement)(InsertionPoint, { 30590 __unstablePopoverSlot: "block-toolbar" 30591 }, (0,external_wp_element_namespaceObject.createElement)(WrappedBlockPopover, { 30592 __unstablePopoverSlot: "block-toolbar" 30593 }), children); 30594 } 30595 30596 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/with-client-id.js 30597 30598 30599 30600 /** 30601 * WordPress dependencies 30602 */ 30603 30604 /** 30605 * Internal dependencies 30606 */ 30607 30608 30609 const withClientId = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => { 30610 const { 30611 clientId 30612 } = useBlockEditContext(); 30613 return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, { 30614 clientId: clientId 30615 })); 30616 }, 'withClientId'); 30617 /* harmony default export */ var with_client_id = (withClientId); 30618 30619 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/button-block-appender.js 30620 30621 30622 /** 30623 * External dependencies 30624 */ 30625 30626 /** 30627 * Internal dependencies 30628 */ 30629 30630 30631 30632 const button_block_appender_ButtonBlockAppender = _ref => { 30633 let { 30634 clientId, 30635 showSeparator, 30636 isFloating, 30637 onAddBlock, 30638 isToggle 30639 } = _ref; 30640 return (0,external_wp_element_namespaceObject.createElement)(button_block_appender, { 30641 className: classnames_default()({ 30642 'block-list-appender__toggle': isToggle 30643 }), 30644 rootClientId: clientId, 30645 showSeparator: showSeparator, 30646 isFloating: isFloating, 30647 onAddBlock: onAddBlock 30648 }); 30649 }; 30650 /* harmony default export */ var inner_blocks_button_block_appender = (with_client_id(button_block_appender_ButtonBlockAppender)); 30651 30652 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/default-block-appender.js 30653 30654 30655 /** 30656 * External dependencies 30657 */ 30658 30659 /** 30660 * WordPress dependencies 30661 */ 30662 30663 30664 30665 /** 30666 * Internal dependencies 30667 */ 30668 30669 30670 30671 30672 const default_block_appender_DefaultBlockAppender = _ref => { 30673 let { 30674 clientId 30675 } = _ref; 30676 return (0,external_wp_element_namespaceObject.createElement)(default_block_appender, { 30677 rootClientId: clientId 30678 }); 30679 }; 30680 /* harmony default export */ var inner_blocks_default_block_appender = ((0,external_wp_compose_namespaceObject.compose)([with_client_id, (0,external_wp_data_namespaceObject.withSelect)((select, _ref2) => { 30681 let { 30682 clientId 30683 } = _ref2; 30684 const { 30685 getBlockOrder 30686 } = select(store); 30687 const blockClientIds = getBlockOrder(clientId); 30688 return { 30689 lastBlockClientId: (0,external_lodash_namespaceObject.last)(blockClientIds) 30690 }; 30691 })])(default_block_appender_DefaultBlockAppender)); 30692 30693 ;// CONCATENATED MODULE: external ["wp","isShallowEqual"] 30694 var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"]; 30695 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject); 30696 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/use-nested-settings-update.js 30697 /** 30698 * WordPress dependencies 30699 */ 30700 30701 30702 30703 /** 30704 * Internal dependencies 30705 */ 30706 30707 30708 30709 /** @typedef {import('../../selectors').WPDirectInsertBlock } WPDirectInsertBlock */ 30710 30711 /** 30712 * This hook is a side effect which updates the block-editor store when changes 30713 * happen to inner block settings. The given props are transformed into a 30714 * settings object, and if that is different from the current settings object in 30715 * the block-editor store, then the store is updated with the new settings which 30716 * came from props. 30717 * 30718 * @param {string} clientId The client ID of the block to update. 30719 * @param {string[]} allowedBlocks An array of block names which are permitted 30720 * in inner blocks. 30721 * @param {?WPDirectInsertBlock} __experimentalDefaultBlock The default block to insert: [ blockName, { blockAttributes } ]. 30722 * @param {?Function|boolean} __experimentalDirectInsert If a default block should be inserted directly by the 30723 * appender. 30724 * @param {string} [templateLock] The template lock specified for the inner 30725 * blocks component. (e.g. "all") 30726 * @param {boolean} captureToolbars Whether or children toolbars should be shown 30727 * in the inner blocks component rather than on 30728 * the child block. 30729 * @param {string} orientation The direction in which the block 30730 * should face. 30731 * @param {Object} layout The layout object for the block container. 30732 */ 30733 30734 function useNestedSettingsUpdate(clientId, allowedBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, captureToolbars, orientation, layout) { 30735 const { 30736 updateBlockListSettings 30737 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 30738 const { 30739 blockListSettings, 30740 parentLock 30741 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 30742 const rootClientId = select(store).getBlockRootClientId(clientId); 30743 return { 30744 blockListSettings: select(store).getBlockListSettings(clientId), 30745 parentLock: select(store).getTemplateLock(rootClientId) 30746 }; 30747 }, [clientId]); // Memoize as inner blocks implementors often pass a new array on every 30748 // render. 30749 30750 const _allowedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => allowedBlocks, allowedBlocks); 30751 30752 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 30753 const newSettings = { 30754 allowedBlocks: _allowedBlocks, 30755 templateLock: templateLock === undefined ? parentLock : templateLock 30756 }; // These values are not defined for RN, so only include them if they 30757 // are defined. 30758 30759 if (captureToolbars !== undefined) { 30760 newSettings.__experimentalCaptureToolbars = captureToolbars; 30761 } // Orientation depends on layout, 30762 // ideally the separate orientation prop should be deprecated. 30763 30764 30765 if (orientation !== undefined) { 30766 newSettings.orientation = orientation; 30767 } else { 30768 const layoutType = getLayoutType(layout === null || layout === void 0 ? void 0 : layout.type); 30769 newSettings.orientation = layoutType.getOrientation(layout); 30770 } 30771 30772 if (__experimentalDefaultBlock !== undefined) { 30773 newSettings.__experimentalDefaultBlock = __experimentalDefaultBlock; 30774 } 30775 30776 if (__experimentalDirectInsert !== undefined) { 30777 newSettings.__experimentalDirectInsert = __experimentalDirectInsert; 30778 } 30779 30780 if (!external_wp_isShallowEqual_default()(blockListSettings, newSettings)) { 30781 updateBlockListSettings(clientId, newSettings); 30782 } 30783 }, [clientId, blockListSettings, _allowedBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, parentLock, captureToolbars, orientation, updateBlockListSettings, layout]); 30784 } 30785 30786 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/use-inner-block-template-sync.js 30787 /** 30788 * External dependencies 30789 */ 30790 30791 /** 30792 * WordPress dependencies 30793 */ 30794 30795 30796 30797 30798 /** 30799 * Internal dependencies 30800 */ 30801 30802 30803 /** 30804 * This hook makes sure that a block's inner blocks stay in sync with the given 30805 * block "template". The template is a block hierarchy to which inner blocks must 30806 * conform. If the blocks get "out of sync" with the template and the template 30807 * is meant to be locked (e.g. templateLock = "all"), then we replace the inner 30808 * blocks with the correct value after synchronizing it with the template. 30809 * 30810 * @param {string} clientId The block client ID. 30811 * @param {Object} template The template to match. 30812 * @param {string} templateLock The template lock state for the inner blocks. For 30813 * example, if the template lock is set to "all", 30814 * then the inner blocks will stay in sync with the 30815 * template. If not defined or set to false, then 30816 * the inner blocks will not be synchronized with 30817 * the given template. 30818 * @param {boolean} templateInsertUpdatesSelection Whether or not to update the 30819 * block-editor selection state when inner blocks 30820 * are replaced after template synchronization. 30821 */ 30822 30823 function useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection) { 30824 const { 30825 getSelectedBlocksInitialCaretPosition 30826 } = (0,external_wp_data_namespaceObject.useSelect)(store); 30827 const { 30828 replaceInnerBlocks 30829 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 30830 const innerBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlocks(clientId), [clientId]); // Maintain a reference to the previous value so we can do a deep equality check. 30831 30832 const existingTemplate = (0,external_wp_element_namespaceObject.useRef)(null); 30833 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 30834 // Only synchronize innerBlocks with template if innerBlocks are empty or 30835 // a locking all exists directly on the block. 30836 if (innerBlocks.length === 0 || templateLock === 'all') { 30837 const hasTemplateChanged = !(0,external_lodash_namespaceObject.isEqual)(template, existingTemplate.current); 30838 30839 if (hasTemplateChanged) { 30840 existingTemplate.current = template; 30841 const nextBlocks = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(innerBlocks, template); 30842 30843 if (!(0,external_lodash_namespaceObject.isEqual)(nextBlocks, innerBlocks)) { 30844 replaceInnerBlocks(clientId, nextBlocks, innerBlocks.length === 0 && templateInsertUpdatesSelection && nextBlocks.length !== 0, // This ensures the "initialPosition" doesn't change when applying the template 30845 // If we're supposed to focus the block, we'll focus the first inner block 30846 // otherwise, we won't apply any auto-focus. 30847 // This ensures for instance that the focus stays in the inserter when inserting the "buttons" block. 30848 getSelectedBlocksInitialCaretPosition()); 30849 } 30850 } 30851 } 30852 }, [innerBlocks, template, templateLock, clientId]); 30853 } 30854 30855 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/get-block-context.js 30856 /** 30857 * External dependencies 30858 */ 30859 30860 /** 30861 * Block context cache, implemented as a WeakMap mapping block types to a 30862 * WeakMap mapping attributes object to context value. 30863 * 30864 * @type {WeakMap<string,WeakMap<string,*>>} 30865 */ 30866 30867 const BLOCK_CONTEXT_CACHE = new WeakMap(); 30868 /** 30869 * Returns a cached context object value for a given set of attributes for the 30870 * block type. 30871 * 30872 * @param {Record<string,*>} attributes Block attributes object. 30873 * @param {WPBlockType} blockType Block type settings. 30874 * 30875 * @return {Record<string,*>} Context value. 30876 */ 30877 30878 function getBlockContext(attributes, blockType) { 30879 if (!BLOCK_CONTEXT_CACHE.has(blockType)) { 30880 BLOCK_CONTEXT_CACHE.set(blockType, new WeakMap()); 30881 } 30882 30883 const blockTypeCache = BLOCK_CONTEXT_CACHE.get(blockType); 30884 30885 if (!blockTypeCache.has(attributes)) { 30886 const context = (0,external_lodash_namespaceObject.mapValues)(blockType.providesContext, attributeName => attributes[attributeName]); 30887 blockTypeCache.set(attributes, context); 30888 } 30889 30890 return blockTypeCache.get(attributes); 30891 } 30892 30893 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-on-block-drop/index.js 30894 /** 30895 * WordPress dependencies 30896 */ 30897 30898 30899 30900 /** 30901 * Internal dependencies 30902 */ 30903 30904 30905 /** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */ 30906 30907 /** 30908 * Retrieve the data for a block drop event. 30909 * 30910 * @param {WPSyntheticEvent} event The drop event. 30911 * 30912 * @return {Object} An object with block drag and drop data. 30913 */ 30914 30915 function parseDropEvent(event) { 30916 let result = { 30917 srcRootClientId: null, 30918 srcClientIds: null, 30919 srcIndex: null, 30920 type: null, 30921 blocks: null 30922 }; 30923 30924 if (!event.dataTransfer) { 30925 return result; 30926 } 30927 30928 try { 30929 result = Object.assign(result, JSON.parse(event.dataTransfer.getData('wp-blocks'))); 30930 } catch (err) { 30931 return result; 30932 } 30933 30934 return result; 30935 } 30936 /** 30937 * A function that returns an event handler function for block drop events. 30938 * 30939 * @param {string} targetRootClientId The root client id where the block(s) will be inserted. 30940 * @param {number} targetBlockIndex The index where the block(s) will be inserted. 30941 * @param {Function} getBlockIndex A function that gets the index of a block. 30942 * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks. 30943 * @param {Function} moveBlocksToPosition A function that moves blocks. 30944 * @param {Function} insertBlocks A function that inserts blocks. 30945 * @param {Function} clearSelectedBlock A function that clears block selection. 30946 * @return {Function} The event handler for a block drop event. 30947 */ 30948 30949 function onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock) { 30950 return event => { 30951 const { 30952 srcRootClientId: sourceRootClientId, 30953 srcClientIds: sourceClientIds, 30954 type: dropType, 30955 blocks 30956 } = parseDropEvent(event); // If the user is inserting a block. 30957 30958 if (dropType === 'inserter') { 30959 clearSelectedBlock(); 30960 const blocksToInsert = blocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block)); 30961 insertBlocks(blocksToInsert, targetBlockIndex, targetRootClientId, true, null); 30962 } // If the user is moving a block. 30963 30964 30965 if (dropType === 'block') { 30966 const sourceBlockIndex = getBlockIndex(sourceClientIds[0]); // If the user is dropping to the same position, return early. 30967 30968 if (sourceRootClientId === targetRootClientId && sourceBlockIndex === targetBlockIndex) { 30969 return; 30970 } // If the user is attempting to drop a block within its own 30971 // nested blocks, return early as this would create infinite 30972 // recursion. 30973 30974 30975 if (sourceClientIds.includes(targetRootClientId) || getClientIdsOfDescendants(sourceClientIds).some(id => id === targetRootClientId)) { 30976 return; 30977 } 30978 30979 const isAtSameLevel = sourceRootClientId === targetRootClientId; 30980 const draggedBlockCount = sourceClientIds.length; // If the block is kept at the same level and moved downwards, 30981 // subtract to take into account that the blocks being dragged 30982 // were removed from the block list above the insertion point. 30983 30984 const insertIndex = isAtSameLevel && sourceBlockIndex < targetBlockIndex ? targetBlockIndex - draggedBlockCount : targetBlockIndex; 30985 moveBlocksToPosition(sourceClientIds, sourceRootClientId, targetRootClientId, insertIndex); 30986 } 30987 }; 30988 } 30989 /** 30990 * A function that returns an event handler function for block-related file drop events. 30991 * 30992 * @param {string} targetRootClientId The root client id where the block(s) will be inserted. 30993 * @param {number} targetBlockIndex The index where the block(s) will be inserted. 30994 * @param {boolean} hasUploadPermissions Whether the user has upload permissions. 30995 * @param {Function} updateBlockAttributes A function that updates a block's attributes. 30996 * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted. 30997 * @param {Function} insertBlocks A function that inserts blocks. 30998 * 30999 * @return {Function} The event handler for a block-related file drop event. 31000 */ 31001 31002 function onFilesDrop(targetRootClientId, targetBlockIndex, hasUploadPermissions, updateBlockAttributes, canInsertBlockType, insertBlocks) { 31003 return files => { 31004 if (!hasUploadPermissions) { 31005 return; 31006 } 31007 31008 const transformation = (0,external_wp_blocks_namespaceObject.findTransform)((0,external_wp_blocks_namespaceObject.getBlockTransforms)('from'), transform => transform.type === 'files' && canInsertBlockType(transform.blockName, targetRootClientId) && transform.isMatch(files)); 31009 31010 if (transformation) { 31011 const blocks = transformation.transform(files, updateBlockAttributes); 31012 insertBlocks(blocks, targetBlockIndex, targetRootClientId); 31013 } 31014 }; 31015 } 31016 /** 31017 * A function that returns an event handler function for block-related HTML drop events. 31018 * 31019 * @param {string} targetRootClientId The root client id where the block(s) will be inserted. 31020 * @param {number} targetBlockIndex The index where the block(s) will be inserted. 31021 * @param {Function} insertBlocks A function that inserts blocks. 31022 * 31023 * @return {Function} The event handler for a block-related HTML drop event. 31024 */ 31025 31026 function onHTMLDrop(targetRootClientId, targetBlockIndex, insertBlocks) { 31027 return HTML => { 31028 const blocks = (0,external_wp_blocks_namespaceObject.pasteHandler)({ 31029 HTML, 31030 mode: 'BLOCKS' 31031 }); 31032 31033 if (blocks.length) { 31034 insertBlocks(blocks, targetBlockIndex, targetRootClientId); 31035 } 31036 }; 31037 } 31038 /** 31039 * A React hook for handling block drop events. 31040 * 31041 * @param {string} targetRootClientId The root client id where the block(s) will be inserted. 31042 * @param {number} targetBlockIndex The index where the block(s) will be inserted. 31043 * 31044 * @return {Object} An object that contains the event handlers `onDrop`, `onFilesDrop` and `onHTMLDrop`. 31045 */ 31046 31047 function useOnBlockDrop(targetRootClientId, targetBlockIndex) { 31048 const hasUploadPermissions = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings().mediaUpload, []); 31049 const { 31050 canInsertBlockType, 31051 getBlockIndex, 31052 getClientIdsOfDescendants 31053 } = (0,external_wp_data_namespaceObject.useSelect)(store); 31054 const { 31055 insertBlocks, 31056 moveBlocksToPosition, 31057 updateBlockAttributes, 31058 clearSelectedBlock 31059 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 31060 31061 const _onDrop = onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock); 31062 31063 const _onFilesDrop = onFilesDrop(targetRootClientId, targetBlockIndex, hasUploadPermissions, updateBlockAttributes, canInsertBlockType, insertBlocks); 31064 31065 const _onHTMLDrop = onHTMLDrop(targetRootClientId, targetBlockIndex, insertBlocks); 31066 31067 return event => { 31068 const files = (0,external_wp_dom_namespaceObject.getFilesFromDataTransfer)(event.dataTransfer); 31069 const html = event.dataTransfer.getData('text/html'); 31070 /** 31071 * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML. 31072 * The order of the checks is important to recognise the HTML drop. 31073 */ 31074 31075 if (html) { 31076 _onHTMLDrop(html); 31077 } else if (files.length) { 31078 _onFilesDrop(files); 31079 } else { 31080 _onDrop(event); 31081 } 31082 }; 31083 } 31084 31085 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/math.js 31086 /** 31087 * A string representing the name of an edge. 31088 * 31089 * @typedef {'top'|'right'|'bottom'|'left'} WPEdgeName 31090 */ 31091 31092 /** 31093 * @typedef {Object} WPPoint 31094 * @property {number} x The horizontal position. 31095 * @property {number} y The vertical position. 31096 */ 31097 31098 /** 31099 * Given a point, a DOMRect and the name of an edge, returns the distance to 31100 * that edge of the rect. 31101 * 31102 * This function works for edges that are horizontal or vertical (e.g. not 31103 * rotated), the following terms are used so that the function works in both 31104 * orientations: 31105 * 31106 * - Forward, meaning the axis running horizontally when an edge is vertical 31107 * and vertically when an edge is horizontal. 31108 * - Lateral, meaning the axis running vertically when an edge is vertical 31109 * and horizontally when an edge is horizontal. 31110 * 31111 * @param {WPPoint} point The point to measure distance from. 31112 * @param {DOMRect} rect A DOM Rect containing edge positions. 31113 * @param {WPEdgeName} edge The edge to measure to. 31114 */ 31115 function getDistanceFromPointToEdge(point, rect, edge) { 31116 const isHorizontal = edge === 'top' || edge === 'bottom'; 31117 const { 31118 x, 31119 y 31120 } = point; 31121 const pointLateralPosition = isHorizontal ? x : y; 31122 const pointForwardPosition = isHorizontal ? y : x; 31123 const edgeStart = isHorizontal ? rect.left : rect.top; 31124 const edgeEnd = isHorizontal ? rect.right : rect.bottom; 31125 const edgeForwardPosition = rect[edge]; // Measure the straight line distance to the edge of the rect, when the 31126 // point is adjacent to the edge. 31127 // Else, if the point is positioned diagonally to the edge of the rect, 31128 // measure diagonally to the nearest corner that the edge meets. 31129 31130 let edgeLateralPosition; 31131 31132 if (pointLateralPosition >= edgeStart && pointLateralPosition <= edgeEnd) { 31133 edgeLateralPosition = pointLateralPosition; 31134 } else if (pointLateralPosition < edgeEnd) { 31135 edgeLateralPosition = edgeStart; 31136 } else { 31137 edgeLateralPosition = edgeEnd; 31138 } 31139 31140 return Math.sqrt((pointLateralPosition - edgeLateralPosition) ** 2 + (pointForwardPosition - edgeForwardPosition) ** 2); 31141 } 31142 /** 31143 * Given a point, a DOMRect and a list of allowed edges returns the name of and 31144 * distance to the nearest edge. 31145 * 31146 * @param {WPPoint} point The point to measure distance from. 31147 * @param {DOMRect} rect A DOM Rect containing edge positions. 31148 * @param {WPEdgeName[]} allowedEdges A list of the edges included in the 31149 * calculation. Defaults to all edges. 31150 * 31151 * @return {[number, string]} An array where the first value is the distance 31152 * and a second is the edge name. 31153 */ 31154 31155 function getDistanceToNearestEdge(point, rect) { 31156 let allowedEdges = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ['top', 'bottom', 'left', 'right']; 31157 let candidateDistance; 31158 let candidateEdge; 31159 allowedEdges.forEach(edge => { 31160 const distance = getDistanceFromPointToEdge(point, rect, edge); 31161 31162 if (candidateDistance === undefined || distance < candidateDistance) { 31163 candidateDistance = distance; 31164 candidateEdge = edge; 31165 } 31166 }); 31167 return [candidateDistance, candidateEdge]; 31168 } 31169 31170 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-block-drop-zone/index.js 31171 /** 31172 * WordPress dependencies 31173 */ 31174 31175 31176 31177 31178 /** 31179 * Internal dependencies 31180 */ 31181 31182 31183 31184 31185 /** @typedef {import('../../utils/math').WPPoint} WPPoint */ 31186 31187 /** 31188 * The orientation of a block list. 31189 * 31190 * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation 31191 */ 31192 31193 /** 31194 * Given a list of block DOM elements finds the index that a block should be dropped 31195 * at. 31196 * 31197 * @param {Element[]} elements Array of DOM elements that represent each block in a block list. 31198 * @param {WPPoint} position The position of the item being dragged. 31199 * @param {WPBlockListOrientation} orientation The orientation of a block list. 31200 * 31201 * @return {number|undefined} The block index that's closest to the drag position. 31202 */ 31203 31204 function getNearestBlockIndex(elements, position, orientation) { 31205 const allowedEdges = orientation === 'horizontal' ? ['left', 'right'] : ['top', 'bottom']; 31206 const isRightToLeft = (0,external_wp_i18n_namespaceObject.isRTL)(); 31207 let candidateIndex; 31208 let candidateDistance; 31209 elements.forEach((element, index) => { 31210 const rect = element.getBoundingClientRect(); 31211 const [distance, edge] = getDistanceToNearestEdge(position, rect, allowedEdges); 31212 31213 if (candidateDistance === undefined || distance < candidateDistance) { 31214 // If the user is dropping to the trailing edge of the block 31215 // add 1 to the index to represent dragging after. 31216 // Take RTL languages into account where the left edge is 31217 // the trailing edge. 31218 const isTrailingEdge = edge === 'bottom' || !isRightToLeft && edge === 'right' || isRightToLeft && edge === 'left'; 31219 const offset = isTrailingEdge ? 1 : 0; // Update the currently known best candidate. 31220 31221 candidateDistance = distance; 31222 candidateIndex = index + offset; 31223 } 31224 }); 31225 return candidateIndex; 31226 } 31227 /** 31228 * @typedef {Object} WPBlockDropZoneConfig 31229 * @property {string} rootClientId The root client id for the block list. 31230 */ 31231 31232 /** 31233 * A React hook that can be used to make a block list handle drag and drop. 31234 * 31235 * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone. 31236 */ 31237 31238 function useBlockDropZone() { 31239 let { 31240 // An undefined value represents a top-level block. Default to an empty 31241 // string for this so that `targetRootClientId` can be easily compared to 31242 // values returned by the `getRootBlockClientId` selector, which also uses 31243 // an empty string to represent top-level blocks. 31244 rootClientId: targetRootClientId = '' 31245 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 31246 const [targetBlockIndex, setTargetBlockIndex] = (0,external_wp_element_namespaceObject.useState)(null); 31247 const isLockedAll = (0,external_wp_data_namespaceObject.useSelect)(select => { 31248 const { 31249 getTemplateLock 31250 } = select(store); 31251 return getTemplateLock(targetRootClientId) === 'all'; 31252 }, [targetRootClientId]); 31253 const { 31254 getBlockListSettings 31255 } = (0,external_wp_data_namespaceObject.useSelect)(store); 31256 const { 31257 showInsertionPoint, 31258 hideInsertionPoint 31259 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 31260 const onBlockDrop = useOnBlockDrop(targetRootClientId, targetBlockIndex); 31261 const throttled = (0,external_wp_compose_namespaceObject.useThrottle)((0,external_wp_element_namespaceObject.useCallback)((event, currentTarget) => { 31262 var _getBlockListSettings; 31263 31264 const blockElements = Array.from(currentTarget.children).filter( // Ensure the element is a block. It should have the `wp-block` class. 31265 element => element.classList.contains('wp-block')); 31266 const targetIndex = getNearestBlockIndex(blockElements, { 31267 x: event.clientX, 31268 y: event.clientY 31269 }, (_getBlockListSettings = getBlockListSettings(targetRootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation); 31270 setTargetBlockIndex(targetIndex === undefined ? 0 : targetIndex); 31271 31272 if (targetIndex !== null) { 31273 showInsertionPoint(targetRootClientId, targetIndex); 31274 } 31275 }, []), 200); 31276 return (0,external_wp_compose_namespaceObject.__experimentalUseDropZone)({ 31277 isDisabled: isLockedAll, 31278 onDrop: onBlockDrop, 31279 31280 onDragOver(event) { 31281 // `currentTarget` is only available while the event is being 31282 // handled, so get it now and pass it to the thottled function. 31283 // https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget 31284 throttled(event, event.currentTarget); 31285 }, 31286 31287 onDragLeave() { 31288 throttled.cancel(); 31289 hideInsertionPoint(); 31290 setTargetBlockIndex(null); 31291 }, 31292 31293 onDragEnd() { 31294 throttled.cancel(); 31295 hideInsertionPoint(); 31296 setTargetBlockIndex(null); 31297 } 31298 31299 }); 31300 } 31301 31302 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/index.js 31303 31304 31305 31306 /** 31307 * External dependencies 31308 */ 31309 31310 /** 31311 * WordPress dependencies 31312 */ 31313 31314 31315 31316 31317 31318 /** 31319 * Internal dependencies 31320 */ 31321 31322 31323 31324 31325 31326 31327 31328 31329 31330 31331 31332 31333 /** 31334 * InnerBlocks is a component which allows a single block to have multiple blocks 31335 * as children. The UncontrolledInnerBlocks component is used whenever the inner 31336 * blocks are not controlled by another entity. In other words, it is normally 31337 * used for inner blocks in the post editor 31338 * 31339 * @param {Object} props The component props. 31340 */ 31341 31342 function UncontrolledInnerBlocks(props) { 31343 const { 31344 clientId, 31345 allowedBlocks, 31346 __experimentalDefaultBlock, 31347 __experimentalDirectInsert, 31348 template, 31349 templateLock, 31350 wrapperRef, 31351 templateInsertUpdatesSelection, 31352 __experimentalCaptureToolbars: captureToolbars, 31353 __experimentalAppenderTagName, 31354 renderAppender, 31355 orientation, 31356 placeholder, 31357 __experimentalLayout 31358 } = props; 31359 useNestedSettingsUpdate(clientId, allowedBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, captureToolbars, orientation, __experimentalLayout); 31360 useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection); 31361 const context = (0,external_wp_data_namespaceObject.useSelect)(select => { 31362 const block = select(store).getBlock(clientId); 31363 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name); 31364 31365 if (!blockType || !blockType.providesContext) { 31366 return; 31367 } 31368 31369 return getBlockContext(block.attributes, blockType); 31370 }, [clientId]); // This component needs to always be synchronous as it's the one changing 31371 // the async mode depending on the block selection. 31372 31373 return (0,external_wp_element_namespaceObject.createElement)(BlockContextProvider, { 31374 value: context 31375 }, (0,external_wp_element_namespaceObject.createElement)(BlockListItems, { 31376 rootClientId: clientId, 31377 renderAppender: renderAppender, 31378 __experimentalAppenderTagName: __experimentalAppenderTagName, 31379 __experimentalLayout: __experimentalLayout, 31380 wrapperRef: wrapperRef, 31381 placeholder: placeholder 31382 })); 31383 } 31384 /** 31385 * The controlled inner blocks component wraps the uncontrolled inner blocks 31386 * component with the blockSync hook. This keeps the innerBlocks of the block in 31387 * the block-editor store in sync with the blocks of the controlling entity. An 31388 * example of an inner block controller is a template part block, which provides 31389 * its own blocks from the template part entity data source. 31390 * 31391 * @param {Object} props The component props. 31392 */ 31393 31394 31395 function ControlledInnerBlocks(props) { 31396 useBlockSync(props); 31397 return (0,external_wp_element_namespaceObject.createElement)(UncontrolledInnerBlocks, props); 31398 } 31399 31400 const ForwardedInnerBlocks = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => { 31401 const innerBlocksProps = useInnerBlocksProps({ 31402 ref 31403 }, props); 31404 return (0,external_wp_element_namespaceObject.createElement)("div", { 31405 className: "block-editor-inner-blocks" 31406 }, (0,external_wp_element_namespaceObject.createElement)("div", innerBlocksProps)); 31407 }); 31408 /** 31409 * This hook is used to lightly mark an element as an inner blocks wrapper 31410 * element. Call this hook and pass the returned props to the element to mark as 31411 * an inner blocks wrapper, automatically rendering inner blocks as children. If 31412 * you define a ref for the element, it is important to pass the ref to this 31413 * hook, which the hook in turn will pass to the component through the props it 31414 * returns. Optionally, you can also pass any other props through this hook, and 31415 * they will be merged and returned. 31416 * 31417 * @param {Object} props Optional. Props to pass to the element. Must contain 31418 * the ref if one is defined. 31419 * @param {Object} options Optional. Inner blocks options. 31420 * 31421 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md 31422 */ 31423 31424 function useInnerBlocksProps() { 31425 let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 31426 let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 31427 const { 31428 clientId 31429 } = useBlockEditContext(); 31430 const isSmallScreen = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); 31431 const { 31432 __experimentalCaptureToolbars, 31433 hasOverlay 31434 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 31435 if (!clientId) { 31436 return {}; 31437 } 31438 31439 const { 31440 getBlockName, 31441 isBlockSelected, 31442 hasSelectedInnerBlock, 31443 isNavigationMode 31444 } = select(store); 31445 const blockName = getBlockName(clientId); 31446 const enableClickThrough = isNavigationMode() || isSmallScreen; 31447 return { 31448 __experimentalCaptureToolbars: select(external_wp_blocks_namespaceObject.store).hasBlockSupport(blockName, '__experimentalExposeControlsToChildren', false), 31449 hasOverlay: blockName !== 'core/template' && !isBlockSelected(clientId) && !hasSelectedInnerBlock(clientId, true) && enableClickThrough 31450 }; 31451 }, [clientId, isSmallScreen]); 31452 const ref = (0,external_wp_compose_namespaceObject.useMergeRefs)([props.ref, useBlockDropZone({ 31453 rootClientId: clientId 31454 })]); 31455 const innerBlocksProps = { 31456 __experimentalCaptureToolbars, 31457 ...options 31458 }; 31459 const InnerBlocks = innerBlocksProps.value && innerBlocksProps.onChange ? ControlledInnerBlocks : UncontrolledInnerBlocks; 31460 return { ...props, 31461 ref, 31462 className: classnames_default()(props.className, 'block-editor-block-list__layout', { 31463 'has-overlay': hasOverlay 31464 }), 31465 children: clientId ? (0,external_wp_element_namespaceObject.createElement)(InnerBlocks, _extends({}, innerBlocksProps, { 31466 clientId: clientId 31467 })) : (0,external_wp_element_namespaceObject.createElement)(BlockListItems, options) 31468 }; 31469 } 31470 useInnerBlocksProps.save = external_wp_blocks_namespaceObject.__unstableGetInnerBlocksProps; // Expose default appender placeholders as components. 31471 31472 ForwardedInnerBlocks.DefaultBlockAppender = inner_blocks_default_block_appender; 31473 ForwardedInnerBlocks.ButtonBlockAppender = inner_blocks_button_block_appender; 31474 31475 ForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children; 31476 /** 31477 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md 31478 */ 31479 31480 31481 /* harmony default export */ var inner_blocks = (ForwardedInnerBlocks); 31482 31483 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/index.js 31484 31485 31486 /** 31487 * External dependencies 31488 */ 31489 31490 /** 31491 * WordPress dependencies 31492 */ 31493 31494 31495 31496 31497 /** 31498 * Internal dependencies 31499 */ 31500 31501 31502 31503 31504 31505 31506 31507 31508 31509 31510 31511 const elementContext = (0,external_wp_element_namespaceObject.createContext)(); 31512 const IntersectionObserver = (0,external_wp_element_namespaceObject.createContext)(); 31513 31514 function Root(_ref) { 31515 let { 31516 className, 31517 ...settings 31518 } = _ref; 31519 const [element, setElement] = (0,external_wp_element_namespaceObject.useState)(); 31520 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); 31521 const { 31522 isOutlineMode, 31523 isFocusMode, 31524 isNavigationMode 31525 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 31526 const { 31527 getSettings, 31528 isNavigationMode: _isNavigationMode 31529 } = select(store); 31530 const { 31531 outlineMode, 31532 focusMode 31533 } = getSettings(); 31534 return { 31535 isOutlineMode: outlineMode, 31536 isFocusMode: focusMode, 31537 isNavigationMode: _isNavigationMode() 31538 }; 31539 }, []); 31540 const innerBlocksProps = useInnerBlocksProps({ 31541 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([useBlockSelectionClearer(), useInBetweenInserter(), setElement]), 31542 className: classnames_default()('is-root-container', className, { 31543 'is-outline-mode': isOutlineMode, 31544 'is-focus-mode': isFocusMode && isLargeViewport, 31545 'is-navigate-mode': isNavigationMode 31546 }) 31547 }, settings); 31548 return (0,external_wp_element_namespaceObject.createElement)(elementContext.Provider, { 31549 value: element 31550 }, (0,external_wp_element_namespaceObject.createElement)("div", innerBlocksProps)); 31551 } 31552 31553 function BlockList(settings) { 31554 usePreParsePatterns(); 31555 return (0,external_wp_element_namespaceObject.createElement)(BlockToolsBackCompat, null, (0,external_wp_element_namespaceObject.createElement)(Provider, { 31556 value: DEFAULT_BLOCK_EDIT_CONTEXT 31557 }, (0,external_wp_element_namespaceObject.createElement)(Root, settings))); 31558 } 31559 BlockList.__unstableElementContext = elementContext; 31560 31561 function Items(_ref2) { 31562 let { 31563 placeholder, 31564 rootClientId, 31565 renderAppender, 31566 __experimentalAppenderTagName, 31567 __experimentalLayout: layout = defaultLayout 31568 } = _ref2; 31569 const [intersectingBlocks, setIntersectingBlocks] = (0,external_wp_element_namespaceObject.useState)(new Set()); 31570 const intersectionObserver = (0,external_wp_element_namespaceObject.useMemo)(() => { 31571 const { 31572 IntersectionObserver: Observer 31573 } = window; 31574 31575 if (!Observer) { 31576 return; 31577 } 31578 31579 return new Observer(entries => { 31580 setIntersectingBlocks(oldIntersectingBlocks => { 31581 const newIntersectingBlocks = new Set(oldIntersectingBlocks); 31582 31583 for (const entry of entries) { 31584 const clientId = entry.target.getAttribute('data-block'); 31585 const action = entry.isIntersecting ? 'add' : 'delete'; 31586 newIntersectingBlocks[action](clientId); 31587 } 31588 31589 return newIntersectingBlocks; 31590 }); 31591 }); 31592 }, [setIntersectingBlocks]); 31593 const { 31594 order, 31595 selectedBlocks 31596 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 31597 const { 31598 getBlockOrder, 31599 getSelectedBlockClientIds 31600 } = select(store); 31601 return { 31602 order: getBlockOrder(rootClientId), 31603 selectedBlocks: getSelectedBlockClientIds() 31604 }; 31605 }, [rootClientId]); 31606 return (0,external_wp_element_namespaceObject.createElement)(LayoutProvider, { 31607 value: layout 31608 }, (0,external_wp_element_namespaceObject.createElement)(IntersectionObserver.Provider, { 31609 value: intersectionObserver 31610 }, order.map(clientId => (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, { 31611 key: clientId, 31612 value: // Only provide data asynchronously if the block is 31613 // not visible and not selected. 31614 !intersectingBlocks.has(clientId) && !selectedBlocks.includes(clientId) 31615 }, (0,external_wp_element_namespaceObject.createElement)(block, { 31616 rootClientId: rootClientId, 31617 clientId: clientId 31618 })))), order.length < 1 && placeholder, (0,external_wp_element_namespaceObject.createElement)(block_list_appender, { 31619 tagName: __experimentalAppenderTagName, 31620 rootClientId: rootClientId, 31621 renderAppender: renderAppender 31622 })); 31623 } 31624 31625 function BlockListItems(props) { 31626 // This component needs to always be synchronous as it's the one changing 31627 // the async mode depending on the block selection. 31628 return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, { 31629 value: false 31630 }, (0,external_wp_element_namespaceObject.createElement)(Items, props)); 31631 } 31632 31633 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/control.js 31634 31635 31636 31637 /** 31638 * External dependencies 31639 */ 31640 31641 31642 /** 31643 * WordPress dependencies 31644 */ 31645 31646 31647 31648 31649 /** 31650 * Internal dependencies 31651 */ 31652 31653 31654 const colorsAndGradientKeys = ['colors', 'disableCustomColors', 'gradients', 'disableCustomGradients']; 31655 31656 function ColorGradientControlInner(_ref) { 31657 let { 31658 colors, 31659 gradients, 31660 disableCustomColors, 31661 disableCustomGradients, 31662 __experimentalHasMultipleOrigins, 31663 __experimentalIsRenderedInSidebar, 31664 className, 31665 label, 31666 onColorChange, 31667 onGradientChange, 31668 colorValue, 31669 gradientValue, 31670 clearable, 31671 showTitle = true, 31672 enableAlpha 31673 } = _ref; 31674 const canChooseAColor = onColorChange && (!(0,external_lodash_namespaceObject.isEmpty)(colors) || !disableCustomColors); 31675 const canChooseAGradient = onGradientChange && (!(0,external_lodash_namespaceObject.isEmpty)(gradients) || !disableCustomGradients); 31676 const [currentTab, setCurrentTab] = (0,external_wp_element_namespaceObject.useState)(gradientValue ? 'gradient' : !!canChooseAColor && 'color'); 31677 31678 if (!canChooseAColor && !canChooseAGradient) { 31679 return null; 31680 } 31681 31682 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl, { 31683 className: classnames_default()('block-editor-color-gradient-control', className) 31684 }, (0,external_wp_element_namespaceObject.createElement)("fieldset", { 31685 className: "block-editor-color-gradient-control__fieldset" 31686 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 31687 spacing: 1 31688 }, showTitle && (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_element_namespaceObject.createElement)("div", { 31689 className: "block-editor-color-gradient-control__color-indicator" 31690 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl.VisualLabel, null, label))), canChooseAColor && canChooseAGradient && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControl, { 31691 value: currentTab, 31692 onChange: setCurrentTab, 31693 label: (0,external_wp_i18n_namespaceObject.__)('Select color type'), 31694 hideLabelFromVision: true, 31695 isBlock: true 31696 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { 31697 value: "color", 31698 label: (0,external_wp_i18n_namespaceObject.__)('Solid') 31699 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { 31700 value: "gradient", 31701 label: (0,external_wp_i18n_namespaceObject.__)('Gradient') 31702 })), (currentTab === 'color' || !canChooseAGradient) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorPalette, { 31703 value: colorValue, 31704 onChange: canChooseAGradient ? newColor => { 31705 onColorChange(newColor); 31706 onGradientChange(); 31707 } : onColorChange, 31708 colors, 31709 disableCustomColors, 31710 __experimentalHasMultipleOrigins: __experimentalHasMultipleOrigins, 31711 __experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar, 31712 clearable: clearable, 31713 enableAlpha: enableAlpha 31714 }), (currentTab === 'gradient' || !canChooseAColor) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.GradientPicker, { 31715 value: gradientValue, 31716 onChange: canChooseAColor ? newGradient => { 31717 onGradientChange(newGradient); 31718 onColorChange(); 31719 } : onGradientChange, 31720 gradients, 31721 disableCustomGradients, 31722 __experimentalHasMultipleOrigins: __experimentalHasMultipleOrigins, 31723 __experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar, 31724 clearable: clearable 31725 })))); 31726 } 31727 31728 function ColorGradientControlSelect(props) { 31729 const colorGradientSettings = {}; 31730 colorGradientSettings.colors = useSetting('color.palette'); 31731 colorGradientSettings.gradients = useSetting('color.gradients'); 31732 colorGradientSettings.disableCustomColors = !useSetting('color.custom'); 31733 colorGradientSettings.disableCustomGradients = !useSetting('color.customGradient'); 31734 return (0,external_wp_element_namespaceObject.createElement)(ColorGradientControlInner, _extends({}, colorGradientSettings, props)); 31735 } 31736 31737 function ColorGradientControl(props) { 31738 if ((0,external_lodash_namespaceObject.every)(colorsAndGradientKeys, key => props.hasOwnProperty(key))) { 31739 return (0,external_wp_element_namespaceObject.createElement)(ColorGradientControlInner, props); 31740 } 31741 31742 return (0,external_wp_element_namespaceObject.createElement)(ColorGradientControlSelect, props); 31743 } 31744 31745 /* harmony default export */ var control = (ColorGradientControl); 31746 31747 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/dropdown.js 31748 31749 31750 31751 /** 31752 * External dependencies 31753 */ 31754 31755 /** 31756 * WordPress dependencies 31757 */ 31758 31759 31760 /** 31761 * Internal dependencies 31762 */ 31763 31764 31765 function ColorGradientSettingsDropdown(_ref) { 31766 let { 31767 colors, 31768 gradients, 31769 disableCustomColors, 31770 disableCustomGradients, 31771 __experimentalHasMultipleOrigins, 31772 __experimentalIsRenderedInSidebar, 31773 enableAlpha, 31774 settings 31775 } = _ref; 31776 let dropdownPosition; 31777 31778 if (__experimentalIsRenderedInSidebar) { 31779 dropdownPosition = 'bottom left'; 31780 } 31781 31782 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { 31783 isBordered: true, 31784 isSeparated: true, 31785 className: "block-editor-panel-color-gradient-settings__item-group" 31786 }, settings.map((setting, index) => setting && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, { 31787 key: index, 31788 position: dropdownPosition, 31789 className: "block-editor-panel-color-gradient-settings__dropdown", 31790 contentClassName: "block-editor-panel-color-gradient-settings__dropdown-content", 31791 renderToggle: _ref2 => { 31792 var _setting$gradientValu; 31793 31794 let { 31795 isOpen, 31796 onToggle 31797 } = _ref2; 31798 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItem, { 31799 onClick: onToggle, 31800 className: classnames_default()('block-editor-panel-color-gradient-settings__item', { 31801 'is-open': isOpen 31802 }) 31803 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 31804 justify: "flex-start" 31805 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, { 31806 className: "block-editor-panel-color-gradient-settings__color-indicator", 31807 colorValue: (_setting$gradientValu = setting.gradientValue) !== null && _setting$gradientValu !== void 0 ? _setting$gradientValu : setting.colorValue 31808 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, setting.label))); 31809 }, 31810 renderContent: () => (0,external_wp_element_namespaceObject.createElement)(control, _extends({ 31811 showTitle: false, 31812 colors, 31813 gradients, 31814 disableCustomColors, 31815 disableCustomGradients, 31816 __experimentalHasMultipleOrigins, 31817 __experimentalIsRenderedInSidebar, 31818 enableAlpha 31819 }, setting)) 31820 }))); 31821 } 31822 31823 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/use-common-single-multiple-selects.js 31824 /** 31825 * Internal dependencies 31826 */ 31827 31828 function useCommonSingleMultipleSelects() { 31829 return { 31830 disableCustomColors: !useSetting('color.custom'), 31831 disableCustomGradients: !useSetting('color.customGradient') 31832 }; 31833 } 31834 31835 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js 31836 /** 31837 * WordPress dependencies 31838 */ 31839 31840 31841 /** 31842 * Internal dependencies 31843 */ 31844 31845 31846 31847 /** 31848 * Retrieves color and gradient related settings. 31849 * 31850 * The arrays for colors and gradients are made up of color palettes from each 31851 * origin i.e. "Core", "Theme", and "User". 31852 * 31853 * @return {Object} Color and gradient related settings. 31854 */ 31855 31856 function useMultipleOriginColorsAndGradients() { 31857 const colorGradientSettings = useCommonSingleMultipleSelects(); 31858 const customColors = useSetting('color.palette.custom'); 31859 const themeColors = useSetting('color.palette.theme'); 31860 const defaultColors = useSetting('color.palette.default'); 31861 const shouldDisplayDefaultColors = useSetting('color.defaultPalette'); 31862 colorGradientSettings.colors = (0,external_wp_element_namespaceObject.useMemo)(() => { 31863 const result = []; 31864 31865 if (themeColors && themeColors.length) { 31866 result.push({ 31867 name: (0,external_wp_i18n_namespaceObject._x)('Theme', 'Indicates this palette comes from the theme.'), 31868 colors: themeColors 31869 }); 31870 } 31871 31872 if (shouldDisplayDefaultColors && defaultColors && defaultColors.length) { 31873 result.push({ 31874 name: (0,external_wp_i18n_namespaceObject._x)('Default', 'Indicates this palette comes from WordPress.'), 31875 colors: defaultColors 31876 }); 31877 } 31878 31879 if (customColors && customColors.length) { 31880 result.push({ 31881 name: (0,external_wp_i18n_namespaceObject._x)('Custom', 'Indicates this palette comes from the theme.'), 31882 colors: customColors 31883 }); 31884 } 31885 31886 return result; 31887 }, [defaultColors, themeColors, customColors]); 31888 const customGradients = useSetting('color.gradients.custom'); 31889 const themeGradients = useSetting('color.gradients.theme'); 31890 const defaultGradients = useSetting('color.gradients.default'); 31891 const shouldDisplayDefaultGradients = useSetting('color.defaultGradients'); 31892 colorGradientSettings.gradients = (0,external_wp_element_namespaceObject.useMemo)(() => { 31893 const result = []; 31894 31895 if (themeGradients && themeGradients.length) { 31896 result.push({ 31897 name: (0,external_wp_i18n_namespaceObject._x)('Theme', 'Indicates this palette comes from the theme.'), 31898 gradients: themeGradients 31899 }); 31900 } 31901 31902 if (shouldDisplayDefaultGradients && defaultGradients && defaultGradients.length) { 31903 result.push({ 31904 name: (0,external_wp_i18n_namespaceObject._x)('Default', 'Indicates this palette comes from WordPress.'), 31905 gradients: defaultGradients 31906 }); 31907 } 31908 31909 if (customGradients && customGradients.length) { 31910 result.push({ 31911 name: (0,external_wp_i18n_namespaceObject._x)('Custom', 'Indicates this palette is created by the user.'), 31912 gradients: customGradients 31913 }); 31914 } 31915 31916 return result; 31917 }, [customGradients, themeGradients, defaultGradients]); 31918 return colorGradientSettings; 31919 } 31920 31921 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/utils.js 31922 /** 31923 * External dependencies 31924 */ 31925 31926 31927 31928 31929 k([names, a11y]); 31930 /** 31931 * Provided an array of color objects as set by the theme or by the editor defaults, 31932 * and the values of the defined color or custom color returns a color object describing the color. 31933 * 31934 * @param {Array} colors Array of color objects as set by the theme or by the editor defaults. 31935 * @param {?string} definedColor A string containing the color slug. 31936 * @param {?string} customColor A string containing the customColor value. 31937 * 31938 * @return {?Object} If definedColor is passed and the name is found in colors, 31939 * the color object exactly as set by the theme or editor defaults is returned. 31940 * Otherwise, an object that just sets the color is defined. 31941 */ 31942 31943 const getColorObjectByAttributeValues = (colors, definedColor, customColor) => { 31944 if (definedColor) { 31945 const colorObj = (0,external_lodash_namespaceObject.find)(colors, { 31946 slug: definedColor 31947 }); 31948 31949 if (colorObj) { 31950 return colorObj; 31951 } 31952 } 31953 31954 return { 31955 color: customColor 31956 }; 31957 }; 31958 /** 31959 * Provided an array of color objects as set by the theme or by the editor defaults, and a color value returns the color object matching that value or undefined. 31960 * 31961 * @param {Array} colors Array of color objects as set by the theme or by the editor defaults. 31962 * @param {?string} colorValue A string containing the color value. 31963 * 31964 * @return {?Object} Color object included in the colors array whose color property equals colorValue. 31965 * Returns undefined if no color object matches this requirement. 31966 */ 31967 31968 const getColorObjectByColorValue = (colors, colorValue) => { 31969 return (0,external_lodash_namespaceObject.find)(colors, { 31970 color: colorValue 31971 }); 31972 }; 31973 /** 31974 * Returns a class based on the context a color is being used and its slug. 31975 * 31976 * @param {string} colorContextName Context/place where color is being used e.g: background, text etc... 31977 * @param {string} colorSlug Slug of the color. 31978 * 31979 * @return {?string} String with the class corresponding to the color in the provided context. 31980 * Returns undefined if either colorContextName or colorSlug are not provided. 31981 */ 31982 31983 function getColorClassName(colorContextName, colorSlug) { 31984 if (!colorContextName || !colorSlug) { 31985 return undefined; 31986 } 31987 31988 return `has-${(0,external_lodash_namespaceObject.kebabCase)(colorSlug)}-$colorContextName}`; 31989 } 31990 /** 31991 * Given an array of color objects and a color value returns the color value of the most readable color in the array. 31992 * 31993 * @param {Array} colors Array of color objects as set by the theme or by the editor defaults. 31994 * @param {?string} colorValue A string containing the color value. 31995 * 31996 * @return {string} String with the color value of the most readable color. 31997 */ 31998 31999 function getMostReadableColor(colors, colorValue) { 32000 const colordColor = w(colorValue); 32001 return (0,external_lodash_namespaceObject.maxBy)(colors, _ref => { 32002 let { 32003 color 32004 } = _ref; 32005 return colordColor.contrast(color); 32006 }).color; 32007 } 32008 32009 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border-color.js 32010 32011 32012 32013 /** 32014 * External dependencies 32015 */ 32016 32017 /** 32018 * WordPress dependencies 32019 */ 32020 32021 32022 32023 32024 32025 /** 32026 * Internal dependencies 32027 */ 32028 32029 32030 32031 32032 32033 32034 // Defining empty array here instead of inline avoids unnecessary re-renders of 32035 // color control. 32036 32037 const border_color_EMPTY_ARRAY = []; 32038 /** 32039 * Inspector control panel containing the border color related configuration. 32040 * 32041 * There is deliberate overlap between the colors and borders block supports 32042 * relating to border color. It can be argued the border color controls could 32043 * be included within either, or both, the colors and borders panels in the 32044 * inspector controls. If they share the same block attributes it should not 32045 * matter. 32046 * 32047 * @param {Object} props Block properties. 32048 * 32049 * @return {WPElement} Border color edit element. 32050 */ 32051 32052 function BorderColorEdit(props) { 32053 const { 32054 attributes: { 32055 borderColor, 32056 style 32057 }, 32058 setAttributes 32059 } = props; 32060 const colorGradientSettings = useMultipleOriginColorsAndGradients(); 32061 const availableColors = colorGradientSettings.colors.reduce((colors, origin) => colors.concat(origin.colors), []); 32062 const { 32063 color: customBorderColor 32064 } = (style === null || style === void 0 ? void 0 : style.border) || {}; 32065 const [colorValue, setColorValue] = (0,external_wp_element_namespaceObject.useState)(() => { 32066 var _getColorObjectByAttr; 32067 32068 return (_getColorObjectByAttr = getColorObjectByAttributeValues(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color; 32069 }); // Detect changes in the color attributes and update the colorValue to keep the 32070 // UI in sync. This is necessary for situations when border controls interact with 32071 // each other: eg, setting the border width to zero causes the color and style 32072 // selections to be cleared. 32073 32074 (0,external_wp_element_namespaceObject.useEffect)(() => { 32075 var _getColorObjectByAttr2; 32076 32077 setColorValue((_getColorObjectByAttr2 = getColorObjectByAttributeValues(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color); 32078 }, [borderColor, customBorderColor, availableColors]); 32079 32080 const onChangeColor = value => { 32081 setColorValue(value); 32082 const colorObject = getColorObjectByColorValue(availableColors, value); 32083 const newStyle = { ...style, 32084 border: { ...(style === null || style === void 0 ? void 0 : style.border), 32085 color: colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value 32086 } 32087 }; // If empty slug, ensure undefined to remove attribute. 32088 32089 const newNamedColor = colorObject !== null && colorObject !== void 0 && colorObject.slug ? colorObject.slug : undefined; 32090 setAttributes({ 32091 style: cleanEmptyObject(newStyle), 32092 borderColor: newNamedColor 32093 }); 32094 }; 32095 32096 const settings = [{ 32097 label: (0,external_wp_i18n_namespaceObject.__)('Color'), 32098 onColorChange: onChangeColor, 32099 colorValue, 32100 clearable: false 32101 }]; 32102 return (0,external_wp_element_namespaceObject.createElement)(ColorGradientSettingsDropdown, _extends({ 32103 settings: settings, 32104 disableCustomColors: true, 32105 disableCustomGradients: true, 32106 __experimentalHasMultipleOrigins: true, 32107 __experimentalIsRenderedInSidebar: true, 32108 enableAlpha: true 32109 }, colorGradientSettings)); 32110 } 32111 /** 32112 * Checks if there is a current value in the border color block support 32113 * attributes. 32114 * 32115 * @param {Object} props Block props. 32116 * @return {boolean} Whether or not the block has a border color value set. 32117 */ 32118 32119 function hasBorderColorValue(props) { 32120 var _style$border; 32121 32122 const { 32123 attributes: { 32124 borderColor, 32125 style 32126 } 32127 } = props; 32128 return !!borderColor || !!(style !== null && style !== void 0 && (_style$border = style.border) !== null && _style$border !== void 0 && _style$border.color); 32129 } 32130 /** 32131 * Resets the border color block support attributes. This can be used when 32132 * disabling the border color support controls for a block via a progressive 32133 * discovery panel. 32134 * 32135 * @param {Object} props Block props. 32136 * @param {Object} props.attributes Block's attributes. 32137 * @param {Object} props.setAttributes Function to set block's attributes. 32138 */ 32139 32140 function resetBorderColor(_ref) { 32141 let { 32142 attributes = {}, 32143 setAttributes 32144 } = _ref; 32145 const { 32146 style 32147 } = attributes; 32148 setAttributes({ 32149 borderColor: undefined, 32150 style: removeBorderAttribute(style, 'color') 32151 }); 32152 } 32153 /** 32154 * Filters registered block settings, extending attributes to include 32155 * `borderColor` if needed. 32156 * 32157 * @param {Object} settings Original block settings. 32158 * 32159 * @return {Object} Updated block settings. 32160 */ 32161 32162 function addAttributes(settings) { 32163 if (!hasBorderSupport(settings, 'color')) { 32164 return settings; 32165 } // Allow blocks to specify default value if needed. 32166 32167 32168 if (settings.attributes.borderColor) { 32169 return settings; 32170 } // Add new borderColor attribute to block settings. 32171 32172 32173 return { ...settings, 32174 attributes: { ...settings.attributes, 32175 borderColor: { 32176 type: 'string' 32177 } 32178 } 32179 }; 32180 } 32181 /** 32182 * Override props assigned to save component to inject border color. 32183 * 32184 * @param {Object} props Additional props applied to save element. 32185 * @param {Object} blockType Block type definition. 32186 * @param {Object} attributes Block's attributes. 32187 * 32188 * @return {Object} Filtered props to apply to save element. 32189 */ 32190 32191 32192 function border_color_addSaveProps(props, blockType, attributes) { 32193 var _style$border2; 32194 32195 if (!hasBorderSupport(blockType, 'color') || shouldSkipSerialization(blockType, BORDER_SUPPORT_KEY, 'color')) { 32196 return props; 32197 } 32198 32199 const { 32200 borderColor, 32201 style 32202 } = attributes; 32203 const borderColorClass = getColorClassName('border-color', borderColor); 32204 const newClassName = classnames_default()(props.className, { 32205 'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border2 = style.border) === null || _style$border2 === void 0 ? void 0 : _style$border2.color), 32206 [borderColorClass]: !!borderColorClass 32207 }); // If we are clearing the last of the previous classes in `className` 32208 // set it to `undefined` to avoid rendering empty DOM attributes. 32209 32210 props.className = newClassName ? newClassName : undefined; 32211 return props; 32212 } 32213 /** 32214 * Filters the registered block settings to apply border color styles and 32215 * classnames to the block edit wrapper. 32216 * 32217 * @param {Object} settings Original block settings. 32218 * 32219 * @return {Object} Filtered block settings. 32220 */ 32221 32222 32223 function addEditProps(settings) { 32224 if (!hasBorderSupport(settings, 'color') || shouldSkipSerialization(settings, BORDER_SUPPORT_KEY, 'color')) { 32225 return settings; 32226 } 32227 32228 const existingGetEditWrapperProps = settings.getEditWrapperProps; 32229 32230 settings.getEditWrapperProps = attributes => { 32231 let props = {}; 32232 32233 if (existingGetEditWrapperProps) { 32234 props = existingGetEditWrapperProps(attributes); 32235 } 32236 32237 return border_color_addSaveProps(props, settings, attributes); 32238 }; 32239 32240 return settings; 32241 } 32242 /** 32243 * This adds inline styles for color palette colors. 32244 * Ideally, this is not needed and themes should load their palettes on the editor. 32245 * 32246 * @param {Function} BlockListBlock Original component. 32247 * 32248 * @return {Function} Wrapped component. 32249 */ 32250 32251 32252 const withBorderColorPaletteStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => { 32253 var _getColorObjectByAttr3, _props$wrapperProps; 32254 32255 const { 32256 name, 32257 attributes 32258 } = props; 32259 const { 32260 borderColor 32261 } = attributes; 32262 const colors = useSetting('color.palette') || border_color_EMPTY_ARRAY; 32263 32264 if (!hasBorderSupport(name, 'color') || shouldSkipSerialization(name, BORDER_SUPPORT_KEY, 'color')) { 32265 return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props); 32266 } 32267 32268 const extraStyles = { 32269 borderColor: borderColor ? (_getColorObjectByAttr3 = getColorObjectByAttributeValues(colors, borderColor)) === null || _getColorObjectByAttr3 === void 0 ? void 0 : _getColorObjectByAttr3.color : undefined 32270 }; 32271 let wrapperProps = props.wrapperProps; 32272 wrapperProps = { ...props.wrapperProps, 32273 style: { ...extraStyles, 32274 ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style) 32275 } 32276 }; 32277 return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, { 32278 wrapperProps: wrapperProps 32279 })); 32280 }); 32281 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/border/addAttributes', addAttributes); 32282 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/border/addSaveProps', border_color_addSaveProps); 32283 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/border/addEditProps', addEditProps); 32284 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/border/with-border-color-palette-styles', withBorderColorPaletteStyles); 32285 32286 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-radius-control/utils.js 32287 /** 32288 * WordPress dependencies 32289 */ 32290 32291 /** 32292 * Gets the (non-undefined) item with the highest occurrence within an array 32293 * Based in part on: https://stackoverflow.com/a/20762713 32294 * 32295 * Undefined values are always sorted to the end by `sort`, so this function 32296 * returns the first element, to always prioritize real values over undefined 32297 * values. 32298 * 32299 * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description 32300 * 32301 * @param {Array<any>} inputArray Array of items to check. 32302 * @return {any} The item with the most occurrences. 32303 */ 32304 32305 function mode(inputArray) { 32306 const arr = [...inputArray]; 32307 return arr.sort((a, b) => inputArray.filter(v => v === b).length - inputArray.filter(v => v === a).length).shift(); 32308 } 32309 /** 32310 * Returns the most common CSS unit in the radius values. 32311 * Falls back to `px` as a default unit. 32312 * 32313 * @param {Object|string} values Radius values. 32314 * @return {string} Most common CSS unit in values. Default: `px`. 32315 */ 32316 32317 function getAllUnit() { 32318 let values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 32319 32320 if (typeof values === 'string') { 32321 const [, unit] = (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(values); 32322 return unit || 'px'; 32323 } 32324 32325 const allUnits = Object.values(values).map(value => { 32326 const [, unit] = (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(value); 32327 return unit; 32328 }); 32329 return mode(allUnits) || 'px'; 32330 } 32331 /** 32332 * Gets the 'all' input value and unit from values data. 32333 * 32334 * @param {Object|string} values Radius values. 32335 * @return {string} A value + unit for the 'all' input. 32336 */ 32337 32338 function getAllValue() { 32339 let values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 32340 32341 /** 32342 * Border radius support was originally a single pixel value. 32343 * 32344 * To maintain backwards compatibility treat this case as the all value. 32345 */ 32346 if (typeof values === 'string') { 32347 return values; 32348 } 32349 32350 const parsedQuantitiesAndUnits = Object.values(values).map(value => (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(value)); 32351 const allValues = parsedQuantitiesAndUnits.map(value => { 32352 var _value$; 32353 32354 return (_value$ = value[0]) !== null && _value$ !== void 0 ? _value$ : ''; 32355 }); 32356 const allUnits = parsedQuantitiesAndUnits.map(value => value[1]); 32357 const value = allValues.every(v => v === allValues[0]) ? allValues[0] : ''; 32358 const unit = mode(allUnits); 32359 const allValue = value === 0 || value ? `$value}$unit}` : undefined; 32360 return allValue; 32361 } 32362 /** 32363 * Checks to determine if values are mixed. 32364 * 32365 * @param {Object} values Radius values. 32366 * @return {boolean} Whether values are mixed. 32367 */ 32368 32369 function hasMixedValues() { 32370 let values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 32371 const allValue = getAllValue(values); 32372 const isMixed = typeof values === 'string' ? false : isNaN(parseFloat(allValue)); 32373 return isMixed; 32374 } 32375 /** 32376 * Checks to determine if values are defined. 32377 * 32378 * @param {Object} values Radius values. 32379 * @return {boolean} Whether values are mixed. 32380 */ 32381 32382 function hasDefinedValues(values) { 32383 if (!values) { 32384 return false; 32385 } // A string value represents a shorthand value. 32386 32387 32388 if (typeof values === 'string') { 32389 return true; 32390 } // An object represents longhand border radius values, if any are set 32391 // flag values as being defined. 32392 32393 32394 const filteredValues = Object.values(values).filter(value => { 32395 return !!value || value === 0; 32396 }); 32397 return !!filteredValues.length; 32398 } 32399 32400 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-radius-control/all-input-control.js 32401 32402 32403 32404 /** 32405 * WordPress dependencies 32406 */ 32407 32408 32409 /** 32410 * Internal dependencies 32411 */ 32412 32413 32414 function AllInputControl(_ref) { 32415 let { 32416 onChange, 32417 values, 32418 ...props 32419 } = _ref; 32420 const allValue = getAllValue(values); 32421 const hasValues = hasDefinedValues(values); 32422 const isMixed = hasValues && hasMixedValues(values); 32423 const allPlaceholder = isMixed ? (0,external_wp_i18n_namespaceObject.__)('Mixed') : null; 32424 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, _extends({}, props, { 32425 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Border radius'), 32426 disableUnits: isMixed, 32427 isOnly: true, 32428 value: allValue, 32429 onChange: onChange, 32430 placeholder: allPlaceholder 32431 })); 32432 } 32433 32434 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-radius-control/input-controls.js 32435 32436 32437 32438 /** 32439 * WordPress dependencies 32440 */ 32441 32442 32443 const CORNERS = { 32444 topLeft: (0,external_wp_i18n_namespaceObject.__)('Top left'), 32445 topRight: (0,external_wp_i18n_namespaceObject.__)('Top right'), 32446 bottomLeft: (0,external_wp_i18n_namespaceObject.__)('Bottom left'), 32447 bottomRight: (0,external_wp_i18n_namespaceObject.__)('Bottom right') 32448 }; 32449 function BoxInputControls(_ref) { 32450 let { 32451 onChange, 32452 values: valuesProp, 32453 ...props 32454 } = _ref; 32455 32456 const createHandleOnChange = corner => next => { 32457 if (!onChange) { 32458 return; 32459 } 32460 32461 onChange({ ...values, 32462 [corner]: next ? next : undefined 32463 }); 32464 }; // For shorthand style & backwards compatibility, handle flat string value. 32465 32466 32467 const values = typeof valuesProp !== 'string' ? valuesProp : { 32468 topLeft: valuesProp, 32469 topRight: valuesProp, 32470 bottomLeft: valuesProp, 32471 bottomRight: valuesProp 32472 }; // Controls are wrapped in tooltips as visible labels aren't desired here. 32473 32474 return (0,external_wp_element_namespaceObject.createElement)("div", { 32475 className: "components-border-radius-control__input-controls-wrapper" 32476 }, Object.entries(CORNERS).map(_ref2 => { 32477 let [key, label] = _ref2; 32478 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, _extends({}, props, { 32479 key: key, 32480 "aria-label": label, 32481 value: values[key], 32482 onChange: createHandleOnChange(key) 32483 })); 32484 })); 32485 } 32486 32487 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/link.js 32488 32489 32490 /** 32491 * WordPress dependencies 32492 */ 32493 32494 const link_link = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 32495 xmlns: "http://www.w3.org/2000/svg", 32496 viewBox: "0 0 24 24" 32497 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 32498 d: "M15.6 7.2H14v1.5h1.6c2 0 3.7 1.7 3.7 3.7s-1.7 3.7-3.7 3.7H14v1.5h1.6c2.8 0 5.2-2.3 5.2-5.2 0-2.9-2.3-5.2-5.2-5.2zM4.7 12.4c0-2 1.7-3.7 3.7-3.7H10V7.2H8.4c-2.9 0-5.2 2.3-5.2 5.2 0 2.9 2.3 5.2 5.2 5.2H10v-1.5H8.4c-2 0-3.7-1.7-3.7-3.7zm4.6.9h5.3v-1.5H9.3v1.5z" 32499 })); 32500 /* harmony default export */ var library_link = (link_link); 32501 32502 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/link-off.js 32503 32504 32505 /** 32506 * WordPress dependencies 32507 */ 32508 32509 const linkOff = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 32510 xmlns: "http://www.w3.org/2000/svg", 32511 viewBox: "0 0 24 24" 32512 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 32513 d: "M15.6 7.3h-.7l1.6-3.5-.9-.4-3.9 8.5H9v1.5h2l-1.3 2.8H8.4c-2 0-3.7-1.7-3.7-3.7s1.7-3.7 3.7-3.7H10V7.3H8.4c-2.9 0-5.2 2.3-5.2 5.2 0 2.9 2.3 5.2 5.2 5.2H9l-1.4 3.2.9.4 5.7-12.5h1.4c2 0 3.7 1.7 3.7 3.7s-1.7 3.7-3.7 3.7H14v1.5h1.6c2.9 0 5.2-2.3 5.2-5.2 0-2.9-2.4-5.2-5.2-5.2z" 32514 })); 32515 /* harmony default export */ var link_off = (linkOff); 32516 32517 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-radius-control/linked-button.js 32518 32519 32520 32521 /** 32522 * WordPress dependencies 32523 */ 32524 32525 32526 32527 function LinkedButton(_ref) { 32528 let { 32529 isLinked, 32530 ...props 32531 } = _ref; 32532 const label = isLinked ? (0,external_wp_i18n_namespaceObject.__)('Unlink Radii') : (0,external_wp_i18n_namespaceObject.__)('Link Radii'); 32533 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, { 32534 text: label 32535 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, { 32536 className: "component-border-radius-control__linked-button", 32537 isPrimary: isLinked, 32538 isSecondary: !isLinked, 32539 isSmall: true, 32540 icon: isLinked ? library_link : link_off, 32541 iconSize: 16, 32542 "aria-label": label 32543 }))); 32544 } 32545 32546 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-radius-control/index.js 32547 32548 32549 /** 32550 * WordPress dependencies 32551 */ 32552 32553 32554 32555 /** 32556 * Internal dependencies 32557 */ 32558 32559 32560 32561 32562 32563 32564 const DEFAULT_VALUES = { 32565 topLeft: null, 32566 topRight: null, 32567 bottomLeft: null, 32568 bottomRight: null 32569 }; 32570 const MIN_BORDER_RADIUS_VALUE = 0; 32571 const MAX_BORDER_RADIUS_VALUES = { 32572 px: 100, 32573 em: 20, 32574 rem: 20 32575 }; 32576 /** 32577 * Control to display border radius options. 32578 * 32579 * @param {Object} props Component props. 32580 * @param {Function} props.onChange Callback to handle onChange. 32581 * @param {Object} props.values Border radius values. 32582 * 32583 * @return {WPElement} Custom border radius control. 32584 */ 32585 32586 function BorderRadiusControl(_ref) { 32587 let { 32588 onChange, 32589 values 32590 } = _ref; 32591 const [isLinked, setIsLinked] = (0,external_wp_element_namespaceObject.useState)(!hasDefinedValues(values) || !hasMixedValues(values)); 32592 const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({ 32593 availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem'] 32594 }); 32595 const unit = getAllUnit(values); 32596 const unitConfig = units && units.find(item => item.value === unit); 32597 const step = (unitConfig === null || unitConfig === void 0 ? void 0 : unitConfig.step) || 1; 32598 const [allValue] = (0,external_wp_components_namespaceObject.__experimentalParseQuantityAndUnitFromRawValue)(getAllValue(values)); 32599 32600 const toggleLinked = () => setIsLinked(!isLinked); 32601 32602 const handleSliderChange = next => { 32603 onChange(next !== undefined ? `$next}$unit}` : undefined); 32604 }; 32605 32606 return (0,external_wp_element_namespaceObject.createElement)("fieldset", { 32607 className: "components-border-radius-control" 32608 }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_i18n_namespaceObject.__)('Radius')), (0,external_wp_element_namespaceObject.createElement)("div", { 32609 className: "components-border-radius-control__wrapper" 32610 }, isLinked ? (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(AllInputControl, { 32611 className: "components-border-radius-control__unit-control", 32612 values: values, 32613 min: MIN_BORDER_RADIUS_VALUE, 32614 onChange: onChange, 32615 units: units 32616 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.RangeControl, { 32617 className: "components-border-radius-control__range-control", 32618 value: allValue !== null && allValue !== void 0 ? allValue : '', 32619 min: MIN_BORDER_RADIUS_VALUE, 32620 max: MAX_BORDER_RADIUS_VALUES[unit], 32621 initialPosition: 0, 32622 withInputField: false, 32623 onChange: handleSliderChange, 32624 step: step 32625 })) : (0,external_wp_element_namespaceObject.createElement)(BoxInputControls, { 32626 min: MIN_BORDER_RADIUS_VALUE, 32627 onChange: onChange, 32628 values: values || DEFAULT_VALUES, 32629 units: units 32630 }), (0,external_wp_element_namespaceObject.createElement)(LinkedButton, { 32631 onClick: toggleLinked, 32632 isLinked: isLinked 32633 }))); 32634 } 32635 32636 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border-radius.js 32637 32638 32639 /** 32640 * Internal dependencies 32641 */ 32642 32643 32644 32645 /** 32646 * Inspector control panel containing the border radius related configuration. 32647 * 32648 * @param {Object} props Block properties. 32649 * 32650 * @return {WPElement} Border radius edit element. 32651 */ 32652 32653 function BorderRadiusEdit(props) { 32654 var _style$border; 32655 32656 const { 32657 attributes: { 32658 style 32659 }, 32660 setAttributes 32661 } = props; 32662 32663 const onChange = newRadius => { 32664 let newStyle = { ...style, 32665 border: { ...(style === null || style === void 0 ? void 0 : style.border), 32666 radius: newRadius 32667 } 32668 }; 32669 32670 if (newRadius === undefined || newRadius === '') { 32671 newStyle = cleanEmptyObject(newStyle); 32672 } 32673 32674 setAttributes({ 32675 style: newStyle 32676 }); 32677 }; 32678 32679 return (0,external_wp_element_namespaceObject.createElement)(BorderRadiusControl, { 32680 values: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius, 32681 onChange: onChange 32682 }); 32683 } 32684 /** 32685 * Checks if there is a current value in the border radius block support 32686 * attributes. 32687 * 32688 * @param {Object} props Block props. 32689 * @return {boolean} Whether or not the block has a border radius value set. 32690 */ 32691 32692 function hasBorderRadiusValue(props) { 32693 var _props$attributes$sty, _props$attributes$sty2; 32694 32695 const borderRadius = (_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.border) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.radius; 32696 32697 if (typeof borderRadius === 'object') { 32698 return Object.entries(borderRadius).some(Boolean); 32699 } 32700 32701 return !!borderRadius; 32702 } 32703 /** 32704 * Resets the border radius block support attributes. This can be used when 32705 * disabling the border radius support controls for a block via a progressive 32706 * discovery panel. 32707 * 32708 * @param {Object} props Block props. 32709 * @param {Object} props.attributes Block's attributes. 32710 * @param {Object} props.setAttributes Function to set block's attributes. 32711 */ 32712 32713 function resetBorderRadius(_ref) { 32714 let { 32715 attributes = {}, 32716 setAttributes 32717 } = _ref; 32718 const { 32719 style 32720 } = attributes; 32721 setAttributes({ 32722 style: removeBorderAttribute(style, 'radius') 32723 }); 32724 } 32725 32726 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/line-solid.js 32727 32728 32729 /** 32730 * WordPress dependencies 32731 */ 32732 32733 const lineSolid = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 32734 xmlns: "http://www.w3.org/2000/svg", 32735 width: "24", 32736 height: "24", 32737 fill: "none" 32738 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 32739 d: "M5 11.25h14v1.5H5z" 32740 })); 32741 /* harmony default export */ var line_solid = (lineSolid); 32742 32743 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/line-dashed.js 32744 32745 32746 /** 32747 * WordPress dependencies 32748 */ 32749 32750 const lineDashed = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 32751 xmlns: "http://www.w3.org/2000/svg", 32752 width: "24", 32753 height: "24", 32754 fill: "none" 32755 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 32756 fillRule: "evenodd", 32757 d: "M5 11.25h3v1.5H5v-1.5zm5.5 0h3v1.5h-3v-1.5zm8.5 0h-3v1.5h3v-1.5z", 32758 clipRule: "evenodd" 32759 })); 32760 /* harmony default export */ var line_dashed = (lineDashed); 32761 32762 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/line-dotted.js 32763 32764 32765 /** 32766 * WordPress dependencies 32767 */ 32768 32769 const lineDotted = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 32770 xmlns: "http://www.w3.org/2000/svg", 32771 width: "24", 32772 height: "24", 32773 fill: "none" 32774 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 32775 fillRule: "evenodd", 32776 d: "M5.25 11.25h1.5v1.5h-1.5v-1.5zm3 0h1.5v1.5h-1.5v-1.5zm4.5 0h-1.5v1.5h1.5v-1.5zm1.5 0h1.5v1.5h-1.5v-1.5zm4.5 0h-1.5v1.5h1.5v-1.5z", 32777 clipRule: "evenodd" 32778 })); 32779 /* harmony default export */ var line_dotted = (lineDotted); 32780 32781 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-style-control/index.js 32782 32783 32784 /** 32785 * WordPress dependencies 32786 */ 32787 32788 32789 32790 const BORDER_STYLES = [{ 32791 label: (0,external_wp_i18n_namespaceObject.__)('Solid'), 32792 icon: line_solid, 32793 value: 'solid' 32794 }, { 32795 label: (0,external_wp_i18n_namespaceObject.__)('Dashed'), 32796 icon: line_dashed, 32797 value: 'dashed' 32798 }, { 32799 label: (0,external_wp_i18n_namespaceObject.__)('Dotted'), 32800 icon: line_dotted, 32801 value: 'dotted' 32802 }]; 32803 /** 32804 * Control to display border style options. 32805 * 32806 * @param {Object} props Component props. 32807 * @param {Function} props.onChange Handler for changing border style selection. 32808 * @param {string} props.value Currently selected border style value. 32809 * 32810 * @return {WPElement} Custom border style segmented control. 32811 */ 32812 32813 function BorderStyleControl(_ref) { 32814 let { 32815 onChange, 32816 value 32817 } = _ref; 32818 return (0,external_wp_element_namespaceObject.createElement)("fieldset", { 32819 className: "components-border-style-control" 32820 }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_i18n_namespaceObject.__)('Style')), (0,external_wp_element_namespaceObject.createElement)("div", { 32821 className: "components-border-style-control__buttons" 32822 }, BORDER_STYLES.map(borderStyle => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 32823 key: borderStyle.value, 32824 icon: borderStyle.icon, 32825 isSmall: true, 32826 isPressed: borderStyle.value === value, 32827 onClick: () => onChange(borderStyle.value === value ? undefined : borderStyle.value), 32828 "aria-label": borderStyle.label 32829 })))); 32830 } 32831 32832 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border-style.js 32833 32834 32835 /** 32836 * Internal dependencies 32837 */ 32838 32839 32840 32841 /** 32842 * Inspector control for configuring border style property. 32843 * 32844 * @param {Object} props Block properties. 32845 * 32846 * @return {WPElement} Border style edit element. 32847 */ 32848 32849 const BorderStyleEdit = props => { 32850 var _style$border; 32851 32852 const { 32853 attributes: { 32854 style 32855 }, 32856 setAttributes 32857 } = props; 32858 32859 const onChange = newBorderStyle => { 32860 const newStyleAttributes = { ...style, 32861 border: { ...(style === null || style === void 0 ? void 0 : style.border), 32862 style: newBorderStyle 32863 } 32864 }; 32865 setAttributes({ 32866 style: cleanEmptyObject(newStyleAttributes) 32867 }); 32868 }; 32869 32870 return (0,external_wp_element_namespaceObject.createElement)(BorderStyleControl, { 32871 value: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.style, 32872 onChange: onChange 32873 }); 32874 }; 32875 /** 32876 * Checks if there is a current value in the border style block support 32877 * attributes. 32878 * 32879 * @param {Object} props Block props. 32880 * @return {boolean} Whether or not the block has a border style value set. 32881 */ 32882 32883 function hasBorderStyleValue(props) { 32884 var _props$attributes$sty, _props$attributes$sty2; 32885 32886 return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.border) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.style); 32887 } 32888 /** 32889 * Resets the border style block support attribute. This can be used when 32890 * disabling the border style support control for a block via a progressive 32891 * discovery panel. 32892 * 32893 * @param {Object} props Block props. 32894 * @param {Object} props.attributes Block's attributes. 32895 * @param {Object} props.setAttributes Function to set block's attributes. 32896 */ 32897 32898 function resetBorderStyle(_ref) { 32899 let { 32900 attributes = {}, 32901 setAttributes 32902 } = _ref; 32903 const { 32904 style 32905 } = attributes; 32906 setAttributes({ 32907 style: removeBorderAttribute(style, 'style') 32908 }); 32909 } 32910 32911 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border-width.js 32912 32913 32914 /** 32915 * WordPress dependencies 32916 */ 32917 32918 32919 32920 /** 32921 * Internal dependencies 32922 */ 32923 32924 32925 32926 32927 const MIN_BORDER_WIDTH = 0; 32928 /** 32929 * Inspector control for configuring border width property. 32930 * 32931 * @param {Object} props Block properties. 32932 * 32933 * @return {WPElement} Border width edit element. 32934 */ 32935 32936 const BorderWidthEdit = props => { 32937 const { 32938 attributes: { 32939 borderColor, 32940 style 32941 }, 32942 setAttributes 32943 } = props; 32944 const { 32945 width, 32946 color: customBorderColor, 32947 style: borderStyle 32948 } = (style === null || style === void 0 ? void 0 : style.border) || {}; // Used to temporarily track previous border color & style selections to be 32949 // able to restore them when border width changes from zero value. 32950 32951 const [styleSelection, setStyleSelection] = (0,external_wp_element_namespaceObject.useState)(); 32952 const [colorSelection, setColorSelection] = (0,external_wp_element_namespaceObject.useState)(); 32953 const [customColorSelection, setCustomColorSelection] = (0,external_wp_element_namespaceObject.useState)(); 32954 32955 const onChange = newWidth => { 32956 let newStyle = { ...style, 32957 border: { ...(style === null || style === void 0 ? void 0 : style.border), 32958 width: newWidth 32959 } 32960 }; // Used to clear named border color attribute. 32961 32962 let borderPaletteColor = borderColor; 32963 const hasZeroWidth = parseFloat(newWidth) === 0; 32964 const hadPreviousZeroWidth = parseFloat(width) === 0; // Setting the border width explicitly to zero will also set the 32965 // border style to `none` and clear border color attributes. 32966 32967 if (hasZeroWidth && !hadPreviousZeroWidth) { 32968 // Before clearing color and style selections, keep track of 32969 // the current selections so they can be restored when the width 32970 // changes to a non-zero value. 32971 setColorSelection(borderColor); 32972 setCustomColorSelection(customBorderColor); 32973 setStyleSelection(borderStyle); // Clear style and color attributes. 32974 32975 borderPaletteColor = undefined; 32976 newStyle.border.color = undefined; 32977 newStyle.border.style = 'none'; 32978 } 32979 32980 if (!hasZeroWidth && hadPreviousZeroWidth) { 32981 // Restore previous border style selection if width is now not zero and 32982 // border style was 'none'. This is to support changes to the UI which 32983 // change the border style UI to a segmented control without a "none" 32984 // option. 32985 if (borderStyle === 'none') { 32986 newStyle.border.style = styleSelection; 32987 } // Restore previous border color selection if width is no longer zero 32988 // and current border color is undefined. 32989 32990 32991 if (borderColor === undefined) { 32992 borderPaletteColor = colorSelection; 32993 newStyle.border.color = customColorSelection; 32994 } 32995 } // If width was reset, clean out undefined styles. 32996 32997 32998 if (newWidth === undefined || newWidth === '') { 32999 newStyle = cleanEmptyObject(newStyle); 33000 } 33001 33002 setAttributes({ 33003 borderColor: borderPaletteColor, 33004 style: newStyle 33005 }); 33006 }; 33007 33008 const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({ 33009 availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem'] 33010 }); 33011 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, { 33012 value: width, 33013 label: (0,external_wp_i18n_namespaceObject.__)('Width'), 33014 min: MIN_BORDER_WIDTH, 33015 onChange: onChange, 33016 units: units 33017 }); 33018 }; 33019 /** 33020 * Checks if there is a current value in the border width block support 33021 * attributes. 33022 * 33023 * @param {Object} props Block props. 33024 * @return {boolean} Whether or not the block has a border width value set. 33025 */ 33026 33027 function hasBorderWidthValue(props) { 33028 var _props$attributes$sty, _props$attributes$sty2; 33029 33030 return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.border) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.width); 33031 } 33032 /** 33033 * Resets the border width block support attribute. This can be used when 33034 * disabling the border width support control for a block via a progressive 33035 * discovery panel. 33036 * 33037 * @param {Object} props Block props. 33038 * @param {Object} props.attributes Block's attributes. 33039 * @param {Object} props.setAttributes Function to set block's attributes. 33040 */ 33041 33042 function resetBorderWidth(_ref) { 33043 let { 33044 attributes = {}, 33045 setAttributes 33046 } = _ref; 33047 const { 33048 style 33049 } = attributes; 33050 setAttributes({ 33051 style: removeBorderAttribute(style, 'width') 33052 }); 33053 } 33054 33055 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border.js 33056 33057 33058 /** 33059 * WordPress dependencies 33060 */ 33061 33062 33063 33064 33065 /** 33066 * Internal dependencies 33067 */ 33068 33069 33070 33071 33072 33073 33074 33075 33076 const BORDER_SUPPORT_KEY = '__experimentalBorder'; 33077 function BorderPanel(props) { 33078 const { 33079 clientId 33080 } = props; 33081 const isColorSupported = useSetting('border.color') && hasBorderSupport(props.name, 'color'); 33082 const isRadiusSupported = useSetting('border.radius') && hasBorderSupport(props.name, 'radius'); 33083 const isStyleSupported = useSetting('border.style') && hasBorderSupport(props.name, 'style'); 33084 const isWidthSupported = useSetting('border.width') && hasBorderSupport(props.name, 'width'); 33085 const isDisabled = [!isColorSupported, !isRadiusSupported, !isStyleSupported, !isWidthSupported].every(Boolean); 33086 33087 if (isDisabled) { 33088 return null; 33089 } 33090 33091 const defaultBorderControls = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, [BORDER_SUPPORT_KEY, '__experimentalDefaultControls']); 33092 33093 const createResetAllFilter = function (borderAttribute) { 33094 let topLevelAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 33095 return newAttributes => { 33096 var _newAttributes$style; 33097 33098 return { ...newAttributes, 33099 ...topLevelAttributes, 33100 style: { ...newAttributes.style, 33101 border: { ...((_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : _newAttributes$style.border), 33102 [borderAttribute]: undefined 33103 } 33104 } 33105 }; 33106 }; 33107 }; 33108 33109 return (0,external_wp_element_namespaceObject.createElement)(inspector_controls, { 33110 __experimentalGroup: "border" 33111 }, isWidthSupported && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, { 33112 className: "single-column", 33113 hasValue: () => hasBorderWidthValue(props), 33114 label: (0,external_wp_i18n_namespaceObject.__)('Width'), 33115 onDeselect: () => resetBorderWidth(props), 33116 isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.width, 33117 resetAllFilter: createResetAllFilter('width'), 33118 panelId: clientId 33119 }, (0,external_wp_element_namespaceObject.createElement)(BorderWidthEdit, props)), isStyleSupported && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, { 33120 className: "single-column", 33121 hasValue: () => hasBorderStyleValue(props), 33122 label: (0,external_wp_i18n_namespaceObject.__)('Style'), 33123 onDeselect: () => resetBorderStyle(props), 33124 isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.style, 33125 resetAllFilter: createResetAllFilter('style'), 33126 panelId: clientId 33127 }, (0,external_wp_element_namespaceObject.createElement)(BorderStyleEdit, props)), isColorSupported && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, { 33128 hasValue: () => hasBorderColorValue(props), 33129 label: (0,external_wp_i18n_namespaceObject.__)('Color'), 33130 onDeselect: () => resetBorderColor(props), 33131 isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.color, 33132 resetAllFilter: createResetAllFilter('color', { 33133 borderColor: undefined 33134 }), 33135 panelId: clientId 33136 }, (0,external_wp_element_namespaceObject.createElement)(BorderColorEdit, props)), isRadiusSupported && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, { 33137 hasValue: () => hasBorderRadiusValue(props), 33138 label: (0,external_wp_i18n_namespaceObject.__)('Radius'), 33139 onDeselect: () => resetBorderRadius(props), 33140 isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.radius, 33141 resetAllFilter: createResetAllFilter('radius'), 33142 panelId: clientId 33143 }, (0,external_wp_element_namespaceObject.createElement)(BorderRadiusEdit, props))); 33144 } 33145 /** 33146 * Determine whether there is block support for border properties. 33147 * 33148 * @param {string} blockName Block name. 33149 * @param {string} feature Border feature to check support for. 33150 * 33151 * @return {boolean} Whether there is support. 33152 */ 33153 33154 function hasBorderSupport(blockName) { 33155 let feature = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'any'; 33156 33157 if (external_wp_element_namespaceObject.Platform.OS !== 'web') { 33158 return false; 33159 } 33160 33161 const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, BORDER_SUPPORT_KEY); 33162 33163 if (support === true) { 33164 return true; 33165 } 33166 33167 if (feature === 'any') { 33168 return !!(support !== null && support !== void 0 && support.color || support !== null && support !== void 0 && support.radius || support !== null && support !== void 0 && support.width || support !== null && support !== void 0 && support.style); 33169 } 33170 33171 return !!(support !== null && support !== void 0 && support[feature]); 33172 } 33173 /** 33174 * Returns a new style object where the specified border attribute has been 33175 * removed. 33176 * 33177 * @param {Object} style Styles from block attributes. 33178 * @param {string} attribute The border style attribute to clear. 33179 * 33180 * @return {Object} Style object with the specified attribute removed. 33181 */ 33182 33183 function removeBorderAttribute(style, attribute) { 33184 return cleanEmptyObject({ ...style, 33185 border: { ...(style === null || style === void 0 ? void 0 : style.border), 33186 [attribute]: undefined 33187 } 33188 }); 33189 } 33190 33191 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradients/use-gradient.js 33192 /** 33193 * External dependencies 33194 */ 33195 33196 /** 33197 * WordPress dependencies 33198 */ 33199 33200 33201 33202 /** 33203 * Internal dependencies 33204 */ 33205 33206 33207 33208 33209 function __experimentalGetGradientClass(gradientSlug) { 33210 if (!gradientSlug) { 33211 return undefined; 33212 } 33213 33214 return `has-$gradientSlug}-gradient-background`; 33215 } 33216 /** 33217 * Retrieves the gradient value per slug. 33218 * 33219 * @param {Array} gradients Gradient Palette 33220 * @param {string} slug Gradient slug 33221 * 33222 * @return {string} Gradient value. 33223 */ 33224 33225 function getGradientValueBySlug(gradients, slug) { 33226 const gradient = (0,external_lodash_namespaceObject.find)(gradients, ['slug', slug]); 33227 return gradient && gradient.gradient; 33228 } 33229 function __experimentalGetGradientObjectByGradientValue(gradients, value) { 33230 const gradient = (0,external_lodash_namespaceObject.find)(gradients, ['gradient', value]); 33231 return gradient; 33232 } 33233 /** 33234 * Retrieves the gradient slug per slug. 33235 * 33236 * @param {Array} gradients Gradient Palette 33237 * @param {string} value Gradient value 33238 * @return {string} Gradient slug. 33239 */ 33240 33241 function getGradientSlugByValue(gradients, value) { 33242 const gradient = __experimentalGetGradientObjectByGradientValue(gradients, value); 33243 33244 return gradient && gradient.slug; 33245 } 33246 function __experimentalUseGradient() { 33247 let { 33248 gradientAttribute = 'gradient', 33249 customGradientAttribute = 'customGradient' 33250 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 33251 const { 33252 clientId 33253 } = useBlockEditContext(); 33254 const userGradientPalette = useSetting('color.gradients.custom'); 33255 const themeGradientPalette = useSetting('color.gradients.theme'); 33256 const defaultGradientPalette = useSetting('color.gradients.default'); 33257 const allGradients = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userGradientPalette || []), ...(themeGradientPalette || []), ...(defaultGradientPalette || [])], [userGradientPalette, themeGradientPalette, defaultGradientPalette]); 33258 const { 33259 gradient, 33260 customGradient 33261 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 33262 const { 33263 getBlockAttributes 33264 } = select(store); 33265 const attributes = getBlockAttributes(clientId) || {}; 33266 return { 33267 customGradient: attributes[customGradientAttribute], 33268 gradient: attributes[gradientAttribute] 33269 }; 33270 }, [clientId, gradientAttribute, customGradientAttribute]); 33271 const { 33272 updateBlockAttributes 33273 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 33274 const setGradient = (0,external_wp_element_namespaceObject.useCallback)(newGradientValue => { 33275 const slug = getGradientSlugByValue(allGradients, newGradientValue); 33276 33277 if (slug) { 33278 updateBlockAttributes(clientId, { 33279 [gradientAttribute]: slug, 33280 [customGradientAttribute]: undefined 33281 }); 33282 return; 33283 } 33284 33285 updateBlockAttributes(clientId, { 33286 [gradientAttribute]: undefined, 33287 [customGradientAttribute]: newGradientValue 33288 }); 33289 }, [allGradients, clientId, updateBlockAttributes]); 33290 33291 const gradientClass = __experimentalGetGradientClass(gradient); 33292 33293 let gradientValue; 33294 33295 if (gradient) { 33296 gradientValue = getGradientValueBySlug(allGradients, gradient); 33297 } else { 33298 gradientValue = customGradient; 33299 } 33300 33301 return { 33302 gradientClass, 33303 gradientValue, 33304 setGradient 33305 }; 33306 } 33307 33308 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/contrast-checker/index.js 33309 33310 33311 /** 33312 * External dependencies 33313 */ 33314 33315 33316 33317 /** 33318 * WordPress dependencies 33319 */ 33320 33321 33322 33323 33324 k([names, a11y]); 33325 33326 function ContrastChecker(_ref) { 33327 let { 33328 backgroundColor, 33329 fallbackBackgroundColor, 33330 fallbackTextColor, 33331 fallbackLinkColor, 33332 fontSize, 33333 // Font size value in pixels. 33334 isLargeText, 33335 textColor, 33336 linkColor, 33337 enableAlphaChecker = false 33338 } = _ref; 33339 const currentBackgroundColor = backgroundColor || fallbackBackgroundColor; // Must have a background color. 33340 33341 if (!currentBackgroundColor) { 33342 return null; 33343 } 33344 33345 const currentTextColor = textColor || fallbackTextColor; 33346 const currentLinkColor = linkColor || fallbackLinkColor; // Must have at least one text color. 33347 33348 if (!currentTextColor && !currentLinkColor) { 33349 return null; 33350 } 33351 33352 const textColors = [{ 33353 color: currentTextColor, 33354 description: (0,external_wp_i18n_namespaceObject.__)('text color') 33355 }, { 33356 color: currentLinkColor, 33357 description: (0,external_wp_i18n_namespaceObject.__)('link color') 33358 }]; 33359 const colordBackgroundColor = w(currentBackgroundColor); 33360 const backgroundColorHasTransparency = colordBackgroundColor.alpha() < 1; 33361 const backgroundColorBrightness = colordBackgroundColor.brightness(); 33362 const isReadableOptions = { 33363 level: 'AA', 33364 size: isLargeText || isLargeText !== false && fontSize >= 24 ? 'large' : 'small' 33365 }; 33366 let message = ''; 33367 let speakMessage = ''; 33368 33369 for (const item of textColors) { 33370 // If there is no color, go no further. 33371 if (!item.color) { 33372 continue; 33373 } 33374 33375 const colordTextColor = w(item.color); 33376 const isColordTextReadable = colordTextColor.isReadable(colordBackgroundColor, isReadableOptions); 33377 const textHasTransparency = colordTextColor.alpha() < 1; // If the contrast is not readable. 33378 33379 if (!isColordTextReadable) { 33380 // Don't show the message if the background or text is transparent. 33381 if (backgroundColorHasTransparency || textHasTransparency) { 33382 continue; 33383 } 33384 33385 message = backgroundColorBrightness < colordTextColor.brightness() ? (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s is a type of text color, e.g., "text color" or "link color". 33386 (0,external_wp_i18n_namespaceObject.__)('This color combination may be hard for people to read. Try using a darker background color and/or a brighter %s.'), item.description) : (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s is a type of text color, e.g., "text color" or "link color". 33387 (0,external_wp_i18n_namespaceObject.__)('This color combination may be hard for people to read. Try using a brighter background color and/or a darker %s.'), item.description); 33388 speakMessage = (0,external_wp_i18n_namespaceObject.__)('This color combination may be hard for people to read.'); // Break from the loop when we have a contrast warning. 33389 // These messages take priority over the transparency warning. 33390 33391 break; 33392 } // If there is no contrast warning and the text is transparent, 33393 // show the transparent warning if alpha check is enabled. 33394 33395 33396 if (textHasTransparency && enableAlphaChecker) { 33397 message = (0,external_wp_i18n_namespaceObject.__)('Transparent text may be hard for people to read.'); 33398 speakMessage = (0,external_wp_i18n_namespaceObject.__)('Transparent text may be hard for people to read.'); 33399 } 33400 } 33401 33402 if (!message) { 33403 return null; 33404 } // Note: The `Notice` component can speak messages via its `spokenMessage` 33405 // prop, but the contrast checker requires granular control over when the 33406 // announcements are made. Notably, the message will be re-announced if a 33407 // new color combination is selected and the contrast is still insufficient. 33408 33409 33410 (0,external_wp_a11y_namespaceObject.speak)(speakMessage); 33411 return (0,external_wp_element_namespaceObject.createElement)("div", { 33412 className: "block-editor-contrast-checker" 33413 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Notice, { 33414 spokenMessage: null, 33415 status: "warning", 33416 isDismissible: false 33417 }, message)); 33418 } 33419 /** 33420 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/contrast-checker/README.md 33421 */ 33422 33423 33424 /* harmony default export */ var contrast_checker = (ContrastChecker); 33425 33426 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/tools-panel-color-dropdown.js 33427 33428 33429 33430 /** 33431 * External dependencies 33432 */ 33433 33434 /** 33435 * WordPress dependencies 33436 */ 33437 33438 33439 /** 33440 * Internal dependencies 33441 */ 33442 33443 33444 33445 function ToolsPanelColorDropdown(_ref) { 33446 var _settings$gradientVal; 33447 33448 let { 33449 settings, 33450 enableAlpha, 33451 ...otherProps 33452 } = _ref; 33453 const colorGradientSettings = useMultipleOriginColorsAndGradients(); 33454 const controlSettings = { ...colorGradientSettings, 33455 clearable: false, 33456 enableAlpha, 33457 label: settings.label, 33458 onColorChange: settings.onColorChange, 33459 onGradientChange: settings.onGradientChange, 33460 colorValue: settings.colorValue, 33461 gradientValue: settings.gradientValue 33462 }; 33463 const selectedColor = (_settings$gradientVal = settings.gradientValue) !== null && _settings$gradientVal !== void 0 ? _settings$gradientVal : settings.colorValue; 33464 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, _extends({ 33465 hasValue: settings.hasValue, 33466 label: settings.label, 33467 onDeselect: settings.onDeselect, 33468 isShownByDefault: settings.isShownByDefault, 33469 resetAllFilter: settings.resetAllFilter 33470 }, otherProps, { 33471 className: "block-editor-tools-panel-color-gradient-settings__item" 33472 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, { 33473 className: "block-editor-tools-panel-color-dropdown", 33474 contentClassName: "block-editor-panel-color-gradient-settings__dropdown-content", 33475 renderToggle: _ref2 => { 33476 let { 33477 isOpen, 33478 onToggle 33479 } = _ref2; 33480 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 33481 onClick: onToggle, 33482 "aria-expanded": isOpen, 33483 className: classnames_default()('block-editor-panel-color-gradient-settings__dropdown', { 33484 'is-open': isOpen 33485 }) 33486 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 33487 justify: "flex-start" 33488 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, { 33489 className: "block-editor-panel-color-gradient-settings__color-indicator", 33490 colorValue: selectedColor 33491 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, settings.label))); 33492 }, 33493 renderContent: () => (0,external_wp_element_namespaceObject.createElement)(control, _extends({ 33494 showTitle: false, 33495 __experimentalHasMultipleOrigins: true, 33496 __experimentalIsRenderedInSidebar: true, 33497 enableAlpha: true 33498 }, controlSettings)) 33499 })); 33500 } 33501 33502 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/color-panel.js 33503 33504 33505 /** 33506 * WordPress dependencies 33507 */ 33508 33509 /** 33510 * Internal dependencies 33511 */ 33512 33513 33514 33515 33516 33517 33518 function getComputedStyle(node) { 33519 return node.ownerDocument.defaultView.getComputedStyle(node); 33520 } 33521 33522 function ColorPanel(_ref) { 33523 let { 33524 enableAlpha = false, 33525 settings, 33526 clientId, 33527 enableContrastChecking = true 33528 } = _ref; 33529 const [detectedBackgroundColor, setDetectedBackgroundColor] = (0,external_wp_element_namespaceObject.useState)(); 33530 const [detectedColor, setDetectedColor] = (0,external_wp_element_namespaceObject.useState)(); 33531 const [detectedLinkColor, setDetectedLinkColor] = (0,external_wp_element_namespaceObject.useState)(); 33532 const ref = useBlockRef(clientId); 33533 (0,external_wp_element_namespaceObject.useEffect)(() => { 33534 var _ref$current; 33535 33536 if (!enableContrastChecking) { 33537 return; 33538 } 33539 33540 if (!ref.current) { 33541 return; 33542 } 33543 33544 setDetectedColor(getComputedStyle(ref.current).color); 33545 const firstLinkElement = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector('a'); 33546 33547 if (firstLinkElement && !!firstLinkElement.innerText) { 33548 setDetectedLinkColor(getComputedStyle(firstLinkElement).color); 33549 } 33550 33551 let backgroundColorNode = ref.current; 33552 let backgroundColor = getComputedStyle(backgroundColorNode).backgroundColor; 33553 33554 while (backgroundColor === 'rgba(0, 0, 0, 0)' && backgroundColorNode.parentNode && backgroundColorNode.parentNode.nodeType === backgroundColorNode.parentNode.ELEMENT_NODE) { 33555 backgroundColorNode = backgroundColorNode.parentNode; 33556 backgroundColor = getComputedStyle(backgroundColorNode).backgroundColor; 33557 } 33558 33559 setDetectedBackgroundColor(backgroundColor); 33560 }); 33561 return (0,external_wp_element_namespaceObject.createElement)(inspector_controls, { 33562 __experimentalGroup: "color" 33563 }, settings.map((setting, index) => (0,external_wp_element_namespaceObject.createElement)(ToolsPanelColorDropdown, { 33564 key: index, 33565 settings: setting, 33566 panelId: clientId, 33567 enableAlpha: enableAlpha 33568 })), enableContrastChecking && (0,external_wp_element_namespaceObject.createElement)(contrast_checker, { 33569 backgroundColor: detectedBackgroundColor, 33570 textColor: detectedColor, 33571 enableAlphaChecker: enableAlpha, 33572 linkColor: detectedLinkColor 33573 })); 33574 } 33575 33576 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/color.js 33577 33578 33579 33580 /** 33581 * External dependencies 33582 */ 33583 33584 33585 /** 33586 * WordPress dependencies 33587 */ 33588 33589 33590 33591 33592 33593 33594 /** 33595 * Internal dependencies 33596 */ 33597 33598 33599 33600 33601 33602 33603 const COLOR_SUPPORT_KEY = 'color'; 33604 33605 const hasColorSupport = blockType => { 33606 const colorSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, COLOR_SUPPORT_KEY); 33607 return colorSupport && (colorSupport.link === true || colorSupport.gradient === true || colorSupport.background !== false || colorSupport.text !== false); 33608 }; 33609 33610 const hasLinkColorSupport = blockType => { 33611 if (external_wp_element_namespaceObject.Platform.OS !== 'web') { 33612 return false; 33613 } 33614 33615 const colorSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, COLOR_SUPPORT_KEY); 33616 return (0,external_lodash_namespaceObject.isObject)(colorSupport) && !!colorSupport.link; 33617 }; 33618 33619 const hasGradientSupport = blockType => { 33620 const colorSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, COLOR_SUPPORT_KEY); 33621 return (0,external_lodash_namespaceObject.isObject)(colorSupport) && !!colorSupport.gradients; 33622 }; 33623 33624 const hasBackgroundColorSupport = blockType => { 33625 const colorSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, COLOR_SUPPORT_KEY); 33626 return colorSupport && colorSupport.background !== false; 33627 }; 33628 33629 const hasTextColorSupport = blockType => { 33630 const colorSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, COLOR_SUPPORT_KEY); 33631 return colorSupport && colorSupport.text !== false; 33632 }; 33633 /** 33634 * Checks whether a color has been set either with a named preset color in 33635 * a top level block attribute or as a custom value within the style attribute 33636 * object. 33637 * 33638 * @param {string} name Name of the color to check. 33639 * @return {boolean} Whether or not a color has a value. 33640 */ 33641 33642 33643 const hasColor = name => props => { 33644 var _props$attributes$sty9, _props$attributes$sty10; 33645 33646 if (name === 'background') { 33647 var _props$attributes$sty, _props$attributes$sty2, _props$attributes$sty3, _props$attributes$sty4; 33648 33649 return !!props.attributes.backgroundColor || !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.color) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.background) || !!props.attributes.gradient || !!((_props$attributes$sty3 = props.attributes.style) !== null && _props$attributes$sty3 !== void 0 && (_props$attributes$sty4 = _props$attributes$sty3.color) !== null && _props$attributes$sty4 !== void 0 && _props$attributes$sty4.gradient); 33650 } 33651 33652 if (name === 'link') { 33653 var _props$attributes$sty5, _props$attributes$sty6, _props$attributes$sty7, _props$attributes$sty8; 33654 33655 return !!((_props$attributes$sty5 = props.attributes.style) !== null && _props$attributes$sty5 !== void 0 && (_props$attributes$sty6 = _props$attributes$sty5.elements) !== null && _props$attributes$sty6 !== void 0 && (_props$attributes$sty7 = _props$attributes$sty6.link) !== null && _props$attributes$sty7 !== void 0 && (_props$attributes$sty8 = _props$attributes$sty7.color) !== null && _props$attributes$sty8 !== void 0 && _props$attributes$sty8.text); 33656 } 33657 33658 return !!props.attributes[`$name}Color`] || !!((_props$attributes$sty9 = props.attributes.style) !== null && _props$attributes$sty9 !== void 0 && (_props$attributes$sty10 = _props$attributes$sty9.color) !== null && _props$attributes$sty10 !== void 0 && _props$attributes$sty10[name]); 33659 }; 33660 /** 33661 * Clears a single color property from a style object. 33662 * 33663 * @param {Array} path Path to color property to clear within styles object. 33664 * @param {Object} style Block attributes style object. 33665 * @return {Object} Styles with the color property omitted. 33666 */ 33667 33668 33669 const clearColorFromStyles = (path, style) => cleanEmptyObject(immutableSet(style, path, undefined)); 33670 /** 33671 * Resets the block attributes for text color. 33672 * 33673 * @param {Object} props Current block props. 33674 * @param {Object} props.attributes Block attributes. 33675 * @param {Function} props.setAttributes Block's setAttributes prop used to apply reset. 33676 */ 33677 33678 33679 const resetTextColor = _ref => { 33680 let { 33681 attributes, 33682 setAttributes 33683 } = _ref; 33684 setAttributes({ 33685 textColor: undefined, 33686 style: clearColorFromStyles(['color', 'text'], attributes.style) 33687 }); 33688 }; 33689 /** 33690 * Clears text color related properties from supplied attributes. 33691 * 33692 * @param {Object} attributes Block attributes. 33693 * @return {Object} Update block attributes with text color properties omitted. 33694 */ 33695 33696 33697 const resetAllTextFilter = attributes => ({ 33698 textColor: undefined, 33699 style: clearColorFromStyles(['color', 'text'], attributes.style) 33700 }); 33701 /** 33702 * Resets the block attributes for link color. 33703 * 33704 * @param {Object} props Current block props. 33705 * @param {Object} props.attributes Block attributes. 33706 * @param {Function} props.setAttributes Block's setAttributes prop used to apply reset. 33707 */ 33708 33709 33710 const resetLinkColor = _ref2 => { 33711 let { 33712 attributes, 33713 setAttributes 33714 } = _ref2; 33715 const path = ['elements', 'link', 'color', 'text']; 33716 setAttributes({ 33717 style: clearColorFromStyles(path, attributes.style) 33718 }); 33719 }; 33720 /** 33721 * Clears link color related properties from supplied attributes. 33722 * 33723 * @param {Object} attributes Block attributes. 33724 * @return {Object} Update block attributes with link color properties omitted. 33725 */ 33726 33727 33728 const resetAllLinkFilter = attributes => ({ 33729 style: clearColorFromStyles(['elements', 'link', 'color', 'text'], attributes.style) 33730 }); 33731 /** 33732 * Clears all background color related properties including gradients from 33733 * supplied block attributes. 33734 * 33735 * @param {Object} attributes Block attributes. 33736 * @return {Object} Block attributes with background and gradient omitted. 33737 */ 33738 33739 33740 const clearBackgroundAndGradient = attributes => { 33741 var _attributes$style; 33742 33743 return { 33744 backgroundColor: undefined, 33745 gradient: undefined, 33746 style: { ...attributes.style, 33747 color: { ...((_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : _attributes$style.color), 33748 background: undefined, 33749 gradient: undefined 33750 } 33751 } 33752 }; 33753 }; 33754 /** 33755 * Resets the block attributes for both background color and gradient. 33756 * 33757 * @param {Object} props Current block props. 33758 * @param {Object} props.attributes Block attributes. 33759 * @param {Function} props.setAttributes Block's setAttributes prop used to apply reset. 33760 */ 33761 33762 33763 const resetBackgroundAndGradient = _ref3 => { 33764 let { 33765 attributes, 33766 setAttributes 33767 } = _ref3; 33768 setAttributes(clearBackgroundAndGradient(attributes)); 33769 }; 33770 /** 33771 * Filters registered block settings, extending attributes to include 33772 * `backgroundColor` and `textColor` attribute. 33773 * 33774 * @param {Object} settings Original block settings. 33775 * 33776 * @return {Object} Filtered block settings. 33777 */ 33778 33779 33780 function color_addAttributes(settings) { 33781 if (!hasColorSupport(settings)) { 33782 return settings; 33783 } // Allow blocks to specify their own attribute definition with default values if needed. 33784 33785 33786 if (!settings.attributes.backgroundColor) { 33787 Object.assign(settings.attributes, { 33788 backgroundColor: { 33789 type: 'string' 33790 } 33791 }); 33792 } 33793 33794 if (!settings.attributes.textColor) { 33795 Object.assign(settings.attributes, { 33796 textColor: { 33797 type: 'string' 33798 } 33799 }); 33800 } 33801 33802 if (hasGradientSupport(settings) && !settings.attributes.gradient) { 33803 Object.assign(settings.attributes, { 33804 gradient: { 33805 type: 'string' 33806 } 33807 }); 33808 } 33809 33810 return settings; 33811 } 33812 /** 33813 * Override props assigned to save component to inject colors classnames. 33814 * 33815 * @param {Object} props Additional props applied to save element. 33816 * @param {Object} blockType Block type. 33817 * @param {Object} attributes Block attributes. 33818 * 33819 * @return {Object} Filtered props applied to save element. 33820 */ 33821 33822 33823 function color_addSaveProps(props, blockType, attributes) { 33824 var _style$color, _style$color2, _style$color3, _style$color4, _style$elements, _style$elements$link; 33825 33826 if (!hasColorSupport(blockType) || shouldSkipSerialization(blockType, COLOR_SUPPORT_KEY)) { 33827 return props; 33828 } 33829 33830 const hasGradient = hasGradientSupport(blockType); // I'd have preferred to avoid the "style" attribute usage here 33831 33832 const { 33833 backgroundColor, 33834 textColor, 33835 gradient, 33836 style 33837 } = attributes; 33838 33839 const shouldSerialize = feature => !shouldSkipSerialization(blockType, COLOR_SUPPORT_KEY, feature); // Primary color classes must come before the `has-text-color`, 33840 // `has-background` and `has-link-color` classes to maintain backwards 33841 // compatibility and avoid block invalidations. 33842 33843 33844 const textClass = shouldSerialize('text') ? getColorClassName('color', textColor) : undefined; 33845 const gradientClass = shouldSerialize('gradients') ? __experimentalGetGradientClass(gradient) : undefined; 33846 const backgroundClass = shouldSerialize('background') ? getColorClassName('background-color', backgroundColor) : undefined; 33847 const serializeHasBackground = shouldSerialize('background') || shouldSerialize('gradients'); 33848 const hasBackground = backgroundColor || (style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.background) || hasGradient && (gradient || (style === null || style === void 0 ? void 0 : (_style$color2 = style.color) === null || _style$color2 === void 0 ? void 0 : _style$color2.gradient)); 33849 const newClassName = classnames_default()(props.className, textClass, gradientClass, { 33850 // Don't apply the background class if there's a custom gradient. 33851 [backgroundClass]: (!hasGradient || !(style !== null && style !== void 0 && (_style$color3 = style.color) !== null && _style$color3 !== void 0 && _style$color3.gradient)) && !!backgroundClass, 33852 'has-text-color': shouldSerialize('text') && (textColor || (style === null || style === void 0 ? void 0 : (_style$color4 = style.color) === null || _style$color4 === void 0 ? void 0 : _style$color4.text)), 33853 'has-background': serializeHasBackground && hasBackground, 33854 'has-link-color': shouldSerialize('link') && (style === null || style === void 0 ? void 0 : (_style$elements = style.elements) === null || _style$elements === void 0 ? void 0 : (_style$elements$link = _style$elements.link) === null || _style$elements$link === void 0 ? void 0 : _style$elements$link.color) 33855 }); 33856 props.className = newClassName ? newClassName : undefined; 33857 return props; 33858 } 33859 /** 33860 * Filters registered block settings to extend the block edit wrapper 33861 * to apply the desired styles and classnames properly. 33862 * 33863 * @param {Object} settings Original block settings. 33864 * 33865 * @return {Object} Filtered block settings. 33866 */ 33867 33868 function color_addEditProps(settings) { 33869 if (!hasColorSupport(settings) || shouldSkipSerialization(settings, COLOR_SUPPORT_KEY)) { 33870 return settings; 33871 } 33872 33873 const existingGetEditWrapperProps = settings.getEditWrapperProps; 33874 33875 settings.getEditWrapperProps = attributes => { 33876 let props = {}; 33877 33878 if (existingGetEditWrapperProps) { 33879 props = existingGetEditWrapperProps(attributes); 33880 } 33881 33882 return color_addSaveProps(props, settings, attributes); 33883 }; 33884 33885 return settings; 33886 } 33887 33888 const getLinkColorFromAttributeValue = (colors, value) => { 33889 const attributeParsed = /var:preset\|color\|(.+)/.exec(value); 33890 33891 if (attributeParsed && attributeParsed[1]) { 33892 return getColorObjectByAttributeValues(colors, attributeParsed[1]).color; 33893 } 33894 33895 return value; 33896 }; 33897 /** 33898 * Inspector control panel containing the color related configuration 33899 * 33900 * @param {Object} props 33901 * 33902 * @return {WPElement} Color edit element. 33903 */ 33904 33905 33906 function ColorEdit(props) { 33907 var _style$color6, _style$color7, _style$color8, _style$elements2, _style$elements2$link, _style$elements2$link2, _style$elements3, _style$elements3$link, _style$elements3$link2; 33908 33909 const { 33910 name: blockName, 33911 attributes 33912 } = props; // Some color settings have a special handling for deprecated flags in `useSetting`, 33913 // so we can't unwrap them by doing const { ... } = useSetting('color') 33914 // until https://github.com/WordPress/gutenberg/issues/37094 is fixed. 33915 33916 const userPalette = useSetting('color.palette.custom'); 33917 const themePalette = useSetting('color.palette.theme'); 33918 const defaultPalette = useSetting('color.palette.default'); 33919 const allSolids = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]); 33920 const userGradientPalette = useSetting('color.gradients.custom'); 33921 const themeGradientPalette = useSetting('color.gradients.theme'); 33922 const defaultGradientPalette = useSetting('color.gradients.default'); 33923 const allGradients = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userGradientPalette || []), ...(themeGradientPalette || []), ...(defaultGradientPalette || [])], [userGradientPalette, themeGradientPalette, defaultGradientPalette]); 33924 const areCustomSolidsEnabled = useSetting('color.custom'); 33925 const areCustomGradientsEnabled = useSetting('color.customGradient'); 33926 const isBackgroundEnabled = useSetting('color.background'); 33927 const isLinkEnabled = useSetting('color.link'); 33928 const isTextEnabled = useSetting('color.text'); 33929 const solidsEnabled = areCustomSolidsEnabled || !themePalette || (themePalette === null || themePalette === void 0 ? void 0 : themePalette.length) > 0; 33930 const gradientsEnabled = areCustomGradientsEnabled || !themeGradientPalette || (themeGradientPalette === null || themeGradientPalette === void 0 ? void 0 : themeGradientPalette.length) > 0; // Shouldn't be needed but right now the ColorGradientsPanel 33931 // can trigger both onChangeColor and onChangeBackground 33932 // synchronously causing our two callbacks to override changes 33933 // from each other. 33934 33935 const localAttributes = (0,external_wp_element_namespaceObject.useRef)(attributes); 33936 (0,external_wp_element_namespaceObject.useEffect)(() => { 33937 localAttributes.current = attributes; 33938 }, [attributes]); 33939 33940 if (!hasColorSupport(blockName)) { 33941 return null; 33942 } 33943 33944 const hasLinkColor = hasLinkColorSupport(blockName) && isLinkEnabled && solidsEnabled; 33945 const hasTextColor = hasTextColorSupport(blockName) && isTextEnabled && solidsEnabled; 33946 const hasBackgroundColor = hasBackgroundColorSupport(blockName) && isBackgroundEnabled && solidsEnabled; 33947 const hasGradientColor = hasGradientSupport(blockName) && gradientsEnabled; 33948 33949 if (!hasLinkColor && !hasTextColor && !hasBackgroundColor && !hasGradientColor) { 33950 return null; 33951 } 33952 33953 const { 33954 style, 33955 textColor, 33956 backgroundColor, 33957 gradient 33958 } = attributes; 33959 let gradientValue; 33960 33961 if (hasGradientColor && gradient) { 33962 gradientValue = getGradientValueBySlug(allGradients, gradient); 33963 } else if (hasGradientColor) { 33964 var _style$color5; 33965 33966 gradientValue = style === null || style === void 0 ? void 0 : (_style$color5 = style.color) === null || _style$color5 === void 0 ? void 0 : _style$color5.gradient; 33967 } 33968 33969 const onChangeColor = name => value => { 33970 var _localAttributes$curr, _localAttributes$curr2; 33971 33972 const colorObject = getColorObjectByColorValue(allSolids, value); 33973 const attributeName = name + 'Color'; 33974 const newStyle = { ...localAttributes.current.style, 33975 color: { ...((_localAttributes$curr = localAttributes.current) === null || _localAttributes$curr === void 0 ? void 0 : (_localAttributes$curr2 = _localAttributes$curr.style) === null || _localAttributes$curr2 === void 0 ? void 0 : _localAttributes$curr2.color), 33976 [name]: colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value 33977 } 33978 }; 33979 const newNamedColor = colorObject !== null && colorObject !== void 0 && colorObject.slug ? colorObject.slug : undefined; 33980 const newAttributes = { 33981 style: cleanEmptyObject(newStyle), 33982 [attributeName]: newNamedColor 33983 }; 33984 props.setAttributes(newAttributes); 33985 localAttributes.current = { ...localAttributes.current, 33986 ...newAttributes 33987 }; 33988 }; 33989 33990 const onChangeGradient = value => { 33991 const slug = getGradientSlugByValue(allGradients, value); 33992 let newAttributes; 33993 33994 if (slug) { 33995 var _localAttributes$curr3, _localAttributes$curr4, _localAttributes$curr5; 33996 33997 const newStyle = { ...((_localAttributes$curr3 = localAttributes.current) === null || _localAttributes$curr3 === void 0 ? void 0 : _localAttributes$curr3.style), 33998 color: { ...((_localAttributes$curr4 = localAttributes.current) === null || _localAttributes$curr4 === void 0 ? void 0 : (_localAttributes$curr5 = _localAttributes$curr4.style) === null || _localAttributes$curr5 === void 0 ? void 0 : _localAttributes$curr5.color), 33999 gradient: undefined 34000 } 34001 }; 34002 newAttributes = { 34003 style: cleanEmptyObject(newStyle), 34004 gradient: slug 34005 }; 34006 } else { 34007 var _localAttributes$curr6, _localAttributes$curr7, _localAttributes$curr8; 34008 34009 const newStyle = { ...((_localAttributes$curr6 = localAttributes.current) === null || _localAttributes$curr6 === void 0 ? void 0 : _localAttributes$curr6.style), 34010 color: { ...((_localAttributes$curr7 = localAttributes.current) === null || _localAttributes$curr7 === void 0 ? void 0 : (_localAttributes$curr8 = _localAttributes$curr7.style) === null || _localAttributes$curr8 === void 0 ? void 0 : _localAttributes$curr8.color), 34011 gradient: value 34012 } 34013 }; 34014 newAttributes = { 34015 style: cleanEmptyObject(newStyle), 34016 gradient: undefined 34017 }; 34018 } 34019 34020 props.setAttributes(newAttributes); 34021 localAttributes.current = { ...localAttributes.current, 34022 ...newAttributes 34023 }; 34024 }; 34025 34026 const onChangeLinkColor = value => { 34027 const colorObject = getColorObjectByColorValue(allSolids, value); 34028 const newLinkColorValue = colorObject !== null && colorObject !== void 0 && colorObject.slug ? `var:preset|color|$colorObject.slug}` : value; 34029 const newStyle = cleanEmptyObject(immutableSet(style, ['elements', 'link', 'color', 'text'], newLinkColorValue)); 34030 props.setAttributes({ 34031 style: newStyle 34032 }); 34033 }; 34034 34035 const enableContrastChecking = external_wp_element_namespaceObject.Platform.OS === 'web' && !gradient && !(style !== null && style !== void 0 && (_style$color6 = style.color) !== null && _style$color6 !== void 0 && _style$color6.gradient); 34036 const defaultColorControls = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, [COLOR_SUPPORT_KEY, '__experimentalDefaultControls']); 34037 return (0,external_wp_element_namespaceObject.createElement)(ColorPanel, { 34038 enableContrastChecking: enableContrastChecking, 34039 clientId: props.clientId, 34040 enableAlpha: true, 34041 settings: [...(hasTextColor ? [{ 34042 label: (0,external_wp_i18n_namespaceObject.__)('Text'), 34043 onColorChange: onChangeColor('text'), 34044 colorValue: getColorObjectByAttributeValues(allSolids, textColor, style === null || style === void 0 ? void 0 : (_style$color7 = style.color) === null || _style$color7 === void 0 ? void 0 : _style$color7.text).color, 34045 isShownByDefault: defaultColorControls === null || defaultColorControls === void 0 ? void 0 : defaultColorControls.text, 34046 hasValue: () => hasColor('text')(props), 34047 onDeselect: () => resetTextColor(props), 34048 resetAllFilter: resetAllTextFilter 34049 }] : []), ...(hasBackgroundColor || hasGradientColor ? [{ 34050 label: (0,external_wp_i18n_namespaceObject.__)('Background'), 34051 onColorChange: hasBackgroundColor ? onChangeColor('background') : undefined, 34052 colorValue: getColorObjectByAttributeValues(allSolids, backgroundColor, style === null || style === void 0 ? void 0 : (_style$color8 = style.color) === null || _style$color8 === void 0 ? void 0 : _style$color8.background).color, 34053 gradientValue, 34054 onGradientChange: hasGradientColor ? onChangeGradient : undefined, 34055 isShownByDefault: defaultColorControls === null || defaultColorControls === void 0 ? void 0 : defaultColorControls.background, 34056 hasValue: () => hasColor('background')(props), 34057 onDeselect: () => resetBackgroundAndGradient(props), 34058 resetAllFilter: clearBackgroundAndGradient 34059 }] : []), ...(hasLinkColor ? [{ 34060 label: (0,external_wp_i18n_namespaceObject.__)('Link'), 34061 onColorChange: onChangeLinkColor, 34062 colorValue: getLinkColorFromAttributeValue(allSolids, style === null || style === void 0 ? void 0 : (_style$elements2 = style.elements) === null || _style$elements2 === void 0 ? void 0 : (_style$elements2$link = _style$elements2.link) === null || _style$elements2$link === void 0 ? void 0 : (_style$elements2$link2 = _style$elements2$link.color) === null || _style$elements2$link2 === void 0 ? void 0 : _style$elements2$link2.text), 34063 clearable: !!(style !== null && style !== void 0 && (_style$elements3 = style.elements) !== null && _style$elements3 !== void 0 && (_style$elements3$link = _style$elements3.link) !== null && _style$elements3$link !== void 0 && (_style$elements3$link2 = _style$elements3$link.color) !== null && _style$elements3$link2 !== void 0 && _style$elements3$link2.text), 34064 isShownByDefault: defaultColorControls === null || defaultColorControls === void 0 ? void 0 : defaultColorControls.link, 34065 hasValue: () => hasColor('link')(props), 34066 onDeselect: () => resetLinkColor(props), 34067 resetAllFilter: resetAllLinkFilter 34068 }] : [])] 34069 }); 34070 } 34071 /** 34072 * This adds inline styles for color palette colors. 34073 * Ideally, this is not needed and themes should load their palettes on the editor. 34074 * 34075 * @param {Function} BlockListBlock Original component. 34076 * 34077 * @return {Function} Wrapped component. 34078 */ 34079 34080 const withColorPaletteStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => { 34081 var _props$wrapperProps; 34082 34083 const { 34084 name, 34085 attributes 34086 } = props; 34087 const { 34088 backgroundColor, 34089 textColor 34090 } = attributes; 34091 const userPalette = useSetting('color.palette.custom') || []; 34092 const themePalette = useSetting('color.palette.theme') || []; 34093 const defaultPalette = useSetting('color.palette.default') || []; 34094 const colors = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]); 34095 34096 if (!hasColorSupport(name) || shouldSkipSerialization(name, COLOR_SUPPORT_KEY)) { 34097 return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props); 34098 } 34099 34100 const extraStyles = {}; 34101 34102 if (textColor && !shouldSkipSerialization(name, COLOR_SUPPORT_KEY, 'text')) { 34103 var _getColorObjectByAttr; 34104 34105 extraStyles.color = (_getColorObjectByAttr = getColorObjectByAttributeValues(colors, textColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color; 34106 } 34107 34108 if (backgroundColor && !shouldSkipSerialization(name, COLOR_SUPPORT_KEY, 'background')) { 34109 var _getColorObjectByAttr2; 34110 34111 extraStyles.backgroundColor = (_getColorObjectByAttr2 = getColorObjectByAttributeValues(colors, backgroundColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color; 34112 } 34113 34114 let wrapperProps = props.wrapperProps; 34115 wrapperProps = { ...props.wrapperProps, 34116 style: { ...extraStyles, 34117 ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style) 34118 } 34119 }; 34120 return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, { 34121 wrapperProps: wrapperProps 34122 })); 34123 }); 34124 const MIGRATION_PATHS = { 34125 linkColor: [['style', 'elements', 'link', 'color', 'text']], 34126 textColor: [['textColor'], ['style', 'color', 'text']], 34127 backgroundColor: [['backgroundColor'], ['style', 'color', 'background']], 34128 gradient: [['gradient'], ['style', 'color', 'gradient']] 34129 }; 34130 function color_addTransforms(result, source, index, results) { 34131 const destinationBlockType = result.name; 34132 const activeSupports = { 34133 linkColor: hasLinkColorSupport(destinationBlockType), 34134 textColor: hasTextColorSupport(destinationBlockType), 34135 backgroundColor: hasBackgroundColorSupport(destinationBlockType), 34136 gradient: hasGradientSupport(destinationBlockType) 34137 }; 34138 return transformStyles(activeSupports, MIGRATION_PATHS, result, source, index, results); 34139 } 34140 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/color/addAttribute', color_addAttributes); 34141 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/color/addSaveProps', color_addSaveProps); 34142 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/color/addEditProps', color_addEditProps); 34143 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/color/with-color-palette-styles', withColorPaletteStyles); 34144 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.switchToBlockType.transformedBlock', 'core/color/addTransforms', color_addTransforms); 34145 34146 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-appearance-control/index.js 34147 34148 34149 /** 34150 * WordPress dependencies 34151 */ 34152 34153 34154 34155 const FONT_STYLES = [{ 34156 name: (0,external_wp_i18n_namespaceObject._x)('Regular', 'font style'), 34157 value: 'normal' 34158 }, { 34159 name: (0,external_wp_i18n_namespaceObject._x)('Italic', 'font style'), 34160 value: 'italic' 34161 }]; 34162 const FONT_WEIGHTS = [{ 34163 name: (0,external_wp_i18n_namespaceObject._x)('Thin', 'font weight'), 34164 value: '100' 34165 }, { 34166 name: (0,external_wp_i18n_namespaceObject._x)('Extra Light', 'font weight'), 34167 value: '200' 34168 }, { 34169 name: (0,external_wp_i18n_namespaceObject._x)('Light', 'font weight'), 34170 value: '300' 34171 }, { 34172 name: (0,external_wp_i18n_namespaceObject._x)('Regular', 'font weight'), 34173 value: '400' 34174 }, { 34175 name: (0,external_wp_i18n_namespaceObject._x)('Medium', 'font weight'), 34176 value: '500' 34177 }, { 34178 name: (0,external_wp_i18n_namespaceObject._x)('Semi Bold', 'font weight'), 34179 value: '600' 34180 }, { 34181 name: (0,external_wp_i18n_namespaceObject._x)('Bold', 'font weight'), 34182 value: '700' 34183 }, { 34184 name: (0,external_wp_i18n_namespaceObject._x)('Extra Bold', 'font weight'), 34185 value: '800' 34186 }, { 34187 name: (0,external_wp_i18n_namespaceObject._x)('Black', 'font weight'), 34188 value: '900' 34189 }]; 34190 /** 34191 * Adjusts font appearance field label in case either font styles or weights 34192 * are disabled. 34193 * 34194 * @param {boolean} hasFontStyles Whether font styles are enabled and present. 34195 * @param {boolean} hasFontWeights Whether font weights are enabled and present. 34196 * @return {string} A label representing what font appearance is being edited. 34197 */ 34198 34199 const getFontAppearanceLabel = (hasFontStyles, hasFontWeights) => { 34200 if (!hasFontStyles) { 34201 return (0,external_wp_i18n_namespaceObject.__)('Font weight'); 34202 } 34203 34204 if (!hasFontWeights) { 34205 return (0,external_wp_i18n_namespaceObject.__)('Font style'); 34206 } 34207 34208 return (0,external_wp_i18n_namespaceObject.__)('Appearance'); 34209 }; 34210 /** 34211 * Control to display unified font style and weight options. 34212 * 34213 * @param {Object} props Component props. 34214 * 34215 * @return {WPElement} Font appearance control. 34216 */ 34217 34218 function FontAppearanceControl(props) { 34219 const { 34220 onChange, 34221 hasFontStyles = true, 34222 hasFontWeights = true, 34223 value: { 34224 fontStyle, 34225 fontWeight 34226 } 34227 } = props; 34228 const hasStylesOrWeights = hasFontStyles || hasFontWeights; 34229 const label = getFontAppearanceLabel(hasFontStyles, hasFontWeights); 34230 const defaultOption = { 34231 key: 'default', 34232 name: (0,external_wp_i18n_namespaceObject.__)('Default'), 34233 style: { 34234 fontStyle: undefined, 34235 fontWeight: undefined 34236 } 34237 }; // Combines both font style and weight options into a single dropdown. 34238 34239 const combineOptions = () => { 34240 const combinedOptions = [defaultOption]; 34241 FONT_STYLES.forEach(_ref => { 34242 let { 34243 name: styleName, 34244 value: styleValue 34245 } = _ref; 34246 FONT_WEIGHTS.forEach(_ref2 => { 34247 let { 34248 name: weightName, 34249 value: weightValue 34250 } = _ref2; 34251 const optionName = styleValue === 'normal' ? weightName : (0,external_wp_i18n_namespaceObject.sprintf)( 34252 /* translators: 1: Font weight name. 2: Font style name. */ 34253 (0,external_wp_i18n_namespaceObject.__)('%1$s %2$s'), weightName, styleName); 34254 combinedOptions.push({ 34255 key: `$styleValue}-$weightValue}`, 34256 name: optionName, 34257 style: { 34258 fontStyle: styleValue, 34259 fontWeight: weightValue 34260 } 34261 }); 34262 }); 34263 }); 34264 return combinedOptions; 34265 }; // Generates select options for font styles only. 34266 34267 34268 const styleOptions = () => { 34269 const combinedOptions = [defaultOption]; 34270 FONT_STYLES.forEach(_ref3 => { 34271 let { 34272 name, 34273 value 34274 } = _ref3; 34275 combinedOptions.push({ 34276 key: value, 34277 name, 34278 style: { 34279 fontStyle: value, 34280 fontWeight: undefined 34281 } 34282 }); 34283 }); 34284 return combinedOptions; 34285 }; // Generates select options for font weights only. 34286 34287 34288 const weightOptions = () => { 34289 const combinedOptions = [defaultOption]; 34290 FONT_WEIGHTS.forEach(_ref4 => { 34291 let { 34292 name, 34293 value 34294 } = _ref4; 34295 combinedOptions.push({ 34296 key: value, 34297 name, 34298 style: { 34299 fontStyle: undefined, 34300 fontWeight: value 34301 } 34302 }); 34303 }); 34304 return combinedOptions; 34305 }; // Map font styles and weights to select options. 34306 34307 34308 const selectOptions = (0,external_wp_element_namespaceObject.useMemo)(() => { 34309 if (hasFontStyles && hasFontWeights) { 34310 return combineOptions(); 34311 } 34312 34313 return hasFontStyles ? styleOptions() : weightOptions(); 34314 }, [props.options]); // Find current selection by comparing font style & weight against options, 34315 // and fall back to the Default option if there is no matching option. 34316 34317 const currentSelection = selectOptions.find(option => option.style.fontStyle === fontStyle && option.style.fontWeight === fontWeight) || selectOptions[0]; // Adjusts screen reader description based on styles or weights. 34318 34319 const getDescribedBy = () => { 34320 if (!currentSelection) { 34321 return (0,external_wp_i18n_namespaceObject.__)('No selected font appearance'); 34322 } 34323 34324 if (!hasFontStyles) { 34325 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Currently selected font weight. 34326 (0,external_wp_i18n_namespaceObject.__)('Currently selected font weight: %s'), currentSelection.name); 34327 } 34328 34329 if (!hasFontWeights) { 34330 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Currently selected font style. 34331 (0,external_wp_i18n_namespaceObject.__)('Currently selected font style: %s'), currentSelection.name); 34332 } 34333 34334 return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Currently selected font appearance. 34335 (0,external_wp_i18n_namespaceObject.__)('Currently selected font appearance: %s'), currentSelection.name); 34336 }; 34337 34338 return hasStylesOrWeights && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CustomSelectControl, { 34339 className: "components-font-appearance-control", 34340 label: label, 34341 describedBy: getDescribedBy(), 34342 options: selectOptions, 34343 value: currentSelection, 34344 onChange: _ref5 => { 34345 let { 34346 selectedItem 34347 } = _ref5; 34348 return onChange(selectedItem.style); 34349 } 34350 }); 34351 } 34352 34353 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/line-height-control/utils.js 34354 const BASE_DEFAULT_VALUE = 1.5; 34355 const STEP = 0.1; 34356 /** 34357 * There are varying value types within LineHeightControl: 34358 * 34359 * {undefined} Initial value. No changes from the user. 34360 * {string} Input value. Value consumed/outputted by the input. Empty would be ''. 34361 * {number} Block attribute type. Input value needs to be converted for attribute setting. 34362 * 34363 * Note: If the value is undefined, the input requires it to be an empty string ('') 34364 * in order to be considered "controlled" by props (rather than internal state). 34365 */ 34366 34367 const RESET_VALUE = ''; 34368 /** 34369 * Determines if the lineHeight attribute has been properly defined. 34370 * 34371 * @param {any} lineHeight The value to check. 34372 * 34373 * @return {boolean} Whether the lineHeight attribute is valid. 34374 */ 34375 34376 function isLineHeightDefined(lineHeight) { 34377 return lineHeight !== undefined && lineHeight !== RESET_VALUE; 34378 } 34379 34380 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/line-height-control/index.js 34381 34382 34383 /** 34384 * WordPress dependencies 34385 */ 34386 34387 34388 34389 /** 34390 * Internal dependencies 34391 */ 34392 34393 34394 34395 const LineHeightControl = _ref => { 34396 let { 34397 value: lineHeight, 34398 onChange, 34399 34400 /** Start opting into the new margin-free styles that will become the default in a future version. */ 34401 __nextHasNoMarginBottom = false, 34402 __unstableInputWidth = '60px' 34403 } = _ref; 34404 const isDefined = isLineHeightDefined(lineHeight); 34405 34406 const adjustNextValue = (nextValue, wasTypedOrPasted) => { 34407 // Set the next value without modification if lineHeight has been defined. 34408 if (isDefined) return nextValue; 34409 /** 34410 * The following logic handles the initial step up/down action 34411 * (from an undefined value state) so that the next values are better suited for 34412 * line-height rendering. For example, the first step up should immediately 34413 * go to 1.6, rather than the normally expected 0.1. 34414 * 34415 * Step up/down actions can be triggered by keydowns of the up/down arrow keys, 34416 * or by clicking the spin buttons. 34417 */ 34418 34419 switch (`$nextValue}`) { 34420 case `$STEP}`: 34421 // Increment by step value. 34422 return BASE_DEFAULT_VALUE + STEP; 34423 34424 case '0': 34425 { 34426 // This means the user explicitly input '0', rather than stepped down 34427 // from an undefined value state. 34428 if (wasTypedOrPasted) return nextValue; // Decrement by step value. 34429 34430 return BASE_DEFAULT_VALUE - STEP; 34431 } 34432 34433 case '': 34434 return BASE_DEFAULT_VALUE; 34435 34436 default: 34437 return nextValue; 34438 } 34439 }; 34440 34441 const stateReducer = (state, action) => { 34442 var _action$payload$event; 34443 34444 // Be careful when changing this — cross-browser behavior of the 34445 // `inputType` field in `input` events are inconsistent. 34446 // For example, Firefox emits an input event with inputType="insertReplacementText" 34447 // on spin button clicks, while other browsers do not even emit an input event. 34448 const wasTypedOrPasted = ['insertText', 'insertFromPaste'].includes((_action$payload$event = action.payload.event.nativeEvent) === null || _action$payload$event === void 0 ? void 0 : _action$payload$event.inputType); 34449 const value = adjustNextValue(state.value, wasTypedOrPasted); 34450 return { ...state, 34451 value 34452 }; 34453 }; 34454 34455 const value = isDefined ? lineHeight : RESET_VALUE; 34456 34457 if (!__nextHasNoMarginBottom) { 34458 external_wp_deprecated_default()('Bottom margin styles for wp.blockEditor.LineHeightControl', { 34459 since: '6.0', 34460 version: '6.4', 34461 hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version' 34462 }); 34463 } 34464 34465 const deprecatedStyles = __nextHasNoMarginBottom ? undefined : { 34466 marginBottom: 24 34467 }; 34468 return (0,external_wp_element_namespaceObject.createElement)("div", { 34469 className: "block-editor-line-height-control", 34470 style: deprecatedStyles 34471 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNumberControl, { 34472 __unstableInputWidth: __unstableInputWidth, 34473 __unstableStateReducer: stateReducer, 34474 onChange: onChange, 34475 label: (0,external_wp_i18n_namespaceObject.__)('Line height'), 34476 placeholder: BASE_DEFAULT_VALUE, 34477 step: STEP, 34478 value: value, 34479 min: 0 34480 })); 34481 }; 34482 /** 34483 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/line-height-control/README.md 34484 */ 34485 34486 34487 /* harmony default export */ var line_height_control = (LineHeightControl); 34488 34489 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/line-height.js 34490 34491 34492 /** 34493 * WordPress dependencies 34494 */ 34495 34496 /** 34497 * Internal dependencies 34498 */ 34499 34500 34501 34502 34503 const LINE_HEIGHT_SUPPORT_KEY = 'typography.lineHeight'; 34504 /** 34505 * Inspector control panel containing the line height related configuration 34506 * 34507 * @param {Object} props 34508 * 34509 * @return {WPElement} Line height edit element. 34510 */ 34511 34512 function LineHeightEdit(props) { 34513 var _style$typography; 34514 34515 const { 34516 attributes: { 34517 style 34518 }, 34519 setAttributes 34520 } = props; 34521 34522 const onChange = newLineHeightValue => { 34523 const newStyle = { ...style, 34524 typography: { ...(style === null || style === void 0 ? void 0 : style.typography), 34525 lineHeight: newLineHeightValue 34526 } 34527 }; 34528 setAttributes({ 34529 style: cleanEmptyObject(newStyle) 34530 }); 34531 }; 34532 34533 return (0,external_wp_element_namespaceObject.createElement)(line_height_control, { 34534 __unstableInputWidth: "100%", 34535 __nextHasNoMarginBottom: true, 34536 value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.lineHeight, 34537 onChange: onChange 34538 }); 34539 } 34540 /** 34541 * Custom hook that checks if line-height settings have been disabled. 34542 * 34543 * @param {string} name The name of the block. 34544 * @return {boolean} Whether setting is disabled. 34545 */ 34546 34547 function useIsLineHeightDisabled() { 34548 let { 34549 name: blockName 34550 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 34551 const isDisabled = !useSetting('typography.lineHeight'); 34552 return !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, LINE_HEIGHT_SUPPORT_KEY) || isDisabled; 34553 } 34554 /** 34555 * Checks if there is a current value set for the line height block support. 34556 * 34557 * @param {Object} props Block props. 34558 * @return {boolean} Whether or not the block has a line height value set. 34559 */ 34560 34561 function hasLineHeightValue(props) { 34562 var _props$attributes$sty, _props$attributes$sty2; 34563 34564 return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.lineHeight); 34565 } 34566 /** 34567 * Resets the line height block support attribute. This can be used when 34568 * disabling the line height support controls for a block via a progressive 34569 * discovery panel. 34570 * 34571 * @param {Object} props Block props. 34572 * @param {Object} props.attributes Block's attributes. 34573 * @param {Object} props.setAttributes Function to set block's attributes. 34574 */ 34575 34576 function resetLineHeight(_ref) { 34577 let { 34578 attributes = {}, 34579 setAttributes 34580 } = _ref; 34581 const { 34582 style 34583 } = attributes; 34584 setAttributes({ 34585 style: cleanEmptyObject({ ...style, 34586 typography: { ...(style === null || style === void 0 ? void 0 : style.typography), 34587 lineHeight: undefined 34588 } 34589 }) 34590 }); 34591 } 34592 34593 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/font-appearance.js 34594 34595 34596 /** 34597 * WordPress dependencies 34598 */ 34599 34600 /** 34601 * Internal dependencies 34602 */ 34603 34604 34605 34606 34607 /** 34608 * Key within block settings' support array indicating support for font style. 34609 */ 34610 34611 const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle'; 34612 /** 34613 * Key within block settings' support array indicating support for font weight. 34614 */ 34615 34616 const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight'; 34617 /** 34618 * Inspector control panel containing the font appearance options. 34619 * 34620 * @param {Object} props Block properties. 34621 * 34622 * @return {WPElement} Font appearance edit element. 34623 */ 34624 34625 function FontAppearanceEdit(props) { 34626 var _style$typography, _style$typography2; 34627 34628 const { 34629 attributes: { 34630 style 34631 }, 34632 setAttributes 34633 } = props; 34634 const hasFontStyles = !useIsFontStyleDisabled(props); 34635 const hasFontWeights = !useIsFontWeightDisabled(props); 34636 34637 const onChange = newStyles => { 34638 setAttributes({ 34639 style: cleanEmptyObject({ ...style, 34640 typography: { ...(style === null || style === void 0 ? void 0 : style.typography), 34641 fontStyle: newStyles.fontStyle, 34642 fontWeight: newStyles.fontWeight 34643 } 34644 }) 34645 }); 34646 }; 34647 34648 const fontStyle = style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontStyle; 34649 const fontWeight = style === null || style === void 0 ? void 0 : (_style$typography2 = style.typography) === null || _style$typography2 === void 0 ? void 0 : _style$typography2.fontWeight; 34650 return (0,external_wp_element_namespaceObject.createElement)(FontAppearanceControl, { 34651 onChange: onChange, 34652 hasFontStyles: hasFontStyles, 34653 hasFontWeights: hasFontWeights, 34654 value: { 34655 fontStyle, 34656 fontWeight 34657 } 34658 }); 34659 } 34660 /** 34661 * Checks if font style support has been disabled either by not opting in for 34662 * support or by failing to provide preset styles. 34663 * 34664 * @param {Object} props Block properties. 34665 * @param {string} props.name Name for the block type. 34666 * 34667 * @return {boolean} Whether font style support has been disabled. 34668 */ 34669 34670 function useIsFontStyleDisabled() { 34671 let { 34672 name: blockName 34673 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 34674 const styleSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, FONT_STYLE_SUPPORT_KEY); 34675 const hasFontStyles = useSetting('typography.fontStyle'); 34676 return !styleSupport || !hasFontStyles; 34677 } 34678 /** 34679 * Checks if font weight support has been disabled either by not opting in for 34680 * support or by failing to provide preset weights. 34681 * 34682 * @param {Object} props Block properties. 34683 * @param {string} props.name Name for the block type. 34684 * 34685 * @return {boolean} Whether font weight support has been disabled. 34686 */ 34687 34688 function useIsFontWeightDisabled() { 34689 let { 34690 name: blockName 34691 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 34692 const weightSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, FONT_WEIGHT_SUPPORT_KEY); 34693 const hasFontWeights = useSetting('typography.fontWeight'); 34694 return !weightSupport || !hasFontWeights; 34695 } 34696 /** 34697 * Checks if font appearance support has been disabled. 34698 * 34699 * @param {Object} props Block properties. 34700 * 34701 * @return {boolean} Whether font appearance support has been disabled. 34702 */ 34703 34704 function useIsFontAppearanceDisabled(props) { 34705 const stylesDisabled = useIsFontStyleDisabled(props); 34706 const weightsDisabled = useIsFontWeightDisabled(props); 34707 return stylesDisabled && weightsDisabled; 34708 } 34709 /** 34710 * Checks if there is either a font style or weight value set within the 34711 * typography styles. 34712 * 34713 * @param {Object} props Block props. 34714 * @return {boolean} Whether or not the block has a font style or weight. 34715 */ 34716 34717 function hasFontAppearanceValue(props) { 34718 var _props$attributes$sty; 34719 34720 const { 34721 fontStyle, 34722 fontWeight 34723 } = ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.typography) || {}; 34724 return !!fontStyle || !!fontWeight; 34725 } 34726 /** 34727 * Resets the font style and weight block support attributes. This can be used 34728 * when disabling the font appearance support controls for a block via a 34729 * progressive discovery panel. 34730 * 34731 * @param {Object} props Block props. 34732 * @param {Object} props.attributes Block's attributes. 34733 * @param {Object} props.setAttributes Function to set block's attributes. 34734 */ 34735 34736 function resetFontAppearance(_ref) { 34737 let { 34738 attributes = {}, 34739 setAttributes 34740 } = _ref; 34741 const { 34742 style 34743 } = attributes; 34744 setAttributes({ 34745 style: cleanEmptyObject({ ...style, 34746 typography: { ...(style === null || style === void 0 ? void 0 : style.typography), 34747 fontStyle: undefined, 34748 fontWeight: undefined 34749 } 34750 }) 34751 }); 34752 } 34753 34754 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-family/index.js 34755 34756 34757 34758 /** 34759 * External dependencies 34760 */ 34761 34762 /** 34763 * WordPress dependencies 34764 */ 34765 34766 34767 34768 /** 34769 * Internal dependencies 34770 */ 34771 34772 34773 function FontFamilyControl(_ref) { 34774 let { 34775 value = '', 34776 onChange, 34777 fontFamilies, 34778 ...props 34779 } = _ref; 34780 const blockLevelFontFamilies = useSetting('typography.fontFamilies'); 34781 34782 if (!fontFamilies) { 34783 fontFamilies = blockLevelFontFamilies; 34784 } 34785 34786 if ((0,external_lodash_namespaceObject.isEmpty)(fontFamilies)) { 34787 return null; 34788 } 34789 34790 const options = [{ 34791 value: '', 34792 label: (0,external_wp_i18n_namespaceObject.__)('Default') 34793 }, ...fontFamilies.map(_ref2 => { 34794 let { 34795 fontFamily, 34796 name 34797 } = _ref2; 34798 return { 34799 value: fontFamily, 34800 label: name || fontFamily 34801 }; 34802 })]; 34803 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, _extends({ 34804 label: (0,external_wp_i18n_namespaceObject.__)('Font family'), 34805 options: options, 34806 value: value, 34807 onChange: onChange, 34808 labelPosition: "top" 34809 }, props)); 34810 } 34811 34812 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/font-family.js 34813 34814 34815 /** 34816 * External dependencies 34817 */ 34818 34819 /** 34820 * WordPress dependencies 34821 */ 34822 34823 34824 34825 34826 /** 34827 * Internal dependencies 34828 */ 34829 34830 34831 34832 34833 34834 const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily'; 34835 /** 34836 * Filters registered block settings, extending attributes to include 34837 * the `fontFamily` attribute. 34838 * 34839 * @param {Object} settings Original block settings 34840 * @return {Object} Filtered block settings 34841 */ 34842 34843 function font_family_addAttributes(settings) { 34844 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, FONT_FAMILY_SUPPORT_KEY)) { 34845 return settings; 34846 } // Allow blocks to specify a default value if needed. 34847 34848 34849 if (!settings.attributes.fontFamily) { 34850 Object.assign(settings.attributes, { 34851 fontFamily: { 34852 type: 'string' 34853 } 34854 }); 34855 } 34856 34857 return settings; 34858 } 34859 /** 34860 * Override props assigned to save component to inject font family. 34861 * 34862 * @param {Object} props Additional props applied to save element 34863 * @param {Object} blockType Block type 34864 * @param {Object} attributes Block attributes 34865 * @return {Object} Filtered props applied to save element 34866 */ 34867 34868 34869 function font_family_addSaveProps(props, blockType, attributes) { 34870 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, FONT_FAMILY_SUPPORT_KEY)) { 34871 return props; 34872 } 34873 34874 if (shouldSkipSerialization(blockType, TYPOGRAPHY_SUPPORT_KEY, 'fontFamily')) { 34875 return props; 34876 } 34877 34878 if (!(attributes !== null && attributes !== void 0 && attributes.fontFamily)) { 34879 return props; 34880 } // Use TokenList to dedupe classes. 34881 34882 34883 const classes = new (external_wp_tokenList_default())(props.className); 34884 classes.add(`has-${(0,external_lodash_namespaceObject.kebabCase)(attributes === null || attributes === void 0 ? void 0 : attributes.fontFamily)}-font-family`); 34885 const newClassName = classes.value; 34886 props.className = newClassName ? newClassName : undefined; 34887 return props; 34888 } 34889 /** 34890 * Filters registered block settings to expand the block edit wrapper 34891 * by applying the desired styles and classnames. 34892 * 34893 * @param {Object} settings Original block settings. 34894 * 34895 * @return {Object} Filtered block settings. 34896 */ 34897 34898 34899 function font_family_addEditProps(settings) { 34900 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, FONT_FAMILY_SUPPORT_KEY)) { 34901 return settings; 34902 } 34903 34904 const existingGetEditWrapperProps = settings.getEditWrapperProps; 34905 34906 settings.getEditWrapperProps = attributes => { 34907 let props = {}; 34908 34909 if (existingGetEditWrapperProps) { 34910 props = existingGetEditWrapperProps(attributes); 34911 } 34912 34913 return font_family_addSaveProps(props, settings, attributes); 34914 }; 34915 34916 return settings; 34917 } 34918 34919 function FontFamilyEdit(_ref) { 34920 var _find; 34921 34922 let { 34923 setAttributes, 34924 attributes: { 34925 fontFamily 34926 } 34927 } = _ref; 34928 const fontFamilies = useSetting('typography.fontFamilies'); 34929 const value = (_find = (0,external_lodash_namespaceObject.find)(fontFamilies, _ref2 => { 34930 let { 34931 slug 34932 } = _ref2; 34933 return fontFamily === slug; 34934 })) === null || _find === void 0 ? void 0 : _find.fontFamily; 34935 34936 function onChange(newValue) { 34937 const predefinedFontFamily = (0,external_lodash_namespaceObject.find)(fontFamilies, _ref3 => { 34938 let { 34939 fontFamily: f 34940 } = _ref3; 34941 return f === newValue; 34942 }); 34943 setAttributes({ 34944 fontFamily: predefinedFontFamily === null || predefinedFontFamily === void 0 ? void 0 : predefinedFontFamily.slug 34945 }); 34946 } 34947 34948 return (0,external_wp_element_namespaceObject.createElement)(FontFamilyControl, { 34949 className: "block-editor-hooks-font-family-control", 34950 fontFamilies: fontFamilies, 34951 value: value, 34952 onChange: onChange 34953 }); 34954 } 34955 /** 34956 * Custom hook that checks if font-family functionality is disabled. 34957 * 34958 * @param {string} name The name of the block. 34959 * @return {boolean} Whether setting is disabled. 34960 */ 34961 34962 function useIsFontFamilyDisabled(_ref4) { 34963 let { 34964 name 34965 } = _ref4; 34966 const fontFamilies = useSetting('typography.fontFamilies'); 34967 return !fontFamilies || fontFamilies.length === 0 || !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(name, FONT_FAMILY_SUPPORT_KEY); 34968 } 34969 /** 34970 * Checks if there is a current value set for the font family block support. 34971 * 34972 * @param {Object} props Block props. 34973 * @return {boolean} Whether or not the block has a font family value set. 34974 */ 34975 34976 function hasFontFamilyValue(props) { 34977 return !!props.attributes.fontFamily; 34978 } 34979 /** 34980 * Resets the font family block support attribute. This can be used when 34981 * disabling the font family support controls for a block via a progressive 34982 * discovery panel. 34983 * 34984 * @param {Object} props Block props. 34985 * @param {Object} props.setAttributes Function to set block's attributes. 34986 */ 34987 34988 function resetFontFamily(_ref5) { 34989 let { 34990 setAttributes 34991 } = _ref5; 34992 setAttributes({ 34993 fontFamily: undefined 34994 }); 34995 } 34996 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/fontFamily/addAttribute', font_family_addAttributes); 34997 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/fontFamily/addSaveProps', font_family_addSaveProps); 34998 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/fontFamily/addEditProps', font_family_addEditProps); 34999 35000 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/utils.js 35001 /** 35002 * External dependencies 35003 */ 35004 35005 /** 35006 * Returns the font size object based on an array of named font sizes and the namedFontSize and customFontSize values. 35007 * If namedFontSize is undefined or not found in fontSizes an object with just the size value based on customFontSize is returned. 35008 * 35009 * @param {Array} fontSizes Array of font size objects containing at least the "name" and "size" values as properties. 35010 * @param {?string} fontSizeAttribute Content of the font size attribute (slug). 35011 * @param {?number} customFontSizeAttribute Contents of the custom font size attribute (value). 35012 * 35013 * @return {?Object} If fontSizeAttribute is set and an equal slug is found in fontSizes it returns the font size object for that slug. 35014 * Otherwise, an object with just the size value based on customFontSize is returned. 35015 */ 35016 35017 const getFontSize = (fontSizes, fontSizeAttribute, customFontSizeAttribute) => { 35018 if (fontSizeAttribute) { 35019 const fontSizeObject = (0,external_lodash_namespaceObject.find)(fontSizes, { 35020 slug: fontSizeAttribute 35021 }); 35022 35023 if (fontSizeObject) { 35024 return fontSizeObject; 35025 } 35026 } 35027 35028 return { 35029 size: customFontSizeAttribute 35030 }; 35031 }; 35032 /** 35033 * Returns the corresponding font size object for a given value. 35034 * 35035 * @param {Array} fontSizes Array of font size objects. 35036 * @param {number} value Font size value. 35037 * 35038 * @return {Object} Font size object. 35039 */ 35040 35041 function getFontSizeObjectByValue(fontSizes, value) { 35042 const fontSizeObject = (0,external_lodash_namespaceObject.find)(fontSizes, { 35043 size: value 35044 }); 35045 35046 if (fontSizeObject) { 35047 return fontSizeObject; 35048 } 35049 35050 return { 35051 size: value 35052 }; 35053 } 35054 /** 35055 * Returns a class based on fontSizeName. 35056 * 35057 * @param {string} fontSizeSlug Slug of the fontSize. 35058 * 35059 * @return {string} String with the class corresponding to the fontSize passed. 35060 * The class is generated by appending 'has-' followed by fontSizeSlug in kebabCase and ending with '-font-size'. 35061 */ 35062 35063 function getFontSizeClass(fontSizeSlug) { 35064 if (!fontSizeSlug) { 35065 return; 35066 } 35067 35068 return `has-${(0,external_lodash_namespaceObject.kebabCase)(fontSizeSlug)}-font-size`; 35069 } 35070 35071 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/font-size-picker.js 35072 35073 35074 35075 /** 35076 * WordPress dependencies 35077 */ 35078 35079 /** 35080 * Internal dependencies 35081 */ 35082 35083 35084 35085 function FontSizePicker(props) { 35086 const fontSizes = useSetting('typography.fontSizes'); 35087 const disableCustomFontSizes = !useSetting('typography.customFontSize'); 35088 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FontSizePicker, _extends({}, props, { 35089 fontSizes: fontSizes, 35090 disableCustomFontSizes: disableCustomFontSizes 35091 })); 35092 } 35093 /** 35094 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/font-sizes/README.md 35095 */ 35096 35097 35098 /* harmony default export */ var font_size_picker = (FontSizePicker); 35099 35100 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/font-size.js 35101 35102 35103 /** 35104 * WordPress dependencies 35105 */ 35106 35107 35108 35109 35110 /** 35111 * Internal dependencies 35112 */ 35113 35114 35115 35116 35117 35118 const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize'; 35119 /** 35120 * Filters registered block settings, extending attributes to include 35121 * `fontSize` and `fontWeight` attributes. 35122 * 35123 * @param {Object} settings Original block settings. 35124 * 35125 * @return {Object} Filtered block settings. 35126 */ 35127 35128 function font_size_addAttributes(settings) { 35129 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, FONT_SIZE_SUPPORT_KEY)) { 35130 return settings; 35131 } // Allow blocks to specify a default value if needed. 35132 35133 35134 if (!settings.attributes.fontSize) { 35135 Object.assign(settings.attributes, { 35136 fontSize: { 35137 type: 'string' 35138 } 35139 }); 35140 } 35141 35142 return settings; 35143 } 35144 /** 35145 * Override props assigned to save component to inject font size. 35146 * 35147 * @param {Object} props Additional props applied to save element. 35148 * @param {Object} blockType Block type. 35149 * @param {Object} attributes Block attributes. 35150 * 35151 * @return {Object} Filtered props applied to save element. 35152 */ 35153 35154 35155 function font_size_addSaveProps(props, blockType, attributes) { 35156 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, FONT_SIZE_SUPPORT_KEY)) { 35157 return props; 35158 } 35159 35160 if (shouldSkipSerialization(blockType, TYPOGRAPHY_SUPPORT_KEY, 'fontSize')) { 35161 return props; 35162 } // Use TokenList to dedupe classes. 35163 35164 35165 const classes = new (external_wp_tokenList_default())(props.className); 35166 classes.add(getFontSizeClass(attributes.fontSize)); 35167 const newClassName = classes.value; 35168 props.className = newClassName ? newClassName : undefined; 35169 return props; 35170 } 35171 /** 35172 * Filters registered block settings to expand the block edit wrapper 35173 * by applying the desired styles and classnames. 35174 * 35175 * @param {Object} settings Original block settings. 35176 * 35177 * @return {Object} Filtered block settings. 35178 */ 35179 35180 35181 function font_size_addEditProps(settings) { 35182 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, FONT_SIZE_SUPPORT_KEY)) { 35183 return settings; 35184 } 35185 35186 const existingGetEditWrapperProps = settings.getEditWrapperProps; 35187 35188 settings.getEditWrapperProps = attributes => { 35189 let props = {}; 35190 35191 if (existingGetEditWrapperProps) { 35192 props = existingGetEditWrapperProps(attributes); 35193 } 35194 35195 return font_size_addSaveProps(props, settings, attributes); 35196 }; 35197 35198 return settings; 35199 } 35200 /** 35201 * Inspector control panel containing the font size related configuration 35202 * 35203 * @param {Object} props 35204 * 35205 * @return {WPElement} Font size edit element. 35206 */ 35207 35208 35209 function FontSizeEdit(props) { 35210 var _style$typography, _style$typography2; 35211 35212 const { 35213 attributes: { 35214 fontSize, 35215 style 35216 }, 35217 setAttributes 35218 } = props; 35219 const fontSizes = useSetting('typography.fontSizes'); 35220 35221 const onChange = value => { 35222 const fontSizeSlug = getFontSizeObjectByValue(fontSizes, value).slug; 35223 setAttributes({ 35224 style: cleanEmptyObject({ ...style, 35225 typography: { ...(style === null || style === void 0 ? void 0 : style.typography), 35226 fontSize: fontSizeSlug ? undefined : value 35227 } 35228 }), 35229 fontSize: fontSizeSlug 35230 }); 35231 }; 35232 35233 const fontSizeObject = getFontSize(fontSizes, fontSize, style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontSize); 35234 const fontSizeValue = (fontSizeObject === null || fontSizeObject === void 0 ? void 0 : fontSizeObject.size) || (style === null || style === void 0 ? void 0 : (_style$typography2 = style.typography) === null || _style$typography2 === void 0 ? void 0 : _style$typography2.fontSize) || fontSize; 35235 return (0,external_wp_element_namespaceObject.createElement)(font_size_picker, { 35236 onChange: onChange, 35237 value: fontSizeValue, 35238 withReset: false 35239 }); 35240 } 35241 /** 35242 * Checks if there is a current value set for the font size block support. 35243 * 35244 * @param {Object} props Block props. 35245 * @return {boolean} Whether or not the block has a font size value set. 35246 */ 35247 35248 function hasFontSizeValue(props) { 35249 var _style$typography3; 35250 35251 const { 35252 fontSize, 35253 style 35254 } = props.attributes; 35255 return !!fontSize || !!(style !== null && style !== void 0 && (_style$typography3 = style.typography) !== null && _style$typography3 !== void 0 && _style$typography3.fontSize); 35256 } 35257 /** 35258 * Resets the font size block support attribute. This can be used when 35259 * disabling the font size support controls for a block via a progressive 35260 * discovery panel. 35261 * 35262 * @param {Object} props Block props. 35263 * @param {Object} props.attributes Block's attributes. 35264 * @param {Object} props.setAttributes Function to set block's attributes. 35265 */ 35266 35267 function resetFontSize(_ref) { 35268 let { 35269 attributes = {}, 35270 setAttributes 35271 } = _ref; 35272 const { 35273 style 35274 } = attributes; 35275 setAttributes({ 35276 fontSize: undefined, 35277 style: cleanEmptyObject({ ...style, 35278 typography: { ...(style === null || style === void 0 ? void 0 : style.typography), 35279 fontSize: undefined 35280 } 35281 }) 35282 }); 35283 } 35284 /** 35285 * Custom hook that checks if font-size settings have been disabled. 35286 * 35287 * @param {string} name The name of the block. 35288 * @return {boolean} Whether setting is disabled. 35289 */ 35290 35291 function useIsFontSizeDisabled() { 35292 let { 35293 name: blockName 35294 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 35295 const fontSizes = useSetting('typography.fontSizes'); 35296 const hasFontSizes = !!(fontSizes !== null && fontSizes !== void 0 && fontSizes.length); 35297 return !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, FONT_SIZE_SUPPORT_KEY) || !hasFontSizes; 35298 } 35299 /** 35300 * Add inline styles for font sizes. 35301 * Ideally, this is not needed and themes load the font-size classes on the 35302 * editor. 35303 * 35304 * @param {Function} BlockListBlock Original component. 35305 * 35306 * @return {Function} Wrapped component. 35307 */ 35308 35309 const withFontSizeInlineStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => { 35310 var _style$typography4, _style$typography5; 35311 35312 const fontSizes = useSetting('typography.fontSizes'); 35313 const { 35314 name: blockName, 35315 attributes: { 35316 fontSize, 35317 style 35318 }, 35319 wrapperProps 35320 } = props; // Only add inline styles if the block supports font sizes, 35321 // doesn't skip serialization of font sizes, 35322 // doesn't already have an inline font size, 35323 // and does have a class to extract the font size from. 35324 35325 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, FONT_SIZE_SUPPORT_KEY) || shouldSkipSerialization(blockName, TYPOGRAPHY_SUPPORT_KEY, 'fontSize') || !fontSize || style !== null && style !== void 0 && (_style$typography4 = style.typography) !== null && _style$typography4 !== void 0 && _style$typography4.fontSize) { 35326 return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props); 35327 } 35328 35329 const fontSizeValue = getFontSize(fontSizes, fontSize, style === null || style === void 0 ? void 0 : (_style$typography5 = style.typography) === null || _style$typography5 === void 0 ? void 0 : _style$typography5.fontSize).size; 35330 const newProps = { ...props, 35331 wrapperProps: { ...wrapperProps, 35332 style: { 35333 fontSize: fontSizeValue, 35334 ...(wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.style) 35335 } 35336 } 35337 }; 35338 return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, newProps); 35339 }, 'withFontSizeInlineStyles'); 35340 const font_size_MIGRATION_PATHS = { 35341 fontSize: [['fontSize'], ['style', 'typography', 'fontSize']] 35342 }; 35343 function font_size_addTransforms(result, source, index, results) { 35344 const destinationBlockType = result.name; 35345 const activeSupports = { 35346 fontSize: (0,external_wp_blocks_namespaceObject.hasBlockSupport)(destinationBlockType, FONT_SIZE_SUPPORT_KEY) 35347 }; 35348 return transformStyles(activeSupports, font_size_MIGRATION_PATHS, result, source, index, results); 35349 } 35350 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/font/addAttribute', font_size_addAttributes); 35351 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/font/addSaveProps', font_size_addSaveProps); 35352 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/font/addEditProps', font_size_addEditProps); 35353 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/font-size/with-font-size-inline-styles', withFontSizeInlineStyles); 35354 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.switchToBlockType.transformedBlock', 'core/font-size/addTransforms', font_size_addTransforms); 35355 35356 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-underline.js 35357 35358 35359 /** 35360 * WordPress dependencies 35361 */ 35362 35363 const formatUnderline = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 35364 xmlns: "http://www.w3.org/2000/svg", 35365 viewBox: "0 0 24 24" 35366 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 35367 d: "M7 18v1h10v-1H7zm5-2c1.5 0 2.6-.4 3.4-1.2.8-.8 1.1-2 1.1-3.5V5H15v5.8c0 1.2-.2 2.1-.6 2.8-.4.7-1.2 1-2.4 1s-2-.3-2.4-1c-.4-.7-.6-1.6-.6-2.8V5H7.5v6.2c0 1.5.4 2.7 1.1 3.5.8.9 1.9 1.3 3.4 1.3z" 35368 })); 35369 /* harmony default export */ var format_underline = (formatUnderline); 35370 35371 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-strikethrough.js 35372 35373 35374 /** 35375 * WordPress dependencies 35376 */ 35377 35378 const formatStrikethrough = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 35379 xmlns: "http://www.w3.org/2000/svg", 35380 viewBox: "0 0 24 24" 35381 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 35382 d: "M9.1 9v-.5c0-.6.2-1.1.7-1.4.5-.3 1.2-.5 2-.5.7 0 1.4.1 2.1.3.7.2 1.4.5 2.1.9l.2-1.9c-.6-.3-1.2-.5-1.9-.7-.8-.1-1.6-.2-2.4-.2-1.5 0-2.7.3-3.6 1-.8.7-1.2 1.5-1.2 2.6V9h2zM20 12H4v1h8.3c.3.1.6.2.8.3.5.2.9.5 1.1.8.3.3.4.7.4 1.2 0 .7-.2 1.1-.8 1.5-.5.3-1.2.5-2.1.5-.8 0-1.6-.1-2.4-.3-.8-.2-1.5-.5-2.2-.8L7 18.1c.5.2 1.2.4 2 .6.8.2 1.6.3 2.4.3 1.7 0 3-.3 3.9-1 .9-.7 1.3-1.6 1.3-2.8 0-.9-.2-1.7-.7-2.2H20v-1z" 35383 })); 35384 /* harmony default export */ var format_strikethrough = (formatStrikethrough); 35385 35386 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/text-decoration-control/index.js 35387 35388 35389 /** 35390 * WordPress dependencies 35391 */ 35392 35393 35394 35395 const TEXT_DECORATIONS = [{ 35396 name: (0,external_wp_i18n_namespaceObject.__)('Underline'), 35397 value: 'underline', 35398 icon: format_underline 35399 }, { 35400 name: (0,external_wp_i18n_namespaceObject.__)('Strikethrough'), 35401 value: 'line-through', 35402 icon: format_strikethrough 35403 }]; 35404 /** 35405 * Control to facilitate text decoration selections. 35406 * 35407 * @param {Object} props Component props. 35408 * @param {string} props.value Currently selected text decoration. 35409 * @param {Function} props.onChange Handles change in text decoration selection. 35410 * 35411 * @return {WPElement} Text decoration control. 35412 */ 35413 35414 function TextDecorationControl(_ref) { 35415 let { 35416 value, 35417 onChange 35418 } = _ref; 35419 return (0,external_wp_element_namespaceObject.createElement)("fieldset", { 35420 className: "block-editor-text-decoration-control" 35421 }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_i18n_namespaceObject.__)('Decoration')), (0,external_wp_element_namespaceObject.createElement)("div", { 35422 className: "block-editor-text-decoration-control__buttons" 35423 }, TEXT_DECORATIONS.map(textDecoration => { 35424 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 35425 key: textDecoration.value, 35426 icon: textDecoration.icon, 35427 isSmall: true, 35428 isPressed: textDecoration.value === value, 35429 onClick: () => onChange(textDecoration.value === value ? undefined : textDecoration.value), 35430 "aria-label": textDecoration.name 35431 }); 35432 }))); 35433 } 35434 35435 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/text-decoration.js 35436 35437 35438 /** 35439 * WordPress dependencies 35440 */ 35441 35442 /** 35443 * Internal dependencies 35444 */ 35445 35446 35447 35448 35449 /** 35450 * Key within block settings' supports array indicating support for text 35451 * decorations e.g. settings found in `block.json`. 35452 */ 35453 35454 const TEXT_DECORATION_SUPPORT_KEY = 'typography.__experimentalTextDecoration'; 35455 /** 35456 * Inspector control panel containing the text decoration options. 35457 * 35458 * @param {Object} props Block properties. 35459 * 35460 * @return {WPElement} Text decoration edit element. 35461 */ 35462 35463 function TextDecorationEdit(props) { 35464 var _style$typography; 35465 35466 const { 35467 attributes: { 35468 style 35469 }, 35470 setAttributes 35471 } = props; 35472 35473 function onChange(newDecoration) { 35474 setAttributes({ 35475 style: cleanEmptyObject({ ...style, 35476 typography: { ...(style === null || style === void 0 ? void 0 : style.typography), 35477 textDecoration: newDecoration 35478 } 35479 }) 35480 }); 35481 } 35482 35483 return (0,external_wp_element_namespaceObject.createElement)(TextDecorationControl, { 35484 value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textDecoration, 35485 onChange: onChange 35486 }); 35487 } 35488 /** 35489 * Checks if text-decoration settings have been disabled. 35490 * 35491 * @param {string} name Name of the block. 35492 * 35493 * @return {boolean} Whether or not the setting is disabled. 35494 */ 35495 35496 function useIsTextDecorationDisabled() { 35497 let { 35498 name: blockName 35499 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 35500 const notSupported = !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, TEXT_DECORATION_SUPPORT_KEY); 35501 const hasTextDecoration = useSetting('typography.textDecoration'); 35502 return notSupported || !hasTextDecoration; 35503 } 35504 /** 35505 * Checks if there is a current value set for the text decoration block support. 35506 * 35507 * @param {Object} props Block props. 35508 * @return {boolean} Whether or not the block has a text decoration set. 35509 */ 35510 35511 function hasTextDecorationValue(props) { 35512 var _props$attributes$sty, _props$attributes$sty2; 35513 35514 return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.textDecoration); 35515 } 35516 /** 35517 * Resets the text decoration block support attribute. This can be used when 35518 * disabling the text decoration support controls for a block via a progressive 35519 * discovery panel. 35520 * 35521 * @param {Object} props Block props. 35522 * @param {Object} props.attributes Block's attributes. 35523 * @param {Object} props.setAttributes Function to set block's attributes. 35524 */ 35525 35526 function resetTextDecoration(_ref) { 35527 let { 35528 attributes = {}, 35529 setAttributes 35530 } = _ref; 35531 const { 35532 style 35533 } = attributes; 35534 setAttributes({ 35535 style: cleanEmptyObject({ ...style, 35536 typography: { ...(style === null || style === void 0 ? void 0 : style.typography), 35537 textDecoration: undefined 35538 } 35539 }) 35540 }); 35541 } 35542 35543 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-uppercase.js 35544 35545 35546 /** 35547 * WordPress dependencies 35548 */ 35549 35550 const formatUppercase = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 35551 xmlns: "http://www.w3.org/2000/svg", 35552 viewBox: "0 0 24 24" 35553 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 35554 d: "M6.1 6.8L2.1 18h1.6l1.1-3h4.3l1.1 3h1.6l-4-11.2H6.1zm-.8 6.8L7 8.9l1.7 4.7H5.3zm15.1-.7c-.4-.5-.9-.8-1.6-1 .4-.2.7-.5.8-.9.2-.4.3-.9.3-1.4 0-.9-.3-1.6-.8-2-.6-.5-1.3-.7-2.4-.7h-3.5V18h4.2c1.1 0 2-.3 2.6-.8.6-.6 1-1.4 1-2.4-.1-.8-.3-1.4-.6-1.9zm-5.7-4.7h1.8c.6 0 1.1.1 1.4.4.3.2.5.7.5 1.3 0 .6-.2 1.1-.5 1.3-.3.2-.8.4-1.4.4h-1.8V8.2zm4 8c-.4.3-.9.5-1.5.5h-2.6v-3.8h2.6c1.4 0 2 .6 2 1.9.1.6-.1 1-.5 1.4z" 35555 })); 35556 /* harmony default export */ var format_uppercase = (formatUppercase); 35557 35558 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-lowercase.js 35559 35560 35561 /** 35562 * WordPress dependencies 35563 */ 35564 35565 const formatLowercase = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 35566 xmlns: "http://www.w3.org/2000/svg", 35567 viewBox: "0 0 24 24" 35568 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 35569 d: "M11 16.8c-.1-.1-.2-.3-.3-.5v-2.6c0-.9-.1-1.7-.3-2.2-.2-.5-.5-.9-.9-1.2-.4-.2-.9-.3-1.6-.3-.5 0-1 .1-1.5.2s-.9.3-1.2.6l.2 1.2c.4-.3.7-.4 1.1-.5.3-.1.7-.2 1-.2.6 0 1 .1 1.3.4.3.2.4.7.4 1.4-1.2 0-2.3.2-3.3.7s-1.4 1.1-1.4 2.1c0 .7.2 1.2.7 1.6.4.4 1 .6 1.8.6.9 0 1.7-.4 2.4-1.2.1.3.2.5.4.7.1.2.3.3.6.4.3.1.6.1 1.1.1h.1l.2-1.2h-.1c-.4.1-.6 0-.7-.1zM9.2 16c-.2.3-.5.6-.9.8-.3.1-.7.2-1.1.2-.4 0-.7-.1-.9-.3-.2-.2-.3-.5-.3-.9 0-.6.2-1 .7-1.3.5-.3 1.3-.4 2.5-.5v2zm10.6-3.9c-.3-.6-.7-1.1-1.2-1.5-.6-.4-1.2-.6-1.9-.6-.5 0-.9.1-1.4.3-.4.2-.8.5-1.1.8V6h-1.4v12h1.3l.2-1c.2.4.6.6 1 .8.4.2.9.3 1.4.3.7 0 1.2-.2 1.8-.5.5-.4 1-.9 1.3-1.5.3-.6.5-1.3.5-2.1-.1-.6-.2-1.3-.5-1.9zm-1.7 4c-.4.5-.9.8-1.6.8s-1.2-.2-1.7-.7c-.4-.5-.7-1.2-.7-2.1 0-.9.2-1.6.7-2.1.4-.5 1-.7 1.7-.7s1.2.3 1.6.8c.4.5.6 1.2.6 2s-.2 1.4-.6 2z" 35570 })); 35571 /* harmony default export */ var format_lowercase = (formatLowercase); 35572 35573 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-capitalize.js 35574 35575 35576 /** 35577 * WordPress dependencies 35578 */ 35579 35580 const formatCapitalize = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 35581 xmlns: "http://www.w3.org/2000/svg", 35582 viewBox: "0 0 24 24" 35583 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 35584 d: "M7.1 6.8L3.1 18h1.6l1.1-3h4.3l1.1 3h1.6l-4-11.2H7.1zm-.8 6.8L8 8.9l1.7 4.7H6.3zm14.5-1.5c-.3-.6-.7-1.1-1.2-1.5-.6-.4-1.2-.6-1.9-.6-.5 0-.9.1-1.4.3-.4.2-.8.5-1.1.8V6h-1.4v12h1.3l.2-1c.2.4.6.6 1 .8.4.2.9.3 1.4.3.7 0 1.2-.2 1.8-.5.5-.4 1-.9 1.3-1.5.3-.6.5-1.3.5-2.1-.1-.6-.2-1.3-.5-1.9zm-1.7 4c-.4.5-.9.8-1.6.8s-1.2-.2-1.7-.7c-.4-.5-.7-1.2-.7-2.1 0-.9.2-1.6.7-2.1.4-.5 1-.7 1.7-.7s1.2.3 1.6.8c.4.5.6 1.2.6 2 .1.8-.2 1.4-.6 2z" 35585 })); 35586 /* harmony default export */ var format_capitalize = (formatCapitalize); 35587 35588 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/text-transform-control/index.js 35589 35590 35591 /** 35592 * WordPress dependencies 35593 */ 35594 35595 35596 35597 const TEXT_TRANSFORMS = [{ 35598 name: (0,external_wp_i18n_namespaceObject.__)('Uppercase'), 35599 value: 'uppercase', 35600 icon: format_uppercase 35601 }, { 35602 name: (0,external_wp_i18n_namespaceObject.__)('Lowercase'), 35603 value: 'lowercase', 35604 icon: format_lowercase 35605 }, { 35606 name: (0,external_wp_i18n_namespaceObject.__)('Capitalize'), 35607 value: 'capitalize', 35608 icon: format_capitalize 35609 }]; 35610 /** 35611 * Control to facilitate text transform selections. 35612 * 35613 * @param {Object} props Component props. 35614 * @param {string} props.value Currently selected text transform. 35615 * @param {Function} props.onChange Handles change in text transform selection. 35616 * 35617 * @return {WPElement} Text transform control. 35618 */ 35619 35620 function TextTransformControl(_ref) { 35621 let { 35622 value, 35623 onChange 35624 } = _ref; 35625 return (0,external_wp_element_namespaceObject.createElement)("fieldset", { 35626 className: "block-editor-text-transform-control" 35627 }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_i18n_namespaceObject.__)('Letter case')), (0,external_wp_element_namespaceObject.createElement)("div", { 35628 className: "block-editor-text-transform-control__buttons" 35629 }, TEXT_TRANSFORMS.map(textTransform => { 35630 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 35631 key: textTransform.value, 35632 icon: textTransform.icon, 35633 isSmall: true, 35634 isPressed: value === textTransform.value, 35635 "aria-label": textTransform.name, 35636 onClick: () => onChange(value === textTransform.value ? undefined : textTransform.value) 35637 }); 35638 }))); 35639 } 35640 35641 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/text-transform.js 35642 35643 35644 /** 35645 * WordPress dependencies 35646 */ 35647 35648 /** 35649 * Internal dependencies 35650 */ 35651 35652 35653 35654 35655 /** 35656 * Key within block settings' supports array indicating support for text 35657 * transforms e.g. settings found in `block.json`. 35658 */ 35659 35660 const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform'; 35661 /** 35662 * Inspector control panel containing the text transform options. 35663 * 35664 * @param {Object} props Block properties. 35665 * 35666 * @return {WPElement} Text transform edit element. 35667 */ 35668 35669 function TextTransformEdit(props) { 35670 var _style$typography; 35671 35672 const { 35673 attributes: { 35674 style 35675 }, 35676 setAttributes 35677 } = props; 35678 35679 function onChange(newTransform) { 35680 setAttributes({ 35681 style: cleanEmptyObject({ ...style, 35682 typography: { ...(style === null || style === void 0 ? void 0 : style.typography), 35683 textTransform: newTransform 35684 } 35685 }) 35686 }); 35687 } 35688 35689 return (0,external_wp_element_namespaceObject.createElement)(TextTransformControl, { 35690 value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textTransform, 35691 onChange: onChange 35692 }); 35693 } 35694 /** 35695 * Checks if text-transform settings have been disabled. 35696 * 35697 * @param {string} name Name of the block. 35698 * 35699 * @return {boolean} Whether or not the setting is disabled. 35700 */ 35701 35702 function useIsTextTransformDisabled() { 35703 let { 35704 name: blockName 35705 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 35706 const notSupported = !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, TEXT_TRANSFORM_SUPPORT_KEY); 35707 const hasTextTransforms = useSetting('typography.textTransform'); 35708 return notSupported || !hasTextTransforms; 35709 } 35710 /** 35711 * Checks if there is a current value set for the text transform block support. 35712 * 35713 * @param {Object} props Block props. 35714 * @return {boolean} Whether or not the block has a text transform set. 35715 */ 35716 35717 function hasTextTransformValue(props) { 35718 var _props$attributes$sty, _props$attributes$sty2; 35719 35720 return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.textTransform); 35721 } 35722 /** 35723 * Resets the text transform block support attribute. This can be used when 35724 * disabling the text transform support controls for a block via a progressive 35725 * discovery panel. 35726 * 35727 * @param {Object} props Block props. 35728 * @param {Object} props.attributes Block's attributes. 35729 * @param {Object} props.setAttributes Function to set block's attributes. 35730 */ 35731 35732 function resetTextTransform(_ref) { 35733 let { 35734 attributes = {}, 35735 setAttributes 35736 } = _ref; 35737 const { 35738 style 35739 } = attributes; 35740 setAttributes({ 35741 style: cleanEmptyObject({ ...style, 35742 typography: { ...(style === null || style === void 0 ? void 0 : style.typography), 35743 textTransform: undefined 35744 } 35745 }) 35746 }); 35747 } 35748 35749 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/letter-spacing-control/index.js 35750 35751 35752 /** 35753 * WordPress dependencies 35754 */ 35755 35756 35757 /** 35758 * Internal dependencies 35759 */ 35760 35761 35762 /** 35763 * Control for letter-spacing. 35764 * 35765 * @param {Object} props Component props. 35766 * @param {string} props.value Currently selected letter-spacing. 35767 * @param {Function} props.onChange Handles change in letter-spacing selection. 35768 * @param {string|number|undefined} props.__unstableInputWidth Input width to pass through to inner UnitControl. Should be a valid CSS value. 35769 * 35770 * @return {WPElement} Letter-spacing control. 35771 */ 35772 35773 function LetterSpacingControl(_ref) { 35774 let { 35775 value, 35776 onChange, 35777 __unstableInputWidth = '60px' 35778 } = _ref; 35779 const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({ 35780 availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem'], 35781 defaultValues: { 35782 px: 2, 35783 em: 0.2, 35784 rem: 0.2 35785 } 35786 }); 35787 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, { 35788 label: (0,external_wp_i18n_namespaceObject.__)('Letter spacing'), 35789 value: value, 35790 __unstableInputWidth: __unstableInputWidth, 35791 units: units, 35792 onChange: onChange 35793 }); 35794 } 35795 35796 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/letter-spacing.js 35797 35798 35799 /** 35800 * WordPress dependencies 35801 */ 35802 35803 /** 35804 * Internal dependencies 35805 */ 35806 35807 35808 35809 35810 /** 35811 * Key within block settings' supports array indicating support for letter-spacing 35812 * e.g. settings found in `block.json`. 35813 */ 35814 35815 const LETTER_SPACING_SUPPORT_KEY = 'typography.__experimentalLetterSpacing'; 35816 /** 35817 * Inspector control panel containing the letter-spacing options. 35818 * 35819 * @param {Object} props Block properties. 35820 * @return {WPElement} Letter-spacing edit element. 35821 */ 35822 35823 function LetterSpacingEdit(props) { 35824 var _style$typography; 35825 35826 const { 35827 attributes: { 35828 style 35829 }, 35830 setAttributes 35831 } = props; 35832 35833 function onChange(newSpacing) { 35834 setAttributes({ 35835 style: cleanEmptyObject({ ...style, 35836 typography: { ...(style === null || style === void 0 ? void 0 : style.typography), 35837 letterSpacing: newSpacing 35838 } 35839 }) 35840 }); 35841 } 35842 35843 return (0,external_wp_element_namespaceObject.createElement)(LetterSpacingControl, { 35844 value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.letterSpacing, 35845 onChange: onChange, 35846 __unstableInputWidth: '100%' 35847 }); 35848 } 35849 /** 35850 * Checks if letter-spacing settings have been disabled. 35851 * 35852 * @param {string} name Name of the block. 35853 * @return {boolean} Whether or not the setting is disabled. 35854 */ 35855 35856 function useIsLetterSpacingDisabled() { 35857 let { 35858 name: blockName 35859 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 35860 const notSupported = !(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, LETTER_SPACING_SUPPORT_KEY); 35861 const hasLetterSpacing = useSetting('typography.letterSpacing'); 35862 return notSupported || !hasLetterSpacing; 35863 } 35864 /** 35865 * Checks if there is a current value set for the letter spacing block support. 35866 * 35867 * @param {Object} props Block props. 35868 * @return {boolean} Whether or not the block has a letter spacing set. 35869 */ 35870 35871 function hasLetterSpacingValue(props) { 35872 var _props$attributes$sty, _props$attributes$sty2; 35873 35874 return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.letterSpacing); 35875 } 35876 /** 35877 * Resets the letter spacing block support attribute. This can be used when 35878 * disabling the letter spacing support controls for a block via a progressive 35879 * discovery panel. 35880 * 35881 * @param {Object} props Block props. 35882 * @param {Object} props.attributes Block's attributes. 35883 * @param {Object} props.setAttributes Function to set block's attributes. 35884 */ 35885 35886 function resetLetterSpacing(_ref) { 35887 let { 35888 attributes = {}, 35889 setAttributes 35890 } = _ref; 35891 const { 35892 style 35893 } = attributes; 35894 setAttributes({ 35895 style: cleanEmptyObject({ ...style, 35896 typography: { ...(style === null || style === void 0 ? void 0 : style.typography), 35897 letterSpacing: undefined 35898 } 35899 }) 35900 }); 35901 } 35902 35903 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/typography.js 35904 35905 35906 /** 35907 * WordPress dependencies 35908 */ 35909 35910 35911 35912 /** 35913 * Internal dependencies 35914 */ 35915 35916 35917 35918 35919 35920 35921 35922 35923 35924 35925 const TYPOGRAPHY_SUPPORT_KEY = 'typography'; 35926 const TYPOGRAPHY_SUPPORT_KEYS = [LINE_HEIGHT_SUPPORT_KEY, FONT_SIZE_SUPPORT_KEY, FONT_STYLE_SUPPORT_KEY, FONT_WEIGHT_SUPPORT_KEY, FONT_FAMILY_SUPPORT_KEY, TEXT_DECORATION_SUPPORT_KEY, TEXT_TRANSFORM_SUPPORT_KEY, LETTER_SPACING_SUPPORT_KEY]; 35927 function TypographyPanel(props) { 35928 const { 35929 clientId 35930 } = props; 35931 const isFontFamilyDisabled = useIsFontFamilyDisabled(props); 35932 const isFontSizeDisabled = useIsFontSizeDisabled(props); 35933 const isFontAppearanceDisabled = useIsFontAppearanceDisabled(props); 35934 const isLineHeightDisabled = useIsLineHeightDisabled(props); 35935 const isTextDecorationDisabled = useIsTextDecorationDisabled(props); 35936 const isTextTransformDisabled = useIsTextTransformDisabled(props); 35937 const isLetterSpacingDisabled = useIsLetterSpacingDisabled(props); 35938 const hasFontStyles = !useIsFontStyleDisabled(props); 35939 const hasFontWeights = !useIsFontWeightDisabled(props); 35940 const isDisabled = useIsTypographyDisabled(props); 35941 const isSupported = hasTypographySupport(props.name); 35942 if (isDisabled || !isSupported) return null; 35943 const defaultControls = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, [TYPOGRAPHY_SUPPORT_KEY, '__experimentalDefaultControls']); 35944 35945 const createResetAllFilter = attribute => newAttributes => { 35946 var _newAttributes$style; 35947 35948 return { ...newAttributes, 35949 style: { ...newAttributes.style, 35950 typography: { ...((_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : _newAttributes$style.typography), 35951 [attribute]: undefined 35952 } 35953 } 35954 }; 35955 }; 35956 35957 return (0,external_wp_element_namespaceObject.createElement)(inspector_controls, { 35958 __experimentalGroup: "typography" 35959 }, !isFontFamilyDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, { 35960 hasValue: () => hasFontFamilyValue(props), 35961 label: (0,external_wp_i18n_namespaceObject.__)('Font family'), 35962 onDeselect: () => resetFontFamily(props), 35963 isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.fontFamily, 35964 resetAllFilter: newAttributes => ({ ...newAttributes, 35965 fontFamily: undefined 35966 }), 35967 panelId: clientId 35968 }, (0,external_wp_element_namespaceObject.createElement)(FontFamilyEdit, props)), !isFontSizeDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, { 35969 hasValue: () => hasFontSizeValue(props), 35970 label: (0,external_wp_i18n_namespaceObject.__)('Font size'), 35971 onDeselect: () => resetFontSize(props), 35972 isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.fontSize, 35973 resetAllFilter: newAttributes => { 35974 var _newAttributes$style2; 35975 35976 return { ...newAttributes, 35977 fontSize: undefined, 35978 style: { ...newAttributes.style, 35979 typography: { ...((_newAttributes$style2 = newAttributes.style) === null || _newAttributes$style2 === void 0 ? void 0 : _newAttributes$style2.typography), 35980 fontSize: undefined 35981 } 35982 } 35983 }; 35984 }, 35985 panelId: clientId 35986 }, (0,external_wp_element_namespaceObject.createElement)(FontSizeEdit, props)), !isFontAppearanceDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, { 35987 className: "single-column", 35988 hasValue: () => hasFontAppearanceValue(props), 35989 label: getFontAppearanceLabel(hasFontStyles, hasFontWeights), 35990 onDeselect: () => resetFontAppearance(props), 35991 isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.fontAppearance, 35992 resetAllFilter: newAttributes => { 35993 var _newAttributes$style3; 35994 35995 return { ...newAttributes, 35996 style: { ...newAttributes.style, 35997 typography: { ...((_newAttributes$style3 = newAttributes.style) === null || _newAttributes$style3 === void 0 ? void 0 : _newAttributes$style3.typography), 35998 fontStyle: undefined, 35999 fontWeight: undefined 36000 } 36001 } 36002 }; 36003 }, 36004 panelId: clientId 36005 }, (0,external_wp_element_namespaceObject.createElement)(FontAppearanceEdit, props)), !isLineHeightDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, { 36006 className: "single-column", 36007 hasValue: () => hasLineHeightValue(props), 36008 label: (0,external_wp_i18n_namespaceObject.__)('Line height'), 36009 onDeselect: () => resetLineHeight(props), 36010 isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.lineHeight, 36011 resetAllFilter: createResetAllFilter('lineHeight'), 36012 panelId: clientId 36013 }, (0,external_wp_element_namespaceObject.createElement)(LineHeightEdit, props)), !isTextDecorationDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, { 36014 className: "single-column", 36015 hasValue: () => hasTextDecorationValue(props), 36016 label: (0,external_wp_i18n_namespaceObject.__)('Decoration'), 36017 onDeselect: () => resetTextDecoration(props), 36018 isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.textDecoration, 36019 resetAllFilter: createResetAllFilter('textDecoration'), 36020 panelId: clientId 36021 }, (0,external_wp_element_namespaceObject.createElement)(TextDecorationEdit, props)), !isTextTransformDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, { 36022 className: "single-column", 36023 hasValue: () => hasTextTransformValue(props), 36024 label: (0,external_wp_i18n_namespaceObject.__)('Letter case'), 36025 onDeselect: () => resetTextTransform(props), 36026 isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.textTransform, 36027 resetAllFilter: createResetAllFilter('textTransform'), 36028 panelId: clientId 36029 }, (0,external_wp_element_namespaceObject.createElement)(TextTransformEdit, props)), !isLetterSpacingDisabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, { 36030 className: "single-column", 36031 hasValue: () => hasLetterSpacingValue(props), 36032 label: (0,external_wp_i18n_namespaceObject.__)('Letter spacing'), 36033 onDeselect: () => resetLetterSpacing(props), 36034 isShownByDefault: defaultControls === null || defaultControls === void 0 ? void 0 : defaultControls.letterSpacing, 36035 resetAllFilter: createResetAllFilter('letterSpacing'), 36036 panelId: clientId 36037 }, (0,external_wp_element_namespaceObject.createElement)(LetterSpacingEdit, props))); 36038 } 36039 const hasTypographySupport = blockName => { 36040 return TYPOGRAPHY_SUPPORT_KEYS.some(key => (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, key)); 36041 }; 36042 36043 function useIsTypographyDisabled() { 36044 let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 36045 const configs = [useIsFontAppearanceDisabled(props), useIsFontSizeDisabled(props), useIsLineHeightDisabled(props), useIsFontFamilyDisabled(props), useIsTextDecorationDisabled(props), useIsTextTransformDisabled(props), useIsLetterSpacingDisabled(props)]; 36046 return configs.filter(Boolean).length === configs.length; 36047 } 36048 36049 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/style.js 36050 36051 36052 36053 /** 36054 * External dependencies 36055 */ 36056 36057 36058 /** 36059 * WordPress dependencies 36060 */ 36061 36062 36063 36064 36065 36066 36067 /** 36068 * Internal dependencies 36069 */ 36070 36071 36072 36073 36074 36075 36076 36077 36078 const styleSupportKeys = [...TYPOGRAPHY_SUPPORT_KEYS, BORDER_SUPPORT_KEY, COLOR_SUPPORT_KEY, SPACING_SUPPORT_KEY]; 36079 36080 const hasStyleSupport = blockType => styleSupportKeys.some(key => (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, key)); 36081 36082 const VARIABLE_REFERENCE_PREFIX = 'var:'; 36083 const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|'; 36084 const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--'; 36085 36086 function compileStyleValue(uncompiledValue) { 36087 if ((0,external_lodash_namespaceObject.startsWith)(uncompiledValue, VARIABLE_REFERENCE_PREFIX)) { 36088 const variable = uncompiledValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE); 36089 return `var(--wp--$variable})`; 36090 } 36091 36092 return uncompiledValue; 36093 } 36094 /** 36095 * Returns the inline styles to add depending on the style object 36096 * 36097 * @param {Object} styles Styles configuration. 36098 * 36099 * @return {Object} Flattened CSS variables declaration. 36100 */ 36101 36102 36103 function getInlineStyles() { 36104 let styles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 36105 const ignoredStyles = ['spacing.blockGap']; 36106 const output = {}; 36107 Object.keys(external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY).forEach(propKey => { 36108 const path = external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[propKey].value; 36109 const subPaths = external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[propKey].properties; // Ignore styles on elements because they are handled on the server. 36110 36111 if ((0,external_lodash_namespaceObject.has)(styles, path) && 'elements' !== (0,external_lodash_namespaceObject.first)(path)) { 36112 // Checking if style value is a string allows for shorthand css 36113 // option and backwards compatibility for border radius support. 36114 const styleValue = (0,external_lodash_namespaceObject.get)(styles, path); 36115 36116 if (!external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[propKey].useEngine) { 36117 if (!!subPaths && !(0,external_lodash_namespaceObject.isString)(styleValue)) { 36118 Object.entries(subPaths).forEach(entry => { 36119 const [name, subPath] = entry; 36120 const value = (0,external_lodash_namespaceObject.get)(styleValue, [subPath]); 36121 36122 if (value) { 36123 output[name] = compileStyleValue(value); 36124 } 36125 }); 36126 } else if (!ignoredStyles.includes(path.join('.'))) { 36127 output[propKey] = compileStyleValue((0,external_lodash_namespaceObject.get)(styles, path)); 36128 } 36129 } 36130 } 36131 }); // The goal is to move everything to server side generated engine styles 36132 // This is temporary as we absorb more and more styles into the engine. 36133 36134 const extraRules = getCSSRules(styles, { 36135 selector: 'self' 36136 }); 36137 extraRules.forEach(rule => { 36138 if (rule.selector !== 'self') { 36139 throw "This style can't be added as inline style"; 36140 } 36141 36142 output[rule.key] = rule.value; 36143 }); 36144 return output; 36145 } 36146 36147 function compileElementsStyles(selector) { 36148 let elements = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 36149 return (0,external_lodash_namespaceObject.map)(elements, (styles, element) => { 36150 const elementStyles = getInlineStyles(styles); 36151 36152 if (!(0,external_lodash_namespaceObject.isEmpty)(elementStyles)) { 36153 // The .editor-styles-wrapper selector is required on elements styles. As it is 36154 // added to all other editor styles, not providing it causes reset and global 36155 // styles to override element styles because of higher specificity. 36156 return [`.editor-styles-wrapper .$selector} $external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS[element]}{`, ...(0,external_lodash_namespaceObject.map)(elementStyles, (value, property) => `\t${(0,external_lodash_namespaceObject.kebabCase)(property)}: $value};`), '}'].join('\n'); 36157 } 36158 36159 return ''; 36160 }).join('\n'); 36161 } 36162 /** 36163 * Filters registered block settings, extending attributes to include `style` attribute. 36164 * 36165 * @param {Object} settings Original block settings. 36166 * 36167 * @return {Object} Filtered block settings. 36168 */ 36169 36170 36171 function style_addAttribute(settings) { 36172 if (!hasStyleSupport(settings)) { 36173 return settings; 36174 } // Allow blocks to specify their own attribute definition with default values if needed. 36175 36176 36177 if (!settings.attributes.style) { 36178 Object.assign(settings.attributes, { 36179 style: { 36180 type: 'object' 36181 } 36182 }); 36183 } 36184 36185 return settings; 36186 } 36187 /** 36188 * A dictionary of paths to flag skipping block support serialization as the key, 36189 * with values providing the style paths to be omitted from serialization. 36190 * 36191 * @constant 36192 * @type {Record<string, string[]>} 36193 */ 36194 36195 36196 const skipSerializationPathsEdit = { 36197 [`$BORDER_SUPPORT_KEY}.__experimentalSkipSerialization`]: ['border'], 36198 [`$COLOR_SUPPORT_KEY}.__experimentalSkipSerialization`]: [COLOR_SUPPORT_KEY], 36199 [`$TYPOGRAPHY_SUPPORT_KEY}.__experimentalSkipSerialization`]: [TYPOGRAPHY_SUPPORT_KEY], 36200 [`$SPACING_SUPPORT_KEY}.__experimentalSkipSerialization`]: ['spacing'] 36201 }; 36202 /** 36203 * A dictionary of paths to flag skipping block support serialization as the key, 36204 * with values providing the style paths to be omitted from serialization. 36205 * 36206 * Extends the Edit skip paths to enable skipping additional paths in just 36207 * the Save component. This allows a block support to be serialized within the 36208 * editor, while using an alternate approach, such as server-side rendering, when 36209 * the support is saved. 36210 * 36211 * @constant 36212 * @type {Record<string, string[]>} 36213 */ 36214 36215 const skipSerializationPathsSave = { ...skipSerializationPathsEdit, 36216 [`$SPACING_SUPPORT_KEY}`]: ['spacing.blockGap'] 36217 }; 36218 /** 36219 * A dictionary used to normalize feature names between support flags, style 36220 * object properties and __experimentSkipSerialization configuration arrays. 36221 * 36222 * This allows not having to provide a migration for a support flag and possible 36223 * backwards compatibility bridges, while still achieving consistency between 36224 * the support flag and the skip serialization array. 36225 * 36226 * @constant 36227 * @type {Record<string, string>} 36228 */ 36229 36230 const renamedFeatures = { 36231 gradients: 'gradient' 36232 }; 36233 /** 36234 * Override props assigned to save component to inject the CSS variables definition. 36235 * 36236 * @param {Object} props Additional props applied to save element. 36237 * @param {Object} blockType Block type. 36238 * @param {Object} attributes Block attributes. 36239 * @param {?Record<string, string[]>} skipPaths An object of keys and paths to skip serialization. 36240 * 36241 * @return {Object} Filtered props applied to save element. 36242 */ 36243 36244 function style_addSaveProps(props, blockType, attributes) { 36245 let skipPaths = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : skipSerializationPathsSave; 36246 36247 if (!hasStyleSupport(blockType)) { 36248 return props; 36249 } 36250 36251 let { 36252 style 36253 } = attributes; 36254 (0,external_lodash_namespaceObject.forEach)(skipPaths, (path, indicator) => { 36255 const skipSerialization = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, indicator); 36256 36257 if (skipSerialization === true) { 36258 style = (0,external_lodash_namespaceObject.omit)(style, path); 36259 } 36260 36261 if (Array.isArray(skipSerialization)) { 36262 skipSerialization.forEach(featureName => { 36263 const feature = renamedFeatures[featureName] || featureName; 36264 style = (0,external_lodash_namespaceObject.omit)(style, [[...path, feature]]); 36265 }); 36266 } 36267 }); 36268 props.style = { ...getInlineStyles(style), 36269 ...props.style 36270 }; 36271 return props; 36272 } 36273 /** 36274 * Filters registered block settings to extend the block edit wrapper 36275 * to apply the desired styles and classnames properly. 36276 * 36277 * @param {Object} settings Original block settings. 36278 * 36279 * @return {Object}.Filtered block settings. 36280 */ 36281 36282 function style_addEditProps(settings) { 36283 if (!hasStyleSupport(settings)) { 36284 return settings; 36285 } 36286 36287 const existingGetEditWrapperProps = settings.getEditWrapperProps; 36288 36289 settings.getEditWrapperProps = attributes => { 36290 let props = {}; 36291 36292 if (existingGetEditWrapperProps) { 36293 props = existingGetEditWrapperProps(attributes); 36294 } 36295 36296 return style_addSaveProps(props, settings, attributes, skipSerializationPathsEdit); 36297 }; 36298 36299 return settings; 36300 } 36301 /** 36302 * Override the default edit UI to include new inspector controls for 36303 * all the custom styles configs. 36304 * 36305 * @param {Function} BlockEdit Original component. 36306 * 36307 * @return {Function} Wrapped component. 36308 */ 36309 36310 const withBlockControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { 36311 const shouldDisplayControls = useDisplayBlockControls(); 36312 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, shouldDisplayControls && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(ColorEdit, props), (0,external_wp_element_namespaceObject.createElement)(TypographyPanel, props), (0,external_wp_element_namespaceObject.createElement)(BorderPanel, props), (0,external_wp_element_namespaceObject.createElement)(DimensionsPanel, props)), (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props)); 36313 }, 'withToolbarControls'); 36314 /** 36315 * Override the default block element to include duotone styles. 36316 * 36317 * @param {Function} BlockListBlock Original component 36318 * @return {Function} Wrapped component 36319 */ 36320 36321 const withElementsStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => { 36322 var _props$attributes$sty, _props$attributes$sty2; 36323 36324 const blockElementsContainerIdentifier = `wp-elements-${(0,external_wp_compose_namespaceObject.useInstanceId)(BlockListBlock)}`; 36325 const skipLinkColorSerialization = shouldSkipSerialization(props.name, COLOR_SUPPORT_KEY, 'link'); // The Elements API only supports link colors for now, 36326 // hence the specific omission of `link` in the elements styles. 36327 // This might need to be refactored or removed if the Elements API 36328 // changes or `link` supports styles beyond `color`. 36329 36330 const elements = skipLinkColorSerialization ? (0,external_lodash_namespaceObject.omit)((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.elements, ['link']) : (_props$attributes$sty2 = props.attributes.style) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.elements; 36331 const styles = compileElementsStyles(blockElementsContainerIdentifier, elements); 36332 const element = (0,external_wp_element_namespaceObject.useContext)(BlockList.__unstableElementContext); 36333 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, elements && element && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)("style", { 36334 dangerouslySetInnerHTML: { 36335 __html: styles 36336 } 36337 }), element), (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, { 36338 className: elements ? classnames_default()(props.className, blockElementsContainerIdentifier) : props.className 36339 }))); 36340 }); 36341 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/style/addAttribute', style_addAttribute); 36342 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/style/addSaveProps', style_addSaveProps); 36343 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/style/addEditProps', style_addEditProps); 36344 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/style/with-block-controls', withBlockControls); 36345 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/with-elements-styles', withElementsStyles); 36346 36347 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/duotone-control/index.js 36348 36349 36350 /** 36351 * WordPress dependencies 36352 */ 36353 36354 36355 36356 36357 function DuotoneControl(_ref) { 36358 let { 36359 colorPalette, 36360 duotonePalette, 36361 disableCustomColors, 36362 disableCustomDuotone, 36363 value, 36364 onChange 36365 } = _ref; 36366 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, { 36367 popoverProps: { 36368 className: 'block-editor-duotone-control__popover', 36369 headerTitle: (0,external_wp_i18n_namespaceObject.__)('Duotone'), 36370 isAlternate: true 36371 }, 36372 renderToggle: _ref2 => { 36373 let { 36374 isOpen, 36375 onToggle 36376 } = _ref2; 36377 36378 const openOnArrowDown = event => { 36379 if (!isOpen && event.keyCode === external_wp_keycodes_namespaceObject.DOWN) { 36380 event.preventDefault(); 36381 onToggle(); 36382 } 36383 }; 36384 36385 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 36386 showTooltip: true, 36387 onClick: onToggle, 36388 "aria-haspopup": "true", 36389 "aria-expanded": isOpen, 36390 onKeyDown: openOnArrowDown, 36391 label: (0,external_wp_i18n_namespaceObject.__)('Apply duotone filter'), 36392 icon: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DuotoneSwatch, { 36393 values: value 36394 }) 36395 }); 36396 }, 36397 renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, { 36398 label: (0,external_wp_i18n_namespaceObject.__)('Duotone') 36399 }, (0,external_wp_element_namespaceObject.createElement)("div", { 36400 className: "block-editor-duotone-control__description" 36401 }, (0,external_wp_i18n_namespaceObject.__)('Create a two-tone color effect without losing your original image.')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DuotonePicker, { 36402 colorPalette: colorPalette, 36403 duotonePalette: duotonePalette, 36404 disableCustomColors: disableCustomColors, 36405 disableCustomDuotone: disableCustomDuotone, 36406 value: value, 36407 onChange: onChange 36408 })) 36409 }); 36410 } 36411 36412 /* harmony default export */ var duotone_control = (DuotoneControl); 36413 36414 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/duotone.js 36415 36416 36417 36418 /** 36419 * External dependencies 36420 */ 36421 36422 36423 36424 /** 36425 * WordPress dependencies 36426 */ 36427 36428 36429 36430 36431 36432 36433 /** 36434 * Internal dependencies 36435 */ 36436 36437 36438 36439 const duotone_EMPTY_ARRAY = []; 36440 k([names]); 36441 /** 36442 * Convert a list of colors to an object of R, G, and B values. 36443 * 36444 * @param {string[]} colors Array of RBG color strings. 36445 * 36446 * @return {Object} R, G, and B values. 36447 */ 36448 36449 function getValuesFromColors() { 36450 let colors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; 36451 const values = { 36452 r: [], 36453 g: [], 36454 b: [], 36455 a: [] 36456 }; 36457 colors.forEach(color => { 36458 const rgbColor = w(color).toRgb(); 36459 values.r.push(rgbColor.r / 255); 36460 values.g.push(rgbColor.g / 255); 36461 values.b.push(rgbColor.b / 255); 36462 values.a.push(rgbColor.a); 36463 }); 36464 return values; 36465 } 36466 /** 36467 * Values for the SVG `feComponentTransfer`. 36468 * 36469 * @typedef Values {Object} 36470 * @property {number[]} r Red values. 36471 * @property {number[]} g Green values. 36472 * @property {number[]} b Blue values. 36473 * @property {number[]} a Alpha values. 36474 */ 36475 36476 /** 36477 * Stylesheet for rendering the duotone filter. 36478 * 36479 * @param {Object} props Duotone props. 36480 * @param {string} props.selector Selector to apply the filter to. 36481 * @param {string} props.id Unique id for this duotone filter. 36482 * 36483 * @return {WPElement} Duotone element. 36484 */ 36485 36486 function DuotoneStylesheet(_ref) { 36487 let { 36488 selector, 36489 id 36490 } = _ref; 36491 const css = ` 36492 $selector} { 36493 filter: url( #$id} ); 36494 } 36495 `; 36496 return (0,external_wp_element_namespaceObject.createElement)("style", null, css); 36497 } 36498 /** 36499 * SVG for rendering the duotone filter. 36500 * 36501 * @param {Object} props Duotone props. 36502 * @param {string} props.id Unique id for this duotone filter. 36503 * @param {Values} props.values R, G, B, and A values to filter with. 36504 * 36505 * @return {WPElement} Duotone element. 36506 */ 36507 36508 36509 function DuotoneFilter(_ref2) { 36510 let { 36511 id, 36512 values 36513 } = _ref2; 36514 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, { 36515 xmlnsXlink: "http://www.w3.org/1999/xlink", 36516 viewBox: "0 0 0 0", 36517 width: "0", 36518 height: "0", 36519 focusable: "false", 36520 role: "none", 36521 style: { 36522 visibility: 'hidden', 36523 position: 'absolute', 36524 left: '-9999px', 36525 overflow: 'hidden' 36526 } 36527 }, (0,external_wp_element_namespaceObject.createElement)("defs", null, (0,external_wp_element_namespaceObject.createElement)("filter", { 36528 id: id 36529 }, (0,external_wp_element_namespaceObject.createElement)("feColorMatrix", { 36530 // Use sRGB instead of linearRGB so transparency looks correct. 36531 colorInterpolationFilters: "sRGB", 36532 type: "matrix" // Use perceptual brightness to convert to grayscale. 36533 , 36534 values: " .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 " 36535 }), (0,external_wp_element_namespaceObject.createElement)("feComponentTransfer", { 36536 // Use sRGB instead of linearRGB to be consistent with how CSS gradients work. 36537 colorInterpolationFilters: "sRGB" 36538 }, (0,external_wp_element_namespaceObject.createElement)("feFuncR", { 36539 type: "table", 36540 tableValues: values.r.join(' ') 36541 }), (0,external_wp_element_namespaceObject.createElement)("feFuncG", { 36542 type: "table", 36543 tableValues: values.g.join(' ') 36544 }), (0,external_wp_element_namespaceObject.createElement)("feFuncB", { 36545 type: "table", 36546 tableValues: values.b.join(' ') 36547 }), (0,external_wp_element_namespaceObject.createElement)("feFuncA", { 36548 type: "table", 36549 tableValues: values.a.join(' ') 36550 })), (0,external_wp_element_namespaceObject.createElement)("feComposite", { 36551 // Re-mask the image with the original transparency since the feColorMatrix above loses that information. 36552 in2: "SourceGraphic", 36553 operator: "in" 36554 })))); 36555 } 36556 /** 36557 * SVG and stylesheet needed for rendering the duotone filter. 36558 * 36559 * @param {Object} props Duotone props. 36560 * @param {string} props.selector Selector to apply the filter to. 36561 * @param {string} props.id Unique id for this duotone filter. 36562 * @param {Values} props.values R, G, B, and A values to filter with. 36563 * 36564 * @return {WPElement} Duotone element. 36565 */ 36566 36567 36568 function InlineDuotone(_ref3) { 36569 let { 36570 selector, 36571 id, 36572 values 36573 } = _ref3; 36574 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(DuotoneFilter, { 36575 id: id, 36576 values: values 36577 }), (0,external_wp_element_namespaceObject.createElement)(DuotoneStylesheet, { 36578 id: id, 36579 selector: selector 36580 })); 36581 } 36582 36583 function useMultiOriginPresets(_ref4) { 36584 let { 36585 presetSetting, 36586 defaultSetting 36587 } = _ref4; 36588 const disableDefault = !useSetting(defaultSetting); 36589 const userPresets = useSetting(`$presetSetting}.custom`) || duotone_EMPTY_ARRAY; 36590 const themePresets = useSetting(`$presetSetting}.theme`) || duotone_EMPTY_ARRAY; 36591 const defaultPresets = useSetting(`$presetSetting}.default`) || duotone_EMPTY_ARRAY; 36592 return (0,external_wp_element_namespaceObject.useMemo)(() => [...userPresets, ...themePresets, ...(disableDefault ? duotone_EMPTY_ARRAY : defaultPresets)], [disableDefault, userPresets, themePresets, defaultPresets]); 36593 } 36594 36595 function DuotonePanel(_ref5) { 36596 var _style$color; 36597 36598 let { 36599 attributes, 36600 setAttributes 36601 } = _ref5; 36602 const style = attributes === null || attributes === void 0 ? void 0 : attributes.style; 36603 const duotone = style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.duotone; 36604 const duotonePalette = useMultiOriginPresets({ 36605 presetSetting: 'color.duotone', 36606 defaultSetting: 'color.defaultDuotone' 36607 }); 36608 const colorPalette = useMultiOriginPresets({ 36609 presetSetting: 'color.palette', 36610 defaultSetting: 'color.defaultPalette' 36611 }); 36612 const disableCustomColors = !useSetting('color.custom'); 36613 const disableCustomDuotone = !useSetting('color.customDuotone') || (colorPalette === null || colorPalette === void 0 ? void 0 : colorPalette.length) === 0 && disableCustomColors; 36614 36615 if ((duotonePalette === null || duotonePalette === void 0 ? void 0 : duotonePalette.length) === 0 && disableCustomDuotone) { 36616 return null; 36617 } 36618 36619 return (0,external_wp_element_namespaceObject.createElement)(block_controls, { 36620 group: "block", 36621 __experimentalShareWithChildBlocks: true 36622 }, (0,external_wp_element_namespaceObject.createElement)(duotone_control, { 36623 duotonePalette: duotonePalette, 36624 colorPalette: colorPalette, 36625 disableCustomDuotone: disableCustomDuotone, 36626 disableCustomColors: disableCustomColors, 36627 value: duotone, 36628 onChange: newDuotone => { 36629 const newStyle = { ...style, 36630 color: { ...(style === null || style === void 0 ? void 0 : style.color), 36631 duotone: newDuotone 36632 } 36633 }; 36634 setAttributes({ 36635 style: newStyle 36636 }); 36637 } 36638 })); 36639 } 36640 /** 36641 * Filters registered block settings, extending attributes to include 36642 * the `duotone` attribute. 36643 * 36644 * @param {Object} settings Original block settings. 36645 * 36646 * @return {Object} Filtered block settings. 36647 */ 36648 36649 36650 function addDuotoneAttributes(settings) { 36651 if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'color.__experimentalDuotone')) { 36652 return settings; 36653 } // Allow blocks to specify their own attribute definition with default 36654 // values if needed. 36655 36656 36657 if (!settings.attributes.style) { 36658 Object.assign(settings.attributes, { 36659 style: { 36660 type: 'object' 36661 } 36662 }); 36663 } 36664 36665 return settings; 36666 } 36667 /** 36668 * Override the default edit UI to include toolbar controls for duotone if the 36669 * block supports duotone. 36670 * 36671 * @param {Function} BlockEdit Original component. 36672 * 36673 * @return {Function} Wrapped component. 36674 */ 36675 36676 36677 const withDuotoneControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { 36678 const hasDuotoneSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(props.name, 'color.__experimentalDuotone'); 36679 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), hasDuotoneSupport && (0,external_wp_element_namespaceObject.createElement)(DuotonePanel, props)); 36680 }, 'withDuotoneControls'); 36681 /** 36682 * Function that scopes a selector with another one. This works a bit like 36683 * SCSS nesting except the `&` operator isn't supported. 36684 * 36685 * @example 36686 * ```js 36687 * const scope = '.a, .b .c'; 36688 * const selector = '> .x, .y'; 36689 * const merged = scopeSelector( scope, selector ); 36690 * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y' 36691 * ``` 36692 * 36693 * @param {string} scope Selector to scope to. 36694 * @param {string} selector Original selector. 36695 * 36696 * @return {string} Scoped selector. 36697 */ 36698 36699 function scopeSelector(scope, selector) { 36700 const scopes = scope.split(','); 36701 const selectors = selector.split(','); 36702 const selectorsScoped = []; 36703 scopes.forEach(outer => { 36704 selectors.forEach(inner => { 36705 selectorsScoped.push(`$outer.trim()} $inner.trim()}`); 36706 }); 36707 }); 36708 return selectorsScoped.join(', '); 36709 } 36710 /** 36711 * Override the default block element to include duotone styles. 36712 * 36713 * @param {Function} BlockListBlock Original component. 36714 * 36715 * @return {Function} Wrapped component. 36716 */ 36717 36718 36719 const withDuotoneStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => { 36720 var _props$attributes, _props$attributes$sty, _props$attributes$sty2; 36721 36722 const duotoneSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, 'color.__experimentalDuotone'); 36723 const values = props === null || props === void 0 ? void 0 : (_props$attributes = props.attributes) === null || _props$attributes === void 0 ? void 0 : (_props$attributes$sty = _props$attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.color) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.duotone; 36724 36725 if (!duotoneSupport || !values) { 36726 return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props); 36727 } 36728 36729 const id = `wp-duotone-${(0,external_wp_compose_namespaceObject.useInstanceId)(BlockListBlock)}`; // Extra .editor-styles-wrapper specificity is needed in the editor 36730 // since we're not using inline styles to apply the filter. We need to 36731 // override duotone applied by global styles and theme.json. 36732 36733 const selectorsGroup = scopeSelector(`.editor-styles-wrapper .$id}`, duotoneSupport); 36734 const className = classnames_default()(props === null || props === void 0 ? void 0 : props.className, id); 36735 const element = (0,external_wp_element_namespaceObject.useContext)(BlockList.__unstableElementContext); 36736 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, element && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)(InlineDuotone, { 36737 selector: selectorsGroup, 36738 id: id, 36739 values: getValuesFromColors(values) 36740 }), element), (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, { 36741 className: className 36742 }))); 36743 }, 'withDuotoneStyles'); 36744 function PresetDuotoneFilter(_ref6) { 36745 let { 36746 preset 36747 } = _ref6; 36748 return (0,external_wp_element_namespaceObject.createElement)(DuotoneFilter, { 36749 id: `wp-duotone-$preset.slug}`, 36750 values: getValuesFromColors(preset.colors) 36751 }); 36752 } 36753 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/editor/duotone/add-attributes', addDuotoneAttributes); 36754 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/duotone/with-editor-controls', withDuotoneControls); 36755 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/duotone/with-styles', withDuotoneStyles); 36756 36757 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/layout.js 36758 36759 36760 36761 /** 36762 * External dependencies 36763 */ 36764 36765 36766 /** 36767 * WordPress dependencies 36768 */ 36769 36770 36771 36772 36773 36774 36775 36776 36777 /** 36778 * Internal dependencies 36779 */ 36780 36781 36782 36783 36784 36785 36786 36787 const layoutBlockSupportKey = '__experimentalLayout'; 36788 36789 function LayoutPanel(_ref) { 36790 let { 36791 setAttributes, 36792 attributes, 36793 name: blockName 36794 } = _ref; 36795 const { 36796 layout 36797 } = attributes; 36798 const defaultThemeLayout = useSetting('layout'); 36799 const themeSupportsLayout = (0,external_wp_data_namespaceObject.useSelect)(select => { 36800 const { 36801 getSettings 36802 } = select(store); 36803 return getSettings().supportsLayout; 36804 }, []); 36805 const layoutBlockSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, layoutBlockSupportKey, {}); 36806 const { 36807 allowSwitching, 36808 allowEditing = true, 36809 allowInheriting = true, 36810 default: defaultBlockLayout 36811 } = layoutBlockSupport; 36812 36813 if (!allowEditing) { 36814 return null; 36815 } // Only show the inherit toggle if it's supported, 36816 // a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values), 36817 // and that the default / flow layout type is in use, as this is the only one that supports inheritance. 36818 36819 36820 const showInheritToggle = !!(allowInheriting && !!defaultThemeLayout && (!(layout !== null && layout !== void 0 && layout.type) || (layout === null || layout === void 0 ? void 0 : layout.type) === 'default' || layout !== null && layout !== void 0 && layout.inherit)); 36821 const usedLayout = layout || defaultBlockLayout || {}; 36822 const { 36823 inherit = false, 36824 type = 'default' 36825 } = usedLayout; 36826 /** 36827 * `themeSupportsLayout` is only relevant to the `default/flow` 36828 * layout and it should not be taken into account when other 36829 * `layout` types are used. 36830 */ 36831 36832 if (type === 'default' && !themeSupportsLayout) { 36833 return null; 36834 } 36835 36836 const layoutType = getLayoutType(type); 36837 36838 const onChangeType = newType => setAttributes({ 36839 layout: { 36840 type: newType 36841 } 36842 }); 36843 36844 const onChangeLayout = newLayout => setAttributes({ 36845 layout: newLayout 36846 }); 36847 36848 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(inspector_controls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, { 36849 title: (0,external_wp_i18n_namespaceObject.__)('Layout') 36850 }, showInheritToggle && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, { 36851 label: (0,external_wp_i18n_namespaceObject.__)('Inherit default layout'), 36852 checked: !!inherit, 36853 onChange: () => setAttributes({ 36854 layout: { 36855 inherit: !inherit 36856 } 36857 }) 36858 }), !inherit && allowSwitching && (0,external_wp_element_namespaceObject.createElement)(LayoutTypeSwitcher, { 36859 type: type, 36860 onChange: onChangeType 36861 }), !inherit && layoutType && (0,external_wp_element_namespaceObject.createElement)(layoutType.inspectorControls, { 36862 layout: usedLayout, 36863 onChange: onChangeLayout, 36864 layoutBlockSupport: layoutBlockSupport 36865 }))), !inherit && layoutType && (0,external_wp_element_namespaceObject.createElement)(layoutType.toolBarControls, { 36866 layout: usedLayout, 36867 onChange: onChangeLayout, 36868 layoutBlockSupport: layoutBlockSupport 36869 })); 36870 } 36871 36872 function LayoutTypeSwitcher(_ref2) { 36873 let { 36874 type, 36875 onChange 36876 } = _ref2; 36877 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ButtonGroup, null, getLayoutTypes().map(_ref3 => { 36878 let { 36879 name, 36880 label 36881 } = _ref3; 36882 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 36883 key: name, 36884 isPressed: type === name, 36885 onClick: () => onChange(name) 36886 }, label); 36887 })); 36888 } 36889 /** 36890 * Filters registered block settings, extending attributes to include `layout`. 36891 * 36892 * @param {Object} settings Original block settings. 36893 * 36894 * @return {Object} Filtered block settings. 36895 */ 36896 36897 36898 function layout_addAttribute(settings) { 36899 if ((0,external_lodash_namespaceObject.has)(settings.attributes, ['layout', 'type'])) { 36900 return settings; 36901 } 36902 36903 if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, layoutBlockSupportKey)) { 36904 settings.attributes = { ...settings.attributes, 36905 layout: { 36906 type: 'object' 36907 } 36908 }; 36909 } 36910 36911 return settings; 36912 } 36913 /** 36914 * Override the default edit UI to include layout controls 36915 * 36916 * @param {Function} BlockEdit Original component. 36917 * 36918 * @return {Function} Wrapped component. 36919 */ 36920 36921 const withInspectorControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { 36922 const { 36923 name: blockName 36924 } = props; 36925 const supportLayout = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, layoutBlockSupportKey); 36926 return [supportLayout && (0,external_wp_element_namespaceObject.createElement)(LayoutPanel, _extends({ 36927 key: "layout" 36928 }, props)), (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({ 36929 key: "edit" 36930 }, props))]; 36931 }, 'withInspectorControls'); 36932 /** 36933 * Override the default block element to add the layout styles. 36934 * 36935 * @param {Function} BlockListBlock Original component. 36936 * 36937 * @return {Function} Wrapped component. 36938 */ 36939 36940 const withLayoutStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => { 36941 const { 36942 name, 36943 attributes 36944 } = props; 36945 const shouldRenderLayoutStyles = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(name, layoutBlockSupportKey); 36946 const id = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockListBlock); 36947 const defaultThemeLayout = useSetting('layout') || {}; 36948 const element = (0,external_wp_element_namespaceObject.useContext)(BlockList.__unstableElementContext); 36949 const { 36950 layout 36951 } = attributes; 36952 const { 36953 default: defaultBlockLayout 36954 } = (0,external_wp_blocks_namespaceObject.getBlockSupport)(name, layoutBlockSupportKey) || {}; 36955 const usedLayout = layout !== null && layout !== void 0 && layout.inherit ? defaultThemeLayout : layout || defaultBlockLayout || {}; 36956 const className = classnames_default()(props === null || props === void 0 ? void 0 : props.className, { 36957 [`wp-container-$id}`]: shouldRenderLayoutStyles 36958 }); 36959 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, shouldRenderLayoutStyles && element && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)(LayoutStyle, { 36960 blockName: name, 36961 selector: `.wp-container-$id}`, 36962 layout: usedLayout, 36963 style: attributes === null || attributes === void 0 ? void 0 : attributes.style 36964 }), element), (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, { 36965 className: className 36966 }))); 36967 }); 36968 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/layout/addAttribute', layout_addAttribute); 36969 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/layout/with-layout-styles', withLayoutStyles); 36970 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/layout/with-inspector-controls', withInspectorControls); 36971 36972 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/use-border-props.js 36973 /** 36974 * External dependencies 36975 */ 36976 36977 /** 36978 * Internal dependencies 36979 */ 36980 36981 36982 36983 // This utility is intended to assist where the serialization of the border 36984 // block support is being skipped for a block but the border related CSS classes 36985 // & styles still need to be generated so they can be applied to inner elements. 36986 36987 const use_border_props_EMPTY_ARRAY = []; 36988 /** 36989 * Provides the CSS class names and inline styles for a block's border support 36990 * attributes. 36991 * 36992 * @param {Object} attributes Block attributes. 36993 * @param {string} attributes.borderColor Selected named border color. 36994 * @param {Object} attributes.style Block's styles attribute. 36995 * 36996 * @return {Object} Border block support derived CSS classes & styles. 36997 */ 36998 36999 function getBorderClassesAndStyles(_ref) { 37000 var _style$border; 37001 37002 let { 37003 borderColor, 37004 style 37005 } = _ref; 37006 const borderStyles = (style === null || style === void 0 ? void 0 : style.border) || {}; 37007 const borderClass = getColorClassName('border-color', borderColor); 37008 const className = classnames_default()({ 37009 [borderClass]: !!borderClass, 37010 'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.color) 37011 }); 37012 return { 37013 className: className || undefined, 37014 style: getInlineStyles({ 37015 border: borderStyles 37016 }) 37017 }; 37018 } 37019 /** 37020 * Derives the border related props for a block from its border block support 37021 * attributes. 37022 * 37023 * Inline styles are forced for named colors to ensure these selections are 37024 * reflected when themes do not load their color stylesheets in the editor. 37025 * 37026 * @param {Object} attributes Block attributes. 37027 * 37028 * @return {Object} ClassName & style props from border block support. 37029 */ 37030 37031 function useBorderProps(attributes) { 37032 const colors = useSetting('color.palette') || use_border_props_EMPTY_ARRAY; 37033 const borderProps = getBorderClassesAndStyles(attributes); // Force inline style to apply border color when themes do not load their 37034 // color stylesheets in the editor. 37035 37036 if (attributes.borderColor) { 37037 const borderColorObject = getColorObjectByAttributeValues(colors, attributes.borderColor); 37038 borderProps.style.borderColor = borderColorObject.color; 37039 } 37040 37041 return borderProps; 37042 } 37043 37044 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/use-color-props.js 37045 /** 37046 * External dependencies 37047 */ 37048 37049 /** 37050 * WordPress dependencies 37051 */ 37052 37053 37054 /** 37055 * Internal dependencies 37056 */ 37057 37058 37059 37060 37061 // The code in this file has largely been lifted from the color block support 37062 // hook. 37063 // 37064 // This utility is intended to assist where the serialization of the colors 37065 // block support is being skipped for a block but the color related CSS classes 37066 // & styles still need to be generated so they can be applied to inner elements. 37067 37068 /** 37069 * Provides the CSS class names and inline styles for a block's color support 37070 * attributes. 37071 * 37072 * @param {Object} attributes Block attributes. 37073 * 37074 * @return {Object} Color block support derived CSS classes & styles. 37075 */ 37076 37077 function getColorClassesAndStyles(attributes) { 37078 var _style$color, _style$color2, _style$color3, _style$color4, _style$elements, _style$elements$link; 37079 37080 const { 37081 backgroundColor, 37082 textColor, 37083 gradient, 37084 style 37085 } = attributes; // Collect color CSS classes. 37086 37087 const backgroundClass = getColorClassName('background-color', backgroundColor); 37088 const textClass = getColorClassName('color', textColor); 37089 37090 const gradientClass = __experimentalGetGradientClass(gradient); 37091 37092 const hasGradient = gradientClass || (style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.gradient); // Determine color CSS class name list. 37093 37094 const className = classnames_default()(textClass, gradientClass, { 37095 // Don't apply the background class if there's a gradient. 37096 [backgroundClass]: !hasGradient && !!backgroundClass, 37097 'has-text-color': textColor || (style === null || style === void 0 ? void 0 : (_style$color2 = style.color) === null || _style$color2 === void 0 ? void 0 : _style$color2.text), 37098 'has-background': backgroundColor || (style === null || style === void 0 ? void 0 : (_style$color3 = style.color) === null || _style$color3 === void 0 ? void 0 : _style$color3.background) || gradient || (style === null || style === void 0 ? void 0 : (_style$color4 = style.color) === null || _style$color4 === void 0 ? void 0 : _style$color4.gradient), 37099 'has-link-color': style === null || style === void 0 ? void 0 : (_style$elements = style.elements) === null || _style$elements === void 0 ? void 0 : (_style$elements$link = _style$elements.link) === null || _style$elements$link === void 0 ? void 0 : _style$elements$link.color 37100 }); // Collect inline styles for colors. 37101 37102 const colorStyles = (style === null || style === void 0 ? void 0 : style.color) || {}; 37103 const styleProp = getInlineStyles({ 37104 color: colorStyles 37105 }); 37106 return { 37107 className: className || undefined, 37108 style: styleProp 37109 }; 37110 } 37111 const EMPTY_OBJECT = {}; 37112 /** 37113 * Determines the color related props for a block derived from its color block 37114 * support attributes. 37115 * 37116 * Inline styles are forced for named colors to ensure these selections are 37117 * reflected when themes do not load their color stylesheets in the editor. 37118 * 37119 * @param {Object} attributes Block attributes. 37120 * 37121 * @return {Object} ClassName & style props from colors block support. 37122 */ 37123 37124 function useColorProps(attributes) { 37125 const { 37126 backgroundColor, 37127 textColor, 37128 gradient 37129 } = attributes; // Some color settings have a special handling for deprecated flags in `useSetting`, 37130 // so we can't unwrap them by doing const { ... } = useSetting('color') 37131 // until https://github.com/WordPress/gutenberg/issues/37094 is fixed. 37132 37133 const userPalette = useSetting('color.palette.custom') || []; 37134 const themePalette = useSetting('color.palette.theme') || []; 37135 const defaultPalette = useSetting('color.palette.default') || []; 37136 const gradientsPerOrigin = useSetting('color.gradients') || EMPTY_OBJECT; 37137 const colors = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]); 37138 const gradients = (0,external_wp_element_namespaceObject.useMemo)(() => [...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.custom) || []), ...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.theme) || []), ...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.default) || [])], [gradientsPerOrigin]); 37139 const colorProps = getColorClassesAndStyles(attributes); // Force inline styles to apply colors when themes do not load their color 37140 // stylesheets in the editor. 37141 37142 if (backgroundColor) { 37143 const backgroundColorObject = getColorObjectByAttributeValues(colors, backgroundColor); 37144 colorProps.style.backgroundColor = backgroundColorObject.color; 37145 } 37146 37147 if (gradient) { 37148 colorProps.style.background = getGradientValueBySlug(gradients, gradient); 37149 } 37150 37151 if (textColor) { 37152 const textColorObject = getColorObjectByAttributeValues(colors, textColor); 37153 colorProps.style.color = textColorObject.color; 37154 } 37155 37156 return colorProps; 37157 } 37158 37159 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/use-spacing-props.js 37160 /** 37161 * Internal dependencies 37162 */ 37163 // This utility is intended to assist where the serialization of the spacing 37164 // block support is being skipped for a block but the spacing related CSS 37165 // styles still need to be generated so they can be applied to inner elements. 37166 37167 /** 37168 * Provides the CSS class names and inline styles for a block's spacing support 37169 * attributes. 37170 * 37171 * @param {Object} attributes Block attributes. 37172 * 37173 * @return {Object} Spacing block support derived CSS classes & styles. 37174 */ 37175 37176 function getSpacingClassesAndStyles(attributes) { 37177 const { 37178 style 37179 } = attributes; // Collect inline styles for spacing. 37180 37181 const spacingStyles = (style === null || style === void 0 ? void 0 : style.spacing) || {}; 37182 const styleProp = getInlineStyles({ 37183 spacing: spacingStyles 37184 }); 37185 return { 37186 style: styleProp 37187 }; 37188 } 37189 37190 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/use-cached-truthy.js 37191 /** 37192 * WordPress dependencies 37193 */ 37194 37195 /** 37196 * Keeps an up-to-date copy of the passed value and returns it. If value becomes falsy, it will return the last truthy copy. 37197 * 37198 * @param {any} value 37199 * @return {any} value 37200 */ 37201 37202 function useCachedTruthy(value) { 37203 const [cachedValue, setCachedValue] = (0,external_wp_element_namespaceObject.useState)(value); 37204 (0,external_wp_element_namespaceObject.useEffect)(() => { 37205 if (value) { 37206 setCachedValue(value); 37207 } 37208 }, [value]); 37209 return cachedValue; 37210 } 37211 37212 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/index.js 37213 /** 37214 * Internal dependencies 37215 */ 37216 37217 37218 37219 37220 37221 37222 37223 37224 37225 37226 37227 37228 37229 37230 37231 37232 37233 37234 37235 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/with-colors.js 37236 37237 37238 37239 /** 37240 * External dependencies 37241 */ 37242 37243 /** 37244 * WordPress dependencies 37245 */ 37246 37247 37248 37249 /** 37250 * Internal dependencies 37251 */ 37252 37253 37254 37255 /** 37256 * Higher order component factory for injecting the `colorsArray` argument as 37257 * the colors prop in the `withCustomColors` HOC. 37258 * 37259 * @param {Array} colorsArray An array of color objects. 37260 * 37261 * @return {Function} The higher order component. 37262 */ 37263 37264 const withCustomColorPalette = colorsArray => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, { 37265 colors: colorsArray 37266 })), 'withCustomColorPalette'); 37267 /** 37268 * Higher order component factory for injecting the editor colors as the 37269 * `colors` prop in the `withColors` HOC. 37270 * 37271 * @return {Function} The higher order component. 37272 */ 37273 37274 37275 const withEditorColorPalette = () => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => { 37276 // Some color settings have a special handling for deprecated flags in `useSetting`, 37277 // so we can't unwrap them by doing const { ... } = useSetting('color') 37278 // until https://github.com/WordPress/gutenberg/issues/37094 is fixed. 37279 const userPalette = useSetting('color.palette.custom'); 37280 const themePalette = useSetting('color.palette.theme'); 37281 const defaultPalette = useSetting('color.palette.default'); 37282 const allColors = (0,external_wp_element_namespaceObject.useMemo)(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]); 37283 return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, { 37284 colors: allColors 37285 })); 37286 }, 'withEditorColorPalette'); 37287 /** 37288 * Helper function used with `createHigherOrderComponent` to create 37289 * higher order components for managing color logic. 37290 * 37291 * @param {Array} colorTypes An array of color types (e.g. 'backgroundColor, borderColor). 37292 * @param {Function} withColorPalette A HOC for injecting the 'colors' prop into the WrappedComponent. 37293 * 37294 * @return {WPComponent} The component that can be used as a HOC. 37295 */ 37296 37297 37298 function createColorHOC(colorTypes, withColorPalette) { 37299 const colorMap = (0,external_lodash_namespaceObject.reduce)(colorTypes, (colorObject, colorType) => { 37300 return { ...colorObject, 37301 ...((0,external_lodash_namespaceObject.isString)(colorType) ? { 37302 [colorType]: (0,external_lodash_namespaceObject.kebabCase)(colorType) 37303 } : colorType) 37304 }; 37305 }, {}); 37306 return (0,external_wp_compose_namespaceObject.compose)([withColorPalette, WrappedComponent => { 37307 return class extends external_wp_element_namespaceObject.Component { 37308 constructor(props) { 37309 super(props); 37310 this.setters = this.createSetters(); 37311 this.colorUtils = { 37312 getMostReadableColor: this.getMostReadableColor.bind(this) 37313 }; 37314 this.state = {}; 37315 } 37316 37317 getMostReadableColor(colorValue) { 37318 const { 37319 colors 37320 } = this.props; 37321 return getMostReadableColor(colors, colorValue); 37322 } 37323 37324 createSetters() { 37325 return (0,external_lodash_namespaceObject.reduce)(colorMap, (settersAccumulator, colorContext, colorAttributeName) => { 37326 const upperFirstColorAttributeName = (0,external_lodash_namespaceObject.upperFirst)(colorAttributeName); 37327 const customColorAttributeName = `custom$upperFirstColorAttributeName}`; 37328 settersAccumulator[`set$upperFirstColorAttributeName}`] = this.createSetColor(colorAttributeName, customColorAttributeName); 37329 return settersAccumulator; 37330 }, {}); 37331 } 37332 37333 createSetColor(colorAttributeName, customColorAttributeName) { 37334 return colorValue => { 37335 const colorObject = getColorObjectByColorValue(this.props.colors, colorValue); 37336 this.props.setAttributes({ 37337 [colorAttributeName]: colorObject && colorObject.slug ? colorObject.slug : undefined, 37338 [customColorAttributeName]: colorObject && colorObject.slug ? undefined : colorValue 37339 }); 37340 }; 37341 } 37342 37343 static getDerivedStateFromProps(_ref, previousState) { 37344 let { 37345 attributes, 37346 colors 37347 } = _ref; 37348 return (0,external_lodash_namespaceObject.reduce)(colorMap, (newState, colorContext, colorAttributeName) => { 37349 const colorObject = getColorObjectByAttributeValues(colors, attributes[colorAttributeName], attributes[`custom${(0,external_lodash_namespaceObject.upperFirst)(colorAttributeName)}`]); 37350 const previousColorObject = previousState[colorAttributeName]; 37351 const previousColor = previousColorObject === null || previousColorObject === void 0 ? void 0 : previousColorObject.color; 37352 /** 37353 * The "and previousColorObject" condition checks that a previous color object was already computed. 37354 * At the start previousColorObject and colorValue are both equal to undefined 37355 * bus as previousColorObject does not exist we should compute the object. 37356 */ 37357 37358 if (previousColor === colorObject.color && previousColorObject) { 37359 newState[colorAttributeName] = previousColorObject; 37360 } else { 37361 newState[colorAttributeName] = { ...colorObject, 37362 class: getColorClassName(colorContext, colorObject.slug) 37363 }; 37364 } 37365 37366 return newState; 37367 }, {}); 37368 } 37369 37370 render() { 37371 return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, this.props, { 37372 colors: undefined 37373 }, this.state, this.setters, { 37374 colorUtils: this.colorUtils 37375 })); 37376 } 37377 37378 }; 37379 }]); 37380 } 37381 /** 37382 * A higher-order component factory for creating a 'withCustomColors' HOC, which handles color logic 37383 * for class generation color value, retrieval and color attribute setting. 37384 * 37385 * Use this higher-order component to work with a custom set of colors. 37386 * 37387 * @example 37388 * 37389 * ```jsx 37390 * const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ]; 37391 * const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS ); 37392 * // ... 37393 * export default compose( 37394 * withCustomColors( 'backgroundColor', 'borderColor' ), 37395 * MyColorfulComponent, 37396 * ); 37397 * ``` 37398 * 37399 * @param {Array} colorsArray The array of color objects (name, slug, color, etc... ). 37400 * 37401 * @return {Function} Higher-order component. 37402 */ 37403 37404 37405 function createCustomColorsHOC(colorsArray) { 37406 return function () { 37407 const withColorPalette = withCustomColorPalette(colorsArray); 37408 37409 for (var _len = arguments.length, colorTypes = new Array(_len), _key = 0; _key < _len; _key++) { 37410 colorTypes[_key] = arguments[_key]; 37411 } 37412 37413 return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(createColorHOC(colorTypes, withColorPalette), 'withCustomColors'); 37414 }; 37415 } 37416 /** 37417 * A higher-order component, which handles color logic for class generation color value, retrieval and color attribute setting. 37418 * 37419 * For use with the default editor/theme color palette. 37420 * 37421 * @example 37422 * 37423 * ```jsx 37424 * export default compose( 37425 * withColors( 'backgroundColor', { textColor: 'color' } ), 37426 * MyColorfulComponent, 37427 * ); 37428 * ``` 37429 * 37430 * @param {...(Object|string)} colorTypes The arguments can be strings or objects. If the argument is an object, 37431 * it should contain the color attribute name as key and the color context as value. 37432 * If the argument is a string the value should be the color attribute name, 37433 * the color context is computed by applying a kebab case transform to the value. 37434 * Color context represents the context/place where the color is going to be used. 37435 * The class name of the color is generated using 'has' followed by the color name 37436 * and ending with the color context all in kebab case e.g: has-green-background-color. 37437 * 37438 * @return {Function} Higher-order component. 37439 */ 37440 37441 function withColors() { 37442 const withColorPalette = withEditorColorPalette(); 37443 37444 for (var _len2 = arguments.length, colorTypes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 37445 colorTypes[_key2] = arguments[_key2]; 37446 } 37447 37448 return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(createColorHOC(colorTypes, withColorPalette), 'withColors'); 37449 } 37450 37451 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/index.js 37452 37453 37454 37455 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradients/index.js 37456 37457 37458 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/with-font-sizes.js 37459 37460 37461 37462 /** 37463 * External dependencies 37464 */ 37465 37466 /** 37467 * WordPress dependencies 37468 */ 37469 37470 37471 37472 /** 37473 * Internal dependencies 37474 */ 37475 37476 37477 37478 const DEFAULT_FONT_SIZES = []; 37479 /** 37480 * Higher-order component, which handles font size logic for class generation, 37481 * font size value retrieval, and font size change handling. 37482 * 37483 * @param {...(Object|string)} fontSizeNames The arguments should all be strings. 37484 * Each string contains the font size 37485 * attribute name e.g: 'fontSize'. 37486 * 37487 * @return {Function} Higher-order component. 37488 */ 37489 37490 /* harmony default export */ var with_font_sizes = (function () { 37491 for (var _len = arguments.length, fontSizeNames = new Array(_len), _key = 0; _key < _len; _key++) { 37492 fontSizeNames[_key] = arguments[_key]; 37493 } 37494 37495 /* 37496 * Computes an object whose key is the font size attribute name as passed in the array, 37497 * and the value is the custom font size attribute name. 37498 * Custom font size is automatically compted by appending custom followed by the font size attribute name in with the first letter capitalized. 37499 */ 37500 const fontSizeAttributeNames = (0,external_lodash_namespaceObject.reduce)(fontSizeNames, (fontSizeAttributeNamesAccumulator, fontSizeAttributeName) => { 37501 fontSizeAttributeNamesAccumulator[fontSizeAttributeName] = `custom${(0,external_lodash_namespaceObject.upperFirst)(fontSizeAttributeName)}`; 37502 return fontSizeAttributeNamesAccumulator; 37503 }, {}); 37504 return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => { 37505 const fontSizes = useSetting('typography.fontSizes') || DEFAULT_FONT_SIZES; 37506 return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, { 37507 fontSizes: fontSizes 37508 })); 37509 }, 'withFontSizes'), WrappedComponent => { 37510 return class extends external_wp_element_namespaceObject.Component { 37511 constructor(props) { 37512 super(props); 37513 this.setters = this.createSetters(); 37514 this.state = {}; 37515 } 37516 37517 createSetters() { 37518 return (0,external_lodash_namespaceObject.reduce)(fontSizeAttributeNames, (settersAccumulator, customFontSizeAttributeName, fontSizeAttributeName) => { 37519 const upperFirstFontSizeAttributeName = (0,external_lodash_namespaceObject.upperFirst)(fontSizeAttributeName); 37520 settersAccumulator[`set$upperFirstFontSizeAttributeName}`] = this.createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName); 37521 return settersAccumulator; 37522 }, {}); 37523 } 37524 37525 createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName) { 37526 return fontSizeValue => { 37527 const fontSizeObject = (0,external_lodash_namespaceObject.find)(this.props.fontSizes, { 37528 size: Number(fontSizeValue) 37529 }); 37530 this.props.setAttributes({ 37531 [fontSizeAttributeName]: fontSizeObject && fontSizeObject.slug ? fontSizeObject.slug : undefined, 37532 [customFontSizeAttributeName]: fontSizeObject && fontSizeObject.slug ? undefined : fontSizeValue 37533 }); 37534 }; 37535 } 37536 37537 static getDerivedStateFromProps(_ref, previousState) { 37538 let { 37539 attributes, 37540 fontSizes 37541 } = _ref; 37542 37543 const didAttributesChange = (customFontSizeAttributeName, fontSizeAttributeName) => { 37544 if (previousState[fontSizeAttributeName]) { 37545 // If new font size is name compare with the previous slug. 37546 if (attributes[fontSizeAttributeName]) { 37547 return attributes[fontSizeAttributeName] !== previousState[fontSizeAttributeName].slug; 37548 } // If font size is not named, update when the font size value changes. 37549 37550 37551 return previousState[fontSizeAttributeName].size !== attributes[customFontSizeAttributeName]; 37552 } // In this case we need to build the font size object. 37553 37554 37555 return true; 37556 }; 37557 37558 if (!(0,external_lodash_namespaceObject.some)(fontSizeAttributeNames, didAttributesChange)) { 37559 return null; 37560 } 37561 37562 const newState = (0,external_lodash_namespaceObject.reduce)((0,external_lodash_namespaceObject.pickBy)(fontSizeAttributeNames, didAttributesChange), (newStateAccumulator, customFontSizeAttributeName, fontSizeAttributeName) => { 37563 const fontSizeAttributeValue = attributes[fontSizeAttributeName]; 37564 const fontSizeObject = getFontSize(fontSizes, fontSizeAttributeValue, attributes[customFontSizeAttributeName]); 37565 newStateAccumulator[fontSizeAttributeName] = { ...fontSizeObject, 37566 class: getFontSizeClass(fontSizeAttributeValue) 37567 }; 37568 return newStateAccumulator; 37569 }, {}); 37570 return { ...previousState, 37571 ...newState 37572 }; 37573 } 37574 37575 render() { 37576 return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, this.props, { 37577 fontSizes: undefined 37578 }, this.state, this.setters)); 37579 } 37580 37581 }; 37582 }]), 'withFontSizes'); 37583 }); 37584 37585 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/index.js 37586 37587 37588 37589 37590 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/align-left.js 37591 37592 37593 /** 37594 * WordPress dependencies 37595 */ 37596 37597 const alignLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 37598 xmlns: "http://www.w3.org/2000/svg", 37599 viewBox: "0 0 24 24" 37600 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 37601 d: "M4 19.8h8.9v-1.5H4v1.5zm8.9-15.6H4v1.5h8.9V4.2zm-8.9 7v1.5h16v-1.5H4z" 37602 })); 37603 /* harmony default export */ var align_left = (alignLeft); 37604 37605 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/align-center.js 37606 37607 37608 /** 37609 * WordPress dependencies 37610 */ 37611 37612 const align_center_alignCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 37613 xmlns: "http://www.w3.org/2000/svg", 37614 viewBox: "0 0 24 24" 37615 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 37616 d: "M16.4 4.2H7.6v1.5h8.9V4.2zM4 11.2v1.5h16v-1.5H4zm3.6 8.6h8.9v-1.5H7.6v1.5z" 37617 })); 37618 /* harmony default export */ var align_center = (align_center_alignCenter); 37619 37620 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/align-right.js 37621 37622 37623 /** 37624 * WordPress dependencies 37625 */ 37626 37627 const alignRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 37628 xmlns: "http://www.w3.org/2000/svg", 37629 viewBox: "0 0 24 24" 37630 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 37631 d: "M11.1 19.8H20v-1.5h-8.9v1.5zm0-15.6v1.5H20V4.2h-8.9zM4 12.8h16v-1.5H4v1.5z" 37632 })); 37633 /* harmony default export */ var align_right = (alignRight); 37634 37635 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/alignment-control/ui.js 37636 37637 37638 37639 /** 37640 * External dependencies 37641 */ 37642 37643 /** 37644 * WordPress dependencies 37645 */ 37646 37647 37648 37649 37650 const DEFAULT_ALIGNMENT_CONTROLS = [{ 37651 icon: align_left, 37652 title: (0,external_wp_i18n_namespaceObject.__)('Align text left'), 37653 align: 'left' 37654 }, { 37655 icon: align_center, 37656 title: (0,external_wp_i18n_namespaceObject.__)('Align text center'), 37657 align: 'center' 37658 }, { 37659 icon: align_right, 37660 title: (0,external_wp_i18n_namespaceObject.__)('Align text right'), 37661 align: 'right' 37662 }]; 37663 const alignment_control_ui_POPOVER_PROPS = { 37664 position: 'bottom right', 37665 isAlternate: true 37666 }; 37667 37668 function AlignmentUI(_ref) { 37669 let { 37670 value, 37671 onChange, 37672 alignmentControls = DEFAULT_ALIGNMENT_CONTROLS, 37673 label = (0,external_wp_i18n_namespaceObject.__)('Align'), 37674 describedBy = (0,external_wp_i18n_namespaceObject.__)('Change text alignment'), 37675 isCollapsed = true, 37676 isToolbar 37677 } = _ref; 37678 37679 function applyOrUnset(align) { 37680 return () => onChange(value === align ? undefined : align); 37681 } 37682 37683 const activeAlignment = (0,external_lodash_namespaceObject.find)(alignmentControls, control => control.align === value); 37684 37685 function setIcon() { 37686 if (activeAlignment) return activeAlignment.icon; 37687 return (0,external_wp_i18n_namespaceObject.isRTL)() ? align_right : align_left; 37688 } 37689 37690 const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu; 37691 const extraProps = isToolbar ? { 37692 isCollapsed 37693 } : {}; 37694 return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({ 37695 icon: setIcon(), 37696 label: label, 37697 toggleProps: { 37698 describedBy 37699 }, 37700 popoverProps: alignment_control_ui_POPOVER_PROPS, 37701 controls: alignmentControls.map(control => { 37702 const { 37703 align 37704 } = control; 37705 const isActive = value === align; 37706 return { ...control, 37707 isActive, 37708 role: isCollapsed ? 'menuitemradio' : undefined, 37709 onClick: applyOrUnset(align) 37710 }; 37711 }) 37712 }, extraProps)); 37713 } 37714 37715 /* harmony default export */ var alignment_control_ui = (AlignmentUI); 37716 37717 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/alignment-control/index.js 37718 37719 37720 37721 /** 37722 * Internal dependencies 37723 */ 37724 37725 37726 const AlignmentControl = props => { 37727 return (0,external_wp_element_namespaceObject.createElement)(alignment_control_ui, _extends({}, props, { 37728 isToolbar: false 37729 })); 37730 }; 37731 37732 const AlignmentToolbar = props => { 37733 return (0,external_wp_element_namespaceObject.createElement)(alignment_control_ui, _extends({}, props, { 37734 isToolbar: true 37735 })); 37736 }; 37737 /** 37738 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/alignment-control/README.md 37739 */ 37740 37741 37742 37743 37744 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/autocompleters/block.js 37745 37746 37747 /** 37748 * External dependencies 37749 */ 37750 37751 /** 37752 * WordPress dependencies 37753 */ 37754 37755 37756 37757 37758 /** 37759 * Internal dependencies 37760 */ 37761 37762 37763 37764 37765 37766 const block_SHOWN_BLOCK_TYPES = 9; 37767 /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */ 37768 37769 /** 37770 * Creates a blocks repeater for replacing the current block with a selected block type. 37771 * 37772 * @return {WPCompleter} A blocks completer. 37773 */ 37774 37775 function createBlockCompleter() { 37776 return { 37777 name: 'blocks', 37778 className: 'block-editor-autocompleters__block', 37779 triggerPrefix: '/', 37780 37781 useItems(filterValue) { 37782 const { 37783 rootClientId, 37784 selectedBlockName 37785 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 37786 const { 37787 getSelectedBlockClientId, 37788 getBlockName, 37789 getBlockInsertionPoint 37790 } = select(store); 37791 const selectedBlockClientId = getSelectedBlockClientId(); 37792 return { 37793 selectedBlockName: selectedBlockClientId ? getBlockName(selectedBlockClientId) : null, 37794 rootClientId: getBlockInsertionPoint().rootClientId 37795 }; 37796 }, []); 37797 const [items, categories, collections] = use_block_types_state(rootClientId, external_lodash_namespaceObject.noop); 37798 const filteredItems = (0,external_wp_element_namespaceObject.useMemo)(() => { 37799 const initialFilteredItems = !!filterValue.trim() ? searchBlockItems(items, categories, collections, filterValue) : (0,external_lodash_namespaceObject.orderBy)(items, ['frecency'], ['desc']); 37800 return initialFilteredItems.filter(item => item.name !== selectedBlockName).slice(0, block_SHOWN_BLOCK_TYPES); 37801 }, [filterValue, selectedBlockName, items, categories, collections]); 37802 const options = (0,external_wp_element_namespaceObject.useMemo)(() => filteredItems.map(blockItem => { 37803 const { 37804 title, 37805 icon, 37806 isDisabled 37807 } = blockItem; 37808 return { 37809 key: `block-$blockItem.id}`, 37810 value: blockItem, 37811 label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(block_icon, { 37812 key: "icon", 37813 icon: icon, 37814 showColors: true 37815 }), title), 37816 isDisabled 37817 }; 37818 }), [filteredItems]); 37819 return [options]; 37820 }, 37821 37822 allowContext(before, after) { 37823 return !(/\S/.test(before) || /\S/.test(after)); 37824 }, 37825 37826 getOptionCompletion(inserterItem) { 37827 const { 37828 name, 37829 initialAttributes, 37830 innerBlocks 37831 } = inserterItem; 37832 return { 37833 action: 'replace', 37834 value: (0,external_wp_blocks_namespaceObject.createBlock)(name, initialAttributes, (0,external_wp_blocks_namespaceObject.createBlocksFromInnerBlocksTemplate)(innerBlocks)) 37835 }; 37836 } 37837 37838 }; 37839 } 37840 /** 37841 * Creates a blocks repeater for replacing the current block with a selected block type. 37842 * 37843 * @return {WPCompleter} A blocks completer. 37844 */ 37845 37846 37847 /* harmony default export */ var autocompleters_block = (createBlockCompleter()); 37848 37849 ;// CONCATENATED MODULE: external ["wp","apiFetch"] 37850 var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"]; 37851 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject); 37852 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/page.js 37853 37854 37855 /** 37856 * WordPress dependencies 37857 */ 37858 37859 const page = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 37860 xmlns: "http://www.w3.org/2000/svg", 37861 viewBox: "0 0 24 24" 37862 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 37863 d: "M7 5.5h10a.5.5 0 01.5.5v12a.5.5 0 01-.5.5H7a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM17 4H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V6a2 2 0 00-2-2zm-1 3.75H8v1.5h8v-1.5zM8 11h8v1.5H8V11zm6 3.25H8v1.5h6v-1.5z" 37864 })); 37865 /* harmony default export */ var library_page = (page); 37866 37867 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/post.js 37868 37869 37870 /** 37871 * WordPress dependencies 37872 */ 37873 37874 const post = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 37875 xmlns: "http://www.w3.org/2000/svg", 37876 viewBox: "0 0 24 24" 37877 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 37878 d: "m7.3 9.7 1.4 1.4c.2-.2.3-.3.4-.5 0 0 0-.1.1-.1.3-.5.4-1.1.3-1.6L12 7 9 4 7.2 6.5c-.6-.1-1.1 0-1.6.3 0 0-.1 0-.1.1-.3.1-.4.2-.6.4l1.4 1.4L4 11v1h1l2.3-2.3zM4 20h9v-1.5H4V20zm0-5.5V16h16v-1.5H4z" 37879 })); 37880 /* harmony default export */ var library_post = (post); 37881 37882 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/autocompleters/link.js 37883 37884 37885 /** 37886 * WordPress dependencies 37887 */ 37888 37889 37890 37891 const SHOWN_SUGGESTIONS = 10; 37892 /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */ 37893 37894 /** 37895 * Creates a suggestion list for links to posts or pages. 37896 * 37897 * @return {WPCompleter} A links completer. 37898 */ 37899 37900 function createLinkCompleter() { 37901 return { 37902 name: 'links', 37903 className: 'block-editor-autocompleters__link', 37904 triggerPrefix: '[[', 37905 options: async letters => { 37906 let options = await external_wp_apiFetch_default()({ 37907 path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/search', { 37908 per_page: SHOWN_SUGGESTIONS, 37909 search: letters, 37910 type: 'post', 37911 order_by: 'menu_order' 37912 }) 37913 }); 37914 options = options.filter(option => option.title !== ''); 37915 return options; 37916 }, 37917 37918 getOptionKeywords(item) { 37919 const expansionWords = item.title.split(/\s+/); 37920 return [...expansionWords]; 37921 }, 37922 37923 getOptionLabel(item) { 37924 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { 37925 key: "icon", 37926 icon: item.subtype === 'page' ? library_page : library_post 37927 }), item.title); 37928 }, 37929 37930 getOptionCompletion(item) { 37931 return (0,external_wp_element_namespaceObject.createElement)("a", { 37932 href: item.url 37933 }, item.title); 37934 } 37935 37936 }; 37937 } 37938 /** 37939 * Creates a suggestion list for links to posts or pages.. 37940 * 37941 * @return {WPCompleter} A link completer. 37942 */ 37943 37944 37945 /* harmony default export */ var autocompleters_link = (createLinkCompleter()); 37946 37947 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/autocomplete/index.js 37948 37949 37950 37951 /** 37952 * External dependencies 37953 */ 37954 37955 /** 37956 * WordPress dependencies 37957 */ 37958 37959 37960 37961 37962 37963 /** 37964 * Internal dependencies 37965 */ 37966 37967 37968 37969 37970 /** 37971 * Shared reference to an empty array for cases where it is important to avoid 37972 * returning a new array reference on every invocation. 37973 * 37974 * @type {Array} 37975 */ 37976 37977 const autocomplete_EMPTY_ARRAY = []; 37978 37979 function useCompleters(_ref) { 37980 let { 37981 completers = autocomplete_EMPTY_ARRAY 37982 } = _ref; 37983 const { 37984 name 37985 } = useBlockEditContext(); 37986 return (0,external_wp_element_namespaceObject.useMemo)(() => { 37987 let filteredCompleters = completers; 37988 37989 if (name === (0,external_wp_blocks_namespaceObject.getDefaultBlockName)() || (0,external_wp_blocks_namespaceObject.getBlockSupport)(name, '__experimentalSlashInserter', false)) { 37990 filteredCompleters = filteredCompleters.concat([autocompleters_block, autocompleters_link]); 37991 } 37992 37993 if ((0,external_wp_hooks_namespaceObject.hasFilter)('editor.Autocomplete.completers')) { 37994 // Provide copies so filters may directly modify them. 37995 if (filteredCompleters === completers) { 37996 filteredCompleters = filteredCompleters.map(external_lodash_namespaceObject.clone); 37997 } 37998 37999 filteredCompleters = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.Autocomplete.completers', filteredCompleters, name); 38000 } 38001 38002 return filteredCompleters; 38003 }, [completers, name]); 38004 } 38005 38006 function useBlockEditorAutocompleteProps(props) { 38007 return (0,external_wp_components_namespaceObject.__unstableUseAutocompleteProps)({ ...props, 38008 completers: useCompleters(props) 38009 }); 38010 } 38011 /** 38012 * Wrap the default Autocomplete component with one that supports a filter hook 38013 * for customizing its list of autocompleters. 38014 * 38015 * @type {import('react').FC} 38016 */ 38017 38018 function BlockEditorAutocomplete(props) { 38019 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Autocomplete, _extends({}, props, { 38020 completers: useCompleters(props) 38021 })); 38022 } 38023 /** 38024 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/autocomplete/README.md 38025 */ 38026 38027 38028 /* harmony default export */ var autocomplete = (BlockEditorAutocomplete); 38029 38030 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/fullscreen.js 38031 38032 38033 /** 38034 * WordPress dependencies 38035 */ 38036 38037 const fullscreen = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 38038 xmlns: "http://www.w3.org/2000/svg", 38039 viewBox: "0 0 24 24" 38040 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 38041 d: "M4.2 9h1.5V5.8H9V4.2H4.2V9zm14 9.2H15v1.5h4.8V15h-1.5v3.2zM15 4.2v1.5h3.2V9h1.5V4.2H15zM5.8 15H4.2v4.8H9v-1.5H5.8V15z" 38042 })); 38043 /* harmony default export */ var library_fullscreen = (fullscreen); 38044 38045 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-full-height-alignment-control/index.js 38046 38047 38048 /** 38049 * WordPress dependencies 38050 */ 38051 38052 38053 38054 38055 function BlockFullHeightAlignmentControl(_ref) { 38056 let { 38057 isActive, 38058 label = (0,external_wp_i18n_namespaceObject.__)('Toggle full height'), 38059 onToggle, 38060 isDisabled 38061 } = _ref; 38062 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 38063 isActive: isActive, 38064 icon: library_fullscreen, 38065 label: label, 38066 onClick: () => onToggle(!isActive), 38067 disabled: isDisabled 38068 }); 38069 } 38070 38071 /* harmony default export */ var block_full_height_alignment_control = (BlockFullHeightAlignmentControl); 38072 38073 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-matrix-control/index.js 38074 38075 38076 /** 38077 * External dependencies 38078 */ 38079 38080 /** 38081 * WordPress dependencies 38082 */ 38083 38084 38085 38086 38087 38088 function BlockAlignmentMatrixControl(props) { 38089 const { 38090 label = (0,external_wp_i18n_namespaceObject.__)('Change matrix alignment'), 38091 onChange = external_lodash_namespaceObject.noop, 38092 value = 'center', 38093 isDisabled 38094 } = props; 38095 const icon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalAlignmentMatrixControl.Icon, { 38096 value: value 38097 }); 38098 const className = 'block-editor-block-alignment-matrix-control'; 38099 const popoverClassName = `$className}__popover`; 38100 const isAlternate = true; 38101 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, { 38102 position: "bottom right", 38103 className: className, 38104 popoverProps: { 38105 className: popoverClassName, 38106 isAlternate 38107 }, 38108 renderToggle: _ref => { 38109 let { 38110 onToggle, 38111 isOpen 38112 } = _ref; 38113 38114 const openOnArrowDown = event => { 38115 if (!isOpen && event.keyCode === external_wp_keycodes_namespaceObject.DOWN) { 38116 event.preventDefault(); 38117 onToggle(); 38118 } 38119 }; 38120 38121 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 38122 onClick: onToggle, 38123 "aria-haspopup": "true", 38124 "aria-expanded": isOpen, 38125 onKeyDown: openOnArrowDown, 38126 label: label, 38127 icon: icon, 38128 showTooltip: true, 38129 disabled: isDisabled 38130 }); 38131 }, 38132 renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalAlignmentMatrixControl, { 38133 hasFocusBorder: false, 38134 onChange: onChange, 38135 value: value 38136 }) 38137 }); 38138 } 38139 38140 /* harmony default export */ var block_alignment_matrix_control = (BlockAlignmentMatrixControl); 38141 38142 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-right-small.js 38143 38144 38145 /** 38146 * WordPress dependencies 38147 */ 38148 38149 const chevronRightSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 38150 xmlns: "http://www.w3.org/2000/svg", 38151 viewBox: "0 0 24 24" 38152 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 38153 d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z" 38154 })); 38155 /* harmony default export */ var chevron_right_small = (chevronRightSmall); 38156 38157 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-breadcrumb/index.js 38158 38159 38160 /** 38161 * WordPress dependencies 38162 */ 38163 38164 38165 38166 38167 /** 38168 * Internal dependencies 38169 */ 38170 38171 38172 38173 /** 38174 * Block breadcrumb component, displaying the hierarchy of the current block selection as a breadcrumb. 38175 * 38176 * @param {Object} props Component props. 38177 * @param {string} props.rootLabelText Translated label for the root element of the breadcrumb trail. 38178 * @return {WPElement} Block Breadcrumb. 38179 */ 38180 38181 function BlockBreadcrumb(_ref) { 38182 let { 38183 rootLabelText 38184 } = _ref; 38185 const { 38186 selectBlock, 38187 clearSelectedBlock 38188 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 38189 const { 38190 clientId, 38191 parents, 38192 hasSelection 38193 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 38194 const { 38195 getSelectionStart, 38196 getSelectedBlockClientId, 38197 getBlockParents 38198 } = select(store); 38199 const selectedBlockClientId = getSelectedBlockClientId(); 38200 return { 38201 parents: getBlockParents(selectedBlockClientId), 38202 clientId: selectedBlockClientId, 38203 hasSelection: !!getSelectionStart().clientId 38204 }; 38205 }, []); 38206 38207 const rootLabel = rootLabelText || (0,external_wp_i18n_namespaceObject.__)('Document'); 38208 /* 38209 * Disable reason: The `list` ARIA role is redundant but 38210 * Safari+VoiceOver won't announce the list otherwise. 38211 */ 38212 38213 /* eslint-disable jsx-a11y/no-redundant-roles */ 38214 38215 38216 return (0,external_wp_element_namespaceObject.createElement)("ul", { 38217 className: "block-editor-block-breadcrumb", 38218 role: "list", 38219 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block breadcrumb') 38220 }, (0,external_wp_element_namespaceObject.createElement)("li", { 38221 className: !hasSelection ? 'block-editor-block-breadcrumb__current' : undefined, 38222 "aria-current": !hasSelection ? 'true' : undefined 38223 }, hasSelection && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 38224 className: "block-editor-block-breadcrumb__button", 38225 variant: "tertiary", 38226 onClick: clearSelectedBlock 38227 }, rootLabel), !hasSelection && rootLabel, !!clientId && (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { 38228 icon: chevron_right_small, 38229 className: "block-editor-block-breadcrumb__separator" 38230 })), parents.map(parentClientId => (0,external_wp_element_namespaceObject.createElement)("li", { 38231 key: parentClientId 38232 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 38233 className: "block-editor-block-breadcrumb__button", 38234 variant: "tertiary", 38235 onClick: () => selectBlock(parentClientId) 38236 }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, { 38237 clientId: parentClientId, 38238 maximumLength: 35 38239 })), (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { 38240 icon: chevron_right_small, 38241 className: "block-editor-block-breadcrumb__separator" 38242 }))), !!clientId && (0,external_wp_element_namespaceObject.createElement)("li", { 38243 className: "block-editor-block-breadcrumb__current", 38244 "aria-current": "true" 38245 }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, { 38246 clientId: clientId, 38247 maximumLength: 35 38248 }))) 38249 /* eslint-enable jsx-a11y/no-redundant-roles */ 38250 ; 38251 } 38252 38253 /* harmony default export */ var block_breadcrumb = (BlockBreadcrumb); 38254 38255 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-content-overlay/index.js 38256 38257 38258 38259 /** 38260 * WordPress dependencies 38261 */ 38262 38263 38264 /** 38265 * Internal dependencies 38266 */ 38267 38268 38269 /** 38270 * External dependencies 38271 */ 38272 38273 38274 function BlockContentOverlay(_ref) { 38275 let { 38276 clientId, 38277 tagName: TagName = 'div', 38278 wrapperProps, 38279 className 38280 } = _ref; 38281 const baseClassName = 'block-editor-block-content-overlay'; 38282 const [isOverlayActive, setIsOverlayActive] = (0,external_wp_element_namespaceObject.useState)(true); 38283 const [isHovered, setIsHovered] = (0,external_wp_element_namespaceObject.useState)(false); 38284 const { 38285 isParentSelected, 38286 hasChildSelected, 38287 isDraggingBlocks, 38288 isParentHighlighted 38289 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 38290 const { 38291 isBlockSelected, 38292 hasSelectedInnerBlock, 38293 isDraggingBlocks: _isDraggingBlocks, 38294 isBlockHighlighted 38295 } = select(store); 38296 return { 38297 isParentSelected: isBlockSelected(clientId), 38298 hasChildSelected: hasSelectedInnerBlock(clientId, true), 38299 isDraggingBlocks: _isDraggingBlocks(), 38300 isParentHighlighted: isBlockHighlighted(clientId) 38301 }; 38302 }, [clientId]); 38303 const classes = classnames_default()(baseClassName, wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.className, className, { 38304 'overlay-active': isOverlayActive, 38305 'parent-highlighted': isParentHighlighted, 38306 'is-dragging-blocks': isDraggingBlocks 38307 }); 38308 (0,external_wp_element_namespaceObject.useEffect)(() => { 38309 // Reenable when blocks are not in use. 38310 if (!isParentSelected && !hasChildSelected && !isOverlayActive) { 38311 setIsOverlayActive(true); 38312 } // Disable if parent selected by another means (such as list view). 38313 // We check hover to ensure the overlay click interaction is not taking place. 38314 // Trying to click the overlay will select the parent block via its 'focusin' 38315 // listener on the wrapper, so if the block is selected while hovered we will 38316 // let the mouseup disable the overlay instead. 38317 38318 38319 if (isParentSelected && !isHovered && isOverlayActive) { 38320 setIsOverlayActive(false); 38321 } // Ensure overlay is disabled if a child block is selected. 38322 38323 38324 if (hasChildSelected && isOverlayActive) { 38325 setIsOverlayActive(false); 38326 } 38327 }, [isParentSelected, hasChildSelected, isOverlayActive, isHovered]); // Disabled because the overlay div doesn't actually have a role or functionality 38328 // as far as the a11y is concerned. We're just catching the first click so that 38329 // the block can be selected without interacting with its contents. 38330 38331 /* eslint-disable jsx-a11y/no-static-element-interactions */ 38332 38333 return (0,external_wp_element_namespaceObject.createElement)(TagName, _extends({}, wrapperProps, { 38334 className: classes, 38335 onMouseEnter: () => setIsHovered(true), 38336 onMouseLeave: () => setIsHovered(false), 38337 onMouseUp: isOverlayActive ? () => setIsOverlayActive(false) : undefined 38338 }), wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.children); 38339 } 38340 /* eslint-enable jsx-a11y/no-static-element-interactions */ 38341 38342 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-style-selector/index.js 38343 38344 38345 /** 38346 * WordPress dependencies 38347 */ 38348 38349 38350 38351 38352 const ColorSelectorSVGIcon = () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, { 38353 xmlns: "https://www.w3.org/2000/svg", 38354 viewBox: "0 0 20 20" 38355 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, { 38356 d: "M7.434 5l3.18 9.16H8.538l-.692-2.184H4.628l-.705 2.184H2L5.18 5h2.254zm-1.13 1.904h-.115l-1.148 3.593H7.44L6.304 6.904zM14.348 7.006c1.853 0 2.9.876 2.9 2.374v4.78h-1.79v-.914h-.114c-.362.64-1.123 1.022-2.031 1.022-1.346 0-2.292-.826-2.292-2.108 0-1.27.972-2.006 2.71-2.107l1.696-.102V9.38c0-.584-.42-.914-1.18-.914-.667 0-1.112.228-1.264.647h-1.701c.12-1.295 1.307-2.107 3.066-2.107zm1.079 4.1l-1.416.09c-.793.056-1.18.342-1.18.844 0 .52.45.837 1.091.837.857 0 1.505-.545 1.505-1.256v-.515z" 38357 })); 38358 /** 38359 * Color Selector Icon component. 38360 * 38361 * @param {Object} props Component properties. 38362 * @param {Object} props.style Style object. 38363 * @param {string} props.className Class name for component. 38364 * 38365 * @return {*} React Icon component. 38366 */ 38367 38368 38369 const ColorSelectorIcon = _ref => { 38370 let { 38371 style, 38372 className 38373 } = _ref; 38374 return (0,external_wp_element_namespaceObject.createElement)("div", { 38375 className: "block-library-colors-selector__icon-container" 38376 }, (0,external_wp_element_namespaceObject.createElement)("div", { 38377 className: `$className} block-library-colors-selector__state-selection`, 38378 style: style 38379 }, (0,external_wp_element_namespaceObject.createElement)(ColorSelectorSVGIcon, null))); 38380 }; 38381 /** 38382 * Renders the Colors Selector Toolbar with the icon button. 38383 * 38384 * @param {Object} props Component properties. 38385 * @param {Object} props.TextColor Text color component that wraps icon. 38386 * @param {Object} props.BackgroundColor Background color component that wraps icon. 38387 * 38388 * @return {*} React toggle button component. 38389 */ 38390 38391 38392 const renderToggleComponent = _ref2 => { 38393 let { 38394 TextColor, 38395 BackgroundColor 38396 } = _ref2; 38397 return _ref3 => { 38398 let { 38399 onToggle, 38400 isOpen 38401 } = _ref3; 38402 38403 const openOnArrowDown = event => { 38404 if (!isOpen && event.keyCode === external_wp_keycodes_namespaceObject.DOWN) { 38405 event.preventDefault(); 38406 onToggle(); 38407 } 38408 }; 38409 38410 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 38411 className: "components-toolbar__control block-library-colors-selector__toggle", 38412 label: (0,external_wp_i18n_namespaceObject.__)('Open Colors Selector'), 38413 onClick: onToggle, 38414 onKeyDown: openOnArrowDown, 38415 icon: (0,external_wp_element_namespaceObject.createElement)(BackgroundColor, null, (0,external_wp_element_namespaceObject.createElement)(TextColor, null, (0,external_wp_element_namespaceObject.createElement)(ColorSelectorIcon, null))) 38416 })); 38417 }; 38418 }; 38419 38420 const BlockColorsStyleSelector = _ref4 => { 38421 let { 38422 children, 38423 ...other 38424 } = _ref4; 38425 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, { 38426 position: "bottom right", 38427 className: "block-library-colors-selector", 38428 contentClassName: "block-library-colors-selector__popover", 38429 renderToggle: renderToggleComponent(other), 38430 renderContent: () => children 38431 }); 38432 }; 38433 38434 /* harmony default export */ var color_style_selector = (BlockColorsStyleSelector); 38435 38436 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/list-view.js 38437 38438 38439 /** 38440 * WordPress dependencies 38441 */ 38442 38443 const listView = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 38444 viewBox: "0 0 24 24", 38445 xmlns: "http://www.w3.org/2000/svg" 38446 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 38447 d: "M13.8 5.2H3v1.5h10.8V5.2zm-3.6 12v1.5H21v-1.5H10.2zm7.2-6H6.6v1.5h10.8v-1.5z" 38448 })); 38449 /* harmony default export */ var list_view = (listView); 38450 38451 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/leaf.js 38452 38453 38454 38455 /** 38456 * External dependencies 38457 */ 38458 38459 38460 /** 38461 * WordPress dependencies 38462 */ 38463 38464 38465 /** 38466 * Internal dependencies 38467 */ 38468 38469 38470 const AnimatedTreeGridRow = animated(external_wp_components_namespaceObject.__experimentalTreeGridRow); 38471 function ListViewLeaf(_ref) { 38472 let { 38473 isSelected, 38474 position, 38475 level, 38476 rowCount, 38477 children, 38478 className, 38479 path, 38480 ...props 38481 } = _ref; 38482 const ref = use_moving_animation({ 38483 isSelected, 38484 adjustScrolling: false, 38485 enableAnimation: true, 38486 triggerAnimationOnChange: path 38487 }); 38488 return (0,external_wp_element_namespaceObject.createElement)(AnimatedTreeGridRow, _extends({ 38489 ref: ref, 38490 className: classnames_default()('block-editor-list-view-leaf', className), 38491 level: level, 38492 positionInSet: position, 38493 setSize: rowCount 38494 }, props), children); 38495 } 38496 38497 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/expander.js 38498 38499 38500 /** 38501 * WordPress dependencies 38502 */ 38503 38504 function ListViewExpander(_ref) { 38505 let { 38506 onClick 38507 } = _ref; 38508 return (// Keyboard events are handled by TreeGrid see: components/src/tree-grid/index.js 38509 // 38510 // The expander component is implemented as a pseudo element in the w3 example 38511 // https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html 38512 // 38513 // We've mimicked this by adding an icon with aria-hidden set to true to hide this from the accessibility tree. 38514 // For the current tree grid implementation, please do not try to make this a button. 38515 // 38516 // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions 38517 (0,external_wp_element_namespaceObject.createElement)("span", { 38518 className: "block-editor-list-view__expander", 38519 onClick: event => onClick(event, { 38520 forceToggle: true 38521 }), 38522 "aria-hidden": "true" 38523 }, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { 38524 icon: chevron_right_small 38525 })) 38526 ); 38527 } 38528 38529 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/block-select-button.js 38530 38531 38532 /** 38533 * External dependencies 38534 */ 38535 38536 /** 38537 * WordPress dependencies 38538 */ 38539 38540 38541 38542 38543 38544 /** 38545 * Internal dependencies 38546 */ 38547 38548 38549 38550 38551 38552 38553 38554 function ListViewBlockSelectButton(_ref, ref) { 38555 let { 38556 className, 38557 block: { 38558 clientId 38559 }, 38560 onClick, 38561 onToggleExpanded, 38562 tabIndex, 38563 onFocus, 38564 onDragStart, 38565 onDragEnd, 38566 draggable 38567 } = _ref; 38568 const blockInformation = useBlockDisplayInformation(clientId); 38569 const { 38570 isLocked 38571 } = useBlockLock(clientId); // The `href` attribute triggers the browser's native HTML drag operations. 38572 // When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html. 38573 // We need to clear any HTML drag data to prevent `pasteHandler` from firing 38574 // inside the `useOnBlockDrop` hook. 38575 38576 const onDragStartHandler = event => { 38577 event.dataTransfer.clearData(); 38578 onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart(event); 38579 }; 38580 38581 function onKeyDownHandler(event) { 38582 if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER || event.keyCode === external_wp_keycodes_namespaceObject.SPACE) { 38583 onClick(event); 38584 } 38585 } 38586 38587 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 38588 className: classnames_default()('block-editor-list-view-block-select-button', className), 38589 onClick: onClick, 38590 onKeyDown: onKeyDownHandler, 38591 ref: ref, 38592 tabIndex: tabIndex, 38593 onFocus: onFocus, 38594 onDragStart: onDragStartHandler, 38595 onDragEnd: onDragEnd, 38596 draggable: draggable, 38597 href: `#block-$clientId}`, 38598 "aria-hidden": true 38599 }, (0,external_wp_element_namespaceObject.createElement)(ListViewExpander, { 38600 onClick: onToggleExpanded 38601 }), (0,external_wp_element_namespaceObject.createElement)(block_icon, { 38602 icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon, 38603 showColors: true 38604 }), (0,external_wp_element_namespaceObject.createElement)("span", { 38605 className: "block-editor-list-view-block-select-button__title" 38606 }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, { 38607 clientId: clientId, 38608 maximumLength: 35 38609 })), (blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.anchor) && (0,external_wp_element_namespaceObject.createElement)("span", { 38610 className: "block-editor-list-view-block-select-button__anchor" 38611 }, blockInformation.anchor), isLocked && (0,external_wp_element_namespaceObject.createElement)("span", { 38612 className: "block-editor-list-view-block-select-button__lock" 38613 }, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { 38614 icon: library_lock 38615 })))); 38616 } 38617 38618 /* harmony default export */ var block_select_button = ((0,external_wp_element_namespaceObject.forwardRef)(ListViewBlockSelectButton)); 38619 38620 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/block-contents.js 38621 38622 38623 38624 /** 38625 * External dependencies 38626 */ 38627 38628 /** 38629 * WordPress dependencies 38630 */ 38631 38632 38633 38634 /** 38635 * Internal dependencies 38636 */ 38637 38638 38639 38640 38641 const ListViewBlockContents = (0,external_wp_element_namespaceObject.forwardRef)((_ref, ref) => { 38642 let { 38643 onClick, 38644 onToggleExpanded, 38645 block, 38646 isSelected, 38647 position, 38648 siblingBlockCount, 38649 level, 38650 isExpanded, 38651 selectedClientIds, 38652 ...props 38653 } = _ref; 38654 const { 38655 clientId 38656 } = block; 38657 const { 38658 blockMovingClientId, 38659 selectedBlockInBlockEditor 38660 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 38661 const { 38662 hasBlockMovingClientId, 38663 getSelectedBlockClientId 38664 } = select(store); 38665 return { 38666 blockMovingClientId: hasBlockMovingClientId(), 38667 selectedBlockInBlockEditor: getSelectedBlockClientId() 38668 }; 38669 }, [clientId]); 38670 const isBlockMoveTarget = blockMovingClientId && selectedBlockInBlockEditor === clientId; 38671 const className = classnames_default()('block-editor-list-view-block-contents', { 38672 'is-dropping-before': isBlockMoveTarget 38673 }); // Only include all selected blocks if the currently clicked on block 38674 // is one of the selected blocks. This ensures that if a user attempts 38675 // to drag a block that isn't part of the selection, they're still able 38676 // to drag it and rearrange its position. 38677 38678 const draggableClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId]; 38679 return (0,external_wp_element_namespaceObject.createElement)(block_draggable, { 38680 clientIds: draggableClientIds 38681 }, _ref2 => { 38682 let { 38683 draggable, 38684 onDragStart, 38685 onDragEnd 38686 } = _ref2; 38687 return (0,external_wp_element_namespaceObject.createElement)(block_select_button, _extends({ 38688 ref: ref, 38689 className: className, 38690 block: block, 38691 onClick: onClick, 38692 onToggleExpanded: onToggleExpanded, 38693 isSelected: isSelected, 38694 position: position, 38695 siblingBlockCount: siblingBlockCount, 38696 level: level, 38697 draggable: draggable, 38698 onDragStart: onDragStart, 38699 onDragEnd: onDragEnd, 38700 isExpanded: isExpanded 38701 }, props)); 38702 }); 38703 }); 38704 /* harmony default export */ var block_contents = (ListViewBlockContents); 38705 38706 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/context.js 38707 /** 38708 * WordPress dependencies 38709 */ 38710 38711 const ListViewContext = (0,external_wp_element_namespaceObject.createContext)({ 38712 __experimentalFeatures: false, 38713 __experimentalPersistentListViewFeatures: false 38714 }); 38715 const useListViewContext = () => (0,external_wp_element_namespaceObject.useContext)(ListViewContext); 38716 38717 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/utils.js 38718 /** 38719 * External dependencies 38720 */ 38721 38722 /** 38723 * WordPress dependencies 38724 */ 38725 38726 38727 const getBlockPositionDescription = (position, siblingCount, level) => (0,external_wp_i18n_namespaceObject.sprintf)( 38728 /* translators: 1: The numerical position of the block. 2: The total number of blocks. 3. The level of nesting for the block. */ 38729 (0,external_wp_i18n_namespaceObject.__)('Block %1$d of %2$d, Level %3$d'), position, siblingCount, level); 38730 /** 38731 * Returns true if the client ID occurs within the block selection or multi-selection, 38732 * or false otherwise. 38733 * 38734 * @param {string} clientId Block client ID. 38735 * @param {string|string[]} selectedBlockClientIds Selected block client ID, or an array of multi-selected blocks client IDs. 38736 * 38737 * @return {boolean} Whether the block is in multi-selection set. 38738 */ 38739 38740 const isClientIdSelected = (clientId, selectedBlockClientIds) => (0,external_lodash_namespaceObject.isArray)(selectedBlockClientIds) && selectedBlockClientIds.length ? selectedBlockClientIds.indexOf(clientId) !== -1 : selectedBlockClientIds === clientId; 38741 /** 38742 * From a start and end clientId of potentially different nesting levels, 38743 * return the nearest-depth ids that have a common level of depth in the 38744 * nesting hierarchy. For multiple block selection, this ensure that the 38745 * selection is always at the same nesting level, and not split across 38746 * separate levels. 38747 * 38748 * @param {string} startId The first id of a selection. 38749 * @param {string} endId The end id of a selection, usually one that has been clicked on. 38750 * @param {string[]} startParents An array of ancestor ids for the start id, in descending order. 38751 * @param {string[]} endParents An array of ancestor ids for the end id, in descending order. 38752 * @return {Object} An object containing the start and end ids. 38753 */ 38754 38755 function getCommonDepthClientIds(startId, endId, startParents, endParents) { 38756 const startPath = [...startParents, startId]; 38757 const endPath = [...endParents, endId]; 38758 const depth = Math.min(startPath.length, endPath.length) - 1; 38759 const start = startPath[depth]; 38760 const end = endPath[depth]; 38761 return { 38762 start, 38763 end 38764 }; 38765 } 38766 38767 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/block.js 38768 38769 38770 /** 38771 * External dependencies 38772 */ 38773 38774 /** 38775 * WordPress dependencies 38776 */ 38777 38778 38779 38780 38781 38782 38783 38784 /** 38785 * Internal dependencies 38786 */ 38787 38788 38789 38790 38791 38792 38793 38794 38795 38796 38797 38798 function ListViewBlock(_ref) { 38799 let { 38800 block, 38801 isDragged, 38802 isSelected, 38803 isBranchSelected, 38804 selectBlock, 38805 position, 38806 level, 38807 rowCount, 38808 siblingBlockCount, 38809 showBlockMovers, 38810 path, 38811 isExpanded, 38812 selectedClientIds, 38813 preventAnnouncement 38814 } = _ref; 38815 const cellRef = (0,external_wp_element_namespaceObject.useRef)(null); 38816 const [isHovered, setIsHovered] = (0,external_wp_element_namespaceObject.useState)(false); 38817 const { 38818 clientId 38819 } = block; 38820 const isFirstSelectedBlock = isSelected && selectedClientIds[0] === clientId; 38821 const isLastSelectedBlock = isSelected && selectedClientIds[selectedClientIds.length - 1] === clientId; 38822 const { 38823 toggleBlockHighlight 38824 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 38825 const blockInformation = useBlockDisplayInformation(clientId); 38826 const { 38827 isLocked 38828 } = useBlockLock(clientId); 38829 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(ListViewBlock); 38830 const descriptionId = `list-view-block-select-button__$instanceId}`; 38831 const blockPositionDescription = getBlockPositionDescription(position, siblingBlockCount, level); 38832 38833 let blockAriaLabel = (0,external_wp_i18n_namespaceObject.__)('Link'); 38834 38835 if (blockInformation) { 38836 blockAriaLabel = isLocked ? (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: The title of the block. This string indicates a link to select the locked block. 38837 (0,external_wp_i18n_namespaceObject.__)('%s link (locked)'), blockInformation.title) : (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: The title of the block. This string indicates a link to select the block. 38838 (0,external_wp_i18n_namespaceObject.__)('%s link'), blockInformation.title); 38839 } 38840 38841 const settingsAriaLabel = blockInformation ? (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: The title of the block. 38842 (0,external_wp_i18n_namespaceObject.__)('Options for %s block'), blockInformation.title) : (0,external_wp_i18n_namespaceObject.__)('Options'); 38843 const { 38844 __experimentalFeatures: withExperimentalFeatures, 38845 __experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures, 38846 __experimentalHideContainerBlockActions: hideContainerBlockActions, 38847 isTreeGridMounted, 38848 expand, 38849 collapse 38850 } = useListViewContext(); 38851 const hasSiblings = siblingBlockCount > 0; 38852 const hasRenderedMovers = showBlockMovers && hasSiblings; 38853 const moverCellClassName = classnames_default()('block-editor-list-view-block__mover-cell', { 38854 'is-visible': isHovered || isSelected 38855 }); 38856 const listViewBlockSettingsClassName = classnames_default()('block-editor-list-view-block__menu-cell', { 38857 'is-visible': isHovered || isFirstSelectedBlock 38858 }); // If ListView has experimental features related to the Persistent List View, 38859 // only focus the selected list item on mount; otherwise the list would always 38860 // try to steal the focus from the editor canvas. 38861 38862 (0,external_wp_element_namespaceObject.useEffect)(() => { 38863 if (withExperimentalPersistentListViewFeatures && !isTreeGridMounted && isSelected) { 38864 cellRef.current.focus(); 38865 } 38866 }, []); 38867 const highlightBlock = withExperimentalPersistentListViewFeatures ? toggleBlockHighlight : () => {}; 38868 const onMouseEnter = (0,external_wp_element_namespaceObject.useCallback)(() => { 38869 setIsHovered(true); 38870 highlightBlock(clientId, true); 38871 }, [clientId, setIsHovered, highlightBlock]); 38872 const onMouseLeave = (0,external_wp_element_namespaceObject.useCallback)(() => { 38873 setIsHovered(false); 38874 highlightBlock(clientId, false); 38875 }, [clientId, setIsHovered, highlightBlock]); 38876 const selectEditorBlock = (0,external_wp_element_namespaceObject.useCallback)(event => { 38877 selectBlock(event, clientId); 38878 event.preventDefault(); 38879 }, [clientId, selectBlock]); 38880 const updateSelection = (0,external_wp_element_namespaceObject.useCallback)(newClientId => { 38881 selectBlock(undefined, newClientId); 38882 }, [selectBlock]); 38883 const toggleExpanded = (0,external_wp_element_namespaceObject.useCallback)(event => { 38884 // Prevent shift+click from opening link in a new window when toggling. 38885 event.preventDefault(); 38886 event.stopPropagation(); 38887 38888 if (isExpanded === true) { 38889 collapse(clientId); 38890 } else if (isExpanded === false) { 38891 expand(clientId); 38892 } 38893 }, [clientId, expand, collapse, isExpanded]); 38894 const showBlockActions = withExperimentalFeatures && ( // hide actions for blocks like core/widget-areas 38895 !hideContainerBlockActions || hideContainerBlockActions && level > 1); 38896 const hideBlockActions = withExperimentalFeatures && !showBlockActions; 38897 let colSpan; 38898 38899 if (hasRenderedMovers) { 38900 colSpan = 2; 38901 } else if (hideBlockActions) { 38902 colSpan = 3; 38903 } 38904 38905 const classes = classnames_default()({ 38906 'is-selected': isSelected, 38907 'is-first-selected': isFirstSelectedBlock, 38908 'is-last-selected': isLastSelectedBlock, 38909 'is-branch-selected': withExperimentalPersistentListViewFeatures && isBranchSelected, 38910 'is-dragging': isDragged, 38911 'has-single-cell': hideBlockActions 38912 }); // Only include all selected blocks if the currently clicked on block 38913 // is one of the selected blocks. This ensures that if a user attempts 38914 // to alter a block that isn't part of the selection, they're still able 38915 // to do so. 38916 38917 const dropdownClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId]; 38918 return (0,external_wp_element_namespaceObject.createElement)(ListViewLeaf, { 38919 className: classes, 38920 onMouseEnter: onMouseEnter, 38921 onMouseLeave: onMouseLeave, 38922 onFocus: onMouseEnter, 38923 onBlur: onMouseLeave, 38924 level: level, 38925 position: position, 38926 rowCount: rowCount, 38927 path: path, 38928 id: `list-view-block-$clientId}`, 38929 "data-block": clientId, 38930 isExpanded: isExpanded, 38931 "aria-selected": !!isSelected 38932 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridCell, { 38933 className: "block-editor-list-view-block__contents-cell", 38934 colSpan: colSpan, 38935 ref: cellRef, 38936 "aria-label": blockAriaLabel, 38937 "aria-selected": !!isSelected, 38938 "aria-expanded": isExpanded, 38939 "aria-describedby": descriptionId 38940 }, _ref2 => { 38941 let { 38942 ref, 38943 tabIndex, 38944 onFocus 38945 } = _ref2; 38946 return (0,external_wp_element_namespaceObject.createElement)("div", { 38947 className: "block-editor-list-view-block__contents-container" 38948 }, (0,external_wp_element_namespaceObject.createElement)(block_contents, { 38949 block: block, 38950 onClick: selectEditorBlock, 38951 onToggleExpanded: toggleExpanded, 38952 isSelected: isSelected, 38953 position: position, 38954 siblingBlockCount: siblingBlockCount, 38955 level: level, 38956 ref: ref, 38957 tabIndex: tabIndex, 38958 onFocus: onFocus, 38959 isExpanded: isExpanded, 38960 selectedClientIds: selectedClientIds, 38961 preventAnnouncement: preventAnnouncement 38962 }), (0,external_wp_element_namespaceObject.createElement)("div", { 38963 className: "block-editor-list-view-block-select-button__description", 38964 id: descriptionId 38965 }, blockPositionDescription)); 38966 }), hasRenderedMovers && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridCell, { 38967 className: moverCellClassName, 38968 withoutGridItem: true 38969 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridItem, null, _ref3 => { 38970 let { 38971 ref, 38972 tabIndex, 38973 onFocus 38974 } = _ref3; 38975 return (0,external_wp_element_namespaceObject.createElement)(BlockMoverUpButton, { 38976 orientation: "vertical", 38977 clientIds: [clientId], 38978 ref: ref, 38979 tabIndex: tabIndex, 38980 onFocus: onFocus 38981 }); 38982 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridItem, null, _ref4 => { 38983 let { 38984 ref, 38985 tabIndex, 38986 onFocus 38987 } = _ref4; 38988 return (0,external_wp_element_namespaceObject.createElement)(BlockMoverDownButton, { 38989 orientation: "vertical", 38990 clientIds: [clientId], 38991 ref: ref, 38992 tabIndex: tabIndex, 38993 onFocus: onFocus 38994 }); 38995 }))), showBlockActions && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridCell, { 38996 className: listViewBlockSettingsClassName, 38997 "aria-selected": !!isSelected 38998 }, _ref5 => { 38999 let { 39000 ref, 39001 tabIndex, 39002 onFocus 39003 } = _ref5; 39004 return (0,external_wp_element_namespaceObject.createElement)(block_settings_dropdown, { 39005 clientIds: dropdownClientIds, 39006 icon: more_vertical, 39007 label: settingsAriaLabel, 39008 toggleProps: { 39009 ref, 39010 className: 'block-editor-list-view-block__menu', 39011 tabIndex, 39012 onFocus 39013 }, 39014 disableOpenOnArrowDown: true, 39015 __experimentalSelectBlock: updateSelection 39016 }); 39017 })); 39018 } 39019 39020 /* harmony default export */ var list_view_block = ((0,external_wp_element_namespaceObject.memo)(ListViewBlock)); 39021 39022 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/branch.js 39023 39024 39025 /** 39026 * External dependencies 39027 */ 39028 39029 /** 39030 * WordPress dependencies 39031 */ 39032 39033 39034 39035 /** 39036 * Internal dependencies 39037 */ 39038 39039 39040 39041 39042 /** 39043 * Given a block, returns the total number of blocks in that subtree. This is used to help determine 39044 * the list position of a block. 39045 * 39046 * When a block is collapsed, we do not count their children as part of that total. In the current drag 39047 * implementation dragged blocks and their children are not counted. 39048 * 39049 * @param {Object} block block tree 39050 * @param {Object} expandedState state that notes which branches are collapsed 39051 * @param {Array} draggedClientIds a list of dragged client ids 39052 * @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state. 39053 * @return {number} block count 39054 */ 39055 39056 function countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault) { 39057 var _expandedState$block$; 39058 39059 const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId); 39060 39061 if (isDragged) { 39062 return 0; 39063 } 39064 39065 const isExpanded = (_expandedState$block$ = expandedState[block.clientId]) !== null && _expandedState$block$ !== void 0 ? _expandedState$block$ : isExpandedByDefault; 39066 39067 if (isExpanded) { 39068 return 1 + block.innerBlocks.reduce(countReducer(expandedState, draggedClientIds, isExpandedByDefault), 0); 39069 } 39070 39071 return 1; 39072 } 39073 39074 const countReducer = (expandedState, draggedClientIds, isExpandedByDefault) => (count, block) => { 39075 var _expandedState$block$2; 39076 39077 const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId); 39078 39079 if (isDragged) { 39080 return count; 39081 } 39082 39083 const isExpanded = (_expandedState$block$2 = expandedState[block.clientId]) !== null && _expandedState$block$2 !== void 0 ? _expandedState$block$2 : isExpandedByDefault; 39084 39085 if (isExpanded && block.innerBlocks.length > 0) { 39086 return count + countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault); 39087 } 39088 39089 return count + 1; 39090 }; 39091 39092 function ListViewBranch(props) { 39093 const { 39094 blocks, 39095 selectBlock, 39096 showBlockMovers, 39097 showNestedBlocks, 39098 selectedClientIds, 39099 level = 1, 39100 path = '', 39101 isBranchSelected = false, 39102 listPosition = 0, 39103 fixedListWindow, 39104 expandNested 39105 } = props; 39106 const { 39107 expandedState, 39108 draggedClientIds, 39109 __experimentalPersistentListViewFeatures 39110 } = useListViewContext(); 39111 const filteredBlocks = (0,external_lodash_namespaceObject.compact)(blocks); 39112 const blockCount = filteredBlocks.length; 39113 let nextPosition = listPosition; 39114 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, filteredBlocks.map((block, index) => { 39115 var _expandedState$client; 39116 39117 const { 39118 clientId, 39119 innerBlocks 39120 } = block; 39121 39122 if (index > 0) { 39123 nextPosition += countBlocks(filteredBlocks[index - 1], expandedState, draggedClientIds, expandNested); 39124 } 39125 39126 const usesWindowing = __experimentalPersistentListViewFeatures; 39127 const { 39128 itemInView 39129 } = fixedListWindow; 39130 const blockInView = !usesWindowing || itemInView(nextPosition); 39131 const position = index + 1; 39132 const updatedPath = path.length > 0 ? `$path}_$position}` : `$position}`; 39133 const hasNestedBlocks = showNestedBlocks && !!innerBlocks && !!innerBlocks.length; 39134 const isExpanded = hasNestedBlocks ? (_expandedState$client = expandedState[clientId]) !== null && _expandedState$client !== void 0 ? _expandedState$client : expandNested : undefined; 39135 const isDragged = !!(draggedClientIds !== null && draggedClientIds !== void 0 && draggedClientIds.includes(clientId)); 39136 const showBlock = isDragged || blockInView; // Make updates to the selected or dragged blocks synchronous, 39137 // but asynchronous for any other block. 39138 39139 const isSelected = isClientIdSelected(clientId, selectedClientIds); 39140 const isSelectedBranch = isBranchSelected || isSelected && hasNestedBlocks; 39141 return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, { 39142 key: clientId, 39143 value: !isSelected 39144 }, showBlock && (0,external_wp_element_namespaceObject.createElement)(list_view_block, { 39145 block: block, 39146 selectBlock: selectBlock, 39147 isSelected: isSelected, 39148 isBranchSelected: isSelectedBranch, 39149 isDragged: isDragged, 39150 level: level, 39151 position: position, 39152 rowCount: blockCount, 39153 siblingBlockCount: blockCount, 39154 showBlockMovers: showBlockMovers, 39155 path: updatedPath, 39156 isExpanded: isExpanded, 39157 listPosition: nextPosition, 39158 selectedClientIds: selectedClientIds 39159 }), !showBlock && (0,external_wp_element_namespaceObject.createElement)("tr", null, (0,external_wp_element_namespaceObject.createElement)("td", { 39160 className: "block-editor-list-view-placeholder" 39161 })), hasNestedBlocks && isExpanded && !isDragged && (0,external_wp_element_namespaceObject.createElement)(ListViewBranch, { 39162 blocks: innerBlocks, 39163 selectBlock: selectBlock, 39164 showBlockMovers: showBlockMovers, 39165 showNestedBlocks: showNestedBlocks, 39166 level: level + 1, 39167 path: updatedPath, 39168 listPosition: nextPosition + 1, 39169 fixedListWindow: fixedListWindow, 39170 isBranchSelected: isSelectedBranch, 39171 selectedClientIds: selectedClientIds, 39172 expandNested: expandNested 39173 })); 39174 })); 39175 } 39176 39177 ListViewBranch.defaultProps = { 39178 selectBlock: () => {} 39179 }; 39180 /* harmony default export */ var branch = ((0,external_wp_element_namespaceObject.memo)(ListViewBranch)); 39181 39182 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/drop-indicator.js 39183 39184 39185 /** 39186 * WordPress dependencies 39187 */ 39188 39189 39190 function ListViewDropIndicator(_ref) { 39191 let { 39192 listViewRef, 39193 blockDropTarget 39194 } = _ref; 39195 const { 39196 rootClientId, 39197 clientId, 39198 dropPosition 39199 } = blockDropTarget || {}; 39200 const [rootBlockElement, blockElement] = (0,external_wp_element_namespaceObject.useMemo)(() => { 39201 if (!listViewRef.current) { 39202 return []; 39203 } // The rootClientId will be defined whenever dropping into inner 39204 // block lists, but is undefined when dropping at the root level. 39205 39206 39207 const _rootBlockElement = rootClientId ? listViewRef.current.querySelector(`[data-block="$rootClientId}"]`) : undefined; // The clientId represents the sibling block, the dragged block will 39208 // usually be inserted adjacent to it. It will be undefined when 39209 // dropping a block into an empty block list. 39210 39211 39212 const _blockElement = clientId ? listViewRef.current.querySelector(`[data-block="$clientId}"]`) : undefined; 39213 39214 return [_rootBlockElement, _blockElement]; 39215 }, [rootClientId, clientId]); // The targetElement is the element that the drop indicator will appear 39216 // before or after. When dropping into an empty block list, blockElement 39217 // is undefined, so the indicator will appear after the rootBlockElement. 39218 39219 const targetElement = blockElement || rootBlockElement; 39220 const getDropIndicatorIndent = (0,external_wp_element_namespaceObject.useCallback)(() => { 39221 if (!rootBlockElement) { 39222 return 0; 39223 } // Calculate the indent using the block icon of the root block. 39224 // Using a classname selector here might be flaky and could be 39225 // improved. 39226 39227 39228 const targetElementRect = targetElement.getBoundingClientRect(); 39229 const rootBlockIconElement = rootBlockElement.querySelector('.block-editor-block-icon'); 39230 const rootBlockIconRect = rootBlockIconElement.getBoundingClientRect(); 39231 return rootBlockIconRect.right - targetElementRect.left; 39232 }, [rootBlockElement, targetElement]); 39233 const style = (0,external_wp_element_namespaceObject.useMemo)(() => { 39234 if (!targetElement) { 39235 return {}; 39236 } 39237 39238 const indent = getDropIndicatorIndent(); 39239 return { 39240 width: targetElement.offsetWidth - indent 39241 }; 39242 }, [getDropIndicatorIndent, targetElement]); 39243 const getAnchorRect = (0,external_wp_element_namespaceObject.useCallback)(() => { 39244 if (!targetElement) { 39245 return {}; 39246 } 39247 39248 const ownerDocument = targetElement.ownerDocument; 39249 const rect = targetElement.getBoundingClientRect(); 39250 const indent = getDropIndicatorIndent(); 39251 const anchorRect = { 39252 left: rect.left + indent, 39253 right: rect.right, 39254 width: 0, 39255 height: rect.height, 39256 ownerDocument 39257 }; 39258 39259 if (dropPosition === 'top') { 39260 return { ...anchorRect, 39261 top: rect.top, 39262 bottom: rect.top 39263 }; 39264 } 39265 39266 if (dropPosition === 'bottom' || dropPosition === 'inside') { 39267 return { ...anchorRect, 39268 top: rect.bottom, 39269 bottom: rect.bottom 39270 }; 39271 } 39272 39273 return {}; 39274 }, [targetElement, dropPosition, getDropIndicatorIndent]); 39275 39276 if (!targetElement) { 39277 return null; 39278 } 39279 39280 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { 39281 noArrow: true, 39282 animate: false, 39283 getAnchorRect: getAnchorRect, 39284 focusOnMount: false, 39285 className: "block-editor-list-view-drop-indicator" 39286 }, (0,external_wp_element_namespaceObject.createElement)("div", { 39287 style: style, 39288 className: "block-editor-list-view-drop-indicator__line" 39289 })); 39290 } 39291 39292 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/use-block-selection.js 39293 /** 39294 * External dependencies 39295 */ 39296 39297 /** 39298 * WordPress dependencies 39299 */ 39300 39301 39302 39303 39304 39305 39306 39307 /** 39308 * Internal dependencies 39309 */ 39310 39311 39312 39313 function useBlockSelection() { 39314 const { 39315 clearSelectedBlock, 39316 multiSelect, 39317 selectBlock 39318 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 39319 const { 39320 getBlockName, 39321 getBlockParents, 39322 getBlockSelectionStart, 39323 getBlockSelectionEnd, 39324 getSelectedBlockClientIds, 39325 hasMultiSelection, 39326 hasSelectedBlock 39327 } = (0,external_wp_data_namespaceObject.useSelect)(store); 39328 const { 39329 getBlockType 39330 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store); 39331 const updateBlockSelection = (0,external_wp_element_namespaceObject.useCallback)(async (event, clientId, destinationClientId) => { 39332 if (!(event !== null && event !== void 0 && event.shiftKey)) { 39333 await clearSelectedBlock(); 39334 selectBlock(clientId); 39335 return; 39336 } // To handle multiple block selection via the `SHIFT` key, prevent 39337 // the browser default behavior of opening the link in a new window. 39338 39339 39340 event.preventDefault(); 39341 const isKeyPress = event.type === 'keydown' && (event.keyCode === external_wp_keycodes_namespaceObject.UP || event.keyCode === external_wp_keycodes_namespaceObject.DOWN || event.keyCode === external_wp_keycodes_namespaceObject.HOME || event.keyCode === external_wp_keycodes_namespaceObject.END); // Handle clicking on a block when no blocks are selected, and return early. 39342 39343 if (!isKeyPress && !hasSelectedBlock() && !hasMultiSelection()) { 39344 selectBlock(clientId, null); 39345 return; 39346 } 39347 39348 const selectedBlocks = getSelectedBlockClientIds(); 39349 const clientIdWithParents = [...getBlockParents(clientId), clientId]; 39350 39351 if (isKeyPress && !selectedBlocks.some(blockId => clientIdWithParents.includes(blockId))) { 39352 // Ensure that shift-selecting blocks via the keyboard only 39353 // expands the current selection if focusing over already 39354 // selected blocks. Otherwise, clear the selection so that 39355 // a user can create a new selection entirely by keyboard. 39356 await clearSelectedBlock(); 39357 } 39358 39359 let startTarget = getBlockSelectionStart(); 39360 let endTarget = clientId; // Handle keyboard behavior for selecting multiple blocks. 39361 39362 if (isKeyPress) { 39363 if (!hasSelectedBlock() && !hasMultiSelection()) { 39364 // Set the starting point of the selection to the currently 39365 // focused block, if there are no blocks currently selected. 39366 // This ensures that as the selection is expanded or contracted, 39367 // the starting point of the selection is anchored to that block. 39368 startTarget = clientId; 39369 } 39370 39371 if (destinationClientId) { 39372 // If the user presses UP or DOWN, we want to ensure that the block they're 39373 // moving to is the target for selection, and not the currently focused one. 39374 endTarget = destinationClientId; 39375 } 39376 } 39377 39378 const startParents = getBlockParents(startTarget); 39379 const endParents = getBlockParents(endTarget); 39380 const { 39381 start, 39382 end 39383 } = getCommonDepthClientIds(startTarget, endTarget, startParents, endParents); 39384 await multiSelect(start, end, null); // Announce deselected block, or number of deselected blocks if 39385 // the total number of blocks deselected is greater than one. 39386 39387 const updatedSelectedBlocks = getSelectedBlockClientIds(); // If the selection is greater than 1 and the Home or End keys 39388 // were used to generate the selection, then skip announcing the 39389 // deselected blocks. 39390 39391 if ((event.keyCode === external_wp_keycodes_namespaceObject.HOME || event.keyCode === external_wp_keycodes_namespaceObject.END) && updatedSelectedBlocks.length > 1) { 39392 return; 39393 } 39394 39395 const selectionDiff = (0,external_lodash_namespaceObject.difference)(selectedBlocks, updatedSelectedBlocks); 39396 let label; 39397 39398 if (selectionDiff.length === 1) { 39399 var _getBlockType; 39400 39401 const title = (_getBlockType = getBlockType(getBlockName(selectionDiff[0]))) === null || _getBlockType === void 0 ? void 0 : _getBlockType.title; 39402 39403 if (title) { 39404 label = (0,external_wp_i18n_namespaceObject.sprintf)( 39405 /* translators: %s: block name */ 39406 (0,external_wp_i18n_namespaceObject.__)('%s deselected.'), title); 39407 } 39408 } else if (selectionDiff.length > 1) { 39409 label = (0,external_wp_i18n_namespaceObject.sprintf)( 39410 /* translators: %s: number of deselected blocks */ 39411 (0,external_wp_i18n_namespaceObject.__)('%s blocks deselected.'), selectionDiff.length); 39412 } 39413 39414 if (label) { 39415 (0,external_wp_a11y_namespaceObject.speak)(label); 39416 } 39417 }, [clearSelectedBlock, getBlockName, getBlockType, getBlockParents, getBlockSelectionStart, getBlockSelectionEnd, getSelectedBlockClientIds, hasMultiSelection, hasSelectedBlock, multiSelect, selectBlock]); 39418 return { 39419 updateBlockSelection 39420 }; 39421 } 39422 39423 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/use-list-view-client-ids.js 39424 /** 39425 * WordPress dependencies 39426 */ 39427 39428 /** 39429 * Internal dependencies 39430 */ 39431 39432 39433 function useListViewClientIds(blocks) { 39434 return (0,external_wp_data_namespaceObject.useSelect)(select => { 39435 const { 39436 getDraggedBlockClientIds, 39437 getSelectedBlockClientIds, 39438 __unstableGetClientIdsTree 39439 } = select(store); 39440 return { 39441 selectedClientIds: getSelectedBlockClientIds(), 39442 draggedClientIds: getDraggedBlockClientIds(), 39443 clientIdsTree: blocks ? blocks : __unstableGetClientIdsTree() 39444 }; 39445 }, [blocks]); 39446 } 39447 39448 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/use-list-view-drop-zone.js 39449 /** 39450 * WordPress dependencies 39451 */ 39452 39453 39454 39455 /** 39456 * Internal dependencies 39457 */ 39458 39459 39460 39461 39462 /** @typedef {import('../../utils/math').WPPoint} WPPoint */ 39463 39464 /** 39465 * The type of a drag event. 39466 * 39467 * @typedef {'default'|'file'|'html'} WPDragEventType 39468 */ 39469 39470 /** 39471 * An array representing data for blocks in the DOM used by drag and drop. 39472 * 39473 * @typedef {Object} WPListViewDropZoneBlocks 39474 * @property {string} clientId The client id for the block. 39475 * @property {string} rootClientId The root client id for the block. 39476 * @property {number} blockIndex The block's index. 39477 * @property {Element} element The DOM element representing the block. 39478 * @property {number} innerBlockCount The number of inner blocks the block has. 39479 * @property {boolean} isDraggedBlock Whether the block is currently being dragged. 39480 * @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block. 39481 * @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block. 39482 */ 39483 39484 /** 39485 * An object containing details of a drop target. 39486 * 39487 * @typedef {Object} WPListViewDropZoneTarget 39488 * @property {string} blockIndex The insertion index. 39489 * @property {string} rootClientId The root client id for the block. 39490 * @property {string|undefined} clientId The client id for the block. 39491 * @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to. 39492 * 'inside' refers to nesting as an inner block. 39493 */ 39494 39495 /** 39496 * Is the point contained by the rectangle. 39497 * 39498 * @param {WPPoint} point The point. 39499 * @param {DOMRect} rect The rectangle. 39500 * 39501 * @return {boolean} True if the point is contained by the rectangle, false otherwise. 39502 */ 39503 39504 function isPointContainedByRect(point, rect) { 39505 return rect.left <= point.x && rect.right >= point.x && rect.top <= point.y && rect.bottom >= point.y; 39506 } 39507 /** 39508 * Determines whether the user positioning the dragged block to nest as an 39509 * inner block. 39510 * 39511 * Presently this is determined by whether the cursor is on the right hand side 39512 * of the block. 39513 * 39514 * @param {WPPoint} point The point representing the cursor position when dragging. 39515 * @param {DOMRect} rect The rectangle. 39516 */ 39517 39518 39519 function isNestingGesture(point, rect) { 39520 const blockCenterX = rect.left + rect.width / 2; 39521 return point.x > blockCenterX; 39522 } // Block navigation is always a vertical list, so only allow dropping 39523 // to the above or below a block. 39524 39525 39526 const ALLOWED_DROP_EDGES = ['top', 'bottom']; 39527 /** 39528 * Given blocks data and the cursor position, compute the drop target. 39529 * 39530 * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view. 39531 * @param {WPPoint} position The point representing the cursor position when dragging. 39532 * 39533 * @return {WPListViewDropZoneTarget} An object containing data about the drop target. 39534 */ 39535 39536 function getListViewDropTarget(blocksData, position) { 39537 let candidateEdge; 39538 let candidateBlockData; 39539 let candidateDistance; 39540 let candidateRect; 39541 39542 for (const blockData of blocksData) { 39543 if (blockData.isDraggedBlock) { 39544 continue; 39545 } 39546 39547 const rect = blockData.element.getBoundingClientRect(); 39548 const [distance, edge] = getDistanceToNearestEdge(position, rect, ALLOWED_DROP_EDGES); 39549 const isCursorWithinBlock = isPointContainedByRect(position, rect); 39550 39551 if (candidateDistance === undefined || distance < candidateDistance || isCursorWithinBlock) { 39552 candidateDistance = distance; 39553 const index = blocksData.indexOf(blockData); 39554 const previousBlockData = blocksData[index - 1]; // If dragging near the top of a block and the preceding block 39555 // is at the same level, use the preceding block as the candidate 39556 // instead, as later it makes determining a nesting drop easier. 39557 39558 if (edge === 'top' && previousBlockData && previousBlockData.rootClientId === blockData.rootClientId && !previousBlockData.isDraggedBlock) { 39559 candidateBlockData = previousBlockData; 39560 candidateEdge = 'bottom'; 39561 candidateRect = previousBlockData.element.getBoundingClientRect(); 39562 } else { 39563 candidateBlockData = blockData; 39564 candidateEdge = edge; 39565 candidateRect = rect; 39566 } // If the mouse position is within the block, break early 39567 // as the user would intend to drop either before or after 39568 // this block. 39569 // 39570 // This solves an issue where some rows in the list view 39571 // tree overlap slightly due to sub-pixel rendering. 39572 39573 39574 if (isCursorWithinBlock) { 39575 break; 39576 } 39577 } 39578 } 39579 39580 if (!candidateBlockData) { 39581 return; 39582 } 39583 39584 const isDraggingBelow = candidateEdge === 'bottom'; // If the user is dragging towards the bottom of the block check whether 39585 // they might be trying to nest the block as a child. 39586 // If the block already has inner blocks, this should always be treated 39587 // as nesting since the next block in the tree will be the first child. 39588 39589 if (isDraggingBelow && candidateBlockData.canInsertDraggedBlocksAsChild && (candidateBlockData.innerBlockCount > 0 || isNestingGesture(position, candidateRect))) { 39590 return { 39591 rootClientId: candidateBlockData.clientId, 39592 blockIndex: 0, 39593 dropPosition: 'inside' 39594 }; 39595 } // If dropping as a sibling, but block cannot be inserted in 39596 // this context, return early. 39597 39598 39599 if (!candidateBlockData.canInsertDraggedBlocksAsSibling) { 39600 return; 39601 } 39602 39603 const offset = isDraggingBelow ? 1 : 0; 39604 return { 39605 rootClientId: candidateBlockData.rootClientId, 39606 clientId: candidateBlockData.clientId, 39607 blockIndex: candidateBlockData.blockIndex + offset, 39608 dropPosition: candidateEdge 39609 }; 39610 } 39611 /** 39612 * A react hook for implementing a drop zone in list view. 39613 * 39614 * @return {WPListViewDropZoneTarget} The drop target. 39615 */ 39616 39617 39618 function useListViewDropZone() { 39619 const { 39620 getBlockRootClientId, 39621 getBlockIndex, 39622 getBlockCount, 39623 getDraggedBlockClientIds, 39624 canInsertBlocks 39625 } = (0,external_wp_data_namespaceObject.useSelect)(store); 39626 const [target, setTarget] = (0,external_wp_element_namespaceObject.useState)(); 39627 const { 39628 rootClientId: targetRootClientId, 39629 blockIndex: targetBlockIndex 39630 } = target || {}; 39631 const onBlockDrop = useOnBlockDrop(targetRootClientId, targetBlockIndex); 39632 const draggedBlockClientIds = getDraggedBlockClientIds(); 39633 const throttled = (0,external_wp_compose_namespaceObject.useThrottle)((0,external_wp_element_namespaceObject.useCallback)((event, currentTarget) => { 39634 const position = { 39635 x: event.clientX, 39636 y: event.clientY 39637 }; 39638 const isBlockDrag = !!(draggedBlockClientIds !== null && draggedBlockClientIds !== void 0 && draggedBlockClientIds.length); 39639 const blockElements = Array.from(currentTarget.querySelectorAll('[data-block]')); 39640 const blocksData = blockElements.map(blockElement => { 39641 const clientId = blockElement.dataset.block; 39642 const rootClientId = getBlockRootClientId(clientId); 39643 return { 39644 clientId, 39645 rootClientId, 39646 blockIndex: getBlockIndex(clientId), 39647 element: blockElement, 39648 isDraggedBlock: isBlockDrag ? draggedBlockClientIds.includes(clientId) : false, 39649 innerBlockCount: getBlockCount(clientId), 39650 canInsertDraggedBlocksAsSibling: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, rootClientId) : true, 39651 canInsertDraggedBlocksAsChild: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, clientId) : true 39652 }; 39653 }); 39654 const newTarget = getListViewDropTarget(blocksData, position); 39655 39656 if (newTarget) { 39657 setTarget(newTarget); 39658 } 39659 }, [draggedBlockClientIds]), 200); 39660 const ref = (0,external_wp_compose_namespaceObject.__experimentalUseDropZone)({ 39661 onDrop: onBlockDrop, 39662 39663 onDragOver(event) { 39664 // `currentTarget` is only available while the event is being 39665 // handled, so get it now and pass it to the thottled function. 39666 // https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget 39667 throttled(event, event.currentTarget); 39668 }, 39669 39670 onDragEnd() { 39671 throttled.cancel(); 39672 setTarget(null); 39673 } 39674 39675 }); 39676 return { 39677 ref, 39678 target 39679 }; 39680 } 39681 39682 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/use-list-view-expand-selected-item.js 39683 /** 39684 * WordPress dependencies 39685 */ 39686 39687 39688 /** 39689 * Internal dependencies 39690 */ 39691 39692 39693 function useListViewExpandSelectedItem(_ref) { 39694 let { 39695 firstSelectedBlockClientId, 39696 setExpandedState 39697 } = _ref; 39698 const [selectedTreeId, setSelectedTreeId] = (0,external_wp_element_namespaceObject.useState)(null); 39699 const { 39700 selectedBlockParentClientIds 39701 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 39702 const { 39703 getBlockParents 39704 } = select(store); 39705 return { 39706 selectedBlockParentClientIds: getBlockParents(firstSelectedBlockClientId, false) 39707 }; 39708 }, [firstSelectedBlockClientId]); 39709 const parentClientIds = Array.isArray(selectedBlockParentClientIds) && selectedBlockParentClientIds.length ? selectedBlockParentClientIds : null; // Expand tree when a block is selected. 39710 39711 (0,external_wp_element_namespaceObject.useEffect)(() => { 39712 // If the selectedTreeId is the same as the selected block, 39713 // it means that the block was selected using the block list tree. 39714 if (selectedTreeId === firstSelectedBlockClientId) { 39715 return; 39716 } // If the selected block has parents, get the top-level parent. 39717 39718 39719 if (parentClientIds) { 39720 // If the selected block has parents, 39721 // expand the tree branch. 39722 setExpandedState({ 39723 type: 'expand', 39724 clientIds: selectedBlockParentClientIds 39725 }); 39726 } 39727 }, [firstSelectedBlockClientId]); 39728 return { 39729 setSelectedTreeId 39730 }; 39731 } 39732 39733 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/index.js 39734 39735 39736 39737 /** 39738 * WordPress dependencies 39739 */ 39740 39741 39742 39743 39744 39745 /** 39746 * Internal dependencies 39747 */ 39748 39749 39750 39751 39752 39753 39754 39755 39756 39757 39758 const expanded = (state, action) => { 39759 if (Array.isArray(action.clientIds)) { 39760 return { ...state, 39761 ...action.clientIds.reduce((newState, id) => ({ ...newState, 39762 [id]: action.type === 'expand' 39763 }), {}) 39764 }; 39765 } 39766 39767 return state; 39768 }; 39769 39770 const BLOCK_LIST_ITEM_HEIGHT = 36; 39771 /** 39772 * Wrap `ListViewRows` with `TreeGrid`. ListViewRows is a 39773 * recursive component (it renders itself), so this ensures TreeGrid is only 39774 * present at the very top of the navigation grid. 39775 * 39776 * @param {Object} props Components props. 39777 * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy. 39778 * @param {boolean} props.showNestedBlocks Flag to enable displaying nested blocks. 39779 * @param {boolean} props.showBlockMovers Flag to enable block movers 39780 * @param {boolean} props.__experimentalFeatures Flag to enable experimental features. 39781 * @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment. 39782 * @param {boolean} props.__experimentalHideContainerBlockActions Flag to hide actions of top level blocks (like core/widget-area) 39783 * @param {string} props.id Unique identifier for the root list element (primarily for a11y purposes). 39784 * @param {boolean} props.expandNested Flag to determine whether nested levels are expanded by default. 39785 * @param {Object} ref Forwarded ref 39786 */ 39787 39788 function ListView(_ref, ref) { 39789 let { 39790 blocks, 39791 __experimentalFeatures, 39792 __experimentalPersistentListViewFeatures, 39793 __experimentalHideContainerBlockActions, 39794 showNestedBlocks, 39795 showBlockMovers, 39796 id, 39797 expandNested = false, 39798 ...props 39799 } = _ref; 39800 const { 39801 clientIdsTree, 39802 draggedClientIds, 39803 selectedClientIds 39804 } = useListViewClientIds(blocks); 39805 const { 39806 visibleBlockCount 39807 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 39808 const { 39809 getGlobalBlockCount, 39810 getClientIdsOfDescendants 39811 } = select(store); 39812 const draggedBlockCount = (draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.length) > 0 ? getClientIdsOfDescendants(draggedClientIds).length + 1 : 0; 39813 return { 39814 visibleBlockCount: getGlobalBlockCount() - draggedBlockCount 39815 }; 39816 }, [draggedClientIds]); 39817 const { 39818 updateBlockSelection 39819 } = useBlockSelection(); 39820 const [expandedState, setExpandedState] = (0,external_wp_element_namespaceObject.useReducer)(expanded, {}); 39821 const { 39822 ref: dropZoneRef, 39823 target: blockDropTarget 39824 } = useListViewDropZone(); 39825 const elementRef = (0,external_wp_element_namespaceObject.useRef)(); 39826 const treeGridRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([elementRef, dropZoneRef, ref]); 39827 const isMounted = (0,external_wp_element_namespaceObject.useRef)(false); 39828 const { 39829 setSelectedTreeId 39830 } = useListViewExpandSelectedItem({ 39831 firstSelectedBlockClientId: selectedClientIds[0], 39832 setExpandedState 39833 }); 39834 const selectEditorBlock = (0,external_wp_element_namespaceObject.useCallback)((event, clientId) => { 39835 updateBlockSelection(event, clientId); 39836 setSelectedTreeId(clientId); 39837 }, [setSelectedTreeId, updateBlockSelection]); 39838 (0,external_wp_element_namespaceObject.useEffect)(() => { 39839 isMounted.current = true; 39840 }, []); // List View renders a fixed number of items and relies on each having a fixed item height of 36px. 39841 // If this value changes, we should also change the itemHeight value set in useFixedWindowList. 39842 // See: https://github.com/WordPress/gutenberg/pull/35230 for additional context. 39843 39844 const [fixedListWindow] = (0,external_wp_compose_namespaceObject.__experimentalUseFixedWindowList)(elementRef, BLOCK_LIST_ITEM_HEIGHT, visibleBlockCount, { 39845 useWindowing: __experimentalPersistentListViewFeatures, 39846 windowOverscan: 40 39847 }); 39848 const expand = (0,external_wp_element_namespaceObject.useCallback)(clientId => { 39849 if (!clientId) { 39850 return; 39851 } 39852 39853 setExpandedState({ 39854 type: 'expand', 39855 clientIds: [clientId] 39856 }); 39857 }, [setExpandedState]); 39858 const collapse = (0,external_wp_element_namespaceObject.useCallback)(clientId => { 39859 if (!clientId) { 39860 return; 39861 } 39862 39863 setExpandedState({ 39864 type: 'collapse', 39865 clientIds: [clientId] 39866 }); 39867 }, [setExpandedState]); 39868 const expandRow = (0,external_wp_element_namespaceObject.useCallback)(row => { 39869 var _row$dataset; 39870 39871 expand(row === null || row === void 0 ? void 0 : (_row$dataset = row.dataset) === null || _row$dataset === void 0 ? void 0 : _row$dataset.block); 39872 }, [expand]); 39873 const collapseRow = (0,external_wp_element_namespaceObject.useCallback)(row => { 39874 var _row$dataset2; 39875 39876 collapse(row === null || row === void 0 ? void 0 : (_row$dataset2 = row.dataset) === null || _row$dataset2 === void 0 ? void 0 : _row$dataset2.block); 39877 }, [collapse]); 39878 const focusRow = (0,external_wp_element_namespaceObject.useCallback)((event, startRow, endRow) => { 39879 if (event.shiftKey) { 39880 var _startRow$dataset, _endRow$dataset; 39881 39882 updateBlockSelection(event, startRow === null || startRow === void 0 ? void 0 : (_startRow$dataset = startRow.dataset) === null || _startRow$dataset === void 0 ? void 0 : _startRow$dataset.block, endRow === null || endRow === void 0 ? void 0 : (_endRow$dataset = endRow.dataset) === null || _endRow$dataset === void 0 ? void 0 : _endRow$dataset.block); 39883 } 39884 }, [updateBlockSelection]); 39885 const contextValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({ 39886 __experimentalFeatures, 39887 __experimentalPersistentListViewFeatures, 39888 __experimentalHideContainerBlockActions, 39889 isTreeGridMounted: isMounted.current, 39890 draggedClientIds, 39891 expandedState, 39892 expand, 39893 collapse 39894 }), [__experimentalFeatures, __experimentalPersistentListViewFeatures, __experimentalHideContainerBlockActions, isMounted.current, draggedClientIds, expandedState, expand, collapse]); 39895 return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, { 39896 value: true 39897 }, (0,external_wp_element_namespaceObject.createElement)(ListViewDropIndicator, { 39898 listViewRef: elementRef, 39899 blockDropTarget: blockDropTarget 39900 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGrid, { 39901 id: id, 39902 className: "block-editor-list-view-tree", 39903 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block navigation structure'), 39904 ref: treeGridRef, 39905 onCollapseRow: collapseRow, 39906 onExpandRow: expandRow, 39907 onFocusRow: focusRow 39908 }, (0,external_wp_element_namespaceObject.createElement)(ListViewContext.Provider, { 39909 value: contextValue 39910 }, (0,external_wp_element_namespaceObject.createElement)(branch, _extends({ 39911 blocks: clientIdsTree, 39912 selectBlock: selectEditorBlock, 39913 showNestedBlocks: showNestedBlocks, 39914 showBlockMovers: showBlockMovers, 39915 fixedListWindow: fixedListWindow, 39916 selectedClientIds: selectedClientIds, 39917 expandNested: expandNested 39918 }, props))))); 39919 } 39920 39921 /* harmony default export */ var components_list_view = ((0,external_wp_element_namespaceObject.forwardRef)(ListView)); 39922 39923 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/dropdown.js 39924 39925 39926 39927 /** 39928 * WordPress dependencies 39929 */ 39930 39931 39932 39933 39934 39935 /** 39936 * Internal dependencies 39937 */ 39938 39939 39940 39941 39942 function BlockNavigationDropdownToggle(_ref) { 39943 let { 39944 isEnabled, 39945 onToggle, 39946 isOpen, 39947 innerRef, 39948 ...props 39949 } = _ref; 39950 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, { 39951 ref: innerRef, 39952 icon: list_view, 39953 "aria-expanded": isOpen, 39954 "aria-haspopup": "true", 39955 onClick: isEnabled ? onToggle : undefined 39956 /* translators: button label text should, if possible, be under 16 characters. */ 39957 , 39958 label: (0,external_wp_i18n_namespaceObject.__)('List view'), 39959 className: "block-editor-block-navigation", 39960 "aria-disabled": !isEnabled 39961 })); 39962 } 39963 39964 function BlockNavigationDropdown(_ref2, ref) { 39965 let { 39966 isDisabled, 39967 __experimentalFeatures, 39968 ...props 39969 } = _ref2; 39970 const hasBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(store).getBlockCount(), []); 39971 const isEnabled = hasBlocks && !isDisabled; 39972 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, { 39973 contentClassName: "block-editor-block-navigation__popover", 39974 position: "bottom right", 39975 renderToggle: _ref3 => { 39976 let { 39977 isOpen, 39978 onToggle 39979 } = _ref3; 39980 return (0,external_wp_element_namespaceObject.createElement)(BlockNavigationDropdownToggle, _extends({}, props, { 39981 innerRef: ref, 39982 isOpen: isOpen, 39983 onToggle: onToggle, 39984 isEnabled: isEnabled 39985 })); 39986 }, 39987 renderContent: () => (0,external_wp_element_namespaceObject.createElement)("div", { 39988 className: "block-editor-block-navigation__container" 39989 }, (0,external_wp_element_namespaceObject.createElement)("p", { 39990 className: "block-editor-block-navigation__label" 39991 }, (0,external_wp_i18n_namespaceObject.__)('List view')), (0,external_wp_element_namespaceObject.createElement)(components_list_view, { 39992 showNestedBlocks: true, 39993 __experimentalFeatures: __experimentalFeatures 39994 })) 39995 }); 39996 } 39997 39998 /* harmony default export */ var dropdown = ((0,external_wp_element_namespaceObject.forwardRef)(BlockNavigationDropdown)); 39999 40000 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/preview-panel.js 40001 40002 40003 /** 40004 * WordPress dependencies 40005 */ 40006 40007 /** 40008 * Internal dependencies 40009 */ 40010 40011 40012 40013 function BlockStylesPreviewPanel(_ref) { 40014 let { 40015 genericPreviewBlock, 40016 style, 40017 className, 40018 activeStyle 40019 } = _ref; 40020 const styleClassName = replaceActiveStyle(className, activeStyle, style); 40021 const previewBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => { 40022 return { ...genericPreviewBlock, 40023 title: style.label || style.name, 40024 description: style.description, 40025 initialAttributes: { ...genericPreviewBlock.attributes, 40026 className: styleClassName + ' block-editor-block-styles__block-preview-container' 40027 } 40028 }; 40029 }, [genericPreviewBlock, styleClassName]); 40030 return (0,external_wp_element_namespaceObject.createElement)(preview_panel, { 40031 item: previewBlocks, 40032 isStylePreview: true 40033 }); 40034 } 40035 40036 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/index.js 40037 40038 40039 /** 40040 * External dependencies 40041 */ 40042 40043 40044 /** 40045 * WordPress dependencies 40046 */ 40047 40048 40049 40050 40051 40052 /** 40053 * Internal dependencies 40054 */ 40055 40056 40057 40058 40059 function BlockStylesPreviewPanelSlot(_ref) { 40060 let { 40061 scope 40062 } = _ref; 40063 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, { 40064 name: `BlockStylesPreviewPanel/$scope}` 40065 }); 40066 } 40067 40068 function BlockStylesPreviewPanelFill(_ref2) { 40069 let { 40070 children, 40071 scope, 40072 ...props 40073 } = _ref2; 40074 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, { 40075 name: `BlockStylesPreviewPanel/$scope}` 40076 }, (0,external_wp_element_namespaceObject.createElement)("div", props, children)); 40077 } // Top position (in px) of the Block Styles container 40078 // relative to the editor pane. 40079 // The value is the equivalent of the container's right position. 40080 40081 40082 const DEFAULT_POSITION_TOP = 16; // Block Styles component for the Settings Sidebar. 40083 40084 function BlockStyles(_ref3) { 40085 let { 40086 clientId, 40087 onSwitch = external_lodash_namespaceObject.noop, 40088 onHoverClassName = external_lodash_namespaceObject.noop, 40089 scope 40090 } = _ref3; 40091 const { 40092 onSelect, 40093 stylesToRender, 40094 activeStyle, 40095 genericPreviewBlock, 40096 className: previewClassName 40097 } = useStylesForBlocks({ 40098 clientId, 40099 onSwitch 40100 }); 40101 const [hoveredStyle, setHoveredStyle] = (0,external_wp_element_namespaceObject.useState)(null); 40102 const [containerScrollTop, setContainerScrollTop] = (0,external_wp_element_namespaceObject.useState)(0); 40103 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); 40104 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 40105 const scrollContainer = document.querySelector('.interface-interface-skeleton__content'); 40106 const scrollTop = (scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTop) || 0; 40107 setContainerScrollTop(scrollTop + DEFAULT_POSITION_TOP); 40108 }, [hoveredStyle]); 40109 40110 if (!stylesToRender || stylesToRender.length === 0) { 40111 return null; 40112 } 40113 40114 const debouncedSetHoveredStyle = (0,external_lodash_namespaceObject.debounce)(setHoveredStyle, 250); 40115 40116 const onSelectStylePreview = style => { 40117 onSelect(style); 40118 onHoverClassName(null); 40119 setHoveredStyle(null); 40120 debouncedSetHoveredStyle.cancel(); 40121 }; 40122 40123 const styleItemHandler = item => { 40124 var _item$name; 40125 40126 if (hoveredStyle === item) { 40127 debouncedSetHoveredStyle.cancel(); 40128 return; 40129 } 40130 40131 debouncedSetHoveredStyle(item); 40132 onHoverClassName((_item$name = item === null || item === void 0 ? void 0 : item.name) !== null && _item$name !== void 0 ? _item$name : null); 40133 }; 40134 40135 return (0,external_wp_element_namespaceObject.createElement)("div", { 40136 className: "block-editor-block-styles" 40137 }, (0,external_wp_element_namespaceObject.createElement)("div", { 40138 className: "block-editor-block-styles__variants" 40139 }, stylesToRender.map(style => { 40140 const buttonText = style.label || style.name; 40141 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 40142 className: classnames_default()('block-editor-block-styles__item', { 40143 'is-active': activeStyle.name === style.name 40144 }), 40145 key: style.name, 40146 variant: "secondary", 40147 label: buttonText, 40148 onMouseEnter: () => styleItemHandler(style), 40149 onFocus: () => styleItemHandler(style), 40150 onMouseLeave: () => styleItemHandler(null), 40151 onBlur: () => styleItemHandler(null), 40152 onKeyDown: event => { 40153 if (external_wp_keycodes_namespaceObject.ENTER === event.keyCode || external_wp_keycodes_namespaceObject.SPACE === event.keyCode) { 40154 event.preventDefault(); 40155 onSelectStylePreview(style); 40156 } 40157 }, 40158 onClick: () => onSelectStylePreview(style), 40159 role: "button", 40160 tabIndex: "0" 40161 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { 40162 as: "span", 40163 limit: 12, 40164 ellipsizeMode: "tail", 40165 className: "block-editor-block-styles__item-text", 40166 truncate: true 40167 }, buttonText)); 40168 })), hoveredStyle && !isMobileViewport && (0,external_wp_element_namespaceObject.createElement)(BlockStylesPreviewPanelFill, { 40169 scope: scope, 40170 className: "block-editor-block-styles__preview-panel", 40171 style: { 40172 top: containerScrollTop 40173 }, 40174 onMouseLeave: () => styleItemHandler(null) 40175 }, (0,external_wp_element_namespaceObject.createElement)(BlockStylesPreviewPanel, { 40176 activeStyle: activeStyle, 40177 className: previewClassName, 40178 genericPreviewBlock: genericPreviewBlock, 40179 style: hoveredStyle 40180 }))); 40181 } 40182 40183 BlockStyles.Slot = BlockStylesPreviewPanelSlot; 40184 /* harmony default export */ var block_styles = (BlockStyles); 40185 40186 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/layout.js 40187 40188 40189 /** 40190 * WordPress dependencies 40191 */ 40192 40193 const layout = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 40194 xmlns: "http://www.w3.org/2000/svg", 40195 viewBox: "0 0 24 24" 40196 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 40197 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" 40198 })); 40199 /* harmony default export */ var library_layout = (layout); 40200 40201 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-variation-picker/index.js 40202 40203 40204 /** 40205 * External dependencies 40206 */ 40207 40208 /** 40209 * WordPress dependencies 40210 */ 40211 40212 40213 40214 40215 40216 function BlockVariationPicker(_ref) { 40217 let { 40218 icon = library_layout, 40219 label = (0,external_wp_i18n_namespaceObject.__)('Choose variation'), 40220 instructions = (0,external_wp_i18n_namespaceObject.__)('Select a variation to start with.'), 40221 variations, 40222 onSelect, 40223 allowSkip 40224 } = _ref; 40225 const classes = classnames_default()('block-editor-block-variation-picker', { 40226 'has-many-variations': variations.length > 4 40227 }); 40228 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, { 40229 icon: icon, 40230 label: label, 40231 instructions: instructions, 40232 className: classes 40233 }, (0,external_wp_element_namespaceObject.createElement)("ul", { 40234 className: "block-editor-block-variation-picker__variations", 40235 role: "list", 40236 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block variations') 40237 }, variations.map(variation => (0,external_wp_element_namespaceObject.createElement)("li", { 40238 key: variation.name 40239 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 40240 variant: "secondary", 40241 icon: variation.icon, 40242 iconSize: 48, 40243 onClick: () => onSelect(variation), 40244 className: "block-editor-block-variation-picker__variation", 40245 label: variation.description || variation.title 40246 }), (0,external_wp_element_namespaceObject.createElement)("span", { 40247 className: "block-editor-block-variation-picker__variation-label", 40248 role: "presentation" 40249 }, variation.title)))), allowSkip && (0,external_wp_element_namespaceObject.createElement)("div", { 40250 className: "block-editor-block-variation-picker__skip" 40251 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 40252 variant: "link", 40253 onClick: () => onSelect() 40254 }, (0,external_wp_i18n_namespaceObject.__)('Skip')))); 40255 } 40256 40257 /* harmony default export */ var block_variation_picker = (BlockVariationPicker); 40258 40259 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/grid.js 40260 40261 40262 /** 40263 * WordPress dependencies 40264 */ 40265 40266 const grid = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 40267 xmlns: "http://www.w3.org/2000/svg", 40268 viewBox: "0 0 24 24" 40269 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 40270 d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7.8 16.5H5c-.3 0-.5-.2-.5-.5v-6.2h6.8v6.7zm0-8.3H4.5V5c0-.3.2-.5.5-.5h6.2v6.7zm8.3 7.8c0 .3-.2.5-.5.5h-6.2v-6.8h6.8V19zm0-7.8h-6.8V4.5H19c.3 0 .5.2.5.5v6.2z", 40271 fillRule: "evenodd", 40272 clipRule: "evenodd" 40273 })); 40274 /* harmony default export */ var library_grid = (grid); 40275 40276 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/constants.js 40277 const VIEWMODES = { 40278 carousel: 'carousel', 40279 grid: 'grid' 40280 }; 40281 40282 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/setup-toolbar.js 40283 40284 40285 /** 40286 * WordPress dependencies 40287 */ 40288 40289 40290 40291 /** 40292 * Internal dependencies 40293 */ 40294 40295 40296 40297 const Actions = _ref => { 40298 let { 40299 onStartBlank, 40300 onBlockPatternSelect 40301 } = _ref; 40302 return (0,external_wp_element_namespaceObject.createElement)("div", { 40303 className: "block-editor-block-pattern-setup__actions" 40304 }, onStartBlank && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 40305 onClick: onStartBlank 40306 }, (0,external_wp_i18n_namespaceObject.__)('Start blank')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 40307 variant: "primary", 40308 onClick: onBlockPatternSelect 40309 }, (0,external_wp_i18n_namespaceObject.__)('Choose'))); 40310 }; 40311 40312 const CarouselNavigation = _ref2 => { 40313 let { 40314 handlePrevious, 40315 handleNext, 40316 activeSlide, 40317 totalSlides 40318 } = _ref2; 40319 return (0,external_wp_element_namespaceObject.createElement)("div", { 40320 className: "block-editor-block-pattern-setup__navigation" 40321 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 40322 icon: chevron_left, 40323 label: (0,external_wp_i18n_namespaceObject.__)('Previous pattern'), 40324 onClick: handlePrevious, 40325 disabled: activeSlide === 0 40326 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 40327 icon: chevron_right, 40328 label: (0,external_wp_i18n_namespaceObject.__)('Next pattern'), 40329 onClick: handleNext, 40330 disabled: activeSlide === totalSlides - 1 40331 })); 40332 }; 40333 40334 const SetupToolbar = _ref3 => { 40335 let { 40336 viewMode, 40337 setViewMode, 40338 handlePrevious, 40339 handleNext, 40340 activeSlide, 40341 totalSlides, 40342 onBlockPatternSelect, 40343 onStartBlank 40344 } = _ref3; 40345 const isCarouselView = viewMode === VIEWMODES.carousel; 40346 const displayControls = (0,external_wp_element_namespaceObject.createElement)("div", { 40347 className: "block-editor-block-pattern-setup__display-controls" 40348 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 40349 icon: stretch_full_width, 40350 label: (0,external_wp_i18n_namespaceObject.__)('Carousel view'), 40351 onClick: () => setViewMode(VIEWMODES.carousel), 40352 isPressed: isCarouselView 40353 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 40354 icon: library_grid, 40355 label: (0,external_wp_i18n_namespaceObject.__)('Grid view'), 40356 onClick: () => setViewMode(VIEWMODES.grid), 40357 isPressed: viewMode === VIEWMODES.grid 40358 })); 40359 return (0,external_wp_element_namespaceObject.createElement)("div", { 40360 className: "block-editor-block-pattern-setup__toolbar" 40361 }, isCarouselView && (0,external_wp_element_namespaceObject.createElement)(CarouselNavigation, { 40362 handlePrevious: handlePrevious, 40363 handleNext: handleNext, 40364 activeSlide: activeSlide, 40365 totalSlides: totalSlides 40366 }), displayControls, isCarouselView && (0,external_wp_element_namespaceObject.createElement)(Actions, { 40367 onBlockPatternSelect: onBlockPatternSelect, 40368 onStartBlank: onStartBlank 40369 })); 40370 }; 40371 40372 /* harmony default export */ var setup_toolbar = (SetupToolbar); 40373 40374 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/use-patterns-setup.js 40375 /** 40376 * WordPress dependencies 40377 */ 40378 40379 /** 40380 * Internal dependencies 40381 */ 40382 40383 40384 40385 function usePatternsSetup(clientId, blockName, filterPatternsFn) { 40386 return (0,external_wp_data_namespaceObject.useSelect)(select => { 40387 const { 40388 getBlockRootClientId, 40389 __experimentalGetPatternsByBlockTypes, 40390 __experimentalGetAllowedPatterns 40391 } = select(store); 40392 const rootClientId = getBlockRootClientId(clientId); 40393 40394 if (filterPatternsFn) { 40395 return __experimentalGetAllowedPatterns(rootClientId).filter(filterPatternsFn); 40396 } 40397 40398 return __experimentalGetPatternsByBlockTypes(blockName, rootClientId); 40399 }, [clientId, blockName, filterPatternsFn]); 40400 } 40401 40402 /* harmony default export */ var use_patterns_setup = (usePatternsSetup); 40403 40404 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/index.js 40405 40406 40407 40408 /** 40409 * WordPress dependencies 40410 */ 40411 40412 40413 40414 40415 40416 40417 /** 40418 * Internal dependencies 40419 */ 40420 40421 40422 40423 40424 40425 40426 40427 const SetupContent = _ref => { 40428 let { 40429 viewMode, 40430 activeSlide, 40431 patterns, 40432 onBlockPatternSelect, 40433 height 40434 } = _ref; 40435 const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)(); 40436 const containerClass = 'block-editor-block-pattern-setup__container'; 40437 40438 if (viewMode === VIEWMODES.carousel) { 40439 const slideClass = new Map([[activeSlide, 'active-slide'], [activeSlide - 1, 'previous-slide'], [activeSlide + 1, 'next-slide']]); 40440 return (0,external_wp_element_namespaceObject.createElement)("div", { 40441 className: "block-editor-block-pattern-setup__carousel", 40442 style: { 40443 height 40444 } 40445 }, (0,external_wp_element_namespaceObject.createElement)("div", { 40446 className: containerClass 40447 }, (0,external_wp_element_namespaceObject.createElement)("ul", { 40448 className: "carousel-container" 40449 }, patterns.map((pattern, index) => (0,external_wp_element_namespaceObject.createElement)(BlockPatternSlide, { 40450 className: slideClass.get(index) || '', 40451 key: pattern.name, 40452 pattern: pattern, 40453 minHeight: height 40454 }))))); 40455 } 40456 40457 return (0,external_wp_element_namespaceObject.createElement)("div", { 40458 style: { 40459 height 40460 }, 40461 className: "block-editor-block-pattern-setup__grid" 40462 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, { 40463 role: "listbox", 40464 className: containerClass, 40465 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Patterns list') 40466 }), patterns.map(pattern => (0,external_wp_element_namespaceObject.createElement)(block_pattern_setup_BlockPattern, { 40467 key: pattern.name, 40468 pattern: pattern, 40469 onSelect: onBlockPatternSelect, 40470 composite: composite 40471 })))); 40472 }; 40473 40474 function block_pattern_setup_BlockPattern(_ref2) { 40475 let { 40476 pattern, 40477 onSelect, 40478 composite 40479 } = _ref2; 40480 const baseClassName = 'block-editor-block-pattern-setup-list'; 40481 const { 40482 blocks, 40483 description, 40484 viewportWidth = 700 40485 } = pattern; 40486 const descriptionId = (0,external_wp_compose_namespaceObject.useInstanceId)(block_pattern_setup_BlockPattern, `$baseClassName}__item-description`); 40487 return (0,external_wp_element_namespaceObject.createElement)("div", { 40488 className: `$baseClassName}__list-item`, 40489 "aria-label": pattern.title, 40490 "aria-describedby": pattern.description ? descriptionId : undefined 40491 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({ 40492 role: "option", 40493 as: "div" 40494 }, composite, { 40495 className: `$baseClassName}__item`, 40496 onClick: () => onSelect(blocks) 40497 }), (0,external_wp_element_namespaceObject.createElement)(block_preview, { 40498 blocks: blocks, 40499 viewportWidth: viewportWidth 40500 })), !!description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 40501 id: descriptionId 40502 }, description)); 40503 } 40504 40505 function BlockPatternSlide(_ref3) { 40506 let { 40507 className, 40508 pattern, 40509 minHeight 40510 } = _ref3; 40511 const { 40512 blocks, 40513 title, 40514 description 40515 } = pattern; 40516 const descriptionId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockPatternSlide, 'block-editor-block-pattern-setup-list__item-description'); 40517 return (0,external_wp_element_namespaceObject.createElement)("li", { 40518 className: `pattern-slide $className}`, 40519 "aria-label": title, 40520 "aria-describedby": description ? descriptionId : undefined 40521 }, (0,external_wp_element_namespaceObject.createElement)(block_preview, { 40522 blocks: blocks, 40523 __experimentalMinHeight: minHeight 40524 }), !!description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 40525 id: descriptionId 40526 }, description)); 40527 } 40528 40529 const BlockPatternSetup = _ref4 => { 40530 let { 40531 clientId, 40532 blockName, 40533 filterPatternsFn, 40534 startBlankComponent, 40535 onBlockPatternSelect 40536 } = _ref4; 40537 const [viewMode, setViewMode] = (0,external_wp_element_namespaceObject.useState)(VIEWMODES.carousel); 40538 const [activeSlide, setActiveSlide] = (0,external_wp_element_namespaceObject.useState)(0); 40539 const [showBlank, setShowBlank] = (0,external_wp_element_namespaceObject.useState)(false); 40540 const { 40541 replaceBlock 40542 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 40543 const patterns = use_patterns_setup(clientId, blockName, filterPatternsFn); 40544 const [contentResizeListener, { 40545 height: contentHeight 40546 }] = (0,external_wp_compose_namespaceObject.useResizeObserver)(); 40547 40548 if (!(patterns !== null && patterns !== void 0 && patterns.length) || showBlank) { 40549 return startBlankComponent; 40550 } 40551 40552 const onBlockPatternSelectDefault = blocks => { 40553 const clonedBlocks = blocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block)); 40554 replaceBlock(clientId, clonedBlocks); 40555 }; 40556 40557 const onPatternSelectCallback = onBlockPatternSelect || onBlockPatternSelectDefault; 40558 const onStartBlank = startBlankComponent ? () => { 40559 setShowBlank(true); 40560 } : undefined; 40561 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, contentResizeListener, (0,external_wp_element_namespaceObject.createElement)("div", { 40562 className: `block-editor-block-pattern-setup view-mode-$viewMode}` 40563 }, (0,external_wp_element_namespaceObject.createElement)(SetupContent, { 40564 viewMode: viewMode, 40565 activeSlide: activeSlide, 40566 patterns: patterns, 40567 onBlockPatternSelect: onPatternSelectCallback, 40568 height: contentHeight - 2 * 60 40569 }), (0,external_wp_element_namespaceObject.createElement)(setup_toolbar, { 40570 viewMode: viewMode, 40571 setViewMode: setViewMode, 40572 activeSlide: activeSlide, 40573 totalSlides: patterns.length, 40574 handleNext: () => { 40575 setActiveSlide(active => active + 1); 40576 }, 40577 handlePrevious: () => { 40578 setActiveSlide(active => active - 1); 40579 }, 40580 onBlockPatternSelect: () => { 40581 onPatternSelectCallback(patterns[activeSlide].blocks); 40582 }, 40583 onStartBlank: onStartBlank 40584 }))); 40585 }; 40586 40587 /* harmony default export */ var block_pattern_setup = (BlockPatternSetup); 40588 40589 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-variation-transforms/index.js 40590 40591 40592 /** 40593 * WordPress dependencies 40594 */ 40595 40596 40597 40598 40599 40600 40601 /** 40602 * Internal dependencies 40603 */ 40604 40605 40606 40607 function VariationsButtons(_ref) { 40608 let { 40609 className, 40610 onSelectVariation, 40611 selectedValue, 40612 variations 40613 } = _ref; 40614 return (0,external_wp_element_namespaceObject.createElement)("fieldset", { 40615 className: className 40616 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 40617 as: "legend" 40618 }, (0,external_wp_i18n_namespaceObject.__)('Transform to variation')), variations.map(variation => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 40619 key: variation.name, 40620 icon: variation.icon, 40621 isPressed: selectedValue === variation.name, 40622 label: selectedValue === variation.name ? variation.title : (0,external_wp_i18n_namespaceObject.sprintf)( 40623 /* translators: %s: Name of the block variation */ 40624 (0,external_wp_i18n_namespaceObject.__)('Transform to %s'), variation.title), 40625 onClick: () => onSelectVariation(variation.name), 40626 "aria-label": variation.title, 40627 showTooltip: true 40628 }))); 40629 } 40630 40631 function VariationsDropdown(_ref2) { 40632 let { 40633 className, 40634 onSelectVariation, 40635 selectedValue, 40636 variations 40637 } = _ref2; 40638 const selectOptions = variations.map(_ref3 => { 40639 let { 40640 name, 40641 title, 40642 description 40643 } = _ref3; 40644 return { 40645 value: name, 40646 label: title, 40647 info: description 40648 }; 40649 }); 40650 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 40651 className: className, 40652 label: (0,external_wp_i18n_namespaceObject.__)('Transform to variation'), 40653 text: (0,external_wp_i18n_namespaceObject.__)('Transform to variation'), 40654 popoverProps: { 40655 position: 'bottom center', 40656 className: `$className}__popover` 40657 }, 40658 icon: chevron_down, 40659 toggleProps: { 40660 iconPosition: 'right' 40661 } 40662 }, () => (0,external_wp_element_namespaceObject.createElement)("div", { 40663 className: `$className}__container` 40664 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, { 40665 choices: selectOptions, 40666 value: selectedValue, 40667 onSelect: onSelectVariation 40668 })))); 40669 } 40670 40671 function __experimentalBlockVariationTransforms(_ref4) { 40672 let { 40673 blockClientId 40674 } = _ref4; 40675 const { 40676 updateBlockAttributes 40677 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 40678 const { 40679 activeBlockVariation, 40680 variations 40681 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 40682 const { 40683 getActiveBlockVariation, 40684 getBlockVariations 40685 } = select(external_wp_blocks_namespaceObject.store); 40686 const { 40687 getBlockName, 40688 getBlockAttributes 40689 } = select(store); 40690 const name = blockClientId && getBlockName(blockClientId); 40691 return { 40692 activeBlockVariation: getActiveBlockVariation(name, getBlockAttributes(blockClientId)), 40693 variations: name && getBlockVariations(name, 'transform') 40694 }; 40695 }, [blockClientId]); 40696 const selectedValue = activeBlockVariation === null || activeBlockVariation === void 0 ? void 0 : activeBlockVariation.name; // Check if each variation has a unique icon. 40697 40698 const hasUniqueIcons = (0,external_wp_element_namespaceObject.useMemo)(() => { 40699 const variationIcons = new Set(); 40700 variations.forEach(variation => { 40701 if (variation.icon) { 40702 variationIcons.add(variation.icon); 40703 } 40704 }); 40705 return variationIcons.size === variations.length; 40706 }, [variations]); 40707 40708 const onSelectVariation = variationName => { 40709 updateBlockAttributes(blockClientId, { ...variations.find(_ref5 => { 40710 let { 40711 name 40712 } = _ref5; 40713 return name === variationName; 40714 }).attributes 40715 }); 40716 }; 40717 40718 const baseClass = 'block-editor-block-variation-transforms'; // Skip rendering if there are no variations 40719 40720 if (!(variations !== null && variations !== void 0 && variations.length)) return null; 40721 const Component = hasUniqueIcons ? VariationsButtons : VariationsDropdown; 40722 return (0,external_wp_element_namespaceObject.createElement)(Component, { 40723 className: baseClass, 40724 onSelectVariation: onSelectVariation, 40725 selectedValue: selectedValue, 40726 variations: variations 40727 }); 40728 } 40729 40730 /* harmony default export */ var block_variation_transforms = (__experimentalBlockVariationTransforms); 40731 40732 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/with-color-context.js 40733 40734 40735 40736 /** 40737 * External dependencies 40738 */ 40739 40740 /** 40741 * WordPress dependencies 40742 */ 40743 40744 40745 /** 40746 * Internal dependencies 40747 */ 40748 40749 40750 /* harmony default export */ var with_color_context = ((0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => { 40751 return props => { 40752 const colorsFeature = useSetting('color.palette'); 40753 const disableCustomColorsFeature = !useSetting('color.custom'); 40754 const colors = props.colors === undefined ? colorsFeature : props.colors; 40755 const disableCustomColors = props.disableCustomColors === undefined ? disableCustomColorsFeature : props.disableCustomColors; 40756 const hasColorsToChoose = !(0,external_lodash_namespaceObject.isEmpty)(colors) || !disableCustomColors; 40757 return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, { 40758 colors, 40759 disableCustomColors, 40760 hasColorsToChoose 40761 })); 40762 }; 40763 }, 'withColorContext')); 40764 40765 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/index.js 40766 /** 40767 * WordPress dependencies 40768 */ 40769 40770 /** 40771 * Internal dependencies 40772 */ 40773 40774 40775 /* harmony default export */ var color_palette = (with_color_context(external_wp_components_namespaceObject.ColorPalette)); 40776 40777 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/control.js 40778 40779 40780 40781 /** 40782 * Internal dependencies 40783 */ 40784 40785 function ColorPaletteControl(_ref) { 40786 let { 40787 onChange, 40788 value, 40789 ...otherProps 40790 } = _ref; 40791 return (0,external_wp_element_namespaceObject.createElement)(control, _extends({}, otherProps, { 40792 onColorChange: onChange, 40793 colorValue: value, 40794 gradients: [], 40795 disableCustomGradients: true 40796 })); 40797 } 40798 40799 ;// CONCATENATED MODULE: external ["wp","date"] 40800 var external_wp_date_namespaceObject = window["wp"]["date"]; 40801 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/date-format-picker/index.js 40802 40803 40804 /** 40805 * External dependencies 40806 */ 40807 40808 /** 40809 * WordPress dependencies 40810 */ 40811 40812 40813 40814 40815 // So that we can illustrate the different formats in the dropdown properly, 40816 // show a date that has a day greater than 12 and a month with more than three 40817 // letters. Here we're using 2022-01-25 which is when WordPress 5.9 was 40818 // released. 40819 40820 const EXAMPLE_DATE = new Date(2022, 0, 25); 40821 /** 40822 * The `DateFormatPicker` component renders controls that let the user choose a 40823 * _date format_. That is, how they want their dates to be formatted. 40824 * 40825 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/date-format-picker/README.md 40826 * 40827 * @param {Object} props 40828 * @param {string|null} props.format The selected date 40829 * format. If 40830 * `null`, 40831 * _Default_ is 40832 * selected. 40833 * @param {string} props.defaultFormat The date format that 40834 * will be used if the 40835 * user selects 40836 * 'Default'. 40837 * @param {( format: string|null ) => void} props.onChange Called when a 40838 * selection is 40839 * made. If `null`, 40840 * _Default_ is 40841 * selected. 40842 */ 40843 40844 function DateFormatPicker(_ref) { 40845 let { 40846 format, 40847 defaultFormat, 40848 onChange 40849 } = _ref; 40850 return (0,external_wp_element_namespaceObject.createElement)("fieldset", { 40851 className: "block-editor-date-format-picker" 40852 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 40853 as: "legend" 40854 }, (0,external_wp_i18n_namespaceObject.__)('Date format')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, { 40855 label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Default format'), (0,external_wp_element_namespaceObject.createElement)("span", { 40856 className: "block-editor-date-format-picker__default-format-toggle-control__hint" 40857 }, (0,external_wp_date_namespaceObject.dateI18n)(defaultFormat, EXAMPLE_DATE))), 40858 checked: !format, 40859 onChange: checked => onChange(checked ? null : defaultFormat) 40860 }), format && (0,external_wp_element_namespaceObject.createElement)(NonDefaultControls, { 40861 format: format, 40862 onChange: onChange 40863 })); 40864 } 40865 40866 function NonDefaultControls(_ref2) { 40867 var _suggestedOptions$fin; 40868 40869 let { 40870 format, 40871 onChange 40872 } = _ref2; 40873 // Suggest a short format, medium format, long format, and a standardised 40874 // (YYYY-MM-DD) format. The short, medium, and long formats are localised as 40875 // different languages have different ways of writing these. For example, 'F 40876 // j, Y' (April 20, 2022) in American English (en_US) is 'j. F Y' (20. April 40877 // 2022) in German (de). The resultant array is de-duplicated as some 40878 // languages will use the same format string for short, medium, and long 40879 // formats. 40880 const suggestedFormats = (0,external_lodash_namespaceObject.uniq)(['Y-m-d', (0,external_wp_i18n_namespaceObject._x)('n/j/Y', 'short date format'), (0,external_wp_i18n_namespaceObject._x)('n/j/Y g:i A', 'short date format with time'), (0,external_wp_i18n_namespaceObject._x)('M j, Y', 'medium date format'), (0,external_wp_i18n_namespaceObject._x)('M j, Y g:i A', 'medium date format with time'), (0,external_wp_i18n_namespaceObject._x)('F j, Y', 'long date format')]); 40881 const suggestedOptions = suggestedFormats.map((suggestedFormat, index) => ({ 40882 key: `suggested-$index}`, 40883 name: (0,external_wp_date_namespaceObject.dateI18n)(suggestedFormat, EXAMPLE_DATE), 40884 format: suggestedFormat 40885 })); 40886 const customOption = { 40887 key: 'custom', 40888 name: (0,external_wp_i18n_namespaceObject.__)('Custom'), 40889 className: 'block-editor-date-format-picker__custom-format-select-control__custom-option', 40890 __experimentalHint: (0,external_wp_i18n_namespaceObject.__)('Enter your own date format') 40891 }; 40892 const [isCustom, setIsCustom] = (0,external_wp_element_namespaceObject.useState)(() => !!format && !suggestedFormats.includes(format)); 40893 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl, { 40894 className: "block-editor-date-format-picker__custom-format-select-control" 40895 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CustomSelectControl, { 40896 label: (0,external_wp_i18n_namespaceObject.__)('Choose a format'), 40897 options: [...suggestedOptions, customOption], 40898 value: isCustom ? customOption : (_suggestedOptions$fin = suggestedOptions.find(option => option.format === format)) !== null && _suggestedOptions$fin !== void 0 ? _suggestedOptions$fin : customOption, 40899 onChange: _ref3 => { 40900 let { 40901 selectedItem 40902 } = _ref3; 40903 40904 if (selectedItem === customOption) { 40905 setIsCustom(true); 40906 } else { 40907 setIsCustom(false); 40908 onChange(selectedItem.format); 40909 } 40910 } 40911 })), isCustom && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { 40912 label: (0,external_wp_i18n_namespaceObject.__)('Custom format'), 40913 hideLabelFromVision: true, 40914 help: (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('Enter a date or time <Link>format string</Link>.'), { 40915 Link: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, { 40916 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/formatting-date-and-time/') 40917 }) 40918 }), 40919 value: format, 40920 onChange: value => onChange(value) 40921 })); 40922 } 40923 40924 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/panel-color-gradient-settings.js 40925 40926 40927 40928 /** 40929 * External dependencies 40930 */ 40931 40932 40933 /** 40934 * WordPress dependencies 40935 */ 40936 40937 40938 40939 /** 40940 * Internal dependencies 40941 */ 40942 40943 40944 40945 40946 40947 40948 // translators: first %s: The type of color or gradient (e.g. background, overlay...), second %s: the color name or value (e.g. red or #ff0000) 40949 40950 const colorIndicatorAriaLabel = (0,external_wp_i18n_namespaceObject.__)('(%s: color %s)'); // translators: first %s: The type of color or gradient (e.g. background, overlay...), second %s: the color name or value (e.g. red or #ff0000) 40951 40952 40953 const gradientIndicatorAriaLabel = (0,external_wp_i18n_namespaceObject.__)('(%s: gradient %s)'); 40954 40955 const panel_color_gradient_settings_colorsAndGradientKeys = ['colors', 'disableCustomColors', 'gradients', 'disableCustomGradients']; 40956 40957 const Indicators = _ref => { 40958 let { 40959 colors, 40960 gradients, 40961 settings 40962 } = _ref; 40963 return settings.map((_ref2, index) => { 40964 let { 40965 colorValue, 40966 gradientValue, 40967 label, 40968 colors: availableColors, 40969 gradients: availableGradients 40970 } = _ref2; 40971 40972 if (!colorValue && !gradientValue) { 40973 return null; 40974 } 40975 40976 let ariaLabel; 40977 40978 if (colorValue) { 40979 const colorObject = getColorObjectByColorValue(availableColors || colors, colorValue); 40980 ariaLabel = (0,external_wp_i18n_namespaceObject.sprintf)(colorIndicatorAriaLabel, label.toLowerCase(), colorObject && colorObject.name || colorValue); 40981 } else { 40982 const gradientObject = __experimentalGetGradientObjectByGradientValue(availableGradients || gradients, colorValue); 40983 40984 ariaLabel = (0,external_wp_i18n_namespaceObject.sprintf)(gradientIndicatorAriaLabel, label.toLowerCase(), gradientObject && gradientObject.name || gradientValue); 40985 } 40986 40987 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, { 40988 key: index, 40989 colorValue: colorValue || gradientValue, 40990 "aria-label": ariaLabel 40991 }); 40992 }); 40993 }; 40994 40995 const PanelColorGradientSettingsInner = _ref3 => { 40996 let { 40997 className, 40998 colors, 40999 gradients, 41000 disableCustomColors, 41001 disableCustomGradients, 41002 children, 41003 settings, 41004 title, 41005 showTitle = true, 41006 __experimentalHasMultipleOrigins, 41007 __experimentalIsRenderedInSidebar, 41008 enableAlpha, 41009 ...props 41010 } = _ref3; 41011 41012 if ((0,external_lodash_namespaceObject.isEmpty)(colors) && (0,external_lodash_namespaceObject.isEmpty)(gradients) && disableCustomColors && disableCustomGradients && (0,external_lodash_namespaceObject.every)(settings, setting => (0,external_lodash_namespaceObject.isEmpty)(setting.colors) && (0,external_lodash_namespaceObject.isEmpty)(setting.gradients) && (setting.disableCustomColors === undefined || setting.disableCustomColors) && (setting.disableCustomGradients === undefined || setting.disableCustomGradients))) { 41013 return null; 41014 } 41015 41016 const titleElement = (0,external_wp_element_namespaceObject.createElement)("span", { 41017 className: "block-editor-panel-color-gradient-settings__panel-title" 41018 }, title, (0,external_wp_element_namespaceObject.createElement)(Indicators, { 41019 colors: colors, 41020 gradients: gradients, 41021 settings: settings 41022 })); 41023 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, _extends({ 41024 className: classnames_default()('block-editor-panel-color-gradient-settings', className), 41025 title: showTitle ? titleElement : undefined 41026 }, props), (0,external_wp_element_namespaceObject.createElement)(ColorGradientSettingsDropdown, { 41027 settings: settings, 41028 colors, 41029 gradients, 41030 disableCustomColors, 41031 disableCustomGradients, 41032 __experimentalHasMultipleOrigins, 41033 __experimentalIsRenderedInSidebar, 41034 enableAlpha 41035 }), !!children && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 41036 marginY: 4 41037 }), " ", children)); 41038 }; 41039 41040 const PanelColorGradientSettingsSingleSelect = props => { 41041 const colorGradientSettings = useCommonSingleMultipleSelects(); 41042 colorGradientSettings.colors = useSetting('color.palette'); 41043 colorGradientSettings.gradients = useSetting('color.gradients'); 41044 return (0,external_wp_element_namespaceObject.createElement)(PanelColorGradientSettingsInner, _extends({}, colorGradientSettings, props)); 41045 }; 41046 41047 const PanelColorGradientSettingsMultipleSelect = props => { 41048 const colorGradientSettings = useMultipleOriginColorsAndGradients(); 41049 return (0,external_wp_element_namespaceObject.createElement)(PanelColorGradientSettingsInner, _extends({}, colorGradientSettings, props)); 41050 }; 41051 41052 const PanelColorGradientSettings = props => { 41053 if ((0,external_lodash_namespaceObject.every)(panel_color_gradient_settings_colorsAndGradientKeys, key => props.hasOwnProperty(key))) { 41054 return (0,external_wp_element_namespaceObject.createElement)(PanelColorGradientSettingsInner, props); 41055 } 41056 41057 if (props.__experimentalHasMultipleOrigins) { 41058 return (0,external_wp_element_namespaceObject.createElement)(PanelColorGradientSettingsMultipleSelect, props); 41059 } 41060 41061 return (0,external_wp_element_namespaceObject.createElement)(PanelColorGradientSettingsSingleSelect, props); 41062 }; 41063 41064 /* harmony default export */ var panel_color_gradient_settings = (PanelColorGradientSettings); 41065 41066 ;// CONCATENATED MODULE: ./node_modules/react-easy-crop/node_modules/tslib/tslib.es6.js 41067 /*! ***************************************************************************** 41068 Copyright (c) Microsoft Corporation. 41069 41070 Permission to use, copy, modify, and/or distribute this software for any 41071 purpose with or without fee is hereby granted. 41072 41073 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 41074 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 41075 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 41076 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 41077 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 41078 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 41079 PERFORMANCE OF THIS SOFTWARE. 41080 ***************************************************************************** */ 41081 /* global Reflect, Promise */ 41082 41083 var extendStatics = function(d, b) { 41084 extendStatics = Object.setPrototypeOf || 41085 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 41086 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; 41087 return extendStatics(d, b); 41088 }; 41089 41090 function __extends(d, b) { 41091 extendStatics(d, b); 41092 function __() { this.constructor = d; } 41093 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 41094 } 41095 41096 var __assign = function() { 41097 __assign = Object.assign || function __assign(t) { 41098 for (var s, i = 1, n = arguments.length; i < n; i++) { 41099 s = arguments[i]; 41100 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 41101 } 41102 return t; 41103 } 41104 return __assign.apply(this, arguments); 41105 } 41106 41107 function __rest(s, e) { 41108 var t = {}; 41109 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) 41110 t[p] = s[p]; 41111 if (s != null && typeof Object.getOwnPropertySymbols === "function") 41112 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { 41113 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) 41114 t[p[i]] = s[p[i]]; 41115 } 41116 return t; 41117 } 41118 41119 function __decorate(decorators, target, key, desc) { 41120 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 41121 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 41122 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 41123 return c > 3 && r && Object.defineProperty(target, key, r), r; 41124 } 41125 41126 function __param(paramIndex, decorator) { 41127 return function (target, key) { decorator(target, key, paramIndex); } 41128 } 41129 41130 function __metadata(metadataKey, metadataValue) { 41131 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); 41132 } 41133 41134 function __awaiter(thisArg, _arguments, P, generator) { 41135 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 41136 return new (P || (P = Promise))(function (resolve, reject) { 41137 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 41138 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 41139 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 41140 step((generator = generator.apply(thisArg, _arguments || [])).next()); 41141 }); 41142 } 41143 41144 function __generator(thisArg, body) { 41145 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 41146 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 41147 function verb(n) { return function (v) { return step([n, v]); }; } 41148 function step(op) { 41149 if (f) throw new TypeError("Generator is already executing."); 41150 while (_) try { 41151 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 41152 if (y = 0, t) op = [op[0] & 2, t.value]; 41153 switch (op[0]) { 41154 case 0: case 1: t = op; break; 41155 case 4: _.label++; return { value: op[1], done: false }; 41156 case 5: _.label++; y = op[1]; op = [0]; continue; 41157 case 7: op = _.ops.pop(); _.trys.pop(); continue; 41158 default: 41159 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 41160 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 41161 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 41162 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 41163 if (t[2]) _.ops.pop(); 41164 _.trys.pop(); continue; 41165 } 41166 op = body.call(thisArg, _); 41167 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 41168 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 41169 } 41170 } 41171 41172 var __createBinding = Object.create ? (function(o, m, k, k2) { 41173 if (k2 === undefined) k2 = k; 41174 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 41175 }) : (function(o, m, k, k2) { 41176 if (k2 === undefined) k2 = k; 41177 o[k2] = m[k]; 41178 }); 41179 41180 function __exportStar(m, o) { 41181 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); 41182 } 41183 41184 function __values(o) { 41185 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; 41186 if (m) return m.call(o); 41187 if (o && typeof o.length === "number") return { 41188 next: function () { 41189 if (o && i >= o.length) o = void 0; 41190 return { value: o && o[i++], done: !o }; 41191 } 41192 }; 41193 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); 41194 } 41195 41196 function __read(o, n) { 41197 var m = typeof Symbol === "function" && o[Symbol.iterator]; 41198 if (!m) return o; 41199 var i = m.call(o), r, ar = [], e; 41200 try { 41201 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); 41202 } 41203 catch (error) { e = { error: error }; } 41204 finally { 41205 try { 41206 if (r && !r.done && (m = i["return"])) m.call(i); 41207 } 41208 finally { if (e) throw e.error; } 41209 } 41210 return ar; 41211 } 41212 41213 function __spread() { 41214 for (var ar = [], i = 0; i < arguments.length; i++) 41215 ar = ar.concat(__read(arguments[i])); 41216 return ar; 41217 } 41218 41219 function __spreadArrays() { 41220 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 41221 for (var r = Array(s), k = 0, i = 0; i < il; i++) 41222 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) 41223 r[k] = a[j]; 41224 return r; 41225 }; 41226 41227 function __await(v) { 41228 return this instanceof __await ? (this.v = v, this) : new __await(v); 41229 } 41230 41231 function __asyncGenerator(thisArg, _arguments, generator) { 41232 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); 41233 var g = generator.apply(thisArg, _arguments || []), i, q = []; 41234 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; 41235 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } 41236 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } 41237 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } 41238 function fulfill(value) { resume("next", value); } 41239 function reject(value) { resume("throw", value); } 41240 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } 41241 } 41242 41243 function __asyncDelegator(o) { 41244 var i, p; 41245 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; 41246 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } 41247 } 41248 41249 function __asyncValues(o) { 41250 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); 41251 var m = o[Symbol.asyncIterator], i; 41252 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); 41253 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } 41254 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } 41255 } 41256 41257 function __makeTemplateObject(cooked, raw) { 41258 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } 41259 return cooked; 41260 }; 41261 41262 var __setModuleDefault = Object.create ? (function(o, v) { 41263 Object.defineProperty(o, "default", { enumerable: true, value: v }); 41264 }) : function(o, v) { 41265 o["default"] = v; 41266 }; 41267 41268 function __importStar(mod) { 41269 if (mod && mod.__esModule) return mod; 41270 var result = {}; 41271 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 41272 __setModuleDefault(result, mod); 41273 return result; 41274 } 41275 41276 function __importDefault(mod) { 41277 return (mod && mod.__esModule) ? mod : { default: mod }; 41278 } 41279 41280 function __classPrivateFieldGet(receiver, privateMap) { 41281 if (!privateMap.has(receiver)) { 41282 throw new TypeError("attempted to get private field on non-instance"); 41283 } 41284 return privateMap.get(receiver); 41285 } 41286 41287 function __classPrivateFieldSet(receiver, privateMap, value) { 41288 if (!privateMap.has(receiver)) { 41289 throw new TypeError("attempted to set private field on non-instance"); 41290 } 41291 privateMap.set(receiver, value); 41292 return value; 41293 } 41294 41295 // EXTERNAL MODULE: ./node_modules/normalize-wheel/index.js 41296 var normalize_wheel = __webpack_require__(7970); 41297 var normalize_wheel_default = /*#__PURE__*/__webpack_require__.n(normalize_wheel); 41298 ;// CONCATENATED MODULE: ./node_modules/react-easy-crop/index.module.js 41299 41300 41301 41302 41303 /** 41304 * Compute the dimension of the crop area based on media size, 41305 * aspect ratio and optionally rotation 41306 */ 41307 41308 function getCropSize(mediaWidth, mediaHeight, containerWidth, containerHeight, aspect, rotation) { 41309 if (rotation === void 0) { 41310 rotation = 0; 41311 } 41312 41313 var _a = translateSize(mediaWidth, mediaHeight, rotation), 41314 width = _a.width, 41315 height = _a.height; 41316 41317 var fittingWidth = Math.min(width, containerWidth); 41318 var fittingHeight = Math.min(height, containerHeight); 41319 41320 if (fittingWidth > fittingHeight * aspect) { 41321 return { 41322 width: fittingHeight * aspect, 41323 height: fittingHeight 41324 }; 41325 } 41326 41327 return { 41328 width: fittingWidth, 41329 height: fittingWidth / aspect 41330 }; 41331 } 41332 /** 41333 * Ensure a new media position stays in the crop area. 41334 */ 41335 41336 function restrictPosition(position, mediaSize, cropSize, zoom, rotation) { 41337 if (rotation === void 0) { 41338 rotation = 0; 41339 } 41340 41341 var _a = translateSize(mediaSize.width, mediaSize.height, rotation), 41342 width = _a.width, 41343 height = _a.height; 41344 41345 return { 41346 x: restrictPositionCoord(position.x, width, cropSize.width, zoom), 41347 y: restrictPositionCoord(position.y, height, cropSize.height, zoom) 41348 }; 41349 } 41350 41351 function restrictPositionCoord(position, mediaSize, cropSize, zoom) { 41352 var maxPosition = mediaSize * zoom / 2 - cropSize / 2; 41353 return Math.min(maxPosition, Math.max(position, -maxPosition)); 41354 } 41355 41356 function getDistanceBetweenPoints(pointA, pointB) { 41357 return Math.sqrt(Math.pow(pointA.y - pointB.y, 2) + Math.pow(pointA.x - pointB.x, 2)); 41358 } 41359 function getRotationBetweenPoints(pointA, pointB) { 41360 return Math.atan2(pointB.y - pointA.y, pointB.x - pointA.x) * 180 / Math.PI; 41361 } 41362 /** 41363 * Compute the output cropped area of the media in percentages and pixels. 41364 * x/y are the top-left coordinates on the src media 41365 */ 41366 41367 function computeCroppedArea(crop, mediaSize, cropSize, aspect, zoom, rotation, restrictPosition) { 41368 if (rotation === void 0) { 41369 rotation = 0; 41370 } 41371 41372 if (restrictPosition === void 0) { 41373 restrictPosition = true; 41374 } // if the media is rotated by the user, we cannot limit the position anymore 41375 // as it might need to be negative. 41376 41377 41378 var limitAreaFn = restrictPosition && rotation === 0 ? limitArea : noOp; 41379 var croppedAreaPercentages = { 41380 x: limitAreaFn(100, ((mediaSize.width - cropSize.width / zoom) / 2 - crop.x / zoom) / mediaSize.width * 100), 41381 y: limitAreaFn(100, ((mediaSize.height - cropSize.height / zoom) / 2 - crop.y / zoom) / mediaSize.height * 100), 41382 width: limitAreaFn(100, cropSize.width / mediaSize.width * 100 / zoom), 41383 height: limitAreaFn(100, cropSize.height / mediaSize.height * 100 / zoom) 41384 }; // we compute the pixels size naively 41385 41386 var widthInPixels = Math.round(limitAreaFn(mediaSize.naturalWidth, croppedAreaPercentages.width * mediaSize.naturalWidth / 100)); 41387 var heightInPixels = Math.round(limitAreaFn(mediaSize.naturalHeight, croppedAreaPercentages.height * mediaSize.naturalHeight / 100)); 41388 var isImgWiderThanHigh = mediaSize.naturalWidth >= mediaSize.naturalHeight * aspect; // then we ensure the width and height exactly match the aspect (to avoid rounding approximations) 41389 // if the media is wider than high, when zoom is 0, the crop height will be equals to iamge height 41390 // thus we want to compute the width from the height and aspect for accuracy. 41391 // Otherwise, we compute the height from width and aspect. 41392 41393 var sizePixels = isImgWiderThanHigh ? { 41394 width: Math.round(heightInPixels * aspect), 41395 height: heightInPixels 41396 } : { 41397 width: widthInPixels, 41398 height: Math.round(widthInPixels / aspect) 41399 }; 41400 41401 var croppedAreaPixels = __assign(__assign({}, sizePixels), { 41402 x: Math.round(limitAreaFn(mediaSize.naturalWidth - sizePixels.width, croppedAreaPercentages.x * mediaSize.naturalWidth / 100)), 41403 y: Math.round(limitAreaFn(mediaSize.naturalHeight - sizePixels.height, croppedAreaPercentages.y * mediaSize.naturalHeight / 100)) 41404 }); 41405 41406 return { 41407 croppedAreaPercentages: croppedAreaPercentages, 41408 croppedAreaPixels: croppedAreaPixels 41409 }; 41410 } 41411 /** 41412 * Ensure the returned value is between 0 and max 41413 */ 41414 41415 function limitArea(max, value) { 41416 return Math.min(max, Math.max(0, value)); 41417 } 41418 41419 function noOp(_max, value) { 41420 return value; 41421 } 41422 /** 41423 * Compute the crop and zoom from the croppedAreaPixels 41424 */ 41425 41426 41427 function getZoomFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize) { 41428 var mediaZoom = mediaSize.width / mediaSize.naturalWidth; 41429 41430 if (cropSize) { 41431 var isHeightMaxSize_1 = cropSize.height > cropSize.width; 41432 return isHeightMaxSize_1 ? cropSize.height / mediaZoom / croppedAreaPixels.height : cropSize.width / mediaZoom / croppedAreaPixels.width; 41433 } 41434 41435 var aspect = croppedAreaPixels.width / croppedAreaPixels.height; 41436 var isHeightMaxSize = mediaSize.naturalWidth >= mediaSize.naturalHeight * aspect; 41437 return isHeightMaxSize ? mediaSize.naturalHeight / croppedAreaPixels.height : mediaSize.naturalWidth / croppedAreaPixels.width; 41438 } 41439 /** 41440 * Compute the crop and zoom from the croppedAreaPixels 41441 */ 41442 41443 41444 function getInitialCropFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize) { 41445 var mediaZoom = mediaSize.width / mediaSize.naturalWidth; 41446 var zoom = getZoomFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize); 41447 var cropZoom = mediaZoom * zoom; 41448 var crop = { 41449 x: ((mediaSize.naturalWidth - croppedAreaPixels.width) / 2 - croppedAreaPixels.x) * cropZoom, 41450 y: ((mediaSize.naturalHeight - croppedAreaPixels.height) / 2 - croppedAreaPixels.y) * cropZoom 41451 }; 41452 return { 41453 crop: crop, 41454 zoom: zoom 41455 }; 41456 } 41457 /** 41458 * Return the point that is the center of point a and b 41459 */ 41460 41461 function getCenter(a, b) { 41462 return { 41463 x: (b.x + a.x) / 2, 41464 y: (b.y + a.y) / 2 41465 }; 41466 } 41467 /** 41468 * 41469 * Returns an x,y point once rotated around xMid,yMid 41470 */ 41471 41472 function rotateAroundMidPoint(x, y, xMid, yMid, degrees) { 41473 var cos = Math.cos; 41474 var sin = Math.sin; 41475 var radian = degrees * Math.PI / 180; // Convert to radians 41476 // Subtract midpoints, so that midpoint is translated to origin 41477 // and add it in the end again 41478 41479 var xr = (x - xMid) * cos(radian) - (y - yMid) * sin(radian) + xMid; 41480 var yr = (x - xMid) * sin(radian) + (y - yMid) * cos(radian) + yMid; 41481 return [xr, yr]; 41482 } 41483 /** 41484 * Returns the new bounding area of a rotated rectangle. 41485 */ 41486 41487 function translateSize(width, height, rotation) { 41488 var centerX = width / 2; 41489 var centerY = height / 2; 41490 var outerBounds = [rotateAroundMidPoint(0, 0, centerX, centerY, rotation), rotateAroundMidPoint(width, 0, centerX, centerY, rotation), rotateAroundMidPoint(width, height, centerX, centerY, rotation), rotateAroundMidPoint(0, height, centerX, centerY, rotation)]; 41491 var minX = Math.min.apply(Math, outerBounds.map(function (p) { 41492 return p[0]; 41493 })); 41494 var maxX = Math.max.apply(Math, outerBounds.map(function (p) { 41495 return p[0]; 41496 })); 41497 var minY = Math.min.apply(Math, outerBounds.map(function (p) { 41498 return p[1]; 41499 })); 41500 var maxY = Math.max.apply(Math, outerBounds.map(function (p) { 41501 return p[1]; 41502 })); 41503 return { 41504 width: maxX - minX, 41505 height: maxY - minY 41506 }; 41507 } 41508 /** 41509 * Combine multiple class names into a single string. 41510 */ 41511 41512 function classNames() { 41513 var args = []; 41514 41515 for (var _i = 0; _i < arguments.length; _i++) { 41516 args[_i] = arguments[_i]; 41517 } 41518 41519 return args.filter(function (value) { 41520 if (typeof value === 'string' && value.length > 0) { 41521 return true; 41522 } 41523 41524 return false; 41525 }).join(' ').trim(); 41526 } 41527 41528 var css_248z = ".reactEasyCrop_Container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n user-select: none;\n touch-action: none;\n cursor: move;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.reactEasyCrop_Image,\n.reactEasyCrop_Video {\n will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */\n}\n\n.reactEasyCrop_Contain {\n max-width: 100%;\n max-height: 100%;\n margin: auto;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n}\n.reactEasyCrop_Cover_Horizontal {\n width: 100%;\n height: auto;\n}\n.reactEasyCrop_Cover_Vertical {\n width: auto;\n height: 100%;\n}\n\n.reactEasyCrop_CropArea {\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n border: 1px solid rgba(255, 255, 255, 0.5);\n box-sizing: border-box;\n box-shadow: 0 0 0 9999em;\n color: rgba(0, 0, 0, 0.5);\n overflow: hidden;\n}\n\n.reactEasyCrop_CropAreaRound {\n border-radius: 50%;\n}\n\n.reactEasyCrop_CropAreaGrid::before {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 0;\n bottom: 0;\n left: 33.33%;\n right: 33.33%;\n border-top: 0;\n border-bottom: 0;\n}\n\n.reactEasyCrop_CropAreaGrid::after {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 33.33%;\n bottom: 33.33%;\n left: 0;\n right: 0;\n border-left: 0;\n border-right: 0;\n}\n"; 41529 41530 var MIN_ZOOM = 1; 41531 var MAX_ZOOM = 3; 41532 41533 var Cropper = 41534 /** @class */ 41535 function (_super) { 41536 __extends(Cropper, _super); 41537 41538 function Cropper() { 41539 var _this = _super !== null && _super.apply(this, arguments) || this; 41540 41541 _this.imageRef = null; 41542 _this.videoRef = null; 41543 _this.containerRef = null; 41544 _this.styleRef = null; 41545 _this.containerRect = null; 41546 _this.mediaSize = { 41547 width: 0, 41548 height: 0, 41549 naturalWidth: 0, 41550 naturalHeight: 0 41551 }; 41552 _this.dragStartPosition = { 41553 x: 0, 41554 y: 0 41555 }; 41556 _this.dragStartCrop = { 41557 x: 0, 41558 y: 0 41559 }; 41560 _this.lastPinchDistance = 0; 41561 _this.lastPinchRotation = 0; 41562 _this.rafDragTimeout = null; 41563 _this.rafPinchTimeout = null; 41564 _this.wheelTimer = null; 41565 _this.state = { 41566 cropSize: null, 41567 hasWheelJustStarted: false 41568 }; // this is to prevent Safari on iOS >= 10 to zoom the page 41569 41570 _this.preventZoomSafari = function (e) { 41571 return e.preventDefault(); 41572 }; 41573 41574 _this.cleanEvents = function () { 41575 document.removeEventListener('mousemove', _this.onMouseMove); 41576 document.removeEventListener('mouseup', _this.onDragStopped); 41577 document.removeEventListener('touchmove', _this.onTouchMove); 41578 document.removeEventListener('touchend', _this.onDragStopped); 41579 }; 41580 41581 _this.clearScrollEvent = function () { 41582 if (_this.containerRef) _this.containerRef.removeEventListener('wheel', _this.onWheel); 41583 41584 if (_this.wheelTimer) { 41585 clearTimeout(_this.wheelTimer); 41586 } 41587 }; 41588 41589 _this.onMediaLoad = function () { 41590 _this.computeSizes(); 41591 41592 _this.emitCropData(); 41593 41594 _this.setInitialCrop(); 41595 41596 if (_this.props.onMediaLoaded) { 41597 _this.props.onMediaLoaded(_this.mediaSize); 41598 } 41599 }; 41600 41601 _this.setInitialCrop = function () { 41602 var _a = _this.props, 41603 initialCroppedAreaPixels = _a.initialCroppedAreaPixels, 41604 cropSize = _a.cropSize; 41605 41606 if (!initialCroppedAreaPixels) { 41607 return; 41608 } 41609 41610 var _b = getInitialCropFromCroppedAreaPixels(initialCroppedAreaPixels, _this.mediaSize, cropSize), 41611 crop = _b.crop, 41612 zoom = _b.zoom; 41613 41614 _this.props.onCropChange(crop); 41615 41616 _this.props.onZoomChange && _this.props.onZoomChange(zoom); 41617 }; 41618 41619 _this.computeSizes = function () { 41620 var _a, _b, _c, _d, _e, _f; 41621 41622 var mediaRef = _this.imageRef || _this.videoRef; 41623 41624 if (mediaRef && _this.containerRef) { 41625 _this.containerRect = _this.containerRef.getBoundingClientRect(); 41626 _this.mediaSize = { 41627 width: mediaRef.offsetWidth, 41628 height: mediaRef.offsetHeight, 41629 naturalWidth: ((_a = _this.imageRef) === null || _a === void 0 ? void 0 : _a.naturalWidth) || ((_b = _this.videoRef) === null || _b === void 0 ? void 0 : _b.videoWidth) || 0, 41630 naturalHeight: ((_c = _this.imageRef) === null || _c === void 0 ? void 0 : _c.naturalHeight) || ((_d = _this.videoRef) === null || _d === void 0 ? void 0 : _d.videoHeight) || 0 41631 }; 41632 var cropSize = _this.props.cropSize ? _this.props.cropSize : getCropSize(mediaRef.offsetWidth, mediaRef.offsetHeight, _this.containerRect.width, _this.containerRect.height, _this.props.aspect, _this.props.rotation); 41633 41634 if (((_e = _this.state.cropSize) === null || _e === void 0 ? void 0 : _e.height) !== cropSize.height || ((_f = _this.state.cropSize) === null || _f === void 0 ? void 0 : _f.width) !== cropSize.width) { 41635 _this.props.onCropSizeChange && _this.props.onCropSizeChange(cropSize); 41636 } 41637 41638 _this.setState({ 41639 cropSize: cropSize 41640 }, _this.recomputeCropPosition); 41641 } 41642 }; 41643 41644 _this.onMouseDown = function (e) { 41645 e.preventDefault(); 41646 document.addEventListener('mousemove', _this.onMouseMove); 41647 document.addEventListener('mouseup', _this.onDragStopped); 41648 41649 _this.onDragStart(Cropper.getMousePoint(e)); 41650 }; 41651 41652 _this.onMouseMove = function (e) { 41653 return _this.onDrag(Cropper.getMousePoint(e)); 41654 }; 41655 41656 _this.onTouchStart = function (e) { 41657 document.addEventListener('touchmove', _this.onTouchMove, { 41658 passive: false 41659 }); // iOS 11 now defaults to passive: true 41660 41661 document.addEventListener('touchend', _this.onDragStopped); 41662 41663 if (e.touches.length === 2) { 41664 _this.onPinchStart(e); 41665 } else if (e.touches.length === 1) { 41666 _this.onDragStart(Cropper.getTouchPoint(e.touches[0])); 41667 } 41668 }; 41669 41670 _this.onTouchMove = function (e) { 41671 // Prevent whole page from scrolling on iOS. 41672 e.preventDefault(); 41673 41674 if (e.touches.length === 2) { 41675 _this.onPinchMove(e); 41676 } else if (e.touches.length === 1) { 41677 _this.onDrag(Cropper.getTouchPoint(e.touches[0])); 41678 } 41679 }; 41680 41681 _this.onDragStart = function (_a) { 41682 var _b, _c; 41683 41684 var x = _a.x, 41685 y = _a.y; 41686 _this.dragStartPosition = { 41687 x: x, 41688 y: y 41689 }; 41690 _this.dragStartCrop = __assign({}, _this.props.crop); 41691 (_c = (_b = _this.props).onInteractionStart) === null || _c === void 0 ? void 0 : _c.call(_b); 41692 }; 41693 41694 _this.onDrag = function (_a) { 41695 var x = _a.x, 41696 y = _a.y; 41697 if (_this.rafDragTimeout) window.cancelAnimationFrame(_this.rafDragTimeout); 41698 _this.rafDragTimeout = window.requestAnimationFrame(function () { 41699 if (!_this.state.cropSize) return; 41700 if (x === undefined || y === undefined) return; 41701 var offsetX = x - _this.dragStartPosition.x; 41702 var offsetY = y - _this.dragStartPosition.y; 41703 var requestedPosition = { 41704 x: _this.dragStartCrop.x + offsetX, 41705 y: _this.dragStartCrop.y + offsetY 41706 }; 41707 var newPosition = _this.props.restrictPosition ? restrictPosition(requestedPosition, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : requestedPosition; 41708 41709 _this.props.onCropChange(newPosition); 41710 }); 41711 }; 41712 41713 _this.onDragStopped = function () { 41714 var _a, _b; 41715 41716 _this.cleanEvents(); 41717 41718 _this.emitCropData(); 41719 41720 (_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a); 41721 }; 41722 41723 _this.onWheel = function (e) { 41724 e.preventDefault(); 41725 var point = Cropper.getMousePoint(e); 41726 var pixelY = normalize_wheel_default()(e).pixelY; 41727 var newZoom = _this.props.zoom - pixelY * _this.props.zoomSpeed / 200; 41728 41729 _this.setNewZoom(newZoom, point); 41730 41731 if (!_this.state.hasWheelJustStarted) { 41732 _this.setState({ 41733 hasWheelJustStarted: true 41734 }, function () { 41735 var _a, _b; 41736 41737 return (_b = (_a = _this.props).onInteractionStart) === null || _b === void 0 ? void 0 : _b.call(_a); 41738 }); 41739 } 41740 41741 if (_this.wheelTimer) { 41742 clearTimeout(_this.wheelTimer); 41743 } 41744 41745 _this.wheelTimer = window.setTimeout(function () { 41746 return _this.setState({ 41747 hasWheelJustStarted: false 41748 }, function () { 41749 var _a, _b; 41750 41751 return (_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a); 41752 }); 41753 }, 250); 41754 }; 41755 41756 _this.getPointOnContainer = function (_a) { 41757 var x = _a.x, 41758 y = _a.y; 41759 41760 if (!_this.containerRect) { 41761 throw new Error('The Cropper is not mounted'); 41762 } 41763 41764 return { 41765 x: _this.containerRect.width / 2 - (x - _this.containerRect.left), 41766 y: _this.containerRect.height / 2 - (y - _this.containerRect.top) 41767 }; 41768 }; 41769 41770 _this.getPointOnMedia = function (_a) { 41771 var x = _a.x, 41772 y = _a.y; 41773 var _b = _this.props, 41774 crop = _b.crop, 41775 zoom = _b.zoom; 41776 return { 41777 x: (x + crop.x) / zoom, 41778 y: (y + crop.y) / zoom 41779 }; 41780 }; 41781 41782 _this.setNewZoom = function (zoom, point) { 41783 if (!_this.state.cropSize || !_this.props.onZoomChange) return; 41784 41785 var zoomPoint = _this.getPointOnContainer(point); 41786 41787 var zoomTarget = _this.getPointOnMedia(zoomPoint); 41788 41789 var newZoom = Math.min(_this.props.maxZoom, Math.max(zoom, _this.props.minZoom)); 41790 var requestedPosition = { 41791 x: zoomTarget.x * newZoom - zoomPoint.x, 41792 y: zoomTarget.y * newZoom - zoomPoint.y 41793 }; 41794 var newPosition = _this.props.restrictPosition ? restrictPosition(requestedPosition, _this.mediaSize, _this.state.cropSize, newZoom, _this.props.rotation) : requestedPosition; 41795 41796 _this.props.onCropChange(newPosition); 41797 41798 _this.props.onZoomChange(newZoom); 41799 }; 41800 41801 _this.getCropData = function () { 41802 if (!_this.state.cropSize) { 41803 return null; 41804 } // this is to ensure the crop is correctly restricted after a zoom back (https://github.com/ricardo-ch/react-easy-crop/issues/6) 41805 41806 41807 var restrictedPosition = _this.props.restrictPosition ? restrictPosition(_this.props.crop, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : _this.props.crop; 41808 return computeCroppedArea(restrictedPosition, _this.mediaSize, _this.state.cropSize, _this.getAspect(), _this.props.zoom, _this.props.rotation, _this.props.restrictPosition); 41809 }; 41810 41811 _this.emitCropData = function () { 41812 var cropData = _this.getCropData(); 41813 41814 if (!cropData) return; 41815 var croppedAreaPercentages = cropData.croppedAreaPercentages, 41816 croppedAreaPixels = cropData.croppedAreaPixels; 41817 41818 if (_this.props.onCropComplete) { 41819 _this.props.onCropComplete(croppedAreaPercentages, croppedAreaPixels); 41820 } 41821 41822 if (_this.props.onCropAreaChange) { 41823 _this.props.onCropAreaChange(croppedAreaPercentages, croppedAreaPixels); 41824 } 41825 }; 41826 41827 _this.emitCropAreaChange = function () { 41828 var cropData = _this.getCropData(); 41829 41830 if (!cropData) return; 41831 var croppedAreaPercentages = cropData.croppedAreaPercentages, 41832 croppedAreaPixels = cropData.croppedAreaPixels; 41833 41834 if (_this.props.onCropAreaChange) { 41835 _this.props.onCropAreaChange(croppedAreaPercentages, croppedAreaPixels); 41836 } 41837 }; 41838 41839 _this.recomputeCropPosition = function () { 41840 if (!_this.state.cropSize) return; 41841 var newPosition = _this.props.restrictPosition ? restrictPosition(_this.props.crop, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : _this.props.crop; 41842 41843 _this.props.onCropChange(newPosition); 41844 41845 _this.emitCropData(); 41846 }; 41847 41848 return _this; 41849 } 41850 41851 Cropper.prototype.componentDidMount = function () { 41852 window.addEventListener('resize', this.computeSizes); 41853 41854 if (this.containerRef) { 41855 this.props.zoomWithScroll && this.containerRef.addEventListener('wheel', this.onWheel, { 41856 passive: false 41857 }); 41858 this.containerRef.addEventListener('gesturestart', this.preventZoomSafari); 41859 this.containerRef.addEventListener('gesturechange', this.preventZoomSafari); 41860 } 41861 41862 if (!this.props.disableAutomaticStylesInjection) { 41863 this.styleRef = document.createElement('style'); 41864 this.styleRef.setAttribute('type', 'text/css'); 41865 this.styleRef.innerHTML = css_248z; 41866 document.head.appendChild(this.styleRef); 41867 } // when rendered via SSR, the image can already be loaded and its onLoad callback will never be called 41868 41869 41870 if (this.imageRef && this.imageRef.complete) { 41871 this.onMediaLoad(); 41872 } 41873 }; 41874 41875 Cropper.prototype.componentWillUnmount = function () { 41876 var _a; 41877 41878 window.removeEventListener('resize', this.computeSizes); 41879 41880 if (this.containerRef) { 41881 this.containerRef.removeEventListener('gesturestart', this.preventZoomSafari); 41882 this.containerRef.removeEventListener('gesturechange', this.preventZoomSafari); 41883 } 41884 41885 if (this.styleRef) { 41886 (_a = this.styleRef.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this.styleRef); 41887 } 41888 41889 this.cleanEvents(); 41890 this.props.zoomWithScroll && this.clearScrollEvent(); 41891 }; 41892 41893 Cropper.prototype.componentDidUpdate = function (prevProps) { 41894 var _a, _b, _c, _d, _e, _f, _g, _h, _j; 41895 41896 if (prevProps.rotation !== this.props.rotation) { 41897 this.computeSizes(); 41898 this.recomputeCropPosition(); 41899 } else if (prevProps.aspect !== this.props.aspect) { 41900 this.computeSizes(); 41901 } else if (prevProps.zoom !== this.props.zoom) { 41902 this.recomputeCropPosition(); 41903 } else if (((_a = prevProps.cropSize) === null || _a === void 0 ? void 0 : _a.height) !== ((_b = this.props.cropSize) === null || _b === void 0 ? void 0 : _b.height) || ((_c = prevProps.cropSize) === null || _c === void 0 ? void 0 : _c.width) !== ((_d = this.props.cropSize) === null || _d === void 0 ? void 0 : _d.width)) { 41904 this.computeSizes(); 41905 } else if (((_e = prevProps.crop) === null || _e === void 0 ? void 0 : _e.x) !== ((_f = this.props.crop) === null || _f === void 0 ? void 0 : _f.x) || ((_g = prevProps.crop) === null || _g === void 0 ? void 0 : _g.y) !== ((_h = this.props.crop) === null || _h === void 0 ? void 0 : _h.y)) { 41906 this.emitCropAreaChange(); 41907 } 41908 41909 if (prevProps.zoomWithScroll !== this.props.zoomWithScroll && this.containerRef) { 41910 this.props.zoomWithScroll ? this.containerRef.addEventListener('wheel', this.onWheel, { 41911 passive: false 41912 }) : this.clearScrollEvent(); 41913 } 41914 41915 if (prevProps.video !== this.props.video) { 41916 (_j = this.videoRef) === null || _j === void 0 ? void 0 : _j.load(); 41917 } 41918 }; 41919 41920 Cropper.prototype.getAspect = function () { 41921 var _a = this.props, 41922 cropSize = _a.cropSize, 41923 aspect = _a.aspect; 41924 41925 if (cropSize) { 41926 return cropSize.width / cropSize.height; 41927 } 41928 41929 return aspect; 41930 }; 41931 41932 Cropper.prototype.onPinchStart = function (e) { 41933 var pointA = Cropper.getTouchPoint(e.touches[0]); 41934 var pointB = Cropper.getTouchPoint(e.touches[1]); 41935 this.lastPinchDistance = getDistanceBetweenPoints(pointA, pointB); 41936 this.lastPinchRotation = getRotationBetweenPoints(pointA, pointB); 41937 this.onDragStart(getCenter(pointA, pointB)); 41938 }; 41939 41940 Cropper.prototype.onPinchMove = function (e) { 41941 var _this = this; 41942 41943 var pointA = Cropper.getTouchPoint(e.touches[0]); 41944 var pointB = Cropper.getTouchPoint(e.touches[1]); 41945 var center = getCenter(pointA, pointB); 41946 this.onDrag(center); 41947 if (this.rafPinchTimeout) window.cancelAnimationFrame(this.rafPinchTimeout); 41948 this.rafPinchTimeout = window.requestAnimationFrame(function () { 41949 var distance = getDistanceBetweenPoints(pointA, pointB); 41950 var newZoom = _this.props.zoom * (distance / _this.lastPinchDistance); 41951 41952 _this.setNewZoom(newZoom, center); 41953 41954 _this.lastPinchDistance = distance; 41955 var rotation = getRotationBetweenPoints(pointA, pointB); 41956 var newRotation = _this.props.rotation + (rotation - _this.lastPinchRotation); 41957 _this.props.onRotationChange && _this.props.onRotationChange(newRotation); 41958 _this.lastPinchRotation = rotation; 41959 }); 41960 }; 41961 41962 Cropper.prototype.render = function () { 41963 var _this = this; 41964 41965 var _a = this.props, 41966 image = _a.image, 41967 video = _a.video, 41968 mediaProps = _a.mediaProps, 41969 transform = _a.transform, 41970 _b = _a.crop, 41971 x = _b.x, 41972 y = _b.y, 41973 rotation = _a.rotation, 41974 zoom = _a.zoom, 41975 cropShape = _a.cropShape, 41976 showGrid = _a.showGrid, 41977 _c = _a.style, 41978 containerStyle = _c.containerStyle, 41979 cropAreaStyle = _c.cropAreaStyle, 41980 mediaStyle = _c.mediaStyle, 41981 _d = _a.classes, 41982 containerClassName = _d.containerClassName, 41983 cropAreaClassName = _d.cropAreaClassName, 41984 mediaClassName = _d.mediaClassName, 41985 objectFit = _a.objectFit; 41986 return /*#__PURE__*/external_React_default().createElement("div", { 41987 onMouseDown: this.onMouseDown, 41988 onTouchStart: this.onTouchStart, 41989 ref: function ref(el) { 41990 return _this.containerRef = el; 41991 }, 41992 "data-testid": "container", 41993 style: containerStyle, 41994 className: classNames('reactEasyCrop_Container', containerClassName) 41995 }, image ? /*#__PURE__*/external_React_default().createElement("img", __assign({ 41996 alt: "", 41997 className: classNames('reactEasyCrop_Image', objectFit === 'contain' && 'reactEasyCrop_Contain', objectFit === 'horizontal-cover' && 'reactEasyCrop_Cover_Horizontal', objectFit === 'vertical-cover' && 'reactEasyCrop_Cover_Vertical', mediaClassName) 41998 }, mediaProps, { 41999 src: image, 42000 ref: function ref(el) { 42001 return _this.imageRef = el; 42002 }, 42003 style: __assign(__assign({}, mediaStyle), { 42004 transform: transform || "translate(" + x + "px, " + y + "px) rotate(" + rotation + "deg) scale(" + zoom + ")" 42005 }), 42006 onLoad: this.onMediaLoad 42007 })) : video && /*#__PURE__*/external_React_default().createElement("video", __assign({ 42008 autoPlay: true, 42009 loop: true, 42010 muted: true, 42011 className: classNames('reactEasyCrop_Video', objectFit === 'contain' && 'reactEasyCrop_Contain', objectFit === 'horizontal-cover' && 'reactEasyCrop_Cover_Horizontal', objectFit === 'vertical-cover' && 'reactEasyCrop_Cover_Vertical', mediaClassName) 42012 }, mediaProps, { 42013 ref: function ref(el) { 42014 return _this.videoRef = el; 42015 }, 42016 onLoadedMetadata: this.onMediaLoad, 42017 style: __assign(__assign({}, mediaStyle), { 42018 transform: transform || "translate(" + x + "px, " + y + "px) rotate(" + rotation + "deg) scale(" + zoom + ")" 42019 }), 42020 controls: false 42021 }), (Array.isArray(video) ? video : [{ 42022 src: video 42023 }]).map(function (item) { 42024 return /*#__PURE__*/external_React_default().createElement("source", __assign({ 42025 key: item.src 42026 }, item)); 42027 })), this.state.cropSize && /*#__PURE__*/external_React_default().createElement("div", { 42028 style: __assign(__assign({}, cropAreaStyle), { 42029 width: this.state.cropSize.width, 42030 height: this.state.cropSize.height 42031 }), 42032 "data-testid": "cropper", 42033 className: classNames('reactEasyCrop_CropArea', cropShape === 'round' && 'reactEasyCrop_CropAreaRound', showGrid && 'reactEasyCrop_CropAreaGrid', cropAreaClassName) 42034 })); 42035 }; 42036 42037 Cropper.defaultProps = { 42038 zoom: 1, 42039 rotation: 0, 42040 aspect: 4 / 3, 42041 maxZoom: MAX_ZOOM, 42042 minZoom: MIN_ZOOM, 42043 cropShape: 'rect', 42044 objectFit: 'contain', 42045 showGrid: true, 42046 style: {}, 42047 classes: {}, 42048 mediaProps: {}, 42049 zoomSpeed: 1, 42050 restrictPosition: true, 42051 zoomWithScroll: true 42052 }; 42053 42054 Cropper.getMousePoint = function (e) { 42055 return { 42056 x: Number(e.clientX), 42057 y: Number(e.clientY) 42058 }; 42059 }; 42060 42061 Cropper.getTouchPoint = function (touch) { 42062 return { 42063 x: Number(touch.clientX), 42064 y: Number(touch.clientY) 42065 }; 42066 }; 42067 42068 return Cropper; 42069 }((external_React_default()).Component); 42070 42071 /* harmony default export */ var index_module = (Cropper); 42072 42073 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/constants.js 42074 const constants_MIN_ZOOM = 100; 42075 const constants_MAX_ZOOM = 300; 42076 const constants_POPOVER_PROPS = { 42077 position: 'bottom right', 42078 isAlternate: true 42079 }; 42080 42081 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/use-save-image.js 42082 /** 42083 * WordPress dependencies 42084 */ 42085 42086 42087 42088 42089 42090 function useSaveImage(_ref) { 42091 let { 42092 crop, 42093 rotation, 42094 height, 42095 width, 42096 aspect, 42097 url, 42098 id, 42099 onSaveImage, 42100 onFinishEditing 42101 } = _ref; 42102 const { 42103 createErrorNotice 42104 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 42105 const [isInProgress, setIsInProgress] = (0,external_wp_element_namespaceObject.useState)(false); 42106 const cancel = (0,external_wp_element_namespaceObject.useCallback)(() => { 42107 setIsInProgress(false); 42108 onFinishEditing(); 42109 }, [setIsInProgress, onFinishEditing]); 42110 const apply = (0,external_wp_element_namespaceObject.useCallback)(() => { 42111 setIsInProgress(true); 42112 let attrs = {}; // The crop script may return some very small, sub-pixel values when the image was not cropped. 42113 // Crop only when the new size has changed by more than 0.1%. 42114 42115 if (crop.width < 99.9 || crop.height < 99.9) { 42116 attrs = crop; 42117 } 42118 42119 if (rotation > 0) { 42120 attrs.rotation = rotation; 42121 } 42122 42123 attrs.src = url; 42124 external_wp_apiFetch_default()({ 42125 path: `/wp/v2/media/$id}/edit`, 42126 method: 'POST', 42127 data: attrs 42128 }).then(response => { 42129 onSaveImage({ 42130 id: response.id, 42131 url: response.source_url, 42132 height: height && width ? width / aspect : undefined 42133 }); 42134 }).catch(error => { 42135 createErrorNotice((0,external_wp_i18n_namespaceObject.sprintf)( 42136 /* translators: 1. Error message */ 42137 (0,external_wp_i18n_namespaceObject.__)('Could not edit image. %s'), error.message), { 42138 id: 'image-editing-error', 42139 type: 'snackbar' 42140 }); 42141 }).finally(() => { 42142 setIsInProgress(false); 42143 onFinishEditing(); 42144 }); 42145 }, [setIsInProgress, crop, rotation, height, width, aspect, url, onSaveImage, createErrorNotice, setIsInProgress, onFinishEditing]); 42146 return (0,external_wp_element_namespaceObject.useMemo)(() => ({ 42147 isInProgress, 42148 apply, 42149 cancel 42150 }), [isInProgress, apply, cancel]); 42151 } 42152 42153 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/use-transform-image.js 42154 /** 42155 * WordPress dependencies 42156 */ 42157 42158 42159 42160 function useTransformState(_ref) { 42161 let { 42162 url, 42163 naturalWidth, 42164 naturalHeight 42165 } = _ref; 42166 const [editedUrl, setEditedUrl] = (0,external_wp_element_namespaceObject.useState)(); 42167 const [crop, setCrop] = (0,external_wp_element_namespaceObject.useState)(); 42168 const [position, setPosition] = (0,external_wp_element_namespaceObject.useState)({ 42169 x: 0, 42170 y: 0 42171 }); 42172 const [zoom, setZoom] = (0,external_wp_element_namespaceObject.useState)(); 42173 const [rotation, setRotation] = (0,external_wp_element_namespaceObject.useState)(); 42174 const [aspect, setAspect] = (0,external_wp_element_namespaceObject.useState)(); 42175 const [defaultAspect, setDefaultAspect] = (0,external_wp_element_namespaceObject.useState)(); 42176 const initializeTransformValues = (0,external_wp_element_namespaceObject.useCallback)(() => { 42177 setPosition({ 42178 x: 0, 42179 y: 0 42180 }); 42181 setZoom(100); 42182 setRotation(0); 42183 setAspect(naturalWidth / naturalHeight); 42184 setDefaultAspect(naturalWidth / naturalHeight); 42185 }, [naturalWidth, naturalHeight, setPosition, setZoom, setRotation, setAspect, setDefaultAspect]); 42186 const rotateClockwise = (0,external_wp_element_namespaceObject.useCallback)(() => { 42187 const angle = (rotation + 90) % 360; 42188 let naturalAspectRatio = naturalWidth / naturalHeight; 42189 42190 if (rotation % 180 === 90) { 42191 naturalAspectRatio = naturalHeight / naturalWidth; 42192 } 42193 42194 if (angle === 0) { 42195 setEditedUrl(); 42196 setRotation(angle); 42197 setAspect(1 / aspect); 42198 setPosition({ 42199 x: -(position.y * naturalAspectRatio), 42200 y: position.x * naturalAspectRatio 42201 }); 42202 return; 42203 } 42204 42205 function editImage(event) { 42206 const canvas = document.createElement('canvas'); 42207 let translateX = 0; 42208 let translateY = 0; 42209 42210 if (angle % 180) { 42211 canvas.width = event.target.height; 42212 canvas.height = event.target.width; 42213 } else { 42214 canvas.width = event.target.width; 42215 canvas.height = event.target.height; 42216 } 42217 42218 if (angle === 90 || angle === 180) { 42219 translateX = canvas.width; 42220 } 42221 42222 if (angle === 270 || angle === 180) { 42223 translateY = canvas.height; 42224 } 42225 42226 const context = canvas.getContext('2d'); 42227 context.translate(translateX, translateY); 42228 context.rotate(angle * Math.PI / 180); 42229 context.drawImage(event.target, 0, 0); 42230 canvas.toBlob(blob => { 42231 setEditedUrl(URL.createObjectURL(blob)); 42232 setRotation(angle); 42233 setAspect(1 / aspect); 42234 setPosition({ 42235 x: -(position.y * naturalAspectRatio), 42236 y: position.x * naturalAspectRatio 42237 }); 42238 }); 42239 } 42240 42241 const el = new window.Image(); 42242 el.src = url; 42243 el.onload = editImage; 42244 const imgCrossOrigin = (0,external_wp_hooks_namespaceObject.applyFilters)('media.crossOrigin', undefined, url); 42245 42246 if (typeof imgCrossOrigin === 'string') { 42247 el.crossOrigin = imgCrossOrigin; 42248 } 42249 }, [rotation, naturalWidth, naturalHeight, setEditedUrl, setRotation, setAspect, setPosition]); 42250 return (0,external_wp_element_namespaceObject.useMemo)(() => ({ 42251 editedUrl, 42252 setEditedUrl, 42253 crop, 42254 setCrop, 42255 position, 42256 setPosition, 42257 zoom, 42258 setZoom, 42259 rotation, 42260 setRotation, 42261 rotateClockwise, 42262 aspect, 42263 setAspect, 42264 defaultAspect, 42265 initializeTransformValues 42266 }), [editedUrl, setEditedUrl, crop, setCrop, position, setPosition, zoom, setZoom, rotation, setRotation, rotateClockwise, aspect, setAspect, defaultAspect, initializeTransformValues]); 42267 } 42268 42269 function useTransformImage(imageProperties, isEditing) { 42270 const transformState = useTransformState(imageProperties); 42271 const { 42272 initializeTransformValues 42273 } = transformState; 42274 (0,external_wp_element_namespaceObject.useEffect)(() => { 42275 if (isEditing) { 42276 initializeTransformValues(); 42277 } 42278 }, [isEditing, initializeTransformValues]); 42279 return transformState; 42280 } 42281 42282 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/context.js 42283 42284 42285 /** 42286 * WordPress dependencies 42287 */ 42288 42289 /** 42290 * Internal dependencies 42291 */ 42292 42293 42294 42295 const ImageEditingContext = (0,external_wp_element_namespaceObject.createContext)({}); 42296 const useImageEditingContext = () => (0,external_wp_element_namespaceObject.useContext)(ImageEditingContext); 42297 function ImageEditingProvider(_ref) { 42298 let { 42299 id, 42300 url, 42301 naturalWidth, 42302 naturalHeight, 42303 isEditing, 42304 onFinishEditing, 42305 onSaveImage, 42306 children 42307 } = _ref; 42308 const transformImage = useTransformImage({ 42309 url, 42310 naturalWidth, 42311 naturalHeight 42312 }, isEditing); 42313 const saveImage = useSaveImage({ 42314 id, 42315 url, 42316 onSaveImage, 42317 onFinishEditing, 42318 ...transformImage 42319 }); 42320 const providerValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...transformImage, 42321 ...saveImage 42322 }), [transformImage, saveImage]); 42323 return (0,external_wp_element_namespaceObject.createElement)(ImageEditingContext.Provider, { 42324 value: providerValue 42325 }, children); 42326 } 42327 42328 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/cropper.js 42329 42330 42331 /** 42332 * External dependencies 42333 */ 42334 42335 42336 /** 42337 * WordPress dependencies 42338 */ 42339 42340 42341 /** 42342 * Internal dependencies 42343 */ 42344 42345 42346 42347 function ImageCropper(_ref) { 42348 let { 42349 url, 42350 width, 42351 height, 42352 clientWidth, 42353 naturalHeight, 42354 naturalWidth 42355 } = _ref; 42356 const { 42357 isInProgress, 42358 editedUrl, 42359 position, 42360 zoom, 42361 aspect, 42362 setPosition, 42363 setCrop, 42364 setZoom, 42365 rotation 42366 } = useImageEditingContext(); 42367 let editedHeight = height || clientWidth * naturalHeight / naturalWidth; 42368 42369 if (rotation % 180 === 90) { 42370 editedHeight = clientWidth * naturalWidth / naturalHeight; 42371 } 42372 42373 return (0,external_wp_element_namespaceObject.createElement)("div", { 42374 className: classnames_default()('wp-block-image__crop-area', { 42375 'is-applying': isInProgress 42376 }), 42377 style: { 42378 width: width || clientWidth, 42379 height: editedHeight 42380 } 42381 }, (0,external_wp_element_namespaceObject.createElement)(index_module, { 42382 image: editedUrl || url, 42383 disabled: isInProgress, 42384 minZoom: constants_MIN_ZOOM / 100, 42385 maxZoom: constants_MAX_ZOOM / 100, 42386 crop: position, 42387 zoom: zoom / 100, 42388 aspect: aspect, 42389 onCropChange: setPosition, 42390 onCropComplete: newCropPercent => { 42391 setCrop(newCropPercent); 42392 }, 42393 onZoomChange: newZoom => { 42394 setZoom(newZoom * 100); 42395 } 42396 }), isInProgress && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null)); 42397 } 42398 42399 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/search.js 42400 42401 42402 /** 42403 * WordPress dependencies 42404 */ 42405 42406 const search = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 42407 xmlns: "http://www.w3.org/2000/svg", 42408 viewBox: "0 0 24 24" 42409 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 42410 d: "M13.5 6C10.5 6 8 8.5 8 11.5c0 1.1.3 2.1.9 3l-3.4 3 1 1.1 3.4-2.9c1 .9 2.2 1.4 3.6 1.4 3 0 5.5-2.5 5.5-5.5C19 8.5 16.5 6 13.5 6zm0 9.5c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4z" 42411 })); 42412 /* harmony default export */ var library_search = (search); 42413 42414 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/zoom-dropdown.js 42415 42416 42417 /** 42418 * WordPress dependencies 42419 */ 42420 42421 42422 42423 /** 42424 * Internal dependencies 42425 */ 42426 42427 42428 42429 function ZoomDropdown() { 42430 const { 42431 isInProgress, 42432 zoom, 42433 setZoom 42434 } = useImageEditingContext(); 42435 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, { 42436 contentClassName: "wp-block-image__zoom", 42437 popoverProps: constants_POPOVER_PROPS, 42438 renderToggle: _ref => { 42439 let { 42440 isOpen, 42441 onToggle 42442 } = _ref; 42443 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 42444 icon: library_search, 42445 label: (0,external_wp_i18n_namespaceObject.__)('Zoom'), 42446 onClick: onToggle, 42447 "aria-expanded": isOpen, 42448 disabled: isInProgress 42449 }); 42450 }, 42451 renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.RangeControl, { 42452 label: (0,external_wp_i18n_namespaceObject.__)('Zoom'), 42453 min: constants_MIN_ZOOM, 42454 max: constants_MAX_ZOOM, 42455 value: Math.round(zoom), 42456 onChange: setZoom 42457 }) 42458 }); 42459 } 42460 42461 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/aspect-ratio.js 42462 42463 42464 /** 42465 * WordPress dependencies 42466 */ 42467 42468 const aspectRatio = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 42469 xmlns: "http://www.w3.org/2000/svg", 42470 viewBox: "0 0 24 24" 42471 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 42472 d: "M18.5 5.5h-13c-1.1 0-2 .9-2 2v9c0 1.1.9 2 2 2h13c1.1 0 2-.9 2-2v-9c0-1.1-.9-2-2-2zm.5 11c0 .3-.2.5-.5.5h-13c-.3 0-.5-.2-.5-.5v-9c0-.3.2-.5.5-.5h13c.3 0 .5.2.5.5v9zM6.5 12H8v-2h2V8.5H6.5V12zm9.5 2h-2v1.5h3.5V12H16v2z" 42473 })); 42474 /* harmony default export */ var aspect_ratio = (aspectRatio); 42475 42476 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/aspect-ratio-dropdown.js 42477 42478 42479 /** 42480 * WordPress dependencies 42481 */ 42482 42483 42484 42485 /** 42486 * Internal dependencies 42487 */ 42488 42489 42490 42491 42492 function AspectGroup(_ref) { 42493 let { 42494 aspectRatios, 42495 isDisabled, 42496 label, 42497 onClick, 42498 value 42499 } = _ref; 42500 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, { 42501 label: label 42502 }, aspectRatios.map(_ref2 => { 42503 let { 42504 title, 42505 aspect 42506 } = _ref2; 42507 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 42508 key: aspect, 42509 disabled: isDisabled, 42510 onClick: () => { 42511 onClick(aspect); 42512 }, 42513 role: "menuitemradio", 42514 isSelected: aspect === value, 42515 icon: aspect === value ? library_check : undefined 42516 }, title); 42517 })); 42518 } 42519 42520 function AspectRatioDropdown(_ref3) { 42521 let { 42522 toggleProps 42523 } = _ref3; 42524 const { 42525 isInProgress, 42526 aspect, 42527 setAspect, 42528 defaultAspect 42529 } = useImageEditingContext(); 42530 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 42531 icon: aspect_ratio, 42532 label: (0,external_wp_i18n_namespaceObject.__)('Aspect Ratio'), 42533 popoverProps: constants_POPOVER_PROPS, 42534 toggleProps: toggleProps, 42535 className: "wp-block-image__aspect-ratio" 42536 }, _ref4 => { 42537 let { 42538 onClose 42539 } = _ref4; 42540 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(AspectGroup, { 42541 isDisabled: isInProgress, 42542 onClick: newAspect => { 42543 setAspect(newAspect); 42544 onClose(); 42545 }, 42546 value: aspect, 42547 aspectRatios: [{ 42548 title: (0,external_wp_i18n_namespaceObject.__)('Original'), 42549 aspect: defaultAspect 42550 }, { 42551 title: (0,external_wp_i18n_namespaceObject.__)('Square'), 42552 aspect: 1 42553 }] 42554 }), (0,external_wp_element_namespaceObject.createElement)(AspectGroup, { 42555 label: (0,external_wp_i18n_namespaceObject.__)('Landscape'), 42556 isDisabled: isInProgress, 42557 onClick: newAspect => { 42558 setAspect(newAspect); 42559 onClose(); 42560 }, 42561 value: aspect, 42562 aspectRatios: [{ 42563 title: (0,external_wp_i18n_namespaceObject.__)('16:10'), 42564 aspect: 16 / 10 42565 }, { 42566 title: (0,external_wp_i18n_namespaceObject.__)('16:9'), 42567 aspect: 16 / 9 42568 }, { 42569 title: (0,external_wp_i18n_namespaceObject.__)('4:3'), 42570 aspect: 4 / 3 42571 }, { 42572 title: (0,external_wp_i18n_namespaceObject.__)('3:2'), 42573 aspect: 3 / 2 42574 }] 42575 }), (0,external_wp_element_namespaceObject.createElement)(AspectGroup, { 42576 label: (0,external_wp_i18n_namespaceObject.__)('Portrait'), 42577 isDisabled: isInProgress, 42578 onClick: newAspect => { 42579 setAspect(newAspect); 42580 onClose(); 42581 }, 42582 value: aspect, 42583 aspectRatios: [{ 42584 title: (0,external_wp_i18n_namespaceObject.__)('10:16'), 42585 aspect: 10 / 16 42586 }, { 42587 title: (0,external_wp_i18n_namespaceObject.__)('9:16'), 42588 aspect: 9 / 16 42589 }, { 42590 title: (0,external_wp_i18n_namespaceObject.__)('3:4'), 42591 aspect: 3 / 4 42592 }, { 42593 title: (0,external_wp_i18n_namespaceObject.__)('2:3'), 42594 aspect: 2 / 3 42595 }] 42596 })); 42597 }); 42598 } 42599 42600 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/rotate-right.js 42601 42602 42603 /** 42604 * WordPress dependencies 42605 */ 42606 42607 const rotateRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 42608 xmlns: "http://www.w3.org/2000/svg", 42609 viewBox: "0 0 24 24" 42610 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 42611 d: "M15.1 4.8l-3-2.5V4c-4.4 0-8 3.6-8 8 0 3.7 2.5 6.9 6 7.7.3.1.6.1 1 .2l.2-1.5c-.4 0-.7-.1-1.1-.2l-.1.2v-.2c-2.6-.8-4.5-3.3-4.5-6.2 0-3.6 2.9-6.5 6.5-6.5v1.8l3-2.5zM20 11c-.2-1.4-.7-2.7-1.6-3.8l-1.2.8c.7.9 1.1 2 1.3 3.1L20 11zm-1.5 1.8c-.1.5-.2 1.1-.4 1.6s-.5 1-.8 1.5l1.2.9c.4-.5.8-1.1 1-1.8s.5-1.3.5-2l-1.5-.2zm-5.6 5.6l.2 1.5c1.4-.2 2.7-.7 3.8-1.6l-.9-1.1c-.9.7-2 1.1-3.1 1.2z" 42612 })); 42613 /* harmony default export */ var rotate_right = (rotateRight); 42614 42615 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/rotation-button.js 42616 42617 42618 /** 42619 * WordPress dependencies 42620 */ 42621 42622 42623 42624 /** 42625 * Internal dependencies 42626 */ 42627 42628 42629 function RotationButton() { 42630 const { 42631 isInProgress, 42632 rotateClockwise 42633 } = useImageEditingContext(); 42634 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 42635 icon: rotate_right, 42636 label: (0,external_wp_i18n_namespaceObject.__)('Rotate'), 42637 onClick: rotateClockwise, 42638 disabled: isInProgress 42639 }); 42640 } 42641 42642 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/form-controls.js 42643 42644 42645 /** 42646 * WordPress dependencies 42647 */ 42648 42649 42650 /** 42651 * Internal dependencies 42652 */ 42653 42654 42655 function FormControls() { 42656 const { 42657 isInProgress, 42658 apply, 42659 cancel 42660 } = useImageEditingContext(); 42661 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 42662 onClick: apply, 42663 disabled: isInProgress 42664 }, (0,external_wp_i18n_namespaceObject.__)('Apply')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 42665 onClick: cancel 42666 }, (0,external_wp_i18n_namespaceObject.__)('Cancel'))); 42667 } 42668 42669 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-editor/index.js 42670 42671 42672 /** 42673 * WordPress dependencies 42674 */ 42675 42676 /** 42677 * Internal dependencies 42678 */ 42679 42680 42681 42682 42683 42684 42685 42686 function ImageEditor(_ref) { 42687 let { 42688 url, 42689 width, 42690 height, 42691 clientWidth, 42692 naturalHeight, 42693 naturalWidth 42694 } = _ref; 42695 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(ImageCropper, { 42696 url: url, 42697 width: width, 42698 height: height, 42699 clientWidth: clientWidth, 42700 naturalHeight: naturalHeight, 42701 naturalWidth: naturalWidth 42702 }), (0,external_wp_element_namespaceObject.createElement)(block_controls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(ZoomDropdown, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, null, toggleProps => (0,external_wp_element_namespaceObject.createElement)(AspectRatioDropdown, { 42703 toggleProps: toggleProps 42704 })), (0,external_wp_element_namespaceObject.createElement)(RotationButton, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(FormControls, null)))); 42705 } 42706 42707 42708 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-size-control/use-dimension-handler.js 42709 /** 42710 * WordPress dependencies 42711 */ 42712 42713 function useDimensionHandler(customHeight, customWidth, defaultHeight, defaultWidth, onChange) { 42714 var _ref, _ref2; 42715 42716 const [currentWidth, setCurrentWidth] = (0,external_wp_element_namespaceObject.useState)((_ref = customWidth !== null && customWidth !== void 0 ? customWidth : defaultWidth) !== null && _ref !== void 0 ? _ref : ''); 42717 const [currentHeight, setCurrentHeight] = (0,external_wp_element_namespaceObject.useState)((_ref2 = customHeight !== null && customHeight !== void 0 ? customHeight : defaultHeight) !== null && _ref2 !== void 0 ? _ref2 : ''); // When an image is first inserted, the default dimensions are initially 42718 // undefined. This effect updates the dimensions when the default values 42719 // come through. 42720 42721 (0,external_wp_element_namespaceObject.useEffect)(() => { 42722 if (customWidth === undefined && defaultWidth !== undefined) { 42723 setCurrentWidth(defaultWidth); 42724 } 42725 42726 if (customHeight === undefined && defaultHeight !== undefined) { 42727 setCurrentHeight(defaultHeight); 42728 } 42729 }, [defaultWidth, defaultHeight]); // If custom values change, it means an outsider has resized the image using some other method (eg resize box) 42730 // this keeps track of these values too. We need to parse before comparing; custom values can be strings. 42731 42732 (0,external_wp_element_namespaceObject.useEffect)(() => { 42733 if (customWidth !== undefined && Number.parseInt(customWidth) !== Number.parseInt(currentWidth)) { 42734 setCurrentWidth(customWidth); 42735 } 42736 42737 if (customHeight !== undefined && Number.parseInt(customHeight) !== Number.parseInt(currentHeight)) { 42738 setCurrentHeight(customHeight); 42739 } 42740 }, [customWidth, customHeight]); 42741 42742 const updateDimension = (dimension, value) => { 42743 if (dimension === 'width') { 42744 setCurrentWidth(value); 42745 } else { 42746 setCurrentHeight(value); 42747 } 42748 42749 onChange({ 42750 [dimension]: value === '' ? undefined : parseInt(value, 10) 42751 }); 42752 }; 42753 42754 const updateDimensions = (nextHeight, nextWidth) => { 42755 setCurrentHeight(nextHeight !== null && nextHeight !== void 0 ? nextHeight : defaultHeight); 42756 setCurrentWidth(nextWidth !== null && nextWidth !== void 0 ? nextWidth : defaultWidth); 42757 onChange({ 42758 height: nextHeight, 42759 width: nextWidth 42760 }); 42761 }; 42762 42763 return { 42764 currentHeight, 42765 currentWidth, 42766 updateDimension, 42767 updateDimensions 42768 }; 42769 } 42770 42771 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-size-control/index.js 42772 42773 42774 /** 42775 * External dependencies 42776 */ 42777 42778 /** 42779 * WordPress dependencies 42780 */ 42781 42782 42783 42784 /** 42785 * Internal dependencies 42786 */ 42787 42788 42789 const IMAGE_SIZE_PRESETS = [25, 50, 75, 100]; 42790 function ImageSizeControl(_ref) { 42791 let { 42792 imageWidth, 42793 imageHeight, 42794 imageSizeOptions = [], 42795 isResizable = true, 42796 slug, 42797 width, 42798 height, 42799 onChange, 42800 onChangeImage = external_lodash_namespaceObject.noop 42801 } = _ref; 42802 const { 42803 currentHeight, 42804 currentWidth, 42805 updateDimension, 42806 updateDimensions 42807 } = useDimensionHandler(height, width, imageHeight, imageWidth, onChange); 42808 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !(0,external_lodash_namespaceObject.isEmpty)(imageSizeOptions) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, { 42809 label: (0,external_wp_i18n_namespaceObject.__)('Image size'), 42810 value: slug, 42811 options: imageSizeOptions, 42812 onChange: onChangeImage 42813 }), isResizable && (0,external_wp_element_namespaceObject.createElement)("div", { 42814 className: "block-editor-image-size-control" 42815 }, (0,external_wp_element_namespaceObject.createElement)("p", { 42816 className: "block-editor-image-size-control__row" 42817 }, (0,external_wp_i18n_namespaceObject.__)('Image dimensions')), (0,external_wp_element_namespaceObject.createElement)("div", { 42818 className: "block-editor-image-size-control__row" 42819 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { 42820 type: "number", 42821 className: "block-editor-image-size-control__width", 42822 label: (0,external_wp_i18n_namespaceObject.__)('Width'), 42823 value: currentWidth, 42824 min: 1, 42825 onChange: value => updateDimension('width', value) 42826 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { 42827 type: "number", 42828 className: "block-editor-image-size-control__height", 42829 label: (0,external_wp_i18n_namespaceObject.__)('Height'), 42830 value: currentHeight, 42831 min: 1, 42832 onChange: value => updateDimension('height', value) 42833 })), (0,external_wp_element_namespaceObject.createElement)("div", { 42834 className: "block-editor-image-size-control__row" 42835 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ButtonGroup, { 42836 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Image size presets') 42837 }, IMAGE_SIZE_PRESETS.map(scale => { 42838 const scaledWidth = Math.round(imageWidth * (scale / 100)); 42839 const scaledHeight = Math.round(imageHeight * (scale / 100)); 42840 const isCurrent = currentWidth === scaledWidth && currentHeight === scaledHeight; 42841 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 42842 key: scale, 42843 isSmall: true, 42844 variant: isCurrent ? 'primary' : undefined, 42845 isPressed: isCurrent, 42846 onClick: () => updateDimensions(scaledHeight, scaledWidth) 42847 }, scale, "%"); 42848 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 42849 isSmall: true, 42850 onClick: () => updateDimensions() 42851 }, (0,external_wp_i18n_namespaceObject.__)('Reset'))))); 42852 } 42853 42854 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/keyboard-return.js 42855 42856 42857 /** 42858 * WordPress dependencies 42859 */ 42860 42861 const keyboardReturn = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 42862 xmlns: "http://www.w3.org/2000/svg", 42863 viewBox: "-2 -2 24 24" 42864 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 42865 d: "M6.734 16.106l2.176-2.38-1.093-1.028-3.846 4.158 3.846 4.157 1.093-1.027-2.176-2.38h2.811c1.125 0 2.25.03 3.374 0 1.428-.001 3.362-.25 4.963-1.277 1.66-1.065 2.868-2.906 2.868-5.859 0-2.479-1.327-4.896-3.65-5.93-1.82-.813-3.044-.8-4.806-.788l-.567.002v1.5c.184 0 .368 0 .553-.002 1.82-.007 2.704-.014 4.21.657 1.854.827 2.76 2.657 2.76 4.561 0 2.472-.973 3.824-2.178 4.596-1.258.807-2.864 1.04-4.163 1.04h-.02c-1.115.03-2.229 0-3.344 0H6.734z" 42866 })); 42867 /* harmony default export */ var keyboard_return = (keyboardReturn); 42868 42869 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/settings-drawer.js 42870 42871 42872 /** 42873 * External dependencies 42874 */ 42875 42876 /** 42877 * WordPress dependencies 42878 */ 42879 42880 42881 42882 42883 const LinkControlSettingsDrawer = _ref => { 42884 let { 42885 value, 42886 onChange = external_lodash_namespaceObject.noop, 42887 settings 42888 } = _ref; 42889 42890 if (!settings || !settings.length) { 42891 return null; 42892 } 42893 42894 const handleSettingChange = setting => newValue => { 42895 onChange({ ...value, 42896 [setting.id]: newValue 42897 }); 42898 }; 42899 42900 const theSettings = settings.map(setting => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, { 42901 className: "block-editor-link-control__setting", 42902 key: setting.id, 42903 label: setting.title, 42904 onChange: handleSettingChange(setting), 42905 checked: value ? !!value[setting.id] : false 42906 })); 42907 return (0,external_wp_element_namespaceObject.createElement)("fieldset", { 42908 className: "block-editor-link-control__settings" 42909 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 42910 as: "legend" 42911 }, (0,external_wp_i18n_namespaceObject.__)('Currently selected link settings')), theSettings); 42912 }; 42913 42914 /* harmony default export */ var settings_drawer = (LinkControlSettingsDrawer); 42915 42916 // EXTERNAL MODULE: ./node_modules/dom-scroll-into-view/lib/index.js 42917 var dom_scroll_into_view_lib = __webpack_require__(5425); 42918 var lib_default = /*#__PURE__*/__webpack_require__.n(dom_scroll_into_view_lib); 42919 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-input/index.js 42920 42921 42922 42923 /** 42924 * External dependencies 42925 */ 42926 42927 42928 42929 /** 42930 * WordPress dependencies 42931 */ 42932 42933 42934 42935 42936 42937 42938 42939 42940 /** 42941 * Internal dependencies 42942 */ 42943 42944 42945 42946 class URLInput extends external_wp_element_namespaceObject.Component { 42947 constructor(props) { 42948 super(props); 42949 this.onChange = this.onChange.bind(this); 42950 this.onFocus = this.onFocus.bind(this); 42951 this.onKeyDown = this.onKeyDown.bind(this); 42952 this.selectLink = this.selectLink.bind(this); 42953 this.handleOnClick = this.handleOnClick.bind(this); 42954 this.bindSuggestionNode = this.bindSuggestionNode.bind(this); 42955 this.autocompleteRef = props.autocompleteRef || (0,external_wp_element_namespaceObject.createRef)(); 42956 this.inputRef = (0,external_wp_element_namespaceObject.createRef)(); 42957 this.updateSuggestions = (0,external_lodash_namespaceObject.debounce)(this.updateSuggestions.bind(this), 200); 42958 this.suggestionNodes = []; 42959 this.isUpdatingSuggestions = false; 42960 this.state = { 42961 suggestions: [], 42962 showSuggestions: false, 42963 selectedSuggestion: null, 42964 suggestionsListboxId: '', 42965 suggestionOptionIdPrefix: '' 42966 }; 42967 } 42968 42969 componentDidUpdate(prevProps) { 42970 const { 42971 showSuggestions, 42972 selectedSuggestion 42973 } = this.state; 42974 const { 42975 value, 42976 __experimentalShowInitialSuggestions = false 42977 } = this.props; // Only have to worry about scrolling selected suggestion into view 42978 // when already expanded. 42979 42980 if (showSuggestions && selectedSuggestion !== null && this.suggestionNodes[selectedSuggestion] && !this.scrollingIntoView) { 42981 this.scrollingIntoView = true; 42982 lib_default()(this.suggestionNodes[selectedSuggestion], this.autocompleteRef.current, { 42983 onlyScrollIfNeeded: true 42984 }); 42985 this.props.setTimeout(() => { 42986 this.scrollingIntoView = false; 42987 }, 100); 42988 } // Update suggestions when the value changes. 42989 42990 42991 if (prevProps.value !== value && !this.props.disableSuggestions && !this.isUpdatingSuggestions) { 42992 if (value !== null && value !== void 0 && value.length) { 42993 // If the new value is not empty we need to update with suggestions for it. 42994 this.updateSuggestions(value); 42995 } else if (__experimentalShowInitialSuggestions) { 42996 // If the new value is empty and we can show initial suggestions, then show initial suggestions. 42997 this.updateSuggestions(); 42998 } 42999 } 43000 } 43001 43002 componentDidMount() { 43003 if (this.shouldShowInitialSuggestions()) { 43004 this.updateSuggestions(); 43005 } 43006 } 43007 43008 componentWillUnmount() { 43009 var _this$suggestionsRequ, _this$suggestionsRequ2; 43010 43011 (_this$suggestionsRequ = this.suggestionsRequest) === null || _this$suggestionsRequ === void 0 ? void 0 : (_this$suggestionsRequ2 = _this$suggestionsRequ.cancel) === null || _this$suggestionsRequ2 === void 0 ? void 0 : _this$suggestionsRequ2.call(_this$suggestionsRequ); 43012 delete this.suggestionsRequest; 43013 } 43014 43015 bindSuggestionNode(index) { 43016 return ref => { 43017 this.suggestionNodes[index] = ref; 43018 }; 43019 } 43020 43021 shouldShowInitialSuggestions() { 43022 const { 43023 suggestions 43024 } = this.state; 43025 const { 43026 __experimentalShowInitialSuggestions = false, 43027 value 43028 } = this.props; 43029 return !this.isUpdatingSuggestions && __experimentalShowInitialSuggestions && !(value && value.length) && !(suggestions && suggestions.length); 43030 } 43031 43032 updateSuggestions() { 43033 var _value; 43034 43035 let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 43036 const { 43037 __experimentalFetchLinkSuggestions: fetchLinkSuggestions, 43038 __experimentalHandleURLSuggestions: handleURLSuggestions 43039 } = this.props; 43040 43041 if (!fetchLinkSuggestions) { 43042 return; 43043 } // Initial suggestions may only show if there is no value 43044 // (note: this includes whitespace). 43045 43046 43047 const isInitialSuggestions = !((_value = value) !== null && _value !== void 0 && _value.length); // Trim only now we've determined whether or not it originally had a "length" 43048 // (even if that value was all whitespace). 43049 43050 value = value.trim(); // Allow a suggestions request if: 43051 // - there are at least 2 characters in the search input (except manual searches where 43052 // search input length is not required to trigger a fetch) 43053 // - this is a direct entry (eg: a URL) 43054 43055 if (!isInitialSuggestions && (value.length < 2 || !handleURLSuggestions && (0,external_wp_url_namespaceObject.isURL)(value))) { 43056 this.setState({ 43057 showSuggestions: false, 43058 selectedSuggestion: null, 43059 loading: false 43060 }); 43061 return; 43062 } 43063 43064 this.isUpdatingSuggestions = true; 43065 this.setState({ 43066 selectedSuggestion: null, 43067 loading: true 43068 }); 43069 const request = fetchLinkSuggestions(value, { 43070 isInitialSuggestions 43071 }); 43072 request.then(suggestions => { 43073 // A fetch Promise doesn't have an abort option. It's mimicked by 43074 // comparing the request reference in on the instance, which is 43075 // reset or deleted on subsequent requests or unmounting. 43076 if (this.suggestionsRequest !== request) { 43077 return; 43078 } 43079 43080 this.setState({ 43081 suggestions, 43082 loading: false, 43083 showSuggestions: !!suggestions.length 43084 }); 43085 43086 if (!!suggestions.length) { 43087 this.props.debouncedSpeak((0,external_wp_i18n_namespaceObject.sprintf)( 43088 /* translators: %s: number of results. */ 43089 (0,external_wp_i18n_namespaceObject._n)('%d result found, use up and down arrow keys to navigate.', '%d results found, use up and down arrow keys to navigate.', suggestions.length), suggestions.length), 'assertive'); 43090 } else { 43091 this.props.debouncedSpeak((0,external_wp_i18n_namespaceObject.__)('No results.'), 'assertive'); 43092 } 43093 43094 this.isUpdatingSuggestions = false; 43095 }).catch(() => { 43096 if (this.suggestionsRequest === request) { 43097 this.setState({ 43098 loading: false 43099 }); 43100 this.isUpdatingSuggestions = false; 43101 } 43102 }); // Note that this assignment is handled *before* the async search request 43103 // as a Promise always resolves on the next tick of the event loop. 43104 43105 this.suggestionsRequest = request; 43106 } 43107 43108 onChange(event) { 43109 const inputValue = event.target.value; 43110 this.props.onChange(inputValue); 43111 43112 if (!this.props.disableSuggestions) { 43113 this.updateSuggestions(inputValue); 43114 } 43115 } 43116 43117 onFocus() { 43118 const { 43119 suggestions 43120 } = this.state; 43121 const { 43122 disableSuggestions, 43123 value 43124 } = this.props; // When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value 43125 // Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons) 43126 43127 if (value && !disableSuggestions && !this.isUpdatingSuggestions && !(suggestions && suggestions.length)) { 43128 // Ensure the suggestions are updated with the current input value. 43129 this.updateSuggestions(value); 43130 } 43131 } 43132 43133 onKeyDown(event) { 43134 const { 43135 showSuggestions, 43136 selectedSuggestion, 43137 suggestions, 43138 loading 43139 } = this.state; // If the suggestions are not shown or loading, we shouldn't handle the arrow keys 43140 // We shouldn't preventDefault to allow block arrow keys navigation. 43141 43142 if (!showSuggestions || !suggestions.length || loading) { 43143 // In the Windows version of Firefox the up and down arrows don't move the caret 43144 // within an input field like they do for Mac Firefox/Chrome/Safari. This causes 43145 // a form of focus trapping that is disruptive to the user experience. This disruption 43146 // only happens if the caret is not in the first or last position in the text input. 43147 // See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747 43148 switch (event.keyCode) { 43149 // When UP is pressed, if the caret is at the start of the text, move it to the 0 43150 // position. 43151 case external_wp_keycodes_namespaceObject.UP: 43152 { 43153 if (0 !== event.target.selectionStart) { 43154 event.preventDefault(); // Set the input caret to position 0. 43155 43156 event.target.setSelectionRange(0, 0); 43157 } 43158 43159 break; 43160 } 43161 // When DOWN is pressed, if the caret is not at the end of the text, move it to the 43162 // last position. 43163 43164 case external_wp_keycodes_namespaceObject.DOWN: 43165 { 43166 if (this.props.value.length !== event.target.selectionStart) { 43167 event.preventDefault(); // Set the input caret to the last position. 43168 43169 event.target.setSelectionRange(this.props.value.length, this.props.value.length); 43170 } 43171 43172 break; 43173 } 43174 // Submitting while loading should trigger onSubmit. 43175 43176 case external_wp_keycodes_namespaceObject.ENTER: 43177 { 43178 if (this.props.onSubmit) { 43179 this.props.onSubmit(null, event); 43180 } 43181 43182 break; 43183 } 43184 } 43185 43186 return; 43187 } 43188 43189 const suggestion = this.state.suggestions[this.state.selectedSuggestion]; 43190 43191 switch (event.keyCode) { 43192 case external_wp_keycodes_namespaceObject.UP: 43193 { 43194 event.preventDefault(); 43195 const previousIndex = !selectedSuggestion ? suggestions.length - 1 : selectedSuggestion - 1; 43196 this.setState({ 43197 selectedSuggestion: previousIndex 43198 }); 43199 break; 43200 } 43201 43202 case external_wp_keycodes_namespaceObject.DOWN: 43203 { 43204 event.preventDefault(); 43205 const nextIndex = selectedSuggestion === null || selectedSuggestion === suggestions.length - 1 ? 0 : selectedSuggestion + 1; 43206 this.setState({ 43207 selectedSuggestion: nextIndex 43208 }); 43209 break; 43210 } 43211 43212 case external_wp_keycodes_namespaceObject.TAB: 43213 { 43214 if (this.state.selectedSuggestion !== null) { 43215 this.selectLink(suggestion); // Announce a link has been selected when tabbing away from the input field. 43216 43217 this.props.speak((0,external_wp_i18n_namespaceObject.__)('Link selected.')); 43218 } 43219 43220 break; 43221 } 43222 43223 case external_wp_keycodes_namespaceObject.ENTER: 43224 { 43225 if (this.state.selectedSuggestion !== null) { 43226 this.selectLink(suggestion); 43227 43228 if (this.props.onSubmit) { 43229 this.props.onSubmit(suggestion, event); 43230 } 43231 } else if (this.props.onSubmit) { 43232 this.props.onSubmit(null, event); 43233 } 43234 43235 break; 43236 } 43237 } 43238 } 43239 43240 selectLink(suggestion) { 43241 this.props.onChange(suggestion.url, suggestion); 43242 this.setState({ 43243 selectedSuggestion: null, 43244 showSuggestions: false 43245 }); 43246 } 43247 43248 handleOnClick(suggestion) { 43249 this.selectLink(suggestion); // Move focus to the input field when a link suggestion is clicked. 43250 43251 this.inputRef.current.focus(); 43252 } 43253 43254 static getDerivedStateFromProps(_ref, _ref2) { 43255 let { 43256 value, 43257 instanceId, 43258 disableSuggestions, 43259 __experimentalShowInitialSuggestions = false 43260 } = _ref; 43261 let { 43262 showSuggestions 43263 } = _ref2; 43264 let shouldShowSuggestions = showSuggestions; 43265 const hasValue = value && value.length; 43266 43267 if (!__experimentalShowInitialSuggestions && !hasValue) { 43268 shouldShowSuggestions = false; 43269 } 43270 43271 if (disableSuggestions === true) { 43272 shouldShowSuggestions = false; 43273 } 43274 43275 return { 43276 showSuggestions: shouldShowSuggestions, 43277 suggestionsListboxId: `block-editor-url-input-suggestions-$instanceId}`, 43278 suggestionOptionIdPrefix: `block-editor-url-input-suggestion-$instanceId}` 43279 }; 43280 } 43281 43282 render() { 43283 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, this.renderControl(), this.renderSuggestions()); 43284 } 43285 43286 renderControl() { 43287 const { 43288 label, 43289 className, 43290 isFullWidth, 43291 instanceId, 43292 placeholder = (0,external_wp_i18n_namespaceObject.__)('Paste URL or type to search'), 43293 __experimentalRenderControl: renderControl, 43294 value = '' 43295 } = this.props; 43296 const { 43297 loading, 43298 showSuggestions, 43299 selectedSuggestion, 43300 suggestionsListboxId, 43301 suggestionOptionIdPrefix 43302 } = this.state; 43303 const controlProps = { 43304 id: `url-input-control-$instanceId}`, 43305 label, 43306 className: classnames_default()('block-editor-url-input', className, { 43307 'is-full-width': isFullWidth 43308 }) 43309 }; 43310 const inputProps = { 43311 value, 43312 required: true, 43313 className: 'block-editor-url-input__input', 43314 type: 'text', 43315 onChange: this.onChange, 43316 onFocus: this.onFocus, 43317 placeholder, 43318 onKeyDown: this.onKeyDown, 43319 role: 'combobox', 43320 'aria-label': (0,external_wp_i18n_namespaceObject.__)('URL'), 43321 'aria-expanded': showSuggestions, 43322 'aria-autocomplete': 'list', 43323 'aria-owns': suggestionsListboxId, 43324 'aria-activedescendant': selectedSuggestion !== null ? `$suggestionOptionIdPrefix}-$selectedSuggestion}` : undefined, 43325 ref: this.inputRef 43326 }; 43327 43328 if (renderControl) { 43329 return renderControl(controlProps, inputProps, loading); 43330 } 43331 43332 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl, controlProps, (0,external_wp_element_namespaceObject.createElement)("input", inputProps), loading && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null)); 43333 } 43334 43335 renderSuggestions() { 43336 const { 43337 className, 43338 __experimentalRenderSuggestions: renderSuggestions, 43339 value = '', 43340 __experimentalShowInitialSuggestions = false 43341 } = this.props; 43342 const { 43343 showSuggestions, 43344 suggestions, 43345 selectedSuggestion, 43346 suggestionsListboxId, 43347 suggestionOptionIdPrefix, 43348 loading 43349 } = this.state; 43350 const suggestionsListProps = { 43351 id: suggestionsListboxId, 43352 ref: this.autocompleteRef, 43353 role: 'listbox' 43354 }; 43355 43356 const buildSuggestionItemProps = (suggestion, index) => { 43357 return { 43358 role: 'option', 43359 tabIndex: '-1', 43360 id: `$suggestionOptionIdPrefix}-$index}`, 43361 ref: this.bindSuggestionNode(index), 43362 'aria-selected': index === selectedSuggestion 43363 }; 43364 }; 43365 43366 if ((0,external_lodash_namespaceObject.isFunction)(renderSuggestions) && showSuggestions && !!suggestions.length) { 43367 return renderSuggestions({ 43368 suggestions, 43369 selectedSuggestion, 43370 suggestionsListProps, 43371 buildSuggestionItemProps, 43372 isLoading: loading, 43373 handleSuggestionClick: this.handleOnClick, 43374 isInitialSuggestions: __experimentalShowInitialSuggestions && !(value && value.length) 43375 }); 43376 } 43377 43378 if (!(0,external_lodash_namespaceObject.isFunction)(renderSuggestions) && showSuggestions && !!suggestions.length) { 43379 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { 43380 position: "bottom", 43381 noArrow: true, 43382 focusOnMount: false 43383 }, (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, suggestionsListProps, { 43384 className: classnames_default()('block-editor-url-input__suggestions', `$className}__suggestions`) 43385 }), suggestions.map((suggestion, index) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, buildSuggestionItemProps(suggestion, index), { 43386 key: suggestion.id, 43387 className: classnames_default()('block-editor-url-input__suggestion', { 43388 'is-selected': index === selectedSuggestion 43389 }), 43390 onClick: () => this.handleOnClick(suggestion) 43391 }), suggestion.title)))); 43392 } 43393 43394 return null; 43395 } 43396 43397 } 43398 /** 43399 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md 43400 */ 43401 43402 43403 /* harmony default export */ var url_input = ((0,external_wp_compose_namespaceObject.compose)(external_wp_compose_namespaceObject.withSafeTimeout, external_wp_components_namespaceObject.withSpokenMessages, external_wp_compose_namespaceObject.withInstanceId, (0,external_wp_data_namespaceObject.withSelect)((select, props) => { 43404 // If a link suggestions handler is already provided then 43405 // bail. 43406 if ((0,external_lodash_namespaceObject.isFunction)(props.__experimentalFetchLinkSuggestions)) { 43407 return; 43408 } 43409 43410 const { 43411 getSettings 43412 } = select(store); 43413 return { 43414 __experimentalFetchLinkSuggestions: getSettings().__experimentalFetchLinkSuggestions 43415 }; 43416 }))(URLInput)); 43417 43418 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-create-button.js 43419 43420 43421 43422 /** 43423 * External dependencies 43424 */ 43425 43426 43427 /** 43428 * WordPress dependencies 43429 */ 43430 43431 43432 43433 43434 43435 const LinkControlSearchCreate = _ref => { 43436 let { 43437 searchTerm, 43438 onClick, 43439 itemProps, 43440 isSelected, 43441 buttonText 43442 } = _ref; 43443 43444 if (!searchTerm) { 43445 return null; 43446 } 43447 43448 let text; 43449 43450 if (buttonText) { 43451 text = (0,external_lodash_namespaceObject.isFunction)(buttonText) ? buttonText(searchTerm) : buttonText; 43452 } else { 43453 text = (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( 43454 /* translators: %s: search term. */ 43455 (0,external_wp_i18n_namespaceObject.__)('Create: <mark>%s</mark>'), searchTerm), { 43456 mark: (0,external_wp_element_namespaceObject.createElement)("mark", null) 43457 }); 43458 } 43459 43460 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, itemProps, { 43461 className: classnames_default()('block-editor-link-control__search-create block-editor-link-control__search-item', { 43462 'is-selected': isSelected 43463 }), 43464 onClick: onClick 43465 }), (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { 43466 className: "block-editor-link-control__search-item-icon", 43467 icon: library_plus 43468 }), (0,external_wp_element_namespaceObject.createElement)("span", { 43469 className: "block-editor-link-control__search-item-header" 43470 }, (0,external_wp_element_namespaceObject.createElement)("span", { 43471 className: "block-editor-link-control__search-item-title" 43472 }, text))); 43473 }; 43474 /* harmony default export */ var search_create_button = (LinkControlSearchCreate); 43475 43476 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/globe.js 43477 43478 43479 /** 43480 * WordPress dependencies 43481 */ 43482 43483 const globe = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 43484 xmlns: "http://www.w3.org/2000/svg", 43485 viewBox: "0 0 24 24" 43486 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 43487 d: "M12 3.3c-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.8s-4-8.8-8.8-8.8zm6.5 5.5h-2.6C15.4 7.3 14.8 6 14 5c2 .6 3.6 2 4.5 3.8zm.7 3.2c0 .6-.1 1.2-.2 1.8h-2.9c.1-.6.1-1.2.1-1.8s-.1-1.2-.1-1.8H19c.2.6.2 1.2.2 1.8zM12 18.7c-1-.7-1.8-1.9-2.3-3.5h4.6c-.5 1.6-1.3 2.9-2.3 3.5zm-2.6-4.9c-.1-.6-.1-1.1-.1-1.8 0-.6.1-1.2.1-1.8h5.2c.1.6.1 1.1.1 1.8s-.1 1.2-.1 1.8H9.4zM4.8 12c0-.6.1-1.2.2-1.8h2.9c-.1.6-.1 1.2-.1 1.8 0 .6.1 1.2.1 1.8H5c-.2-.6-.2-1.2-.2-1.8zM12 5.3c1 .7 1.8 1.9 2.3 3.5H9.7c.5-1.6 1.3-2.9 2.3-3.5zM10 5c-.8 1-1.4 2.3-1.8 3.8H5.5C6.4 7 8 5.6 10 5zM5.5 15.3h2.6c.4 1.5 1 2.8 1.8 3.7-1.8-.6-3.5-2-4.4-3.7zM14 19c.8-1 1.4-2.2 1.8-3.7h2.6C17.6 17 16 18.4 14 19z" 43488 })); 43489 /* harmony default export */ var library_globe = (globe); 43490 43491 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-item.js 43492 43493 43494 43495 /** 43496 * External dependencies 43497 */ 43498 43499 /** 43500 * WordPress dependencies 43501 */ 43502 43503 43504 43505 43506 43507 const LinkControlSearchItem = _ref => { 43508 let { 43509 itemProps, 43510 suggestion, 43511 isSelected = false, 43512 onClick, 43513 isURL = false, 43514 searchTerm = '', 43515 shouldShowType = false 43516 } = _ref; 43517 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, itemProps, { 43518 onClick: onClick, 43519 className: classnames_default()('block-editor-link-control__search-item', { 43520 'is-selected': isSelected, 43521 'is-url': isURL, 43522 'is-entity': !isURL 43523 }) 43524 }), isURL && (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { 43525 className: "block-editor-link-control__search-item-icon", 43526 icon: library_globe 43527 }), (0,external_wp_element_namespaceObject.createElement)("span", { 43528 className: "block-editor-link-control__search-item-header" 43529 }, (0,external_wp_element_namespaceObject.createElement)("span", { 43530 className: "block-editor-link-control__search-item-title" 43531 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextHighlight, { 43532 text: suggestion.title, 43533 highlight: searchTerm 43534 })), (0,external_wp_element_namespaceObject.createElement)("span", { 43535 "aria-hidden": !isURL, 43536 className: "block-editor-link-control__search-item-info" 43537 }, !isURL && ((0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURI)(suggestion.url)) || ''), isURL && (0,external_wp_i18n_namespaceObject.__)('Press ENTER to add this link'))), shouldShowType && suggestion.type && (0,external_wp_element_namespaceObject.createElement)("span", { 43538 className: "block-editor-link-control__search-item-type" 43539 }, getVisualTypeName(suggestion))); 43540 }; 43541 43542 function getVisualTypeName(suggestion) { 43543 if (suggestion.isFrontPage) { 43544 return 'front page'; 43545 } // Rename 'post_tag' to 'tag'. Ideally, the API would return the localised CPT or taxonomy label. 43546 43547 43548 return suggestion.type === 'post_tag' ? 'tag' : suggestion.type; 43549 } 43550 43551 /* harmony default export */ var search_item = (LinkControlSearchItem); 43552 43553 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/constants.js 43554 /** 43555 * WordPress dependencies 43556 */ 43557 // Used as a unique identifier for the "Create" option within search results. 43558 // Used to help distinguish the "Create" suggestion within the search results in 43559 // order to handle it as a unique case. 43560 43561 const CREATE_TYPE = '__CREATE__'; 43562 const DEFAULT_LINK_SETTINGS = [{ 43563 id: 'opensInNewTab', 43564 title: (0,external_wp_i18n_namespaceObject.__)('Open in new tab') 43565 }]; 43566 43567 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-results.js 43568 43569 43570 /** 43571 * WordPress dependencies 43572 */ 43573 43574 43575 /** 43576 * External dependencies 43577 */ 43578 43579 43580 43581 /** 43582 * Internal dependencies 43583 */ 43584 43585 43586 43587 43588 function LinkControlSearchResults(_ref) { 43589 let { 43590 instanceId, 43591 withCreateSuggestion, 43592 currentInputValue, 43593 handleSuggestionClick, 43594 suggestionsListProps, 43595 buildSuggestionItemProps, 43596 suggestions, 43597 selectedSuggestion, 43598 isLoading, 43599 isInitialSuggestions, 43600 createSuggestionButtonText, 43601 suggestionsQuery 43602 } = _ref; 43603 const resultsListClasses = classnames_default()('block-editor-link-control__search-results', { 43604 'is-loading': isLoading 43605 }); 43606 const directLinkEntryTypes = ['url', 'mailto', 'tel', 'internal']; 43607 const isSingleDirectEntryResult = suggestions.length === 1 && directLinkEntryTypes.includes(suggestions[0].type.toLowerCase()); 43608 const shouldShowCreateSuggestion = withCreateSuggestion && !isSingleDirectEntryResult && !isInitialSuggestions; // If the query has a specified type, then we can skip showing them in the result. See #24839. 43609 43610 const shouldShowSuggestionsTypes = !(suggestionsQuery !== null && suggestionsQuery !== void 0 && suggestionsQuery.type); // According to guidelines aria-label should be added if the label 43611 // itself is not visible. 43612 // See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role 43613 43614 const searchResultsLabelId = `block-editor-link-control-search-results-label-$instanceId}`; 43615 const labelText = isInitialSuggestions ? (0,external_wp_i18n_namespaceObject.__)('Recently updated') : (0,external_wp_i18n_namespaceObject.sprintf)( 43616 /* translators: %s: search term. */ 43617 (0,external_wp_i18n_namespaceObject.__)('Search results for "%s"'), currentInputValue); // VisuallyHidden rightly doesn't accept custom classNames 43618 // so we conditionally render it as a wrapper to visually hide the label 43619 // when that is required. 43620 43621 const searchResultsLabel = (0,external_wp_element_namespaceObject.createElement)(isInitialSuggestions ? external_wp_element_namespaceObject.Fragment : external_wp_components_namespaceObject.VisuallyHidden, {}, // Empty props. 43622 (0,external_wp_element_namespaceObject.createElement)("span", { 43623 className: "block-editor-link-control__search-results-label", 43624 id: searchResultsLabelId 43625 }, labelText)); 43626 return (0,external_wp_element_namespaceObject.createElement)("div", { 43627 className: "block-editor-link-control__search-results-wrapper" 43628 }, searchResultsLabel, (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, suggestionsListProps, { 43629 className: resultsListClasses, 43630 "aria-labelledby": searchResultsLabelId 43631 }), suggestions.map((suggestion, index) => { 43632 if (shouldShowCreateSuggestion && CREATE_TYPE === suggestion.type) { 43633 return (0,external_wp_element_namespaceObject.createElement)(search_create_button, { 43634 searchTerm: currentInputValue, 43635 buttonText: createSuggestionButtonText, 43636 onClick: () => handleSuggestionClick(suggestion) // Intentionally only using `type` here as 43637 // the constant is enough to uniquely 43638 // identify the single "CREATE" suggestion. 43639 , 43640 key: suggestion.type, 43641 itemProps: buildSuggestionItemProps(suggestion, index), 43642 isSelected: index === selectedSuggestion 43643 }); 43644 } // If we're not handling "Create" suggestions above then 43645 // we don't want them in the main results so exit early. 43646 43647 43648 if (CREATE_TYPE === suggestion.type) { 43649 return null; 43650 } 43651 43652 return (0,external_wp_element_namespaceObject.createElement)(search_item, { 43653 key: `$suggestion.id}-$suggestion.type}`, 43654 itemProps: buildSuggestionItemProps(suggestion, index), 43655 suggestion: suggestion, 43656 index: index, 43657 onClick: () => { 43658 handleSuggestionClick(suggestion); 43659 }, 43660 isSelected: index === selectedSuggestion, 43661 isURL: directLinkEntryTypes.includes(suggestion.type.toLowerCase()), 43662 searchTerm: currentInputValue, 43663 shouldShowType: shouldShowSuggestionsTypes, 43664 isFrontPage: suggestion === null || suggestion === void 0 ? void 0 : suggestion.isFrontPage 43665 }); 43666 }))); 43667 } 43668 43669 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/is-url-like.js 43670 /** 43671 * External dependencies 43672 */ 43673 43674 /** 43675 * WordPress dependencies 43676 */ 43677 43678 43679 /** 43680 * Determines whether a given value could be a URL. Note this does not 43681 * guarantee the value is a URL only that it looks like it might be one. For 43682 * example, just because a string has `www.` in it doesn't make it a URL, 43683 * but it does make it highly likely that it will be so in the context of 43684 * creating a link it makes sense to treat it like one. 43685 * 43686 * @param {string} val the candidate for being URL-like (or not). 43687 * 43688 * @return {boolean} whether or not the value is potentially a URL. 43689 */ 43690 43691 function isURLLike(val) { 43692 const isInternal = (0,external_lodash_namespaceObject.startsWith)(val, '#'); 43693 return (0,external_wp_url_namespaceObject.isURL)(val) || val && val.includes('www.') || isInternal; 43694 } 43695 43696 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/use-search-handler.js 43697 /** 43698 * WordPress dependencies 43699 */ 43700 43701 43702 43703 /** 43704 * External dependencies 43705 */ 43706 43707 43708 /** 43709 * Internal dependencies 43710 */ 43711 43712 43713 43714 43715 const handleNoop = () => Promise.resolve([]); 43716 const handleDirectEntry = val => { 43717 let type = 'URL'; 43718 const protocol = (0,external_wp_url_namespaceObject.getProtocol)(val) || ''; 43719 43720 if (protocol.includes('mailto')) { 43721 type = 'mailto'; 43722 } 43723 43724 if (protocol.includes('tel')) { 43725 type = 'tel'; 43726 } 43727 43728 if ((0,external_lodash_namespaceObject.startsWith)(val, '#')) { 43729 type = 'internal'; 43730 } 43731 43732 return Promise.resolve([{ 43733 id: val, 43734 title: val, 43735 url: type === 'URL' ? (0,external_wp_url_namespaceObject.prependHTTP)(val) : val, 43736 type 43737 }]); 43738 }; 43739 43740 const handleEntitySearch = async (val, suggestionsQuery, fetchSearchSuggestions, directEntryHandler, withCreateSuggestion, withURLSuggestion, pageOnFront) => { 43741 const { 43742 isInitialSuggestions 43743 } = suggestionsQuery; 43744 let resultsIncludeFrontPage = false; 43745 let results = await Promise.all([fetchSearchSuggestions(val, suggestionsQuery), directEntryHandler(val)]); // Identify front page and update type to match. 43746 43747 results[0] = results[0].map(result => { 43748 if (Number(result.id) === pageOnFront) { 43749 resultsIncludeFrontPage = true; 43750 result.isFrontPage = true; 43751 return result; 43752 } 43753 43754 return result; 43755 }); 43756 const couldBeURL = !val.includes(' '); // If it's potentially a URL search then concat on a URL search suggestion 43757 // just for good measure. That way once the actual results run out we always 43758 // have a URL option to fallback on. 43759 43760 if (!resultsIncludeFrontPage && couldBeURL && withURLSuggestion && !isInitialSuggestions) { 43761 results = results[0].concat(results[1]); 43762 } else { 43763 results = results[0]; 43764 } // If displaying initial suggestions just return plain results. 43765 43766 43767 if (isInitialSuggestions) { 43768 return results; 43769 } // Here we append a faux suggestion to represent a "CREATE" option. This 43770 // is detected in the rendering of the search results and handled as a 43771 // special case. This is currently necessary because the suggestions 43772 // dropdown will only appear if there are valid suggestions and 43773 // therefore unless the create option is a suggestion it will not 43774 // display in scenarios where there are no results returned from the 43775 // API. In addition promoting CREATE to a first class suggestion affords 43776 // the a11y benefits afforded by `URLInput` to all suggestions (eg: 43777 // keyboard handling, ARIA roles...etc). 43778 // 43779 // Note also that the value of the `title` and `url` properties must correspond 43780 // to the text value of the `<input>`. This is because `title` is used 43781 // when creating the suggestion. Similarly `url` is used when using keyboard to select 43782 // the suggestion (the <form> `onSubmit` handler falls-back to `url`). 43783 43784 43785 return isURLLike(val) || !withCreateSuggestion ? results : results.concat({ 43786 // the `id` prop is intentionally ommitted here because it 43787 // is never exposed as part of the component's public API. 43788 // see: https://github.com/WordPress/gutenberg/pull/19775#discussion_r378931316. 43789 title: val, 43790 // Must match the existing `<input>`s text value. 43791 url: val, 43792 // Must match the existing `<input>`s text value. 43793 type: CREATE_TYPE 43794 }); 43795 }; 43796 43797 function useSearchHandler(suggestionsQuery, allowDirectEntry, withCreateSuggestion, withURLSuggestion) { 43798 const { 43799 fetchSearchSuggestions, 43800 pageOnFront 43801 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 43802 const { 43803 getSettings 43804 } = select(store); 43805 return { 43806 pageOnFront: getSettings().pageOnFront, 43807 fetchSearchSuggestions: getSettings().__experimentalFetchLinkSuggestions 43808 }; 43809 }, []); 43810 const directEntryHandler = allowDirectEntry ? handleDirectEntry : handleNoop; 43811 return (0,external_wp_element_namespaceObject.useCallback)((val, _ref) => { 43812 let { 43813 isInitialSuggestions 43814 } = _ref; 43815 return isURLLike(val) ? directEntryHandler(val, { 43816 isInitialSuggestions 43817 }) : handleEntitySearch(val, { ...suggestionsQuery, 43818 isInitialSuggestions 43819 }, fetchSearchSuggestions, directEntryHandler, withCreateSuggestion, withURLSuggestion, pageOnFront); 43820 }, [directEntryHandler, fetchSearchSuggestions, withCreateSuggestion]); 43821 } 43822 43823 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-input.js 43824 43825 43826 /** 43827 * External dependencies 43828 */ 43829 43830 43831 /** 43832 * WordPress dependencies 43833 */ 43834 43835 43836 43837 43838 /** 43839 * Internal dependencies 43840 */ 43841 43842 43843 43844 43845 // Must be a function as otherwise URLInput will default 43846 // to the fetchLinkSuggestions passed in block editor settings 43847 // which will cause an unintended http request. 43848 43849 const noopSearchHandler = () => Promise.resolve([]); 43850 43851 const LinkControlSearchInput = (0,external_wp_element_namespaceObject.forwardRef)((_ref, ref) => { 43852 let { 43853 value, 43854 children, 43855 currentLink = {}, 43856 className = null, 43857 placeholder = null, 43858 withCreateSuggestion = false, 43859 onCreateSuggestion = external_lodash_namespaceObject.noop, 43860 onChange = external_lodash_namespaceObject.noop, 43861 onSelect = external_lodash_namespaceObject.noop, 43862 showSuggestions = true, 43863 renderSuggestions = props => (0,external_wp_element_namespaceObject.createElement)(LinkControlSearchResults, props), 43864 fetchSuggestions = null, 43865 allowDirectEntry = true, 43866 showInitialSuggestions = false, 43867 suggestionsQuery = {}, 43868 withURLSuggestion = true, 43869 createSuggestionButtonText, 43870 useLabel = false 43871 } = _ref; 43872 const genericSearchHandler = useSearchHandler(suggestionsQuery, allowDirectEntry, withCreateSuggestion, withURLSuggestion); 43873 const searchHandler = showSuggestions ? fetchSuggestions || genericSearchHandler : noopSearchHandler; 43874 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(LinkControlSearchInput); 43875 const [focusedSuggestion, setFocusedSuggestion] = (0,external_wp_element_namespaceObject.useState)(); 43876 /** 43877 * Handles the user moving between different suggestions. Does not handle 43878 * choosing an individual item. 43879 * 43880 * @param {string} selection the url of the selected suggestion. 43881 * @param {Object} suggestion the suggestion object. 43882 */ 43883 43884 const onInputChange = (selection, suggestion) => { 43885 onChange(selection); 43886 setFocusedSuggestion(suggestion); 43887 }; 43888 43889 const handleRenderSuggestions = props => renderSuggestions({ ...props, 43890 instanceId, 43891 withCreateSuggestion, 43892 currentInputValue: value, 43893 createSuggestionButtonText, 43894 suggestionsQuery, 43895 handleSuggestionClick: suggestion => { 43896 if (props.handleSuggestionClick) { 43897 props.handleSuggestionClick(suggestion); 43898 } 43899 43900 onSuggestionSelected(suggestion); 43901 } 43902 }); 43903 43904 const onSuggestionSelected = async selectedSuggestion => { 43905 let suggestion = selectedSuggestion; 43906 43907 if (CREATE_TYPE === selectedSuggestion.type) { 43908 // Create a new page and call onSelect with the output from the onCreateSuggestion callback. 43909 try { 43910 var _suggestion; 43911 43912 suggestion = await onCreateSuggestion(selectedSuggestion.title); 43913 43914 if ((_suggestion = suggestion) !== null && _suggestion !== void 0 && _suggestion.url) { 43915 onSelect(suggestion); 43916 } 43917 } catch (e) {} 43918 43919 return; 43920 } 43921 43922 if (allowDirectEntry || suggestion && Object.keys(suggestion).length >= 1) { 43923 onSelect( // Some direct entries don't have types or IDs, and we still need to clear the previous ones. 43924 { ...(0,external_lodash_namespaceObject.omit)(currentLink, 'id', 'url'), 43925 ...suggestion 43926 }, suggestion); 43927 } 43928 }; 43929 43930 const inputClasses = classnames_default()(className, { 43931 'has-no-label': !useLabel 43932 }); 43933 return (0,external_wp_element_namespaceObject.createElement)("div", { 43934 className: "block-editor-link-control__search-input-container" 43935 }, (0,external_wp_element_namespaceObject.createElement)(url_input, { 43936 label: useLabel ? 'URL' : undefined, 43937 className: inputClasses, 43938 value: value, 43939 onChange: onInputChange, 43940 placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : (0,external_wp_i18n_namespaceObject.__)('Search or type url'), 43941 __experimentalRenderSuggestions: showSuggestions ? handleRenderSuggestions : null, 43942 __experimentalFetchLinkSuggestions: searchHandler, 43943 __experimentalHandleURLSuggestions: true, 43944 __experimentalShowInitialSuggestions: showInitialSuggestions, 43945 onSubmit: (suggestion, event) => { 43946 var _value$trim; 43947 43948 const hasSuggestion = suggestion || focusedSuggestion; // If there is no suggestion and the value (ie: any manually entered URL) is empty 43949 // then don't allow submission otherwise we get empty links. 43950 43951 if (!hasSuggestion && !(value !== null && value !== void 0 && (_value$trim = value.trim()) !== null && _value$trim !== void 0 && _value$trim.length)) { 43952 event.preventDefault(); 43953 } else { 43954 onSuggestionSelected(hasSuggestion || { 43955 url: value 43956 }); 43957 } 43958 }, 43959 ref: ref 43960 }), children); 43961 }); 43962 /* harmony default export */ var search_input = (LinkControlSearchInput); 43963 43964 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/info.js 43965 43966 43967 /** 43968 * WordPress dependencies 43969 */ 43970 43971 const info = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 43972 xmlns: "http://www.w3.org/2000/svg", 43973 viewBox: "0 0 24 24" 43974 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 43975 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" 43976 })); 43977 /* harmony default export */ var library_info = (info); 43978 43979 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/pencil.js 43980 43981 43982 /** 43983 * WordPress dependencies 43984 */ 43985 43986 const pencil = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 43987 xmlns: "http://www.w3.org/2000/svg", 43988 viewBox: "0 0 24 24" 43989 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 43990 d: "M20.1 5.1L16.9 2 6.2 12.7l-1.3 4.4 4.5-1.3L20.1 5.1zM4 20.8h8v-1.5H4v1.5z" 43991 })); 43992 /* harmony default export */ var library_pencil = (pencil); 43993 43994 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/edit.js 43995 /** 43996 * Internal dependencies 43997 */ 43998 43999 /* harmony default export */ var library_edit = (library_pencil); 44000 44001 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/viewer-slot.js 44002 /** 44003 * WordPress dependencies 44004 */ 44005 44006 const { 44007 Slot: ViewerSlot, 44008 Fill: ViewerFill 44009 } = (0,external_wp_components_namespaceObject.createSlotFill)('BlockEditorLinkControlViewer'); 44010 44011 /* harmony default export */ var viewer_slot = ((/* unused pure expression or super */ null && (ViewerSlot))); 44012 44013 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/use-rich-url-data.js 44014 /** 44015 * Internal dependencies 44016 */ 44017 44018 /** 44019 * WordPress dependencies 44020 */ 44021 44022 44023 44024 44025 function use_rich_url_data_reducer(state, action) { 44026 switch (action.type) { 44027 case 'RESOLVED': 44028 return { ...state, 44029 isFetching: false, 44030 richData: action.richData 44031 }; 44032 44033 case 'ERROR': 44034 return { ...state, 44035 isFetching: false, 44036 richData: null 44037 }; 44038 44039 case 'LOADING': 44040 return { ...state, 44041 isFetching: true 44042 }; 44043 44044 default: 44045 throw new Error(`Unexpected action type $action.type}`); 44046 } 44047 } 44048 44049 function useRemoteUrlData(url) { 44050 const [state, dispatch] = (0,external_wp_element_namespaceObject.useReducer)(use_rich_url_data_reducer, { 44051 richData: null, 44052 isFetching: false 44053 }); 44054 const { 44055 fetchRichUrlData 44056 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 44057 const { 44058 getSettings 44059 } = select(store); 44060 return { 44061 fetchRichUrlData: getSettings().__experimentalFetchRichUrlData 44062 }; 44063 }, []); 44064 (0,external_wp_element_namespaceObject.useEffect)(() => { 44065 // Only make the request if we have an actual URL 44066 // and the fetching util is available. In some editors 44067 // there may not be such a util. 44068 if (url !== null && url !== void 0 && url.length && fetchRichUrlData && typeof AbortController !== 'undefined') { 44069 dispatch({ 44070 type: 'LOADING' 44071 }); 44072 const controller = new window.AbortController(); 44073 const signal = controller.signal; 44074 fetchRichUrlData(url, { 44075 signal 44076 }).then(urlData => { 44077 dispatch({ 44078 type: 'RESOLVED', 44079 richData: urlData 44080 }); 44081 }).catch(() => { 44082 // Avoid setting state on unmounted component 44083 if (!signal.aborted) { 44084 dispatch({ 44085 type: 'ERROR' 44086 }); 44087 } 44088 }); // Cleanup: when the URL changes the abort the current request. 44089 44090 return () => { 44091 controller.abort(); 44092 }; 44093 } 44094 }, [url]); 44095 return state; 44096 } 44097 44098 /* harmony default export */ var use_rich_url_data = (useRemoteUrlData); 44099 44100 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/link-preview.js 44101 44102 44103 /** 44104 * External dependencies 44105 */ 44106 44107 /** 44108 * WordPress dependencies 44109 */ 44110 44111 44112 44113 44114 44115 44116 /** 44117 * Internal dependencies 44118 */ 44119 44120 44121 44122 function LinkPreview(_ref) { 44123 var _value$url; 44124 44125 let { 44126 value, 44127 onEditClick, 44128 hasRichPreviews = false, 44129 hasUnlinkControl = false, 44130 onRemove 44131 } = _ref; 44132 // Avoid fetching if rich previews are not desired. 44133 const showRichPreviews = hasRichPreviews ? value === null || value === void 0 ? void 0 : value.url : null; 44134 const { 44135 richData, 44136 isFetching 44137 } = use_rich_url_data(showRichPreviews); // Rich data may be an empty object so test for that. 44138 44139 const hasRichData = richData && Object.keys(richData).length; 44140 const displayURL = value && (0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURI)(value.url), 16) || ''; 44141 const displayTitle = (richData === null || richData === void 0 ? void 0 : richData.title) || (value === null || value === void 0 ? void 0 : value.title) || displayURL; // url can be undefined if the href attribute is unset 44142 44143 const isEmptyURL = !(value !== null && value !== void 0 && (_value$url = value.url) !== null && _value$url !== void 0 && _value$url.length); 44144 let icon; 44145 44146 if (richData !== null && richData !== void 0 && richData.icon) { 44147 icon = (0,external_wp_element_namespaceObject.createElement)("img", { 44148 src: richData === null || richData === void 0 ? void 0 : richData.icon, 44149 alt: "" 44150 }); 44151 } else if (isEmptyURL) { 44152 icon = (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { 44153 icon: library_info, 44154 size: 32 44155 }); 44156 } else { 44157 icon = (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { 44158 icon: library_globe 44159 }); 44160 } 44161 44162 return (0,external_wp_element_namespaceObject.createElement)("div", { 44163 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Currently selected'), 44164 "aria-selected": "true", 44165 className: classnames_default()('block-editor-link-control__search-item', { 44166 'is-current': true, 44167 'is-rich': hasRichData, 44168 'is-fetching': !!isFetching, 44169 'is-preview': true, 44170 'is-error': isEmptyURL 44171 }) 44172 }, (0,external_wp_element_namespaceObject.createElement)("div", { 44173 className: "block-editor-link-control__search-item-top" 44174 }, (0,external_wp_element_namespaceObject.createElement)("span", { 44175 className: "block-editor-link-control__search-item-header" 44176 }, (0,external_wp_element_namespaceObject.createElement)("span", { 44177 className: classnames_default()('block-editor-link-control__search-item-icon', { 44178 'is-image': richData === null || richData === void 0 ? void 0 : richData.icon 44179 }) 44180 }, icon), (0,external_wp_element_namespaceObject.createElement)("span", { 44181 className: "block-editor-link-control__search-item-details" 44182 }, !isEmptyURL ? (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, { 44183 className: "block-editor-link-control__search-item-title", 44184 href: value.url 44185 }, (0,external_wp_dom_namespaceObject.__unstableStripHTML)(displayTitle)), (value === null || value === void 0 ? void 0 : value.url) && (0,external_wp_element_namespaceObject.createElement)("span", { 44186 className: "block-editor-link-control__search-item-info" 44187 }, displayURL)) : (0,external_wp_element_namespaceObject.createElement)("span", { 44188 className: "block-editor-link-control__search-item-error-notice" 44189 }, (0,external_wp_i18n_namespaceObject.__)('Link is empty')))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 44190 icon: library_edit, 44191 label: (0,external_wp_i18n_namespaceObject.__)('Edit'), 44192 className: "block-editor-link-control__search-item-action", 44193 onClick: onEditClick, 44194 iconSize: 24 44195 }), hasUnlinkControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 44196 icon: link_off, 44197 label: (0,external_wp_i18n_namespaceObject.__)('Unlink'), 44198 className: "block-editor-link-control__search-item-action block-editor-link-control__unlink", 44199 onClick: onRemove, 44200 iconSize: 24 44201 }), (0,external_wp_element_namespaceObject.createElement)(ViewerSlot, { 44202 fillProps: value 44203 })), (hasRichData && ((richData === null || richData === void 0 ? void 0 : richData.image) || (richData === null || richData === void 0 ? void 0 : richData.description)) || isFetching) && (0,external_wp_element_namespaceObject.createElement)("div", { 44204 className: "block-editor-link-control__search-item-bottom" 44205 }, ((richData === null || richData === void 0 ? void 0 : richData.image) || isFetching) && (0,external_wp_element_namespaceObject.createElement)("div", { 44206 "aria-hidden": !(richData !== null && richData !== void 0 && richData.image), 44207 className: classnames_default()('block-editor-link-control__search-item-image', { 44208 'is-placeholder': !(richData !== null && richData !== void 0 && richData.image) 44209 }) 44210 }, (richData === null || richData === void 0 ? void 0 : richData.image) && (0,external_wp_element_namespaceObject.createElement)("img", { 44211 src: richData === null || richData === void 0 ? void 0 : richData.image, 44212 alt: "" 44213 })), ((richData === null || richData === void 0 ? void 0 : richData.description) || isFetching) && (0,external_wp_element_namespaceObject.createElement)("div", { 44214 "aria-hidden": !(richData !== null && richData !== void 0 && richData.description), 44215 className: classnames_default()('block-editor-link-control__search-item-description', { 44216 'is-placeholder': !(richData !== null && richData !== void 0 && richData.description) 44217 }) 44218 }, (richData === null || richData === void 0 ? void 0 : richData.description) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { 44219 truncate: true, 44220 numberOfLines: "2" 44221 }, richData.description)))); 44222 } 44223 44224 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/use-create-page.js 44225 /** 44226 * WordPress dependencies 44227 */ 44228 44229 44230 function useCreatePage(handleCreatePage) { 44231 const cancelableCreateSuggestion = (0,external_wp_element_namespaceObject.useRef)(); 44232 const [isCreatingPage, setIsCreatingPage] = (0,external_wp_element_namespaceObject.useState)(false); 44233 const [errorMessage, setErrorMessage] = (0,external_wp_element_namespaceObject.useState)(null); 44234 44235 const createPage = async function (suggestionTitle) { 44236 setIsCreatingPage(true); 44237 setErrorMessage(null); 44238 44239 try { 44240 // Make cancellable in order that we can avoid setting State 44241 // if the component unmounts during the call to `createSuggestion` 44242 cancelableCreateSuggestion.current = makeCancelable( // Using Promise.resolve to allow createSuggestion to return a 44243 // non-Promise based value. 44244 Promise.resolve(handleCreatePage(suggestionTitle))); 44245 return await cancelableCreateSuggestion.current.promise; 44246 } catch (error) { 44247 if (error && error.isCanceled) { 44248 return; // bail if canceled to avoid setting state 44249 } 44250 44251 setErrorMessage(error.message || (0,external_wp_i18n_namespaceObject.__)('An unknown error occurred during creation. Please try again.')); 44252 throw error; 44253 } finally { 44254 setIsCreatingPage(false); 44255 } 44256 }; 44257 /** 44258 * Handles cancelling any pending Promises that have been made cancelable. 44259 */ 44260 44261 44262 (0,external_wp_element_namespaceObject.useEffect)(() => { 44263 return () => { 44264 // componentDidUnmount 44265 if (cancelableCreateSuggestion.current) { 44266 cancelableCreateSuggestion.current.cancel(); 44267 } 44268 }; 44269 }, []); 44270 return { 44271 createPage, 44272 isCreatingPage, 44273 errorMessage 44274 }; 44275 } 44276 /** 44277 * Creates a wrapper around a promise which allows it to be programmatically 44278 * cancelled. 44279 * See: https://reactjs.org/blog/2015/12/16/ismounted-antipattern.html 44280 * 44281 * @param {Promise} promise the Promise to make cancelable 44282 */ 44283 44284 const makeCancelable = promise => { 44285 let hasCanceled_ = false; 44286 const wrappedPromise = new Promise((resolve, reject) => { 44287 promise.then(val => hasCanceled_ ? reject({ 44288 isCanceled: true 44289 }) : resolve(val), error => hasCanceled_ ? reject({ 44290 isCanceled: true 44291 }) : reject(error)); 44292 }); 44293 return { 44294 promise: wrappedPromise, 44295 44296 cancel() { 44297 hasCanceled_ = true; 44298 } 44299 44300 }; 44301 }; 44302 44303 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/index.js 44304 44305 44306 /** 44307 * External dependencies 44308 */ 44309 44310 44311 /** 44312 * WordPress dependencies 44313 */ 44314 44315 44316 44317 44318 44319 44320 44321 /** 44322 * Internal dependencies 44323 */ 44324 44325 44326 44327 44328 44329 44330 44331 /** 44332 * Default properties associated with a link control value. 44333 * 44334 * @typedef WPLinkControlDefaultValue 44335 * 44336 * @property {string} url Link URL. 44337 * @property {string=} title Link title. 44338 * @property {boolean=} opensInNewTab Whether link should open in a new browser 44339 * tab. This value is only assigned if not 44340 * providing a custom `settings` prop. 44341 */ 44342 44343 /* eslint-disable jsdoc/valid-types */ 44344 44345 /** 44346 * Custom settings values associated with a link. 44347 * 44348 * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue 44349 */ 44350 44351 /* eslint-enable */ 44352 44353 /** 44354 * Custom settings values associated with a link. 44355 * 44356 * @typedef WPLinkControlSetting 44357 * 44358 * @property {string} id Identifier to use as property for setting value. 44359 * @property {string} title Human-readable label to show in user interface. 44360 */ 44361 44362 /** 44363 * Properties associated with a link control value, composed as a union of the 44364 * default properties and any custom settings values. 44365 * 44366 * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue 44367 */ 44368 44369 /** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */ 44370 44371 /** 44372 * Properties associated with a search suggestion used within the LinkControl. 44373 * 44374 * @typedef WPLinkControlSuggestion 44375 * 44376 * @property {string} id Identifier to use to uniquely identify the suggestion. 44377 * @property {string} type Identifies the type of the suggestion (eg: `post`, 44378 * `page`, `url`...etc) 44379 * @property {string} title Human-readable label to show in user interface. 44380 * @property {string} url A URL for the suggestion. 44381 */ 44382 44383 /** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */ 44384 44385 /** 44386 * @typedef WPLinkControlProps 44387 * 44388 * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to 44389 * render a `ToggleControl` for that setting. 44390 * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the 44391 * internal editing state of the component to respective 44392 * show or not show the URL input field. 44393 * @property {WPLinkControlValue=} value Current link value. 44394 * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if 44395 * the user selects a new link or updates settings. 44396 * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link. 44397 * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL. 44398 * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately. 44399 * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion. 44400 * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions. 44401 * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL. 44402 * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion. 44403 * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component. 44404 */ 44405 44406 /** 44407 * Renders a link control. A link control is a controlled input which maintains 44408 * a value associated with a link (HTML anchor element) and relevant settings 44409 * for how that link is expected to behave. 44410 * 44411 * @param {WPLinkControlProps} props Component props. 44412 */ 44413 44414 function LinkControl(_ref) { 44415 var _currentInputValue$tr, _value$url, _value$url$trim; 44416 44417 let { 44418 searchInputPlaceholder, 44419 value, 44420 settings = DEFAULT_LINK_SETTINGS, 44421 onChange = external_lodash_namespaceObject.noop, 44422 onRemove, 44423 noDirectEntry = false, 44424 showSuggestions = true, 44425 showInitialSuggestions, 44426 forceIsEditingLink, 44427 createSuggestion, 44428 withCreateSuggestion, 44429 inputValue: propInputValue = '', 44430 suggestionsQuery = {}, 44431 noURLSuggestion = false, 44432 createSuggestionButtonText, 44433 hasRichPreviews = false, 44434 hasTextControl = false, 44435 renderControlBottom = null 44436 } = _ref; 44437 44438 if (withCreateSuggestion === undefined && createSuggestion) { 44439 withCreateSuggestion = true; 44440 } 44441 44442 const isMounting = (0,external_wp_element_namespaceObject.useRef)(true); 44443 const wrapperNode = (0,external_wp_element_namespaceObject.useRef)(); 44444 const textInputRef = (0,external_wp_element_namespaceObject.useRef)(); 44445 const [internalInputValue, setInternalInputValue] = (0,external_wp_element_namespaceObject.useState)((value === null || value === void 0 ? void 0 : value.url) || ''); 44446 const [internalTextValue, setInternalTextValue] = (0,external_wp_element_namespaceObject.useState)((value === null || value === void 0 ? void 0 : value.title) || ''); 44447 const currentInputValue = propInputValue || internalInputValue; 44448 const [isEditingLink, setIsEditingLink] = (0,external_wp_element_namespaceObject.useState)(forceIsEditingLink !== undefined ? forceIsEditingLink : !value || !value.url); 44449 const isEndingEditWithFocus = (0,external_wp_element_namespaceObject.useRef)(false); 44450 const currentInputIsEmpty = !(currentInputValue !== null && currentInputValue !== void 0 && (_currentInputValue$tr = currentInputValue.trim()) !== null && _currentInputValue$tr !== void 0 && _currentInputValue$tr.length); 44451 const { 44452 createPage, 44453 isCreatingPage, 44454 errorMessage 44455 } = useCreatePage(createSuggestion); 44456 (0,external_wp_element_namespaceObject.useEffect)(() => { 44457 if (forceIsEditingLink !== undefined && forceIsEditingLink !== isEditingLink) { 44458 setIsEditingLink(forceIsEditingLink); 44459 } 44460 }, [forceIsEditingLink]); 44461 (0,external_wp_element_namespaceObject.useEffect)(() => { 44462 // We don't auto focus into the Link UI on mount 44463 // because otherwise using the keyboard to select text 44464 // *within* the link format is not possible. 44465 if (isMounting.current) { 44466 isMounting.current = false; 44467 return; 44468 } // Unless we are mounting, we always want to focus either: 44469 // - the URL input 44470 // - the first focusable element in the Link UI. 44471 // But in editing mode if there is a text input present then 44472 // the URL input is at index 1. If not then it is at index 0. 44473 44474 44475 const whichFocusTargetIndex = textInputRef !== null && textInputRef !== void 0 && textInputRef.current ? 1 : 0; // Scenario - when: 44476 // - switching between editable and non editable LinkControl 44477 // - clicking on a link 44478 // ...then move focus to the *first* element to avoid focus loss 44479 // and to ensure focus is *within* the Link UI. 44480 44481 const nextFocusTarget = external_wp_dom_namespaceObject.focus.focusable.find(wrapperNode.current)[whichFocusTargetIndex] || wrapperNode.current; 44482 nextFocusTarget.focus(); 44483 isEndingEditWithFocus.current = false; 44484 }, [isEditingLink, isCreatingPage]); 44485 (0,external_wp_element_namespaceObject.useEffect)(() => { 44486 /** 44487 * If the value's `text` property changes then sync this 44488 * back up with state. 44489 */ 44490 if (value !== null && value !== void 0 && value.title && value.title !== internalTextValue) { 44491 setInternalTextValue(value.title); 44492 } 44493 /** 44494 * Update the state value internalInputValue if the url value changes 44495 * for example when clicking on another anchor 44496 */ 44497 44498 44499 if (value !== null && value !== void 0 && value.url) { 44500 setInternalInputValue(value.url); 44501 } 44502 }, [value]); 44503 /** 44504 * Cancels editing state and marks that focus may need to be restored after 44505 * the next render, if focus was within the wrapper when editing finished. 44506 */ 44507 44508 function stopEditing() { 44509 var _wrapperNode$current; 44510 44511 isEndingEditWithFocus.current = !!((_wrapperNode$current = wrapperNode.current) !== null && _wrapperNode$current !== void 0 && _wrapperNode$current.contains(wrapperNode.current.ownerDocument.activeElement)); 44512 setIsEditingLink(false); 44513 } 44514 44515 const handleSelectSuggestion = updatedValue => { 44516 onChange({ ...updatedValue, 44517 title: internalTextValue || (updatedValue === null || updatedValue === void 0 ? void 0 : updatedValue.title) 44518 }); 44519 stopEditing(); 44520 }; 44521 44522 const handleSubmit = () => { 44523 if (currentInputValue !== (value === null || value === void 0 ? void 0 : value.url) || internalTextValue !== (value === null || value === void 0 ? void 0 : value.title)) { 44524 onChange({ 44525 url: currentInputValue, 44526 title: internalTextValue 44527 }); 44528 } 44529 44530 stopEditing(); 44531 }; 44532 44533 const handleSubmitWithEnter = event => { 44534 const { 44535 keyCode 44536 } = event; 44537 44538 if (keyCode === external_wp_keycodes_namespaceObject.ENTER && !currentInputIsEmpty // Disallow submitting empty values. 44539 ) { 44540 event.preventDefault(); 44541 handleSubmit(); 44542 } 44543 }; 44544 44545 const shownUnlinkControl = onRemove && value && !isEditingLink && !isCreatingPage; 44546 const showSettingsDrawer = !!(settings !== null && settings !== void 0 && settings.length); // Only show text control once a URL value has been committed 44547 // and it isn't just empty whitespace. 44548 // See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927. 44549 44550 const showTextControl = (value === null || value === void 0 ? void 0 : (_value$url = value.url) === null || _value$url === void 0 ? void 0 : (_value$url$trim = _value$url.trim()) === null || _value$url$trim === void 0 ? void 0 : _value$url$trim.length) > 0 && hasTextControl; 44551 return (0,external_wp_element_namespaceObject.createElement)("div", { 44552 tabIndex: -1, 44553 ref: wrapperNode, 44554 className: "block-editor-link-control" 44555 }, isCreatingPage && (0,external_wp_element_namespaceObject.createElement)("div", { 44556 className: "block-editor-link-control__loading" 44557 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null), " ", (0,external_wp_i18n_namespaceObject.__)('Creating'), "\u2026"), (isEditingLink || !value) && !isCreatingPage && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", { 44558 className: classnames_default()({ 44559 'block-editor-link-control__search-input-wrapper': true, 44560 'has-text-control': showTextControl 44561 }) 44562 }, showTextControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { 44563 ref: textInputRef, 44564 className: "block-editor-link-control__field block-editor-link-control__text-content", 44565 label: "Text", 44566 value: internalTextValue, 44567 onChange: setInternalTextValue, 44568 onKeyDown: handleSubmitWithEnter 44569 }), (0,external_wp_element_namespaceObject.createElement)(search_input, { 44570 currentLink: value, 44571 className: "block-editor-link-control__field block-editor-link-control__search-input", 44572 placeholder: searchInputPlaceholder, 44573 value: currentInputValue, 44574 withCreateSuggestion: withCreateSuggestion, 44575 onCreateSuggestion: createPage, 44576 onChange: setInternalInputValue, 44577 onSelect: handleSelectSuggestion, 44578 showInitialSuggestions: showInitialSuggestions, 44579 allowDirectEntry: !noDirectEntry, 44580 showSuggestions: showSuggestions, 44581 suggestionsQuery: suggestionsQuery, 44582 withURLSuggestion: !noURLSuggestion, 44583 createSuggestionButtonText: createSuggestionButtonText, 44584 useLabel: showTextControl 44585 }, (0,external_wp_element_namespaceObject.createElement)("div", { 44586 className: "block-editor-link-control__search-actions" 44587 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 44588 onClick: handleSubmit, 44589 label: (0,external_wp_i18n_namespaceObject.__)('Submit'), 44590 icon: keyboard_return, 44591 className: "block-editor-link-control__search-submit", 44592 disabled: currentInputIsEmpty // Disallow submitting empty values. 44593 44594 })))), errorMessage && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Notice, { 44595 className: "block-editor-link-control__search-error", 44596 status: "error", 44597 isDismissible: false 44598 }, errorMessage)), value && !isEditingLink && !isCreatingPage && (0,external_wp_element_namespaceObject.createElement)(LinkPreview, { 44599 key: value === null || value === void 0 ? void 0 : value.url // force remount when URL changes to avoid race conditions for rich previews 44600 , 44601 value: value, 44602 onEditClick: () => setIsEditingLink(true), 44603 hasRichPreviews: hasRichPreviews, 44604 hasUnlinkControl: shownUnlinkControl, 44605 onRemove: onRemove 44606 }), showSettingsDrawer && (0,external_wp_element_namespaceObject.createElement)("div", { 44607 className: "block-editor-link-control__tools" 44608 }, (0,external_wp_element_namespaceObject.createElement)(settings_drawer, { 44609 value: value, 44610 settings: settings, 44611 onChange: onChange 44612 })), renderControlBottom && renderControlBottom()); 44613 } 44614 44615 LinkControl.ViewerFill = ViewerFill; 44616 /* harmony default export */ var link_control = (LinkControl); 44617 44618 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/media.js 44619 44620 44621 /** 44622 * WordPress dependencies 44623 */ 44624 44625 const media = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 44626 xmlns: "http://www.w3.org/2000/svg", 44627 viewBox: "0 0 24 24" 44628 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 44629 d: "M18.7 3H5.3C4 3 3 4 3 5.3v13.4C3 20 4 21 5.3 21h13.4c1.3 0 2.3-1 2.3-2.3V5.3C21 4 20 3 18.7 3zm.8 15.7c0 .4-.4.8-.8.8H5.3c-.4 0-.8-.4-.8-.8V5.3c0-.4.4-.8.8-.8h13.4c.4 0 .8.4.8.8v13.4zM10 15l5-3-5-3v6z" 44630 })); 44631 /* harmony default export */ var library_media = (media); 44632 44633 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/upload.js 44634 44635 44636 /** 44637 * WordPress dependencies 44638 */ 44639 44640 const upload = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 44641 xmlns: "http://www.w3.org/2000/svg", 44642 viewBox: "0 0 24 24" 44643 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 44644 d: "M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z" 44645 })); 44646 /* harmony default export */ var library_upload = (upload); 44647 44648 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-upload/index.js 44649 /** 44650 * WordPress dependencies 44651 */ 44652 44653 /** 44654 * This is a placeholder for the media upload component necessary to make it possible to provide 44655 * an integration with the core blocks that handle media files. By default it renders nothing but 44656 * it provides a way to have it overridden with the `editor.MediaUpload` filter. 44657 * 44658 * @return {WPComponent} The component to be rendered. 44659 */ 44660 44661 const MediaUpload = () => null; 44662 /** 44663 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-upload/README.md 44664 */ 44665 44666 44667 /* harmony default export */ var media_upload = ((0,external_wp_components_namespaceObject.withFilters)('editor.MediaUpload')(MediaUpload)); 44668 44669 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-upload/check.js 44670 /** 44671 * WordPress dependencies 44672 */ 44673 44674 /** 44675 * Internal dependencies 44676 */ 44677 44678 44679 function MediaUploadCheck(_ref) { 44680 let { 44681 fallback = null, 44682 children 44683 } = _ref; 44684 const hasUploadPermissions = (0,external_wp_data_namespaceObject.useSelect)(select => { 44685 const { 44686 getSettings 44687 } = select(store); 44688 return !!getSettings().mediaUpload; 44689 }, []); 44690 return hasUploadPermissions ? children : fallback; 44691 } 44692 /** 44693 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-upload/README.md 44694 */ 44695 44696 /* harmony default export */ var media_upload_check = (MediaUploadCheck); 44697 44698 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-replace-flow/index.js 44699 44700 44701 /** 44702 * External dependencies 44703 */ 44704 44705 /** 44706 * WordPress dependencies 44707 */ 44708 44709 44710 44711 44712 44713 44714 44715 44716 44717 44718 44719 /** 44720 * Internal dependencies 44721 */ 44722 44723 44724 44725 44726 44727 44728 const MediaReplaceFlow = _ref => { 44729 let { 44730 mediaURL, 44731 mediaId, 44732 mediaIds, 44733 allowedTypes, 44734 accept, 44735 onError, 44736 onSelect, 44737 onSelectURL, 44738 onFilesUpload = external_lodash_namespaceObject.noop, 44739 onCloseModal = external_lodash_namespaceObject.noop, 44740 name = (0,external_wp_i18n_namespaceObject.__)('Replace'), 44741 createNotice, 44742 removeNotice, 44743 children, 44744 multiple = false, 44745 addToGallery, 44746 handleUpload = true 44747 } = _ref; 44748 const [mediaURLValue, setMediaURLValue] = (0,external_wp_element_namespaceObject.useState)(mediaURL); 44749 const mediaUpload = (0,external_wp_data_namespaceObject.useSelect)(select => { 44750 return select(store).getSettings().mediaUpload; 44751 }, []); 44752 const editMediaButtonRef = (0,external_wp_element_namespaceObject.useRef)(); 44753 const errorNoticeID = (0,external_lodash_namespaceObject.uniqueId)('block-editor/media-replace-flow/error-notice/'); 44754 44755 const onUploadError = message => { 44756 const safeMessage = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(message); 44757 44758 if (onError) { 44759 onError(safeMessage); 44760 return; 44761 } // We need to set a timeout for showing the notice 44762 // so that VoiceOver and possibly other screen readers 44763 // can announce the error afer the toolbar button 44764 // regains focus once the upload dialog closes. 44765 // Otherwise VO simply skips over the notice and announces 44766 // the focused element and the open menu. 44767 44768 44769 setTimeout(() => { 44770 createNotice('error', safeMessage, { 44771 speak: true, 44772 id: errorNoticeID, 44773 isDismissible: true 44774 }); 44775 }, 1000); 44776 }; 44777 44778 const selectMedia = (media, closeMenu) => { 44779 closeMenu(); 44780 setMediaURLValue(media === null || media === void 0 ? void 0 : media.url); // Calling `onSelect` after the state update since it might unmount the component. 44781 44782 onSelect(media); 44783 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('The media file has been replaced')); 44784 removeNotice(errorNoticeID); 44785 }; 44786 44787 const uploadFiles = (event, closeMenu) => { 44788 const files = event.target.files; 44789 44790 if (!handleUpload) { 44791 closeMenu(); 44792 return onSelect(files); 44793 } 44794 44795 onFilesUpload(files); 44796 mediaUpload({ 44797 allowedTypes, 44798 filesList: files, 44799 onFileChange: _ref2 => { 44800 let [media] = _ref2; 44801 selectMedia(media, closeMenu); 44802 }, 44803 onError: onUploadError 44804 }); 44805 }; 44806 44807 const openOnArrowDown = event => { 44808 if (event.keyCode === external_wp_keycodes_namespaceObject.DOWN) { 44809 event.preventDefault(); 44810 event.target.click(); 44811 } 44812 }; 44813 44814 const onlyAllowsImages = () => { 44815 if (!allowedTypes || allowedTypes.length === 0) { 44816 return false; 44817 } 44818 44819 return allowedTypes.every(allowedType => allowedType === 'image' || allowedType.startsWith('image/')); 44820 }; 44821 44822 const gallery = multiple && onlyAllowsImages(); 44823 const POPOVER_PROPS = { 44824 isAlternate: true 44825 }; 44826 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, { 44827 popoverProps: POPOVER_PROPS, 44828 contentClassName: "block-editor-media-replace-flow__options", 44829 renderToggle: _ref3 => { 44830 let { 44831 isOpen, 44832 onToggle 44833 } = _ref3; 44834 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 44835 ref: editMediaButtonRef, 44836 "aria-expanded": isOpen, 44837 "aria-haspopup": "true", 44838 onClick: onToggle, 44839 onKeyDown: openOnArrowDown 44840 }, name); 44841 }, 44842 renderContent: _ref4 => { 44843 let { 44844 onClose 44845 } = _ref4; 44846 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, { 44847 className: "block-editor-media-replace-flow__media-upload-menu" 44848 }, (0,external_wp_element_namespaceObject.createElement)(media_upload, { 44849 gallery: gallery, 44850 addToGallery: addToGallery, 44851 multiple: multiple, 44852 value: multiple ? mediaIds : mediaId, 44853 onSelect: media => selectMedia(media, onClose), 44854 allowedTypes: allowedTypes, 44855 onClose: onCloseModal, 44856 render: _ref5 => { 44857 let { 44858 open 44859 } = _ref5; 44860 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 44861 icon: library_media, 44862 onClick: open 44863 }, (0,external_wp_i18n_namespaceObject.__)('Open Media Library')); 44864 } 44865 }), (0,external_wp_element_namespaceObject.createElement)(media_upload_check, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FormFileUpload, { 44866 onChange: event => { 44867 uploadFiles(event, onClose); 44868 }, 44869 accept: accept, 44870 multiple: multiple, 44871 render: _ref6 => { 44872 let { 44873 openFileDialog 44874 } = _ref6; 44875 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 44876 icon: library_upload, 44877 onClick: () => { 44878 openFileDialog(); 44879 } 44880 }, (0,external_wp_i18n_namespaceObject.__)('Upload')); 44881 } 44882 })), children), onSelectURL && // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions 44883 (0,external_wp_element_namespaceObject.createElement)("form", { 44884 className: "block-editor-media-flow__url-input" 44885 }, (0,external_wp_element_namespaceObject.createElement)("span", { 44886 className: "block-editor-media-replace-flow__image-url-label" 44887 }, (0,external_wp_i18n_namespaceObject.__)('Current media URL:')), (0,external_wp_element_namespaceObject.createElement)(link_control, { 44888 value: { 44889 url: mediaURLValue 44890 }, 44891 settings: [], 44892 showSuggestions: false, 44893 onChange: _ref7 => { 44894 let { 44895 url 44896 } = _ref7; 44897 setMediaURLValue(url); 44898 onSelectURL(url); 44899 editMediaButtonRef.current.focus(); 44900 } 44901 }))); 44902 } 44903 }); 44904 }; 44905 /** 44906 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-replace-flow/README.md 44907 */ 44908 44909 44910 /* harmony default export */ var media_replace_flow = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withDispatch)(dispatch => { 44911 const { 44912 createNotice, 44913 removeNotice 44914 } = dispatch(external_wp_notices_namespaceObject.store); 44915 return { 44916 createNotice, 44917 removeNotice 44918 }; 44919 }), (0,external_wp_components_namespaceObject.withFilters)('editor.MediaReplaceFlow')])(MediaReplaceFlow)); 44920 44921 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/link-viewer-url.js 44922 44923 44924 /** 44925 * External dependencies 44926 */ 44927 44928 /** 44929 * WordPress dependencies 44930 */ 44931 44932 44933 44934 function LinkViewerURL(_ref) { 44935 let { 44936 url, 44937 urlLabel, 44938 className 44939 } = _ref; 44940 const linkClassName = classnames_default()(className, 'block-editor-url-popover__link-viewer-url'); 44941 44942 if (!url) { 44943 return (0,external_wp_element_namespaceObject.createElement)("span", { 44944 className: linkClassName 44945 }); 44946 } 44947 44948 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, { 44949 className: linkClassName, 44950 href: url 44951 }, urlLabel || (0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURI)(url))); 44952 } 44953 44954 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/link-viewer.js 44955 44956 44957 44958 /** 44959 * External dependencies 44960 */ 44961 44962 /** 44963 * WordPress dependencies 44964 */ 44965 44966 44967 44968 44969 /** 44970 * Internal dependencies 44971 */ 44972 44973 44974 function LinkViewer(_ref) { 44975 let { 44976 className, 44977 linkClassName, 44978 onEditLinkClick, 44979 url, 44980 urlLabel, 44981 ...props 44982 } = _ref; 44983 return (0,external_wp_element_namespaceObject.createElement)("div", _extends({ 44984 className: classnames_default()('block-editor-url-popover__link-viewer', className) 44985 }, props), (0,external_wp_element_namespaceObject.createElement)(LinkViewerURL, { 44986 url: url, 44987 urlLabel: urlLabel, 44988 className: linkClassName 44989 }), onEditLinkClick && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 44990 icon: library_edit, 44991 label: (0,external_wp_i18n_namespaceObject.__)('Edit'), 44992 onClick: onEditLinkClick 44993 })); 44994 } 44995 44996 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/link-editor.js 44997 44998 44999 45000 /** 45001 * External dependencies 45002 */ 45003 45004 /** 45005 * WordPress dependencies 45006 */ 45007 45008 45009 45010 45011 /** 45012 * Internal dependencies 45013 */ 45014 45015 45016 function LinkEditor(_ref) { 45017 let { 45018 autocompleteRef, 45019 className, 45020 onChangeInputValue, 45021 value, 45022 ...props 45023 } = _ref; 45024 return (0,external_wp_element_namespaceObject.createElement)("form", _extends({ 45025 className: classnames_default()('block-editor-url-popover__link-editor', className) 45026 }, props), (0,external_wp_element_namespaceObject.createElement)(url_input, { 45027 value: value, 45028 onChange: onChangeInputValue, 45029 autocompleteRef: autocompleteRef 45030 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 45031 icon: keyboard_return, 45032 label: (0,external_wp_i18n_namespaceObject.__)('Apply'), 45033 type: "submit" 45034 })); 45035 } 45036 45037 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/index.js 45038 45039 45040 45041 /** 45042 * WordPress dependencies 45043 */ 45044 45045 45046 45047 45048 /** 45049 * Internal dependencies 45050 */ 45051 45052 45053 45054 45055 function URLPopover(_ref) { 45056 let { 45057 additionalControls, 45058 children, 45059 renderSettings, 45060 position = 'bottom center', 45061 focusOnMount = 'firstElement', 45062 ...popoverProps 45063 } = _ref; 45064 const [isSettingsExpanded, setIsSettingsExpanded] = (0,external_wp_element_namespaceObject.useState)(false); 45065 const showSettings = !!renderSettings && isSettingsExpanded; 45066 45067 const toggleSettingsVisibility = () => { 45068 setIsSettingsExpanded(!isSettingsExpanded); 45069 }; 45070 45071 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, _extends({ 45072 className: "block-editor-url-popover", 45073 focusOnMount: focusOnMount, 45074 position: position 45075 }, popoverProps), (0,external_wp_element_namespaceObject.createElement)("div", { 45076 className: "block-editor-url-popover__input-container" 45077 }, (0,external_wp_element_namespaceObject.createElement)("div", { 45078 className: "block-editor-url-popover__row" 45079 }, children, !!renderSettings && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 45080 className: "block-editor-url-popover__settings-toggle", 45081 icon: chevron_down, 45082 label: (0,external_wp_i18n_namespaceObject.__)('Link settings'), 45083 onClick: toggleSettingsVisibility, 45084 "aria-expanded": isSettingsExpanded 45085 })), showSettings && (0,external_wp_element_namespaceObject.createElement)("div", { 45086 className: "block-editor-url-popover__row block-editor-url-popover__settings" 45087 }, renderSettings())), additionalControls && !showSettings && (0,external_wp_element_namespaceObject.createElement)("div", { 45088 className: "block-editor-url-popover__additional-controls" 45089 }, additionalControls)); 45090 } 45091 45092 URLPopover.LinkEditor = LinkEditor; 45093 URLPopover.LinkViewer = LinkViewer; 45094 /** 45095 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-popover/README.md 45096 */ 45097 45098 /* harmony default export */ var url_popover = (URLPopover); 45099 45100 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-placeholder/index.js 45101 45102 45103 /** 45104 * External dependencies 45105 */ 45106 45107 45108 /** 45109 * WordPress dependencies 45110 */ 45111 45112 45113 45114 45115 45116 45117 /** 45118 * Internal dependencies 45119 */ 45120 45121 45122 45123 45124 45125 45126 const InsertFromURLPopover = _ref => { 45127 let { 45128 src, 45129 onChange, 45130 onSubmit, 45131 onClose 45132 } = _ref; 45133 return (0,external_wp_element_namespaceObject.createElement)(url_popover, { 45134 onClose: onClose 45135 }, (0,external_wp_element_namespaceObject.createElement)("form", { 45136 className: "block-editor-media-placeholder__url-input-form", 45137 onSubmit: onSubmit 45138 }, (0,external_wp_element_namespaceObject.createElement)("input", { 45139 className: "block-editor-media-placeholder__url-input-field", 45140 type: "text", 45141 "aria-label": (0,external_wp_i18n_namespaceObject.__)('URL'), 45142 placeholder: (0,external_wp_i18n_namespaceObject.__)('Paste or type URL'), 45143 onChange: onChange, 45144 value: src 45145 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 45146 className: "block-editor-media-placeholder__url-input-submit-button", 45147 icon: keyboard_return, 45148 label: (0,external_wp_i18n_namespaceObject.__)('Apply'), 45149 type: "submit" 45150 }))); 45151 }; 45152 45153 function MediaPlaceholder(_ref2) { 45154 let { 45155 value = {}, 45156 allowedTypes, 45157 className, 45158 icon, 45159 labels = {}, 45160 mediaPreview, 45161 notices, 45162 isAppender, 45163 accept, 45164 addToGallery, 45165 multiple = false, 45166 handleUpload = true, 45167 disableDropZone, 45168 disableMediaButtons, 45169 onError, 45170 onSelect, 45171 onCancel, 45172 onSelectURL, 45173 onDoubleClick, 45174 onFilesPreUpload = external_lodash_namespaceObject.noop, 45175 onHTMLDrop = external_lodash_namespaceObject.noop, 45176 onClose = external_lodash_namespaceObject.noop, 45177 children, 45178 mediaLibraryButton, 45179 placeholder, 45180 style 45181 } = _ref2; 45182 const mediaUpload = (0,external_wp_data_namespaceObject.useSelect)(select => { 45183 const { 45184 getSettings 45185 } = select(store); 45186 return getSettings().mediaUpload; 45187 }, []); 45188 const [src, setSrc] = (0,external_wp_element_namespaceObject.useState)(''); 45189 const [isURLInputVisible, setIsURLInputVisible] = (0,external_wp_element_namespaceObject.useState)(false); 45190 (0,external_wp_element_namespaceObject.useEffect)(() => { 45191 var _value$src; 45192 45193 setSrc((_value$src = value === null || value === void 0 ? void 0 : value.src) !== null && _value$src !== void 0 ? _value$src : ''); 45194 }, [value === null || value === void 0 ? void 0 : value.src]); 45195 45196 const onlyAllowsImages = () => { 45197 if (!allowedTypes || allowedTypes.length === 0) { 45198 return false; 45199 } 45200 45201 return allowedTypes.every(allowedType => allowedType === 'image' || allowedType.startsWith('image/')); 45202 }; 45203 45204 const onChangeSrc = event => { 45205 setSrc(event.target.value); 45206 }; 45207 45208 const openURLInput = () => { 45209 setIsURLInputVisible(true); 45210 }; 45211 45212 const closeURLInput = () => { 45213 setIsURLInputVisible(false); 45214 }; 45215 45216 const onSubmitSrc = event => { 45217 event.preventDefault(); 45218 45219 if (src && onSelectURL) { 45220 onSelectURL(src); 45221 closeURLInput(); 45222 } 45223 }; 45224 45225 const onFilesUpload = files => { 45226 if (!handleUpload) { 45227 return onSelect(files); 45228 } 45229 45230 onFilesPreUpload(files); 45231 let setMedia; 45232 45233 if (multiple) { 45234 if (addToGallery) { 45235 // Since the setMedia function runs multiple times per upload group 45236 // and is passed newMedia containing every item in its group each time, we must 45237 // filter out whatever this upload group had previously returned to the 45238 // gallery before adding and returning the image array with replacement newMedia 45239 // values. 45240 // Define an array to store urls from newMedia between subsequent function calls. 45241 let lastMediaPassed = []; 45242 45243 setMedia = newMedia => { 45244 // Remove any images this upload group is responsible for (lastMediaPassed). 45245 // Their replacements are contained in newMedia. 45246 const filteredMedia = (value !== null && value !== void 0 ? value : []).filter(item => { 45247 // If Item has id, only remove it if lastMediaPassed has an item with that id. 45248 if (item.id) { 45249 return !lastMediaPassed.some( // Be sure to convert to number for comparison. 45250 _ref3 => { 45251 let { 45252 id 45253 } = _ref3; 45254 return Number(id) === Number(item.id); 45255 }); 45256 } // Compare transient images via .includes since gallery may append extra info onto the url. 45257 45258 45259 return !lastMediaPassed.some(_ref4 => { 45260 let { 45261 urlSlug 45262 } = _ref4; 45263 return item.url.includes(urlSlug); 45264 }); 45265 }); // Return the filtered media array along with newMedia. 45266 45267 onSelect(filteredMedia.concat(newMedia)); // Reset lastMediaPassed and set it with ids and urls from newMedia. 45268 45269 lastMediaPassed = newMedia.map(media => { 45270 // Add everything up to '.fileType' to compare via .includes. 45271 const cutOffIndex = media.url.lastIndexOf('.'); 45272 const urlSlug = media.url.slice(0, cutOffIndex); 45273 return { 45274 id: media.id, 45275 urlSlug 45276 }; 45277 }); 45278 }; 45279 } else { 45280 setMedia = onSelect; 45281 } 45282 } else { 45283 setMedia = _ref5 => { 45284 let [media] = _ref5; 45285 return onSelect(media); 45286 }; 45287 } 45288 45289 mediaUpload({ 45290 allowedTypes, 45291 filesList: files, 45292 onFileChange: setMedia, 45293 onError 45294 }); 45295 }; 45296 45297 const onUpload = event => { 45298 onFilesUpload(event.target.files); 45299 }; 45300 45301 const defaultRenderPlaceholder = content => { 45302 let { 45303 instructions, 45304 title 45305 } = labels; 45306 45307 if (!mediaUpload && !onSelectURL) { 45308 instructions = (0,external_wp_i18n_namespaceObject.__)('To edit this block, you need permission to upload media.'); 45309 } 45310 45311 if (instructions === undefined || title === undefined) { 45312 const typesAllowed = allowedTypes !== null && allowedTypes !== void 0 ? allowedTypes : []; 45313 const [firstAllowedType] = typesAllowed; 45314 const isOneType = 1 === typesAllowed.length; 45315 const isAudio = isOneType && 'audio' === firstAllowedType; 45316 const isImage = isOneType && 'image' === firstAllowedType; 45317 const isVideo = isOneType && 'video' === firstAllowedType; 45318 45319 if (instructions === undefined && mediaUpload) { 45320 instructions = (0,external_wp_i18n_namespaceObject.__)('Upload a media file or pick one from your media library.'); 45321 45322 if (isAudio) { 45323 instructions = (0,external_wp_i18n_namespaceObject.__)('Upload an audio file, pick one from your media library, or add one with a URL.'); 45324 } else if (isImage) { 45325 instructions = (0,external_wp_i18n_namespaceObject.__)('Upload an image file, pick one from your media library, or add one with a URL.'); 45326 } else if (isVideo) { 45327 instructions = (0,external_wp_i18n_namespaceObject.__)('Upload a video file, pick one from your media library, or add one with a URL.'); 45328 } 45329 } 45330 45331 if (title === undefined) { 45332 title = (0,external_wp_i18n_namespaceObject.__)('Media'); 45333 45334 if (isAudio) { 45335 title = (0,external_wp_i18n_namespaceObject.__)('Audio'); 45336 } else if (isImage) { 45337 title = (0,external_wp_i18n_namespaceObject.__)('Image'); 45338 } else if (isVideo) { 45339 title = (0,external_wp_i18n_namespaceObject.__)('Video'); 45340 } 45341 } 45342 } 45343 45344 const placeholderClassName = classnames_default()('block-editor-media-placeholder', className, { 45345 'is-appender': isAppender 45346 }); 45347 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, { 45348 icon: icon, 45349 label: title, 45350 instructions: instructions, 45351 className: placeholderClassName, 45352 notices: notices, 45353 onDoubleClick: onDoubleClick, 45354 preview: mediaPreview, 45355 style: style 45356 }, content, children); 45357 }; 45358 45359 const renderPlaceholder = placeholder !== null && placeholder !== void 0 ? placeholder : defaultRenderPlaceholder; 45360 45361 const renderDropZone = () => { 45362 if (disableDropZone) { 45363 return null; 45364 } 45365 45366 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropZone, { 45367 onFilesDrop: onFilesUpload, 45368 onHTMLDrop: onHTMLDrop 45369 }); 45370 }; 45371 45372 const renderCancelLink = () => { 45373 return onCancel && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 45374 className: "block-editor-media-placeholder__cancel-button", 45375 title: (0,external_wp_i18n_namespaceObject.__)('Cancel'), 45376 variant: "link", 45377 onClick: onCancel 45378 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')); 45379 }; 45380 45381 const renderUrlSelectionUI = () => { 45382 return onSelectURL && (0,external_wp_element_namespaceObject.createElement)("div", { 45383 className: "block-editor-media-placeholder__url-input-container" 45384 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 45385 className: "block-editor-media-placeholder__button", 45386 onClick: openURLInput, 45387 isPressed: isURLInputVisible, 45388 variant: "tertiary" 45389 }, (0,external_wp_i18n_namespaceObject.__)('Insert from URL')), isURLInputVisible && (0,external_wp_element_namespaceObject.createElement)(InsertFromURLPopover, { 45390 src: src, 45391 onChange: onChangeSrc, 45392 onSubmit: onSubmitSrc, 45393 onClose: closeURLInput 45394 })); 45395 }; 45396 45397 const renderMediaUploadChecked = () => { 45398 const defaultButton = _ref6 => { 45399 let { 45400 open 45401 } = _ref6; 45402 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 45403 variant: "tertiary", 45404 onClick: () => { 45405 open(); 45406 } 45407 }, (0,external_wp_i18n_namespaceObject.__)('Media Library')); 45408 }; 45409 45410 const libraryButton = mediaLibraryButton !== null && mediaLibraryButton !== void 0 ? mediaLibraryButton : defaultButton; 45411 const uploadMediaLibraryButton = (0,external_wp_element_namespaceObject.createElement)(media_upload, { 45412 addToGallery: addToGallery, 45413 gallery: multiple && onlyAllowsImages(), 45414 multiple: multiple, 45415 onSelect: onSelect, 45416 onClose: onClose, 45417 allowedTypes: allowedTypes, 45418 value: Array.isArray(value) ? value.map(_ref7 => { 45419 let { 45420 id 45421 } = _ref7; 45422 return id; 45423 }) : value.id, 45424 render: libraryButton 45425 }); 45426 45427 if (mediaUpload && isAppender) { 45428 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, renderDropZone(), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FormFileUpload, { 45429 onChange: onUpload, 45430 accept: accept, 45431 multiple: multiple, 45432 render: _ref8 => { 45433 let { 45434 openFileDialog 45435 } = _ref8; 45436 const content = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 45437 variant: "primary", 45438 className: classnames_default()('block-editor-media-placeholder__button', 'block-editor-media-placeholder__upload-button'), 45439 onClick: openFileDialog 45440 }, (0,external_wp_i18n_namespaceObject.__)('Upload')), uploadMediaLibraryButton, renderUrlSelectionUI(), renderCancelLink()); 45441 return renderPlaceholder(content); 45442 } 45443 })); 45444 } 45445 45446 if (mediaUpload) { 45447 const content = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, renderDropZone(), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FormFileUpload, { 45448 variant: "primary", 45449 className: classnames_default()('block-editor-media-placeholder__button', 'block-editor-media-placeholder__upload-button'), 45450 onChange: onUpload, 45451 accept: accept, 45452 multiple: multiple 45453 }, (0,external_wp_i18n_namespaceObject.__)('Upload')), uploadMediaLibraryButton, renderUrlSelectionUI(), renderCancelLink()); 45454 return renderPlaceholder(content); 45455 } 45456 45457 return renderPlaceholder(uploadMediaLibraryButton); 45458 }; 45459 45460 if (disableMediaButtons) { 45461 return (0,external_wp_element_namespaceObject.createElement)(media_upload_check, null, renderDropZone()); 45462 } 45463 45464 return (0,external_wp_element_namespaceObject.createElement)(media_upload_check, { 45465 fallback: renderPlaceholder(renderUrlSelectionUI()) 45466 }, renderMediaUploadChecked()); 45467 } 45468 /** 45469 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-placeholder/README.md 45470 */ 45471 45472 /* harmony default export */ var media_placeholder = ((0,external_wp_components_namespaceObject.withFilters)('editor.MediaPlaceholder')(MediaPlaceholder)); 45473 45474 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/panel-color-settings/index.js 45475 45476 45477 45478 /** 45479 * Internal dependencies 45480 */ 45481 45482 45483 const PanelColorSettings = _ref => { 45484 let { 45485 colorSettings, 45486 ...props 45487 } = _ref; 45488 const settings = colorSettings.map(setting => { 45489 if (!setting) { 45490 return setting; 45491 } 45492 45493 const { 45494 value, 45495 onChange, 45496 ...otherSettings 45497 } = setting; 45498 return { ...otherSettings, 45499 colorValue: value, 45500 onColorChange: onChange 45501 }; 45502 }); 45503 return (0,external_wp_element_namespaceObject.createElement)(panel_color_gradient_settings, _extends({ 45504 settings: settings, 45505 gradients: [], 45506 disableCustomGradients: true 45507 }, props)); 45508 }; 45509 45510 /* harmony default export */ var panel_color_settings = (PanelColorSettings); 45511 45512 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-toolbar/index.js 45513 45514 45515 /** 45516 * External dependencies 45517 */ 45518 45519 45520 /** 45521 * WordPress dependencies 45522 */ 45523 45524 45525 45526 45527 const format_toolbar_POPOVER_PROPS = { 45528 position: 'bottom right', 45529 isAlternate: true 45530 }; 45531 45532 const FormatToolbar = () => { 45533 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, ['bold', 'italic', 'link'].map(format => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, { 45534 name: `RichText.ToolbarControls.$format}`, 45535 key: format 45536 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, { 45537 name: "RichText.ToolbarControls" 45538 }, fills => { 45539 if (!fills.length) { 45540 return null; 45541 } 45542 45543 const allProps = fills.map(_ref => { 45544 let [{ 45545 props 45546 }] = _ref; 45547 return props; 45548 }); 45549 const hasActive = allProps.some(_ref2 => { 45550 let { 45551 isActive 45552 } = _ref2; 45553 return isActive; 45554 }); 45555 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, null, toggleProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 45556 icon: chevron_down 45557 /* translators: button label text should, if possible, be under 16 characters. */ 45558 , 45559 label: (0,external_wp_i18n_namespaceObject.__)('More'), 45560 toggleProps: { ...toggleProps, 45561 className: classnames_default()(toggleProps.className, { 45562 'is-pressed': hasActive 45563 }), 45564 describedBy: (0,external_wp_i18n_namespaceObject.__)('Displays more block tools') 45565 }, 45566 controls: (0,external_lodash_namespaceObject.orderBy)(fills.map(_ref3 => { 45567 let [{ 45568 props 45569 }] = _ref3; 45570 return props; 45571 }), 'title'), 45572 popoverProps: format_toolbar_POPOVER_PROPS 45573 })); 45574 })); 45575 }; 45576 45577 /* harmony default export */ var format_toolbar = (FormatToolbar); 45578 45579 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-toolbar-container.js 45580 45581 45582 /** 45583 * WordPress dependencies 45584 */ 45585 45586 /** 45587 * Internal dependencies 45588 */ 45589 45590 45591 45592 45593 const FormatToolbarContainer = _ref => { 45594 let { 45595 inline, 45596 anchorRef 45597 } = _ref; 45598 45599 if (inline) { 45600 // Render in popover. 45601 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { 45602 noArrow: true, 45603 position: "top center", 45604 focusOnMount: false, 45605 anchorRef: anchorRef, 45606 className: "block-editor-rich-text__inline-format-toolbar", 45607 __unstableSlotName: "block-toolbar" 45608 }, (0,external_wp_element_namespaceObject.createElement)("div", { 45609 className: "block-editor-rich-text__inline-format-toolbar-group" 45610 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(format_toolbar, null)))); 45611 } // Render regular toolbar. 45612 45613 45614 return (0,external_wp_element_namespaceObject.createElement)(block_controls, { 45615 group: "inline" 45616 }, (0,external_wp_element_namespaceObject.createElement)(format_toolbar, null)); 45617 }; 45618 45619 /* harmony default export */ var format_toolbar_container = (FormatToolbarContainer); 45620 45621 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-undo-automatic-change.js 45622 /** 45623 * WordPress dependencies 45624 */ 45625 45626 45627 45628 /** 45629 * Internal dependencies 45630 */ 45631 45632 45633 function useUndoAutomaticChange() { 45634 const { 45635 didAutomaticChange, 45636 getSettings 45637 } = (0,external_wp_data_namespaceObject.useSelect)(store); 45638 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => { 45639 function onKeyDown(event) { 45640 const { 45641 keyCode 45642 } = event; 45643 45644 if (event.defaultPrevented) { 45645 return; 45646 } 45647 45648 if (keyCode !== external_wp_keycodes_namespaceObject.DELETE && keyCode !== external_wp_keycodes_namespaceObject.BACKSPACE && keyCode !== external_wp_keycodes_namespaceObject.ESCAPE) { 45649 return; 45650 } 45651 45652 if (!didAutomaticChange()) { 45653 return; 45654 } 45655 45656 event.preventDefault(); 45657 45658 getSettings().__experimentalUndo(); 45659 } 45660 45661 element.addEventListener('keydown', onKeyDown); 45662 return () => { 45663 element.removeEventListener('keydown', onKeyDown); 45664 }; 45665 }, []); 45666 } 45667 45668 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-caret-in-format.js 45669 /** 45670 * WordPress dependencies 45671 */ 45672 45673 45674 /** 45675 * Internal dependencies 45676 */ 45677 45678 45679 function useCaretInFormat(_ref) { 45680 let { 45681 value 45682 } = _ref; 45683 const hasActiveFormats = value.activeFormats && !!value.activeFormats.length; 45684 const { 45685 isCaretWithinFormattedText 45686 } = (0,external_wp_data_namespaceObject.useSelect)(store); 45687 const { 45688 enterFormattedText, 45689 exitFormattedText 45690 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 45691 (0,external_wp_element_namespaceObject.useEffect)(() => { 45692 if (hasActiveFormats) { 45693 if (!isCaretWithinFormattedText()) { 45694 enterFormattedText(); 45695 } 45696 } else if (isCaretWithinFormattedText()) { 45697 exitFormattedText(); 45698 } 45699 }, [hasActiveFormats]); 45700 } 45701 45702 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-mark-persistent.js 45703 /** 45704 * WordPress dependencies 45705 */ 45706 45707 45708 /** 45709 * Internal dependencies 45710 */ 45711 45712 45713 function useMarkPersistent(_ref) { 45714 let { 45715 html, 45716 value 45717 } = _ref; 45718 const previousText = (0,external_wp_element_namespaceObject.useRef)(); 45719 const hasActiveFormats = value.activeFormats && !!value.activeFormats.length; 45720 const { 45721 __unstableMarkLastChangeAsPersistent 45722 } = (0,external_wp_data_namespaceObject.useDispatch)(store); // Must be set synchronously to make sure it applies to the last change. 45723 45724 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 45725 // Ignore mount. 45726 if (!previousText.current) { 45727 previousText.current = value.text; 45728 return; 45729 } // Text input, so don't create an undo level for every character. 45730 // Create an undo level after 1 second of no input. 45731 45732 45733 if (previousText.current !== value.text) { 45734 const timeout = window.setTimeout(() => { 45735 __unstableMarkLastChangeAsPersistent(); 45736 }, 1000); 45737 previousText.current = value.text; 45738 return () => { 45739 window.clearTimeout(timeout); 45740 }; 45741 } 45742 45743 __unstableMarkLastChangeAsPersistent(); 45744 }, [html, hasActiveFormats]); 45745 } 45746 45747 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/file-paste-handler.js 45748 /** 45749 * WordPress dependencies 45750 */ 45751 45752 function filePasteHandler(files) { 45753 return files.filter(_ref => { 45754 let { 45755 type 45756 } = _ref; 45757 return /^image\/(?:jpe?g|png|gif|webp)$/.test(type); 45758 }).map(file => `<img src="${(0,external_wp_blob_namespaceObject.createBlobURL)(file)}">`).join(''); 45759 } 45760 45761 ;// CONCATENATED MODULE: external ["wp","shortcode"] 45762 var external_wp_shortcode_namespaceObject = window["wp"]["shortcode"]; 45763 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/utils.js 45764 45765 45766 /** 45767 * WordPress dependencies 45768 */ 45769 45770 45771 45772 45773 function addActiveFormats(value, activeFormats) { 45774 if (activeFormats !== null && activeFormats !== void 0 && activeFormats.length) { 45775 let index = value.formats.length; 45776 45777 while (index--) { 45778 value.formats[index] = [...activeFormats, ...(value.formats[index] || [])]; 45779 } 45780 } 45781 } 45782 /** 45783 * Get the multiline tag based on the multiline prop. 45784 * 45785 * @param {?(string|boolean)} multiline The multiline prop. 45786 * 45787 * @return {?string} The multiline tag. 45788 */ 45789 45790 function getMultilineTag(multiline) { 45791 if (multiline !== true && multiline !== 'p' && multiline !== 'li') { 45792 return; 45793 } 45794 45795 return multiline === true ? 'p' : multiline; 45796 } 45797 function getAllowedFormats(_ref) { 45798 let { 45799 allowedFormats, 45800 formattingControls, 45801 disableFormats 45802 } = _ref; 45803 45804 if (disableFormats) { 45805 return getAllowedFormats.EMPTY_ARRAY; 45806 } 45807 45808 if (!allowedFormats && !formattingControls) { 45809 return; 45810 } 45811 45812 if (allowedFormats) { 45813 return allowedFormats; 45814 } 45815 45816 external_wp_deprecated_default()('wp.blockEditor.RichText formattingControls prop', { 45817 since: '5.4', 45818 alternative: 'allowedFormats', 45819 version: '6.2' 45820 }); 45821 return formattingControls.map(name => `core/$name}`); 45822 } 45823 getAllowedFormats.EMPTY_ARRAY = []; 45824 const isShortcode = text => (0,external_wp_shortcode_namespaceObject.regexp)('.*').test(text); 45825 /** 45826 * Creates a link from pasted URL. 45827 * Creates a paragraph block containing a link to the URL, and calls `onReplace`. 45828 * 45829 * @param {string} url The URL that could not be embedded. 45830 * @param {Function} onReplace Function to call with the created fallback block. 45831 */ 45832 45833 function createLinkInParagraph(url, onReplace) { 45834 const link = createElement("a", { 45835 href: url 45836 }, url); 45837 onReplace(createBlock('core/paragraph', { 45838 content: renderToString(link) 45839 })); 45840 } 45841 45842 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/split-value.js 45843 /** 45844 * WordPress dependencies 45845 */ 45846 45847 /* 45848 * Signals to the RichText owner that the block can be replaced with two blocks 45849 * as a result of splitting the block by pressing enter, or with blocks as a 45850 * result of splitting the block by pasting block content in the instance. 45851 */ 45852 45853 function splitValue(_ref) { 45854 let { 45855 value, 45856 pastedBlocks = [], 45857 onReplace, 45858 onSplit, 45859 onSplitMiddle, 45860 multilineTag 45861 } = _ref; 45862 45863 if (!onReplace || !onSplit) { 45864 return; 45865 } // Ensure the value has a selection. This might happen when trying to split 45866 // an empty value before there was a `selectionchange` event. 45867 45868 45869 const { 45870 start = 0, 45871 end = 0 45872 } = value; 45873 const valueWithEnsuredSelection = { ...value, 45874 start, 45875 end 45876 }; 45877 const blocks = []; 45878 const [before, after] = (0,external_wp_richText_namespaceObject.split)(valueWithEnsuredSelection); 45879 const hasPastedBlocks = pastedBlocks.length > 0; 45880 let lastPastedBlockIndex = -1; // Consider the after value to be the original it is not empty and the 45881 // before value *is* empty. 45882 45883 const isAfterOriginal = (0,external_wp_richText_namespaceObject.isEmpty)(before) && !(0,external_wp_richText_namespaceObject.isEmpty)(after); // Create a block with the content before the caret if there's no pasted 45884 // blocks, or if there are pasted blocks and the value is not empty. We do 45885 // not want a leading empty block on paste, but we do if split with e.g. the 45886 // enter key. 45887 45888 if (!hasPastedBlocks || !(0,external_wp_richText_namespaceObject.isEmpty)(before)) { 45889 blocks.push(onSplit((0,external_wp_richText_namespaceObject.toHTMLString)({ 45890 value: before, 45891 multilineTag 45892 }), !isAfterOriginal)); 45893 lastPastedBlockIndex += 1; 45894 } 45895 45896 if (hasPastedBlocks) { 45897 blocks.push(...pastedBlocks); 45898 lastPastedBlockIndex += pastedBlocks.length; 45899 } else if (onSplitMiddle) { 45900 blocks.push(onSplitMiddle()); 45901 } // If there's pasted blocks, append a block with non empty content / after 45902 // the caret. Otherwise, do append an empty block if there is no 45903 // `onSplitMiddle` prop, but if there is and the content is empty, the 45904 // middle block is enough to set focus in. 45905 45906 45907 if (hasPastedBlocks ? !(0,external_wp_richText_namespaceObject.isEmpty)(after) : !onSplitMiddle || !(0,external_wp_richText_namespaceObject.isEmpty)(after)) { 45908 blocks.push(onSplit((0,external_wp_richText_namespaceObject.toHTMLString)({ 45909 value: after, 45910 multilineTag 45911 }), isAfterOriginal)); 45912 } // If there are pasted blocks, set the selection to the last one. Otherwise, 45913 // set the selection to the second block. 45914 45915 45916 const indexToSelect = hasPastedBlocks ? lastPastedBlockIndex : 1; // If there are pasted blocks, move the caret to the end of the selected 45917 // block Otherwise, retain the default value. 45918 45919 const initialPosition = hasPastedBlocks ? -1 : 0; 45920 onReplace(blocks, indexToSelect, initialPosition); 45921 } 45922 45923 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-paste-handler.js 45924 /** 45925 * WordPress dependencies 45926 */ 45927 45928 45929 45930 45931 45932 45933 /** 45934 * Internal dependencies 45935 */ 45936 45937 45938 45939 45940 45941 /** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */ 45942 45943 /** 45944 * Replaces line separators with line breaks if not multiline. 45945 * Replaces line breaks with line separators if multiline. 45946 * 45947 * @param {RichTextValue} value Value to adjust. 45948 * @param {boolean} isMultiline Whether to adjust to multiline or not. 45949 * 45950 * @return {RichTextValue} Adjusted value. 45951 */ 45952 45953 function adjustLines(value, isMultiline) { 45954 if (isMultiline) { 45955 return (0,external_wp_richText_namespaceObject.replace)(value, /\n+/g, external_wp_richText_namespaceObject.__UNSTABLE_LINE_SEPARATOR); 45956 } 45957 45958 return (0,external_wp_richText_namespaceObject.replace)(value, new RegExp(external_wp_richText_namespaceObject.__UNSTABLE_LINE_SEPARATOR, 'g'), '\n'); 45959 } 45960 45961 function usePasteHandler(props) { 45962 const propsRef = (0,external_wp_element_namespaceObject.useRef)(props); 45963 propsRef.current = props; 45964 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => { 45965 function _onPaste(event) { 45966 const { 45967 isSelected, 45968 disableFormats, 45969 onChange, 45970 value, 45971 formatTypes, 45972 tagName, 45973 onReplace, 45974 onSplit, 45975 onSplitMiddle, 45976 __unstableEmbedURLOnPaste, 45977 multilineTag, 45978 preserveWhiteSpace, 45979 pastePlainText 45980 } = propsRef.current; 45981 45982 if (!isSelected) { 45983 return; 45984 } 45985 45986 const { 45987 clipboardData 45988 } = event; 45989 let plainText = ''; 45990 let html = ''; // IE11 only supports `Text` as an argument for `getData` and will 45991 // otherwise throw an invalid argument error, so we try the standard 45992 // arguments first, then fallback to `Text` if they fail. 45993 45994 try { 45995 plainText = clipboardData.getData('text/plain'); 45996 html = clipboardData.getData('text/html'); 45997 } catch (error1) { 45998 try { 45999 html = clipboardData.getData('Text'); 46000 } catch (error2) { 46001 // Some browsers like UC Browser paste plain text by default and 46002 // don't support clipboardData at all, so allow default 46003 // behaviour. 46004 return; 46005 } 46006 } // Remove Windows-specific metadata appended within copied HTML text. 46007 46008 46009 html = removeWindowsFragments(html); // Strip meta tag. 46010 46011 html = removeCharsetMetaTag(html); 46012 event.preventDefault(); // Allows us to ask for this information when we get a report. 46013 46014 window.console.log('Received HTML:\n\n', html); 46015 window.console.log('Received plain text:\n\n', plainText); 46016 46017 if (disableFormats) { 46018 onChange((0,external_wp_richText_namespaceObject.insert)(value, plainText)); 46019 return; 46020 } 46021 46022 const transformed = formatTypes.reduce((accumlator, _ref) => { 46023 let { 46024 __unstablePasteRule 46025 } = _ref; 46026 46027 // Only allow one transform. 46028 if (__unstablePasteRule && accumlator === value) { 46029 accumlator = __unstablePasteRule(value, { 46030 html, 46031 plainText 46032 }); 46033 } 46034 46035 return accumlator; 46036 }, value); 46037 46038 if (transformed !== value) { 46039 onChange(transformed); 46040 return; 46041 } 46042 46043 const files = [...(0,external_wp_dom_namespaceObject.getFilesFromDataTransfer)(clipboardData)]; 46044 const isInternal = clipboardData.getData('rich-text') === 'true'; // If the data comes from a rich text instance, we can directly use it 46045 // without filtering the data. The filters are only meant for externally 46046 // pasted content and remove inline styles. 46047 46048 if (isInternal) { 46049 const pastedMultilineTag = clipboardData.getData('rich-text-multi-line-tag') || undefined; 46050 let pastedValue = (0,external_wp_richText_namespaceObject.create)({ 46051 html, 46052 multilineTag: pastedMultilineTag, 46053 multilineWrapperTags: pastedMultilineTag === 'li' ? ['ul', 'ol'] : undefined, 46054 preserveWhiteSpace 46055 }); 46056 pastedValue = adjustLines(pastedValue, !!multilineTag); 46057 addActiveFormats(pastedValue, value.activeFormats); 46058 onChange((0,external_wp_richText_namespaceObject.insert)(value, pastedValue)); 46059 return; 46060 } 46061 46062 if (pastePlainText) { 46063 onChange((0,external_wp_richText_namespaceObject.insert)(value, (0,external_wp_richText_namespaceObject.create)({ 46064 text: plainText 46065 }))); 46066 return; 46067 } // Process any attached files, unless we infer that the files in 46068 // question are redundant "screenshots" of the actual HTML payload, 46069 // as created by certain office-type programs. 46070 // 46071 // @see shouldDismissPastedFiles 46072 46073 46074 if (files !== null && files !== void 0 && files.length && !shouldDismissPastedFiles(files, html, plainText)) { 46075 const content = (0,external_wp_blocks_namespaceObject.pasteHandler)({ 46076 HTML: filePasteHandler(files), 46077 mode: 'BLOCKS', 46078 tagName, 46079 preserveWhiteSpace 46080 }); // Allows us to ask for this information when we get a report. 46081 // eslint-disable-next-line no-console 46082 46083 window.console.log('Received items:\n\n', files); 46084 46085 if (onReplace && (0,external_wp_richText_namespaceObject.isEmpty)(value)) { 46086 onReplace(content); 46087 } else { 46088 splitValue({ 46089 value, 46090 pastedBlocks: content, 46091 onReplace, 46092 onSplit, 46093 onSplitMiddle, 46094 multilineTag 46095 }); 46096 } 46097 46098 return; 46099 } 46100 46101 let mode = onReplace && onSplit ? 'AUTO' : 'INLINE'; // Force the blocks mode when the user is pasting 46102 // on a new line & the content resembles a shortcode. 46103 // Otherwise it's going to be detected as inline 46104 // and the shortcode won't be replaced. 46105 46106 if (mode === 'AUTO' && (0,external_wp_richText_namespaceObject.isEmpty)(value) && isShortcode(plainText)) { 46107 mode = 'BLOCKS'; 46108 } 46109 46110 if (__unstableEmbedURLOnPaste && (0,external_wp_richText_namespaceObject.isEmpty)(value) && (0,external_wp_url_namespaceObject.isURL)(plainText.trim())) { 46111 mode = 'BLOCKS'; 46112 } 46113 46114 const content = (0,external_wp_blocks_namespaceObject.pasteHandler)({ 46115 HTML: html, 46116 plainText, 46117 mode, 46118 tagName, 46119 preserveWhiteSpace 46120 }); 46121 46122 if (typeof content === 'string') { 46123 let valueToInsert = (0,external_wp_richText_namespaceObject.create)({ 46124 html: content 46125 }); // If the content should be multiline, we should process text 46126 // separated by a line break as separate lines. 46127 46128 valueToInsert = adjustLines(valueToInsert, !!multilineTag); 46129 addActiveFormats(valueToInsert, value.activeFormats); 46130 onChange((0,external_wp_richText_namespaceObject.insert)(value, valueToInsert)); 46131 } else if (content.length > 0) { 46132 if (onReplace && (0,external_wp_richText_namespaceObject.isEmpty)(value)) { 46133 onReplace(content, content.length - 1, -1); 46134 } else { 46135 splitValue({ 46136 value, 46137 pastedBlocks: content, 46138 onReplace, 46139 onSplit, 46140 onSplitMiddle, 46141 multilineTag 46142 }); 46143 } 46144 } 46145 } 46146 46147 element.addEventListener('paste', _onPaste); 46148 return () => { 46149 element.removeEventListener('paste', _onPaste); 46150 }; 46151 }, []); 46152 } 46153 /** 46154 * Normalizes a given string of HTML to remove the Windows specific "Fragment" comments 46155 * and any preceeding and trailing whitespace. 46156 * 46157 * @param {string} html the html to be normalized 46158 * @return {string} the normalized html 46159 */ 46160 46161 function removeWindowsFragments(html) { 46162 const startReg = /.*<!--StartFragment-->/s; 46163 const endReg = /<!--EndFragment-->.*/s; 46164 return html.replace(startReg, '').replace(endReg, ''); 46165 } 46166 /** 46167 * Removes the charset meta tag inserted by Chromium. 46168 * See: 46169 * - https://github.com/WordPress/gutenberg/issues/33585 46170 * - https://bugs.chromium.org/p/chromium/issues/detail?id=1264616#c4 46171 * 46172 * @param {string} html the html to be stripped of the meta tag. 46173 * @return {string} the cleaned html 46174 */ 46175 46176 46177 function removeCharsetMetaTag(html) { 46178 const metaTag = `<meta charset='utf-8'>`; 46179 46180 if (html.startsWith(metaTag)) { 46181 return html.slice(metaTag.length); 46182 } 46183 46184 return html; 46185 } 46186 46187 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/prevent-event-discovery.js 46188 /** 46189 * WordPress dependencies 46190 */ 46191 46192 function preventEventDiscovery(value) { 46193 const searchText = 'tales of gutenberg'; 46194 const addText = ' 🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️'; 46195 const { 46196 start, 46197 text 46198 } = value; 46199 46200 if (start < searchText.length) { 46201 return value; 46202 } 46203 46204 const charactersBefore = text.slice(start - searchText.length, start); 46205 46206 if (charactersBefore.toLowerCase() !== searchText) { 46207 return value; 46208 } 46209 46210 return (0,external_wp_richText_namespaceObject.insert)(value, addText); 46211 } 46212 46213 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-input-rules.js 46214 /** 46215 * External dependencies 46216 */ 46217 46218 /** 46219 * WordPress dependencies 46220 */ 46221 46222 46223 46224 46225 46226 46227 /** 46228 * Internal dependencies 46229 */ 46230 46231 46232 // A robust way to retain selection position through various 46233 // transforms is to insert a special character at the position and 46234 // then recover it. 46235 46236 const START_OF_SELECTED_AREA = '\u0086'; 46237 46238 function findSelection(blocks) { 46239 let i = blocks.length; 46240 46241 while (i--) { 46242 const attributeKey = (0,external_lodash_namespaceObject.findKey)(blocks[i].attributes, v => typeof v === 'string' && v.indexOf(START_OF_SELECTED_AREA) !== -1); 46243 46244 if (attributeKey) { 46245 blocks[i].attributes[attributeKey] = blocks[i].attributes[attributeKey].replace(START_OF_SELECTED_AREA, ''); 46246 return blocks[i].clientId; 46247 } 46248 46249 const nestedSelection = findSelection(blocks[i].innerBlocks); 46250 46251 if (nestedSelection) { 46252 return nestedSelection; 46253 } 46254 } 46255 } 46256 46257 function useInputRules(props) { 46258 const { 46259 __unstableMarkLastChangeAsPersistent, 46260 __unstableMarkAutomaticChange 46261 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 46262 const propsRef = (0,external_wp_element_namespaceObject.useRef)(props); 46263 propsRef.current = props; 46264 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => { 46265 function inputRule() { 46266 const { 46267 value, 46268 onReplace, 46269 selectionChange 46270 } = propsRef.current; 46271 46272 if (!onReplace) { 46273 return; 46274 } 46275 46276 const { 46277 start, 46278 text 46279 } = value; 46280 const characterBefore = text.slice(start - 1, start); // The character right before the caret must be a plain space. 46281 46282 if (characterBefore !== ' ') { 46283 return; 46284 } 46285 46286 const trimmedTextBefore = text.slice(0, start).trim(); 46287 const prefixTransforms = (0,external_wp_blocks_namespaceObject.getBlockTransforms)('from').filter(_ref => { 46288 let { 46289 type 46290 } = _ref; 46291 return type === 'prefix'; 46292 }); 46293 const transformation = (0,external_wp_blocks_namespaceObject.findTransform)(prefixTransforms, _ref2 => { 46294 let { 46295 prefix 46296 } = _ref2; 46297 return trimmedTextBefore === prefix; 46298 }); 46299 46300 if (!transformation) { 46301 return; 46302 } 46303 46304 const content = (0,external_wp_richText_namespaceObject.toHTMLString)({ 46305 value: (0,external_wp_richText_namespaceObject.insert)(value, START_OF_SELECTED_AREA, 0, start) 46306 }); 46307 const block = transformation.transform(content); 46308 selectionChange(findSelection([block])); 46309 onReplace([block]); 46310 46311 __unstableMarkAutomaticChange(); 46312 } 46313 46314 function onInput(event) { 46315 const { 46316 inputType, 46317 type 46318 } = event; 46319 const { 46320 value, 46321 onChange, 46322 __unstableAllowPrefixTransformations, 46323 formatTypes 46324 } = propsRef.current; // Only run input rules when inserting text. 46325 46326 if (inputType !== 'insertText' && type !== 'compositionend') { 46327 return; 46328 } 46329 46330 if (__unstableAllowPrefixTransformations && inputRule) { 46331 inputRule(); 46332 } 46333 46334 const transformed = formatTypes.reduce((accumlator, _ref3) => { 46335 let { 46336 __unstableInputRule 46337 } = _ref3; 46338 46339 if (__unstableInputRule) { 46340 accumlator = __unstableInputRule(accumlator); 46341 } 46342 46343 return accumlator; 46344 }, preventEventDiscovery(value)); 46345 46346 if (transformed !== value) { 46347 __unstableMarkLastChangeAsPersistent(); 46348 46349 onChange({ ...transformed, 46350 activeFormats: value.activeFormats 46351 }); 46352 46353 __unstableMarkAutomaticChange(); 46354 } 46355 } 46356 46357 element.addEventListener('input', onInput); 46358 element.addEventListener('compositionend', onInput); 46359 return () => { 46360 element.removeEventListener('input', onInput); 46361 element.removeEventListener('compositionend', onInput); 46362 }; 46363 }, []); 46364 } 46365 46366 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-enter.js 46367 /** 46368 * WordPress dependencies 46369 */ 46370 46371 /** 46372 * WordPress dependencies 46373 */ 46374 46375 46376 46377 46378 46379 46380 /** 46381 * Internal dependencies 46382 */ 46383 46384 46385 46386 function useEnter(props) { 46387 const { 46388 __unstableMarkAutomaticChange 46389 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 46390 const propsRef = (0,external_wp_element_namespaceObject.useRef)(props); 46391 propsRef.current = props; 46392 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => { 46393 function onKeyDown(event) { 46394 if (event.defaultPrevented) { 46395 return; 46396 } 46397 46398 const { 46399 removeEditorOnlyFormats, 46400 value, 46401 onReplace, 46402 onSplit, 46403 onSplitMiddle, 46404 multilineTag, 46405 onChange, 46406 disableLineBreaks, 46407 onSplitAtEnd 46408 } = propsRef.current; 46409 46410 if (event.keyCode !== external_wp_keycodes_namespaceObject.ENTER) { 46411 return; 46412 } 46413 46414 event.preventDefault(); 46415 const _value = { ...value 46416 }; 46417 _value.formats = removeEditorOnlyFormats(value); 46418 const canSplit = onReplace && onSplit; 46419 46420 if (onReplace) { 46421 const transforms = (0,external_wp_blocks_namespaceObject.getBlockTransforms)('from').filter(_ref => { 46422 let { 46423 type 46424 } = _ref; 46425 return type === 'enter'; 46426 }); 46427 const transformation = (0,external_wp_blocks_namespaceObject.findTransform)(transforms, item => { 46428 return item.regExp.test(_value.text); 46429 }); 46430 46431 if (transformation) { 46432 onReplace([transformation.transform({ 46433 content: _value.text 46434 })]); 46435 46436 __unstableMarkAutomaticChange(); 46437 } 46438 } 46439 46440 if (multilineTag) { 46441 if (event.shiftKey) { 46442 if (!disableLineBreaks) { 46443 onChange((0,external_wp_richText_namespaceObject.insert)(_value, '\n')); 46444 } 46445 } else if (canSplit && (0,external_wp_richText_namespaceObject.__unstableIsEmptyLine)(_value)) { 46446 splitValue({ 46447 value: _value, 46448 onReplace, 46449 onSplit, 46450 onSplitMiddle, 46451 multilineTag 46452 }); 46453 } else { 46454 onChange((0,external_wp_richText_namespaceObject.__unstableInsertLineSeparator)(_value)); 46455 } 46456 } else { 46457 const { 46458 text, 46459 start, 46460 end 46461 } = _value; 46462 const canSplitAtEnd = onSplitAtEnd && start === end && end === text.length; 46463 46464 if (event.shiftKey || !canSplit && !canSplitAtEnd) { 46465 if (!disableLineBreaks) { 46466 onChange((0,external_wp_richText_namespaceObject.insert)(_value, '\n')); 46467 } 46468 } else if (!canSplit && canSplitAtEnd) { 46469 onSplitAtEnd(); 46470 } else if (canSplit) { 46471 splitValue({ 46472 value: _value, 46473 onReplace, 46474 onSplit, 46475 onSplitMiddle, 46476 multilineTag 46477 }); 46478 } 46479 } 46480 } 46481 46482 element.addEventListener('keydown', onKeyDown); 46483 return () => { 46484 element.removeEventListener('keydown', onKeyDown); 46485 }; 46486 }, []); 46487 } 46488 46489 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-format-types.js 46490 /** 46491 * WordPress dependencies 46492 */ 46493 46494 46495 /** 46496 * Internal dependencies 46497 */ 46498 46499 46500 46501 function formatTypesSelector(select) { 46502 return select(external_wp_richText_namespaceObject.store).getFormatTypes(); 46503 } 46504 /** 46505 * Set of all interactive content tags. 46506 * 46507 * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content 46508 */ 46509 46510 46511 const interactiveContentTags = new Set(['a', 'audio', 'button', 'details', 'embed', 'iframe', 'input', 'label', 'select', 'textarea', 'video']); 46512 /** 46513 * This hook provides RichText with the `formatTypes` and its derived props from 46514 * experimental format type settings. 46515 * 46516 * @param {Object} $0 Options 46517 * @param {string} $0.clientId Block client ID. 46518 * @param {string} $0.identifier Block attribute. 46519 * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not. 46520 * @param {Array} $0.allowedFormats Allowed formats 46521 */ 46522 46523 function useFormatTypes(_ref) { 46524 let { 46525 clientId, 46526 identifier, 46527 withoutInteractiveFormatting, 46528 allowedFormats 46529 } = _ref; 46530 const allFormatTypes = (0,external_wp_data_namespaceObject.useSelect)(formatTypesSelector, []); 46531 const formatTypes = (0,external_wp_element_namespaceObject.useMemo)(() => { 46532 return allFormatTypes.filter(_ref2 => { 46533 let { 46534 name, 46535 tagName 46536 } = _ref2; 46537 46538 if (allowedFormats && !allowedFormats.includes(name)) { 46539 return false; 46540 } 46541 46542 if (withoutInteractiveFormatting && interactiveContentTags.has(tagName)) { 46543 return false; 46544 } 46545 46546 return true; 46547 }); 46548 }, [allFormatTypes, allowedFormats, interactiveContentTags]); 46549 const keyedSelected = (0,external_wp_data_namespaceObject.useSelect)(select => formatTypes.reduce((accumulator, type) => { 46550 if (type.__experimentalGetPropsForEditableTreePreparation) { 46551 accumulator[type.name] = type.__experimentalGetPropsForEditableTreePreparation(select, { 46552 richTextIdentifier: identifier, 46553 blockClientId: clientId 46554 }); 46555 } 46556 46557 return accumulator; 46558 }, {}), [formatTypes, clientId, identifier]); 46559 const dispatch = (0,external_wp_data_namespaceObject.useDispatch)(); 46560 const prepareHandlers = []; 46561 const valueHandlers = []; 46562 const changeHandlers = []; 46563 const dependencies = []; 46564 formatTypes.forEach(type => { 46565 if (type.__experimentalCreatePrepareEditableTree) { 46566 const selected = keyedSelected[type.name]; 46567 46568 const handler = type.__experimentalCreatePrepareEditableTree(selected, { 46569 richTextIdentifier: identifier, 46570 blockClientId: clientId 46571 }); 46572 46573 if (type.__experimentalCreateOnChangeEditableValue) { 46574 valueHandlers.push(handler); 46575 } else { 46576 prepareHandlers.push(handler); 46577 } 46578 46579 for (const key in selected) { 46580 dependencies.push(selected[key]); 46581 } 46582 } 46583 46584 if (type.__experimentalCreateOnChangeEditableValue) { 46585 let dispatchers = {}; 46586 46587 if (type.__experimentalGetPropsForEditableTreeChangeHandler) { 46588 dispatchers = type.__experimentalGetPropsForEditableTreeChangeHandler(dispatch, { 46589 richTextIdentifier: identifier, 46590 blockClientId: clientId 46591 }); 46592 } 46593 46594 changeHandlers.push(type.__experimentalCreateOnChangeEditableValue({ ...(keyedSelected[type.name] || {}), 46595 ...dispatchers 46596 }, { 46597 richTextIdentifier: identifier, 46598 blockClientId: clientId 46599 })); 46600 } 46601 }); 46602 return { 46603 formatTypes, 46604 prepareHandlers, 46605 valueHandlers, 46606 changeHandlers, 46607 dependencies 46608 }; 46609 } 46610 46611 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-remove-browser-shortcuts.js 46612 /** 46613 * WordPress dependencies 46614 */ 46615 46616 46617 /** 46618 * Hook to prevent default behaviors for key combinations otherwise handled 46619 * internally by RichText. 46620 * 46621 * @return {import('react').RefObject} The component to be rendered. 46622 */ 46623 46624 function useRemoveBrowserShortcuts() { 46625 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 46626 function onKeydown(event) { 46627 if (external_wp_keycodes_namespaceObject.isKeyboardEvent.primary(event, 'z') || external_wp_keycodes_namespaceObject.isKeyboardEvent.primary(event, 'y') || external_wp_keycodes_namespaceObject.isKeyboardEvent.primaryShift(event, 'z')) { 46628 event.preventDefault(); 46629 } 46630 } 46631 46632 node.addEventListener('keydown', onKeydown); 46633 return () => { 46634 node.addEventListener('keydown', onKeydown); 46635 }; 46636 }, []); 46637 } 46638 46639 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-shortcuts.js 46640 /** 46641 * WordPress dependencies 46642 */ 46643 46644 function useShortcuts(keyboardShortcuts) { 46645 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => { 46646 function onKeyDown(event) { 46647 for (const keyboardShortcut of keyboardShortcuts.current) { 46648 keyboardShortcut(event); 46649 } 46650 } 46651 46652 element.addEventListener('keydown', onKeyDown); 46653 return () => { 46654 element.removeEventListener('keydown', onKeyDown); 46655 }; 46656 }, []); 46657 } 46658 46659 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-input-events.js 46660 /** 46661 * WordPress dependencies 46662 */ 46663 46664 function useInputEvents(inputEvents) { 46665 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => { 46666 function onInput(event) { 46667 for (const keyboardShortcut of inputEvents.current) { 46668 keyboardShortcut(event); 46669 } 46670 } 46671 46672 element.addEventListener('input', onInput); 46673 return () => { 46674 element.removeEventListener('input', onInput); 46675 }; 46676 }, []); 46677 } 46678 46679 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-firefox-compat.js 46680 /** 46681 * WordPress dependencies 46682 */ 46683 46684 46685 /** 46686 * Internal dependencies 46687 */ 46688 46689 46690 function useFirefoxCompat() { 46691 const { 46692 isMultiSelecting 46693 } = (0,external_wp_data_namespaceObject.useSelect)(store); 46694 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => { 46695 function onFocus() { 46696 if (!isMultiSelecting()) { 46697 return; 46698 } // This is a little hack to work around focus issues with nested 46699 // editable elements in Firefox. For some reason the editable child 46700 // element sometimes regains focus, while it should not be focusable 46701 // and focus should remain on the editable parent element. 46702 // To do: try to find the cause of the shifting focus. 46703 46704 46705 const parentEditable = element.parentElement.closest('[contenteditable="true"]'); 46706 46707 if (parentEditable) { 46708 parentEditable.focus(); 46709 } 46710 } 46711 46712 element.addEventListener('focus', onFocus); 46713 return () => { 46714 element.removeEventListener('focus', onFocus); 46715 }; 46716 }, []); 46717 } 46718 46719 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-edit.js 46720 46721 46722 /** 46723 * WordPress dependencies 46724 */ 46725 46726 /** 46727 * External dependencies 46728 */ 46729 46730 46731 function FormatEdit(_ref) { 46732 let { 46733 formatTypes, 46734 onChange, 46735 onFocus, 46736 value, 46737 forwardedRef 46738 } = _ref; 46739 return formatTypes.map(settings => { 46740 const { 46741 name, 46742 edit: Edit 46743 } = settings; 46744 46745 if (!Edit) { 46746 return null; 46747 } 46748 46749 const activeFormat = (0,external_wp_richText_namespaceObject.getActiveFormat)(value, name); 46750 let isActive = activeFormat !== undefined; 46751 const activeObject = (0,external_wp_richText_namespaceObject.getActiveObject)(value); 46752 const isObjectActive = activeObject !== undefined && activeObject.type === name; // Edge case: un-collapsed link formats. 46753 // If there is a missing link format at either end of the selection 46754 // then we shouldn't show the Edit UI because the selection has exceeded 46755 // the bounds of the link format. 46756 // Also if the format objects don't match then we're dealing with two separate 46757 // links so we should not allow the link to be modified over the top. 46758 46759 if (name === 'core/link' && !(0,external_wp_richText_namespaceObject.isCollapsed)(value)) { 46760 const formats = value.formats; 46761 const linkFormatAtStart = (0,external_lodash_namespaceObject.find)(formats[value.start], { 46762 type: 'core/link' 46763 }); 46764 const linkFormatAtEnd = (0,external_lodash_namespaceObject.find)(formats[value.end - 1], { 46765 type: 'core/link' 46766 }); 46767 46768 if (!linkFormatAtStart || !linkFormatAtEnd || linkFormatAtStart !== linkFormatAtEnd) { 46769 isActive = false; 46770 } 46771 } 46772 46773 return (0,external_wp_element_namespaceObject.createElement)(Edit, { 46774 key: name, 46775 isActive: isActive, 46776 activeAttributes: isActive ? activeFormat.attributes || {} : {}, 46777 isObjectActive: isObjectActive, 46778 activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {}, 46779 value: value, 46780 onChange: onChange, 46781 onFocus: onFocus, 46782 contentRef: forwardedRef 46783 }); 46784 }); 46785 } 46786 46787 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/index.js 46788 46789 46790 46791 /** 46792 * External dependencies 46793 */ 46794 46795 46796 /** 46797 * WordPress dependencies 46798 */ 46799 46800 46801 46802 46803 46804 46805 46806 46807 46808 /** 46809 * Internal dependencies 46810 */ 46811 46812 46813 46814 46815 46816 46817 46818 46819 46820 46821 46822 46823 46824 46825 46826 46827 46828 46829 const keyboardShortcutContext = (0,external_wp_element_namespaceObject.createContext)(); 46830 const inputEventContext = (0,external_wp_element_namespaceObject.createContext)(); 46831 /** 46832 * Removes props used for the native version of RichText so that they are not 46833 * passed to the DOM element and log warnings. 46834 * 46835 * @param {Object} props Props to filter. 46836 * 46837 * @return {Object} Filtered props. 46838 */ 46839 46840 function removeNativeProps(props) { 46841 return (0,external_lodash_namespaceObject.omit)(props, ['__unstableMobileNoFocusOnMount', 'deleteEnter', 'placeholderTextColor', 'textAlign', 'selectionColor', 'tagsToEliminate', 'rootTagsToEliminate', 'disableEditingMenu', 'fontSize', 'fontFamily', 'fontWeight', 'fontStyle', 'minWidth', 'maxWidth', 'setRef']); 46842 } 46843 46844 function RichTextWrapper(_ref, forwardedRef) { 46845 let { 46846 children, 46847 tagName = 'div', 46848 value: originalValue = '', 46849 onChange: originalOnChange, 46850 isSelected: originalIsSelected, 46851 multiline, 46852 inlineToolbar, 46853 wrapperClassName, 46854 autocompleters, 46855 onReplace, 46856 placeholder, 46857 allowedFormats, 46858 formattingControls, 46859 withoutInteractiveFormatting, 46860 onRemove, 46861 onMerge, 46862 onSplit, 46863 __unstableOnSplitAtEnd: onSplitAtEnd, 46864 __unstableOnSplitMiddle: onSplitMiddle, 46865 identifier, 46866 preserveWhiteSpace, 46867 __unstablePastePlainText: pastePlainText, 46868 __unstableEmbedURLOnPaste, 46869 __unstableDisableFormats: disableFormats, 46870 disableLineBreaks, 46871 unstableOnFocus, 46872 __unstableAllowPrefixTransformations, 46873 ...props 46874 } = _ref; 46875 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(RichTextWrapper); 46876 identifier = identifier || instanceId; 46877 props = removeNativeProps(props); 46878 const anchorRef = (0,external_wp_element_namespaceObject.useRef)(); 46879 const { 46880 clientId 46881 } = useBlockEditContext(); 46882 46883 const selector = select => { 46884 const { 46885 getSelectionStart, 46886 getSelectionEnd 46887 } = select(store); 46888 const selectionStart = getSelectionStart(); 46889 const selectionEnd = getSelectionEnd(); 46890 let isSelected; 46891 46892 if (originalIsSelected === undefined) { 46893 isSelected = selectionStart.clientId === clientId && selectionEnd.clientId === clientId && selectionStart.attributeKey === identifier; 46894 } else if (originalIsSelected) { 46895 isSelected = selectionStart.clientId === clientId; 46896 } 46897 46898 return { 46899 selectionStart: isSelected ? selectionStart.offset : undefined, 46900 selectionEnd: isSelected ? selectionEnd.offset : undefined, 46901 isSelected 46902 }; 46903 }; // This selector must run on every render so the right selection state is 46904 // retreived from the store on merge. 46905 // To do: fix this somehow. 46906 46907 46908 const { 46909 selectionStart, 46910 selectionEnd, 46911 isSelected 46912 } = (0,external_wp_data_namespaceObject.useSelect)(selector); 46913 const { 46914 selectionChange 46915 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 46916 const multilineTag = getMultilineTag(multiline); 46917 const adjustedAllowedFormats = getAllowedFormats({ 46918 allowedFormats, 46919 formattingControls, 46920 disableFormats 46921 }); 46922 const hasFormats = !adjustedAllowedFormats || adjustedAllowedFormats.length > 0; 46923 let adjustedValue = originalValue; 46924 let adjustedOnChange = originalOnChange; // Handle deprecated format. 46925 46926 if (Array.isArray(originalValue)) { 46927 adjustedValue = external_wp_blocks_namespaceObject.children.toHTML(originalValue); 46928 46929 adjustedOnChange = newValue => originalOnChange(external_wp_blocks_namespaceObject.children.fromDOM((0,external_wp_richText_namespaceObject.__unstableCreateElement)(document, newValue).childNodes)); 46930 } 46931 46932 const onSelectionChange = (0,external_wp_element_namespaceObject.useCallback)((start, end) => { 46933 const selection = {}; 46934 const unset = start === undefined && end === undefined; 46935 46936 if (typeof start === 'number' || unset) { 46937 selection.start = { 46938 clientId, 46939 attributeKey: identifier, 46940 offset: start 46941 }; 46942 } 46943 46944 if (typeof end === 'number' || unset) { 46945 selection.end = { 46946 clientId, 46947 attributeKey: identifier, 46948 offset: end 46949 }; 46950 } 46951 46952 selectionChange(selection); 46953 }, [clientId, identifier]); 46954 const { 46955 formatTypes, 46956 prepareHandlers, 46957 valueHandlers, 46958 changeHandlers, 46959 dependencies 46960 } = useFormatTypes({ 46961 clientId, 46962 identifier, 46963 withoutInteractiveFormatting, 46964 allowedFormats: adjustedAllowedFormats 46965 }); 46966 46967 function addEditorOnlyFormats(value) { 46968 return valueHandlers.reduce((accumulator, fn) => fn(accumulator, value.text), value.formats); 46969 } 46970 46971 function removeEditorOnlyFormats(value) { 46972 formatTypes.forEach(formatType => { 46973 // Remove formats created by prepareEditableTree, because they are editor only. 46974 if (formatType.__experimentalCreatePrepareEditableTree) { 46975 value = (0,external_wp_richText_namespaceObject.removeFormat)(value, formatType.name, 0, value.text.length); 46976 } 46977 }); 46978 return value.formats; 46979 } 46980 46981 function addInvisibleFormats(value) { 46982 return prepareHandlers.reduce((accumulator, fn) => fn(accumulator, value.text), value.formats); 46983 } 46984 46985 const { 46986 value, 46987 onChange, 46988 ref: richTextRef 46989 } = (0,external_wp_richText_namespaceObject.__unstableUseRichText)({ 46990 value: adjustedValue, 46991 46992 onChange(html, _ref2) { 46993 let { 46994 __unstableFormats, 46995 __unstableText 46996 } = _ref2; 46997 adjustedOnChange(html); 46998 Object.values(changeHandlers).forEach(changeHandler => { 46999 changeHandler(__unstableFormats, __unstableText); 47000 }); 47001 }, 47002 47003 selectionStart, 47004 selectionEnd, 47005 onSelectionChange, 47006 placeholder, 47007 __unstableIsSelected: isSelected, 47008 __unstableMultilineTag: multilineTag, 47009 __unstableDisableFormats: disableFormats, 47010 preserveWhiteSpace, 47011 __unstableDependencies: [...dependencies, tagName], 47012 __unstableAfterParse: addEditorOnlyFormats, 47013 __unstableBeforeSerialize: removeEditorOnlyFormats, 47014 __unstableAddInvisibleFormats: addInvisibleFormats 47015 }); 47016 const autocompleteProps = useBlockEditorAutocompleteProps({ 47017 onReplace, 47018 completers: autocompleters, 47019 record: value, 47020 onChange 47021 }); 47022 useCaretInFormat({ 47023 value 47024 }); 47025 useMarkPersistent({ 47026 html: adjustedValue, 47027 value 47028 }); 47029 const keyboardShortcuts = (0,external_wp_element_namespaceObject.useRef)(new Set()); 47030 const inputEvents = (0,external_wp_element_namespaceObject.useRef)(new Set()); 47031 47032 function onKeyDown(event) { 47033 const { 47034 keyCode 47035 } = event; 47036 47037 if (event.defaultPrevented) { 47038 return; 47039 } 47040 47041 if (keyCode === external_wp_keycodes_namespaceObject.DELETE || keyCode === external_wp_keycodes_namespaceObject.BACKSPACE) { 47042 const { 47043 start, 47044 end, 47045 text 47046 } = value; 47047 const isReverse = keyCode === external_wp_keycodes_namespaceObject.BACKSPACE; 47048 const hasActiveFormats = value.activeFormats && !!value.activeFormats.length; // Only process delete if the key press occurs at an uncollapsed edge. 47049 47050 if (!(0,external_wp_richText_namespaceObject.isCollapsed)(value) || hasActiveFormats || isReverse && start !== 0 || !isReverse && end !== text.length) { 47051 return; 47052 } 47053 47054 if (onMerge) { 47055 onMerge(!isReverse); 47056 } // Only handle remove on Backspace. This serves dual-purpose of being 47057 // an intentional user interaction distinguishing between Backspace and 47058 // Delete to remove the empty field, but also to avoid merge & remove 47059 // causing destruction of two fields (merge, then removed merged). 47060 47061 47062 if (onRemove && (0,external_wp_richText_namespaceObject.isEmpty)(value) && isReverse) { 47063 onRemove(!isReverse); 47064 } 47065 47066 event.preventDefault(); 47067 } 47068 } 47069 47070 function onFocus() { 47071 anchorRef.current.focus(); 47072 } 47073 47074 const TagName = tagName; 47075 const content = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isSelected && (0,external_wp_element_namespaceObject.createElement)(keyboardShortcutContext.Provider, { 47076 value: keyboardShortcuts 47077 }, (0,external_wp_element_namespaceObject.createElement)(inputEventContext.Provider, { 47078 value: inputEvents 47079 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.__unstableSlotNameProvider, { 47080 value: "__unstable-block-tools-after" 47081 }, children && children({ 47082 value, 47083 onChange, 47084 onFocus 47085 }), (0,external_wp_element_namespaceObject.createElement)(FormatEdit, { 47086 value: value, 47087 onChange: onChange, 47088 onFocus: onFocus, 47089 formatTypes: formatTypes, 47090 forwardedRef: anchorRef 47091 })))), isSelected && hasFormats && (0,external_wp_element_namespaceObject.createElement)(format_toolbar_container, { 47092 inline: inlineToolbar, 47093 anchorRef: anchorRef.current 47094 }), (0,external_wp_element_namespaceObject.createElement)(TagName // Overridable props. 47095 , _extends({ 47096 role: "textbox", 47097 "aria-multiline": !disableLineBreaks, 47098 "aria-label": placeholder 47099 }, props, autocompleteProps, { 47100 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([forwardedRef, autocompleteProps.ref, props.ref, richTextRef, useInputRules({ 47101 value, 47102 onChange, 47103 __unstableAllowPrefixTransformations, 47104 formatTypes, 47105 onReplace, 47106 selectionChange 47107 }), useRemoveBrowserShortcuts(), useShortcuts(keyboardShortcuts), useInputEvents(inputEvents), useUndoAutomaticChange(), usePasteHandler({ 47108 isSelected, 47109 disableFormats, 47110 onChange, 47111 value, 47112 formatTypes, 47113 tagName, 47114 onReplace, 47115 onSplit, 47116 onSplitMiddle, 47117 __unstableEmbedURLOnPaste, 47118 multilineTag, 47119 preserveWhiteSpace, 47120 pastePlainText 47121 }), useEnter({ 47122 removeEditorOnlyFormats, 47123 value, 47124 onReplace, 47125 onSplit, 47126 onSplitMiddle, 47127 multilineTag, 47128 onChange, 47129 disableLineBreaks, 47130 onSplitAtEnd 47131 }), useFirefoxCompat(), anchorRef]), 47132 contentEditable: true, 47133 suppressContentEditableWarning: true, 47134 className: classnames_default()('block-editor-rich-text__editable', props.className, 'rich-text'), 47135 onFocus: unstableOnFocus, 47136 onKeyDown: onKeyDown 47137 }))); 47138 47139 if (!wrapperClassName) { 47140 return content; 47141 } 47142 47143 external_wp_deprecated_default()('wp.blockEditor.RichText wrapperClassName prop', { 47144 since: '5.4', 47145 alternative: 'className prop or create your own wrapper div', 47146 version: '6.2' 47147 }); 47148 const className = classnames_default()('block-editor-rich-text', wrapperClassName); 47149 return (0,external_wp_element_namespaceObject.createElement)("div", { 47150 className: className 47151 }, content); 47152 } 47153 47154 const ForwardedRichTextContainer = (0,external_wp_element_namespaceObject.forwardRef)(RichTextWrapper); 47155 47156 ForwardedRichTextContainer.Content = _ref3 => { 47157 let { 47158 value, 47159 tagName: Tag, 47160 multiline, 47161 ...props 47162 } = _ref3; 47163 47164 // Handle deprecated `children` and `node` sources. 47165 if (Array.isArray(value)) { 47166 value = external_wp_blocks_namespaceObject.children.toHTML(value); 47167 } 47168 47169 const MultilineTag = getMultilineTag(multiline); 47170 47171 if (!value && MultilineTag) { 47172 value = `<$MultilineTag}></$MultilineTag}>`; 47173 } 47174 47175 const content = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, value); 47176 47177 if (Tag) { 47178 return (0,external_wp_element_namespaceObject.createElement)(Tag, (0,external_lodash_namespaceObject.omit)(props, ['format']), content); 47179 } 47180 47181 return content; 47182 }; 47183 47184 ForwardedRichTextContainer.isEmpty = value => { 47185 return !value || value.length === 0; 47186 }; 47187 /** 47188 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md 47189 */ 47190 47191 47192 /* harmony default export */ var rich_text = (ForwardedRichTextContainer); 47193 47194 47195 47196 47197 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/editable-text/index.js 47198 47199 47200 47201 /** 47202 * WordPress dependencies 47203 */ 47204 47205 /** 47206 * Internal dependencies 47207 */ 47208 47209 47210 const EditableText = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => { 47211 return (0,external_wp_element_namespaceObject.createElement)(rich_text, _extends({ 47212 ref: ref 47213 }, props, { 47214 __unstableDisableFormats: true, 47215 preserveWhiteSpace: true 47216 })); 47217 }); 47218 47219 EditableText.Content = _ref => { 47220 let { 47221 value = '', 47222 tagName: Tag = 'div', 47223 ...props 47224 } = _ref; 47225 return (0,external_wp_element_namespaceObject.createElement)(Tag, props, value); 47226 }; 47227 /** 47228 * Renders an editable text input in which text formatting is not allowed. 47229 */ 47230 47231 47232 /* harmony default export */ var editable_text = (EditableText); 47233 47234 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/plain-text/index.js 47235 47236 47237 47238 /** 47239 * External dependencies 47240 */ 47241 47242 47243 /** 47244 * WordPress dependencies 47245 */ 47246 47247 47248 /** 47249 * Internal dependencies 47250 */ 47251 47252 47253 /** 47254 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/plain-text/README.md 47255 */ 47256 47257 const PlainText = (0,external_wp_element_namespaceObject.forwardRef)((_ref, ref) => { 47258 let { 47259 __experimentalVersion, 47260 ...props 47261 } = _ref; 47262 47263 if (__experimentalVersion === 2) { 47264 return (0,external_wp_element_namespaceObject.createElement)(editable_text, _extends({ 47265 ref: ref 47266 }, props)); 47267 } 47268 47269 const { 47270 className, 47271 onChange, 47272 ...remainingProps 47273 } = props; 47274 return (0,external_wp_element_namespaceObject.createElement)(lib/* default */.Z, _extends({ 47275 ref: ref, 47276 className: classnames_default()('block-editor-plain-text', className), 47277 onChange: event => onChange(event.target.value) 47278 }, remainingProps)); 47279 }); 47280 /* harmony default export */ var plain_text = (PlainText); 47281 47282 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/responsive-block-control/label.js 47283 47284 47285 /** 47286 * WordPress dependencies 47287 */ 47288 47289 47290 47291 47292 function ResponsiveBlockControlLabel(_ref) { 47293 let { 47294 property, 47295 viewport, 47296 desc 47297 } = _ref; 47298 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(ResponsiveBlockControlLabel); 47299 const accessibleLabel = desc || (0,external_wp_i18n_namespaceObject.sprintf)( 47300 /* translators: 1: property name. 2: viewport name. */ 47301 (0,external_wp_i18n_namespaceObject._x)('Controls the %1$s property for %2$s viewports.', 'Text labelling a interface as controlling a given layout property (eg: margin) for a given screen size.'), property, viewport.label); 47302 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("span", { 47303 "aria-describedby": `rbc-desc-$instanceId}` 47304 }, viewport.label), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 47305 as: "span", 47306 id: `rbc-desc-$instanceId}` 47307 }, accessibleLabel)); 47308 } 47309 47310 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/responsive-block-control/index.js 47311 47312 47313 /** 47314 * External dependencies 47315 */ 47316 47317 /** 47318 * WordPress dependencies 47319 */ 47320 47321 47322 47323 47324 /** 47325 * Internal dependencies 47326 */ 47327 47328 47329 47330 function ResponsiveBlockControl(props) { 47331 const { 47332 title, 47333 property, 47334 toggleLabel, 47335 onIsResponsiveChange, 47336 renderDefaultControl, 47337 renderResponsiveControls, 47338 isResponsive = false, 47339 defaultLabel = { 47340 id: 'all', 47341 47342 /* translators: 'Label. Used to signify a layout property (eg: margin, padding) will apply uniformly to all screensizes.' */ 47343 label: (0,external_wp_i18n_namespaceObject.__)('All') 47344 }, 47345 viewports = [{ 47346 id: 'small', 47347 label: (0,external_wp_i18n_namespaceObject.__)('Small screens') 47348 }, { 47349 id: 'medium', 47350 label: (0,external_wp_i18n_namespaceObject.__)('Medium screens') 47351 }, { 47352 id: 'large', 47353 label: (0,external_wp_i18n_namespaceObject.__)('Large screens') 47354 }] 47355 } = props; 47356 47357 if (!title || !property || !renderDefaultControl) { 47358 return null; 47359 } 47360 47361 const toggleControlLabel = toggleLabel || (0,external_wp_i18n_namespaceObject.sprintf)( 47362 /* translators: 'Toggle control label. Should the property be the same across all screen sizes or unique per screen size.'. %s property value for the control (eg: margin, padding...etc) */ 47363 (0,external_wp_i18n_namespaceObject.__)('Use the same %s on all screensizes.'), property); 47364 /* translators: 'Help text for the responsive mode toggle control.' */ 47365 47366 const toggleHelpText = (0,external_wp_i18n_namespaceObject.__)('Toggle between using the same value for all screen sizes or using a unique value per screen size.'); 47367 47368 const defaultControl = renderDefaultControl((0,external_wp_element_namespaceObject.createElement)(ResponsiveBlockControlLabel, { 47369 property: property, 47370 viewport: defaultLabel 47371 }), defaultLabel); 47372 47373 const defaultResponsiveControls = () => { 47374 return viewports.map(viewport => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, { 47375 key: viewport.id 47376 }, renderDefaultControl((0,external_wp_element_namespaceObject.createElement)(ResponsiveBlockControlLabel, { 47377 property: property, 47378 viewport: viewport 47379 }), viewport))); 47380 }; 47381 47382 return (0,external_wp_element_namespaceObject.createElement)("fieldset", { 47383 className: "block-editor-responsive-block-control" 47384 }, (0,external_wp_element_namespaceObject.createElement)("legend", { 47385 className: "block-editor-responsive-block-control__title" 47386 }, title), (0,external_wp_element_namespaceObject.createElement)("div", { 47387 className: "block-editor-responsive-block-control__inner" 47388 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, { 47389 className: "block-editor-responsive-block-control__toggle", 47390 label: toggleControlLabel, 47391 checked: !isResponsive, 47392 onChange: onIsResponsiveChange, 47393 help: toggleHelpText 47394 }), (0,external_wp_element_namespaceObject.createElement)("div", { 47395 className: classnames_default()('block-editor-responsive-block-control__group', { 47396 'is-responsive': isResponsive 47397 }) 47398 }, !isResponsive && defaultControl, isResponsive && (renderResponsiveControls ? renderResponsiveControls(viewports) : defaultResponsiveControls())))); 47399 } 47400 47401 /* harmony default export */ var responsive_block_control = (ResponsiveBlockControl); 47402 47403 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/shortcut.js 47404 /** 47405 * WordPress dependencies 47406 */ 47407 47408 47409 /** 47410 * Internal dependencies 47411 */ 47412 47413 47414 function RichTextShortcut(_ref) { 47415 let { 47416 character, 47417 type, 47418 onUse 47419 } = _ref; 47420 const keyboardShortcuts = (0,external_wp_element_namespaceObject.useContext)(keyboardShortcutContext); 47421 const onUseRef = (0,external_wp_element_namespaceObject.useRef)(); 47422 onUseRef.current = onUse; 47423 (0,external_wp_element_namespaceObject.useEffect)(() => { 47424 function callback(event) { 47425 if (external_wp_keycodes_namespaceObject.isKeyboardEvent[type](event, character)) { 47426 onUseRef.current(); 47427 event.preventDefault(); 47428 } 47429 } 47430 47431 keyboardShortcuts.current.add(callback); 47432 return () => { 47433 keyboardShortcuts.current.delete(callback); 47434 }; 47435 }, [character, type]); 47436 return null; 47437 } 47438 47439 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/toolbar-button.js 47440 47441 47442 47443 /** 47444 * WordPress dependencies 47445 */ 47446 47447 47448 function RichTextToolbarButton(_ref) { 47449 let { 47450 name, 47451 shortcutType, 47452 shortcutCharacter, 47453 ...props 47454 } = _ref; 47455 let shortcut; 47456 let fillName = 'RichText.ToolbarControls'; 47457 47458 if (name) { 47459 fillName += `.$name}`; 47460 } 47461 47462 if (shortcutType && shortcutCharacter) { 47463 shortcut = external_wp_keycodes_namespaceObject.displayShortcut[shortcutType](shortcutCharacter); 47464 } 47465 47466 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, { 47467 name: fillName 47468 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, _extends({}, props, { 47469 shortcut: shortcut 47470 }))); 47471 } 47472 47473 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/input-event.js 47474 /** 47475 * WordPress dependencies 47476 */ 47477 47478 /** 47479 * Internal dependencies 47480 */ 47481 47482 47483 function __unstableRichTextInputEvent(_ref) { 47484 let { 47485 inputType, 47486 onInput 47487 } = _ref; 47488 const callbacks = (0,external_wp_element_namespaceObject.useContext)(inputEventContext); 47489 const onInputRef = (0,external_wp_element_namespaceObject.useRef)(); 47490 onInputRef.current = onInput; 47491 (0,external_wp_element_namespaceObject.useEffect)(() => { 47492 function callback(event) { 47493 if (event.inputType === inputType) { 47494 onInputRef.current(); 47495 event.preventDefault(); 47496 } 47497 } 47498 47499 callbacks.current.add(callback); 47500 return () => { 47501 callbacks.current.delete(callback); 47502 }; 47503 }, [inputType]); 47504 return null; 47505 } 47506 47507 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/tool-selector/index.js 47508 47509 47510 47511 /** 47512 * WordPress dependencies 47513 */ 47514 47515 47516 47517 47518 47519 /** 47520 * Internal dependencies 47521 */ 47522 47523 47524 const selectIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, { 47525 xmlns: "http://www.w3.org/2000/svg", 47526 width: "24", 47527 height: "24", 47528 viewBox: "0 0 24 24" 47529 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, { 47530 d: "M9.4 20.5L5.2 3.8l14.6 9-2 .3c-.2 0-.4.1-.7.1-.9.2-1.6.3-2.2.5-.8.3-1.4.5-1.8.8-.4.3-.8.8-1.3 1.5-.4.5-.8 1.2-1.2 2l-.3.6-.9 1.9zM7.6 7.1l2.4 9.3c.2-.4.5-.8.7-1.1.6-.8 1.1-1.4 1.6-1.8.5-.4 1.3-.8 2.2-1.1l1.2-.3-8.1-5z" 47531 })); 47532 47533 function ToolSelector(props, ref) { 47534 const isNavigationTool = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isNavigationMode(), []); 47535 const { 47536 setNavigationMode 47537 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 47538 47539 const onSwitchMode = mode => { 47540 setNavigationMode(mode === 'edit' ? false : true); 47541 }; 47542 47543 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, { 47544 renderToggle: _ref => { 47545 let { 47546 isOpen, 47547 onToggle 47548 } = _ref; 47549 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, { 47550 ref: ref, 47551 icon: isNavigationTool ? selectIcon : library_edit, 47552 "aria-expanded": isOpen, 47553 "aria-haspopup": "true", 47554 onClick: onToggle 47555 /* translators: button label text should, if possible, be under 16 characters. */ 47556 , 47557 label: (0,external_wp_i18n_namespaceObject.__)('Tools') 47558 })); 47559 }, 47560 position: "bottom right", 47561 renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, { 47562 role: "menu", 47563 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Tools') 47564 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, { 47565 value: isNavigationTool ? 'select' : 'edit', 47566 onSelect: onSwitchMode, 47567 choices: [{ 47568 value: 'edit', 47569 label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { 47570 icon: library_edit 47571 }), (0,external_wp_i18n_namespaceObject.__)('Edit')) 47572 }, { 47573 value: 'select', 47574 label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, selectIcon, (0,external_wp_i18n_namespaceObject.__)('Select')) 47575 }] 47576 })), (0,external_wp_element_namespaceObject.createElement)("div", { 47577 className: "block-editor-tool-selector__help" 47578 }, (0,external_wp_i18n_namespaceObject.__)('Tools provide different interactions for selecting, navigating, and editing blocks. Toggle between select and edit by pressing Escape and Enter.'))) 47579 }); 47580 } 47581 47582 /* harmony default export */ var tool_selector = ((0,external_wp_element_namespaceObject.forwardRef)(ToolSelector)); 47583 47584 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/unit-control/index.js 47585 47586 47587 47588 /** 47589 * WordPress dependencies 47590 */ 47591 47592 /** 47593 * Internal dependencies 47594 */ 47595 47596 47597 function UnitControl(_ref) { 47598 let { 47599 units: unitsProp, 47600 ...props 47601 } = _ref; 47602 const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({ 47603 availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw'], 47604 units: unitsProp 47605 }); 47606 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, _extends({ 47607 units: units 47608 }, props)); 47609 } 47610 47611 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/arrow-left.js 47612 47613 47614 /** 47615 * WordPress dependencies 47616 */ 47617 47618 const arrowLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 47619 xmlns: "http://www.w3.org/2000/svg", 47620 viewBox: "0 0 24 24" 47621 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 47622 d: "M20 10.8H6.7l4.1-4.5-1.1-1.1-5.8 6.3 5.8 5.8 1.1-1.1-4-3.9H20z" 47623 })); 47624 /* harmony default export */ var arrow_left = (arrowLeft); 47625 47626 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-input/button.js 47627 47628 47629 /** 47630 * WordPress dependencies 47631 */ 47632 47633 47634 47635 47636 /** 47637 * Internal dependencies 47638 */ 47639 47640 47641 47642 class URLInputButton extends external_wp_element_namespaceObject.Component { 47643 constructor() { 47644 super(...arguments); 47645 this.toggle = this.toggle.bind(this); 47646 this.submitLink = this.submitLink.bind(this); 47647 this.state = { 47648 expanded: false 47649 }; 47650 } 47651 47652 toggle() { 47653 this.setState({ 47654 expanded: !this.state.expanded 47655 }); 47656 } 47657 47658 submitLink(event) { 47659 event.preventDefault(); 47660 this.toggle(); 47661 } 47662 47663 render() { 47664 const { 47665 url, 47666 onChange 47667 } = this.props; 47668 const { 47669 expanded 47670 } = this.state; 47671 const buttonLabel = url ? (0,external_wp_i18n_namespaceObject.__)('Edit link') : (0,external_wp_i18n_namespaceObject.__)('Insert link'); 47672 return (0,external_wp_element_namespaceObject.createElement)("div", { 47673 className: "block-editor-url-input__button" 47674 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 47675 icon: library_link, 47676 label: buttonLabel, 47677 onClick: this.toggle, 47678 className: "components-toolbar__control", 47679 isPressed: !!url 47680 }), expanded && (0,external_wp_element_namespaceObject.createElement)("form", { 47681 className: "block-editor-url-input__button-modal", 47682 onSubmit: this.submitLink 47683 }, (0,external_wp_element_namespaceObject.createElement)("div", { 47684 className: "block-editor-url-input__button-modal-line" 47685 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 47686 className: "block-editor-url-input__back", 47687 icon: arrow_left, 47688 label: (0,external_wp_i18n_namespaceObject.__)('Close'), 47689 onClick: this.toggle 47690 }), (0,external_wp_element_namespaceObject.createElement)(url_input, { 47691 value: url || '', 47692 onChange: onChange 47693 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 47694 icon: keyboard_return, 47695 label: (0,external_wp_i18n_namespaceObject.__)('Submit'), 47696 type: "submit" 47697 })))); 47698 } 47699 47700 } 47701 /** 47702 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md 47703 */ 47704 47705 47706 /* harmony default export */ var url_input_button = (URLInputButton); 47707 47708 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close.js 47709 47710 47711 /** 47712 * WordPress dependencies 47713 */ 47714 47715 const close_close = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 47716 xmlns: "http://www.w3.org/2000/svg", 47717 viewBox: "0 0 24 24" 47718 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 47719 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" 47720 })); 47721 /* harmony default export */ var library_close = (close_close); 47722 47723 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/image-url-input-ui.js 47724 47725 47726 /** 47727 * External dependencies 47728 */ 47729 47730 /** 47731 * WordPress dependencies 47732 */ 47733 47734 47735 47736 47737 47738 /** 47739 * Internal dependencies 47740 */ 47741 47742 47743 const LINK_DESTINATION_NONE = 'none'; 47744 const LINK_DESTINATION_CUSTOM = 'custom'; 47745 const LINK_DESTINATION_MEDIA = 'media'; 47746 const LINK_DESTINATION_ATTACHMENT = 'attachment'; 47747 const NEW_TAB_REL = ['noreferrer', 'noopener']; 47748 const icon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, { 47749 viewBox: "0 0 24 24", 47750 xmlns: "http://www.w3.org/2000/svg" 47751 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, { 47752 d: "M0,0h24v24H0V0z", 47753 fill: "none" 47754 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, { 47755 d: "m19 5v14h-14v-14h14m0-2h-14c-1.1 0-2 0.9-2 2v14c0 1.1 0.9 2 2 2h14c1.1 0 2-0.9 2-2v-14c0-1.1-0.9-2-2-2z" 47756 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, { 47757 d: "m14.14 11.86l-3 3.87-2.14-2.59-3 3.86h12l-3.86-5.14z" 47758 })); 47759 47760 const ImageURLInputUI = _ref => { 47761 let { 47762 linkDestination, 47763 onChangeUrl, 47764 url, 47765 mediaType = 'image', 47766 mediaUrl, 47767 mediaLink, 47768 linkTarget, 47769 linkClass, 47770 rel 47771 } = _ref; 47772 const [isOpen, setIsOpen] = (0,external_wp_element_namespaceObject.useState)(false); 47773 const openLinkUI = (0,external_wp_element_namespaceObject.useCallback)(() => { 47774 setIsOpen(true); 47775 }); 47776 const [isEditingLink, setIsEditingLink] = (0,external_wp_element_namespaceObject.useState)(false); 47777 const [urlInput, setUrlInput] = (0,external_wp_element_namespaceObject.useState)(null); 47778 const autocompleteRef = (0,external_wp_element_namespaceObject.useRef)(null); 47779 const startEditLink = (0,external_wp_element_namespaceObject.useCallback)(() => { 47780 if (linkDestination === LINK_DESTINATION_MEDIA || linkDestination === LINK_DESTINATION_ATTACHMENT) { 47781 setUrlInput(''); 47782 } 47783 47784 setIsEditingLink(true); 47785 }); 47786 const stopEditLink = (0,external_wp_element_namespaceObject.useCallback)(() => { 47787 setIsEditingLink(false); 47788 }); 47789 const closeLinkUI = (0,external_wp_element_namespaceObject.useCallback)(() => { 47790 setUrlInput(null); 47791 stopEditLink(); 47792 setIsOpen(false); 47793 }); 47794 47795 const getUpdatedLinkTargetSettings = value => { 47796 const newLinkTarget = value ? '_blank' : undefined; 47797 let updatedRel; 47798 47799 if (newLinkTarget) { 47800 const rels = (rel !== null && rel !== void 0 ? rel : '').split(' '); 47801 NEW_TAB_REL.forEach(relVal => { 47802 if (!rels.includes(relVal)) { 47803 rels.push(relVal); 47804 } 47805 }); 47806 updatedRel = rels.join(' '); 47807 } else { 47808 const rels = (rel !== null && rel !== void 0 ? rel : '').split(' ').filter(relVal => NEW_TAB_REL.includes(relVal) === false); 47809 updatedRel = rels.length ? rels.join(' ') : undefined; 47810 } 47811 47812 return { 47813 linkTarget: newLinkTarget, 47814 rel: updatedRel 47815 }; 47816 }; 47817 47818 const onFocusOutside = (0,external_wp_element_namespaceObject.useCallback)(() => { 47819 return event => { 47820 // The autocomplete suggestions list renders in a separate popover (in a portal), 47821 // so onFocusOutside fails to detect that a click on a suggestion occurred in the 47822 // LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and 47823 // return to avoid the popover being closed. 47824 const autocompleteElement = autocompleteRef.current; 47825 47826 if (autocompleteElement && autocompleteElement.contains(event.target)) { 47827 return; 47828 } 47829 47830 setIsOpen(false); 47831 setUrlInput(null); 47832 stopEditLink(); 47833 }; 47834 }); 47835 const onSubmitLinkChange = (0,external_wp_element_namespaceObject.useCallback)(() => { 47836 return event => { 47837 if (urlInput) { 47838 var _getLinkDestinations$; 47839 47840 // It is possible the entered URL actually matches a named link destination. 47841 // This check will ensure our link destination is correct. 47842 const selectedDestination = ((_getLinkDestinations$ = getLinkDestinations().find(destination => destination.url === urlInput)) === null || _getLinkDestinations$ === void 0 ? void 0 : _getLinkDestinations$.linkDestination) || LINK_DESTINATION_CUSTOM; 47843 onChangeUrl({ 47844 href: urlInput, 47845 linkDestination: selectedDestination 47846 }); 47847 } 47848 47849 stopEditLink(); 47850 setUrlInput(null); 47851 event.preventDefault(); 47852 }; 47853 }); 47854 const onLinkRemove = (0,external_wp_element_namespaceObject.useCallback)(() => { 47855 onChangeUrl({ 47856 linkDestination: LINK_DESTINATION_NONE, 47857 href: '' 47858 }); 47859 }); 47860 47861 const getLinkDestinations = () => { 47862 const linkDestinations = [{ 47863 linkDestination: LINK_DESTINATION_MEDIA, 47864 title: (0,external_wp_i18n_namespaceObject.__)('Media File'), 47865 url: mediaType === 'image' ? mediaUrl : undefined, 47866 icon 47867 }]; 47868 47869 if (mediaType === 'image' && mediaLink) { 47870 linkDestinations.push({ 47871 linkDestination: LINK_DESTINATION_ATTACHMENT, 47872 title: (0,external_wp_i18n_namespaceObject.__)('Attachment Page'), 47873 url: mediaType === 'image' ? mediaLink : undefined, 47874 icon: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, { 47875 viewBox: "0 0 24 24", 47876 xmlns: "http://www.w3.org/2000/svg" 47877 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, { 47878 d: "M0 0h24v24H0V0z", 47879 fill: "none" 47880 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, { 47881 d: "M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z" 47882 })) 47883 }); 47884 } 47885 47886 return linkDestinations; 47887 }; 47888 47889 const onSetHref = value => { 47890 const linkDestinations = getLinkDestinations(); 47891 let linkDestinationInput; 47892 47893 if (!value) { 47894 linkDestinationInput = LINK_DESTINATION_NONE; 47895 } else { 47896 linkDestinationInput = ((0,external_lodash_namespaceObject.find)(linkDestinations, destination => { 47897 return destination.url === value; 47898 }) || { 47899 linkDestination: LINK_DESTINATION_CUSTOM 47900 }).linkDestination; 47901 } 47902 47903 onChangeUrl({ 47904 linkDestination: linkDestinationInput, 47905 href: value 47906 }); 47907 }; 47908 47909 const onSetNewTab = value => { 47910 const updatedLinkTarget = getUpdatedLinkTargetSettings(value); 47911 onChangeUrl(updatedLinkTarget); 47912 }; 47913 47914 const onSetLinkRel = value => { 47915 onChangeUrl({ 47916 rel: value 47917 }); 47918 }; 47919 47920 const onSetLinkClass = value => { 47921 onChangeUrl({ 47922 linkClass: value 47923 }); 47924 }; 47925 47926 const advancedOptions = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, { 47927 label: (0,external_wp_i18n_namespaceObject.__)('Open in new tab'), 47928 onChange: onSetNewTab, 47929 checked: linkTarget === '_blank' 47930 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { 47931 label: (0,external_wp_i18n_namespaceObject.__)('Link Rel'), 47932 value: rel !== null && rel !== void 0 ? rel : '', 47933 onChange: onSetLinkRel 47934 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { 47935 label: (0,external_wp_i18n_namespaceObject.__)('Link CSS Class'), 47936 value: linkClass || '', 47937 onChange: onSetLinkClass 47938 })); 47939 const linkEditorValue = urlInput !== null ? urlInput : url; 47940 const urlLabel = ((0,external_lodash_namespaceObject.find)(getLinkDestinations(), ['linkDestination', linkDestination]) || {}).title; 47941 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 47942 icon: library_link, 47943 className: "components-toolbar__control", 47944 label: url ? (0,external_wp_i18n_namespaceObject.__)('Edit link') : (0,external_wp_i18n_namespaceObject.__)('Insert link'), 47945 "aria-expanded": isOpen, 47946 onClick: openLinkUI 47947 }), isOpen && (0,external_wp_element_namespaceObject.createElement)(url_popover, { 47948 onFocusOutside: onFocusOutside(), 47949 onClose: closeLinkUI, 47950 renderSettings: () => advancedOptions, 47951 additionalControls: !linkEditorValue && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, null, (0,external_lodash_namespaceObject.map)(getLinkDestinations(), link => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 47952 key: link.linkDestination, 47953 icon: link.icon, 47954 onClick: () => { 47955 setUrlInput(null); 47956 onSetHref(link.url); 47957 stopEditLink(); 47958 } 47959 }, link.title))) 47960 }, (!url || isEditingLink) && (0,external_wp_element_namespaceObject.createElement)(url_popover.LinkEditor, { 47961 className: "block-editor-format-toolbar__link-container-content", 47962 value: linkEditorValue, 47963 onChangeInputValue: setUrlInput, 47964 onSubmit: onSubmitLinkChange(), 47965 autocompleteRef: autocompleteRef 47966 }), url && !isEditingLink && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(url_popover.LinkViewer, { 47967 className: "block-editor-format-toolbar__link-container-content", 47968 url: url, 47969 onEditLinkClick: startEditLink, 47970 urlLabel: urlLabel 47971 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 47972 icon: library_close, 47973 label: (0,external_wp_i18n_namespaceObject.__)('Remove link'), 47974 onClick: onLinkRemove 47975 })))); 47976 }; 47977 47978 47979 47980 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/preview-options/index.js 47981 47982 47983 /** 47984 * External dependencies 47985 */ 47986 47987 /** 47988 * WordPress dependencies 47989 */ 47990 47991 47992 47993 47994 47995 function PreviewOptions(_ref) { 47996 let { 47997 children, 47998 className, 47999 isEnabled = true, 48000 deviceType, 48001 setDeviceType 48002 } = _ref; 48003 const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<'); 48004 if (isMobile) return null; 48005 const popoverProps = { 48006 className: classnames_default()(className, 'block-editor-post-preview__dropdown-content'), 48007 position: 'bottom left' 48008 }; 48009 const toggleProps = { 48010 variant: 'tertiary', 48011 className: 'block-editor-post-preview__button-toggle', 48012 disabled: !isEnabled, 48013 48014 /* translators: button label text should, if possible, be under 16 characters. */ 48015 children: (0,external_wp_i18n_namespaceObject.__)('Preview') 48016 }; 48017 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 48018 className: "block-editor-post-preview__dropdown", 48019 popoverProps: popoverProps, 48020 toggleProps: toggleProps, 48021 icon: null 48022 }, () => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 48023 className: "block-editor-post-preview__button-resize", 48024 onClick: () => setDeviceType('Desktop'), 48025 icon: deviceType === 'Desktop' && library_check 48026 }, (0,external_wp_i18n_namespaceObject.__)('Desktop')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 48027 className: "block-editor-post-preview__button-resize", 48028 onClick: () => setDeviceType('Tablet'), 48029 icon: deviceType === 'Tablet' && library_check 48030 }, (0,external_wp_i18n_namespaceObject.__)('Tablet')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 48031 className: "block-editor-post-preview__button-resize", 48032 onClick: () => setDeviceType('Mobile'), 48033 icon: deviceType === 'Mobile' && library_check 48034 }, (0,external_wp_i18n_namespaceObject.__)('Mobile'))), children)); 48035 } 48036 48037 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-resize-canvas/index.js 48038 /** 48039 * WordPress dependencies 48040 */ 48041 48042 /** 48043 * Function to resize the editor window. 48044 * 48045 * @param {string} deviceType Used for determining the size of the container (e.g. Desktop, Tablet, Mobile) 48046 * 48047 * @return {Object} Inline styles to be added to resizable container. 48048 */ 48049 48050 function useResizeCanvas(deviceType) { 48051 const [actualWidth, updateActualWidth] = (0,external_wp_element_namespaceObject.useState)(window.innerWidth); 48052 (0,external_wp_element_namespaceObject.useEffect)(() => { 48053 if (deviceType === 'Desktop') { 48054 return; 48055 } 48056 48057 const resizeListener = () => updateActualWidth(window.innerWidth); 48058 48059 window.addEventListener('resize', resizeListener); 48060 return () => { 48061 window.removeEventListener('resize', resizeListener); 48062 }; 48063 }, [deviceType]); 48064 48065 const getCanvasWidth = device => { 48066 let deviceWidth; 48067 48068 switch (device) { 48069 case 'Tablet': 48070 deviceWidth = 780; 48071 break; 48072 48073 case 'Mobile': 48074 deviceWidth = 360; 48075 break; 48076 48077 default: 48078 return null; 48079 } 48080 48081 return deviceWidth < actualWidth ? deviceWidth : actualWidth; 48082 }; 48083 48084 const marginValue = () => window.innerHeight < 800 ? 36 : 72; 48085 48086 const contentInlineStyles = device => { 48087 const height = device === 'Mobile' ? '768px' : '1024px'; 48088 48089 switch (device) { 48090 case 'Tablet': 48091 case 'Mobile': 48092 return { 48093 width: getCanvasWidth(device), 48094 margin: marginValue() + 'px auto', 48095 height, 48096 borderRadius: '2px 2px 2px 2px', 48097 border: '1px solid #ddd', 48098 overflowY: 'auto' 48099 }; 48100 48101 default: 48102 return null; 48103 } 48104 }; 48105 48106 return contentInlineStyles(deviceType); 48107 } 48108 48109 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/skip-to-selected-block/index.js 48110 48111 48112 /** 48113 * WordPress dependencies 48114 */ 48115 48116 48117 48118 /** 48119 * Internal dependencies 48120 */ 48121 48122 48123 48124 48125 const SkipToSelectedBlock = _ref => { 48126 let { 48127 selectedBlockClientId 48128 } = _ref; 48129 const ref = useBlockRef(selectedBlockClientId); 48130 48131 const onClick = () => { 48132 ref.current.focus(); 48133 }; 48134 48135 return selectedBlockClientId ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 48136 variant: "secondary", 48137 className: "block-editor-skip-to-selected-block", 48138 onClick: onClick 48139 }, (0,external_wp_i18n_namespaceObject.__)('Skip to the selected block')) : null; 48140 }; 48141 /** 48142 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/skip-to-selected-block/README.md 48143 */ 48144 48145 48146 /* harmony default export */ var skip_to_selected_block = ((0,external_wp_data_namespaceObject.withSelect)(select => { 48147 return { 48148 selectedBlockClientId: select(store).getBlockSelectionStart() 48149 }; 48150 })(SkipToSelectedBlock)); 48151 48152 ;// CONCATENATED MODULE: external ["wp","wordcount"] 48153 var external_wp_wordcount_namespaceObject = window["wp"]["wordcount"]; 48154 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/multi-selection-inspector/index.js 48155 48156 48157 /** 48158 * WordPress dependencies 48159 */ 48160 48161 48162 48163 48164 48165 /** 48166 * Internal dependencies 48167 */ 48168 48169 48170 48171 48172 function MultiSelectionInspector(_ref) { 48173 let { 48174 blocks 48175 } = _ref; 48176 const words = (0,external_wp_wordcount_namespaceObject.count)((0,external_wp_blocks_namespaceObject.serialize)(blocks), 'words'); 48177 return (0,external_wp_element_namespaceObject.createElement)("div", { 48178 className: "block-editor-multi-selection-inspector__card" 48179 }, (0,external_wp_element_namespaceObject.createElement)(block_icon, { 48180 icon: library_copy, 48181 showColors: true 48182 }), (0,external_wp_element_namespaceObject.createElement)("div", { 48183 className: "block-editor-multi-selection-inspector__card-content" 48184 }, (0,external_wp_element_namespaceObject.createElement)("div", { 48185 className: "block-editor-multi-selection-inspector__card-title" 48186 }, (0,external_wp_i18n_namespaceObject.sprintf)( 48187 /* translators: %d: number of blocks */ 48188 (0,external_wp_i18n_namespaceObject._n)('%d block', '%d blocks', blocks.length), blocks.length)), (0,external_wp_element_namespaceObject.createElement)("div", { 48189 className: "block-editor-multi-selection-inspector__card-description" 48190 }, (0,external_wp_i18n_namespaceObject.sprintf)( 48191 /* translators: %d: number of words */ 48192 (0,external_wp_i18n_namespaceObject._n)('%d word', '%d words', words), words)))); 48193 } 48194 48195 /* harmony default export */ var multi_selection_inspector = ((0,external_wp_data_namespaceObject.withSelect)(select => { 48196 const { 48197 getMultiSelectedBlocks 48198 } = select(store); 48199 return { 48200 blocks: getMultiSelectedBlocks() 48201 }; 48202 })(MultiSelectionInspector)); 48203 48204 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/default-style-picker/index.js 48205 48206 48207 /** 48208 * WordPress dependencies 48209 */ 48210 48211 48212 48213 48214 48215 /** 48216 * Internal dependencies 48217 */ 48218 48219 48220 48221 function DefaultStylePicker(_ref) { 48222 let { 48223 blockName 48224 } = _ref; 48225 const { 48226 preferredStyle, 48227 onUpdatePreferredStyleVariations, 48228 styles 48229 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 48230 var _preferredStyleVariat, _preferredStyleVariat2; 48231 48232 const settings = select(store).getSettings(); 48233 const preferredStyleVariations = settings.__experimentalPreferredStyleVariations; 48234 return { 48235 preferredStyle: preferredStyleVariations === null || preferredStyleVariations === void 0 ? void 0 : (_preferredStyleVariat = preferredStyleVariations.value) === null || _preferredStyleVariat === void 0 ? void 0 : _preferredStyleVariat[blockName], 48236 onUpdatePreferredStyleVariations: (_preferredStyleVariat2 = preferredStyleVariations === null || preferredStyleVariations === void 0 ? void 0 : preferredStyleVariations.onChange) !== null && _preferredStyleVariat2 !== void 0 ? _preferredStyleVariat2 : null, 48237 styles: select(external_wp_blocks_namespaceObject.store).getBlockStyles(blockName) 48238 }; 48239 }, [blockName]); 48240 const selectOptions = (0,external_wp_element_namespaceObject.useMemo)(() => [{ 48241 label: (0,external_wp_i18n_namespaceObject.__)('Not set'), 48242 value: '' 48243 }, ...styles.map(_ref2 => { 48244 let { 48245 label, 48246 name 48247 } = _ref2; 48248 return { 48249 label, 48250 value: name 48251 }; 48252 })], [styles]); 48253 const defaultStyleName = (0,external_wp_element_namespaceObject.useMemo)(() => { 48254 var _getDefaultStyle; 48255 48256 return (_getDefaultStyle = getDefaultStyle(styles)) === null || _getDefaultStyle === void 0 ? void 0 : _getDefaultStyle.name; 48257 }, [styles]); 48258 const selectOnChange = (0,external_wp_element_namespaceObject.useCallback)(blockStyle => { 48259 onUpdatePreferredStyleVariations(blockName, blockStyle); 48260 }, [blockName, onUpdatePreferredStyleVariations]); // Until the functionality is migrated to global styles, 48261 // only show the default style picker if a non-default style has already been selected. 48262 48263 if (!preferredStyle || preferredStyle === defaultStyleName) { 48264 return null; 48265 } 48266 48267 return onUpdatePreferredStyleVariations && (0,external_wp_element_namespaceObject.createElement)("div", { 48268 className: "default-style-picker__default-switcher" 48269 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, { 48270 options: selectOptions, 48271 value: preferredStyle || '', 48272 label: (0,external_wp_i18n_namespaceObject.__)('Default Style'), 48273 onChange: selectOnChange 48274 })); 48275 } 48276 48277 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-inspector/index.js 48278 48279 48280 /** 48281 * WordPress dependencies 48282 */ 48283 48284 48285 48286 48287 /** 48288 * Internal dependencies 48289 */ 48290 48291 48292 48293 48294 48295 48296 48297 48298 48299 48300 48301 const BlockInspector = _ref => { 48302 let { 48303 showNoBlockSelectedMessage = true 48304 } = _ref; 48305 const { 48306 count, 48307 hasBlockStyles, 48308 selectedBlockName, 48309 selectedBlockClientId, 48310 blockType 48311 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 48312 const { 48313 getSelectedBlockClientId, 48314 getSelectedBlockCount, 48315 getBlockName 48316 } = select(store); 48317 const { 48318 getBlockStyles 48319 } = select(external_wp_blocks_namespaceObject.store); 48320 48321 const _selectedBlockClientId = getSelectedBlockClientId(); 48322 48323 const _selectedBlockName = _selectedBlockClientId && getBlockName(_selectedBlockClientId); 48324 48325 const _blockType = _selectedBlockName && (0,external_wp_blocks_namespaceObject.getBlockType)(_selectedBlockName); 48326 48327 const blockStyles = _selectedBlockName && getBlockStyles(_selectedBlockName); 48328 48329 return { 48330 count: getSelectedBlockCount(), 48331 selectedBlockClientId: _selectedBlockClientId, 48332 selectedBlockName: _selectedBlockName, 48333 blockType: _blockType, 48334 hasBlockStyles: blockStyles && blockStyles.length > 0 48335 }; 48336 }, []); 48337 48338 if (count > 1) { 48339 return (0,external_wp_element_namespaceObject.createElement)("div", { 48340 className: "block-editor-block-inspector" 48341 }, (0,external_wp_element_namespaceObject.createElement)(multi_selection_inspector, null), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, null), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, { 48342 __experimentalGroup: "color", 48343 label: (0,external_wp_i18n_namespaceObject.__)('Color'), 48344 className: "color-block-support-panel__inner-wrapper" 48345 }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, { 48346 __experimentalGroup: "typography", 48347 label: (0,external_wp_i18n_namespaceObject.__)('Typography') 48348 }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, { 48349 __experimentalGroup: "dimensions", 48350 label: (0,external_wp_i18n_namespaceObject.__)('Dimensions') 48351 }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, { 48352 __experimentalGroup: "border", 48353 label: (0,external_wp_i18n_namespaceObject.__)('Border') 48354 })); 48355 } 48356 48357 const isSelectedBlockUnregistered = selectedBlockName === (0,external_wp_blocks_namespaceObject.getUnregisteredTypeHandlerName)(); 48358 /* 48359 * If the selected block is of an unregistered type, avoid showing it as an actual selection 48360 * because we want the user to focus on the unregistered block warning, not block settings. 48361 */ 48362 48363 if (!blockType || !selectedBlockClientId || isSelectedBlockUnregistered) { 48364 if (showNoBlockSelectedMessage) { 48365 return (0,external_wp_element_namespaceObject.createElement)("span", { 48366 className: "block-editor-block-inspector__no-blocks" 48367 }, (0,external_wp_i18n_namespaceObject.__)('No block selected.')); 48368 } 48369 48370 return null; 48371 } 48372 48373 return (0,external_wp_element_namespaceObject.createElement)(BlockInspectorSingleBlock, { 48374 clientId: selectedBlockClientId, 48375 blockName: blockType.name, 48376 hasBlockStyles: hasBlockStyles 48377 }); 48378 }; 48379 48380 const BlockInspectorSingleBlock = _ref2 => { 48381 let { 48382 clientId, 48383 blockName, 48384 hasBlockStyles 48385 } = _ref2; 48386 const blockInformation = useBlockDisplayInformation(clientId); 48387 return (0,external_wp_element_namespaceObject.createElement)("div", { 48388 className: "block-editor-block-inspector" 48389 }, (0,external_wp_element_namespaceObject.createElement)(block_card, blockInformation), (0,external_wp_element_namespaceObject.createElement)(block_variation_transforms, { 48390 blockClientId: clientId 48391 }), hasBlockStyles && (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, { 48392 title: (0,external_wp_i18n_namespaceObject.__)('Styles') 48393 }, (0,external_wp_element_namespaceObject.createElement)(block_styles, { 48394 scope: "core/block-inspector", 48395 clientId: clientId 48396 }), (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, 'defaultStylePicker', true) && (0,external_wp_element_namespaceObject.createElement)(DefaultStylePicker, { 48397 blockName: blockName 48398 }))), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, null), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, { 48399 __experimentalGroup: "color", 48400 label: (0,external_wp_i18n_namespaceObject.__)('Color'), 48401 className: "color-block-support-panel__inner-wrapper" 48402 }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, { 48403 __experimentalGroup: "typography", 48404 label: (0,external_wp_i18n_namespaceObject.__)('Typography') 48405 }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, { 48406 __experimentalGroup: "dimensions", 48407 label: (0,external_wp_i18n_namespaceObject.__)('Dimensions') 48408 }), (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, { 48409 __experimentalGroup: "border", 48410 label: (0,external_wp_i18n_namespaceObject.__)('Border') 48411 }), (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_element_namespaceObject.createElement)(AdvancedControls, null)), (0,external_wp_element_namespaceObject.createElement)(skip_to_selected_block, { 48412 key: "back" 48413 })); 48414 }; 48415 48416 const AdvancedControls = () => { 48417 const slot = (0,external_wp_components_namespaceObject.__experimentalUseSlot)(InspectorAdvancedControls.slotName); 48418 const hasFills = Boolean(slot.fills && slot.fills.length); 48419 48420 if (!hasFills) { 48421 return null; 48422 } 48423 48424 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, { 48425 className: "block-editor-block-inspector__advanced", 48426 title: (0,external_wp_i18n_namespaceObject.__)('Advanced'), 48427 initialOpen: false 48428 }, (0,external_wp_element_namespaceObject.createElement)(inspector_controls.Slot, { 48429 __experimentalGroup: "advanced" 48430 })); 48431 }; 48432 /** 48433 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-inspector/README.md 48434 */ 48435 48436 48437 /* harmony default export */ var block_inspector = (BlockInspector); 48438 48439 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/index.js 48440 48441 48442 48443 /** 48444 * External dependencies 48445 */ 48446 48447 /** 48448 * WordPress dependencies 48449 */ 48450 48451 48452 48453 48454 48455 /** 48456 * Internal dependencies 48457 */ 48458 48459 48460 48461 48462 48463 48464 /** 48465 * Renders block tools (the block toolbar, select/navigation mode toolbar, the 48466 * insertion point and a slot for the inline rich text toolbar). Must be wrapped 48467 * around the block content and editor styles wrapper or iframe. 48468 * 48469 * @param {Object} $0 Props. 48470 * @param {Object} $0.children The block content and style container. 48471 * @param {Object} $0.__unstableContentRef Ref holding the content scroll container. 48472 */ 48473 48474 function BlockTools(_ref) { 48475 let { 48476 children, 48477 __unstableContentRef, 48478 ...props 48479 } = _ref; 48480 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); 48481 const hasFixedToolbar = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings().hasFixedToolbar, []); 48482 const isMatch = (0,external_wp_keyboardShortcuts_namespaceObject.__unstableUseShortcutEventMatch)(); 48483 const { 48484 getSelectedBlockClientIds, 48485 getBlockRootClientId 48486 } = (0,external_wp_data_namespaceObject.useSelect)(store); 48487 const { 48488 duplicateBlocks, 48489 removeBlocks, 48490 insertAfterBlock, 48491 insertBeforeBlock, 48492 clearSelectedBlock, 48493 moveBlocksUp, 48494 moveBlocksDown 48495 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 48496 48497 function onKeyDown(event) { 48498 if (isMatch('core/block-editor/move-up', event)) { 48499 const clientIds = getSelectedBlockClientIds(); 48500 48501 if (clientIds.length) { 48502 event.preventDefault(); 48503 const rootClientId = getBlockRootClientId((0,external_lodash_namespaceObject.first)(clientIds)); 48504 moveBlocksUp(clientIds, rootClientId); 48505 } 48506 } else if (isMatch('core/block-editor/move-down', event)) { 48507 const clientIds = getSelectedBlockClientIds(); 48508 48509 if (clientIds.length) { 48510 event.preventDefault(); 48511 const rootClientId = getBlockRootClientId((0,external_lodash_namespaceObject.first)(clientIds)); 48512 moveBlocksDown(clientIds, rootClientId); 48513 } 48514 } else if (isMatch('core/block-editor/duplicate', event)) { 48515 const clientIds = getSelectedBlockClientIds(); 48516 48517 if (clientIds.length) { 48518 event.preventDefault(); 48519 duplicateBlocks(clientIds); 48520 } 48521 } else if (isMatch('core/block-editor/remove', event)) { 48522 const clientIds = getSelectedBlockClientIds(); 48523 48524 if (clientIds.length) { 48525 event.preventDefault(); 48526 removeBlocks(clientIds); 48527 } 48528 } else if (isMatch('core/block-editor/insert-after', event)) { 48529 const clientIds = getSelectedBlockClientIds(); 48530 48531 if (clientIds.length) { 48532 event.preventDefault(); 48533 insertAfterBlock((0,external_lodash_namespaceObject.last)(clientIds)); 48534 } 48535 } else if (isMatch('core/block-editor/insert-before', event)) { 48536 const clientIds = getSelectedBlockClientIds(); 48537 48538 if (clientIds.length) { 48539 event.preventDefault(); 48540 insertBeforeBlock((0,external_lodash_namespaceObject.first)(clientIds)); 48541 } 48542 } else if (isMatch('core/block-editor/unselect', event)) { 48543 const clientIds = getSelectedBlockClientIds(); 48544 48545 if (clientIds.length > 1) { 48546 event.preventDefault(); 48547 clearSelectedBlock(); 48548 event.target.ownerDocument.defaultView.getSelection().removeAllRanges(); 48549 } 48550 } 48551 } 48552 48553 return (// eslint-disable-next-line jsx-a11y/no-static-element-interactions 48554 (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, props, { 48555 onKeyDown: onKeyDown 48556 }), (0,external_wp_element_namespaceObject.createElement)(InsertionPoint, { 48557 __unstableContentRef: __unstableContentRef 48558 }, (hasFixedToolbar || !isLargeViewport) && (0,external_wp_element_namespaceObject.createElement)(block_contextual_toolbar, { 48559 isFixed: true 48560 }), (0,external_wp_element_namespaceObject.createElement)(WrappedBlockPopover, { 48561 __unstableContentRef: __unstableContentRef 48562 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, { 48563 name: "block-toolbar", 48564 ref: usePopoverScroll(__unstableContentRef) 48565 }), children, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, { 48566 name: "__unstable-block-tools-after", 48567 ref: usePopoverScroll(__unstableContentRef) 48568 }))) 48569 ); 48570 } 48571 48572 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/library.js 48573 48574 48575 /** 48576 * External dependencies 48577 */ 48578 48579 /** 48580 * WordPress dependencies 48581 */ 48582 48583 48584 48585 /** 48586 * Internal dependencies 48587 */ 48588 48589 48590 48591 48592 function InserterLibrary(_ref, ref) { 48593 let { 48594 rootClientId, 48595 clientId, 48596 isAppender, 48597 showInserterHelpPanel, 48598 showMostUsedBlocks = false, 48599 __experimentalInsertionIndex, 48600 __experimentalFilterValue, 48601 onSelect = external_lodash_namespaceObject.noop, 48602 shouldFocusBlock = false 48603 } = _ref; 48604 const destinationRootClientId = (0,external_wp_data_namespaceObject.useSelect)(select => { 48605 const { 48606 getBlockRootClientId 48607 } = select(store); 48608 return rootClientId || getBlockRootClientId(clientId) || undefined; 48609 }, [clientId, rootClientId]); 48610 return (0,external_wp_element_namespaceObject.createElement)(menu, { 48611 onSelect: onSelect, 48612 rootClientId: destinationRootClientId, 48613 clientId: clientId, 48614 isAppender: isAppender, 48615 showInserterHelpPanel: showInserterHelpPanel, 48616 showMostUsedBlocks: showMostUsedBlocks, 48617 __experimentalInsertionIndex: __experimentalInsertionIndex, 48618 __experimentalFilterValue: __experimentalFilterValue, 48619 shouldFocusBlock: shouldFocusBlock, 48620 ref: ref 48621 }); 48622 } 48623 48624 /* harmony default export */ var library = ((0,external_wp_element_namespaceObject.forwardRef)(InserterLibrary)); 48625 48626 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/keyboard-shortcuts/index.js 48627 /** 48628 * WordPress dependencies 48629 */ 48630 48631 48632 48633 48634 48635 function KeyboardShortcuts() { 48636 return null; 48637 } 48638 48639 function KeyboardShortcutsRegister() { 48640 // Registering the shortcuts. 48641 const { 48642 registerShortcut 48643 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store); 48644 (0,external_wp_element_namespaceObject.useEffect)(() => { 48645 registerShortcut({ 48646 name: 'core/block-editor/duplicate', 48647 category: 'block', 48648 description: (0,external_wp_i18n_namespaceObject.__)('Duplicate the selected block(s).'), 48649 keyCombination: { 48650 modifier: 'primaryShift', 48651 character: 'd' 48652 } 48653 }); 48654 registerShortcut({ 48655 name: 'core/block-editor/remove', 48656 category: 'block', 48657 description: (0,external_wp_i18n_namespaceObject.__)('Remove the selected block(s).'), 48658 keyCombination: { 48659 modifier: 'access', 48660 character: 'z' 48661 } 48662 }); 48663 registerShortcut({ 48664 name: 'core/block-editor/insert-before', 48665 category: 'block', 48666 description: (0,external_wp_i18n_namespaceObject.__)('Insert a new block before the selected block(s).'), 48667 keyCombination: { 48668 modifier: 'primaryAlt', 48669 character: 't' 48670 } 48671 }); 48672 registerShortcut({ 48673 name: 'core/block-editor/insert-after', 48674 category: 'block', 48675 description: (0,external_wp_i18n_namespaceObject.__)('Insert a new block after the selected block(s).'), 48676 keyCombination: { 48677 modifier: 'primaryAlt', 48678 character: 'y' 48679 } 48680 }); 48681 registerShortcut({ 48682 name: 'core/block-editor/delete-multi-selection', 48683 category: 'block', 48684 description: (0,external_wp_i18n_namespaceObject.__)('Delete selection.'), 48685 keyCombination: { 48686 character: 'del' 48687 }, 48688 aliases: [{ 48689 character: 'backspace' 48690 }] 48691 }); 48692 registerShortcut({ 48693 name: 'core/block-editor/select-all', 48694 category: 'selection', 48695 description: (0,external_wp_i18n_namespaceObject.__)('Select all text when typing. Press again to select all blocks.'), 48696 keyCombination: { 48697 modifier: 'primary', 48698 character: 'a' 48699 } 48700 }); 48701 registerShortcut({ 48702 name: 'core/block-editor/unselect', 48703 category: 'selection', 48704 description: (0,external_wp_i18n_namespaceObject.__)('Clear selection.'), 48705 keyCombination: { 48706 character: 'escape' 48707 } 48708 }); 48709 registerShortcut({ 48710 name: 'core/block-editor/focus-toolbar', 48711 category: 'global', 48712 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the nearest toolbar.'), 48713 keyCombination: { 48714 modifier: 'alt', 48715 character: 'F10' 48716 } 48717 }); 48718 registerShortcut({ 48719 name: 'core/block-editor/move-up', 48720 category: 'block', 48721 description: (0,external_wp_i18n_namespaceObject.__)('Move the selected block(s) up.'), 48722 keyCombination: { 48723 modifier: 'secondary', 48724 character: 't' 48725 } 48726 }); 48727 registerShortcut({ 48728 name: 'core/block-editor/move-down', 48729 category: 'block', 48730 description: (0,external_wp_i18n_namespaceObject.__)('Move the selected block(s) down.'), 48731 keyCombination: { 48732 modifier: 'secondary', 48733 character: 'y' 48734 } 48735 }); 48736 }, [registerShortcut]); 48737 return null; 48738 } 48739 48740 KeyboardShortcuts.Register = KeyboardShortcutsRegister; 48741 /* harmony default export */ var keyboard_shortcuts = (KeyboardShortcuts); 48742 48743 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/selection-scroll-into-view/index.js 48744 /** 48745 * WordPress dependencies 48746 */ 48747 48748 /** 48749 * Scrolls the multi block selection end into view if not in view already. This 48750 * is important to do after selection by keyboard. 48751 * 48752 * @deprecated 48753 */ 48754 48755 function MultiSelectScrollIntoView() { 48756 external_wp_deprecated_default()('wp.blockEditor.MultiSelectScrollIntoView', { 48757 hint: 'This behaviour is now built-in.', 48758 since: '5.8' 48759 }); 48760 return null; 48761 } 48762 48763 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/observe-typing/index.js 48764 48765 48766 /** 48767 * WordPress dependencies 48768 */ 48769 48770 48771 48772 48773 /** 48774 * Internal dependencies 48775 */ 48776 48777 48778 /** 48779 * Set of key codes upon which typing is to be initiated on a keydown event. 48780 * 48781 * @type {Set<number>} 48782 */ 48783 48784 const KEY_DOWN_ELIGIBLE_KEY_CODES = new Set([external_wp_keycodes_namespaceObject.UP, external_wp_keycodes_namespaceObject.RIGHT, external_wp_keycodes_namespaceObject.DOWN, external_wp_keycodes_namespaceObject.LEFT, external_wp_keycodes_namespaceObject.ENTER, external_wp_keycodes_namespaceObject.BACKSPACE]); 48785 /** 48786 * Returns true if a given keydown event can be inferred as intent to start 48787 * typing, or false otherwise. A keydown is considered eligible if it is a 48788 * text navigation without shift active. 48789 * 48790 * @param {KeyboardEvent} event Keydown event to test. 48791 * 48792 * @return {boolean} Whether event is eligible to start typing. 48793 */ 48794 48795 function isKeyDownEligibleForStartTyping(event) { 48796 const { 48797 keyCode, 48798 shiftKey 48799 } = event; 48800 return !shiftKey && KEY_DOWN_ELIGIBLE_KEY_CODES.has(keyCode); 48801 } 48802 /** 48803 * Removes the `isTyping` flag when the mouse moves in the document of the given 48804 * element. 48805 */ 48806 48807 48808 function useMouseMoveTypingReset() { 48809 const isTyping = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isTyping(), []); 48810 const { 48811 stopTyping 48812 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 48813 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 48814 if (!isTyping) { 48815 return; 48816 } 48817 48818 const { 48819 ownerDocument 48820 } = node; 48821 let lastClientX; 48822 let lastClientY; 48823 /** 48824 * On mouse move, unset typing flag if user has moved cursor. 48825 * 48826 * @param {MouseEvent} event Mousemove event. 48827 */ 48828 48829 function stopTypingOnMouseMove(event) { 48830 const { 48831 clientX, 48832 clientY 48833 } = event; // We need to check that the mouse really moved because Safari 48834 // triggers mousemove events when shift or ctrl are pressed. 48835 48836 if (lastClientX && lastClientY && (lastClientX !== clientX || lastClientY !== clientY)) { 48837 stopTyping(); 48838 } 48839 48840 lastClientX = clientX; 48841 lastClientY = clientY; 48842 } 48843 48844 ownerDocument.addEventListener('mousemove', stopTypingOnMouseMove); 48845 return () => { 48846 ownerDocument.removeEventListener('mousemove', stopTypingOnMouseMove); 48847 }; 48848 }, [isTyping, stopTyping]); 48849 } 48850 /** 48851 * Sets and removes the `isTyping` flag based on user actions: 48852 * 48853 * - Sets the flag if the user types within the given element. 48854 * - Removes the flag when the user selects some text, focusses a non-text 48855 * field, presses ESC or TAB, or moves the mouse in the document. 48856 */ 48857 48858 function useTypingObserver() { 48859 const isTyping = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isTyping()); 48860 const { 48861 startTyping, 48862 stopTyping 48863 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 48864 const ref1 = useMouseMoveTypingReset(); 48865 const ref2 = (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 48866 const { 48867 ownerDocument 48868 } = node; 48869 const { 48870 defaultView 48871 } = ownerDocument; // Listeners to stop typing should only be added when typing. 48872 // Listeners to start typing should only be added when not typing. 48873 48874 if (isTyping) { 48875 let timerId; 48876 /** 48877 * Stops typing when focus transitions to a non-text field element. 48878 * 48879 * @param {FocusEvent} event Focus event. 48880 */ 48881 48882 function stopTypingOnNonTextField(event) { 48883 const { 48884 target 48885 } = event; // Since focus to a non-text field via arrow key will trigger 48886 // before the keydown event, wait until after current stack 48887 // before evaluating whether typing is to be stopped. Otherwise, 48888 // typing will re-start. 48889 48890 timerId = defaultView.setTimeout(() => { 48891 if (!(0,external_wp_dom_namespaceObject.isTextField)(target)) { 48892 stopTyping(); 48893 } 48894 }); 48895 } 48896 /** 48897 * Unsets typing flag if user presses Escape while typing flag is 48898 * active. 48899 * 48900 * @param {KeyboardEvent} event Keypress or keydown event to 48901 * interpret. 48902 */ 48903 48904 48905 function stopTypingOnEscapeKey(event) { 48906 const { 48907 keyCode 48908 } = event; 48909 48910 if (keyCode === external_wp_keycodes_namespaceObject.ESCAPE || keyCode === external_wp_keycodes_namespaceObject.TAB) { 48911 stopTyping(); 48912 } 48913 } 48914 /** 48915 * On selection change, unset typing flag if user has made an 48916 * uncollapsed (shift) selection. 48917 */ 48918 48919 48920 function stopTypingOnSelectionUncollapse() { 48921 const selection = defaultView.getSelection(); 48922 const isCollapsed = selection.rangeCount > 0 && selection.getRangeAt(0).collapsed; 48923 48924 if (!isCollapsed) { 48925 stopTyping(); 48926 } 48927 } 48928 48929 node.addEventListener('focus', stopTypingOnNonTextField); 48930 node.addEventListener('keydown', stopTypingOnEscapeKey); 48931 ownerDocument.addEventListener('selectionchange', stopTypingOnSelectionUncollapse); 48932 return () => { 48933 defaultView.clearTimeout(timerId); 48934 node.removeEventListener('focus', stopTypingOnNonTextField); 48935 node.removeEventListener('keydown', stopTypingOnEscapeKey); 48936 ownerDocument.removeEventListener('selectionchange', stopTypingOnSelectionUncollapse); 48937 }; 48938 } 48939 /** 48940 * Handles a keypress or keydown event to infer intention to start 48941 * typing. 48942 * 48943 * @param {KeyboardEvent} event Keypress or keydown event to interpret. 48944 */ 48945 48946 48947 function startTypingInTextField(event) { 48948 const { 48949 type, 48950 target 48951 } = event; // Abort early if already typing, or key press is incurred outside a 48952 // text field (e.g. arrow-ing through toolbar buttons). 48953 // Ignore typing if outside the current DOM container 48954 48955 if (!(0,external_wp_dom_namespaceObject.isTextField)(target) || !node.contains(target)) { 48956 return; 48957 } // Special-case keydown because certain keys do not emit a keypress 48958 // event. Conversely avoid keydown as the canonical event since 48959 // there are many keydown which are explicitly not targeted for 48960 // typing. 48961 48962 48963 if (type === 'keydown' && !isKeyDownEligibleForStartTyping(event)) { 48964 return; 48965 } 48966 48967 startTyping(); 48968 } 48969 48970 node.addEventListener('keypress', startTypingInTextField); 48971 node.addEventListener('keydown', startTypingInTextField); 48972 return () => { 48973 node.removeEventListener('keypress', startTypingInTextField); 48974 node.removeEventListener('keydown', startTypingInTextField); 48975 }; 48976 }, [isTyping, startTyping, stopTyping]); 48977 return (0,external_wp_compose_namespaceObject.useMergeRefs)([ref1, ref2]); 48978 } 48979 48980 function ObserveTyping(_ref) { 48981 let { 48982 children 48983 } = _ref; 48984 return (0,external_wp_element_namespaceObject.createElement)("div", { 48985 ref: useTypingObserver() 48986 }, children); 48987 } 48988 /** 48989 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/observe-typing/README.md 48990 */ 48991 48992 48993 /* harmony default export */ var observe_typing = (ObserveTyping); 48994 48995 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/typewriter/index.js 48996 48997 48998 /** 48999 * WordPress dependencies 49000 */ 49001 49002 49003 49004 49005 /** 49006 * Internal dependencies 49007 */ 49008 49009 49010 const isIE = window.navigator.userAgent.indexOf('Trident') !== -1; 49011 const arrowKeyCodes = new Set([external_wp_keycodes_namespaceObject.UP, external_wp_keycodes_namespaceObject.DOWN, external_wp_keycodes_namespaceObject.LEFT, external_wp_keycodes_namespaceObject.RIGHT]); 49012 const initialTriggerPercentage = 0.75; 49013 function useTypewriter() { 49014 const hasSelectedBlock = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).hasSelectedBlock(), []); 49015 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => { 49016 if (!hasSelectedBlock) { 49017 return; 49018 } 49019 49020 const { 49021 ownerDocument 49022 } = node; 49023 const { 49024 defaultView 49025 } = ownerDocument; 49026 let scrollResizeRafId; 49027 let onKeyDownRafId; 49028 let caretRect; 49029 49030 function onScrollResize() { 49031 if (scrollResizeRafId) { 49032 return; 49033 } 49034 49035 scrollResizeRafId = defaultView.requestAnimationFrame(() => { 49036 computeCaretRectangle(); 49037 scrollResizeRafId = null; 49038 }); 49039 } 49040 49041 function onKeyDown(event) { 49042 // Ensure the any remaining request is cancelled. 49043 if (onKeyDownRafId) { 49044 defaultView.cancelAnimationFrame(onKeyDownRafId); 49045 } // Use an animation frame for a smooth result. 49046 49047 49048 onKeyDownRafId = defaultView.requestAnimationFrame(() => { 49049 maintainCaretPosition(event); 49050 onKeyDownRafId = null; 49051 }); 49052 } 49053 /** 49054 * Maintains the scroll position after a selection change caused by a 49055 * keyboard event. 49056 * 49057 * @param {KeyboardEvent} event Keyboard event. 49058 */ 49059 49060 49061 function maintainCaretPosition(_ref) { 49062 let { 49063 keyCode 49064 } = _ref; 49065 49066 if (!isSelectionEligibleForScroll()) { 49067 return; 49068 } 49069 49070 const currentCaretRect = (0,external_wp_dom_namespaceObject.computeCaretRect)(defaultView); 49071 49072 if (!currentCaretRect) { 49073 return; 49074 } // If for some reason there is no position set to be scrolled to, let 49075 // this be the position to be scrolled to in the future. 49076 49077 49078 if (!caretRect) { 49079 caretRect = currentCaretRect; 49080 return; 49081 } // Even though enabling the typewriter effect for arrow keys results in 49082 // a pleasant experience, it may not be the case for everyone, so, for 49083 // now, let's disable it. 49084 49085 49086 if (arrowKeyCodes.has(keyCode)) { 49087 // Reset the caret position to maintain. 49088 caretRect = currentCaretRect; 49089 return; 49090 } 49091 49092 const diff = currentCaretRect.top - caretRect.top; 49093 49094 if (diff === 0) { 49095 return; 49096 } 49097 49098 const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(node); // The page must be scrollable. 49099 49100 if (!scrollContainer) { 49101 return; 49102 } 49103 49104 const windowScroll = scrollContainer === ownerDocument.body; 49105 const scrollY = windowScroll ? defaultView.scrollY : scrollContainer.scrollTop; 49106 const scrollContainerY = windowScroll ? 0 : scrollContainer.getBoundingClientRect().top; 49107 const relativeScrollPosition = windowScroll ? caretRect.top / defaultView.innerHeight : (caretRect.top - scrollContainerY) / (defaultView.innerHeight - scrollContainerY); // If the scroll position is at the start, the active editable element 49108 // is the last one, and the caret is positioned within the initial 49109 // trigger percentage of the page, do not scroll the page. 49110 // The typewriter effect should not kick in until an empty page has been 49111 // filled with the initial trigger percentage or the user scrolls 49112 // intentionally down. 49113 49114 if (scrollY === 0 && relativeScrollPosition < initialTriggerPercentage && isLastEditableNode()) { 49115 // Reset the caret position to maintain. 49116 caretRect = currentCaretRect; 49117 return; 49118 } 49119 49120 const scrollContainerHeight = windowScroll ? defaultView.innerHeight : scrollContainer.clientHeight; // Abort if the target scroll position would scroll the caret out of 49121 // view. 49122 49123 if ( // The caret is under the lower fold. 49124 caretRect.top + caretRect.height > scrollContainerY + scrollContainerHeight || // The caret is above the upper fold. 49125 caretRect.top < scrollContainerY) { 49126 // Reset the caret position to maintain. 49127 caretRect = currentCaretRect; 49128 return; 49129 } 49130 49131 if (windowScroll) { 49132 defaultView.scrollBy(0, diff); 49133 } else { 49134 scrollContainer.scrollTop += diff; 49135 } 49136 } 49137 /** 49138 * Adds a `selectionchange` listener to reset the scroll position to be 49139 * maintained. 49140 */ 49141 49142 49143 function addSelectionChangeListener() { 49144 ownerDocument.addEventListener('selectionchange', computeCaretRectOnSelectionChange); 49145 } 49146 /** 49147 * Resets the scroll position to be maintained during a `selectionchange` 49148 * event. Also removes the listener, so it acts as a one-time listener. 49149 */ 49150 49151 49152 function computeCaretRectOnSelectionChange() { 49153 ownerDocument.removeEventListener('selectionchange', computeCaretRectOnSelectionChange); 49154 computeCaretRectangle(); 49155 } 49156 /** 49157 * Resets the scroll position to be maintained. 49158 */ 49159 49160 49161 function computeCaretRectangle() { 49162 if (isSelectionEligibleForScroll()) { 49163 caretRect = (0,external_wp_dom_namespaceObject.computeCaretRect)(defaultView); 49164 } 49165 } 49166 /** 49167 * Checks if the current situation is elegible for scroll: 49168 * - There should be one and only one block selected. 49169 * - The component must contain the selection. 49170 * - The active element must be contenteditable. 49171 */ 49172 49173 49174 function isSelectionEligibleForScroll() { 49175 return node.contains(ownerDocument.activeElement) && ownerDocument.activeElement.isContentEditable; 49176 } 49177 49178 function isLastEditableNode() { 49179 const editableNodes = node.querySelectorAll('[contenteditable="true"]'); 49180 const lastEditableNode = editableNodes[editableNodes.length - 1]; 49181 return lastEditableNode === ownerDocument.activeElement; 49182 } // When the user scrolls or resizes, the scroll position should be 49183 // reset. 49184 49185 49186 defaultView.addEventListener('scroll', onScrollResize, true); 49187 defaultView.addEventListener('resize', onScrollResize, true); 49188 node.addEventListener('keydown', onKeyDown); 49189 node.addEventListener('keyup', maintainCaretPosition); 49190 node.addEventListener('mousedown', addSelectionChangeListener); 49191 node.addEventListener('touchstart', addSelectionChangeListener); 49192 return () => { 49193 defaultView.removeEventListener('scroll', onScrollResize, true); 49194 defaultView.removeEventListener('resize', onScrollResize, true); 49195 node.removeEventListener('keydown', onKeyDown); 49196 node.removeEventListener('keyup', maintainCaretPosition); 49197 node.removeEventListener('mousedown', addSelectionChangeListener); 49198 node.removeEventListener('touchstart', addSelectionChangeListener); 49199 ownerDocument.removeEventListener('selectionchange', computeCaretRectOnSelectionChange); 49200 defaultView.cancelAnimationFrame(scrollResizeRafId); 49201 defaultView.cancelAnimationFrame(onKeyDownRafId); 49202 }; 49203 }, [hasSelectedBlock]); 49204 } 49205 49206 function Typewriter(_ref2) { 49207 let { 49208 children 49209 } = _ref2; 49210 return (0,external_wp_element_namespaceObject.createElement)("div", { 49211 ref: useTypewriter(), 49212 className: "block-editor__typewriter" 49213 }, children); 49214 } 49215 /** 49216 * The exported component. The implementation of Typewriter faced technical 49217 * challenges in Internet Explorer, and is simply skipped, rendering the given 49218 * props children instead. 49219 * 49220 * @type {WPComponent} 49221 */ 49222 49223 49224 const TypewriterOrIEBypass = isIE ? props => props.children : Typewriter; 49225 /** 49226 * Ensures that the text selection keeps the same vertical distance from the 49227 * viewport during keyboard events within this component. The vertical distance 49228 * can vary. It is the last clicked or scrolled to position. 49229 */ 49230 49231 /* harmony default export */ var typewriter = (TypewriterOrIEBypass); 49232 49233 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-no-recursive-renders/index.js 49234 49235 49236 /** 49237 * WordPress dependencies 49238 */ 49239 49240 /** 49241 * Internal dependencies 49242 */ 49243 49244 49245 const RenderedRefsContext = (0,external_wp_element_namespaceObject.createContext)({}); 49246 /** 49247 * Immutably adds an unique identifier to a set scoped for a given block type. 49248 * 49249 * @param {Object} renderedBlocks Rendered blocks grouped by block name 49250 * @param {string} blockName Name of the block. 49251 * @param {*} uniqueId Any value that acts as a unique identifier for a block instance. 49252 * 49253 * @return {Object} The list of rendered blocks grouped by block name. 49254 */ 49255 49256 function addToBlockType(renderedBlocks, blockName, uniqueId) { 49257 const result = { ...renderedBlocks, 49258 [blockName]: renderedBlocks[blockName] ? new Set(renderedBlocks[blockName]) : new Set() 49259 }; 49260 result[blockName].add(uniqueId); 49261 return result; 49262 } 49263 /** 49264 * A React hook for keeping track of blocks previously rendered up in the block 49265 * tree. Blocks susceptible to recursion can use this hook in their `Edit` 49266 * function to prevent said recursion. 49267 * 49268 * @param {*} uniqueId Any value that acts as a unique identifier for a block instance. 49269 * @param {string} blockName Optional block name. 49270 * 49271 * @return {[boolean, Function]} A tuple of: 49272 * - a boolean describing whether the provided id 49273 * has already been rendered; 49274 * - a React context provider to be used to wrap 49275 * other elements. 49276 */ 49277 49278 49279 function useNoRecursiveRenders(uniqueId) { 49280 var _previouslyRenderedBl; 49281 49282 let blockName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 49283 const previouslyRenderedBlocks = (0,external_wp_element_namespaceObject.useContext)(RenderedRefsContext); 49284 const { 49285 name 49286 } = useBlockEditContext(); 49287 blockName = blockName || name; 49288 const hasAlreadyRendered = Boolean((_previouslyRenderedBl = previouslyRenderedBlocks[blockName]) === null || _previouslyRenderedBl === void 0 ? void 0 : _previouslyRenderedBl.has(uniqueId)); 49289 const newRenderedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => addToBlockType(previouslyRenderedBlocks, blockName, uniqueId), [previouslyRenderedBlocks, blockName, uniqueId]); 49290 const Provider = (0,external_wp_element_namespaceObject.useCallback)(_ref => { 49291 let { 49292 children 49293 } = _ref; 49294 return (0,external_wp_element_namespaceObject.createElement)(RenderedRefsContext.Provider, { 49295 value: newRenderedBlocks 49296 }, children); 49297 }, [newRenderedBlocks]); 49298 return [hasAlreadyRendered, Provider]; 49299 } 49300 49301 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/index.js 49302 /* 49303 * Block Creation Components 49304 */ 49305 49306 49307 49308 49309 49310 49311 49312 49313 49314 49315 49316 49317 49318 49319 49320 49321 49322 49323 49324 49325 49326 49327 49328 49329 49330 49331 49332 49333 49334 49335 49336 49337 49338 49339 49340 49341 49342 49343 49344 49345 49346 49347 49348 49349 49350 49351 49352 49353 49354 49355 49356 49357 49358 49359 49360 49361 49362 49363 49364 49365 49366 49367 49368 49369 /* 49370 * Content Related Components 49371 */ 49372 49373 49374 49375 49376 49377 49378 49379 49380 49381 49382 49383 49384 49385 49386 49387 49388 49389 49390 49391 49392 49393 49394 49395 49396 49397 49398 49399 49400 49401 49402 49403 49404 49405 49406 49407 49408 /* 49409 * State Related Components 49410 */ 49411 49412 49413 49414 49415 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/block-variation-transforms.js 49416 /** 49417 * External dependencies 49418 */ 49419 49420 /** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */ 49421 49422 /** 49423 * Matches the provided block variations with a block's attributes. If no match 49424 * or more than one matches are found it returns `undefined`. If a single match is 49425 * found it returns it. 49426 * 49427 * This is a simple implementation for now as it takes into account only the attributes 49428 * of a block variation and not `InnerBlocks`. 49429 * 49430 * @param {Object} blockAttributes - The block attributes to try to find a match. 49431 * @param {WPBlockVariation[]} variations - A list of block variations to test for a match. 49432 * @return {?WPBlockVariation} - If a match is found returns it. If not or more than one matches are found returns `undefined`. 49433 */ 49434 49435 const __experimentalGetMatchingVariation = (blockAttributes, variations) => { 49436 if (!variations || !blockAttributes) return; 49437 const matches = variations.filter(_ref => { 49438 let { 49439 attributes 49440 } = _ref; 49441 if (!attributes || !Object.keys(attributes).length) return false; 49442 return (0,external_lodash_namespaceObject.isMatch)(blockAttributes, attributes); 49443 }); 49444 if (matches.length !== 1) return; 49445 return matches[0]; 49446 }; 49447 49448 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/parse-css-unit-to-px.js 49449 /** 49450 * Converts string to object { value, unit }. 49451 * 49452 * @param {string} cssUnit 49453 * @return {Object} parsedUnit 49454 */ 49455 function parseUnit(cssUnit) { 49456 const match = cssUnit === null || cssUnit === void 0 ? void 0 : cssUnit.trim().match(/^(0?[-.]?\d*\.?\d+)(r?e[m|x]|v[h|w|min|max]+|p[x|t|c]|[c|m]m|%|in|ch|Q|lh)$/); 49457 49458 if (!isNaN(cssUnit) && !isNaN(parseFloat(cssUnit))) { 49459 return { 49460 value: parseFloat(cssUnit), 49461 unit: 'px' 49462 }; 49463 } 49464 49465 return match ? { 49466 value: parseFloat(match[1]) || match[1], 49467 unit: match[2] 49468 } : { 49469 value: cssUnit, 49470 unit: undefined 49471 }; 49472 } 49473 /** 49474 * Evaluate a math expression. 49475 * 49476 * @param {string} expression 49477 * @return {number} evaluated expression. 49478 */ 49479 49480 49481 function calculate(expression) { 49482 return Function(`'use strict'; return ($expression})`)(); 49483 } 49484 /** 49485 * Calculates the css function value for the supported css functions such as max, min, clamp and calc. 49486 * 49487 * @param {string} functionUnitValue string should be in a particular format (for example min(12px,12px) ) no nested loops. 49488 * @param {Object} options 49489 * @return {string} unit containing the unit in PX. 49490 */ 49491 49492 49493 function getFunctionUnitValue(functionUnitValue, options) { 49494 const functionUnit = functionUnitValue.split(/[(),]/g).filter(Boolean); 49495 const units = functionUnit.slice(1).map(unit => parseUnit(getPxFromCssUnit(unit, options)).value).filter(Boolean); 49496 49497 switch (functionUnit[0]) { 49498 case 'min': 49499 return Math.min(...units) + 'px'; 49500 49501 case 'max': 49502 return Math.max(...units) + 'px'; 49503 49504 case 'clamp': 49505 if (units.length !== 3) { 49506 return null; 49507 } 49508 49509 if (units[1] < units[0]) { 49510 return units[0] + 'px'; 49511 } 49512 49513 if (units[1] > units[2]) { 49514 return units[2] + 'px'; 49515 } 49516 49517 return units[1] + 'px'; 49518 49519 case 'calc': 49520 return units[0] + 'px'; 49521 } 49522 } 49523 /** 49524 * Take a css function such as min, max, calc, clamp and returns parsedUnit 49525 * 49526 * How this works for the nested function is that it first replaces the inner function call. 49527 * Then it tackles the outer onces. 49528 * So for example: min( max(25px, 35px), 40px ) 49529 * in the first pass we would replace max(25px, 35px) with 35px. 49530 * then we would try to evaluate min( 35px, 40px ) 49531 * and then finally return 35px. 49532 * 49533 * @param {string} cssUnit 49534 * @return {Object} parsedUnit object. 49535 */ 49536 49537 49538 function parseUnitFunction(cssUnit) { 49539 while (true) { 49540 const currentCssUnit = cssUnit; 49541 const regExp = /(max|min|calc|clamp)\(([^()]*)\)/g; 49542 const matches = regExp.exec(cssUnit) || []; 49543 49544 if (matches[0]) { 49545 const functionUnitValue = getFunctionUnitValue(matches[0]); 49546 cssUnit = cssUnit.replace(matches[0], functionUnitValue); 49547 } // If the unit hasn't been modified or we have a single value break free. 49548 49549 49550 if (cssUnit === currentCssUnit || parseFloat(cssUnit)) { 49551 break; 49552 } 49553 } 49554 49555 return parseUnit(cssUnit); 49556 } 49557 /** 49558 * Return true if we think this is a math expression. 49559 * 49560 * @param {string} cssUnit the cssUnit value being evaluted. 49561 * @return {boolean} Whether the cssUnit is a math expression. 49562 */ 49563 49564 49565 function isMathExpression(cssUnit) { 49566 for (let i = 0; i < cssUnit.length; i++) { 49567 if (['+', '-', '/', '*'].includes(cssUnit[i])) { 49568 return true; 49569 } 49570 } 49571 49572 return false; 49573 } 49574 /** 49575 * Evaluates the math expression and return a px value. 49576 * 49577 * @param {string} cssUnit the cssUnit value being evaluted. 49578 * @return {string} return a converfted value to px. 49579 */ 49580 49581 49582 function evalMathExpression(cssUnit) { 49583 let errorFound = false; // Convert every part of the expression to px values. 49584 49585 const cssUnitsBits = cssUnit.split(/[+-/*/]/g).filter(Boolean); 49586 49587 for (const unit of cssUnitsBits) { 49588 // Standardize the unit to px and extract the value. 49589 const parsedUnit = parseUnit(getPxFromCssUnit(unit)); 49590 49591 if (!parseFloat(parsedUnit.value)) { 49592 errorFound = true; // End early since we are dealing with a null value. 49593 49594 break; 49595 } 49596 49597 cssUnit = cssUnit.replace(unit, parsedUnit.value); 49598 } 49599 49600 return errorFound ? null : calculate(cssUnit).toFixed(0) + 'px'; 49601 } 49602 /** 49603 * Convert a parsedUnit object to px value. 49604 * 49605 * @param {Object} parsedUnit 49606 * @param {Object} options 49607 * @return {string} or {null} returns the converted with in a px value format. 49608 */ 49609 49610 49611 function convertParsedUnitToPx(parsedUnit, options) { 49612 const PIXELS_PER_INCH = 96; 49613 const ONE_PERCENT = 0.01; 49614 const defaultProperties = { 49615 fontSize: 16, 49616 lineHeight: 16, 49617 width: 375, 49618 height: 812, 49619 type: 'font' 49620 }; 49621 const setOptions = Object.assign({}, defaultProperties, options); 49622 const relativeUnits = { 49623 em: setOptions.fontSize, 49624 rem: setOptions.fontSize, 49625 vh: setOptions.height * ONE_PERCENT, 49626 vw: setOptions.width * ONE_PERCENT, 49627 vmin: (setOptions.width < setOptions.height ? setOptions.width : setOptions.height) * ONE_PERCENT, 49628 vmax: (setOptions.width > setOptions.height ? setOptions.width : setOptions.height) * ONE_PERCENT, 49629 '%': (setOptions.type === 'font' ? setOptions.fontSize : setOptions.width) * ONE_PERCENT, 49630 ch: 8, 49631 // The advance measure (width) of the glyph "0" of the element's font. Approximate 49632 ex: 7.15625, 49633 // X-height of the element's font. Approximate. 49634 lh: setOptions.lineHeight 49635 }; 49636 const absoluteUnits = { 49637 in: PIXELS_PER_INCH, 49638 cm: PIXELS_PER_INCH / 2.54, 49639 mm: PIXELS_PER_INCH / 25.4, 49640 pt: PIXELS_PER_INCH / 72, 49641 pc: PIXELS_PER_INCH / 6, 49642 px: 1, 49643 Q: PIXELS_PER_INCH / 2.54 / 40 49644 }; 49645 49646 if (relativeUnits[parsedUnit.unit]) { 49647 return (relativeUnits[parsedUnit.unit] * parsedUnit.value).toFixed(0) + 'px'; 49648 } 49649 49650 if (absoluteUnits[parsedUnit.unit]) { 49651 return (absoluteUnits[parsedUnit.unit] * parsedUnit.value).toFixed(0) + 'px'; 49652 } 49653 49654 return null; 49655 } 49656 /** 49657 * Returns the px value of a cssUnit. 49658 * 49659 * @param {string} cssUnit 49660 * @param {Object} options 49661 * @return {string} returns the cssUnit value in a simple px format. 49662 */ 49663 49664 49665 function getPxFromCssUnit(cssUnit) { 49666 let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 49667 49668 if (Number.isFinite(cssUnit)) { 49669 return cssUnit.toFixed(0) + 'px'; 49670 } 49671 49672 if (cssUnit === undefined) { 49673 return null; 49674 } 49675 49676 let parsedUnit = parseUnit(cssUnit); 49677 49678 if (!parsedUnit.unit) { 49679 parsedUnit = parseUnitFunction(cssUnit, options); 49680 } 49681 49682 if (isMathExpression(cssUnit) && !parsedUnit.unit) { 49683 return evalMathExpression(cssUnit); 49684 } 49685 49686 return convertParsedUnitToPx(parsedUnit, options); 49687 } // Use simple cache. 49688 49689 const cache = {}; 49690 /** 49691 * Returns the px value of a cssUnit. The memoized version of getPxFromCssUnit; 49692 * 49693 * @param {string} cssUnit 49694 * @param {Object} options 49695 * @return {string} returns the cssUnit value in a simple px format. 49696 */ 49697 49698 function memoizedGetPxFromCssUnit(cssUnit) { 49699 let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 49700 const hash = cssUnit + hashOptions(options); 49701 49702 if (!cache[hash]) { 49703 cache[hash] = getPxFromCssUnit(cssUnit, options); 49704 } 49705 49706 return cache[hash]; 49707 } 49708 49709 function hashOptions(options) { 49710 let hash = ''; 49711 49712 if (options.hasOwnProperty('fontSize')) { 49713 hash = ':' + options.width; 49714 } 49715 49716 if (options.hasOwnProperty('lineHeight')) { 49717 hash = ':' + options.lineHeight; 49718 } 49719 49720 if (options.hasOwnProperty('width')) { 49721 hash = ':' + options.width; 49722 } 49723 49724 if (options.hasOwnProperty('height')) { 49725 hash = ':' + options.height; 49726 } 49727 49728 if (options.hasOwnProperty('type')) { 49729 hash = ':' + options.type; 49730 } 49731 49732 return hash; 49733 } 49734 49735 /* harmony default export */ var parse_css_unit_to_px = (memoizedGetPxFromCssUnit); 49736 49737 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/index.js 49738 49739 49740 49741 49742 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/index.js 49743 /** 49744 * Internal dependencies 49745 */ 49746 49747 49748 49749 49750 49751 49752 49753 }(); 49754 (window.wp = window.wp || {}).blockEditor = __webpack_exports__; 49755 /******/ })() 49756 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |