Aucune description

edit-widgets.js 159KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673
  1. /******/ (function() { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ 4403:
  4. /***/ (function(module, exports) {
  5. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  6. Copyright (c) 2018 Jed Watson.
  7. Licensed under the MIT License (MIT), see
  8. http://jedwatson.github.io/classnames
  9. */
  10. /* global define */
  11. (function () {
  12. 'use strict';
  13. var hasOwn = {}.hasOwnProperty;
  14. function classNames() {
  15. var classes = [];
  16. for (var i = 0; i < arguments.length; i++) {
  17. var arg = arguments[i];
  18. if (!arg) continue;
  19. var argType = typeof arg;
  20. if (argType === 'string' || argType === 'number') {
  21. classes.push(arg);
  22. } else if (Array.isArray(arg)) {
  23. if (arg.length) {
  24. var inner = classNames.apply(null, arg);
  25. if (inner) {
  26. classes.push(inner);
  27. }
  28. }
  29. } else if (argType === 'object') {
  30. if (arg.toString === Object.prototype.toString) {
  31. for (var key in arg) {
  32. if (hasOwn.call(arg, key) && arg[key]) {
  33. classes.push(key);
  34. }
  35. }
  36. } else {
  37. classes.push(arg.toString());
  38. }
  39. }
  40. }
  41. return classes.join(' ');
  42. }
  43. if ( true && module.exports) {
  44. classNames.default = classNames;
  45. module.exports = classNames;
  46. } else if (true) {
  47. // register as 'classnames', consistent with npm package name
  48. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  49. return classNames;
  50. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  51. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  52. } else {}
  53. }());
  54. /***/ })
  55. /******/ });
  56. /************************************************************************/
  57. /******/ // The module cache
  58. /******/ var __webpack_module_cache__ = {};
  59. /******/
  60. /******/ // The require function
  61. /******/ function __webpack_require__(moduleId) {
  62. /******/ // Check if module is in cache
  63. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  64. /******/ if (cachedModule !== undefined) {
  65. /******/ return cachedModule.exports;
  66. /******/ }
  67. /******/ // Create a new module (and put it into the cache)
  68. /******/ var module = __webpack_module_cache__[moduleId] = {
  69. /******/ // no module.id needed
  70. /******/ // no module.loaded needed
  71. /******/ exports: {}
  72. /******/ };
  73. /******/
  74. /******/ // Execute the module function
  75. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  76. /******/
  77. /******/ // Return the exports of the module
  78. /******/ return module.exports;
  79. /******/ }
  80. /******/
  81. /************************************************************************/
  82. /******/ /* webpack/runtime/compat get default export */
  83. /******/ !function() {
  84. /******/ // getDefaultExport function for compatibility with non-harmony modules
  85. /******/ __webpack_require__.n = function(module) {
  86. /******/ var getter = module && module.__esModule ?
  87. /******/ function() { return module['default']; } :
  88. /******/ function() { return module; };
  89. /******/ __webpack_require__.d(getter, { a: getter });
  90. /******/ return getter;
  91. /******/ };
  92. /******/ }();
  93. /******/
  94. /******/ /* webpack/runtime/define property getters */
  95. /******/ !function() {
  96. /******/ // define getter functions for harmony exports
  97. /******/ __webpack_require__.d = function(exports, definition) {
  98. /******/ for(var key in definition) {
  99. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  100. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  101. /******/ }
  102. /******/ }
  103. /******/ };
  104. /******/ }();
  105. /******/
  106. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  107. /******/ !function() {
  108. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  109. /******/ }();
  110. /******/
  111. /******/ /* webpack/runtime/make namespace object */
  112. /******/ !function() {
  113. /******/ // define __esModule on exports
  114. /******/ __webpack_require__.r = function(exports) {
  115. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  116. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  117. /******/ }
  118. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  119. /******/ };
  120. /******/ }();
  121. /******/
  122. /************************************************************************/
  123. var __webpack_exports__ = {};
  124. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  125. !function() {
  126. "use strict";
  127. // ESM COMPAT FLAG
  128. __webpack_require__.r(__webpack_exports__);
  129. // EXPORTS
  130. __webpack_require__.d(__webpack_exports__, {
  131. "initialize": function() { return /* binding */ initialize; },
  132. "reinitializeEditor": function() { return /* binding */ reinitializeEditor; }
  133. });
  134. // NAMESPACE OBJECT: ./node_modules/@wordpress/interface/build-module/store/actions.js
  135. var actions_namespaceObject = {};
  136. __webpack_require__.r(actions_namespaceObject);
  137. __webpack_require__.d(actions_namespaceObject, {
  138. "disableComplementaryArea": function() { return disableComplementaryArea; },
  139. "enableComplementaryArea": function() { return enableComplementaryArea; },
  140. "pinItem": function() { return pinItem; },
  141. "setFeatureDefaults": function() { return setFeatureDefaults; },
  142. "setFeatureValue": function() { return setFeatureValue; },
  143. "toggleFeature": function() { return toggleFeature; },
  144. "unpinItem": function() { return unpinItem; }
  145. });
  146. // NAMESPACE OBJECT: ./node_modules/@wordpress/interface/build-module/store/selectors.js
  147. var selectors_namespaceObject = {};
  148. __webpack_require__.r(selectors_namespaceObject);
  149. __webpack_require__.d(selectors_namespaceObject, {
  150. "getActiveComplementaryArea": function() { return getActiveComplementaryArea; },
  151. "isFeatureActive": function() { return isFeatureActive; },
  152. "isItemPinned": function() { return isItemPinned; }
  153. });
  154. // NAMESPACE OBJECT: ./node_modules/@wordpress/edit-widgets/build-module/store/actions.js
  155. var store_actions_namespaceObject = {};
  156. __webpack_require__.r(store_actions_namespaceObject);
  157. __webpack_require__.d(store_actions_namespaceObject, {
  158. "closeGeneralSidebar": function() { return closeGeneralSidebar; },
  159. "moveBlockToWidgetArea": function() { return moveBlockToWidgetArea; },
  160. "persistStubPost": function() { return persistStubPost; },
  161. "saveEditedWidgetAreas": function() { return saveEditedWidgetAreas; },
  162. "saveWidgetArea": function() { return saveWidgetArea; },
  163. "saveWidgetAreas": function() { return saveWidgetAreas; },
  164. "setIsInserterOpened": function() { return setIsInserterOpened; },
  165. "setIsListViewOpened": function() { return setIsListViewOpened; },
  166. "setIsWidgetAreaOpen": function() { return setIsWidgetAreaOpen; },
  167. "setWidgetAreasOpenState": function() { return setWidgetAreasOpenState; },
  168. "setWidgetIdForClientId": function() { return setWidgetIdForClientId; }
  169. });
  170. // NAMESPACE OBJECT: ./node_modules/@wordpress/edit-widgets/build-module/store/resolvers.js
  171. var resolvers_namespaceObject = {};
  172. __webpack_require__.r(resolvers_namespaceObject);
  173. __webpack_require__.d(resolvers_namespaceObject, {
  174. "getWidgetAreas": function() { return getWidgetAreas; },
  175. "getWidgets": function() { return getWidgets; }
  176. });
  177. // NAMESPACE OBJECT: ./node_modules/@wordpress/edit-widgets/build-module/store/selectors.js
  178. var store_selectors_namespaceObject = {};
  179. __webpack_require__.r(store_selectors_namespaceObject);
  180. __webpack_require__.d(store_selectors_namespaceObject, {
  181. "__experimentalGetInsertionPoint": function() { return __experimentalGetInsertionPoint; },
  182. "canInsertBlockInWidgetArea": function() { return canInsertBlockInWidgetArea; },
  183. "getEditedWidgetAreas": function() { return getEditedWidgetAreas; },
  184. "getIsWidgetAreaOpen": function() { return getIsWidgetAreaOpen; },
  185. "getParentWidgetAreaBlock": function() { return getParentWidgetAreaBlock; },
  186. "getReferenceWidgetBlocks": function() { return getReferenceWidgetBlocks; },
  187. "getWidget": function() { return getWidget; },
  188. "getWidgetAreaForWidgetId": function() { return getWidgetAreaForWidgetId; },
  189. "getWidgetAreas": function() { return selectors_getWidgetAreas; },
  190. "getWidgets": function() { return selectors_getWidgets; },
  191. "isInserterOpened": function() { return isInserterOpened; },
  192. "isListViewOpened": function() { return isListViewOpened; },
  193. "isSavingWidgetAreas": function() { return isSavingWidgetAreas; }
  194. });
  195. // NAMESPACE OBJECT: ./node_modules/@wordpress/edit-widgets/build-module/blocks/widget-area/index.js
  196. var widget_area_namespaceObject = {};
  197. __webpack_require__.r(widget_area_namespaceObject);
  198. __webpack_require__.d(widget_area_namespaceObject, {
  199. "metadata": function() { return metadata; },
  200. "name": function() { return widget_area_name; },
  201. "settings": function() { return settings; }
  202. });
  203. ;// CONCATENATED MODULE: external ["wp","element"]
  204. var external_wp_element_namespaceObject = window["wp"]["element"];
  205. ;// CONCATENATED MODULE: external ["wp","blocks"]
  206. var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
  207. ;// CONCATENATED MODULE: external ["wp","data"]
  208. var external_wp_data_namespaceObject = window["wp"]["data"];
  209. ;// CONCATENATED MODULE: external ["wp","blockLibrary"]
  210. var external_wp_blockLibrary_namespaceObject = window["wp"]["blockLibrary"];
  211. ;// CONCATENATED MODULE: external ["wp","coreData"]
  212. var external_wp_coreData_namespaceObject = window["wp"]["coreData"];
  213. ;// CONCATENATED MODULE: external ["wp","widgets"]
  214. var external_wp_widgets_namespaceObject = window["wp"]["widgets"];
  215. ;// CONCATENATED MODULE: external ["wp","preferences"]
  216. var external_wp_preferences_namespaceObject = window["wp"]["preferences"];
  217. ;// CONCATENATED MODULE: external ["wp","apiFetch"]
  218. var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
  219. var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
  220. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/store/reducer.js
  221. /**
  222. * WordPress dependencies
  223. */
  224. /**
  225. * Controls the open state of the widget areas.
  226. *
  227. * @param {Object} state Redux state.
  228. * @param {Object} action Redux action.
  229. *
  230. * @return {Array} Updated state.
  231. */
  232. function widgetAreasOpenState() {
  233. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  234. let action = arguments.length > 1 ? arguments[1] : undefined;
  235. const {
  236. type
  237. } = action;
  238. switch (type) {
  239. case 'SET_WIDGET_AREAS_OPEN_STATE':
  240. {
  241. return action.widgetAreasOpenState;
  242. }
  243. case 'SET_IS_WIDGET_AREA_OPEN':
  244. {
  245. const {
  246. clientId,
  247. isOpen
  248. } = action;
  249. return { ...state,
  250. [clientId]: isOpen
  251. };
  252. }
  253. default:
  254. {
  255. return state;
  256. }
  257. }
  258. }
  259. /**
  260. * Reducer to set the block inserter panel open or closed.
  261. *
  262. * Note: this reducer interacts with the list view panel reducer
  263. * to make sure that only one of the two panels is open at the same time.
  264. *
  265. * @param {Object} state Current state.
  266. * @param {Object} action Dispatched action.
  267. */
  268. function blockInserterPanel() {
  269. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  270. let action = arguments.length > 1 ? arguments[1] : undefined;
  271. switch (action.type) {
  272. case 'SET_IS_LIST_VIEW_OPENED':
  273. return action.isOpen ? false : state;
  274. case 'SET_IS_INSERTER_OPENED':
  275. return action.value;
  276. }
  277. return state;
  278. }
  279. /**
  280. * Reducer to set the list view panel open or closed.
  281. *
  282. * Note: this reducer interacts with the inserter panel reducer
  283. * to make sure that only one of the two panels is open at the same time.
  284. *
  285. * @param {Object} state Current state.
  286. * @param {Object} action Dispatched action.
  287. */
  288. function listViewPanel() {
  289. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  290. let action = arguments.length > 1 ? arguments[1] : undefined;
  291. switch (action.type) {
  292. case 'SET_IS_INSERTER_OPENED':
  293. return action.value ? false : state;
  294. case 'SET_IS_LIST_VIEW_OPENED':
  295. return action.isOpen;
  296. }
  297. return state;
  298. }
  299. /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
  300. blockInserterPanel,
  301. listViewPanel,
  302. widgetAreasOpenState
  303. }));
  304. ;// CONCATENATED MODULE: external ["wp","i18n"]
  305. var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  306. ;// CONCATENATED MODULE: external ["wp","notices"]
  307. var external_wp_notices_namespaceObject = window["wp"]["notices"];
  308. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
  309. function _extends() {
  310. _extends = Object.assign || function (target) {
  311. for (var i = 1; i < arguments.length; i++) {
  312. var source = arguments[i];
  313. for (var key in source) {
  314. if (Object.prototype.hasOwnProperty.call(source, key)) {
  315. target[key] = source[key];
  316. }
  317. }
  318. }
  319. return target;
  320. };
  321. return _extends.apply(this, arguments);
  322. }
  323. // EXTERNAL MODULE: ./node_modules/classnames/index.js
  324. var classnames = __webpack_require__(4403);
  325. var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
  326. ;// CONCATENATED MODULE: external ["wp","components"]
  327. var external_wp_components_namespaceObject = window["wp"]["components"];
  328. ;// CONCATENATED MODULE: external ["wp","primitives"]
  329. var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
  330. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/check.js
  331. /**
  332. * WordPress dependencies
  333. */
  334. const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  335. xmlns: "http://www.w3.org/2000/svg",
  336. viewBox: "0 0 24 24"
  337. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  338. d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
  339. }));
  340. /* harmony default export */ var library_check = (check);
  341. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/star-filled.js
  342. /**
  343. * WordPress dependencies
  344. */
  345. const starFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  346. xmlns: "http://www.w3.org/2000/svg",
  347. viewBox: "0 0 24 24"
  348. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  349. d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"
  350. }));
  351. /* harmony default export */ var star_filled = (starFilled);
  352. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/star-empty.js
  353. /**
  354. * WordPress dependencies
  355. */
  356. const starEmpty = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  357. xmlns: "http://www.w3.org/2000/svg",
  358. viewBox: "0 0 24 24"
  359. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  360. fillRule: "evenodd",
  361. d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z",
  362. clipRule: "evenodd"
  363. }));
  364. /* harmony default export */ var star_empty = (starEmpty);
  365. ;// CONCATENATED MODULE: external ["wp","viewport"]
  366. var external_wp_viewport_namespaceObject = window["wp"]["viewport"];
  367. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close-small.js
  368. /**
  369. * WordPress dependencies
  370. */
  371. const closeSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  372. xmlns: "http://www.w3.org/2000/svg",
  373. viewBox: "0 0 24 24"
  374. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  375. d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"
  376. }));
  377. /* harmony default export */ var close_small = (closeSmall);
  378. ;// CONCATENATED MODULE: external "lodash"
  379. var external_lodash_namespaceObject = window["lodash"];
  380. ;// CONCATENATED MODULE: external ["wp","deprecated"]
  381. var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  382. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  383. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/store/actions.js
  384. /**
  385. * WordPress dependencies
  386. */
  387. /**
  388. * Enable the complementary area.
  389. *
  390. * @param {string} scope Complementary area scope.
  391. * @param {string} area Area identifier.
  392. */
  393. const enableComplementaryArea = (scope, area) => _ref => {
  394. let {
  395. registry
  396. } = _ref;
  397. // Return early if there's no area.
  398. if (!area) {
  399. return;
  400. }
  401. registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'complementaryArea', area);
  402. };
  403. /**
  404. * Disable the complementary area.
  405. *
  406. * @param {string} scope Complementary area scope.
  407. */
  408. const disableComplementaryArea = scope => _ref2 => {
  409. let {
  410. registry
  411. } = _ref2;
  412. registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'complementaryArea', null);
  413. };
  414. /**
  415. * Pins an item.
  416. *
  417. * @param {string} scope Item scope.
  418. * @param {string} item Item identifier.
  419. *
  420. * @return {Object} Action object.
  421. */
  422. const pinItem = (scope, item) => _ref3 => {
  423. let {
  424. registry
  425. } = _ref3;
  426. // Return early if there's no item.
  427. if (!item) {
  428. return;
  429. }
  430. const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems'); // The item is already pinned, there's nothing to do.
  431. if ((pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) === true) {
  432. return;
  433. }
  434. registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', { ...pinnedItems,
  435. [item]: true
  436. });
  437. };
  438. /**
  439. * Unpins an item.
  440. *
  441. * @param {string} scope Item scope.
  442. * @param {string} item Item identifier.
  443. */
  444. const unpinItem = (scope, item) => _ref4 => {
  445. let {
  446. registry
  447. } = _ref4;
  448. // Return early if there's no item.
  449. if (!item) {
  450. return;
  451. }
  452. const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
  453. registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', { ...pinnedItems,
  454. [item]: false
  455. });
  456. };
  457. /**
  458. * Returns an action object used in signalling that a feature should be toggled.
  459. *
  460. * @param {string} scope The feature scope (e.g. core/edit-post).
  461. * @param {string} featureName The feature name.
  462. */
  463. function toggleFeature(scope, featureName) {
  464. return function (_ref5) {
  465. let {
  466. registry
  467. } = _ref5;
  468. external_wp_deprecated_default()(`dispatch( 'core/interface' ).toggleFeature`, {
  469. since: '6.0',
  470. alternative: `dispatch( 'core/preferences' ).toggle`
  471. });
  472. registry.dispatch(external_wp_preferences_namespaceObject.store).toggle(scope, featureName);
  473. };
  474. }
  475. /**
  476. * Returns an action object used in signalling that a feature should be set to
  477. * a true or false value
  478. *
  479. * @param {string} scope The feature scope (e.g. core/edit-post).
  480. * @param {string} featureName The feature name.
  481. * @param {boolean} value The value to set.
  482. *
  483. * @return {Object} Action object.
  484. */
  485. function setFeatureValue(scope, featureName, value) {
  486. return function (_ref6) {
  487. let {
  488. registry
  489. } = _ref6;
  490. external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureValue`, {
  491. since: '6.0',
  492. alternative: `dispatch( 'core/preferences' ).set`
  493. });
  494. registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, featureName, !!value);
  495. };
  496. }
  497. /**
  498. * Returns an action object used in signalling that defaults should be set for features.
  499. *
  500. * @param {string} scope The feature scope (e.g. core/edit-post).
  501. * @param {Object<string, boolean>} defaults A key/value map of feature names to values.
  502. *
  503. * @return {Object} Action object.
  504. */
  505. function setFeatureDefaults(scope, defaults) {
  506. return function (_ref7) {
  507. let {
  508. registry
  509. } = _ref7;
  510. external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureDefaults`, {
  511. since: '6.0',
  512. alternative: `dispatch( 'core/preferences' ).setDefaults`
  513. });
  514. registry.dispatch(external_wp_preferences_namespaceObject.store).setDefaults(scope, defaults);
  515. };
  516. }
  517. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/store/selectors.js
  518. /**
  519. * WordPress dependencies
  520. */
  521. /**
  522. * Returns the complementary area that is active in a given scope.
  523. *
  524. * @param {Object} state Global application state.
  525. * @param {string} scope Item scope.
  526. *
  527. * @return {string} The complementary area that is active in the given scope.
  528. */
  529. const getActiveComplementaryArea = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => {
  530. return select(external_wp_preferences_namespaceObject.store).get(scope, 'complementaryArea');
  531. });
  532. /**
  533. * Returns a boolean indicating if an item is pinned or not.
  534. *
  535. * @param {Object} state Global application state.
  536. * @param {string} scope Scope.
  537. * @param {string} item Item to check.
  538. *
  539. * @return {boolean} True if the item is pinned and false otherwise.
  540. */
  541. const isItemPinned = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, item) => {
  542. var _pinnedItems$item;
  543. const pinnedItems = select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
  544. return (_pinnedItems$item = pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) !== null && _pinnedItems$item !== void 0 ? _pinnedItems$item : true;
  545. });
  546. /**
  547. * Returns a boolean indicating whether a feature is active for a particular
  548. * scope.
  549. *
  550. * @param {Object} state The store state.
  551. * @param {string} scope The scope of the feature (e.g. core/edit-post).
  552. * @param {string} featureName The name of the feature.
  553. *
  554. * @return {boolean} Is the feature enabled?
  555. */
  556. const isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, featureName) => {
  557. external_wp_deprecated_default()(`select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
  558. since: '6.0',
  559. alternative: `select( 'core/preferences' ).get( scope, featureName )`
  560. });
  561. return !!select(external_wp_preferences_namespaceObject.store).get(scope, featureName);
  562. });
  563. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/store/constants.js
  564. /**
  565. * The identifier for the data store.
  566. *
  567. * @type {string}
  568. */
  569. const STORE_NAME = 'core/interface';
  570. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/store/index.js
  571. /**
  572. * WordPress dependencies
  573. */
  574. /**
  575. * Internal dependencies
  576. */
  577. /**
  578. * Store definition for the interface namespace.
  579. *
  580. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  581. *
  582. * @type {Object}
  583. */
  584. const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
  585. reducer: () => {},
  586. actions: actions_namespaceObject,
  587. selectors: selectors_namespaceObject
  588. }); // Once we build a more generic persistence plugin that works across types of stores
  589. // we'd be able to replace this with a register call.
  590. (0,external_wp_data_namespaceObject.register)(store);
  591. ;// CONCATENATED MODULE: external ["wp","plugins"]
  592. var external_wp_plugins_namespaceObject = window["wp"]["plugins"];
  593. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/complementary-area-context/index.js
  594. /**
  595. * WordPress dependencies
  596. */
  597. /* harmony default export */ var complementary_area_context = ((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
  598. return {
  599. icon: ownProps.icon || context.icon,
  600. identifier: ownProps.identifier || `${context.name}/${ownProps.name}`
  601. };
  602. }));
  603. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/complementary-area-toggle/index.js
  604. /**
  605. * External dependencies
  606. */
  607. /**
  608. * WordPress dependencies
  609. */
  610. /**
  611. * Internal dependencies
  612. */
  613. function ComplementaryAreaToggle(_ref) {
  614. let {
  615. as = external_wp_components_namespaceObject.Button,
  616. scope,
  617. identifier,
  618. icon,
  619. selectedIcon,
  620. ...props
  621. } = _ref;
  622. const ComponentToUse = as;
  623. const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(scope) === identifier, [identifier]);
  624. const {
  625. enableComplementaryArea,
  626. disableComplementaryArea
  627. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  628. return (0,external_wp_element_namespaceObject.createElement)(ComponentToUse, _extends({
  629. icon: selectedIcon && isSelected ? selectedIcon : icon,
  630. onClick: () => {
  631. if (isSelected) {
  632. disableComplementaryArea(scope);
  633. } else {
  634. enableComplementaryArea(scope, identifier);
  635. }
  636. }
  637. }, (0,external_lodash_namespaceObject.omit)(props, ['name'])));
  638. }
  639. /* harmony default export */ var complementary_area_toggle = (complementary_area_context(ComplementaryAreaToggle));
  640. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/complementary-area-header/index.js
  641. /**
  642. * External dependencies
  643. */
  644. /**
  645. * WordPress dependencies
  646. */
  647. /**
  648. * Internal dependencies
  649. */
  650. const ComplementaryAreaHeader = _ref => {
  651. let {
  652. smallScreenTitle,
  653. children,
  654. className,
  655. toggleButtonProps
  656. } = _ref;
  657. const toggleButton = (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, _extends({
  658. icon: close_small
  659. }, toggleButtonProps));
  660. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  661. className: "components-panel__header interface-complementary-area-header__small"
  662. }, smallScreenTitle && (0,external_wp_element_namespaceObject.createElement)("span", {
  663. className: "interface-complementary-area-header__small-title"
  664. }, smallScreenTitle), toggleButton), (0,external_wp_element_namespaceObject.createElement)("div", {
  665. className: classnames_default()('components-panel__header', 'interface-complementary-area-header', className),
  666. tabIndex: -1
  667. }, children, toggleButton));
  668. };
  669. /* harmony default export */ var complementary_area_header = (ComplementaryAreaHeader);
  670. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/action-item/index.js
  671. /**
  672. * External dependencies
  673. */
  674. /**
  675. * WordPress dependencies
  676. */
  677. function ActionItemSlot(_ref) {
  678. let {
  679. name,
  680. as: Component = external_wp_components_namespaceObject.ButtonGroup,
  681. fillProps = {},
  682. bubblesVirtually,
  683. ...props
  684. } = _ref;
  685. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, {
  686. name: name,
  687. bubblesVirtually: bubblesVirtually,
  688. fillProps: fillProps
  689. }, fills => {
  690. if ((0,external_lodash_namespaceObject.isEmpty)(external_wp_element_namespaceObject.Children.toArray(fills))) {
  691. return null;
  692. } // Special handling exists for backward compatibility.
  693. // It ensures that menu items created by plugin authors aren't
  694. // duplicated with automatically injected menu items coming
  695. // from pinnable plugin sidebars.
  696. // @see https://github.com/WordPress/gutenberg/issues/14457
  697. const initializedByPlugins = [];
  698. external_wp_element_namespaceObject.Children.forEach(fills, _ref2 => {
  699. let {
  700. props: {
  701. __unstableExplicitMenuItem,
  702. __unstableTarget
  703. }
  704. } = _ref2;
  705. if (__unstableTarget && __unstableExplicitMenuItem) {
  706. initializedByPlugins.push(__unstableTarget);
  707. }
  708. });
  709. const children = external_wp_element_namespaceObject.Children.map(fills, child => {
  710. if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(child.props.__unstableTarget)) {
  711. return null;
  712. }
  713. return child;
  714. });
  715. return (0,external_wp_element_namespaceObject.createElement)(Component, props, children);
  716. });
  717. }
  718. function ActionItem(_ref3) {
  719. let {
  720. name,
  721. as: Component = external_wp_components_namespaceObject.Button,
  722. onClick,
  723. ...props
  724. } = _ref3;
  725. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
  726. name: name
  727. }, _ref4 => {
  728. let {
  729. onClick: fpOnClick
  730. } = _ref4;
  731. return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({
  732. onClick: onClick || fpOnClick ? function () {
  733. (onClick || external_lodash_namespaceObject.noop)(...arguments);
  734. (fpOnClick || external_lodash_namespaceObject.noop)(...arguments);
  735. } : undefined
  736. }, props));
  737. });
  738. }
  739. ActionItem.Slot = ActionItemSlot;
  740. /* harmony default export */ var action_item = (ActionItem);
  741. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/complementary-area-more-menu-item/index.js
  742. /**
  743. * External dependencies
  744. */
  745. /**
  746. * WordPress dependencies
  747. */
  748. /**
  749. * Internal dependencies
  750. */
  751. const PluginsMenuItem = props => // Menu item is marked with unstable prop for backward compatibility.
  752. // They are removed so they don't leak to DOM elements.
  753. // @see https://github.com/WordPress/gutenberg/issues/14457
  754. (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, (0,external_lodash_namespaceObject.omit)(props, ['__unstableExplicitMenuItem', '__unstableTarget']));
  755. function ComplementaryAreaMoreMenuItem(_ref) {
  756. let {
  757. scope,
  758. target,
  759. __unstableExplicitMenuItem,
  760. ...props
  761. } = _ref;
  762. return (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, _extends({
  763. as: toggleProps => {
  764. return (0,external_wp_element_namespaceObject.createElement)(action_item, _extends({
  765. __unstableExplicitMenuItem: __unstableExplicitMenuItem,
  766. __unstableTarget: `${scope}/${target}`,
  767. as: PluginsMenuItem,
  768. name: `${scope}/plugin-more-menu`
  769. }, toggleProps));
  770. },
  771. role: "menuitemcheckbox",
  772. selectedIcon: library_check,
  773. name: target,
  774. scope: scope
  775. }, props));
  776. }
  777. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/pinned-items/index.js
  778. /**
  779. * External dependencies
  780. */
  781. /**
  782. * WordPress dependencies
  783. */
  784. function PinnedItems(_ref) {
  785. let {
  786. scope,
  787. ...props
  788. } = _ref;
  789. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, _extends({
  790. name: `PinnedItems/${scope}`
  791. }, props));
  792. }
  793. function PinnedItemsSlot(_ref2) {
  794. let {
  795. scope,
  796. className,
  797. ...props
  798. } = _ref2;
  799. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, _extends({
  800. name: `PinnedItems/${scope}`
  801. }, props), fills => !(0,external_lodash_namespaceObject.isEmpty)(fills) && (0,external_wp_element_namespaceObject.createElement)("div", {
  802. className: classnames_default()(className, 'interface-pinned-items')
  803. }, fills));
  804. }
  805. PinnedItems.Slot = PinnedItemsSlot;
  806. /* harmony default export */ var pinned_items = (PinnedItems);
  807. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/complementary-area/index.js
  808. /**
  809. * External dependencies
  810. */
  811. /**
  812. * WordPress dependencies
  813. */
  814. /**
  815. * Internal dependencies
  816. */
  817. function ComplementaryAreaSlot(_ref) {
  818. let {
  819. scope,
  820. ...props
  821. } = _ref;
  822. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, _extends({
  823. name: `ComplementaryArea/${scope}`
  824. }, props));
  825. }
  826. function ComplementaryAreaFill(_ref2) {
  827. let {
  828. scope,
  829. children,
  830. className
  831. } = _ref2;
  832. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
  833. name: `ComplementaryArea/${scope}`
  834. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  835. className: className
  836. }, children));
  837. }
  838. function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
  839. const previousIsSmall = (0,external_wp_element_namespaceObject.useRef)(false);
  840. const shouldOpenWhenNotSmall = (0,external_wp_element_namespaceObject.useRef)(false);
  841. const {
  842. enableComplementaryArea,
  843. disableComplementaryArea
  844. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  845. (0,external_wp_element_namespaceObject.useEffect)(() => {
  846. // If the complementary area is active and the editor is switching from a big to a small window size.
  847. if (isActive && isSmall && !previousIsSmall.current) {
  848. // Disable the complementary area.
  849. disableComplementaryArea(scope); // Flag the complementary area to be reopened when the window size goes from small to big.
  850. shouldOpenWhenNotSmall.current = true;
  851. } else if ( // If there is a flag indicating the complementary area should be enabled when we go from small to big window size
  852. // and we are going from a small to big window size.
  853. shouldOpenWhenNotSmall.current && !isSmall && previousIsSmall.current) {
  854. // Remove the flag indicating the complementary area should be enabled.
  855. shouldOpenWhenNotSmall.current = false; // Enable the complementary area.
  856. enableComplementaryArea(scope, identifier);
  857. } else if ( // If the flag is indicating the current complementary should be reopened but another complementary area becomes active,
  858. // remove the flag.
  859. shouldOpenWhenNotSmall.current && activeArea && activeArea !== identifier) {
  860. shouldOpenWhenNotSmall.current = false;
  861. }
  862. if (isSmall !== previousIsSmall.current) {
  863. previousIsSmall.current = isSmall;
  864. }
  865. }, [isActive, isSmall, scope, identifier, activeArea]);
  866. }
  867. function ComplementaryArea(_ref3) {
  868. let {
  869. children,
  870. className,
  871. closeLabel = (0,external_wp_i18n_namespaceObject.__)('Close plugin'),
  872. identifier,
  873. header,
  874. headerClassName,
  875. icon,
  876. isPinnable = true,
  877. panelClassName,
  878. scope,
  879. name,
  880. smallScreenTitle,
  881. title,
  882. toggleShortcut,
  883. isActiveByDefault,
  884. showIconLabels = false
  885. } = _ref3;
  886. const {
  887. isActive,
  888. isPinned,
  889. activeArea,
  890. isSmall,
  891. isLarge
  892. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  893. const {
  894. getActiveComplementaryArea,
  895. isItemPinned
  896. } = select(store);
  897. const _activeArea = getActiveComplementaryArea(scope);
  898. return {
  899. isActive: _activeArea === identifier,
  900. isPinned: isItemPinned(scope, identifier),
  901. activeArea: _activeArea,
  902. isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'),
  903. isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large')
  904. };
  905. }, [identifier, scope]);
  906. useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall);
  907. const {
  908. enableComplementaryArea,
  909. disableComplementaryArea,
  910. pinItem,
  911. unpinItem
  912. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  913. (0,external_wp_element_namespaceObject.useEffect)(() => {
  914. if (isActiveByDefault && activeArea === undefined && !isSmall) {
  915. enableComplementaryArea(scope, identifier);
  916. }
  917. }, [activeArea, isActiveByDefault, scope, identifier, isSmall]);
  918. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isPinnable && (0,external_wp_element_namespaceObject.createElement)(pinned_items, {
  919. scope: scope
  920. }, isPinned && (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, {
  921. scope: scope,
  922. identifier: identifier,
  923. isPressed: isActive && (!showIconLabels || isLarge),
  924. "aria-expanded": isActive,
  925. label: title,
  926. icon: showIconLabels ? library_check : icon,
  927. showTooltip: !showIconLabels,
  928. variant: showIconLabels ? 'tertiary' : undefined
  929. })), name && isPinnable && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem, {
  930. target: name,
  931. scope: scope,
  932. icon: icon
  933. }, title), isActive && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaFill, {
  934. className: classnames_default()('interface-complementary-area', className),
  935. scope: scope
  936. }, (0,external_wp_element_namespaceObject.createElement)(complementary_area_header, {
  937. className: headerClassName,
  938. closeLabel: closeLabel,
  939. onClose: () => disableComplementaryArea(scope),
  940. smallScreenTitle: smallScreenTitle,
  941. toggleButtonProps: {
  942. label: closeLabel,
  943. shortcut: toggleShortcut,
  944. scope,
  945. identifier
  946. }
  947. }, header || (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("strong", null, title), isPinnable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  948. className: "interface-complementary-area__pin-unpin-item",
  949. icon: isPinned ? star_filled : star_empty,
  950. label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'),
  951. onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier),
  952. isPressed: isPinned,
  953. "aria-expanded": isPinned
  954. }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Panel, {
  955. className: panelClassName
  956. }, children)));
  957. }
  958. const ComplementaryAreaWrapped = complementary_area_context(ComplementaryArea);
  959. ComplementaryAreaWrapped.Slot = ComplementaryAreaSlot;
  960. /* harmony default export */ var complementary_area = (ComplementaryAreaWrapped);
  961. ;// CONCATENATED MODULE: external ["wp","compose"]
  962. var external_wp_compose_namespaceObject = window["wp"]["compose"];
  963. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/interface-skeleton/index.js
  964. /**
  965. * External dependencies
  966. */
  967. /**
  968. * WordPress dependencies
  969. */
  970. /**
  971. * WordPress dependencies
  972. */
  973. function useHTMLClass(className) {
  974. (0,external_wp_element_namespaceObject.useEffect)(() => {
  975. const element = document && document.querySelector(`html:not(.${className})`);
  976. if (!element) {
  977. return;
  978. }
  979. element.classList.toggle(className);
  980. return () => {
  981. element.classList.toggle(className);
  982. };
  983. }, [className]);
  984. }
  985. function InterfaceSkeleton(_ref, ref) {
  986. let {
  987. footer,
  988. header,
  989. sidebar,
  990. secondarySidebar,
  991. notices,
  992. content,
  993. drawer,
  994. actions,
  995. labels,
  996. className,
  997. shortcuts
  998. } = _ref;
  999. const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)(shortcuts);
  1000. useHTMLClass('interface-interface-skeleton__html-container');
  1001. const defaultLabels = {
  1002. /* translators: accessibility text for the nav bar landmark region. */
  1003. drawer: (0,external_wp_i18n_namespaceObject.__)('Drawer'),
  1004. /* translators: accessibility text for the top bar landmark region. */
  1005. header: (0,external_wp_i18n_namespaceObject.__)('Header'),
  1006. /* translators: accessibility text for the content landmark region. */
  1007. body: (0,external_wp_i18n_namespaceObject.__)('Content'),
  1008. /* translators: accessibility text for the secondary sidebar landmark region. */
  1009. secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block Library'),
  1010. /* translators: accessibility text for the settings landmark region. */
  1011. sidebar: (0,external_wp_i18n_namespaceObject.__)('Settings'),
  1012. /* translators: accessibility text for the publish landmark region. */
  1013. actions: (0,external_wp_i18n_namespaceObject.__)('Publish'),
  1014. /* translators: accessibility text for the footer landmark region. */
  1015. footer: (0,external_wp_i18n_namespaceObject.__)('Footer')
  1016. };
  1017. const mergedLabels = { ...defaultLabels,
  1018. ...labels
  1019. };
  1020. return (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, navigateRegionsProps, {
  1021. ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, navigateRegionsProps.ref]),
  1022. className: classnames_default()(className, 'interface-interface-skeleton', navigateRegionsProps.className, !!footer && 'has-footer')
  1023. }), !!drawer && (0,external_wp_element_namespaceObject.createElement)("div", {
  1024. className: "interface-interface-skeleton__drawer",
  1025. role: "region",
  1026. "aria-label": mergedLabels.drawer,
  1027. tabIndex: "-1"
  1028. }, drawer), (0,external_wp_element_namespaceObject.createElement)("div", {
  1029. className: "interface-interface-skeleton__editor"
  1030. }, !!header && (0,external_wp_element_namespaceObject.createElement)("div", {
  1031. className: "interface-interface-skeleton__header",
  1032. role: "region",
  1033. "aria-label": mergedLabels.header,
  1034. tabIndex: "-1"
  1035. }, header), (0,external_wp_element_namespaceObject.createElement)("div", {
  1036. className: "interface-interface-skeleton__body"
  1037. }, !!secondarySidebar && (0,external_wp_element_namespaceObject.createElement)("div", {
  1038. className: "interface-interface-skeleton__secondary-sidebar",
  1039. role: "region",
  1040. "aria-label": mergedLabels.secondarySidebar,
  1041. tabIndex: "-1"
  1042. }, secondarySidebar), !!notices && (0,external_wp_element_namespaceObject.createElement)("div", {
  1043. className: "interface-interface-skeleton__notices"
  1044. }, notices), (0,external_wp_element_namespaceObject.createElement)("div", {
  1045. className: "interface-interface-skeleton__content",
  1046. role: "region",
  1047. "aria-label": mergedLabels.body,
  1048. tabIndex: "-1"
  1049. }, content), !!sidebar && (0,external_wp_element_namespaceObject.createElement)("div", {
  1050. className: "interface-interface-skeleton__sidebar",
  1051. role: "region",
  1052. "aria-label": mergedLabels.sidebar,
  1053. tabIndex: "-1"
  1054. }, sidebar), !!actions && (0,external_wp_element_namespaceObject.createElement)("div", {
  1055. className: "interface-interface-skeleton__actions",
  1056. role: "region",
  1057. "aria-label": mergedLabels.actions,
  1058. tabIndex: "-1"
  1059. }, actions))), !!footer && (0,external_wp_element_namespaceObject.createElement)("div", {
  1060. className: "interface-interface-skeleton__footer",
  1061. role: "region",
  1062. "aria-label": mergedLabels.footer,
  1063. tabIndex: "-1"
  1064. }, footer));
  1065. }
  1066. /* harmony default export */ var interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton));
  1067. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/more-vertical.js
  1068. /**
  1069. * WordPress dependencies
  1070. */
  1071. const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1072. xmlns: "http://www.w3.org/2000/svg",
  1073. viewBox: "0 0 24 24"
  1074. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1075. d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
  1076. }));
  1077. /* harmony default export */ var more_vertical = (moreVertical);
  1078. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/more-menu-dropdown/index.js
  1079. /**
  1080. * External dependencies
  1081. */
  1082. /**
  1083. * WordPress dependencies
  1084. */
  1085. function MoreMenuDropdown(_ref) {
  1086. let {
  1087. as: DropdownComponent = external_wp_components_namespaceObject.DropdownMenu,
  1088. className,
  1089. /* translators: button label text should, if possible, be under 16 characters. */
  1090. label = (0,external_wp_i18n_namespaceObject.__)('Options'),
  1091. popoverProps,
  1092. toggleProps,
  1093. children
  1094. } = _ref;
  1095. return (0,external_wp_element_namespaceObject.createElement)(DropdownComponent, {
  1096. className: classnames_default()('interface-more-menu-dropdown', className),
  1097. icon: more_vertical,
  1098. label: label,
  1099. popoverProps: {
  1100. position: 'bottom left',
  1101. ...popoverProps,
  1102. className: classnames_default()('interface-more-menu-dropdown__content', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className)
  1103. },
  1104. toggleProps: {
  1105. tooltipPosition: 'bottom',
  1106. ...toggleProps
  1107. }
  1108. }, onClose => children(onClose));
  1109. }
  1110. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/index.js
  1111. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/index.js
  1112. ;// CONCATENATED MODULE: external ["wp","blockEditor"]
  1113. var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
  1114. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/store/transformers.js
  1115. /**
  1116. * WordPress dependencies
  1117. */
  1118. /**
  1119. * Converts a widget entity record into a block.
  1120. *
  1121. * @param {Object} widget The widget entity record.
  1122. * @return {Object} a block (converted from the entity record).
  1123. */
  1124. function transformWidgetToBlock(widget) {
  1125. if (widget.id_base === 'block') {
  1126. const parsedBlocks = (0,external_wp_blocks_namespaceObject.parse)(widget.instance.raw.content);
  1127. if (!parsedBlocks.length) {
  1128. return (0,external_wp_widgets_namespaceObject.addWidgetIdToBlock)((0,external_wp_blocks_namespaceObject.createBlock)('core/paragraph', {}, []), widget.id);
  1129. }
  1130. return (0,external_wp_widgets_namespaceObject.addWidgetIdToBlock)(parsedBlocks[0], widget.id);
  1131. }
  1132. let attributes;
  1133. if (widget._embedded.about[0].is_multi) {
  1134. attributes = {
  1135. idBase: widget.id_base,
  1136. instance: widget.instance
  1137. };
  1138. } else {
  1139. attributes = {
  1140. id: widget.id
  1141. };
  1142. }
  1143. return (0,external_wp_widgets_namespaceObject.addWidgetIdToBlock)((0,external_wp_blocks_namespaceObject.createBlock)('core/legacy-widget', attributes, []), widget.id);
  1144. }
  1145. /**
  1146. * Converts a block to a widget entity record.
  1147. *
  1148. * @param {Object} block The block.
  1149. * @param {Object?} relatedWidget A related widget entity record from the API (optional).
  1150. * @return {Object} the widget object (converted from block).
  1151. */
  1152. function transformBlockToWidget(block) {
  1153. let relatedWidget = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1154. let widget;
  1155. const isValidLegacyWidgetBlock = block.name === 'core/legacy-widget' && (block.attributes.id || block.attributes.instance);
  1156. if (isValidLegacyWidgetBlock) {
  1157. var _block$attributes$id, _block$attributes$idB, _block$attributes$ins;
  1158. widget = { ...relatedWidget,
  1159. id: (_block$attributes$id = block.attributes.id) !== null && _block$attributes$id !== void 0 ? _block$attributes$id : relatedWidget.id,
  1160. id_base: (_block$attributes$idB = block.attributes.idBase) !== null && _block$attributes$idB !== void 0 ? _block$attributes$idB : relatedWidget.id_base,
  1161. instance: (_block$attributes$ins = block.attributes.instance) !== null && _block$attributes$ins !== void 0 ? _block$attributes$ins : relatedWidget.instance
  1162. };
  1163. } else {
  1164. widget = { ...relatedWidget,
  1165. id_base: 'block',
  1166. instance: {
  1167. raw: {
  1168. content: (0,external_wp_blocks_namespaceObject.serialize)(block)
  1169. }
  1170. }
  1171. };
  1172. } // Delete read-only properties.
  1173. delete widget.rendered;
  1174. delete widget.rendered_form;
  1175. return widget;
  1176. }
  1177. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/store/utils.js
  1178. /**
  1179. * "Kind" of the navigation post.
  1180. *
  1181. * @type {string}
  1182. */
  1183. const KIND = 'root';
  1184. /**
  1185. * "post type" of the navigation post.
  1186. *
  1187. * @type {string}
  1188. */
  1189. const WIDGET_AREA_ENTITY_TYPE = 'sidebar';
  1190. /**
  1191. * "post type" of the widget area post.
  1192. *
  1193. * @type {string}
  1194. */
  1195. const POST_TYPE = 'postType';
  1196. /**
  1197. * Builds an ID for a new widget area post.
  1198. *
  1199. * @param {number} widgetAreaId Widget area id.
  1200. * @return {string} An ID.
  1201. */
  1202. const buildWidgetAreaPostId = widgetAreaId => `widget-area-${widgetAreaId}`;
  1203. /**
  1204. * Builds an ID for a global widget areas post.
  1205. *
  1206. * @return {string} An ID.
  1207. */
  1208. const buildWidgetAreasPostId = () => `widget-areas`;
  1209. /**
  1210. * Builds a query to resolve sidebars.
  1211. *
  1212. * @return {Object} Query.
  1213. */
  1214. function buildWidgetAreasQuery() {
  1215. return {
  1216. per_page: -1
  1217. };
  1218. }
  1219. /**
  1220. * Builds a query to resolve widgets.
  1221. *
  1222. * @return {Object} Query.
  1223. */
  1224. function buildWidgetsQuery() {
  1225. return {
  1226. per_page: -1,
  1227. _embed: 'about'
  1228. };
  1229. }
  1230. /**
  1231. * Creates a stub post with given id and set of blocks. Used as a governing entity records
  1232. * for all widget areas.
  1233. *
  1234. * @param {string} id Post ID.
  1235. * @param {Array} blocks The list of blocks.
  1236. * @return {Object} A stub post object formatted in compliance with the data layer.
  1237. */
  1238. const createStubPost = (id, blocks) => ({
  1239. id,
  1240. slug: id,
  1241. status: 'draft',
  1242. type: 'page',
  1243. blocks,
  1244. meta: {
  1245. widgetAreaId: id
  1246. }
  1247. });
  1248. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/store/constants.js
  1249. /**
  1250. * Module Constants
  1251. */
  1252. const constants_STORE_NAME = 'core/edit-widgets';
  1253. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/store/actions.js
  1254. /**
  1255. * WordPress dependencies
  1256. */
  1257. /**
  1258. * Internal dependencies
  1259. */
  1260. /**
  1261. * Persists a stub post with given ID to core data store. The post is meant to be in-memory only and
  1262. * shouldn't be saved via the API.
  1263. *
  1264. * @param {string} id Post ID.
  1265. * @param {Array} blocks Blocks the post should consist of.
  1266. * @return {Object} The post object.
  1267. */
  1268. const persistStubPost = (id, blocks) => _ref => {
  1269. let {
  1270. registry
  1271. } = _ref;
  1272. const stubPost = createStubPost(id, blocks);
  1273. registry.dispatch(external_wp_coreData_namespaceObject.store).receiveEntityRecords(KIND, POST_TYPE, stubPost, {
  1274. id: stubPost.id
  1275. }, false);
  1276. return stubPost;
  1277. };
  1278. /**
  1279. * Converts all the blocks from edited widget areas into widgets,
  1280. * and submits a batch request to save everything at once.
  1281. *
  1282. * Creates a snackbar notice on either success or error.
  1283. *
  1284. * @return {Function} An action creator.
  1285. */
  1286. const saveEditedWidgetAreas = () => async _ref2 => {
  1287. let {
  1288. select,
  1289. dispatch,
  1290. registry
  1291. } = _ref2;
  1292. const editedWidgetAreas = select.getEditedWidgetAreas();
  1293. if (!(editedWidgetAreas !== null && editedWidgetAreas !== void 0 && editedWidgetAreas.length)) {
  1294. return;
  1295. }
  1296. try {
  1297. await dispatch.saveWidgetAreas(editedWidgetAreas);
  1298. registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Widgets saved.'), {
  1299. type: 'snackbar'
  1300. });
  1301. } catch (e) {
  1302. registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(
  1303. /* translators: %s: The error message. */
  1304. (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('There was an error. %s'), e.message), {
  1305. type: 'snackbar'
  1306. });
  1307. }
  1308. };
  1309. /**
  1310. * Converts all the blocks from specified widget areas into widgets,
  1311. * and submits a batch request to save everything at once.
  1312. *
  1313. * @param {Object[]} widgetAreas Widget areas to save.
  1314. * @return {Function} An action creator.
  1315. */
  1316. const saveWidgetAreas = widgetAreas => async _ref3 => {
  1317. let {
  1318. dispatch,
  1319. registry
  1320. } = _ref3;
  1321. try {
  1322. for (const widgetArea of widgetAreas) {
  1323. await dispatch.saveWidgetArea(widgetArea.id);
  1324. }
  1325. } finally {
  1326. // saveEditedEntityRecord resets the resolution status, let's fix it manually.
  1327. await registry.dispatch(external_wp_coreData_namespaceObject.store).finishResolution('getEntityRecord', KIND, WIDGET_AREA_ENTITY_TYPE, buildWidgetAreasQuery());
  1328. }
  1329. };
  1330. /**
  1331. * Converts all the blocks from a widget area specified by ID into widgets,
  1332. * and submits a batch request to save everything at once.
  1333. *
  1334. * @param {string} widgetAreaId ID of the widget area to process.
  1335. * @return {Function} An action creator.
  1336. */
  1337. const saveWidgetArea = widgetAreaId => async _ref4 => {
  1338. let {
  1339. dispatch,
  1340. select,
  1341. registry
  1342. } = _ref4;
  1343. const widgets = select.getWidgets();
  1344. const post = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(widgetAreaId)); // Get all widgets from this area
  1345. const areaWidgets = Object.values(widgets).filter(_ref5 => {
  1346. let {
  1347. sidebar
  1348. } = _ref5;
  1349. return sidebar === widgetAreaId;
  1350. }); // Remove all duplicate reference widget instances for legacy widgets.
  1351. // Why? We filter out the widgets with duplicate IDs to prevent adding more than one instance of a widget
  1352. // implemented using a function. WordPress doesn't support having more than one instance of these, if you try to
  1353. // save multiple instances of these in different sidebars you will run into undefined behaviors.
  1354. const usedReferenceWidgets = [];
  1355. const widgetsBlocks = post.blocks.filter(block => {
  1356. const {
  1357. id
  1358. } = block.attributes;
  1359. if (block.name === 'core/legacy-widget' && id) {
  1360. if (usedReferenceWidgets.includes(id)) {
  1361. return false;
  1362. }
  1363. usedReferenceWidgets.push(id);
  1364. }
  1365. return true;
  1366. }); // Determine which widgets have been deleted. We can tell if a widget is
  1367. // deleted and not just moved to a different area by looking to see if
  1368. // getWidgetAreaForWidgetId() finds something.
  1369. const deletedWidgets = [];
  1370. for (const widget of areaWidgets) {
  1371. const widgetsNewArea = select.getWidgetAreaForWidgetId(widget.id);
  1372. if (!widgetsNewArea) {
  1373. deletedWidgets.push(widget);
  1374. }
  1375. }
  1376. const batchMeta = [];
  1377. const batchTasks = [];
  1378. const sidebarWidgetsIds = [];
  1379. for (let i = 0; i < widgetsBlocks.length; i++) {
  1380. const block = widgetsBlocks[i];
  1381. const widgetId = (0,external_wp_widgets_namespaceObject.getWidgetIdFromBlock)(block);
  1382. const oldWidget = widgets[widgetId];
  1383. const widget = transformBlockToWidget(block, oldWidget); // We'll replace the null widgetId after save, but we track it here
  1384. // since order is important.
  1385. sidebarWidgetsIds.push(widgetId); // Check oldWidget as widgetId might refer to an ID which has been
  1386. // deleted, e.g. if a deleted block is restored via undo after saving.
  1387. if (oldWidget) {
  1388. // Update an existing widget.
  1389. registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('root', 'widget', widgetId, { ...widget,
  1390. sidebar: widgetAreaId
  1391. }, {
  1392. undoIgnore: true
  1393. });
  1394. const hasEdits = registry.select(external_wp_coreData_namespaceObject.store).hasEditsForEntityRecord('root', 'widget', widgetId);
  1395. if (!hasEdits) {
  1396. continue;
  1397. }
  1398. batchTasks.push(_ref6 => {
  1399. let {
  1400. saveEditedEntityRecord
  1401. } = _ref6;
  1402. return saveEditedEntityRecord('root', 'widget', widgetId);
  1403. });
  1404. } else {
  1405. // Create a new widget.
  1406. batchTasks.push(_ref7 => {
  1407. let {
  1408. saveEntityRecord
  1409. } = _ref7;
  1410. return saveEntityRecord('root', 'widget', { ...widget,
  1411. sidebar: widgetAreaId
  1412. });
  1413. });
  1414. }
  1415. batchMeta.push({
  1416. block,
  1417. position: i,
  1418. clientId: block.clientId
  1419. });
  1420. }
  1421. for (const widget of deletedWidgets) {
  1422. batchTasks.push(_ref8 => {
  1423. let {
  1424. deleteEntityRecord
  1425. } = _ref8;
  1426. return deleteEntityRecord('root', 'widget', widget.id, {
  1427. force: true
  1428. });
  1429. });
  1430. }
  1431. const records = await registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalBatch(batchTasks);
  1432. const preservedRecords = records.filter(record => !record.hasOwnProperty('deleted'));
  1433. const failedWidgetNames = [];
  1434. for (let i = 0; i < preservedRecords.length; i++) {
  1435. const widget = preservedRecords[i];
  1436. const {
  1437. block,
  1438. position
  1439. } = batchMeta[i]; // Set __internalWidgetId on the block. This will be persisted to the
  1440. // store when we dispatch receiveEntityRecords( post ) below.
  1441. post.blocks[position].attributes.__internalWidgetId = widget.id;
  1442. const error = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('root', 'widget', widget.id);
  1443. if (error) {
  1444. var _block$attributes;
  1445. failedWidgetNames.push(((_block$attributes = block.attributes) === null || _block$attributes === void 0 ? void 0 : _block$attributes.name) || (block === null || block === void 0 ? void 0 : block.name));
  1446. }
  1447. if (!sidebarWidgetsIds[position]) {
  1448. sidebarWidgetsIds[position] = widget.id;
  1449. }
  1450. }
  1451. if (failedWidgetNames.length) {
  1452. throw new Error((0,external_wp_i18n_namespaceObject.sprintf)(
  1453. /* translators: %s: List of widget names */
  1454. (0,external_wp_i18n_namespaceObject.__)('Could not save the following widgets: %s.'), failedWidgetNames.join(', ')));
  1455. }
  1456. registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId, {
  1457. widgets: sidebarWidgetsIds
  1458. }, {
  1459. undoIgnore: true
  1460. });
  1461. dispatch(trySaveWidgetArea(widgetAreaId));
  1462. registry.dispatch(external_wp_coreData_namespaceObject.store).receiveEntityRecords(KIND, POST_TYPE, post, undefined);
  1463. };
  1464. const trySaveWidgetArea = widgetAreaId => _ref9 => {
  1465. let {
  1466. registry
  1467. } = _ref9;
  1468. registry.dispatch(external_wp_coreData_namespaceObject.store).saveEditedEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId, {
  1469. throwOnError: true
  1470. });
  1471. };
  1472. /**
  1473. * Sets the clientId stored for a particular widgetId.
  1474. *
  1475. * @param {number} clientId Client id.
  1476. * @param {number} widgetId Widget id.
  1477. *
  1478. * @return {Object} Action.
  1479. */
  1480. function setWidgetIdForClientId(clientId, widgetId) {
  1481. return {
  1482. type: 'SET_WIDGET_ID_FOR_CLIENT_ID',
  1483. clientId,
  1484. widgetId
  1485. };
  1486. }
  1487. /**
  1488. * Sets the open state of all the widget areas.
  1489. *
  1490. * @param {Object} widgetAreasOpenState The open states of all the widget areas.
  1491. *
  1492. * @return {Object} Action.
  1493. */
  1494. function setWidgetAreasOpenState(widgetAreasOpenState) {
  1495. return {
  1496. type: 'SET_WIDGET_AREAS_OPEN_STATE',
  1497. widgetAreasOpenState
  1498. };
  1499. }
  1500. /**
  1501. * Sets the open state of the widget area.
  1502. *
  1503. * @param {string} clientId The clientId of the widget area.
  1504. * @param {boolean} isOpen Whether the widget area should be opened.
  1505. *
  1506. * @return {Object} Action.
  1507. */
  1508. function setIsWidgetAreaOpen(clientId, isOpen) {
  1509. return {
  1510. type: 'SET_IS_WIDGET_AREA_OPEN',
  1511. clientId,
  1512. isOpen
  1513. };
  1514. }
  1515. /**
  1516. * Returns an action object used to open/close the inserter.
  1517. *
  1518. * @param {boolean|Object} value Whether the inserter should be
  1519. * opened (true) or closed (false).
  1520. * To specify an insertion point,
  1521. * use an object.
  1522. * @param {string} value.rootClientId The root client ID to insert at.
  1523. * @param {number} value.insertionIndex The index to insert at.
  1524. *
  1525. * @return {Object} Action object.
  1526. */
  1527. function setIsInserterOpened(value) {
  1528. return {
  1529. type: 'SET_IS_INSERTER_OPENED',
  1530. value
  1531. };
  1532. }
  1533. /**
  1534. * Returns an action object used to open/close the list view.
  1535. *
  1536. * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.
  1537. * @return {Object} Action object.
  1538. */
  1539. function setIsListViewOpened(isOpen) {
  1540. return {
  1541. type: 'SET_IS_LIST_VIEW_OPENED',
  1542. isOpen
  1543. };
  1544. }
  1545. /**
  1546. * Returns an action object signalling that the user closed the sidebar.
  1547. *
  1548. * @return {Object} Action creator.
  1549. */
  1550. const closeGeneralSidebar = () => _ref10 => {
  1551. let {
  1552. registry
  1553. } = _ref10;
  1554. registry.dispatch(store).disableComplementaryArea(constants_STORE_NAME);
  1555. };
  1556. /**
  1557. * Action that handles moving a block between widget areas
  1558. *
  1559. * @param {string} clientId The clientId of the block to move.
  1560. * @param {string} widgetAreaId The id of the widget area to move the block to.
  1561. */
  1562. const moveBlockToWidgetArea = (clientId, widgetAreaId) => async _ref11 => {
  1563. let {
  1564. dispatch,
  1565. select,
  1566. registry
  1567. } = _ref11;
  1568. const sourceRootClientId = registry.select(external_wp_blockEditor_namespaceObject.store).getBlockRootClientId([clientId]); // Search the top level blocks (widget areas) for the one with the matching
  1569. // id attribute. Makes the assumption that all top-level blocks are widget
  1570. // areas.
  1571. const widgetAreas = registry.select(external_wp_blockEditor_namespaceObject.store).getBlocks();
  1572. const destinationWidgetAreaBlock = widgetAreas.find(_ref12 => {
  1573. let {
  1574. attributes
  1575. } = _ref12;
  1576. return attributes.id === widgetAreaId;
  1577. });
  1578. const destinationRootClientId = destinationWidgetAreaBlock.clientId; // Get the index for moving to the end of the the destination widget area.
  1579. const destinationInnerBlocksClientIds = registry.select(external_wp_blockEditor_namespaceObject.store).getBlockOrder(destinationRootClientId);
  1580. const destinationIndex = destinationInnerBlocksClientIds.length; // Reveal the widget area, if it's not open.
  1581. const isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen(destinationRootClientId);
  1582. if (!isDestinationWidgetAreaOpen) {
  1583. dispatch.setIsWidgetAreaOpen(destinationRootClientId, true);
  1584. } // Move the block.
  1585. registry.dispatch(external_wp_blockEditor_namespaceObject.store).moveBlocksToPosition([clientId], sourceRootClientId, destinationRootClientId, destinationIndex);
  1586. };
  1587. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/store/resolvers.js
  1588. /**
  1589. * WordPress dependencies
  1590. */
  1591. /**
  1592. * Internal dependencies
  1593. */
  1594. /**
  1595. * Creates a "stub" widgets post reflecting all available widget areas. The
  1596. * post is meant as a convenient to only exists in runtime and should never be saved. It
  1597. * enables a convenient way of editing the widgets by using a regular post editor.
  1598. *
  1599. * Fetches all widgets from all widgets aras, converts them into blocks, and hydrates a new post with them.
  1600. *
  1601. * @return {Function} An action creator.
  1602. */
  1603. const getWidgetAreas = () => async _ref => {
  1604. let {
  1605. dispatch,
  1606. registry
  1607. } = _ref;
  1608. const query = buildWidgetAreasQuery();
  1609. const widgetAreas = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getEntityRecords(KIND, WIDGET_AREA_ENTITY_TYPE, query);
  1610. const widgetAreaBlocks = [];
  1611. const sortedWidgetAreas = widgetAreas.sort((a, b) => {
  1612. if (a.id === 'wp_inactive_widgets') {
  1613. return 1;
  1614. }
  1615. if (b.id === 'wp_inactive_widgets') {
  1616. return -1;
  1617. }
  1618. return 0;
  1619. });
  1620. for (const widgetArea of sortedWidgetAreas) {
  1621. widgetAreaBlocks.push((0,external_wp_blocks_namespaceObject.createBlock)('core/widget-area', {
  1622. id: widgetArea.id,
  1623. name: widgetArea.name
  1624. }));
  1625. if (!widgetArea.widgets.length) {
  1626. // If this widget area has no widgets, it won't get a post setup by
  1627. // the getWidgets resolver.
  1628. dispatch(persistStubPost(buildWidgetAreaPostId(widgetArea.id), []));
  1629. }
  1630. }
  1631. const widgetAreasOpenState = {};
  1632. widgetAreaBlocks.forEach((widgetAreaBlock, index) => {
  1633. // Defaults to open the first widget area.
  1634. widgetAreasOpenState[widgetAreaBlock.clientId] = index === 0;
  1635. });
  1636. dispatch(setWidgetAreasOpenState(widgetAreasOpenState));
  1637. dispatch(persistStubPost(buildWidgetAreasPostId(), widgetAreaBlocks));
  1638. };
  1639. /**
  1640. * Fetches all widgets from all widgets ares, and groups them by widget area Id.
  1641. *
  1642. * @return {Function} An action creator.
  1643. */
  1644. const getWidgets = () => async _ref2 => {
  1645. let {
  1646. dispatch,
  1647. registry
  1648. } = _ref2;
  1649. const query = buildWidgetsQuery();
  1650. const widgets = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getEntityRecords('root', 'widget', query);
  1651. const groupedBySidebar = {};
  1652. for (const widget of widgets) {
  1653. const block = transformWidgetToBlock(widget);
  1654. groupedBySidebar[widget.sidebar] = groupedBySidebar[widget.sidebar] || [];
  1655. groupedBySidebar[widget.sidebar].push(block);
  1656. }
  1657. for (const sidebarId in groupedBySidebar) {
  1658. if (groupedBySidebar.hasOwnProperty(sidebarId)) {
  1659. // Persist the actual post containing the widget block
  1660. dispatch(persistStubPost(buildWidgetAreaPostId(sidebarId), groupedBySidebar[sidebarId]));
  1661. }
  1662. }
  1663. };
  1664. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/store/selectors.js
  1665. /**
  1666. * External dependencies
  1667. */
  1668. /**
  1669. * WordPress dependencies
  1670. */
  1671. /**
  1672. * Internal dependencies
  1673. */
  1674. /**
  1675. * Returns all API widgets.
  1676. *
  1677. * @return {Object[]} API List of widgets.
  1678. */
  1679. const selectors_getWidgets = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
  1680. const widgets = select(external_wp_coreData_namespaceObject.store).getEntityRecords('root', 'widget', buildWidgetsQuery());
  1681. return (0,external_lodash_namespaceObject.keyBy)(widgets, 'id');
  1682. });
  1683. /**
  1684. * Returns API widget data for a particular widget ID.
  1685. *
  1686. * @param {number} id Widget ID.
  1687. *
  1688. * @return {Object} API widget data for a particular widget ID.
  1689. */
  1690. const getWidget = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, id) => {
  1691. const widgets = select(constants_STORE_NAME).getWidgets();
  1692. return widgets[id];
  1693. });
  1694. /**
  1695. * Returns all API widget areas.
  1696. *
  1697. * @return {Object[]} API List of widget areas.
  1698. */
  1699. const selectors_getWidgetAreas = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
  1700. const query = buildWidgetAreasQuery();
  1701. return select(external_wp_coreData_namespaceObject.store).getEntityRecords(KIND, WIDGET_AREA_ENTITY_TYPE, query);
  1702. });
  1703. /**
  1704. * Returns widgetArea containing a block identify by given widgetId
  1705. *
  1706. * @param {string} widgetId The ID of the widget.
  1707. * @return {Object} Containing widget area.
  1708. */
  1709. const getWidgetAreaForWidgetId = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, widgetId) => {
  1710. const widgetAreas = select(constants_STORE_NAME).getWidgetAreas();
  1711. return widgetAreas.find(widgetArea => {
  1712. const post = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(widgetArea.id));
  1713. const blockWidgetIds = post.blocks.map(block => (0,external_wp_widgets_namespaceObject.getWidgetIdFromBlock)(block));
  1714. return blockWidgetIds.includes(widgetId);
  1715. });
  1716. });
  1717. /**
  1718. * Given a child client id, returns the parent widget area block.
  1719. *
  1720. * @param {string} clientId The client id of a block in a widget area.
  1721. *
  1722. * @return {WPBlock} The widget area block.
  1723. */
  1724. const getParentWidgetAreaBlock = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, clientId) => {
  1725. const {
  1726. getBlock,
  1727. getBlockName,
  1728. getBlockParents
  1729. } = select(external_wp_blockEditor_namespaceObject.store);
  1730. const blockParents = getBlockParents(clientId);
  1731. const widgetAreaClientId = blockParents.find(parentClientId => getBlockName(parentClientId) === 'core/widget-area');
  1732. return getBlock(widgetAreaClientId);
  1733. });
  1734. /**
  1735. * Returns all edited widget area entity records.
  1736. *
  1737. * @return {Object[]} List of edited widget area entity records.
  1738. */
  1739. const getEditedWidgetAreas = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, ids) => {
  1740. let widgetAreas = select(constants_STORE_NAME).getWidgetAreas();
  1741. if (!widgetAreas) {
  1742. return [];
  1743. }
  1744. if (ids) {
  1745. widgetAreas = widgetAreas.filter(_ref => {
  1746. let {
  1747. id
  1748. } = _ref;
  1749. return ids.includes(id);
  1750. });
  1751. }
  1752. return widgetAreas.filter(_ref2 => {
  1753. let {
  1754. id
  1755. } = _ref2;
  1756. return select(external_wp_coreData_namespaceObject.store).hasEditsForEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(id));
  1757. }).map(_ref3 => {
  1758. let {
  1759. id
  1760. } = _ref3;
  1761. return select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, id);
  1762. });
  1763. });
  1764. /**
  1765. * Returns all blocks representing reference widgets.
  1766. *
  1767. * @param {string} referenceWidgetName Optional. If given, only reference widgets with this name will be returned.
  1768. * @return {Array} List of all blocks representing reference widgets
  1769. */
  1770. const getReferenceWidgetBlocks = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => function (state) {
  1771. let referenceWidgetName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1772. const results = [];
  1773. const widgetAreas = select(constants_STORE_NAME).getWidgetAreas();
  1774. for (const _widgetArea of widgetAreas) {
  1775. const post = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(_widgetArea.id));
  1776. for (const block of post.blocks) {
  1777. var _block$attributes;
  1778. if (block.name === 'core/legacy-widget' && (!referenceWidgetName || ((_block$attributes = block.attributes) === null || _block$attributes === void 0 ? void 0 : _block$attributes.referenceWidgetName) === referenceWidgetName)) {
  1779. results.push(block);
  1780. }
  1781. }
  1782. }
  1783. return results;
  1784. });
  1785. /**
  1786. * Returns true if any widget area is currently being saved.
  1787. *
  1788. * @return {boolean} True if any widget area is currently being saved. False otherwise.
  1789. */
  1790. const isSavingWidgetAreas = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
  1791. var _select$getWidgetArea;
  1792. const widgetAreasIds = (_select$getWidgetArea = select(constants_STORE_NAME).getWidgetAreas()) === null || _select$getWidgetArea === void 0 ? void 0 : _select$getWidgetArea.map(_ref4 => {
  1793. let {
  1794. id
  1795. } = _ref4;
  1796. return id;
  1797. });
  1798. if (!widgetAreasIds) {
  1799. return false;
  1800. }
  1801. for (const id of widgetAreasIds) {
  1802. const isSaving = select(external_wp_coreData_namespaceObject.store).isSavingEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, id);
  1803. if (isSaving) {
  1804. return true;
  1805. }
  1806. }
  1807. const widgetIds = [...Object.keys(select(constants_STORE_NAME).getWidgets()), undefined // account for new widgets without an ID
  1808. ];
  1809. for (const id of widgetIds) {
  1810. const isSaving = select(external_wp_coreData_namespaceObject.store).isSavingEntityRecord('root', 'widget', id);
  1811. if (isSaving) {
  1812. return true;
  1813. }
  1814. }
  1815. return false;
  1816. });
  1817. /**
  1818. * Gets whether the widget area is opened.
  1819. *
  1820. * @param {Array} state The open state of the widget areas.
  1821. * @param {string} clientId The clientId of the widget area.
  1822. *
  1823. * @return {boolean} True if the widget area is open.
  1824. */
  1825. const getIsWidgetAreaOpen = (state, clientId) => {
  1826. const {
  1827. widgetAreasOpenState
  1828. } = state;
  1829. return !!widgetAreasOpenState[clientId];
  1830. };
  1831. /**
  1832. * Returns true if the inserter is opened.
  1833. *
  1834. * @param {Object} state Global application state.
  1835. *
  1836. * @return {boolean} Whether the inserter is opened.
  1837. */
  1838. function isInserterOpened(state) {
  1839. return !!state.blockInserterPanel;
  1840. }
  1841. /**
  1842. * Get the insertion point for the inserter.
  1843. *
  1844. * @param {Object} state Global application state.
  1845. *
  1846. * @return {Object} The root client ID and index to insert at.
  1847. */
  1848. function __experimentalGetInsertionPoint(state) {
  1849. const {
  1850. rootClientId,
  1851. insertionIndex
  1852. } = state.blockInserterPanel;
  1853. return {
  1854. rootClientId,
  1855. insertionIndex
  1856. };
  1857. }
  1858. /**
  1859. * Returns true if a block can be inserted into a widget area.
  1860. *
  1861. * @param {Array} state The open state of the widget areas.
  1862. * @param {string} blockName The name of the block being inserted.
  1863. *
  1864. * @return {boolean} True if the block can be inserted in a widget area.
  1865. */
  1866. const canInsertBlockInWidgetArea = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, blockName) => {
  1867. // Widget areas are always top-level blocks, which getBlocks will return.
  1868. const widgetAreas = select(external_wp_blockEditor_namespaceObject.store).getBlocks(); // Makes an assumption that a block that can be inserted into one
  1869. // widget area can be inserted into any widget area. Uses the first
  1870. // widget area for testing whether the block can be inserted.
  1871. const [firstWidgetArea] = widgetAreas;
  1872. return select(external_wp_blockEditor_namespaceObject.store).canInsertBlockType(blockName, firstWidgetArea.clientId);
  1873. });
  1874. /**
  1875. * Returns true if the list view is opened.
  1876. *
  1877. * @param {Object} state Global application state.
  1878. *
  1879. * @return {boolean} Whether the list view is opened.
  1880. */
  1881. function isListViewOpened(state) {
  1882. return state.listViewPanel;
  1883. }
  1884. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/store/index.js
  1885. /**
  1886. * WordPress dependencies
  1887. */
  1888. /**
  1889. * Internal dependencies
  1890. */
  1891. /**
  1892. * Block editor data store configuration.
  1893. *
  1894. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#register
  1895. *
  1896. * @type {Object}
  1897. */
  1898. const storeConfig = {
  1899. reducer: reducer,
  1900. selectors: store_selectors_namespaceObject,
  1901. resolvers: resolvers_namespaceObject,
  1902. actions: store_actions_namespaceObject
  1903. };
  1904. /**
  1905. * Store definition for the edit widgets namespace.
  1906. *
  1907. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  1908. *
  1909. * @type {Object}
  1910. */
  1911. const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(constants_STORE_NAME, storeConfig);
  1912. (0,external_wp_data_namespaceObject.register)(store_store); // This package uses a few in-memory post types as wrappers for convenience.
  1913. // This middleware prevents any network requests related to these types as they are
  1914. // bound to fail anyway.
  1915. external_wp_apiFetch_default().use(function (options, next) {
  1916. var _options$path;
  1917. if (((_options$path = options.path) === null || _options$path === void 0 ? void 0 : _options$path.indexOf('/wp/v2/types/widget-area')) === 0) {
  1918. return Promise.resolve({});
  1919. }
  1920. return next(options);
  1921. });
  1922. ;// CONCATENATED MODULE: external ["wp","hooks"]
  1923. var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
  1924. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/filters/move-to-widget-area.js
  1925. /**
  1926. * WordPress dependencies
  1927. */
  1928. /**
  1929. * Internal dependencies
  1930. */
  1931. const withMoveToWidgetAreaToolbarItem = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
  1932. const {
  1933. clientId,
  1934. name: blockName
  1935. } = props;
  1936. const {
  1937. widgetAreas,
  1938. currentWidgetAreaId,
  1939. canInsertBlockInWidgetArea
  1940. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  1941. var _widgetAreaBlock$attr;
  1942. // Component won't display for a widget area, so don't run selectors.
  1943. if (blockName === 'core/widget-area') {
  1944. return {};
  1945. }
  1946. const selectors = select(store_store);
  1947. const widgetAreaBlock = selectors.getParentWidgetAreaBlock(clientId);
  1948. return {
  1949. widgetAreas: selectors.getWidgetAreas(),
  1950. currentWidgetAreaId: widgetAreaBlock === null || widgetAreaBlock === void 0 ? void 0 : (_widgetAreaBlock$attr = widgetAreaBlock.attributes) === null || _widgetAreaBlock$attr === void 0 ? void 0 : _widgetAreaBlock$attr.id,
  1951. canInsertBlockInWidgetArea: selectors.canInsertBlockInWidgetArea(blockName)
  1952. };
  1953. }, [clientId, blockName]);
  1954. const {
  1955. moveBlockToWidgetArea
  1956. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  1957. const hasMultipleWidgetAreas = (widgetAreas === null || widgetAreas === void 0 ? void 0 : widgetAreas.length) > 1;
  1958. const isMoveToWidgetAreaVisible = blockName !== 'core/widget-area' && hasMultipleWidgetAreas && canInsertBlockInWidgetArea;
  1959. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), isMoveToWidgetAreaVisible && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_widgets_namespaceObject.MoveToWidgetArea, {
  1960. widgetAreas: widgetAreas,
  1961. currentWidgetAreaId: currentWidgetAreaId,
  1962. onSelect: widgetAreaId => {
  1963. moveBlockToWidgetArea(props.clientId, widgetAreaId);
  1964. }
  1965. })));
  1966. }, 'withMoveToWidgetAreaToolbarItem');
  1967. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-widgets/block-edit', withMoveToWidgetAreaToolbarItem);
  1968. ;// CONCATENATED MODULE: external ["wp","mediaUtils"]
  1969. var external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"];
  1970. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/filters/replace-media-upload.js
  1971. /**
  1972. * WordPress dependencies
  1973. */
  1974. const replaceMediaUpload = () => external_wp_mediaUtils_namespaceObject.MediaUpload;
  1975. (0,external_wp_hooks_namespaceObject.addFilter)('editor.MediaUpload', 'core/edit-widgets/replace-media-upload', replaceMediaUpload);
  1976. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/filters/index.js
  1977. /**
  1978. * Internal dependencies
  1979. */
  1980. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/blocks/widget-area/edit/use-is-dragging-within.js
  1981. /**
  1982. * WordPress dependencies
  1983. */
  1984. /** @typedef {import('@wordpress/element').RefObject} RefObject */
  1985. /**
  1986. * A React hook to determine if it's dragging within the target element.
  1987. *
  1988. * @param {RefObject<HTMLElement>} elementRef The target elementRef object.
  1989. *
  1990. * @return {boolean} Is dragging within the target element.
  1991. */
  1992. const useIsDraggingWithin = elementRef => {
  1993. const [isDraggingWithin, setIsDraggingWithin] = (0,external_wp_element_namespaceObject.useState)(false);
  1994. (0,external_wp_element_namespaceObject.useEffect)(() => {
  1995. const {
  1996. ownerDocument
  1997. } = elementRef.current;
  1998. function handleDragStart(event) {
  1999. // Check the first time when the dragging starts.
  2000. handleDragEnter(event);
  2001. } // Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.
  2002. function handleDragEnd() {
  2003. setIsDraggingWithin(false);
  2004. }
  2005. function handleDragEnter(event) {
  2006. // Check if the current target is inside the item element.
  2007. if (elementRef.current.contains(event.target)) {
  2008. setIsDraggingWithin(true);
  2009. } else {
  2010. setIsDraggingWithin(false);
  2011. }
  2012. } // Bind these events to the document to catch all drag events.
  2013. // Ideally, we can also use `event.relatedTarget`, but sadly that doesn't work in Safari.
  2014. ownerDocument.addEventListener('dragstart', handleDragStart);
  2015. ownerDocument.addEventListener('dragend', handleDragEnd);
  2016. ownerDocument.addEventListener('dragenter', handleDragEnter);
  2017. return () => {
  2018. ownerDocument.removeEventListener('dragstart', handleDragStart);
  2019. ownerDocument.removeEventListener('dragend', handleDragEnd);
  2020. ownerDocument.removeEventListener('dragenter', handleDragEnter);
  2021. };
  2022. }, []);
  2023. return isDraggingWithin;
  2024. };
  2025. /* harmony default export */ var use_is_dragging_within = (useIsDraggingWithin);
  2026. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/blocks/widget-area/edit/inner-blocks.js
  2027. /**
  2028. * External dependencies
  2029. */
  2030. /**
  2031. * WordPress dependencies
  2032. */
  2033. /**
  2034. * Internal dependencies
  2035. */
  2036. function WidgetAreaInnerBlocks(_ref) {
  2037. let {
  2038. id
  2039. } = _ref;
  2040. const [blocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('root', 'postType');
  2041. const innerBlocksRef = (0,external_wp_element_namespaceObject.useRef)();
  2042. const isDraggingWithinInnerBlocks = use_is_dragging_within(innerBlocksRef);
  2043. const shouldHighlightDropZone = isDraggingWithinInnerBlocks; // Using the experimental hook so that we can control the className of the element.
  2044. const innerBlocksProps = (0,external_wp_blockEditor_namespaceObject.useInnerBlocksProps)({
  2045. ref: innerBlocksRef
  2046. }, {
  2047. value: blocks,
  2048. onInput,
  2049. onChange,
  2050. templateLock: false,
  2051. renderAppender: external_wp_blockEditor_namespaceObject.InnerBlocks.ButtonBlockAppender
  2052. });
  2053. return (0,external_wp_element_namespaceObject.createElement)("div", {
  2054. "data-widget-area-id": id,
  2055. className: classnames_default()('wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper', {
  2056. 'wp-block-widget-area__highlight-drop-zone': shouldHighlightDropZone
  2057. })
  2058. }, (0,external_wp_element_namespaceObject.createElement)("div", innerBlocksProps));
  2059. }
  2060. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/blocks/widget-area/edit/index.js
  2061. /**
  2062. * WordPress dependencies
  2063. */
  2064. /**
  2065. * Internal dependencies
  2066. */
  2067. /** @typedef {import('@wordpress/element').RefObject} RefObject */
  2068. function WidgetAreaEdit(_ref) {
  2069. let {
  2070. clientId,
  2071. className,
  2072. attributes: {
  2073. id,
  2074. name
  2075. }
  2076. } = _ref;
  2077. const isOpen = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getIsWidgetAreaOpen(clientId), [clientId]);
  2078. const {
  2079. setIsWidgetAreaOpen
  2080. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  2081. const wrapper = (0,external_wp_element_namespaceObject.useRef)();
  2082. const setOpen = (0,external_wp_element_namespaceObject.useCallback)(openState => setIsWidgetAreaOpen(clientId, openState), [clientId]);
  2083. const isDragging = useIsDragging(wrapper);
  2084. const isDraggingWithin = use_is_dragging_within(wrapper);
  2085. const [openedWhileDragging, setOpenedWhileDragging] = (0,external_wp_element_namespaceObject.useState)(false);
  2086. (0,external_wp_element_namespaceObject.useEffect)(() => {
  2087. if (!isDragging) {
  2088. setOpenedWhileDragging(false);
  2089. return;
  2090. }
  2091. if (isDraggingWithin && !isOpen) {
  2092. setOpen(true);
  2093. setOpenedWhileDragging(true);
  2094. } else if (!isDraggingWithin && isOpen && openedWhileDragging) {
  2095. setOpen(false);
  2096. }
  2097. }, [isOpen, isDragging, isDraggingWithin, openedWhileDragging]);
  2098. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Panel, {
  2099. className: className,
  2100. ref: wrapper
  2101. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
  2102. title: name,
  2103. opened: isOpen,
  2104. onToggle: () => {
  2105. setIsWidgetAreaOpen(clientId, !isOpen);
  2106. },
  2107. scrollAfterOpen: !isDragging
  2108. }, _ref2 => {
  2109. let {
  2110. opened
  2111. } = _ref2;
  2112. return (// This is required to ensure LegacyWidget blocks are not
  2113. // unmounted when the panel is collapsed. Unmounting legacy
  2114. // widgets may have unintended consequences (e.g. TinyMCE
  2115. // not being properly reinitialized)
  2116. (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableDisclosureContent, {
  2117. className: "wp-block-widget-area__panel-body-content",
  2118. visible: opened
  2119. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_coreData_namespaceObject.EntityProvider, {
  2120. kind: "root",
  2121. type: "postType",
  2122. id: `widget-area-${id}`
  2123. }, (0,external_wp_element_namespaceObject.createElement)(WidgetAreaInnerBlocks, {
  2124. id: id
  2125. })))
  2126. );
  2127. }));
  2128. }
  2129. /**
  2130. * A React hook to determine if dragging is active.
  2131. *
  2132. * @param {RefObject<HTMLElement>} elementRef The target elementRef object.
  2133. *
  2134. * @return {boolean} Is dragging within the entire document.
  2135. */
  2136. const useIsDragging = elementRef => {
  2137. const [isDragging, setIsDragging] = (0,external_wp_element_namespaceObject.useState)(false);
  2138. (0,external_wp_element_namespaceObject.useEffect)(() => {
  2139. const {
  2140. ownerDocument
  2141. } = elementRef.current;
  2142. function handleDragStart() {
  2143. setIsDragging(true);
  2144. }
  2145. function handleDragEnd() {
  2146. setIsDragging(false);
  2147. }
  2148. ownerDocument.addEventListener('dragstart', handleDragStart);
  2149. ownerDocument.addEventListener('dragend', handleDragEnd);
  2150. return () => {
  2151. ownerDocument.removeEventListener('dragstart', handleDragStart);
  2152. ownerDocument.removeEventListener('dragend', handleDragEnd);
  2153. };
  2154. }, []);
  2155. return isDragging;
  2156. };
  2157. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/blocks/widget-area/index.js
  2158. /**
  2159. * WordPress dependencies
  2160. */
  2161. /**
  2162. * Internal dependencies
  2163. */
  2164. const metadata = {
  2165. name: "core/widget-area",
  2166. category: "widgets",
  2167. attributes: {
  2168. id: {
  2169. type: "string"
  2170. },
  2171. name: {
  2172. type: "string"
  2173. }
  2174. },
  2175. supports: {
  2176. html: false,
  2177. inserter: false,
  2178. customClassName: false,
  2179. reusable: false,
  2180. __experimentalToolbar: false,
  2181. __experimentalParentSelector: false
  2182. },
  2183. editorStyle: "wp-block-widget-area-editor",
  2184. style: "wp-block-widget-area"
  2185. };
  2186. const {
  2187. name: widget_area_name
  2188. } = metadata;
  2189. const settings = {
  2190. title: (0,external_wp_i18n_namespaceObject.__)('Widget Area'),
  2191. description: (0,external_wp_i18n_namespaceObject.__)('A widget area container.'),
  2192. __experimentalLabel: _ref => {
  2193. let {
  2194. name: label
  2195. } = _ref;
  2196. return label;
  2197. },
  2198. edit: WidgetAreaEdit
  2199. };
  2200. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/error-boundary/index.js
  2201. /**
  2202. * WordPress dependencies
  2203. */
  2204. function CopyButton(_ref) {
  2205. let {
  2206. text,
  2207. children
  2208. } = _ref;
  2209. const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text);
  2210. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  2211. variant: "secondary",
  2212. ref: ref
  2213. }, children);
  2214. }
  2215. class ErrorBoundary extends external_wp_element_namespaceObject.Component {
  2216. constructor() {
  2217. super(...arguments);
  2218. this.reboot = this.reboot.bind(this);
  2219. this.state = {
  2220. error: null
  2221. };
  2222. }
  2223. componentDidCatch(error) {
  2224. this.setState({
  2225. error
  2226. });
  2227. }
  2228. reboot() {
  2229. this.props.onError();
  2230. }
  2231. render() {
  2232. const {
  2233. error
  2234. } = this.state;
  2235. if (!error) {
  2236. return this.props.children;
  2237. }
  2238. return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, {
  2239. className: "edit-widgets-error-boundary",
  2240. actions: [(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  2241. key: "recovery",
  2242. onClick: this.reboot,
  2243. variant: "secondary"
  2244. }, (0,external_wp_i18n_namespaceObject.__)('Attempt Recovery')), (0,external_wp_element_namespaceObject.createElement)(CopyButton, {
  2245. key: "copy-error",
  2246. text: error.stack
  2247. }, (0,external_wp_i18n_namespaceObject.__)('Copy Error'))]
  2248. }, (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.'));
  2249. }
  2250. }
  2251. ;// CONCATENATED MODULE: external ["wp","reusableBlocks"]
  2252. var external_wp_reusableBlocks_namespaceObject = window["wp"]["reusableBlocks"];
  2253. ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
  2254. var external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
  2255. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/keyboard-shortcuts/index.js
  2256. /**
  2257. * WordPress dependencies
  2258. */
  2259. /**
  2260. * Internal dependencies
  2261. */
  2262. function KeyboardShortcuts() {
  2263. const {
  2264. redo,
  2265. undo
  2266. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
  2267. const {
  2268. saveEditedWidgetAreas
  2269. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  2270. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-widgets/undo', event => {
  2271. undo();
  2272. event.preventDefault();
  2273. });
  2274. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-widgets/redo', event => {
  2275. redo();
  2276. event.preventDefault();
  2277. });
  2278. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-widgets/save', event => {
  2279. event.preventDefault();
  2280. saveEditedWidgetAreas();
  2281. });
  2282. return null;
  2283. }
  2284. function KeyboardShortcutsRegister() {
  2285. // Registering the shortcuts.
  2286. const {
  2287. registerShortcut
  2288. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
  2289. (0,external_wp_element_namespaceObject.useEffect)(() => {
  2290. registerShortcut({
  2291. name: 'core/edit-widgets/undo',
  2292. category: 'global',
  2293. description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'),
  2294. keyCombination: {
  2295. modifier: 'primary',
  2296. character: 'z'
  2297. }
  2298. });
  2299. registerShortcut({
  2300. name: 'core/edit-widgets/redo',
  2301. category: 'global',
  2302. description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'),
  2303. keyCombination: {
  2304. modifier: 'primaryShift',
  2305. character: 'z'
  2306. }
  2307. });
  2308. registerShortcut({
  2309. name: 'core/edit-widgets/save',
  2310. category: 'global',
  2311. description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'),
  2312. keyCombination: {
  2313. modifier: 'primary',
  2314. character: 's'
  2315. }
  2316. });
  2317. registerShortcut({
  2318. name: 'core/edit-widgets/keyboard-shortcuts',
  2319. category: 'main',
  2320. description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'),
  2321. keyCombination: {
  2322. modifier: 'access',
  2323. character: 'h'
  2324. }
  2325. });
  2326. registerShortcut({
  2327. name: 'core/edit-widgets/next-region',
  2328. category: 'global',
  2329. description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'),
  2330. keyCombination: {
  2331. modifier: 'ctrl',
  2332. character: '`'
  2333. },
  2334. aliases: [{
  2335. modifier: 'access',
  2336. character: 'n'
  2337. }]
  2338. });
  2339. registerShortcut({
  2340. name: 'core/edit-widgets/previous-region',
  2341. category: 'global',
  2342. description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'),
  2343. keyCombination: {
  2344. modifier: 'ctrlShift',
  2345. character: '`'
  2346. },
  2347. aliases: [{
  2348. modifier: 'access',
  2349. character: 'p'
  2350. }]
  2351. });
  2352. }, [registerShortcut]);
  2353. return null;
  2354. }
  2355. KeyboardShortcuts.Register = KeyboardShortcutsRegister;
  2356. /* harmony default export */ var keyboard_shortcuts = (KeyboardShortcuts);
  2357. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/hooks/use-last-selected-widget-area.js
  2358. /**
  2359. * WordPress dependencies
  2360. */
  2361. /**
  2362. * Internal dependencies
  2363. */
  2364. /**
  2365. * A react hook that returns the client id of the last widget area to have
  2366. * been selected, or to have a selected block within it.
  2367. *
  2368. * @return {string} clientId of the widget area last selected.
  2369. */
  2370. const useLastSelectedWidgetArea = () => (0,external_wp_data_namespaceObject.useSelect)(select => {
  2371. var _widgetAreasPost$bloc;
  2372. const {
  2373. getBlockSelectionEnd,
  2374. getBlockName
  2375. } = select(external_wp_blockEditor_namespaceObject.store);
  2376. const selectionEndClientId = getBlockSelectionEnd(); // If the selected block is a widget area, return its clientId.
  2377. if (getBlockName(selectionEndClientId) === 'core/widget-area') {
  2378. return selectionEndClientId;
  2379. }
  2380. const {
  2381. getParentWidgetAreaBlock
  2382. } = select(store_store);
  2383. const widgetAreaBlock = getParentWidgetAreaBlock(selectionEndClientId);
  2384. const widgetAreaBlockClientId = widgetAreaBlock === null || widgetAreaBlock === void 0 ? void 0 : widgetAreaBlock.clientId;
  2385. if (widgetAreaBlockClientId) {
  2386. return widgetAreaBlockClientId;
  2387. } // If no widget area has been selected, return the clientId of the first
  2388. // area.
  2389. const {
  2390. getEntityRecord
  2391. } = select(external_wp_coreData_namespaceObject.store);
  2392. const widgetAreasPost = getEntityRecord(KIND, POST_TYPE, buildWidgetAreasPostId());
  2393. return widgetAreasPost === null || widgetAreasPost === void 0 ? void 0 : (_widgetAreasPost$bloc = widgetAreasPost.blocks[0]) === null || _widgetAreasPost$bloc === void 0 ? void 0 : _widgetAreasPost$bloc.clientId;
  2394. }, []);
  2395. /* harmony default export */ var use_last_selected_widget_area = (useLastSelectedWidgetArea);
  2396. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/constants.js
  2397. const ALLOW_REUSABLE_BLOCKS = false;
  2398. const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;
  2399. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/widget-areas-block-editor-provider/index.js
  2400. /**
  2401. * External dependencies
  2402. */
  2403. /**
  2404. * WordPress dependencies
  2405. */
  2406. /**
  2407. * Internal dependencies
  2408. */
  2409. function WidgetAreasBlockEditorProvider(_ref) {
  2410. let {
  2411. blockEditorSettings,
  2412. children,
  2413. ...props
  2414. } = _ref;
  2415. const {
  2416. hasUploadPermissions,
  2417. reusableBlocks,
  2418. isFixedToolbarActive,
  2419. keepCaretInsideBlock
  2420. } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
  2421. hasUploadPermissions: (0,external_lodash_namespaceObject.defaultTo)(select(external_wp_coreData_namespaceObject.store).canUser('create', 'media'), true),
  2422. widgetAreas: select(store_store).getWidgetAreas(),
  2423. widgets: select(store_store).getWidgets(),
  2424. reusableBlocks: ALLOW_REUSABLE_BLOCKS ? select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_block') : [],
  2425. isFixedToolbarActive: !!select(external_wp_preferences_namespaceObject.store).get('core/edit-widgets', 'fixedToolbar'),
  2426. keepCaretInsideBlock: !!select(external_wp_preferences_namespaceObject.store).get('core/edit-widgets', 'keepCaretInsideBlock')
  2427. }), []);
  2428. const {
  2429. setIsInserterOpened
  2430. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  2431. const settings = (0,external_wp_element_namespaceObject.useMemo)(() => {
  2432. let mediaUploadBlockEditor;
  2433. if (hasUploadPermissions) {
  2434. mediaUploadBlockEditor = _ref2 => {
  2435. let {
  2436. onError,
  2437. ...argumentsObject
  2438. } = _ref2;
  2439. (0,external_wp_mediaUtils_namespaceObject.uploadMedia)({
  2440. wpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,
  2441. onError: _ref3 => {
  2442. let {
  2443. message
  2444. } = _ref3;
  2445. return onError(message);
  2446. },
  2447. ...argumentsObject
  2448. });
  2449. };
  2450. }
  2451. return { ...blockEditorSettings,
  2452. __experimentalReusableBlocks: reusableBlocks,
  2453. hasFixedToolbar: isFixedToolbarActive,
  2454. keepCaretInsideBlock,
  2455. mediaUpload: mediaUploadBlockEditor,
  2456. templateLock: 'all',
  2457. __experimentalSetIsInserterOpened: setIsInserterOpened
  2458. };
  2459. }, [blockEditorSettings, isFixedToolbarActive, keepCaretInsideBlock, hasUploadPermissions, reusableBlocks, setIsInserterOpened]);
  2460. const widgetAreaId = use_last_selected_widget_area();
  2461. const [blocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)(KIND, POST_TYPE, {
  2462. id: buildWidgetAreasPostId()
  2463. });
  2464. return (0,external_wp_element_namespaceObject.createElement)(external_wp_keyboardShortcuts_namespaceObject.ShortcutProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts.Register, null), (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcuts.Register, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SlotFillProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, _extends({
  2465. value: blocks,
  2466. onInput: onInput,
  2467. onChange: onChange,
  2468. settings: settings,
  2469. useSubRegistry: false
  2470. }, props), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.CopyHandler, null, children), (0,external_wp_element_namespaceObject.createElement)(external_wp_reusableBlocks_namespaceObject.ReusableBlocksMenuItems, {
  2471. rootClientId: widgetAreaId
  2472. }))));
  2473. }
  2474. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/cog.js
  2475. /**
  2476. * WordPress dependencies
  2477. */
  2478. const cog = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  2479. xmlns: "http://www.w3.org/2000/svg",
  2480. viewBox: "0 0 24 24"
  2481. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  2482. fillRule: "evenodd",
  2483. d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z",
  2484. clipRule: "evenodd"
  2485. }));
  2486. /* harmony default export */ var library_cog = (cog);
  2487. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/block-default.js
  2488. /**
  2489. * WordPress dependencies
  2490. */
  2491. const blockDefault = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  2492. xmlns: "http://www.w3.org/2000/svg",
  2493. viewBox: "0 0 24 24"
  2494. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  2495. 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"
  2496. }));
  2497. /* harmony default export */ var block_default = (blockDefault);
  2498. ;// CONCATENATED MODULE: external ["wp","url"]
  2499. var external_wp_url_namespaceObject = window["wp"]["url"];
  2500. ;// CONCATENATED MODULE: external ["wp","dom"]
  2501. var external_wp_dom_namespaceObject = window["wp"]["dom"];
  2502. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/sidebar/widget-areas.js
  2503. /**
  2504. * WordPress dependencies
  2505. */
  2506. /**
  2507. * Internal dependencies
  2508. */
  2509. function WidgetAreas(_ref) {
  2510. let {
  2511. selectedWidgetAreaId
  2512. } = _ref;
  2513. const widgetAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getWidgetAreas(), []);
  2514. const selectedWidgetArea = (0,external_wp_element_namespaceObject.useMemo)(() => selectedWidgetAreaId && (widgetAreas === null || widgetAreas === void 0 ? void 0 : widgetAreas.find(widgetArea => widgetArea.id === selectedWidgetAreaId)), [selectedWidgetAreaId, widgetAreas]);
  2515. let description;
  2516. if (!selectedWidgetArea) {
  2517. description = (0,external_wp_i18n_namespaceObject.__)('Widget Areas are global parts in your site’s layout that can accept blocks. These vary by theme, but are typically parts like your Sidebar or Footer.');
  2518. } else if (selectedWidgetAreaId === 'wp_inactive_widgets') {
  2519. description = (0,external_wp_i18n_namespaceObject.__)('Blocks in this Widget Area will not be displayed in your site.');
  2520. } else {
  2521. description = selectedWidgetArea.description;
  2522. }
  2523. return (0,external_wp_element_namespaceObject.createElement)("div", {
  2524. className: "edit-widgets-widget-areas"
  2525. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  2526. className: "edit-widgets-widget-areas__top-container"
  2527. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, {
  2528. icon: block_default
  2529. }), (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_element_namespaceObject.createElement)("p", {
  2530. // Use `dangerouslySetInnerHTML` to keep backwards
  2531. // compatibility. Basic markup in the description is an
  2532. // established feature of WordPress.
  2533. // @see https://github.com/WordPress/gutenberg/issues/33106
  2534. dangerouslySetInnerHTML: {
  2535. __html: (0,external_wp_dom_namespaceObject.safeHTML)(description)
  2536. }
  2537. }), (widgetAreas === null || widgetAreas === void 0 ? void 0 : widgetAreas.length) === 0 && (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Your theme does not contain any Widget Areas.')), !selectedWidgetArea && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  2538. href: (0,external_wp_url_namespaceObject.addQueryArgs)('customize.php', {
  2539. 'autofocus[panel]': 'widgets',
  2540. return: window.location.pathname
  2541. }),
  2542. variant: "tertiary"
  2543. }, (0,external_wp_i18n_namespaceObject.__)('Manage with live preview')))));
  2544. }
  2545. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/sidebar/index.js
  2546. /**
  2547. * External dependencies
  2548. */
  2549. /**
  2550. * WordPress dependencies
  2551. */
  2552. const SIDEBAR_ACTIVE_BY_DEFAULT = external_wp_element_namespaceObject.Platform.select({
  2553. web: true,
  2554. native: false
  2555. });
  2556. const BLOCK_INSPECTOR_IDENTIFIER = 'edit-widgets/block-inspector'; // Widget areas were one called block areas, so use 'edit-widgets/block-areas'
  2557. // for backwards compatibility.
  2558. const WIDGET_AREAS_IDENTIFIER = 'edit-widgets/block-areas';
  2559. /**
  2560. * Internal dependencies
  2561. */
  2562. function ComplementaryAreaTab(_ref) {
  2563. let {
  2564. identifier,
  2565. label,
  2566. isActive
  2567. } = _ref;
  2568. const {
  2569. enableComplementaryArea
  2570. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  2571. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  2572. onClick: () => enableComplementaryArea(store_store.name, identifier),
  2573. className: classnames_default()('edit-widgets-sidebar__panel-tab', {
  2574. 'is-active': isActive
  2575. }),
  2576. "aria-label": isActive ? // translators: %s: sidebar label e.g: "Widget Areas".
  2577. (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('%s (selected)'), label) : label,
  2578. "data-label": label
  2579. }, label);
  2580. }
  2581. function Sidebar() {
  2582. const {
  2583. enableComplementaryArea
  2584. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  2585. const {
  2586. currentArea,
  2587. hasSelectedNonAreaBlock,
  2588. isGeneralSidebarOpen,
  2589. selectedWidgetAreaBlock
  2590. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  2591. const {
  2592. getSelectedBlock,
  2593. getBlock,
  2594. getBlockParentsByBlockName
  2595. } = select(external_wp_blockEditor_namespaceObject.store);
  2596. const {
  2597. getActiveComplementaryArea
  2598. } = select(store);
  2599. const selectedBlock = getSelectedBlock();
  2600. const activeArea = getActiveComplementaryArea(store_store.name);
  2601. let currentSelection = activeArea;
  2602. if (!currentSelection) {
  2603. if (selectedBlock) {
  2604. currentSelection = BLOCK_INSPECTOR_IDENTIFIER;
  2605. } else {
  2606. currentSelection = WIDGET_AREAS_IDENTIFIER;
  2607. }
  2608. }
  2609. let widgetAreaBlock;
  2610. if (selectedBlock) {
  2611. if (selectedBlock.name === 'core/widget-area') {
  2612. widgetAreaBlock = selectedBlock;
  2613. } else {
  2614. widgetAreaBlock = getBlock(getBlockParentsByBlockName(selectedBlock.clientId, 'core/widget-area')[0]);
  2615. }
  2616. }
  2617. return {
  2618. currentArea: currentSelection,
  2619. hasSelectedNonAreaBlock: !!(selectedBlock && selectedBlock.name !== 'core/widget-area'),
  2620. isGeneralSidebarOpen: !!activeArea,
  2621. selectedWidgetAreaBlock: widgetAreaBlock
  2622. };
  2623. }, []); // currentArea, and isGeneralSidebarOpen are intentionally left out from the dependencies,
  2624. // because we want to run the effect when a block is selected/unselected and not when the sidebar state changes.
  2625. (0,external_wp_element_namespaceObject.useEffect)(() => {
  2626. if (hasSelectedNonAreaBlock && currentArea === WIDGET_AREAS_IDENTIFIER && isGeneralSidebarOpen) {
  2627. enableComplementaryArea('core/edit-widgets', BLOCK_INSPECTOR_IDENTIFIER);
  2628. }
  2629. if (!hasSelectedNonAreaBlock && currentArea === BLOCK_INSPECTOR_IDENTIFIER && isGeneralSidebarOpen) {
  2630. enableComplementaryArea('core/edit-widgets', WIDGET_AREAS_IDENTIFIER);
  2631. }
  2632. }, [hasSelectedNonAreaBlock, enableComplementaryArea]);
  2633. return (0,external_wp_element_namespaceObject.createElement)(complementary_area, {
  2634. className: "edit-widgets-sidebar",
  2635. header: (0,external_wp_element_namespaceObject.createElement)("ul", null, (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaTab, {
  2636. identifier: WIDGET_AREAS_IDENTIFIER,
  2637. label: selectedWidgetAreaBlock ? selectedWidgetAreaBlock.attributes.name : (0,external_wp_i18n_namespaceObject.__)('Widget Areas'),
  2638. isActive: currentArea === WIDGET_AREAS_IDENTIFIER
  2639. })), (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaTab, {
  2640. identifier: BLOCK_INSPECTOR_IDENTIFIER,
  2641. label: (0,external_wp_i18n_namespaceObject.__)('Block'),
  2642. isActive: currentArea === BLOCK_INSPECTOR_IDENTIFIER
  2643. }))),
  2644. headerClassName: "edit-widgets-sidebar__panel-tabs"
  2645. /* translators: button label text should, if possible, be under 16 characters. */
  2646. ,
  2647. title: (0,external_wp_i18n_namespaceObject.__)('Settings'),
  2648. closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close settings'),
  2649. scope: "core/edit-widgets",
  2650. identifier: currentArea,
  2651. icon: library_cog,
  2652. isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT
  2653. }, currentArea === WIDGET_AREAS_IDENTIFIER && (0,external_wp_element_namespaceObject.createElement)(WidgetAreas, {
  2654. selectedWidgetAreaId: selectedWidgetAreaBlock === null || selectedWidgetAreaBlock === void 0 ? void 0 : selectedWidgetAreaBlock.attributes.id
  2655. }), currentArea === BLOCK_INSPECTOR_IDENTIFIER && (hasSelectedNonAreaBlock ? (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockInspector, null) : // Pretend that Widget Areas are part of the UI by not
  2656. // showing the Block Inspector when one is selected.
  2657. (0,external_wp_element_namespaceObject.createElement)("span", {
  2658. className: "block-editor-block-inspector__no-blocks"
  2659. }, (0,external_wp_i18n_namespaceObject.__)('No block selected.'))));
  2660. }
  2661. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plus.js
  2662. /**
  2663. * WordPress dependencies
  2664. */
  2665. const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  2666. xmlns: "http://www.w3.org/2000/svg",
  2667. viewBox: "0 0 24 24"
  2668. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  2669. d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"
  2670. }));
  2671. /* harmony default export */ var library_plus = (plus);
  2672. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/list-view.js
  2673. /**
  2674. * WordPress dependencies
  2675. */
  2676. const listView = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  2677. viewBox: "0 0 24 24",
  2678. xmlns: "http://www.w3.org/2000/svg"
  2679. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  2680. d: "M13.8 5.2H3v1.5h10.8V5.2zm-3.6 12v1.5H21v-1.5H10.2zm7.2-6H6.6v1.5h10.8v-1.5z"
  2681. }));
  2682. /* harmony default export */ var list_view = (listView);
  2683. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/save-button/index.js
  2684. /**
  2685. * WordPress dependencies
  2686. */
  2687. /**
  2688. * Internal dependencies
  2689. */
  2690. function SaveButton() {
  2691. const {
  2692. hasEditedWidgetAreaIds,
  2693. isSaving
  2694. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  2695. var _getEditedWidgetAreas;
  2696. const {
  2697. getEditedWidgetAreas,
  2698. isSavingWidgetAreas
  2699. } = select(store_store);
  2700. return {
  2701. hasEditedWidgetAreaIds: ((_getEditedWidgetAreas = getEditedWidgetAreas()) === null || _getEditedWidgetAreas === void 0 ? void 0 : _getEditedWidgetAreas.length) > 0,
  2702. isSaving: isSavingWidgetAreas()
  2703. };
  2704. }, []);
  2705. const {
  2706. saveEditedWidgetAreas
  2707. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  2708. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  2709. variant: "primary",
  2710. isBusy: isSaving,
  2711. "aria-disabled": isSaving,
  2712. onClick: isSaving ? undefined : saveEditedWidgetAreas,
  2713. disabled: !hasEditedWidgetAreaIds
  2714. }, isSaving ? (0,external_wp_i18n_namespaceObject.__)('Saving…') : (0,external_wp_i18n_namespaceObject.__)('Update'));
  2715. }
  2716. /* harmony default export */ var save_button = (SaveButton);
  2717. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/undo.js
  2718. /**
  2719. * WordPress dependencies
  2720. */
  2721. const undo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  2722. xmlns: "http://www.w3.org/2000/svg",
  2723. viewBox: "0 0 24 24"
  2724. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  2725. d: "M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"
  2726. }));
  2727. /* harmony default export */ var library_undo = (undo);
  2728. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/redo.js
  2729. /**
  2730. * WordPress dependencies
  2731. */
  2732. const redo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  2733. xmlns: "http://www.w3.org/2000/svg",
  2734. viewBox: "0 0 24 24"
  2735. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  2736. d: "M15.6 6.5l-1.1 1 2.9 3.3H8c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.3-.5h9.2L14.5 15l1.1 1.1 4.6-4.6-4.6-5z"
  2737. }));
  2738. /* harmony default export */ var library_redo = (redo);
  2739. ;// CONCATENATED MODULE: external ["wp","keycodes"]
  2740. var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
  2741. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/header/undo-redo/undo.js
  2742. /**
  2743. * WordPress dependencies
  2744. */
  2745. function UndoButton() {
  2746. const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasUndo(), []);
  2747. const {
  2748. undo
  2749. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
  2750. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  2751. icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo,
  2752. label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
  2753. shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z') // If there are no undo levels we don't want to actually disable this
  2754. // button, because it will remove focus for keyboard users.
  2755. // See: https://github.com/WordPress/gutenberg/issues/3486
  2756. ,
  2757. "aria-disabled": !hasUndo,
  2758. onClick: hasUndo ? undo : undefined
  2759. });
  2760. }
  2761. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/header/undo-redo/redo.js
  2762. /**
  2763. * WordPress dependencies
  2764. */
  2765. function RedoButton() {
  2766. const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasRedo(), []);
  2767. const {
  2768. redo
  2769. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
  2770. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  2771. icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo,
  2772. label: (0,external_wp_i18n_namespaceObject.__)('Redo'),
  2773. shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') // If there are no undo levels we don't want to actually disable this
  2774. // button, because it will remove focus for keyboard users.
  2775. // See: https://github.com/WordPress/gutenberg/issues/3486
  2776. ,
  2777. "aria-disabled": !hasRedo,
  2778. onClick: hasRedo ? redo : undefined
  2779. });
  2780. }
  2781. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/external.js
  2782. /**
  2783. * WordPress dependencies
  2784. */
  2785. const external = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  2786. xmlns: "http://www.w3.org/2000/svg",
  2787. viewBox: "0 0 24 24"
  2788. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  2789. d: "M18.2 17c0 .7-.6 1.2-1.2 1.2H7c-.7 0-1.2-.6-1.2-1.2V7c0-.7.6-1.2 1.2-1.2h3.2V4.2H7C5.5 4.2 4.2 5.5 4.2 7v10c0 1.5 1.2 2.8 2.8 2.8h10c1.5 0 2.8-1.2 2.8-2.8v-3.6h-1.5V17zM14.9 3v1.5h3.7l-6.4 6.4 1.1 1.1 6.4-6.4v3.7h1.5V3h-6.3z"
  2790. }));
  2791. /* harmony default export */ var library_external = (external);
  2792. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/keyboard-shortcut-help-modal/config.js
  2793. /**
  2794. * WordPress dependencies
  2795. */
  2796. const textFormattingShortcuts = [{
  2797. keyCombination: {
  2798. modifier: 'primary',
  2799. character: 'b'
  2800. },
  2801. description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.')
  2802. }, {
  2803. keyCombination: {
  2804. modifier: 'primary',
  2805. character: 'i'
  2806. },
  2807. description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.')
  2808. }, {
  2809. keyCombination: {
  2810. modifier: 'primary',
  2811. character: 'k'
  2812. },
  2813. description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.')
  2814. }, {
  2815. keyCombination: {
  2816. modifier: 'primaryShift',
  2817. character: 'k'
  2818. },
  2819. description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.')
  2820. }, {
  2821. keyCombination: {
  2822. modifier: 'primary',
  2823. character: 'u'
  2824. },
  2825. description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.')
  2826. }];
  2827. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/keyboard-shortcut-help-modal/shortcut.js
  2828. /**
  2829. * External dependencies
  2830. */
  2831. /**
  2832. * WordPress dependencies
  2833. */
  2834. function KeyCombination(_ref) {
  2835. let {
  2836. keyCombination,
  2837. forceAriaLabel
  2838. } = _ref;
  2839. const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character;
  2840. const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character;
  2841. return (0,external_wp_element_namespaceObject.createElement)("kbd", {
  2842. className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-key-combination",
  2843. "aria-label": forceAriaLabel || ariaLabel
  2844. }, (0,external_lodash_namespaceObject.castArray)(shortcut).map((character, index) => {
  2845. if (character === '+') {
  2846. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, {
  2847. key: index
  2848. }, character);
  2849. }
  2850. return (0,external_wp_element_namespaceObject.createElement)("kbd", {
  2851. key: index,
  2852. className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-key"
  2853. }, character);
  2854. }));
  2855. }
  2856. function Shortcut(_ref2) {
  2857. let {
  2858. description,
  2859. keyCombination,
  2860. aliases = [],
  2861. ariaLabel
  2862. } = _ref2;
  2863. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  2864. className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-description"
  2865. }, description), (0,external_wp_element_namespaceObject.createElement)("div", {
  2866. className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-term"
  2867. }, (0,external_wp_element_namespaceObject.createElement)(KeyCombination, {
  2868. keyCombination: keyCombination,
  2869. forceAriaLabel: ariaLabel
  2870. }), aliases.map((alias, index) => (0,external_wp_element_namespaceObject.createElement)(KeyCombination, {
  2871. keyCombination: alias,
  2872. forceAriaLabel: ariaLabel,
  2873. key: index
  2874. }))));
  2875. }
  2876. /* harmony default export */ var keyboard_shortcut_help_modal_shortcut = (Shortcut);
  2877. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js
  2878. /**
  2879. * WordPress dependencies
  2880. */
  2881. /**
  2882. * Internal dependencies
  2883. */
  2884. function DynamicShortcut(_ref) {
  2885. let {
  2886. name
  2887. } = _ref;
  2888. const {
  2889. keyCombination,
  2890. description,
  2891. aliases
  2892. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  2893. const {
  2894. getShortcutKeyCombination,
  2895. getShortcutDescription,
  2896. getShortcutAliases
  2897. } = select(external_wp_keyboardShortcuts_namespaceObject.store);
  2898. return {
  2899. keyCombination: getShortcutKeyCombination(name),
  2900. aliases: getShortcutAliases(name),
  2901. description: getShortcutDescription(name)
  2902. };
  2903. }, [name]);
  2904. if (!keyCombination) {
  2905. return null;
  2906. }
  2907. return (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcut_help_modal_shortcut, {
  2908. keyCombination: keyCombination,
  2909. description: description,
  2910. aliases: aliases
  2911. });
  2912. }
  2913. /* harmony default export */ var dynamic_shortcut = (DynamicShortcut);
  2914. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/keyboard-shortcut-help-modal/index.js
  2915. /**
  2916. * External dependencies
  2917. */
  2918. /**
  2919. * WordPress dependencies
  2920. */
  2921. /**
  2922. * Internal dependencies
  2923. */
  2924. const ShortcutList = _ref => {
  2925. let {
  2926. shortcuts
  2927. } = _ref;
  2928. return (
  2929. /*
  2930. * Disable reason: The `list` ARIA role is redundant but
  2931. * Safari+VoiceOver won't announce the list otherwise.
  2932. */
  2933. /* eslint-disable jsx-a11y/no-redundant-roles */
  2934. (0,external_wp_element_namespaceObject.createElement)("ul", {
  2935. className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-list",
  2936. role: "list"
  2937. }, shortcuts.map((shortcut, index) => (0,external_wp_element_namespaceObject.createElement)("li", {
  2938. className: "edit-widgets-keyboard-shortcut-help-modal__shortcut",
  2939. key: index
  2940. }, (0,external_lodash_namespaceObject.isString)(shortcut) ? (0,external_wp_element_namespaceObject.createElement)(dynamic_shortcut, {
  2941. name: shortcut
  2942. }) : (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcut_help_modal_shortcut, shortcut))))
  2943. /* eslint-enable jsx-a11y/no-redundant-roles */
  2944. );
  2945. };
  2946. const ShortcutSection = _ref2 => {
  2947. let {
  2948. title,
  2949. shortcuts,
  2950. className
  2951. } = _ref2;
  2952. return (0,external_wp_element_namespaceObject.createElement)("section", {
  2953. className: classnames_default()('edit-widgets-keyboard-shortcut-help-modal__section', className)
  2954. }, !!title && (0,external_wp_element_namespaceObject.createElement)("h2", {
  2955. className: "edit-widgets-keyboard-shortcut-help-modal__section-title"
  2956. }, title), (0,external_wp_element_namespaceObject.createElement)(ShortcutList, {
  2957. shortcuts: shortcuts
  2958. }));
  2959. };
  2960. const ShortcutCategorySection = _ref3 => {
  2961. let {
  2962. title,
  2963. categoryName,
  2964. additionalShortcuts = []
  2965. } = _ref3;
  2966. const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => {
  2967. return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName);
  2968. }, [categoryName]);
  2969. return (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
  2970. title: title,
  2971. shortcuts: categoryShortcuts.concat(additionalShortcuts)
  2972. });
  2973. };
  2974. function KeyboardShortcutHelpModal(_ref4) {
  2975. let {
  2976. isModalActive,
  2977. toggleModal
  2978. } = _ref4;
  2979. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-widgets/keyboard-shortcuts', toggleModal, {
  2980. bindGlobal: true
  2981. });
  2982. if (!isModalActive) {
  2983. return null;
  2984. }
  2985. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
  2986. className: "edit-widgets-keyboard-shortcut-help-modal",
  2987. title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
  2988. closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
  2989. onRequestClose: toggleModal
  2990. }, (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
  2991. className: "edit-widgets-keyboard-shortcut-help-modal__main-shortcuts",
  2992. shortcuts: ['core/edit-widgets/keyboard-shortcuts']
  2993. }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
  2994. title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'),
  2995. categoryName: "global"
  2996. }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
  2997. title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'),
  2998. categoryName: "selection"
  2999. }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
  3000. title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'),
  3001. categoryName: "block",
  3002. additionalShortcuts: [{
  3003. keyCombination: {
  3004. character: '/'
  3005. },
  3006. description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'),
  3007. /* translators: The forward-slash character. e.g. '/'. */
  3008. ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash')
  3009. }]
  3010. }), (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
  3011. title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'),
  3012. shortcuts: textFormattingShortcuts
  3013. }));
  3014. }
  3015. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/more-menu/tools-more-menu-group.js
  3016. /**
  3017. * External dependencies
  3018. */
  3019. /**
  3020. * WordPress dependencies
  3021. */
  3022. const {
  3023. Fill: ToolsMoreMenuGroup,
  3024. Slot
  3025. } = (0,external_wp_components_namespaceObject.createSlotFill)('EditWidgetsToolsMoreMenuGroup');
  3026. ToolsMoreMenuGroup.Slot = _ref => {
  3027. let {
  3028. fillProps
  3029. } = _ref;
  3030. return (0,external_wp_element_namespaceObject.createElement)(Slot, {
  3031. fillProps: fillProps
  3032. }, fills => !(0,external_lodash_namespaceObject.isEmpty)(fills) && fills);
  3033. };
  3034. /* harmony default export */ var tools_more_menu_group = (ToolsMoreMenuGroup);
  3035. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/more-menu/index.js
  3036. /**
  3037. * WordPress dependencies
  3038. */
  3039. /**
  3040. * Internal dependencies
  3041. */
  3042. function MoreMenu() {
  3043. const [isKeyboardShortcutsModalActive, setIsKeyboardShortcutsModalVisible] = (0,external_wp_element_namespaceObject.useState)(false);
  3044. const toggleKeyboardShortcutsModal = () => setIsKeyboardShortcutsModalVisible(!isKeyboardShortcutsModalActive);
  3045. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-widgets/keyboard-shortcuts', toggleKeyboardShortcutsModal);
  3046. const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
  3047. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(MoreMenuDropdown, null, onClose => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isLargeViewport && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  3048. label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun')
  3049. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
  3050. scope: "core/edit-widgets",
  3051. name: "fixedToolbar",
  3052. label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'),
  3053. info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'),
  3054. messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated'),
  3055. messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated')
  3056. })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  3057. label: (0,external_wp_i18n_namespaceObject.__)('Tools')
  3058. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  3059. onClick: () => {
  3060. setIsKeyboardShortcutsModalVisible(true);
  3061. },
  3062. shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h')
  3063. }, (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts')), (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
  3064. scope: "core/edit-widgets",
  3065. name: "welcomeGuide",
  3066. label: (0,external_wp_i18n_namespaceObject.__)('Welcome Guide')
  3067. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  3068. role: "menuitem",
  3069. icon: library_external,
  3070. href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/block-based-widgets-editor/'),
  3071. target: "_blank",
  3072. rel: "noopener noreferrer"
  3073. }, (0,external_wp_i18n_namespaceObject.__)('Help'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  3074. as: "span"
  3075. },
  3076. /* translators: accessibility text */
  3077. (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)'))), (0,external_wp_element_namespaceObject.createElement)(tools_more_menu_group.Slot, {
  3078. fillProps: {
  3079. onClose
  3080. }
  3081. })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  3082. label: (0,external_wp_i18n_namespaceObject.__)('Preferences')
  3083. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
  3084. scope: "core/edit-widgets",
  3085. name: "keepCaretInsideBlock",
  3086. label: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block'),
  3087. info: (0,external_wp_i18n_namespaceObject.__)('Aids screen readers by stopping text caret from leaving blocks.'),
  3088. messageActivated: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block activated'),
  3089. messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block deactivated')
  3090. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
  3091. scope: "core/edit-widgets",
  3092. name: "themeStyles",
  3093. info: (0,external_wp_i18n_namespaceObject.__)('Make the editor look like your theme.'),
  3094. label: (0,external_wp_i18n_namespaceObject.__)('Use theme styles')
  3095. }), isLargeViewport && (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
  3096. scope: "core/edit-widgets",
  3097. name: "showBlockBreadcrumbs",
  3098. label: (0,external_wp_i18n_namespaceObject.__)('Display block breadcrumbs'),
  3099. info: (0,external_wp_i18n_namespaceObject.__)('Shows block breadcrumbs at the bottom of the editor.'),
  3100. messageActivated: (0,external_wp_i18n_namespaceObject.__)('Display block breadcrumbs activated'),
  3101. messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Display block breadcrumbs deactivated')
  3102. })))), (0,external_wp_element_namespaceObject.createElement)(KeyboardShortcutHelpModal, {
  3103. isModalActive: isKeyboardShortcutsModalActive,
  3104. toggleModal: toggleKeyboardShortcutsModal
  3105. }));
  3106. }
  3107. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/header/index.js
  3108. /**
  3109. * WordPress dependencies
  3110. */
  3111. /**
  3112. * Internal dependencies
  3113. */
  3114. function Header() {
  3115. const isMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
  3116. const inserterButton = (0,external_wp_element_namespaceObject.useRef)();
  3117. const widgetAreaClientId = use_last_selected_widget_area();
  3118. const isLastSelectedWidgetAreaOpen = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getIsWidgetAreaOpen(widgetAreaClientId), [widgetAreaClientId]);
  3119. const {
  3120. isInserterOpen,
  3121. isListViewOpen
  3122. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  3123. const {
  3124. isInserterOpened,
  3125. isListViewOpened
  3126. } = select(store_store);
  3127. return {
  3128. isInserterOpen: isInserterOpened(),
  3129. isListViewOpen: isListViewOpened()
  3130. };
  3131. }, []);
  3132. const {
  3133. setIsWidgetAreaOpen,
  3134. setIsInserterOpened,
  3135. setIsListViewOpened
  3136. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  3137. const {
  3138. selectBlock
  3139. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
  3140. const handleClick = () => {
  3141. if (isInserterOpen) {
  3142. // Focusing the inserter button closes the inserter popover.
  3143. setIsInserterOpened(false);
  3144. } else {
  3145. if (!isLastSelectedWidgetAreaOpen) {
  3146. // Select the last selected block if hasn't already.
  3147. selectBlock(widgetAreaClientId); // Open the last selected widget area when opening the inserter.
  3148. setIsWidgetAreaOpen(widgetAreaClientId, true);
  3149. } // The DOM updates resulting from selectBlock() and setIsInserterOpened() calls are applied the
  3150. // same tick and pretty much in a random order. The inserter is closed if any other part of the
  3151. // app receives focus. If selectBlock() happens to take effect after setIsInserterOpened() then
  3152. // the inserter is visible for a brief moment and then gets auto-closed due to focus moving to
  3153. // the selected block.
  3154. window.requestAnimationFrame(() => setIsInserterOpened(true));
  3155. }
  3156. };
  3157. const toggleListView = (0,external_wp_element_namespaceObject.useCallback)(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
  3158. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  3159. className: "edit-widgets-header"
  3160. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  3161. className: "edit-widgets-header__navigable-toolbar-wrapper"
  3162. }, isMediumViewport && (0,external_wp_element_namespaceObject.createElement)("h1", {
  3163. className: "edit-widgets-header__title"
  3164. }, (0,external_wp_i18n_namespaceObject.__)('Widgets')), !isMediumViewport && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  3165. as: "h1",
  3166. className: "edit-widgets-header__title"
  3167. }, (0,external_wp_i18n_namespaceObject.__)('Widgets')), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.NavigableToolbar, {
  3168. className: "edit-widgets-header-toolbar",
  3169. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document tools')
  3170. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
  3171. ref: inserterButton,
  3172. as: external_wp_components_namespaceObject.Button,
  3173. className: "edit-widgets-header-toolbar__inserter-toggle",
  3174. variant: "primary",
  3175. isPressed: isInserterOpen,
  3176. onMouseDown: event => {
  3177. event.preventDefault();
  3178. },
  3179. onClick: handleClick,
  3180. icon: library_plus
  3181. /* translators: button label text should, if possible, be under 16
  3182. characters. */
  3183. ,
  3184. label: (0,external_wp_i18n_namespaceObject._x)('Toggle block inserter', 'Generic label for block inserter button')
  3185. }), isMediumViewport && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(UndoButton, null), (0,external_wp_element_namespaceObject.createElement)(RedoButton, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
  3186. as: external_wp_components_namespaceObject.Button,
  3187. className: "edit-widgets-header-toolbar__list-view-toggle",
  3188. icon: list_view,
  3189. isPressed: isListViewOpen
  3190. /* translators: button label text should, if possible, be under 16 characters. */
  3191. ,
  3192. label: (0,external_wp_i18n_namespaceObject.__)('List View'),
  3193. onClick: toggleListView
  3194. })))), (0,external_wp_element_namespaceObject.createElement)("div", {
  3195. className: "edit-widgets-header__actions"
  3196. }, (0,external_wp_element_namespaceObject.createElement)(save_button, null), (0,external_wp_element_namespaceObject.createElement)(pinned_items.Slot, {
  3197. scope: "core/edit-widgets"
  3198. }), (0,external_wp_element_namespaceObject.createElement)(MoreMenu, null))));
  3199. }
  3200. /* harmony default export */ var header = (Header);
  3201. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/notices/index.js
  3202. /**
  3203. * External dependencies
  3204. */
  3205. /**
  3206. * WordPress dependencies
  3207. */
  3208. function Notices() {
  3209. const {
  3210. removeNotice
  3211. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
  3212. const {
  3213. notices
  3214. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  3215. return {
  3216. notices: select(external_wp_notices_namespaceObject.store).getNotices()
  3217. };
  3218. }, []);
  3219. const dismissibleNotices = (0,external_lodash_namespaceObject.filter)(notices, {
  3220. isDismissible: true,
  3221. type: 'default'
  3222. });
  3223. const nonDismissibleNotices = (0,external_lodash_namespaceObject.filter)(notices, {
  3224. isDismissible: false,
  3225. type: 'default'
  3226. });
  3227. const snackbarNotices = (0,external_lodash_namespaceObject.filter)(notices, {
  3228. type: 'snackbar'
  3229. });
  3230. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NoticeList, {
  3231. notices: nonDismissibleNotices,
  3232. className: "edit-widgets-notices__pinned"
  3233. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NoticeList, {
  3234. notices: dismissibleNotices,
  3235. className: "edit-widgets-notices__dismissible",
  3236. onRemove: removeNotice
  3237. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SnackbarList, {
  3238. notices: snackbarNotices,
  3239. className: "edit-widgets-notices__snackbar",
  3240. onRemove: removeNotice
  3241. }));
  3242. }
  3243. /* harmony default export */ var notices = (Notices);
  3244. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/widget-areas-block-editor-content/index.js
  3245. /**
  3246. * WordPress dependencies
  3247. */
  3248. /**
  3249. * Internal dependencies
  3250. */
  3251. function WidgetAreasBlockEditorContent(_ref) {
  3252. let {
  3253. blockEditorSettings
  3254. } = _ref;
  3255. const hasThemeStyles = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_preferences_namespaceObject.store).get('core/edit-widgets', 'themeStyles'), []);
  3256. const styles = (0,external_wp_element_namespaceObject.useMemo)(() => {
  3257. return hasThemeStyles ? blockEditorSettings.styles : [];
  3258. }, [blockEditorSettings, hasThemeStyles]);
  3259. return (0,external_wp_element_namespaceObject.createElement)("div", {
  3260. className: "edit-widgets-block-editor"
  3261. }, (0,external_wp_element_namespaceObject.createElement)(notices, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockTools, null, (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcuts, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, {
  3262. styles: styles
  3263. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSelectionClearer, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.WritingFlow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.ObserveTyping, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockList, {
  3264. className: "edit-widgets-main-block-list"
  3265. }))))));
  3266. }
  3267. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close.js
  3268. /**
  3269. * WordPress dependencies
  3270. */
  3271. const close_close = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  3272. xmlns: "http://www.w3.org/2000/svg",
  3273. viewBox: "0 0 24 24"
  3274. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  3275. 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"
  3276. }));
  3277. /* harmony default export */ var library_close = (close_close);
  3278. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/hooks/use-widget-library-insertion-point.js
  3279. /**
  3280. * WordPress dependencies
  3281. */
  3282. /**
  3283. * Internal dependencies
  3284. */
  3285. const useWidgetLibraryInsertionPoint = () => {
  3286. const firstRootId = (0,external_wp_data_namespaceObject.useSelect)(select => {
  3287. var _widgetAreasPost$bloc;
  3288. // Default to the first widget area
  3289. const {
  3290. getEntityRecord
  3291. } = select(external_wp_coreData_namespaceObject.store);
  3292. const widgetAreasPost = getEntityRecord(KIND, POST_TYPE, buildWidgetAreasPostId());
  3293. return widgetAreasPost === null || widgetAreasPost === void 0 ? void 0 : (_widgetAreasPost$bloc = widgetAreasPost.blocks[0]) === null || _widgetAreasPost$bloc === void 0 ? void 0 : _widgetAreasPost$bloc.clientId;
  3294. }, []);
  3295. return (0,external_wp_data_namespaceObject.useSelect)(select => {
  3296. const {
  3297. getBlockRootClientId,
  3298. getBlockSelectionEnd,
  3299. getBlockOrder,
  3300. getBlockIndex
  3301. } = select(external_wp_blockEditor_namespaceObject.store);
  3302. const insertionPoint = select(store_store).__experimentalGetInsertionPoint(); // "Browse all" in the quick inserter will set the rootClientId to the current block.
  3303. // Otherwise, it will just be undefined, and we'll have to handle it differently below.
  3304. if (insertionPoint.rootClientId) {
  3305. return insertionPoint;
  3306. }
  3307. const clientId = getBlockSelectionEnd() || firstRootId;
  3308. const rootClientId = getBlockRootClientId(clientId); // If the selected block is at the root level, it's a widget area and
  3309. // blocks can't be inserted here. Return this block as the root and the
  3310. // last child clientId indicating insertion at the end.
  3311. if (clientId && rootClientId === '') {
  3312. return {
  3313. rootClientId: clientId,
  3314. insertionIndex: getBlockOrder(clientId).length
  3315. };
  3316. }
  3317. return {
  3318. rootClientId,
  3319. insertionIndex: getBlockIndex(clientId) + 1
  3320. };
  3321. }, [firstRootId]);
  3322. };
  3323. /* harmony default export */ var use_widget_library_insertion_point = (useWidgetLibraryInsertionPoint);
  3324. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/secondary-sidebar/inserter-sidebar.js
  3325. /**
  3326. * WordPress dependencies
  3327. */
  3328. /**
  3329. * Internal dependencies
  3330. */
  3331. function InserterSidebar() {
  3332. const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
  3333. const {
  3334. rootClientId,
  3335. insertionIndex
  3336. } = use_widget_library_insertion_point();
  3337. const {
  3338. setIsInserterOpened
  3339. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  3340. const closeInserter = (0,external_wp_element_namespaceObject.useCallback)(() => {
  3341. return setIsInserterOpened(false);
  3342. }, [setIsInserterOpened]);
  3343. const TagName = !isMobileViewport ? external_wp_components_namespaceObject.VisuallyHidden : 'div';
  3344. const [inserterDialogRef, inserterDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
  3345. onClose: closeInserter,
  3346. focusOnMount: null
  3347. });
  3348. const libraryRef = (0,external_wp_element_namespaceObject.useRef)();
  3349. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3350. libraryRef.current.focusSearch();
  3351. }, []);
  3352. return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
  3353. ref: inserterDialogRef
  3354. }, inserterDialogProps, {
  3355. className: "edit-widgets-layout__inserter-panel"
  3356. }), (0,external_wp_element_namespaceObject.createElement)(TagName, {
  3357. className: "edit-widgets-layout__inserter-panel-header"
  3358. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  3359. icon: library_close,
  3360. onClick: closeInserter,
  3361. label: (0,external_wp_i18n_namespaceObject.__)('Close block inserter')
  3362. })), (0,external_wp_element_namespaceObject.createElement)("div", {
  3363. className: "edit-widgets-layout__inserter-panel-content"
  3364. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLibrary, {
  3365. showInserterHelpPanel: true,
  3366. shouldFocusBlock: isMobileViewport,
  3367. rootClientId: rootClientId,
  3368. __experimentalInsertionIndex: insertionIndex,
  3369. ref: libraryRef
  3370. })));
  3371. }
  3372. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/secondary-sidebar/list-view-sidebar.js
  3373. /**
  3374. * WordPress dependencies
  3375. */
  3376. /**
  3377. * Internal dependencies
  3378. */
  3379. function ListViewSidebar() {
  3380. const {
  3381. setIsListViewOpened
  3382. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  3383. const focusOnMountRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)('firstElement');
  3384. const headerFocusReturnRef = (0,external_wp_compose_namespaceObject.useFocusReturn)();
  3385. const contentFocusReturnRef = (0,external_wp_compose_namespaceObject.useFocusReturn)();
  3386. function closeOnEscape(event) {
  3387. if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
  3388. event.preventDefault();
  3389. setIsListViewOpened(false);
  3390. }
  3391. }
  3392. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(ListViewSidebar);
  3393. const labelId = `edit-widgets-editor__list-view-panel-label-${instanceId}`;
  3394. return (// eslint-disable-next-line jsx-a11y/no-static-element-interactions
  3395. (0,external_wp_element_namespaceObject.createElement)("div", {
  3396. "aria-labelledby": labelId,
  3397. className: "edit-widgets-editor__list-view-panel",
  3398. onKeyDown: closeOnEscape
  3399. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  3400. className: "edit-widgets-editor__list-view-panel-header",
  3401. ref: headerFocusReturnRef
  3402. }, (0,external_wp_element_namespaceObject.createElement)("strong", {
  3403. id: labelId
  3404. }, (0,external_wp_i18n_namespaceObject.__)('List View')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  3405. icon: close_small,
  3406. label: (0,external_wp_i18n_namespaceObject.__)('Close List View Sidebar'),
  3407. onClick: () => setIsListViewOpened(false)
  3408. })), (0,external_wp_element_namespaceObject.createElement)("div", {
  3409. className: "edit-widgets-editor__list-view-panel-content",
  3410. ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([contentFocusReturnRef, focusOnMountRef])
  3411. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalListView, {
  3412. showNestedBlocks: true,
  3413. __experimentalHideContainerBlockActions: true,
  3414. __experimentalFeatures: true,
  3415. __experimentalPersistentListViewFeatures: true
  3416. })))
  3417. );
  3418. }
  3419. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/secondary-sidebar/index.js
  3420. /**
  3421. * WordPress dependencies
  3422. */
  3423. /**
  3424. * Internal dependencies
  3425. */
  3426. /**
  3427. * Internal dependencies
  3428. */
  3429. function SecondarySidebar() {
  3430. const {
  3431. isInserterOpen,
  3432. isListViewOpen
  3433. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  3434. const {
  3435. isInserterOpened,
  3436. isListViewOpened
  3437. } = select(store_store);
  3438. return {
  3439. isInserterOpen: isInserterOpened(),
  3440. isListViewOpen: isListViewOpened()
  3441. };
  3442. }, []);
  3443. if (isInserterOpen) {
  3444. return (0,external_wp_element_namespaceObject.createElement)(InserterSidebar, null);
  3445. }
  3446. if (isListViewOpen) {
  3447. return (0,external_wp_element_namespaceObject.createElement)(ListViewSidebar, null);
  3448. }
  3449. return null;
  3450. }
  3451. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/layout/interface.js
  3452. /**
  3453. * WordPress dependencies
  3454. */
  3455. /**
  3456. * Internal dependencies
  3457. */
  3458. const interfaceLabels = {
  3459. /* translators: accessibility text for the widgets screen top bar landmark region. */
  3460. header: (0,external_wp_i18n_namespaceObject.__)('Widgets top bar'),
  3461. /* translators: accessibility text for the widgets screen content landmark region. */
  3462. body: (0,external_wp_i18n_namespaceObject.__)('Widgets and blocks'),
  3463. /* translators: accessibility text for the widgets screen settings landmark region. */
  3464. sidebar: (0,external_wp_i18n_namespaceObject.__)('Widgets settings'),
  3465. /* translators: accessibility text for the widgets screen footer landmark region. */
  3466. footer: (0,external_wp_i18n_namespaceObject.__)('Widgets footer')
  3467. };
  3468. function Interface(_ref) {
  3469. let {
  3470. blockEditorSettings
  3471. } = _ref;
  3472. const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
  3473. const isHugeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('huge', '>=');
  3474. const {
  3475. setIsInserterOpened,
  3476. setIsListViewOpened,
  3477. closeGeneralSidebar
  3478. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  3479. const {
  3480. hasBlockBreadCrumbsEnabled,
  3481. hasSidebarEnabled,
  3482. isInserterOpened,
  3483. isListViewOpened,
  3484. previousShortcut,
  3485. nextShortcut
  3486. } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
  3487. hasSidebarEnabled: !!select(store).getActiveComplementaryArea(store_store.name),
  3488. isInserterOpened: !!select(store_store).isInserterOpened(),
  3489. isListViewOpened: !!select(store_store).isListViewOpened(),
  3490. hasBlockBreadCrumbsEnabled: !!select(external_wp_preferences_namespaceObject.store).get('core/edit-widgets', 'showBlockBreadcrumbs'),
  3491. previousShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-widgets/previous-region'),
  3492. nextShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-widgets/next-region')
  3493. }), []); // Inserter and Sidebars are mutually exclusive
  3494. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3495. if (hasSidebarEnabled && !isHugeViewport) {
  3496. setIsInserterOpened(false);
  3497. setIsListViewOpened(false);
  3498. }
  3499. }, [hasSidebarEnabled, isHugeViewport]);
  3500. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3501. if ((isInserterOpened || isListViewOpened) && !isHugeViewport) {
  3502. closeGeneralSidebar();
  3503. }
  3504. }, [isInserterOpened, isListViewOpened, isHugeViewport]);
  3505. const secondarySidebarLabel = isListViewOpened ? (0,external_wp_i18n_namespaceObject.__)('List View') : (0,external_wp_i18n_namespaceObject.__)('Block Library');
  3506. const hasSecondarySidebar = isListViewOpened || isInserterOpened;
  3507. return (0,external_wp_element_namespaceObject.createElement)(interface_skeleton, {
  3508. labels: { ...interfaceLabels,
  3509. secondarySidebar: secondarySidebarLabel
  3510. },
  3511. header: (0,external_wp_element_namespaceObject.createElement)(header, null),
  3512. secondarySidebar: hasSecondarySidebar && (0,external_wp_element_namespaceObject.createElement)(SecondarySidebar, null),
  3513. sidebar: hasSidebarEnabled && (0,external_wp_element_namespaceObject.createElement)(complementary_area.Slot, {
  3514. scope: "core/edit-widgets"
  3515. }),
  3516. content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(WidgetAreasBlockEditorContent, {
  3517. blockEditorSettings: blockEditorSettings
  3518. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockStyles.Slot, {
  3519. scope: "core/block-inspector"
  3520. })),
  3521. footer: hasBlockBreadCrumbsEnabled && !isMobileViewport && (0,external_wp_element_namespaceObject.createElement)("div", {
  3522. className: "edit-widgets-layout__footer"
  3523. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockBreadcrumb, {
  3524. rootLabelText: (0,external_wp_i18n_namespaceObject.__)('Widgets')
  3525. })),
  3526. shortcuts: {
  3527. previous: previousShortcut,
  3528. next: nextShortcut
  3529. }
  3530. });
  3531. }
  3532. /* harmony default export */ var layout_interface = (Interface);
  3533. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/layout/unsaved-changes-warning.js
  3534. /**
  3535. * WordPress dependencies
  3536. */
  3537. /**
  3538. * Internal dependencies
  3539. */
  3540. /**
  3541. * Warns the user if there are unsaved changes before leaving the editor.
  3542. *
  3543. * This is a duplicate of the component implemented in the editor package.
  3544. * Duplicated here as edit-widgets doesn't depend on editor.
  3545. *
  3546. * @return {WPComponent} The component.
  3547. */
  3548. function UnsavedChangesWarning() {
  3549. const isDirty = (0,external_wp_data_namespaceObject.useSelect)(select => {
  3550. const {
  3551. getEditedWidgetAreas
  3552. } = select(store_store);
  3553. const editedWidgetAreas = getEditedWidgetAreas();
  3554. return (editedWidgetAreas === null || editedWidgetAreas === void 0 ? void 0 : editedWidgetAreas.length) > 0;
  3555. }, []);
  3556. (0,external_wp_element_namespaceObject.useEffect)(() => {
  3557. /**
  3558. * Warns the user if there are unsaved changes before leaving the editor.
  3559. *
  3560. * @param {Event} event `beforeunload` event.
  3561. *
  3562. * @return {?string} Warning prompt message, if unsaved changes exist.
  3563. */
  3564. const warnIfUnsavedChanges = event => {
  3565. if (isDirty) {
  3566. event.returnValue = (0,external_wp_i18n_namespaceObject.__)('You have unsaved changes. If you proceed, they will be lost.');
  3567. return event.returnValue;
  3568. }
  3569. };
  3570. window.addEventListener('beforeunload', warnIfUnsavedChanges);
  3571. return () => {
  3572. window.removeEventListener('beforeunload', warnIfUnsavedChanges);
  3573. };
  3574. }, [isDirty]);
  3575. return null;
  3576. }
  3577. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/welcome-guide/index.js
  3578. /**
  3579. * WordPress dependencies
  3580. */
  3581. /**
  3582. * Internal dependencies
  3583. */
  3584. function WelcomeGuide() {
  3585. var _widgetAreas$filter$l;
  3586. const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_preferences_namespaceObject.store).get('core/edit-widgets', 'welcomeGuide'), []);
  3587. const {
  3588. toggle
  3589. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
  3590. const widgetAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getWidgetAreas({
  3591. per_page: -1
  3592. }), []);
  3593. if (!isActive) {
  3594. return null;
  3595. }
  3596. const isEntirelyBlockWidgets = widgetAreas === null || widgetAreas === void 0 ? void 0 : widgetAreas.every(widgetArea => widgetArea.id === 'wp_inactive_widgets' || widgetArea.widgets.every(widgetId => widgetId.startsWith('block-')));
  3597. const numWidgetAreas = (_widgetAreas$filter$l = widgetAreas === null || widgetAreas === void 0 ? void 0 : widgetAreas.filter(widgetArea => widgetArea.id !== 'wp_inactive_widgets').length) !== null && _widgetAreas$filter$l !== void 0 ? _widgetAreas$filter$l : 0;
  3598. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Guide, {
  3599. className: "edit-widgets-welcome-guide",
  3600. contentLabel: (0,external_wp_i18n_namespaceObject.__)('Welcome to block Widgets'),
  3601. finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get started'),
  3602. onFinish: () => toggle('core/edit-widgets', 'welcomeGuide'),
  3603. pages: [{
  3604. image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
  3605. nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.svg",
  3606. animatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.gif"
  3607. }),
  3608. content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
  3609. className: "edit-widgets-welcome-guide__heading"
  3610. }, (0,external_wp_i18n_namespaceObject.__)('Welcome to block Widgets')), isEntirelyBlockWidgets ? (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("p", {
  3611. className: "edit-widgets-welcome-guide__text"
  3612. }, (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %s: Number of block areas in the current theme.
  3613. (0,external_wp_i18n_namespaceObject._n)('Your theme provides %s “block” area for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.', 'Your theme provides %s different “block” areas for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.', numWidgetAreas), numWidgetAreas))) : (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("p", {
  3614. className: "edit-widgets-welcome-guide__text"
  3615. }, (0,external_wp_i18n_namespaceObject.__)('You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.')), (0,external_wp_element_namespaceObject.createElement)("p", {
  3616. className: "edit-widgets-welcome-guide__text"
  3617. }, (0,external_wp_element_namespaceObject.createElement)("strong", null, (0,external_wp_i18n_namespaceObject.__)('Want to stick with the old widgets?')), ' ', (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
  3618. href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/plugins/classic-widgets/')
  3619. }, (0,external_wp_i18n_namespaceObject.__)('Get the Classic Widgets plugin.')))))
  3620. }, {
  3621. image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
  3622. nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-editor.svg",
  3623. animatedSrc: "https://s.w.org/images/block-editor/welcome-editor.gif"
  3624. }),
  3625. content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
  3626. className: "edit-widgets-welcome-guide__heading"
  3627. }, (0,external_wp_i18n_namespaceObject.__)('Make each block your own')), (0,external_wp_element_namespaceObject.createElement)("p", {
  3628. className: "edit-widgets-welcome-guide__text"
  3629. }, (0,external_wp_i18n_namespaceObject.__)('Each block comes with its own set of controls for changing things like color, width, and alignment. These will show and hide automatically when you have a block selected.')))
  3630. }, {
  3631. image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
  3632. nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-library.svg",
  3633. animatedSrc: "https://s.w.org/images/block-editor/welcome-library.gif"
  3634. }),
  3635. content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
  3636. className: "edit-widgets-welcome-guide__heading"
  3637. }, (0,external_wp_i18n_namespaceObject.__)('Get to know the block library')), (0,external_wp_element_namespaceObject.createElement)("p", {
  3638. className: "edit-widgets-welcome-guide__text"
  3639. }, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('All of the blocks available to you live in the block library. You’ll find it wherever you see the <InserterIconImage /> icon.'), {
  3640. InserterIconImage: (0,external_wp_element_namespaceObject.createElement)("img", {
  3641. className: "edit-widgets-welcome-guide__inserter-icon",
  3642. alt: (0,external_wp_i18n_namespaceObject.__)('inserter'),
  3643. src: "data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='18' height='18' rx='2' fill='%231E1E1E'/%3E%3Cpath d='M9.22727 4V14M4 8.77273H14' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E%0A"
  3644. })
  3645. })))
  3646. }, {
  3647. image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
  3648. nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg",
  3649. animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif"
  3650. }),
  3651. content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
  3652. className: "edit-widgets-welcome-guide__heading"
  3653. }, (0,external_wp_i18n_namespaceObject.__)('Learn how to use the block editor')), (0,external_wp_element_namespaceObject.createElement)("p", {
  3654. className: "edit-widgets-welcome-guide__text"
  3655. }, (0,external_wp_i18n_namespaceObject.__)('New to the block editor? Want to learn more about using it? '), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
  3656. href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/wordpress-editor/')
  3657. }, (0,external_wp_i18n_namespaceObject.__)("Here's a detailed guide."))))
  3658. }]
  3659. });
  3660. }
  3661. function WelcomeGuideImage(_ref) {
  3662. let {
  3663. nonAnimatedSrc,
  3664. animatedSrc
  3665. } = _ref;
  3666. return (0,external_wp_element_namespaceObject.createElement)("picture", {
  3667. className: "edit-widgets-welcome-guide__image"
  3668. }, (0,external_wp_element_namespaceObject.createElement)("source", {
  3669. srcSet: nonAnimatedSrc,
  3670. media: "(prefers-reduced-motion: reduce)"
  3671. }), (0,external_wp_element_namespaceObject.createElement)("img", {
  3672. src: animatedSrc,
  3673. width: "312",
  3674. height: "240",
  3675. alt: ""
  3676. }));
  3677. }
  3678. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/components/layout/index.js
  3679. /**
  3680. * WordPress dependencies
  3681. */
  3682. /**
  3683. * Internal dependencies
  3684. */
  3685. function Layout(_ref) {
  3686. let {
  3687. blockEditorSettings,
  3688. onError
  3689. } = _ref;
  3690. const {
  3691. createErrorNotice
  3692. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
  3693. function onPluginAreaError(name) {
  3694. createErrorNotice((0,external_wp_i18n_namespaceObject.sprintf)(
  3695. /* translators: %s: plugin name */
  3696. (0,external_wp_i18n_namespaceObject.__)('The "%s" plugin has encountered an error and cannot be rendered.'), name));
  3697. }
  3698. return (0,external_wp_element_namespaceObject.createElement)(ErrorBoundary, {
  3699. onError: onError
  3700. }, (0,external_wp_element_namespaceObject.createElement)(WidgetAreasBlockEditorProvider, {
  3701. blockEditorSettings: blockEditorSettings
  3702. }, (0,external_wp_element_namespaceObject.createElement)(layout_interface, {
  3703. blockEditorSettings: blockEditorSettings
  3704. }), (0,external_wp_element_namespaceObject.createElement)(Sidebar, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_plugins_namespaceObject.PluginArea, {
  3705. onError: onPluginAreaError
  3706. }), (0,external_wp_element_namespaceObject.createElement)(UnsavedChangesWarning, null), (0,external_wp_element_namespaceObject.createElement)(WelcomeGuide, null)));
  3707. }
  3708. /* harmony default export */ var layout = (Layout);
  3709. ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-widgets/build-module/index.js
  3710. /**
  3711. * WordPress dependencies
  3712. */
  3713. /**
  3714. * Internal dependencies
  3715. */
  3716. const disabledBlocks = ['core/more', 'core/freeform', 'core/template-part', ...(ALLOW_REUSABLE_BLOCKS ? [] : ['core/block'])];
  3717. /**
  3718. * Reinitializes the editor after the user chooses to reboot the editor after
  3719. * an unhandled error occurs, replacing previously mounted editor element using
  3720. * an initial state from prior to the crash.
  3721. *
  3722. * @param {Element} target DOM node in which editor is rendered.
  3723. * @param {?Object} settings Editor settings object.
  3724. */
  3725. function reinitializeEditor(target, settings) {
  3726. (0,external_wp_element_namespaceObject.unmountComponentAtNode)(target);
  3727. const reboot = reinitializeEditor.bind(null, target, settings);
  3728. (0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(layout, {
  3729. blockEditorSettings: settings,
  3730. onError: reboot
  3731. }), target);
  3732. }
  3733. /**
  3734. * Initializes the block editor in the widgets screen.
  3735. *
  3736. * @param {string} id ID of the root element to render the screen in.
  3737. * @param {Object} settings Block editor settings.
  3738. */
  3739. function initialize(id, settings) {
  3740. const target = document.getElementById(id);
  3741. const reboot = reinitializeEditor.bind(null, target, settings);
  3742. const coreBlocks = (0,external_wp_blockLibrary_namespaceObject.__experimentalGetCoreBlocks)().filter(block => {
  3743. return !(disabledBlocks.includes(block.name) || block.name.startsWith('core/post') || block.name.startsWith('core/query') || block.name.startsWith('core/site') || block.name.startsWith('core/navigation'));
  3744. });
  3745. (0,external_wp_data_namespaceObject.dispatch)(external_wp_preferences_namespaceObject.store).setDefaults('core/edit-widgets', {
  3746. fixedToolbar: false,
  3747. welcomeGuide: true,
  3748. showBlockBreadcrumbs: true,
  3749. themeStyles: true
  3750. });
  3751. (0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).__experimentalReapplyBlockTypeFilters();
  3752. (0,external_wp_blockLibrary_namespaceObject.registerCoreBlocks)(coreBlocks);
  3753. (0,external_wp_widgets_namespaceObject.registerLegacyWidgetBlock)();
  3754. if (false) {}
  3755. (0,external_wp_widgets_namespaceObject.registerLegacyWidgetVariations)(settings);
  3756. registerBlock(widget_area_namespaceObject);
  3757. (0,external_wp_widgets_namespaceObject.registerWidgetGroupBlock)();
  3758. settings.__experimentalFetchLinkSuggestions = (search, searchOptions) => (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings); // As we are unregistering `core/freeform` to avoid the Classic block, we must
  3759. // replace it with something as the default freeform content handler. Failure to
  3760. // do this will result in errors in the default block parser.
  3761. // see: https://github.com/WordPress/gutenberg/issues/33097
  3762. (0,external_wp_blocks_namespaceObject.setFreeformContentHandlerName)('core/html');
  3763. (0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(layout, {
  3764. blockEditorSettings: settings,
  3765. onError: reboot
  3766. }), target);
  3767. }
  3768. /**
  3769. * Function to register an individual block.
  3770. *
  3771. * @param {Object} block The block to be registered.
  3772. *
  3773. */
  3774. const registerBlock = block => {
  3775. if (!block) {
  3776. return;
  3777. }
  3778. const {
  3779. metadata,
  3780. settings,
  3781. name
  3782. } = block;
  3783. if (metadata) {
  3784. (0,external_wp_blocks_namespaceObject.unstable__bootstrapServerSideBlockDefinitions)({
  3785. [name]: metadata
  3786. });
  3787. }
  3788. (0,external_wp_blocks_namespaceObject.registerBlockType)(name, settings);
  3789. };
  3790. }();
  3791. (window.wp = window.wp || {}).editWidgets = __webpack_exports__;
  3792. /******/ })()
  3793. ;