editor.js 380 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903
  1. /******/ (function() { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ 6411:
  4. /***/ (function(module, exports) {
  5. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  6. autosize 4.0.4
  7. license: MIT
  8. http://www.jacklmoore.com/autosize
  9. */
  10. (function (global, factory) {
  11. if (true) {
  12. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  13. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  14. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  15. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  16. } else { var mod; }
  17. })(this, function (module, exports) {
  18. 'use strict';
  19. var map = typeof Map === "function" ? new Map() : function () {
  20. var keys = [];
  21. var values = [];
  22. return {
  23. has: function has(key) {
  24. return keys.indexOf(key) > -1;
  25. },
  26. get: function get(key) {
  27. return values[keys.indexOf(key)];
  28. },
  29. set: function set(key, value) {
  30. if (keys.indexOf(key) === -1) {
  31. keys.push(key);
  32. values.push(value);
  33. }
  34. },
  35. delete: function _delete(key) {
  36. var index = keys.indexOf(key);
  37. if (index > -1) {
  38. keys.splice(index, 1);
  39. values.splice(index, 1);
  40. }
  41. }
  42. };
  43. }();
  44. var createEvent = function createEvent(name) {
  45. return new Event(name, { bubbles: true });
  46. };
  47. try {
  48. new Event('test');
  49. } catch (e) {
  50. // IE does not support `new Event()`
  51. createEvent = function createEvent(name) {
  52. var evt = document.createEvent('Event');
  53. evt.initEvent(name, true, false);
  54. return evt;
  55. };
  56. }
  57. function assign(ta) {
  58. if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has(ta)) return;
  59. var heightOffset = null;
  60. var clientWidth = null;
  61. var cachedHeight = null;
  62. function init() {
  63. var style = window.getComputedStyle(ta, null);
  64. if (style.resize === 'vertical') {
  65. ta.style.resize = 'none';
  66. } else if (style.resize === 'both') {
  67. ta.style.resize = 'horizontal';
  68. }
  69. if (style.boxSizing === 'content-box') {
  70. heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
  71. } else {
  72. heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
  73. }
  74. // Fix when a textarea is not on document body and heightOffset is Not a Number
  75. if (isNaN(heightOffset)) {
  76. heightOffset = 0;
  77. }
  78. update();
  79. }
  80. function changeOverflow(value) {
  81. {
  82. // Chrome/Safari-specific fix:
  83. // When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space
  84. // made available by removing the scrollbar. The following forces the necessary text reflow.
  85. var width = ta.style.width;
  86. ta.style.width = '0px';
  87. // Force reflow:
  88. /* jshint ignore:start */
  89. ta.offsetWidth;
  90. /* jshint ignore:end */
  91. ta.style.width = width;
  92. }
  93. ta.style.overflowY = value;
  94. }
  95. function getParentOverflows(el) {
  96. var arr = [];
  97. while (el && el.parentNode && el.parentNode instanceof Element) {
  98. if (el.parentNode.scrollTop) {
  99. arr.push({
  100. node: el.parentNode,
  101. scrollTop: el.parentNode.scrollTop
  102. });
  103. }
  104. el = el.parentNode;
  105. }
  106. return arr;
  107. }
  108. function resize() {
  109. if (ta.scrollHeight === 0) {
  110. // If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
  111. return;
  112. }
  113. var overflows = getParentOverflows(ta);
  114. var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)
  115. ta.style.height = '';
  116. ta.style.height = ta.scrollHeight + heightOffset + 'px';
  117. // used to check if an update is actually necessary on window.resize
  118. clientWidth = ta.clientWidth;
  119. // prevents scroll-position jumping
  120. overflows.forEach(function (el) {
  121. el.node.scrollTop = el.scrollTop;
  122. });
  123. if (docTop) {
  124. document.documentElement.scrollTop = docTop;
  125. }
  126. }
  127. function update() {
  128. resize();
  129. var styleHeight = Math.round(parseFloat(ta.style.height));
  130. var computed = window.getComputedStyle(ta, null);
  131. // Using offsetHeight as a replacement for computed.height in IE, because IE does not account use of border-box
  132. var actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(computed.height)) : ta.offsetHeight;
  133. // The actual height not matching the style height (set via the resize method) indicates that
  134. // the max-height has been exceeded, in which case the overflow should be allowed.
  135. if (actualHeight < styleHeight) {
  136. if (computed.overflowY === 'hidden') {
  137. changeOverflow('scroll');
  138. resize();
  139. actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
  140. }
  141. } else {
  142. // Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
  143. if (computed.overflowY !== 'hidden') {
  144. changeOverflow('hidden');
  145. resize();
  146. actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
  147. }
  148. }
  149. if (cachedHeight !== actualHeight) {
  150. cachedHeight = actualHeight;
  151. var evt = createEvent('autosize:resized');
  152. try {
  153. ta.dispatchEvent(evt);
  154. } catch (err) {
  155. // Firefox will throw an error on dispatchEvent for a detached element
  156. // https://bugzilla.mozilla.org/show_bug.cgi?id=889376
  157. }
  158. }
  159. }
  160. var pageResize = function pageResize() {
  161. if (ta.clientWidth !== clientWidth) {
  162. update();
  163. }
  164. };
  165. var destroy = function (style) {
  166. window.removeEventListener('resize', pageResize, false);
  167. ta.removeEventListener('input', update, false);
  168. ta.removeEventListener('keyup', update, false);
  169. ta.removeEventListener('autosize:destroy', destroy, false);
  170. ta.removeEventListener('autosize:update', update, false);
  171. Object.keys(style).forEach(function (key) {
  172. ta.style[key] = style[key];
  173. });
  174. map.delete(ta);
  175. }.bind(ta, {
  176. height: ta.style.height,
  177. resize: ta.style.resize,
  178. overflowY: ta.style.overflowY,
  179. overflowX: ta.style.overflowX,
  180. wordWrap: ta.style.wordWrap
  181. });
  182. ta.addEventListener('autosize:destroy', destroy, false);
  183. // IE9 does not fire onpropertychange or oninput for deletions,
  184. // so binding to onkeyup to catch most of those events.
  185. // There is no way that I know of to detect something like 'cut' in IE9.
  186. if ('onpropertychange' in ta && 'oninput' in ta) {
  187. ta.addEventListener('keyup', update, false);
  188. }
  189. window.addEventListener('resize', pageResize, false);
  190. ta.addEventListener('input', update, false);
  191. ta.addEventListener('autosize:update', update, false);
  192. ta.style.overflowX = 'hidden';
  193. ta.style.wordWrap = 'break-word';
  194. map.set(ta, {
  195. destroy: destroy,
  196. update: update
  197. });
  198. init();
  199. }
  200. function destroy(ta) {
  201. var methods = map.get(ta);
  202. if (methods) {
  203. methods.destroy();
  204. }
  205. }
  206. function update(ta) {
  207. var methods = map.get(ta);
  208. if (methods) {
  209. methods.update();
  210. }
  211. }
  212. var autosize = null;
  213. // Do nothing in Node.js environment and IE8 (or lower)
  214. if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') {
  215. autosize = function autosize(el) {
  216. return el;
  217. };
  218. autosize.destroy = function (el) {
  219. return el;
  220. };
  221. autosize.update = function (el) {
  222. return el;
  223. };
  224. } else {
  225. autosize = function autosize(el, options) {
  226. if (el) {
  227. Array.prototype.forEach.call(el.length ? el : [el], function (x) {
  228. return assign(x, options);
  229. });
  230. }
  231. return el;
  232. };
  233. autosize.destroy = function (el) {
  234. if (el) {
  235. Array.prototype.forEach.call(el.length ? el : [el], destroy);
  236. }
  237. return el;
  238. };
  239. autosize.update = function (el) {
  240. if (el) {
  241. Array.prototype.forEach.call(el.length ? el : [el], update);
  242. }
  243. return el;
  244. };
  245. }
  246. exports.default = autosize;
  247. module.exports = exports['default'];
  248. });
  249. /***/ }),
  250. /***/ 4403:
  251. /***/ (function(module, exports) {
  252. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  253. Copyright (c) 2018 Jed Watson.
  254. Licensed under the MIT License (MIT), see
  255. http://jedwatson.github.io/classnames
  256. */
  257. /* global define */
  258. (function () {
  259. 'use strict';
  260. var hasOwn = {}.hasOwnProperty;
  261. function classNames() {
  262. var classes = [];
  263. for (var i = 0; i < arguments.length; i++) {
  264. var arg = arguments[i];
  265. if (!arg) continue;
  266. var argType = typeof arg;
  267. if (argType === 'string' || argType === 'number') {
  268. classes.push(arg);
  269. } else if (Array.isArray(arg)) {
  270. if (arg.length) {
  271. var inner = classNames.apply(null, arg);
  272. if (inner) {
  273. classes.push(inner);
  274. }
  275. }
  276. } else if (argType === 'object') {
  277. if (arg.toString === Object.prototype.toString) {
  278. for (var key in arg) {
  279. if (hasOwn.call(arg, key) && arg[key]) {
  280. classes.push(key);
  281. }
  282. }
  283. } else {
  284. classes.push(arg.toString());
  285. }
  286. }
  287. }
  288. return classes.join(' ');
  289. }
  290. if ( true && module.exports) {
  291. classNames.default = classNames;
  292. module.exports = classNames;
  293. } else if (true) {
  294. // register as 'classnames', consistent with npm package name
  295. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  296. return classNames;
  297. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  298. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  299. } else {}
  300. }());
  301. /***/ }),
  302. /***/ 4827:
  303. /***/ (function(module) {
  304. // This code has been refactored for 140 bytes
  305. // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js
  306. var computedStyle = function (el, prop, getComputedStyle) {
  307. getComputedStyle = window.getComputedStyle;
  308. // In one fell swoop
  309. return (
  310. // If we have getComputedStyle
  311. getComputedStyle ?
  312. // Query it
  313. // TODO: From CSS-Query notes, we might need (node, null) for FF
  314. getComputedStyle(el) :
  315. // Otherwise, we are in IE and use currentStyle
  316. el.currentStyle
  317. )[
  318. // Switch to camelCase for CSSOM
  319. // DEV: Grabbed from jQuery
  320. // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194
  321. // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597
  322. prop.replace(/-(\w)/gi, function (word, letter) {
  323. return letter.toUpperCase();
  324. })
  325. ];
  326. };
  327. module.exports = computedStyle;
  328. /***/ }),
  329. /***/ 9894:
  330. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  331. // Load in dependencies
  332. var computedStyle = __webpack_require__(4827);
  333. /**
  334. * Calculate the `line-height` of a given node
  335. * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM.
  336. * @returns {Number} `line-height` of the element in pixels
  337. */
  338. function lineHeight(node) {
  339. // Grab the line-height via style
  340. var lnHeightStr = computedStyle(node, 'line-height');
  341. var lnHeight = parseFloat(lnHeightStr, 10);
  342. // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em')
  343. if (lnHeightStr === lnHeight + '') {
  344. // Save the old lineHeight style and update the em unit to the element
  345. var _lnHeightStyle = node.style.lineHeight;
  346. node.style.lineHeight = lnHeightStr + 'em';
  347. // Calculate the em based height
  348. lnHeightStr = computedStyle(node, 'line-height');
  349. lnHeight = parseFloat(lnHeightStr, 10);
  350. // Revert the lineHeight style
  351. if (_lnHeightStyle) {
  352. node.style.lineHeight = _lnHeightStyle;
  353. } else {
  354. delete node.style.lineHeight;
  355. }
  356. }
  357. // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt)
  358. // DEV: `em` units are converted to `pt` in IE6
  359. // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length
  360. if (lnHeightStr.indexOf('pt') !== -1) {
  361. lnHeight *= 4;
  362. lnHeight /= 3;
  363. // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm)
  364. } else if (lnHeightStr.indexOf('mm') !== -1) {
  365. lnHeight *= 96;
  366. lnHeight /= 25.4;
  367. // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm)
  368. } else if (lnHeightStr.indexOf('cm') !== -1) {
  369. lnHeight *= 96;
  370. lnHeight /= 2.54;
  371. // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in)
  372. } else if (lnHeightStr.indexOf('in') !== -1) {
  373. lnHeight *= 96;
  374. // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc)
  375. } else if (lnHeightStr.indexOf('pc') !== -1) {
  376. lnHeight *= 16;
  377. }
  378. // Continue our computation
  379. lnHeight = Math.round(lnHeight);
  380. // If the line-height is "normal", calculate by font-size
  381. if (lnHeightStr === 'normal') {
  382. // Create a temporary node
  383. var nodeName = node.nodeName;
  384. var _node = document.createElement(nodeName);
  385. _node.innerHTML = '&nbsp;';
  386. // If we have a text area, reset it to only 1 row
  387. // https://github.com/twolfson/line-height/issues/4
  388. if (nodeName.toUpperCase() === 'TEXTAREA') {
  389. _node.setAttribute('rows', '1');
  390. }
  391. // Set the font-size of the element
  392. var fontSizeStr = computedStyle(node, 'font-size');
  393. _node.style.fontSize = fontSizeStr;
  394. // Remove default padding/border which can affect offset height
  395. // https://github.com/twolfson/line-height/issues/4
  396. // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight
  397. _node.style.padding = '0px';
  398. _node.style.border = '0px';
  399. // Append it to the body
  400. var body = document.body;
  401. body.appendChild(_node);
  402. // Assume the line height of the element is the height
  403. var height = _node.offsetHeight;
  404. lnHeight = height;
  405. // Remove our child from the DOM
  406. body.removeChild(_node);
  407. }
  408. // Return the calculated height
  409. return lnHeight;
  410. }
  411. // Export lineHeight
  412. module.exports = lineHeight;
  413. /***/ }),
  414. /***/ 5372:
  415. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  416. "use strict";
  417. /**
  418. * Copyright (c) 2013-present, Facebook, Inc.
  419. *
  420. * This source code is licensed under the MIT license found in the
  421. * LICENSE file in the root directory of this source tree.
  422. */
  423. var ReactPropTypesSecret = __webpack_require__(9567);
  424. function emptyFunction() {}
  425. function emptyFunctionWithReset() {}
  426. emptyFunctionWithReset.resetWarningCache = emptyFunction;
  427. module.exports = function() {
  428. function shim(props, propName, componentName, location, propFullName, secret) {
  429. if (secret === ReactPropTypesSecret) {
  430. // It is still safe when called from React.
  431. return;
  432. }
  433. var err = new Error(
  434. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  435. 'Use PropTypes.checkPropTypes() to call them. ' +
  436. 'Read more at http://fb.me/use-check-prop-types'
  437. );
  438. err.name = 'Invariant Violation';
  439. throw err;
  440. };
  441. shim.isRequired = shim;
  442. function getShim() {
  443. return shim;
  444. };
  445. // Important!
  446. // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
  447. var ReactPropTypes = {
  448. array: shim,
  449. bigint: shim,
  450. bool: shim,
  451. func: shim,
  452. number: shim,
  453. object: shim,
  454. string: shim,
  455. symbol: shim,
  456. any: shim,
  457. arrayOf: getShim,
  458. element: shim,
  459. elementType: shim,
  460. instanceOf: getShim,
  461. node: shim,
  462. objectOf: getShim,
  463. oneOf: getShim,
  464. oneOfType: getShim,
  465. shape: getShim,
  466. exact: getShim,
  467. checkPropTypes: emptyFunctionWithReset,
  468. resetWarningCache: emptyFunction
  469. };
  470. ReactPropTypes.PropTypes = ReactPropTypes;
  471. return ReactPropTypes;
  472. };
  473. /***/ }),
  474. /***/ 2652:
  475. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  476. /**
  477. * Copyright (c) 2013-present, Facebook, Inc.
  478. *
  479. * This source code is licensed under the MIT license found in the
  480. * LICENSE file in the root directory of this source tree.
  481. */
  482. if (false) { var throwOnDirectAccess, ReactIs; } else {
  483. // By explicitly using `prop-types` you are opting into new production behavior.
  484. // http://fb.me/prop-types-in-prod
  485. module.exports = __webpack_require__(5372)();
  486. }
  487. /***/ }),
  488. /***/ 9567:
  489. /***/ (function(module) {
  490. "use strict";
  491. /**
  492. * Copyright (c) 2013-present, Facebook, Inc.
  493. *
  494. * This source code is licensed under the MIT license found in the
  495. * LICENSE file in the root directory of this source tree.
  496. */
  497. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  498. module.exports = ReactPropTypesSecret;
  499. /***/ }),
  500. /***/ 5438:
  501. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  502. "use strict";
  503. var __extends = (this && this.__extends) || (function () {
  504. var extendStatics = Object.setPrototypeOf ||
  505. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  506. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  507. return function (d, b) {
  508. extendStatics(d, b);
  509. function __() { this.constructor = d; }
  510. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  511. };
  512. })();
  513. var __assign = (this && this.__assign) || Object.assign || function(t) {
  514. for (var s, i = 1, n = arguments.length; i < n; i++) {
  515. s = arguments[i];
  516. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  517. t[p] = s[p];
  518. }
  519. return t;
  520. };
  521. var __rest = (this && this.__rest) || function (s, e) {
  522. var t = {};
  523. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  524. t[p] = s[p];
  525. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  526. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  527. t[p[i]] = s[p[i]];
  528. return t;
  529. };
  530. exports.__esModule = true;
  531. var React = __webpack_require__(9196);
  532. var PropTypes = __webpack_require__(2652);
  533. var autosize = __webpack_require__(6411);
  534. var _getLineHeight = __webpack_require__(9894);
  535. var getLineHeight = _getLineHeight;
  536. var RESIZED = "autosize:resized";
  537. /**
  538. * A light replacement for built-in textarea component
  539. * which automaticaly adjusts its height to match the content
  540. */
  541. var TextareaAutosizeClass = /** @class */ (function (_super) {
  542. __extends(TextareaAutosizeClass, _super);
  543. function TextareaAutosizeClass() {
  544. var _this = _super !== null && _super.apply(this, arguments) || this;
  545. _this.state = {
  546. lineHeight: null
  547. };
  548. _this.textarea = null;
  549. _this.onResize = function (e) {
  550. if (_this.props.onResize) {
  551. _this.props.onResize(e);
  552. }
  553. };
  554. _this.updateLineHeight = function () {
  555. if (_this.textarea) {
  556. _this.setState({
  557. lineHeight: getLineHeight(_this.textarea)
  558. });
  559. }
  560. };
  561. _this.onChange = function (e) {
  562. var onChange = _this.props.onChange;
  563. _this.currentValue = e.currentTarget.value;
  564. onChange && onChange(e);
  565. };
  566. return _this;
  567. }
  568. TextareaAutosizeClass.prototype.componentDidMount = function () {
  569. var _this = this;
  570. var _a = this.props, maxRows = _a.maxRows, async = _a.async;
  571. if (typeof maxRows === "number") {
  572. this.updateLineHeight();
  573. }
  574. if (typeof maxRows === "number" || async) {
  575. /*
  576. the defer is needed to:
  577. - force "autosize" to activate the scrollbar when this.props.maxRows is passed
  578. - support StyledComponents (see #71)
  579. */
  580. setTimeout(function () { return _this.textarea && autosize(_this.textarea); });
  581. }
  582. else {
  583. this.textarea && autosize(this.textarea);
  584. }
  585. if (this.textarea) {
  586. this.textarea.addEventListener(RESIZED, this.onResize);
  587. }
  588. };
  589. TextareaAutosizeClass.prototype.componentWillUnmount = function () {
  590. if (this.textarea) {
  591. this.textarea.removeEventListener(RESIZED, this.onResize);
  592. autosize.destroy(this.textarea);
  593. }
  594. };
  595. TextareaAutosizeClass.prototype.render = function () {
  596. var _this = this;
  597. var _a = this, _b = _a.props, onResize = _b.onResize, maxRows = _b.maxRows, onChange = _b.onChange, style = _b.style, innerRef = _b.innerRef, children = _b.children, props = __rest(_b, ["onResize", "maxRows", "onChange", "style", "innerRef", "children"]), lineHeight = _a.state.lineHeight;
  598. var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null;
  599. return (React.createElement("textarea", __assign({}, props, { onChange: this.onChange, style: maxHeight ? __assign({}, style, { maxHeight: maxHeight }) : style, ref: function (element) {
  600. _this.textarea = element;
  601. if (typeof _this.props.innerRef === 'function') {
  602. _this.props.innerRef(element);
  603. }
  604. else if (_this.props.innerRef) {
  605. _this.props.innerRef.current = element;
  606. }
  607. } }), children));
  608. };
  609. TextareaAutosizeClass.prototype.componentDidUpdate = function () {
  610. this.textarea && autosize.update(this.textarea);
  611. };
  612. TextareaAutosizeClass.defaultProps = {
  613. rows: 1,
  614. async: false
  615. };
  616. TextareaAutosizeClass.propTypes = {
  617. rows: PropTypes.number,
  618. maxRows: PropTypes.number,
  619. onResize: PropTypes.func,
  620. innerRef: PropTypes.any,
  621. async: PropTypes.bool
  622. };
  623. return TextareaAutosizeClass;
  624. }(React.Component));
  625. exports.TextareaAutosize = React.forwardRef(function (props, ref) {
  626. return React.createElement(TextareaAutosizeClass, __assign({}, props, { innerRef: ref }));
  627. });
  628. /***/ }),
  629. /***/ 773:
  630. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  631. "use strict";
  632. var __webpack_unused_export__;
  633. __webpack_unused_export__ = true;
  634. var TextareaAutosize_1 = __webpack_require__(5438);
  635. exports.Z = TextareaAutosize_1.TextareaAutosize;
  636. /***/ }),
  637. /***/ 9196:
  638. /***/ (function(module) {
  639. "use strict";
  640. module.exports = window["React"];
  641. /***/ })
  642. /******/ });
  643. /************************************************************************/
  644. /******/ // The module cache
  645. /******/ var __webpack_module_cache__ = {};
  646. /******/
  647. /******/ // The require function
  648. /******/ function __webpack_require__(moduleId) {
  649. /******/ // Check if module is in cache
  650. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  651. /******/ if (cachedModule !== undefined) {
  652. /******/ return cachedModule.exports;
  653. /******/ }
  654. /******/ // Create a new module (and put it into the cache)
  655. /******/ var module = __webpack_module_cache__[moduleId] = {
  656. /******/ // no module.id needed
  657. /******/ // no module.loaded needed
  658. /******/ exports: {}
  659. /******/ };
  660. /******/
  661. /******/ // Execute the module function
  662. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  663. /******/
  664. /******/ // Return the exports of the module
  665. /******/ return module.exports;
  666. /******/ }
  667. /******/
  668. /************************************************************************/
  669. /******/ /* webpack/runtime/compat get default export */
  670. /******/ !function() {
  671. /******/ // getDefaultExport function for compatibility with non-harmony modules
  672. /******/ __webpack_require__.n = function(module) {
  673. /******/ var getter = module && module.__esModule ?
  674. /******/ function() { return module['default']; } :
  675. /******/ function() { return module; };
  676. /******/ __webpack_require__.d(getter, { a: getter });
  677. /******/ return getter;
  678. /******/ };
  679. /******/ }();
  680. /******/
  681. /******/ /* webpack/runtime/define property getters */
  682. /******/ !function() {
  683. /******/ // define getter functions for harmony exports
  684. /******/ __webpack_require__.d = function(exports, definition) {
  685. /******/ for(var key in definition) {
  686. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  687. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  688. /******/ }
  689. /******/ }
  690. /******/ };
  691. /******/ }();
  692. /******/
  693. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  694. /******/ !function() {
  695. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  696. /******/ }();
  697. /******/
  698. /******/ /* webpack/runtime/make namespace object */
  699. /******/ !function() {
  700. /******/ // define __esModule on exports
  701. /******/ __webpack_require__.r = function(exports) {
  702. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  703. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  704. /******/ }
  705. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  706. /******/ };
  707. /******/ }();
  708. /******/
  709. /************************************************************************/
  710. var __webpack_exports__ = {};
  711. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  712. !function() {
  713. "use strict";
  714. // ESM COMPAT FLAG
  715. __webpack_require__.r(__webpack_exports__);
  716. // EXPORTS
  717. __webpack_require__.d(__webpack_exports__, {
  718. "AlignmentToolbar": function() { return /* reexport */ AlignmentToolbar; },
  719. "Autocomplete": function() { return /* reexport */ Autocomplete; },
  720. "AutosaveMonitor": function() { return /* reexport */ autosave_monitor; },
  721. "BlockAlignmentToolbar": function() { return /* reexport */ BlockAlignmentToolbar; },
  722. "BlockControls": function() { return /* reexport */ BlockControls; },
  723. "BlockEdit": function() { return /* reexport */ BlockEdit; },
  724. "BlockEditorKeyboardShortcuts": function() { return /* reexport */ BlockEditorKeyboardShortcuts; },
  725. "BlockFormatControls": function() { return /* reexport */ BlockFormatControls; },
  726. "BlockIcon": function() { return /* reexport */ BlockIcon; },
  727. "BlockInspector": function() { return /* reexport */ BlockInspector; },
  728. "BlockList": function() { return /* reexport */ BlockList; },
  729. "BlockMover": function() { return /* reexport */ BlockMover; },
  730. "BlockNavigationDropdown": function() { return /* reexport */ BlockNavigationDropdown; },
  731. "BlockSelectionClearer": function() { return /* reexport */ BlockSelectionClearer; },
  732. "BlockSettingsMenu": function() { return /* reexport */ BlockSettingsMenu; },
  733. "BlockTitle": function() { return /* reexport */ BlockTitle; },
  734. "BlockToolbar": function() { return /* reexport */ BlockToolbar; },
  735. "ColorPalette": function() { return /* reexport */ ColorPalette; },
  736. "ContrastChecker": function() { return /* reexport */ ContrastChecker; },
  737. "CopyHandler": function() { return /* reexport */ CopyHandler; },
  738. "DefaultBlockAppender": function() { return /* reexport */ DefaultBlockAppender; },
  739. "DocumentOutline": function() { return /* reexport */ document_outline; },
  740. "DocumentOutlineCheck": function() { return /* reexport */ check; },
  741. "EditorHistoryRedo": function() { return /* reexport */ editor_history_redo; },
  742. "EditorHistoryUndo": function() { return /* reexport */ editor_history_undo; },
  743. "EditorKeyboardShortcutsRegister": function() { return /* reexport */ register_shortcuts; },
  744. "EditorNotices": function() { return /* reexport */ editor_notices; },
  745. "EditorProvider": function() { return /* reexport */ provider; },
  746. "EditorSnackbars": function() { return /* reexport */ EditorSnackbars; },
  747. "EntitiesSavedStates": function() { return /* reexport */ EntitiesSavedStates; },
  748. "ErrorBoundary": function() { return /* reexport */ error_boundary; },
  749. "FontSizePicker": function() { return /* reexport */ FontSizePicker; },
  750. "InnerBlocks": function() { return /* reexport */ InnerBlocks; },
  751. "Inserter": function() { return /* reexport */ Inserter; },
  752. "InspectorAdvancedControls": function() { return /* reexport */ InspectorAdvancedControls; },
  753. "InspectorControls": function() { return /* reexport */ InspectorControls; },
  754. "LocalAutosaveMonitor": function() { return /* reexport */ local_autosave_monitor; },
  755. "MediaPlaceholder": function() { return /* reexport */ MediaPlaceholder; },
  756. "MediaUpload": function() { return /* reexport */ MediaUpload; },
  757. "MediaUploadCheck": function() { return /* reexport */ MediaUploadCheck; },
  758. "MultiSelectScrollIntoView": function() { return /* reexport */ MultiSelectScrollIntoView; },
  759. "NavigableToolbar": function() { return /* reexport */ NavigableToolbar; },
  760. "ObserveTyping": function() { return /* reexport */ ObserveTyping; },
  761. "PageAttributesCheck": function() { return /* reexport */ page_attributes_check; },
  762. "PageAttributesOrder": function() { return /* reexport */ order; },
  763. "PageAttributesParent": function() { return /* reexport */ page_attributes_parent; },
  764. "PageTemplate": function() { return /* reexport */ post_template; },
  765. "PanelColorSettings": function() { return /* reexport */ PanelColorSettings; },
  766. "PlainText": function() { return /* reexport */ PlainText; },
  767. "PostAuthor": function() { return /* reexport */ post_author; },
  768. "PostAuthorCheck": function() { return /* reexport */ PostAuthorCheck; },
  769. "PostComments": function() { return /* reexport */ post_comments; },
  770. "PostExcerpt": function() { return /* reexport */ post_excerpt; },
  771. "PostExcerptCheck": function() { return /* reexport */ post_excerpt_check; },
  772. "PostFeaturedImage": function() { return /* reexport */ post_featured_image; },
  773. "PostFeaturedImageCheck": function() { return /* reexport */ post_featured_image_check; },
  774. "PostFormat": function() { return /* reexport */ PostFormat; },
  775. "PostFormatCheck": function() { return /* reexport */ post_format_check; },
  776. "PostLastRevision": function() { return /* reexport */ post_last_revision; },
  777. "PostLastRevisionCheck": function() { return /* reexport */ post_last_revision_check; },
  778. "PostLockedModal": function() { return /* reexport */ PostLockedModal; },
  779. "PostPendingStatus": function() { return /* reexport */ post_pending_status; },
  780. "PostPendingStatusCheck": function() { return /* reexport */ post_pending_status_check; },
  781. "PostPingbacks": function() { return /* reexport */ post_pingbacks; },
  782. "PostPreviewButton": function() { return /* reexport */ post_preview_button; },
  783. "PostPublishButton": function() { return /* reexport */ post_publish_button; },
  784. "PostPublishButtonLabel": function() { return /* reexport */ label; },
  785. "PostPublishPanel": function() { return /* reexport */ post_publish_panel; },
  786. "PostSavedState": function() { return /* reexport */ PostSavedState; },
  787. "PostSchedule": function() { return /* reexport */ PostSchedule; },
  788. "PostScheduleCheck": function() { return /* reexport */ post_schedule_check; },
  789. "PostScheduleLabel": function() { return /* reexport */ post_schedule_label; },
  790. "PostSlug": function() { return /* reexport */ post_slug; },
  791. "PostSlugCheck": function() { return /* reexport */ PostSlugCheck; },
  792. "PostSticky": function() { return /* reexport */ post_sticky; },
  793. "PostStickyCheck": function() { return /* reexport */ post_sticky_check; },
  794. "PostSwitchToDraftButton": function() { return /* reexport */ post_switch_to_draft_button; },
  795. "PostTaxonomies": function() { return /* reexport */ post_taxonomies; },
  796. "PostTaxonomiesCheck": function() { return /* reexport */ post_taxonomies_check; },
  797. "PostTaxonomiesFlatTermSelector": function() { return /* reexport */ flat_term_selector; },
  798. "PostTaxonomiesHierarchicalTermSelector": function() { return /* reexport */ hierarchical_term_selector; },
  799. "PostTextEditor": function() { return /* reexport */ PostTextEditor; },
  800. "PostTitle": function() { return /* reexport */ PostTitle; },
  801. "PostTrash": function() { return /* reexport */ PostTrash; },
  802. "PostTrashCheck": function() { return /* reexport */ post_trash_check; },
  803. "PostTypeSupportCheck": function() { return /* reexport */ post_type_support_check; },
  804. "PostVisibility": function() { return /* reexport */ post_visibility; },
  805. "PostVisibilityCheck": function() { return /* reexport */ post_visibility_check; },
  806. "PostVisibilityLabel": function() { return /* reexport */ post_visibility_label; },
  807. "RichText": function() { return /* reexport */ RichText; },
  808. "RichTextShortcut": function() { return /* reexport */ RichTextShortcut; },
  809. "RichTextToolbarButton": function() { return /* reexport */ RichTextToolbarButton; },
  810. "ServerSideRender": function() { return /* reexport */ (external_wp_serverSideRender_default()); },
  811. "SkipToSelectedBlock": function() { return /* reexport */ SkipToSelectedBlock; },
  812. "TableOfContents": function() { return /* reexport */ table_of_contents; },
  813. "TextEditorGlobalKeyboardShortcuts": function() { return /* reexport */ TextEditorGlobalKeyboardShortcuts; },
  814. "ThemeSupportCheck": function() { return /* reexport */ theme_support_check; },
  815. "URLInput": function() { return /* reexport */ URLInput; },
  816. "URLInputButton": function() { return /* reexport */ URLInputButton; },
  817. "URLPopover": function() { return /* reexport */ URLPopover; },
  818. "UnsavedChangesWarning": function() { return /* reexport */ UnsavedChangesWarning; },
  819. "VisualEditorGlobalKeyboardShortcuts": function() { return /* reexport */ visual_editor_shortcuts; },
  820. "Warning": function() { return /* reexport */ Warning; },
  821. "WordCount": function() { return /* reexport */ WordCount; },
  822. "WritingFlow": function() { return /* reexport */ WritingFlow; },
  823. "__unstableRichTextInputEvent": function() { return /* reexport */ __unstableRichTextInputEvent; },
  824. "cleanForSlug": function() { return /* reexport */ cleanForSlug; },
  825. "createCustomColorsHOC": function() { return /* reexport */ createCustomColorsHOC; },
  826. "getColorClassName": function() { return /* reexport */ getColorClassName; },
  827. "getColorObjectByAttributeValues": function() { return /* reexport */ getColorObjectByAttributeValues; },
  828. "getColorObjectByColorValue": function() { return /* reexport */ getColorObjectByColorValue; },
  829. "getFontSize": function() { return /* reexport */ getFontSize; },
  830. "getFontSizeClass": function() { return /* reexport */ getFontSizeClass; },
  831. "getTemplatePartIcon": function() { return /* reexport */ getTemplatePartIcon; },
  832. "mediaUpload": function() { return /* reexport */ mediaUpload; },
  833. "store": function() { return /* reexport */ store_store; },
  834. "storeConfig": function() { return /* reexport */ storeConfig; },
  835. "transformStyles": function() { return /* reexport */ external_wp_blockEditor_namespaceObject.transformStyles; },
  836. "userAutocompleter": function() { return /* reexport */ user; },
  837. "withColorContext": function() { return /* reexport */ withColorContext; },
  838. "withColors": function() { return /* reexport */ withColors; },
  839. "withFontSizes": function() { return /* reexport */ withFontSizes; }
  840. });
  841. // NAMESPACE OBJECT: ./node_modules/@wordpress/editor/build-module/store/selectors.js
  842. var selectors_namespaceObject = {};
  843. __webpack_require__.r(selectors_namespaceObject);
  844. __webpack_require__.d(selectors_namespaceObject, {
  845. "__experimentalGetDefaultTemplatePartAreas": function() { return __experimentalGetDefaultTemplatePartAreas; },
  846. "__experimentalGetDefaultTemplateType": function() { return __experimentalGetDefaultTemplateType; },
  847. "__experimentalGetDefaultTemplateTypes": function() { return __experimentalGetDefaultTemplateTypes; },
  848. "__experimentalGetTemplateInfo": function() { return __experimentalGetTemplateInfo; },
  849. "__unstableIsEditorReady": function() { return __unstableIsEditorReady; },
  850. "canInsertBlockType": function() { return canInsertBlockType; },
  851. "canUserUseUnfilteredHTML": function() { return canUserUseUnfilteredHTML; },
  852. "didPostSaveRequestFail": function() { return didPostSaveRequestFail; },
  853. "didPostSaveRequestSucceed": function() { return didPostSaveRequestSucceed; },
  854. "getActivePostLock": function() { return getActivePostLock; },
  855. "getAdjacentBlockClientId": function() { return getAdjacentBlockClientId; },
  856. "getAutosaveAttribute": function() { return getAutosaveAttribute; },
  857. "getBlock": function() { return getBlock; },
  858. "getBlockAttributes": function() { return getBlockAttributes; },
  859. "getBlockCount": function() { return getBlockCount; },
  860. "getBlockHierarchyRootClientId": function() { return getBlockHierarchyRootClientId; },
  861. "getBlockIndex": function() { return getBlockIndex; },
  862. "getBlockInsertionPoint": function() { return getBlockInsertionPoint; },
  863. "getBlockListSettings": function() { return getBlockListSettings; },
  864. "getBlockMode": function() { return getBlockMode; },
  865. "getBlockName": function() { return getBlockName; },
  866. "getBlockOrder": function() { return getBlockOrder; },
  867. "getBlockRootClientId": function() { return getBlockRootClientId; },
  868. "getBlockSelectionEnd": function() { return getBlockSelectionEnd; },
  869. "getBlockSelectionStart": function() { return getBlockSelectionStart; },
  870. "getBlocks": function() { return getBlocks; },
  871. "getBlocksByClientId": function() { return getBlocksByClientId; },
  872. "getClientIdsOfDescendants": function() { return getClientIdsOfDescendants; },
  873. "getClientIdsWithDescendants": function() { return getClientIdsWithDescendants; },
  874. "getCurrentPost": function() { return getCurrentPost; },
  875. "getCurrentPostAttribute": function() { return getCurrentPostAttribute; },
  876. "getCurrentPostId": function() { return getCurrentPostId; },
  877. "getCurrentPostLastRevisionId": function() { return getCurrentPostLastRevisionId; },
  878. "getCurrentPostRevisionsCount": function() { return getCurrentPostRevisionsCount; },
  879. "getCurrentPostType": function() { return getCurrentPostType; },
  880. "getEditedPostAttribute": function() { return getEditedPostAttribute; },
  881. "getEditedPostContent": function() { return getEditedPostContent; },
  882. "getEditedPostPreviewLink": function() { return getEditedPostPreviewLink; },
  883. "getEditedPostSlug": function() { return getEditedPostSlug; },
  884. "getEditedPostVisibility": function() { return getEditedPostVisibility; },
  885. "getEditorBlocks": function() { return getEditorBlocks; },
  886. "getEditorSelection": function() { return getEditorSelection; },
  887. "getEditorSelectionEnd": function() { return getEditorSelectionEnd; },
  888. "getEditorSelectionStart": function() { return getEditorSelectionStart; },
  889. "getEditorSettings": function() { return getEditorSettings; },
  890. "getFirstMultiSelectedBlockClientId": function() { return getFirstMultiSelectedBlockClientId; },
  891. "getGlobalBlockCount": function() { return getGlobalBlockCount; },
  892. "getInserterItems": function() { return getInserterItems; },
  893. "getLastMultiSelectedBlockClientId": function() { return getLastMultiSelectedBlockClientId; },
  894. "getMultiSelectedBlockClientIds": function() { return getMultiSelectedBlockClientIds; },
  895. "getMultiSelectedBlocks": function() { return getMultiSelectedBlocks; },
  896. "getMultiSelectedBlocksEndClientId": function() { return getMultiSelectedBlocksEndClientId; },
  897. "getMultiSelectedBlocksStartClientId": function() { return getMultiSelectedBlocksStartClientId; },
  898. "getNextBlockClientId": function() { return getNextBlockClientId; },
  899. "getPermalink": function() { return getPermalink; },
  900. "getPermalinkParts": function() { return getPermalinkParts; },
  901. "getPostEdits": function() { return getPostEdits; },
  902. "getPostLockUser": function() { return getPostLockUser; },
  903. "getPostTypeLabel": function() { return getPostTypeLabel; },
  904. "getPreviousBlockClientId": function() { return getPreviousBlockClientId; },
  905. "getSelectedBlock": function() { return getSelectedBlock; },
  906. "getSelectedBlockClientId": function() { return getSelectedBlockClientId; },
  907. "getSelectedBlockCount": function() { return getSelectedBlockCount; },
  908. "getSelectedBlocksInitialCaretPosition": function() { return getSelectedBlocksInitialCaretPosition; },
  909. "getStateBeforeOptimisticTransaction": function() { return getStateBeforeOptimisticTransaction; },
  910. "getSuggestedPostFormat": function() { return getSuggestedPostFormat; },
  911. "getTemplate": function() { return getTemplate; },
  912. "getTemplateLock": function() { return getTemplateLock; },
  913. "hasChangedContent": function() { return hasChangedContent; },
  914. "hasEditorRedo": function() { return hasEditorRedo; },
  915. "hasEditorUndo": function() { return hasEditorUndo; },
  916. "hasInserterItems": function() { return hasInserterItems; },
  917. "hasMultiSelection": function() { return hasMultiSelection; },
  918. "hasNonPostEntityChanges": function() { return hasNonPostEntityChanges; },
  919. "hasSelectedBlock": function() { return hasSelectedBlock; },
  920. "hasSelectedInnerBlock": function() { return hasSelectedInnerBlock; },
  921. "inSomeHistory": function() { return inSomeHistory; },
  922. "isAncestorMultiSelected": function() { return isAncestorMultiSelected; },
  923. "isAutosavingPost": function() { return isAutosavingPost; },
  924. "isBlockInsertionPointVisible": function() { return isBlockInsertionPointVisible; },
  925. "isBlockMultiSelected": function() { return isBlockMultiSelected; },
  926. "isBlockSelected": function() { return isBlockSelected; },
  927. "isBlockValid": function() { return isBlockValid; },
  928. "isBlockWithinSelection": function() { return isBlockWithinSelection; },
  929. "isCaretWithinFormattedText": function() { return isCaretWithinFormattedText; },
  930. "isCleanNewPost": function() { return isCleanNewPost; },
  931. "isCurrentPostPending": function() { return isCurrentPostPending; },
  932. "isCurrentPostPublished": function() { return isCurrentPostPublished; },
  933. "isCurrentPostScheduled": function() { return isCurrentPostScheduled; },
  934. "isEditedPostAutosaveable": function() { return isEditedPostAutosaveable; },
  935. "isEditedPostBeingScheduled": function() { return isEditedPostBeingScheduled; },
  936. "isEditedPostDateFloating": function() { return isEditedPostDateFloating; },
  937. "isEditedPostDirty": function() { return isEditedPostDirty; },
  938. "isEditedPostEmpty": function() { return isEditedPostEmpty; },
  939. "isEditedPostNew": function() { return isEditedPostNew; },
  940. "isEditedPostPublishable": function() { return isEditedPostPublishable; },
  941. "isEditedPostSaveable": function() { return isEditedPostSaveable; },
  942. "isFirstMultiSelectedBlock": function() { return isFirstMultiSelectedBlock; },
  943. "isMultiSelecting": function() { return isMultiSelecting; },
  944. "isPermalinkEditable": function() { return isPermalinkEditable; },
  945. "isPostAutosavingLocked": function() { return isPostAutosavingLocked; },
  946. "isPostLockTakeover": function() { return isPostLockTakeover; },
  947. "isPostLocked": function() { return isPostLocked; },
  948. "isPostSavingLocked": function() { return isPostSavingLocked; },
  949. "isPreviewingPost": function() { return isPreviewingPost; },
  950. "isPublishSidebarEnabled": function() { return isPublishSidebarEnabled; },
  951. "isPublishingPost": function() { return isPublishingPost; },
  952. "isSavingNonPostEntityChanges": function() { return isSavingNonPostEntityChanges; },
  953. "isSavingPost": function() { return isSavingPost; },
  954. "isSelectionEnabled": function() { return isSelectionEnabled; },
  955. "isTyping": function() { return isTyping; },
  956. "isValidTemplate": function() { return isValidTemplate; }
  957. });
  958. // NAMESPACE OBJECT: ./node_modules/@wordpress/editor/build-module/store/actions.js
  959. var actions_namespaceObject = {};
  960. __webpack_require__.r(actions_namespaceObject);
  961. __webpack_require__.d(actions_namespaceObject, {
  962. "__experimentalTearDownEditor": function() { return __experimentalTearDownEditor; },
  963. "autosave": function() { return autosave; },
  964. "clearSelectedBlock": function() { return clearSelectedBlock; },
  965. "createUndoLevel": function() { return createUndoLevel; },
  966. "disablePublishSidebar": function() { return disablePublishSidebar; },
  967. "editPost": function() { return editPost; },
  968. "enablePublishSidebar": function() { return enablePublishSidebar; },
  969. "enterFormattedText": function() { return enterFormattedText; },
  970. "exitFormattedText": function() { return exitFormattedText; },
  971. "hideInsertionPoint": function() { return hideInsertionPoint; },
  972. "insertBlock": function() { return insertBlock; },
  973. "insertBlocks": function() { return insertBlocks; },
  974. "insertDefaultBlock": function() { return insertDefaultBlock; },
  975. "lockPostAutosaving": function() { return lockPostAutosaving; },
  976. "lockPostSaving": function() { return lockPostSaving; },
  977. "mergeBlocks": function() { return mergeBlocks; },
  978. "moveBlockToPosition": function() { return moveBlockToPosition; },
  979. "moveBlocksDown": function() { return moveBlocksDown; },
  980. "moveBlocksUp": function() { return moveBlocksUp; },
  981. "multiSelect": function() { return multiSelect; },
  982. "receiveBlocks": function() { return receiveBlocks; },
  983. "redo": function() { return redo; },
  984. "refreshPost": function() { return refreshPost; },
  985. "removeBlock": function() { return removeBlock; },
  986. "removeBlocks": function() { return removeBlocks; },
  987. "replaceBlock": function() { return replaceBlock; },
  988. "replaceBlocks": function() { return replaceBlocks; },
  989. "resetBlocks": function() { return resetBlocks; },
  990. "resetEditorBlocks": function() { return resetEditorBlocks; },
  991. "resetPost": function() { return resetPost; },
  992. "savePost": function() { return savePost; },
  993. "selectBlock": function() { return selectBlock; },
  994. "setTemplateValidity": function() { return setTemplateValidity; },
  995. "setupEditor": function() { return setupEditor; },
  996. "setupEditorState": function() { return setupEditorState; },
  997. "showInsertionPoint": function() { return showInsertionPoint; },
  998. "startMultiSelect": function() { return startMultiSelect; },
  999. "startTyping": function() { return startTyping; },
  1000. "stopMultiSelect": function() { return stopMultiSelect; },
  1001. "stopTyping": function() { return stopTyping; },
  1002. "synchronizeTemplate": function() { return synchronizeTemplate; },
  1003. "toggleBlockMode": function() { return toggleBlockMode; },
  1004. "toggleSelection": function() { return toggleSelection; },
  1005. "trashPost": function() { return trashPost; },
  1006. "undo": function() { return undo; },
  1007. "unlockPostAutosaving": function() { return unlockPostAutosaving; },
  1008. "unlockPostSaving": function() { return unlockPostSaving; },
  1009. "updateBlock": function() { return updateBlock; },
  1010. "updateBlockAttributes": function() { return updateBlockAttributes; },
  1011. "updateBlockListSettings": function() { return updateBlockListSettings; },
  1012. "updateEditorSettings": function() { return updateEditorSettings; },
  1013. "updatePost": function() { return updatePost; },
  1014. "updatePostLock": function() { return updatePostLock; }
  1015. });
  1016. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
  1017. function _extends() {
  1018. _extends = Object.assign ? Object.assign.bind() : function (target) {
  1019. for (var i = 1; i < arguments.length; i++) {
  1020. var source = arguments[i];
  1021. for (var key in source) {
  1022. if (Object.prototype.hasOwnProperty.call(source, key)) {
  1023. target[key] = source[key];
  1024. }
  1025. }
  1026. }
  1027. return target;
  1028. };
  1029. return _extends.apply(this, arguments);
  1030. }
  1031. ;// CONCATENATED MODULE: external ["wp","element"]
  1032. var external_wp_element_namespaceObject = window["wp"]["element"];
  1033. ;// CONCATENATED MODULE: external "lodash"
  1034. var external_lodash_namespaceObject = window["lodash"];
  1035. ;// CONCATENATED MODULE: external ["wp","blocks"]
  1036. var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
  1037. ;// CONCATENATED MODULE: external ["wp","data"]
  1038. var external_wp_data_namespaceObject = window["wp"]["data"];
  1039. ;// CONCATENATED MODULE: external ["wp","coreData"]
  1040. var external_wp_coreData_namespaceObject = window["wp"]["coreData"];
  1041. ;// CONCATENATED MODULE: external ["wp","compose"]
  1042. var external_wp_compose_namespaceObject = window["wp"]["compose"];
  1043. ;// CONCATENATED MODULE: external ["wp","hooks"]
  1044. var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
  1045. ;// CONCATENATED MODULE: external ["wp","blockEditor"]
  1046. var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
  1047. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/defaults.js
  1048. /**
  1049. * WordPress dependencies
  1050. */
  1051. /**
  1052. * The default post editor settings.
  1053. *
  1054. * @property {boolean|Array} allowedBlockTypes Allowed block types
  1055. * @property {boolean} richEditingEnabled Whether rich editing is enabled or not
  1056. * @property {boolean} codeEditingEnabled Whether code editing is enabled or not
  1057. * @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.
  1058. * true = the user has opted to show the Custom Fields panel at the bottom of the editor.
  1059. * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
  1060. * undefined = the current environment does not support Custom Fields, so the option toggle in Preferences -> Panels to enable the Custom Fields panel is not displayed.
  1061. * @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API.
  1062. * @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage.
  1063. * @property {Array?} availableTemplates The available post templates
  1064. * @property {boolean} disablePostFormats Whether or not the post formats are disabled
  1065. * @property {Array?} allowedMimeTypes List of allowed mime types and file extensions
  1066. * @property {number} maxUploadFileSize Maximum upload file size
  1067. * @property {boolean} supportsLayout Whether the editor supports layouts.
  1068. */
  1069. const EDITOR_SETTINGS_DEFAULTS = { ...external_wp_blockEditor_namespaceObject.SETTINGS_DEFAULTS,
  1070. richEditingEnabled: true,
  1071. codeEditingEnabled: true,
  1072. enableCustomFields: undefined,
  1073. supportsLayout: true
  1074. };
  1075. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/reducer.js
  1076. /**
  1077. * External dependencies
  1078. */
  1079. /**
  1080. * WordPress dependencies
  1081. */
  1082. /**
  1083. * Internal dependencies
  1084. */
  1085. /**
  1086. * Returns a post attribute value, flattening nested rendered content using its
  1087. * raw value in place of its original object form.
  1088. *
  1089. * @param {*} value Original value.
  1090. *
  1091. * @return {*} Raw value.
  1092. */
  1093. function getPostRawValue(value) {
  1094. if (value && 'object' === typeof value && 'raw' in value) {
  1095. return value.raw;
  1096. }
  1097. return value;
  1098. }
  1099. /**
  1100. * Returns true if the two object arguments have the same keys, or false
  1101. * otherwise.
  1102. *
  1103. * @param {Object} a First object.
  1104. * @param {Object} b Second object.
  1105. *
  1106. * @return {boolean} Whether the two objects have the same keys.
  1107. */
  1108. function hasSameKeys(a, b) {
  1109. return isEqual(keys(a), keys(b));
  1110. }
  1111. /**
  1112. * Returns true if, given the currently dispatching action and the previously
  1113. * dispatched action, the two actions are editing the same post property, or
  1114. * false otherwise.
  1115. *
  1116. * @param {Object} action Currently dispatching action.
  1117. * @param {Object} previousAction Previously dispatched action.
  1118. *
  1119. * @return {boolean} Whether actions are updating the same post property.
  1120. */
  1121. function isUpdatingSamePostProperty(action, previousAction) {
  1122. return action.type === 'EDIT_POST' && hasSameKeys(action.edits, previousAction.edits);
  1123. }
  1124. /**
  1125. * Returns true if, given the currently dispatching action and the previously
  1126. * dispatched action, the two actions are modifying the same property such that
  1127. * undo history should be batched.
  1128. *
  1129. * @param {Object} action Currently dispatching action.
  1130. * @param {Object} previousAction Previously dispatched action.
  1131. *
  1132. * @return {boolean} Whether to overwrite present state.
  1133. */
  1134. function shouldOverwriteState(action, previousAction) {
  1135. if (action.type === 'RESET_EDITOR_BLOCKS') {
  1136. return !action.shouldCreateUndoLevel;
  1137. }
  1138. if (!previousAction || action.type !== previousAction.type) {
  1139. return false;
  1140. }
  1141. return isUpdatingSamePostProperty(action, previousAction);
  1142. }
  1143. function postId() {
  1144. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  1145. let action = arguments.length > 1 ? arguments[1] : undefined;
  1146. switch (action.type) {
  1147. case 'SETUP_EDITOR_STATE':
  1148. return action.post.id;
  1149. }
  1150. return state;
  1151. }
  1152. function postType() {
  1153. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  1154. let action = arguments.length > 1 ? arguments[1] : undefined;
  1155. switch (action.type) {
  1156. case 'SETUP_EDITOR_STATE':
  1157. return action.post.type;
  1158. }
  1159. return state;
  1160. }
  1161. /**
  1162. * Reducer returning whether the post blocks match the defined template or not.
  1163. *
  1164. * @param {Object} state Current state.
  1165. * @param {Object} action Dispatched action.
  1166. *
  1167. * @return {boolean} Updated state.
  1168. */
  1169. function template() {
  1170. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  1171. isValid: true
  1172. };
  1173. let action = arguments.length > 1 ? arguments[1] : undefined;
  1174. switch (action.type) {
  1175. case 'SET_TEMPLATE_VALIDITY':
  1176. return { ...state,
  1177. isValid: action.isValid
  1178. };
  1179. }
  1180. return state;
  1181. }
  1182. /**
  1183. * Reducer returning current network request state (whether a request to
  1184. * the WP REST API is in progress, successful, or failed).
  1185. *
  1186. * @param {Object} state Current state.
  1187. * @param {Object} action Dispatched action.
  1188. *
  1189. * @return {Object} Updated state.
  1190. */
  1191. function saving() {
  1192. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1193. let action = arguments.length > 1 ? arguments[1] : undefined;
  1194. switch (action.type) {
  1195. case 'REQUEST_POST_UPDATE_START':
  1196. case 'REQUEST_POST_UPDATE_FINISH':
  1197. return {
  1198. pending: action.type === 'REQUEST_POST_UPDATE_START',
  1199. options: action.options || {}
  1200. };
  1201. }
  1202. return state;
  1203. }
  1204. /**
  1205. * Post Lock State.
  1206. *
  1207. * @typedef {Object} PostLockState
  1208. *
  1209. * @property {boolean} isLocked Whether the post is locked.
  1210. * @property {?boolean} isTakeover Whether the post editing has been taken over.
  1211. * @property {?boolean} activePostLock Active post lock value.
  1212. * @property {?Object} user User that took over the post.
  1213. */
  1214. /**
  1215. * Reducer returning the post lock status.
  1216. *
  1217. * @param {PostLockState} state Current state.
  1218. * @param {Object} action Dispatched action.
  1219. *
  1220. * @return {PostLockState} Updated state.
  1221. */
  1222. function postLock() {
  1223. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  1224. isLocked: false
  1225. };
  1226. let action = arguments.length > 1 ? arguments[1] : undefined;
  1227. switch (action.type) {
  1228. case 'UPDATE_POST_LOCK':
  1229. return action.lock;
  1230. }
  1231. return state;
  1232. }
  1233. /**
  1234. * Post saving lock.
  1235. *
  1236. * When post saving is locked, the post cannot be published or updated.
  1237. *
  1238. * @param {PostLockState} state Current state.
  1239. * @param {Object} action Dispatched action.
  1240. *
  1241. * @return {PostLockState} Updated state.
  1242. */
  1243. function postSavingLock() {
  1244. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1245. let action = arguments.length > 1 ? arguments[1] : undefined;
  1246. switch (action.type) {
  1247. case 'LOCK_POST_SAVING':
  1248. return { ...state,
  1249. [action.lockName]: true
  1250. };
  1251. case 'UNLOCK_POST_SAVING':
  1252. return (0,external_lodash_namespaceObject.omit)(state, action.lockName);
  1253. }
  1254. return state;
  1255. }
  1256. /**
  1257. * Post autosaving lock.
  1258. *
  1259. * When post autosaving is locked, the post will not autosave.
  1260. *
  1261. * @param {PostLockState} state Current state.
  1262. * @param {Object} action Dispatched action.
  1263. *
  1264. * @return {PostLockState} Updated state.
  1265. */
  1266. function postAutosavingLock() {
  1267. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1268. let action = arguments.length > 1 ? arguments[1] : undefined;
  1269. switch (action.type) {
  1270. case 'LOCK_POST_AUTOSAVING':
  1271. return { ...state,
  1272. [action.lockName]: true
  1273. };
  1274. case 'UNLOCK_POST_AUTOSAVING':
  1275. return (0,external_lodash_namespaceObject.omit)(state, action.lockName);
  1276. }
  1277. return state;
  1278. }
  1279. /**
  1280. * Reducer returning whether the editor is ready to be rendered.
  1281. * The editor is considered ready to be rendered once
  1282. * the post object is loaded properly and the initial blocks parsed.
  1283. *
  1284. * @param {boolean} state
  1285. * @param {Object} action
  1286. *
  1287. * @return {boolean} Updated state.
  1288. */
  1289. function isReady() {
  1290. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1291. let action = arguments.length > 1 ? arguments[1] : undefined;
  1292. switch (action.type) {
  1293. case 'SETUP_EDITOR_STATE':
  1294. return true;
  1295. case 'TEAR_DOWN_EDITOR':
  1296. return false;
  1297. }
  1298. return state;
  1299. }
  1300. /**
  1301. * Reducer returning the post editor setting.
  1302. *
  1303. * @param {Object} state Current state.
  1304. * @param {Object} action Dispatched action.
  1305. *
  1306. * @return {Object} Updated state.
  1307. */
  1308. function editorSettings() {
  1309. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : EDITOR_SETTINGS_DEFAULTS;
  1310. let action = arguments.length > 1 ? arguments[1] : undefined;
  1311. switch (action.type) {
  1312. case 'UPDATE_EDITOR_SETTINGS':
  1313. return { ...state,
  1314. ...action.settings
  1315. };
  1316. }
  1317. return state;
  1318. }
  1319. /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
  1320. postId,
  1321. postType,
  1322. saving,
  1323. postLock,
  1324. template,
  1325. postSavingLock,
  1326. isReady,
  1327. editorSettings,
  1328. postAutosavingLock
  1329. }));
  1330. ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js
  1331. var LEAF_KEY, hasWeakMap;
  1332. /**
  1333. * Arbitrary value used as key for referencing cache object in WeakMap tree.
  1334. *
  1335. * @type {Object}
  1336. */
  1337. LEAF_KEY = {};
  1338. /**
  1339. * Whether environment supports WeakMap.
  1340. *
  1341. * @type {boolean}
  1342. */
  1343. hasWeakMap = typeof WeakMap !== 'undefined';
  1344. /**
  1345. * Returns the first argument as the sole entry in an array.
  1346. *
  1347. * @param {*} value Value to return.
  1348. *
  1349. * @return {Array} Value returned as entry in array.
  1350. */
  1351. function arrayOf( value ) {
  1352. return [ value ];
  1353. }
  1354. /**
  1355. * Returns true if the value passed is object-like, or false otherwise. A value
  1356. * is object-like if it can support property assignment, e.g. object or array.
  1357. *
  1358. * @param {*} value Value to test.
  1359. *
  1360. * @return {boolean} Whether value is object-like.
  1361. */
  1362. function isObjectLike( value ) {
  1363. return !! value && 'object' === typeof value;
  1364. }
  1365. /**
  1366. * Creates and returns a new cache object.
  1367. *
  1368. * @return {Object} Cache object.
  1369. */
  1370. function createCache() {
  1371. var cache = {
  1372. clear: function() {
  1373. cache.head = null;
  1374. },
  1375. };
  1376. return cache;
  1377. }
  1378. /**
  1379. * Returns true if entries within the two arrays are strictly equal by
  1380. * reference from a starting index.
  1381. *
  1382. * @param {Array} a First array.
  1383. * @param {Array} b Second array.
  1384. * @param {number} fromIndex Index from which to start comparison.
  1385. *
  1386. * @return {boolean} Whether arrays are shallowly equal.
  1387. */
  1388. function isShallowEqual( a, b, fromIndex ) {
  1389. var i;
  1390. if ( a.length !== b.length ) {
  1391. return false;
  1392. }
  1393. for ( i = fromIndex; i < a.length; i++ ) {
  1394. if ( a[ i ] !== b[ i ] ) {
  1395. return false;
  1396. }
  1397. }
  1398. return true;
  1399. }
  1400. /**
  1401. * Returns a memoized selector function. The getDependants function argument is
  1402. * called before the memoized selector and is expected to return an immutable
  1403. * reference or array of references on which the selector depends for computing
  1404. * its own return value. The memoize cache is preserved only as long as those
  1405. * dependant references remain the same. If getDependants returns a different
  1406. * reference(s), the cache is cleared and the selector value regenerated.
  1407. *
  1408. * @param {Function} selector Selector function.
  1409. * @param {Function} getDependants Dependant getter returning an immutable
  1410. * reference or array of reference used in
  1411. * cache bust consideration.
  1412. *
  1413. * @return {Function} Memoized selector.
  1414. */
  1415. /* harmony default export */ function rememo(selector, getDependants ) {
  1416. var rootCache, getCache;
  1417. // Use object source as dependant if getter not provided
  1418. if ( ! getDependants ) {
  1419. getDependants = arrayOf;
  1420. }
  1421. /**
  1422. * Returns the root cache. If WeakMap is supported, this is assigned to the
  1423. * root WeakMap cache set, otherwise it is a shared instance of the default
  1424. * cache object.
  1425. *
  1426. * @return {(WeakMap|Object)} Root cache object.
  1427. */
  1428. function getRootCache() {
  1429. return rootCache;
  1430. }
  1431. /**
  1432. * Returns the cache for a given dependants array. When possible, a WeakMap
  1433. * will be used to create a unique cache for each set of dependants. This
  1434. * is feasible due to the nature of WeakMap in allowing garbage collection
  1435. * to occur on entries where the key object is no longer referenced. Since
  1436. * WeakMap requires the key to be an object, this is only possible when the
  1437. * dependant is object-like. The root cache is created as a hierarchy where
  1438. * each top-level key is the first entry in a dependants set, the value a
  1439. * WeakMap where each key is the next dependant, and so on. This continues
  1440. * so long as the dependants are object-like. If no dependants are object-
  1441. * like, then the cache is shared across all invocations.
  1442. *
  1443. * @see isObjectLike
  1444. *
  1445. * @param {Array} dependants Selector dependants.
  1446. *
  1447. * @return {Object} Cache object.
  1448. */
  1449. function getWeakMapCache( dependants ) {
  1450. var caches = rootCache,
  1451. isUniqueByDependants = true,
  1452. i, dependant, map, cache;
  1453. for ( i = 0; i < dependants.length; i++ ) {
  1454. dependant = dependants[ i ];
  1455. // Can only compose WeakMap from object-like key.
  1456. if ( ! isObjectLike( dependant ) ) {
  1457. isUniqueByDependants = false;
  1458. break;
  1459. }
  1460. // Does current segment of cache already have a WeakMap?
  1461. if ( caches.has( dependant ) ) {
  1462. // Traverse into nested WeakMap.
  1463. caches = caches.get( dependant );
  1464. } else {
  1465. // Create, set, and traverse into a new one.
  1466. map = new WeakMap();
  1467. caches.set( dependant, map );
  1468. caches = map;
  1469. }
  1470. }
  1471. // We use an arbitrary (but consistent) object as key for the last item
  1472. // in the WeakMap to serve as our running cache.
  1473. if ( ! caches.has( LEAF_KEY ) ) {
  1474. cache = createCache();
  1475. cache.isUniqueByDependants = isUniqueByDependants;
  1476. caches.set( LEAF_KEY, cache );
  1477. }
  1478. return caches.get( LEAF_KEY );
  1479. }
  1480. // Assign cache handler by availability of WeakMap
  1481. getCache = hasWeakMap ? getWeakMapCache : getRootCache;
  1482. /**
  1483. * Resets root memoization cache.
  1484. */
  1485. function clear() {
  1486. rootCache = hasWeakMap ? new WeakMap() : createCache();
  1487. }
  1488. // eslint-disable-next-line jsdoc/check-param-names
  1489. /**
  1490. * The augmented selector call, considering first whether dependants have
  1491. * changed before passing it to underlying memoize function.
  1492. *
  1493. * @param {Object} source Source object for derivation.
  1494. * @param {...*} extraArgs Additional arguments to pass to selector.
  1495. *
  1496. * @return {*} Selector result.
  1497. */
  1498. function callSelector( /* source, ...extraArgs */ ) {
  1499. var len = arguments.length,
  1500. cache, node, i, args, dependants;
  1501. // Create copy of arguments (avoid leaking deoptimization).
  1502. args = new Array( len );
  1503. for ( i = 0; i < len; i++ ) {
  1504. args[ i ] = arguments[ i ];
  1505. }
  1506. dependants = getDependants.apply( null, args );
  1507. cache = getCache( dependants );
  1508. // If not guaranteed uniqueness by dependants (primitive type or lack
  1509. // of WeakMap support), shallow compare against last dependants and, if
  1510. // references have changed, destroy cache to recalculate result.
  1511. if ( ! cache.isUniqueByDependants ) {
  1512. if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
  1513. cache.clear();
  1514. }
  1515. cache.lastDependants = dependants;
  1516. }
  1517. node = cache.head;
  1518. while ( node ) {
  1519. // Check whether node arguments match arguments
  1520. if ( ! isShallowEqual( node.args, args, 1 ) ) {
  1521. node = node.next;
  1522. continue;
  1523. }
  1524. // At this point we can assume we've found a match
  1525. // Surface matched node to head if not already
  1526. if ( node !== cache.head ) {
  1527. // Adjust siblings to point to each other.
  1528. node.prev.next = node.next;
  1529. if ( node.next ) {
  1530. node.next.prev = node.prev;
  1531. }
  1532. node.next = cache.head;
  1533. node.prev = null;
  1534. cache.head.prev = node;
  1535. cache.head = node;
  1536. }
  1537. // Return immediately
  1538. return node.val;
  1539. }
  1540. // No cached value found. Continue to insertion phase:
  1541. node = {
  1542. // Generate the result from original function
  1543. val: selector.apply( null, args ),
  1544. };
  1545. // Avoid including the source object in the cache.
  1546. args[ 0 ] = null;
  1547. node.args = args;
  1548. // Don't need to check whether node is already head, since it would
  1549. // have been returned above already if it was
  1550. // Shift existing head down list
  1551. if ( cache.head ) {
  1552. cache.head.prev = node;
  1553. node.next = cache.head;
  1554. }
  1555. cache.head = node;
  1556. return node.val;
  1557. }
  1558. callSelector.getDependants = getDependants;
  1559. callSelector.clear = clear;
  1560. clear();
  1561. return callSelector;
  1562. }
  1563. ;// CONCATENATED MODULE: external ["wp","date"]
  1564. var external_wp_date_namespaceObject = window["wp"]["date"];
  1565. ;// CONCATENATED MODULE: external ["wp","url"]
  1566. var external_wp_url_namespaceObject = window["wp"]["url"];
  1567. ;// CONCATENATED MODULE: external ["wp","deprecated"]
  1568. var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  1569. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  1570. ;// CONCATENATED MODULE: external ["wp","primitives"]
  1571. var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
  1572. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/layout.js
  1573. /**
  1574. * WordPress dependencies
  1575. */
  1576. const layout = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1577. xmlns: "http://www.w3.org/2000/svg",
  1578. viewBox: "0 0 24 24"
  1579. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1580. d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
  1581. }));
  1582. /* harmony default export */ var library_layout = (layout);
  1583. ;// CONCATENATED MODULE: external ["wp","preferences"]
  1584. var external_wp_preferences_namespaceObject = window["wp"]["preferences"];
  1585. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/constants.js
  1586. /**
  1587. * Set of post properties for which edits should assume a merging behavior,
  1588. * assuming an object value.
  1589. *
  1590. * @type {Set}
  1591. */
  1592. const EDIT_MERGE_PROPERTIES = new Set(['meta']);
  1593. /**
  1594. * Constant for the store module (or reducer) key.
  1595. *
  1596. * @type {string}
  1597. */
  1598. const STORE_NAME = 'core/editor';
  1599. const SAVE_POST_NOTICE_ID = 'SAVE_POST_NOTICE_ID';
  1600. const TRASH_POST_NOTICE_ID = 'TRASH_POST_NOTICE_ID';
  1601. const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;
  1602. const ONE_MINUTE_IN_MS = 60 * 1000;
  1603. const AUTOSAVE_PROPERTIES = ['title', 'excerpt', 'content'];
  1604. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/header.js
  1605. /**
  1606. * WordPress dependencies
  1607. */
  1608. const header = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1609. xmlns: "http://www.w3.org/2000/svg",
  1610. viewBox: "0 0 24 24"
  1611. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1612. d: "M18.5 10.5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
  1613. }));
  1614. /* harmony default export */ var library_header = (header);
  1615. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/footer.js
  1616. /**
  1617. * WordPress dependencies
  1618. */
  1619. const footer = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1620. xmlns: "http://www.w3.org/2000/svg",
  1621. viewBox: "0 0 24 24"
  1622. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1623. fillRule: "evenodd",
  1624. d: "M18 5.5h-8v8h8.5V6a.5.5 0 00-.5-.5zm-9.5 8h-3V6a.5.5 0 01.5-.5h2.5v8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
  1625. }));
  1626. /* harmony default export */ var library_footer = (footer);
  1627. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/sidebar.js
  1628. /**
  1629. * WordPress dependencies
  1630. */
  1631. const sidebar = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1632. xmlns: "http://www.w3.org/2000/svg",
  1633. viewBox: "0 0 24 24"
  1634. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1635. d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
  1636. }));
  1637. /* harmony default export */ var library_sidebar = (sidebar);
  1638. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol-filled.js
  1639. /**
  1640. * WordPress dependencies
  1641. */
  1642. const symbolFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1643. xmlns: "http://www.w3.org/2000/svg",
  1644. viewBox: "0 0 24 24"
  1645. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1646. d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-17.6 1L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z"
  1647. }));
  1648. /* harmony default export */ var symbol_filled = (symbolFilled);
  1649. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/get-template-part-icon.js
  1650. /**
  1651. * WordPress dependencies
  1652. */
  1653. /**
  1654. * Helper function to retrieve the corresponding icon by name.
  1655. *
  1656. * @param {string} iconName The name of the icon.
  1657. *
  1658. * @return {Object} The corresponding icon.
  1659. */
  1660. function getTemplatePartIcon(iconName) {
  1661. if ('header' === iconName) {
  1662. return library_header;
  1663. } else if ('footer' === iconName) {
  1664. return library_footer;
  1665. } else if ('sidebar' === iconName) {
  1666. return library_sidebar;
  1667. }
  1668. return symbol_filled;
  1669. }
  1670. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/selectors.js
  1671. /**
  1672. * External dependencies
  1673. */
  1674. /**
  1675. * WordPress dependencies
  1676. */
  1677. /**
  1678. * Internal dependencies
  1679. */
  1680. /**
  1681. * Shared reference to an empty object for cases where it is important to avoid
  1682. * returning a new object reference on every invocation, as in a connected or
  1683. * other pure component which performs `shouldComponentUpdate` check on props.
  1684. * This should be used as a last resort, since the normalized data should be
  1685. * maintained by the reducer result in state.
  1686. */
  1687. const EMPTY_OBJECT = {};
  1688. /**
  1689. * Shared reference to an empty array for cases where it is important to avoid
  1690. * returning a new array reference on every invocation, as in a connected or
  1691. * other pure component which performs `shouldComponentUpdate` check on props.
  1692. * This should be used as a last resort, since the normalized data should be
  1693. * maintained by the reducer result in state.
  1694. */
  1695. const EMPTY_ARRAY = [];
  1696. /**
  1697. * Returns true if any past editor history snapshots exist, or false otherwise.
  1698. *
  1699. * @param {Object} state Global application state.
  1700. *
  1701. * @return {boolean} Whether undo history exists.
  1702. */
  1703. const hasEditorUndo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
  1704. return select(external_wp_coreData_namespaceObject.store).hasUndo();
  1705. });
  1706. /**
  1707. * Returns true if any future editor history snapshots exist, or false
  1708. * otherwise.
  1709. *
  1710. * @param {Object} state Global application state.
  1711. *
  1712. * @return {boolean} Whether redo history exists.
  1713. */
  1714. const hasEditorRedo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
  1715. return select(external_wp_coreData_namespaceObject.store).hasRedo();
  1716. });
  1717. /**
  1718. * Returns true if the currently edited post is yet to be saved, or false if
  1719. * the post has been saved.
  1720. *
  1721. * @param {Object} state Global application state.
  1722. *
  1723. * @return {boolean} Whether the post is new.
  1724. */
  1725. function isEditedPostNew(state) {
  1726. return getCurrentPost(state).status === 'auto-draft';
  1727. }
  1728. /**
  1729. * Returns true if content includes unsaved changes, or false otherwise.
  1730. *
  1731. * @param {Object} state Editor state.
  1732. *
  1733. * @return {boolean} Whether content includes unsaved changes.
  1734. */
  1735. function hasChangedContent(state) {
  1736. const edits = getPostEdits(state);
  1737. return 'blocks' in edits || // `edits` is intended to contain only values which are different from
  1738. // the saved post, so the mere presence of a property is an indicator
  1739. // that the value is different than what is known to be saved. While
  1740. // content in Visual mode is represented by the blocks state, in Text
  1741. // mode it is tracked by `edits.content`.
  1742. 'content' in edits;
  1743. }
  1744. /**
  1745. * Returns true if there are unsaved values for the current edit session, or
  1746. * false if the editing state matches the saved or new post.
  1747. *
  1748. * @param {Object} state Global application state.
  1749. *
  1750. * @return {boolean} Whether unsaved values exist.
  1751. */
  1752. const isEditedPostDirty = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
  1753. // Edits should contain only fields which differ from the saved post (reset
  1754. // at initial load and save complete). Thus, a non-empty edits state can be
  1755. // inferred to contain unsaved values.
  1756. const postType = getCurrentPostType(state);
  1757. const postId = getCurrentPostId(state);
  1758. if (select(external_wp_coreData_namespaceObject.store).hasEditsForEntityRecord('postType', postType, postId)) {
  1759. return true;
  1760. }
  1761. return false;
  1762. });
  1763. /**
  1764. * Returns true if there are unsaved edits for entities other than
  1765. * the editor's post, and false otherwise.
  1766. *
  1767. * @param {Object} state Global application state.
  1768. *
  1769. * @return {boolean} Whether there are edits or not.
  1770. */
  1771. const hasNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
  1772. const dirtyEntityRecords = select(external_wp_coreData_namespaceObject.store).__experimentalGetDirtyEntityRecords();
  1773. const {
  1774. type,
  1775. id
  1776. } = getCurrentPost(state);
  1777. return (0,external_lodash_namespaceObject.some)(dirtyEntityRecords, entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id);
  1778. });
  1779. /**
  1780. * Returns true if there are no unsaved values for the current edit session and
  1781. * if the currently edited post is new (has never been saved before).
  1782. *
  1783. * @param {Object} state Global application state.
  1784. *
  1785. * @return {boolean} Whether new post and unsaved values exist.
  1786. */
  1787. function isCleanNewPost(state) {
  1788. return !isEditedPostDirty(state) && isEditedPostNew(state);
  1789. }
  1790. /**
  1791. * Returns the post currently being edited in its last known saved state, not
  1792. * including unsaved edits. Returns an object containing relevant default post
  1793. * values if the post has not yet been saved.
  1794. *
  1795. * @param {Object} state Global application state.
  1796. *
  1797. * @return {Object} Post object.
  1798. */
  1799. const getCurrentPost = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
  1800. const postId = getCurrentPostId(state);
  1801. const postType = getCurrentPostType(state);
  1802. const post = select(external_wp_coreData_namespaceObject.store).getRawEntityRecord('postType', postType, postId);
  1803. if (post) {
  1804. return post;
  1805. } // This exists for compatibility with the previous selector behavior
  1806. // which would guarantee an object return based on the editor reducer's
  1807. // default empty object state.
  1808. return EMPTY_OBJECT;
  1809. });
  1810. /**
  1811. * Returns the post type of the post currently being edited.
  1812. *
  1813. * @param {Object} state Global application state.
  1814. *
  1815. * @return {string} Post type.
  1816. */
  1817. function getCurrentPostType(state) {
  1818. return state.postType;
  1819. }
  1820. /**
  1821. * Returns the ID of the post currently being edited, or null if the post has
  1822. * not yet been saved.
  1823. *
  1824. * @param {Object} state Global application state.
  1825. *
  1826. * @return {?number} ID of current post.
  1827. */
  1828. function getCurrentPostId(state) {
  1829. return state.postId;
  1830. }
  1831. /**
  1832. * Returns the number of revisions of the post currently being edited.
  1833. *
  1834. * @param {Object} state Global application state.
  1835. *
  1836. * @return {number} Number of revisions.
  1837. */
  1838. function getCurrentPostRevisionsCount(state) {
  1839. return (0,external_lodash_namespaceObject.get)(getCurrentPost(state), ['_links', 'version-history', 0, 'count'], 0);
  1840. }
  1841. /**
  1842. * Returns the last revision ID of the post currently being edited,
  1843. * or null if the post has no revisions.
  1844. *
  1845. * @param {Object} state Global application state.
  1846. *
  1847. * @return {?number} ID of the last revision.
  1848. */
  1849. function getCurrentPostLastRevisionId(state) {
  1850. return (0,external_lodash_namespaceObject.get)(getCurrentPost(state), ['_links', 'predecessor-version', 0, 'id'], null);
  1851. }
  1852. /**
  1853. * Returns any post values which have been changed in the editor but not yet
  1854. * been saved.
  1855. *
  1856. * @param {Object} state Global application state.
  1857. *
  1858. * @return {Object} Object of key value pairs comprising unsaved edits.
  1859. */
  1860. const getPostEdits = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
  1861. const postType = getCurrentPostType(state);
  1862. const postId = getCurrentPostId(state);
  1863. return select(external_wp_coreData_namespaceObject.store).getEntityRecordEdits('postType', postType, postId) || EMPTY_OBJECT;
  1864. });
  1865. /**
  1866. * Returns an attribute value of the saved post.
  1867. *
  1868. * @param {Object} state Global application state.
  1869. * @param {string} attributeName Post attribute name.
  1870. *
  1871. * @return {*} Post attribute value.
  1872. */
  1873. function getCurrentPostAttribute(state, attributeName) {
  1874. switch (attributeName) {
  1875. case 'type':
  1876. return getCurrentPostType(state);
  1877. case 'id':
  1878. return getCurrentPostId(state);
  1879. default:
  1880. const post = getCurrentPost(state);
  1881. if (!post.hasOwnProperty(attributeName)) {
  1882. break;
  1883. }
  1884. return getPostRawValue(post[attributeName]);
  1885. }
  1886. }
  1887. /**
  1888. * Returns a single attribute of the post being edited, preferring the unsaved
  1889. * edit if one exists, but merging with the attribute value for the last known
  1890. * saved state of the post (this is needed for some nested attributes like meta).
  1891. *
  1892. * @param {Object} state Global application state.
  1893. * @param {string} attributeName Post attribute name.
  1894. *
  1895. * @return {*} Post attribute value.
  1896. */
  1897. const getNestedEditedPostProperty = (state, attributeName) => {
  1898. const edits = getPostEdits(state);
  1899. if (!edits.hasOwnProperty(attributeName)) {
  1900. return getCurrentPostAttribute(state, attributeName);
  1901. }
  1902. return { ...getCurrentPostAttribute(state, attributeName),
  1903. ...edits[attributeName]
  1904. };
  1905. };
  1906. /**
  1907. * Returns a single attribute of the post being edited, preferring the unsaved
  1908. * edit if one exists, but falling back to the attribute for the last known
  1909. * saved state of the post.
  1910. *
  1911. * @param {Object} state Global application state.
  1912. * @param {string} attributeName Post attribute name.
  1913. *
  1914. * @return {*} Post attribute value.
  1915. */
  1916. function getEditedPostAttribute(state, attributeName) {
  1917. // Special cases.
  1918. switch (attributeName) {
  1919. case 'content':
  1920. return getEditedPostContent(state);
  1921. } // Fall back to saved post value if not edited.
  1922. const edits = getPostEdits(state);
  1923. if (!edits.hasOwnProperty(attributeName)) {
  1924. return getCurrentPostAttribute(state, attributeName);
  1925. } // Merge properties are objects which contain only the patch edit in state,
  1926. // and thus must be merged with the current post attribute.
  1927. if (EDIT_MERGE_PROPERTIES.has(attributeName)) {
  1928. return getNestedEditedPostProperty(state, attributeName);
  1929. }
  1930. return edits[attributeName];
  1931. }
  1932. /**
  1933. * Returns an attribute value of the current autosave revision for a post, or
  1934. * null if there is no autosave for the post.
  1935. *
  1936. * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector
  1937. * from the '@wordpress/core-data' package and access properties on the returned
  1938. * autosave object using getPostRawValue.
  1939. *
  1940. * @param {Object} state Global application state.
  1941. * @param {string} attributeName Autosave attribute name.
  1942. *
  1943. * @return {*} Autosave attribute value.
  1944. */
  1945. const getAutosaveAttribute = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, attributeName) => {
  1946. if (!(0,external_lodash_namespaceObject.includes)(AUTOSAVE_PROPERTIES, attributeName) && attributeName !== 'preview_link') {
  1947. return;
  1948. }
  1949. const postType = getCurrentPostType(state);
  1950. const postId = getCurrentPostId(state);
  1951. const currentUserId = (0,external_lodash_namespaceObject.get)(select(external_wp_coreData_namespaceObject.store).getCurrentUser(), ['id']);
  1952. const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId);
  1953. if (autosave) {
  1954. return getPostRawValue(autosave[attributeName]);
  1955. }
  1956. });
  1957. /**
  1958. * Returns the current visibility of the post being edited, preferring the
  1959. * unsaved value if different than the saved post. The return value is one of
  1960. * "private", "password", or "public".
  1961. *
  1962. * @param {Object} state Global application state.
  1963. *
  1964. * @return {string} Post visibility.
  1965. */
  1966. function getEditedPostVisibility(state) {
  1967. const status = getEditedPostAttribute(state, 'status');
  1968. if (status === 'private') {
  1969. return 'private';
  1970. }
  1971. const password = getEditedPostAttribute(state, 'password');
  1972. if (password) {
  1973. return 'password';
  1974. }
  1975. return 'public';
  1976. }
  1977. /**
  1978. * Returns true if post is pending review.
  1979. *
  1980. * @param {Object} state Global application state.
  1981. *
  1982. * @return {boolean} Whether current post is pending review.
  1983. */
  1984. function isCurrentPostPending(state) {
  1985. return getCurrentPost(state).status === 'pending';
  1986. }
  1987. /**
  1988. * Return true if the current post has already been published.
  1989. *
  1990. * @param {Object} state Global application state.
  1991. * @param {Object?} currentPost Explicit current post for bypassing registry selector.
  1992. *
  1993. * @return {boolean} Whether the post has been published.
  1994. */
  1995. function isCurrentPostPublished(state, currentPost) {
  1996. const post = currentPost || getCurrentPost(state);
  1997. return ['publish', 'private'].indexOf(post.status) !== -1 || post.status === 'future' && !(0,external_wp_date_namespaceObject.isInTheFuture)(new Date(Number((0,external_wp_date_namespaceObject.getDate)(post.date)) - ONE_MINUTE_IN_MS));
  1998. }
  1999. /**
  2000. * Returns true if post is already scheduled.
  2001. *
  2002. * @param {Object} state Global application state.
  2003. *
  2004. * @return {boolean} Whether current post is scheduled to be posted.
  2005. */
  2006. function isCurrentPostScheduled(state) {
  2007. return getCurrentPost(state).status === 'future' && !isCurrentPostPublished(state);
  2008. }
  2009. /**
  2010. * Return true if the post being edited can be published.
  2011. *
  2012. * @param {Object} state Global application state.
  2013. *
  2014. * @return {boolean} Whether the post can been published.
  2015. */
  2016. function isEditedPostPublishable(state) {
  2017. const post = getCurrentPost(state); // TODO: Post being publishable should be superset of condition of post
  2018. // being saveable. Currently this restriction is imposed at UI.
  2019. //
  2020. // See: <PostPublishButton /> (`isButtonEnabled` assigned by `isSaveable`).
  2021. return isEditedPostDirty(state) || ['publish', 'private', 'future'].indexOf(post.status) === -1;
  2022. }
  2023. /**
  2024. * Returns true if the post can be saved, or false otherwise. A post must
  2025. * contain a title, an excerpt, or non-empty content to be valid for save.
  2026. *
  2027. * @param {Object} state Global application state.
  2028. *
  2029. * @return {boolean} Whether the post can be saved.
  2030. */
  2031. function isEditedPostSaveable(state) {
  2032. if (isSavingPost(state)) {
  2033. return false;
  2034. } // TODO: Post should not be saveable if not dirty. Cannot be added here at
  2035. // this time since posts where meta boxes are present can be saved even if
  2036. // the post is not dirty. Currently this restriction is imposed at UI, but
  2037. // should be moved here.
  2038. //
  2039. // See: `isEditedPostPublishable` (includes `isEditedPostDirty` condition)
  2040. // See: <PostSavedState /> (`forceIsDirty` prop)
  2041. // See: <PostPublishButton /> (`forceIsDirty` prop)
  2042. // See: https://github.com/WordPress/gutenberg/pull/4184.
  2043. return !!getEditedPostAttribute(state, 'title') || !!getEditedPostAttribute(state, 'excerpt') || !isEditedPostEmpty(state) || external_wp_element_namespaceObject.Platform.OS === 'native';
  2044. }
  2045. /**
  2046. * Returns true if the edited post has content. A post has content if it has at
  2047. * least one saveable block or otherwise has a non-empty content property
  2048. * assigned.
  2049. *
  2050. * @param {Object} state Global application state.
  2051. *
  2052. * @return {boolean} Whether post has content.
  2053. */
  2054. function isEditedPostEmpty(state) {
  2055. // While the condition of truthy content string is sufficient to determine
  2056. // emptiness, testing saveable blocks length is a trivial operation. Since
  2057. // this function can be called frequently, optimize for the fast case as a
  2058. // condition of the mere existence of blocks. Note that the value of edited
  2059. // content takes precedent over block content, and must fall through to the
  2060. // default logic.
  2061. const blocks = getEditorBlocks(state);
  2062. if (blocks.length) {
  2063. // Pierce the abstraction of the serializer in knowing that blocks are
  2064. // joined with with newlines such that even if every individual block
  2065. // produces an empty save result, the serialized content is non-empty.
  2066. if (blocks.length > 1) {
  2067. return false;
  2068. } // There are two conditions under which the optimization cannot be
  2069. // assumed, and a fallthrough to getEditedPostContent must occur:
  2070. //
  2071. // 1. getBlocksForSerialization has special treatment in omitting a
  2072. // single unmodified default block.
  2073. // 2. Comment delimiters are omitted for a freeform or unregistered
  2074. // block in its serialization. The freeform block specifically may
  2075. // produce an empty string in its saved output.
  2076. //
  2077. // For all other content, the single block is assumed to make a post
  2078. // non-empty, if only by virtue of its own comment delimiters.
  2079. const blockName = blocks[0].name;
  2080. if (blockName !== (0,external_wp_blocks_namespaceObject.getDefaultBlockName)() && blockName !== (0,external_wp_blocks_namespaceObject.getFreeformContentHandlerName)()) {
  2081. return false;
  2082. }
  2083. }
  2084. return !getEditedPostContent(state);
  2085. }
  2086. /**
  2087. * Returns true if the post can be autosaved, or false otherwise.
  2088. *
  2089. * @param {Object} state Global application state.
  2090. * @param {Object} autosave A raw autosave object from the REST API.
  2091. *
  2092. * @return {boolean} Whether the post can be autosaved.
  2093. */
  2094. const isEditedPostAutosaveable = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
  2095. // A post must contain a title, an excerpt, or non-empty content to be valid for autosaving.
  2096. if (!isEditedPostSaveable(state)) {
  2097. return false;
  2098. } // A post is not autosavable when there is a post autosave lock.
  2099. if (isPostAutosavingLocked(state)) {
  2100. return false;
  2101. }
  2102. const postType = getCurrentPostType(state);
  2103. const postId = getCurrentPostId(state);
  2104. const hasFetchedAutosave = select(external_wp_coreData_namespaceObject.store).hasFetchedAutosaves(postType, postId);
  2105. const currentUserId = (0,external_lodash_namespaceObject.get)(select(external_wp_coreData_namespaceObject.store).getCurrentUser(), ['id']); // Disable reason - this line causes the side-effect of fetching the autosave
  2106. // via a resolver, moving below the return would result in the autosave never
  2107. // being fetched.
  2108. // eslint-disable-next-line @wordpress/no-unused-vars-before-return
  2109. const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId); // If any existing autosaves have not yet been fetched, this function is
  2110. // unable to determine if the post is autosaveable, so return false.
  2111. if (!hasFetchedAutosave) {
  2112. return false;
  2113. } // If we don't already have an autosave, the post is autosaveable.
  2114. if (!autosave) {
  2115. return true;
  2116. } // To avoid an expensive content serialization, use the content dirtiness
  2117. // flag in place of content field comparison against the known autosave.
  2118. // This is not strictly accurate, and relies on a tolerance toward autosave
  2119. // request failures for unnecessary saves.
  2120. if (hasChangedContent(state)) {
  2121. return true;
  2122. } // If the title or excerpt has changed, the post is autosaveable.
  2123. return ['title', 'excerpt'].some(field => getPostRawValue(autosave[field]) !== getEditedPostAttribute(state, field));
  2124. });
  2125. /**
  2126. * Return true if the post being edited is being scheduled. Preferring the
  2127. * unsaved status values.
  2128. *
  2129. * @param {Object} state Global application state.
  2130. *
  2131. * @return {boolean} Whether the post has been published.
  2132. */
  2133. function isEditedPostBeingScheduled(state) {
  2134. const date = getEditedPostAttribute(state, 'date'); // Offset the date by one minute (network latency).
  2135. const checkedDate = new Date(Number((0,external_wp_date_namespaceObject.getDate)(date)) - ONE_MINUTE_IN_MS);
  2136. return (0,external_wp_date_namespaceObject.isInTheFuture)(checkedDate);
  2137. }
  2138. /**
  2139. * Returns whether the current post should be considered to have a "floating"
  2140. * date (i.e. that it would publish "Immediately" rather than at a set time).
  2141. *
  2142. * Unlike in the PHP backend, the REST API returns a full date string for posts
  2143. * where the 0000-00-00T00:00:00 placeholder is present in the database. To
  2144. * infer that a post is set to publish "Immediately" we check whether the date
  2145. * and modified date are the same.
  2146. *
  2147. * @param {Object} state Editor state.
  2148. *
  2149. * @return {boolean} Whether the edited post has a floating date value.
  2150. */
  2151. function isEditedPostDateFloating(state) {
  2152. const date = getEditedPostAttribute(state, 'date');
  2153. const modified = getEditedPostAttribute(state, 'modified'); // This should be the status of the persisted post
  2154. // It shouldn't use the "edited" status otherwise it breaks the
  2155. // inferred post data floating status
  2156. // See https://github.com/WordPress/gutenberg/issues/28083.
  2157. const status = getCurrentPost(state).status;
  2158. if (status === 'draft' || status === 'auto-draft' || status === 'pending') {
  2159. return date === modified || date === null;
  2160. }
  2161. return false;
  2162. }
  2163. /**
  2164. * Returns true if the post is currently being saved, or false otherwise.
  2165. *
  2166. * @param {Object} state Global application state.
  2167. *
  2168. * @return {boolean} Whether post is being saved.
  2169. */
  2170. const isSavingPost = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
  2171. const postType = getCurrentPostType(state);
  2172. const postId = getCurrentPostId(state);
  2173. return select(external_wp_coreData_namespaceObject.store).isSavingEntityRecord('postType', postType, postId);
  2174. });
  2175. /**
  2176. * Returns true if non-post entities are currently being saved, or false otherwise.
  2177. *
  2178. * @param {Object} state Global application state.
  2179. *
  2180. * @return {boolean} Whether non-post entities are being saved.
  2181. */
  2182. const isSavingNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
  2183. const entitiesBeingSaved = select(external_wp_coreData_namespaceObject.store).__experimentalGetEntitiesBeingSaved();
  2184. const {
  2185. type,
  2186. id
  2187. } = getCurrentPost(state);
  2188. return (0,external_lodash_namespaceObject.some)(entitiesBeingSaved, entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id);
  2189. });
  2190. /**
  2191. * Returns true if a previous post save was attempted successfully, or false
  2192. * otherwise.
  2193. *
  2194. * @param {Object} state Global application state.
  2195. *
  2196. * @return {boolean} Whether the post was saved successfully.
  2197. */
  2198. const didPostSaveRequestSucceed = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
  2199. const postType = getCurrentPostType(state);
  2200. const postId = getCurrentPostId(state);
  2201. return !select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
  2202. });
  2203. /**
  2204. * Returns true if a previous post save was attempted but failed, or false
  2205. * otherwise.
  2206. *
  2207. * @param {Object} state Global application state.
  2208. *
  2209. * @return {boolean} Whether the post save failed.
  2210. */
  2211. const didPostSaveRequestFail = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
  2212. const postType = getCurrentPostType(state);
  2213. const postId = getCurrentPostId(state);
  2214. return !!select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
  2215. });
  2216. /**
  2217. * Returns true if the post is autosaving, or false otherwise.
  2218. *
  2219. * @param {Object} state Global application state.
  2220. *
  2221. * @return {boolean} Whether the post is autosaving.
  2222. */
  2223. function isAutosavingPost(state) {
  2224. if (!isSavingPost(state)) {
  2225. return false;
  2226. }
  2227. return !!(0,external_lodash_namespaceObject.get)(state.saving, ['options', 'isAutosave']);
  2228. }
  2229. /**
  2230. * Returns true if the post is being previewed, or false otherwise.
  2231. *
  2232. * @param {Object} state Global application state.
  2233. *
  2234. * @return {boolean} Whether the post is being previewed.
  2235. */
  2236. function isPreviewingPost(state) {
  2237. if (!isSavingPost(state)) {
  2238. return false;
  2239. }
  2240. return !!(0,external_lodash_namespaceObject.get)(state.saving, ['options', 'isPreview']);
  2241. }
  2242. /**
  2243. * Returns the post preview link
  2244. *
  2245. * @param {Object} state Global application state.
  2246. *
  2247. * @return {string?} Preview Link.
  2248. */
  2249. function getEditedPostPreviewLink(state) {
  2250. if (state.saving.pending || isSavingPost(state)) {
  2251. return;
  2252. }
  2253. let previewLink = getAutosaveAttribute(state, 'preview_link'); // Fix for issue: https://github.com/WordPress/gutenberg/issues/33616
  2254. // If the post is draft, ignore the preview link from the autosave record,
  2255. // because the preview could be a stale autosave if the post was switched from
  2256. // published to draft.
  2257. // See: https://github.com/WordPress/gutenberg/pull/37952.
  2258. if (!previewLink || 'draft' === getCurrentPost(state).status) {
  2259. previewLink = getEditedPostAttribute(state, 'link');
  2260. if (previewLink) {
  2261. previewLink = (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
  2262. preview: true
  2263. });
  2264. }
  2265. }
  2266. const featuredImageId = getEditedPostAttribute(state, 'featured_media');
  2267. if (previewLink && featuredImageId) {
  2268. return (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
  2269. _thumbnail_id: featuredImageId
  2270. });
  2271. }
  2272. return previewLink;
  2273. }
  2274. /**
  2275. * Returns a suggested post format for the current post, inferred only if there
  2276. * is a single block within the post and it is of a type known to match a
  2277. * default post format. Returns null if the format cannot be determined.
  2278. *
  2279. * @param {Object} state Global application state.
  2280. *
  2281. * @return {?string} Suggested post format.
  2282. */
  2283. function getSuggestedPostFormat(state) {
  2284. const blocks = getEditorBlocks(state);
  2285. if (blocks.length > 2) return null;
  2286. let name; // If there is only one block in the content of the post grab its name
  2287. // so we can derive a suitable post format from it.
  2288. if (blocks.length === 1) {
  2289. name = blocks[0].name; // Check for core/embed `video` and `audio` eligible suggestions.
  2290. if (name === 'core/embed') {
  2291. var _blocks$0$attributes;
  2292. const provider = (_blocks$0$attributes = blocks[0].attributes) === null || _blocks$0$attributes === void 0 ? void 0 : _blocks$0$attributes.providerNameSlug;
  2293. if (['youtube', 'vimeo'].includes(provider)) {
  2294. name = 'core/video';
  2295. } else if (['spotify', 'soundcloud'].includes(provider)) {
  2296. name = 'core/audio';
  2297. }
  2298. }
  2299. } // If there are two blocks in the content and the last one is a text blocks
  2300. // grab the name of the first one to also suggest a post format from it.
  2301. if (blocks.length === 2 && blocks[1].name === 'core/paragraph') {
  2302. name = blocks[0].name;
  2303. } // We only convert to default post formats in core.
  2304. switch (name) {
  2305. case 'core/image':
  2306. return 'image';
  2307. case 'core/quote':
  2308. case 'core/pullquote':
  2309. return 'quote';
  2310. case 'core/gallery':
  2311. return 'gallery';
  2312. case 'core/video':
  2313. return 'video';
  2314. case 'core/audio':
  2315. return 'audio';
  2316. default:
  2317. return null;
  2318. }
  2319. }
  2320. /**
  2321. * Returns the content of the post being edited.
  2322. *
  2323. * @param {Object} state Global application state.
  2324. *
  2325. * @return {string} Post content.
  2326. */
  2327. const getEditedPostContent = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
  2328. const postId = getCurrentPostId(state);
  2329. const postType = getCurrentPostType(state);
  2330. const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
  2331. if (record) {
  2332. if (typeof record.content === 'function') {
  2333. return record.content(record);
  2334. } else if (record.blocks) {
  2335. return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
  2336. } else if (record.content) {
  2337. return record.content;
  2338. }
  2339. }
  2340. return '';
  2341. });
  2342. /**
  2343. * Returns true if the post is being published, or false otherwise.
  2344. *
  2345. * @param {Object} state Global application state.
  2346. *
  2347. * @return {boolean} Whether post is being published.
  2348. */
  2349. function isPublishingPost(state) {
  2350. return isSavingPost(state) && !isCurrentPostPublished(state) && getEditedPostAttribute(state, 'status') === 'publish';
  2351. }
  2352. /**
  2353. * Returns whether the permalink is editable or not.
  2354. *
  2355. * @param {Object} state Editor state.
  2356. *
  2357. * @return {boolean} Whether or not the permalink is editable.
  2358. */
  2359. function isPermalinkEditable(state) {
  2360. const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
  2361. return PERMALINK_POSTNAME_REGEX.test(permalinkTemplate);
  2362. }
  2363. /**
  2364. * Returns the permalink for the post.
  2365. *
  2366. * @param {Object} state Editor state.
  2367. *
  2368. * @return {?string} The permalink, or null if the post is not viewable.
  2369. */
  2370. function getPermalink(state) {
  2371. const permalinkParts = getPermalinkParts(state);
  2372. if (!permalinkParts) {
  2373. return null;
  2374. }
  2375. const {
  2376. prefix,
  2377. postName,
  2378. suffix
  2379. } = permalinkParts;
  2380. if (isPermalinkEditable(state)) {
  2381. return prefix + postName + suffix;
  2382. }
  2383. return prefix;
  2384. }
  2385. /**
  2386. * Returns the slug for the post being edited, preferring a manually edited
  2387. * value if one exists, then a sanitized version of the current post title, and
  2388. * finally the post ID.
  2389. *
  2390. * @param {Object} state Editor state.
  2391. *
  2392. * @return {string} The current slug to be displayed in the editor
  2393. */
  2394. function getEditedPostSlug(state) {
  2395. return getEditedPostAttribute(state, 'slug') || (0,external_wp_url_namespaceObject.cleanForSlug)(getEditedPostAttribute(state, 'title')) || getCurrentPostId(state);
  2396. }
  2397. /**
  2398. * Returns the permalink for a post, split into it's three parts: the prefix,
  2399. * the postName, and the suffix.
  2400. *
  2401. * @param {Object} state Editor state.
  2402. *
  2403. * @return {Object} An object containing the prefix, postName, and suffix for
  2404. * the permalink, or null if the post is not viewable.
  2405. */
  2406. function getPermalinkParts(state) {
  2407. const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
  2408. if (!permalinkTemplate) {
  2409. return null;
  2410. }
  2411. const postName = getEditedPostAttribute(state, 'slug') || getEditedPostAttribute(state, 'generated_slug');
  2412. const [prefix, suffix] = permalinkTemplate.split(PERMALINK_POSTNAME_REGEX);
  2413. return {
  2414. prefix,
  2415. postName,
  2416. suffix
  2417. };
  2418. }
  2419. /**
  2420. * Returns whether the post is locked.
  2421. *
  2422. * @param {Object} state Global application state.
  2423. *
  2424. * @return {boolean} Is locked.
  2425. */
  2426. function isPostLocked(state) {
  2427. return state.postLock.isLocked;
  2428. }
  2429. /**
  2430. * Returns whether post saving is locked.
  2431. *
  2432. * @param {Object} state Global application state.
  2433. *
  2434. * @return {boolean} Is locked.
  2435. */
  2436. function isPostSavingLocked(state) {
  2437. return Object.keys(state.postSavingLock).length > 0;
  2438. }
  2439. /**
  2440. * Returns whether post autosaving is locked.
  2441. *
  2442. * @param {Object} state Global application state.
  2443. *
  2444. * @return {boolean} Is locked.
  2445. */
  2446. function isPostAutosavingLocked(state) {
  2447. return Object.keys(state.postAutosavingLock).length > 0;
  2448. }
  2449. /**
  2450. * Returns whether the edition of the post has been taken over.
  2451. *
  2452. * @param {Object} state Global application state.
  2453. *
  2454. * @return {boolean} Is post lock takeover.
  2455. */
  2456. function isPostLockTakeover(state) {
  2457. return state.postLock.isTakeover;
  2458. }
  2459. /**
  2460. * Returns details about the post lock user.
  2461. *
  2462. * @param {Object} state Global application state.
  2463. *
  2464. * @return {Object} A user object.
  2465. */
  2466. function getPostLockUser(state) {
  2467. return state.postLock.user;
  2468. }
  2469. /**
  2470. * Returns the active post lock.
  2471. *
  2472. * @param {Object} state Global application state.
  2473. *
  2474. * @return {Object} The lock object.
  2475. */
  2476. function getActivePostLock(state) {
  2477. return state.postLock.activePostLock;
  2478. }
  2479. /**
  2480. * Returns whether or not the user has the unfiltered_html capability.
  2481. *
  2482. * @param {Object} state Editor state.
  2483. *
  2484. * @return {boolean} Whether the user can or can't post unfiltered HTML.
  2485. */
  2486. function canUserUseUnfilteredHTML(state) {
  2487. return (0,external_lodash_namespaceObject.has)(getCurrentPost(state), ['_links', 'wp:action-unfiltered-html']);
  2488. }
  2489. /**
  2490. * Returns whether the pre-publish panel should be shown
  2491. * or skipped when the user clicks the "publish" button.
  2492. *
  2493. * @return {boolean} Whether the pre-publish panel should be shown or not.
  2494. */
  2495. const isPublishSidebarEnabled = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => !!select(external_wp_preferences_namespaceObject.store).get('core/edit-post', 'isPublishSidebarEnabled'));
  2496. /**
  2497. * Return the current block list.
  2498. *
  2499. * @param {Object} state
  2500. * @return {Array} Block list.
  2501. */
  2502. function getEditorBlocks(state) {
  2503. return getEditedPostAttribute(state, 'blocks') || EMPTY_ARRAY;
  2504. }
  2505. /**
  2506. * A block selection object.
  2507. *
  2508. * @typedef {Object} WPBlockSelection
  2509. *
  2510. * @property {string} clientId A block client ID.
  2511. * @property {string} attributeKey A block attribute key.
  2512. * @property {number} offset An attribute value offset, based on the rich
  2513. * text value. See `wp.richText.create`.
  2514. */
  2515. /**
  2516. * Returns the current selection start.
  2517. *
  2518. * @param {Object} state
  2519. * @return {WPBlockSelection} The selection start.
  2520. *
  2521. * @deprecated since Gutenberg 10.0.0.
  2522. */
  2523. function getEditorSelectionStart(state) {
  2524. var _getEditedPostAttribu;
  2525. external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", {
  2526. since: '5.8',
  2527. alternative: "select('core/editor').getEditorSelection"
  2528. });
  2529. return (_getEditedPostAttribu = getEditedPostAttribute(state, 'selection')) === null || _getEditedPostAttribu === void 0 ? void 0 : _getEditedPostAttribu.selectionStart;
  2530. }
  2531. /**
  2532. * Returns the current selection end.
  2533. *
  2534. * @param {Object} state
  2535. * @return {WPBlockSelection} The selection end.
  2536. *
  2537. * @deprecated since Gutenberg 10.0.0.
  2538. */
  2539. function getEditorSelectionEnd(state) {
  2540. var _getEditedPostAttribu2;
  2541. external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", {
  2542. since: '5.8',
  2543. alternative: "select('core/editor').getEditorSelection"
  2544. });
  2545. return (_getEditedPostAttribu2 = getEditedPostAttribute(state, 'selection')) === null || _getEditedPostAttribu2 === void 0 ? void 0 : _getEditedPostAttribu2.selectionEnd;
  2546. }
  2547. /**
  2548. * Returns the current selection.
  2549. *
  2550. * @param {Object} state
  2551. * @return {WPBlockSelection} The selection end.
  2552. */
  2553. function getEditorSelection(state) {
  2554. return getEditedPostAttribute(state, 'selection');
  2555. }
  2556. /**
  2557. * Is the editor ready
  2558. *
  2559. * @param {Object} state
  2560. * @return {boolean} is Ready.
  2561. */
  2562. function __unstableIsEditorReady(state) {
  2563. return state.isReady;
  2564. }
  2565. /**
  2566. * Returns the post editor settings.
  2567. *
  2568. * @param {Object} state Editor state.
  2569. *
  2570. * @return {Object} The editor settings object.
  2571. */
  2572. function getEditorSettings(state) {
  2573. return state.editorSettings;
  2574. }
  2575. /*
  2576. * Backward compatibility
  2577. */
  2578. /**
  2579. * Returns state object prior to a specified optimist transaction ID, or `null`
  2580. * if the transaction corresponding to the given ID cannot be found.
  2581. *
  2582. * @deprecated since Gutenberg 9.7.0.
  2583. */
  2584. function getStateBeforeOptimisticTransaction() {
  2585. external_wp_deprecated_default()("select('core/editor').getStateBeforeOptimisticTransaction", {
  2586. since: '5.7',
  2587. hint: 'No state history is kept on this store anymore'
  2588. });
  2589. return null;
  2590. }
  2591. /**
  2592. * Returns true if an optimistic transaction is pending commit, for which the
  2593. * before state satisfies the given predicate function.
  2594. *
  2595. * @deprecated since Gutenberg 9.7.0.
  2596. */
  2597. function inSomeHistory() {
  2598. external_wp_deprecated_default()("select('core/editor').inSomeHistory", {
  2599. since: '5.7',
  2600. hint: 'No state history is kept on this store anymore'
  2601. });
  2602. return false;
  2603. }
  2604. function getBlockEditorSelector(name) {
  2605. return (0,external_wp_data_namespaceObject.createRegistrySelector)(select => function (state) {
  2606. external_wp_deprecated_default()("`wp.data.select( 'core/editor' )." + name + '`', {
  2607. since: '5.3',
  2608. alternative: "`wp.data.select( 'core/block-editor' )." + name + '`',
  2609. version: '6.2'
  2610. });
  2611. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  2612. args[_key - 1] = arguments[_key];
  2613. }
  2614. return select(external_wp_blockEditor_namespaceObject.store)[name](...args);
  2615. });
  2616. }
  2617. /**
  2618. * @see getBlockName in core/block-editor store.
  2619. */
  2620. const getBlockName = getBlockEditorSelector('getBlockName');
  2621. /**
  2622. * @see isBlockValid in core/block-editor store.
  2623. */
  2624. const isBlockValid = getBlockEditorSelector('isBlockValid');
  2625. /**
  2626. * @see getBlockAttributes in core/block-editor store.
  2627. */
  2628. const getBlockAttributes = getBlockEditorSelector('getBlockAttributes');
  2629. /**
  2630. * @see getBlock in core/block-editor store.
  2631. */
  2632. const getBlock = getBlockEditorSelector('getBlock');
  2633. /**
  2634. * @see getBlocks in core/block-editor store.
  2635. */
  2636. const getBlocks = getBlockEditorSelector('getBlocks');
  2637. /**
  2638. * @see getClientIdsOfDescendants in core/block-editor store.
  2639. */
  2640. const getClientIdsOfDescendants = getBlockEditorSelector('getClientIdsOfDescendants');
  2641. /**
  2642. * @see getClientIdsWithDescendants in core/block-editor store.
  2643. */
  2644. const getClientIdsWithDescendants = getBlockEditorSelector('getClientIdsWithDescendants');
  2645. /**
  2646. * @see getGlobalBlockCount in core/block-editor store.
  2647. */
  2648. const getGlobalBlockCount = getBlockEditorSelector('getGlobalBlockCount');
  2649. /**
  2650. * @see getBlocksByClientId in core/block-editor store.
  2651. */
  2652. const getBlocksByClientId = getBlockEditorSelector('getBlocksByClientId');
  2653. /**
  2654. * @see getBlockCount in core/block-editor store.
  2655. */
  2656. const getBlockCount = getBlockEditorSelector('getBlockCount');
  2657. /**
  2658. * @see getBlockSelectionStart in core/block-editor store.
  2659. */
  2660. const getBlockSelectionStart = getBlockEditorSelector('getBlockSelectionStart');
  2661. /**
  2662. * @see getBlockSelectionEnd in core/block-editor store.
  2663. */
  2664. const getBlockSelectionEnd = getBlockEditorSelector('getBlockSelectionEnd');
  2665. /**
  2666. * @see getSelectedBlockCount in core/block-editor store.
  2667. */
  2668. const getSelectedBlockCount = getBlockEditorSelector('getSelectedBlockCount');
  2669. /**
  2670. * @see hasSelectedBlock in core/block-editor store.
  2671. */
  2672. const hasSelectedBlock = getBlockEditorSelector('hasSelectedBlock');
  2673. /**
  2674. * @see getSelectedBlockClientId in core/block-editor store.
  2675. */
  2676. const getSelectedBlockClientId = getBlockEditorSelector('getSelectedBlockClientId');
  2677. /**
  2678. * @see getSelectedBlock in core/block-editor store.
  2679. */
  2680. const getSelectedBlock = getBlockEditorSelector('getSelectedBlock');
  2681. /**
  2682. * @see getBlockRootClientId in core/block-editor store.
  2683. */
  2684. const getBlockRootClientId = getBlockEditorSelector('getBlockRootClientId');
  2685. /**
  2686. * @see getBlockHierarchyRootClientId in core/block-editor store.
  2687. */
  2688. const getBlockHierarchyRootClientId = getBlockEditorSelector('getBlockHierarchyRootClientId');
  2689. /**
  2690. * @see getAdjacentBlockClientId in core/block-editor store.
  2691. */
  2692. const getAdjacentBlockClientId = getBlockEditorSelector('getAdjacentBlockClientId');
  2693. /**
  2694. * @see getPreviousBlockClientId in core/block-editor store.
  2695. */
  2696. const getPreviousBlockClientId = getBlockEditorSelector('getPreviousBlockClientId');
  2697. /**
  2698. * @see getNextBlockClientId in core/block-editor store.
  2699. */
  2700. const getNextBlockClientId = getBlockEditorSelector('getNextBlockClientId');
  2701. /**
  2702. * @see getSelectedBlocksInitialCaretPosition in core/block-editor store.
  2703. */
  2704. const getSelectedBlocksInitialCaretPosition = getBlockEditorSelector('getSelectedBlocksInitialCaretPosition');
  2705. /**
  2706. * @see getMultiSelectedBlockClientIds in core/block-editor store.
  2707. */
  2708. const getMultiSelectedBlockClientIds = getBlockEditorSelector('getMultiSelectedBlockClientIds');
  2709. /**
  2710. * @see getMultiSelectedBlocks in core/block-editor store.
  2711. */
  2712. const getMultiSelectedBlocks = getBlockEditorSelector('getMultiSelectedBlocks');
  2713. /**
  2714. * @see getFirstMultiSelectedBlockClientId in core/block-editor store.
  2715. */
  2716. const getFirstMultiSelectedBlockClientId = getBlockEditorSelector('getFirstMultiSelectedBlockClientId');
  2717. /**
  2718. * @see getLastMultiSelectedBlockClientId in core/block-editor store.
  2719. */
  2720. const getLastMultiSelectedBlockClientId = getBlockEditorSelector('getLastMultiSelectedBlockClientId');
  2721. /**
  2722. * @see isFirstMultiSelectedBlock in core/block-editor store.
  2723. */
  2724. const isFirstMultiSelectedBlock = getBlockEditorSelector('isFirstMultiSelectedBlock');
  2725. /**
  2726. * @see isBlockMultiSelected in core/block-editor store.
  2727. */
  2728. const isBlockMultiSelected = getBlockEditorSelector('isBlockMultiSelected');
  2729. /**
  2730. * @see isAncestorMultiSelected in core/block-editor store.
  2731. */
  2732. const isAncestorMultiSelected = getBlockEditorSelector('isAncestorMultiSelected');
  2733. /**
  2734. * @see getMultiSelectedBlocksStartClientId in core/block-editor store.
  2735. */
  2736. const getMultiSelectedBlocksStartClientId = getBlockEditorSelector('getMultiSelectedBlocksStartClientId');
  2737. /**
  2738. * @see getMultiSelectedBlocksEndClientId in core/block-editor store.
  2739. */
  2740. const getMultiSelectedBlocksEndClientId = getBlockEditorSelector('getMultiSelectedBlocksEndClientId');
  2741. /**
  2742. * @see getBlockOrder in core/block-editor store.
  2743. */
  2744. const getBlockOrder = getBlockEditorSelector('getBlockOrder');
  2745. /**
  2746. * @see getBlockIndex in core/block-editor store.
  2747. */
  2748. const getBlockIndex = getBlockEditorSelector('getBlockIndex');
  2749. /**
  2750. * @see isBlockSelected in core/block-editor store.
  2751. */
  2752. const isBlockSelected = getBlockEditorSelector('isBlockSelected');
  2753. /**
  2754. * @see hasSelectedInnerBlock in core/block-editor store.
  2755. */
  2756. const hasSelectedInnerBlock = getBlockEditorSelector('hasSelectedInnerBlock');
  2757. /**
  2758. * @see isBlockWithinSelection in core/block-editor store.
  2759. */
  2760. const isBlockWithinSelection = getBlockEditorSelector('isBlockWithinSelection');
  2761. /**
  2762. * @see hasMultiSelection in core/block-editor store.
  2763. */
  2764. const hasMultiSelection = getBlockEditorSelector('hasMultiSelection');
  2765. /**
  2766. * @see isMultiSelecting in core/block-editor store.
  2767. */
  2768. const isMultiSelecting = getBlockEditorSelector('isMultiSelecting');
  2769. /**
  2770. * @see isSelectionEnabled in core/block-editor store.
  2771. */
  2772. const isSelectionEnabled = getBlockEditorSelector('isSelectionEnabled');
  2773. /**
  2774. * @see getBlockMode in core/block-editor store.
  2775. */
  2776. const getBlockMode = getBlockEditorSelector('getBlockMode');
  2777. /**
  2778. * @see isTyping in core/block-editor store.
  2779. */
  2780. const isTyping = getBlockEditorSelector('isTyping');
  2781. /**
  2782. * @see isCaretWithinFormattedText in core/block-editor store.
  2783. */
  2784. const isCaretWithinFormattedText = getBlockEditorSelector('isCaretWithinFormattedText');
  2785. /**
  2786. * @see getBlockInsertionPoint in core/block-editor store.
  2787. */
  2788. const getBlockInsertionPoint = getBlockEditorSelector('getBlockInsertionPoint');
  2789. /**
  2790. * @see isBlockInsertionPointVisible in core/block-editor store.
  2791. */
  2792. const isBlockInsertionPointVisible = getBlockEditorSelector('isBlockInsertionPointVisible');
  2793. /**
  2794. * @see isValidTemplate in core/block-editor store.
  2795. */
  2796. const isValidTemplate = getBlockEditorSelector('isValidTemplate');
  2797. /**
  2798. * @see getTemplate in core/block-editor store.
  2799. */
  2800. const getTemplate = getBlockEditorSelector('getTemplate');
  2801. /**
  2802. * @see getTemplateLock in core/block-editor store.
  2803. */
  2804. const getTemplateLock = getBlockEditorSelector('getTemplateLock');
  2805. /**
  2806. * @see canInsertBlockType in core/block-editor store.
  2807. */
  2808. const canInsertBlockType = getBlockEditorSelector('canInsertBlockType');
  2809. /**
  2810. * @see getInserterItems in core/block-editor store.
  2811. */
  2812. const getInserterItems = getBlockEditorSelector('getInserterItems');
  2813. /**
  2814. * @see hasInserterItems in core/block-editor store.
  2815. */
  2816. const hasInserterItems = getBlockEditorSelector('hasInserterItems');
  2817. /**
  2818. * @see getBlockListSettings in core/block-editor store.
  2819. */
  2820. const getBlockListSettings = getBlockEditorSelector('getBlockListSettings');
  2821. /**
  2822. * Returns the default template types.
  2823. *
  2824. * @param {Object} state Global application state.
  2825. *
  2826. * @return {Object} The template types.
  2827. */
  2828. function __experimentalGetDefaultTemplateTypes(state) {
  2829. var _getEditorSettings;
  2830. return (_getEditorSettings = getEditorSettings(state)) === null || _getEditorSettings === void 0 ? void 0 : _getEditorSettings.defaultTemplateTypes;
  2831. }
  2832. /**
  2833. * Returns the default template part areas.
  2834. *
  2835. * @param {Object} state Global application state.
  2836. *
  2837. * @return {Array} The template part areas.
  2838. */
  2839. const __experimentalGetDefaultTemplatePartAreas = rememo(state => {
  2840. var _getEditorSettings2;
  2841. const areas = ((_getEditorSettings2 = getEditorSettings(state)) === null || _getEditorSettings2 === void 0 ? void 0 : _getEditorSettings2.defaultTemplatePartAreas) || [];
  2842. return areas === null || areas === void 0 ? void 0 : areas.map(item => {
  2843. return { ...item,
  2844. icon: getTemplatePartIcon(item.icon)
  2845. };
  2846. });
  2847. }, state => {
  2848. var _getEditorSettings3;
  2849. return [(_getEditorSettings3 = getEditorSettings(state)) === null || _getEditorSettings3 === void 0 ? void 0 : _getEditorSettings3.defaultTemplatePartAreas];
  2850. });
  2851. /**
  2852. * Returns a default template type searched by slug.
  2853. *
  2854. * @param {Object} state Global application state.
  2855. * @param {string} slug The template type slug.
  2856. *
  2857. * @return {Object} The template type.
  2858. */
  2859. const __experimentalGetDefaultTemplateType = rememo((state, slug) => (0,external_lodash_namespaceObject.find)(__experimentalGetDefaultTemplateTypes(state), {
  2860. slug
  2861. }) || {}, (state, slug) => [__experimentalGetDefaultTemplateTypes(state), slug]);
  2862. /**
  2863. * Given a template entity, return information about it which is ready to be
  2864. * rendered, such as the title, description, and icon.
  2865. *
  2866. * @param {Object} state Global application state.
  2867. * @param {Object} template The template for which we need information.
  2868. * @return {Object} Information about the template, including title, description, and icon.
  2869. */
  2870. function __experimentalGetTemplateInfo(state, template) {
  2871. var _experimentalGetDefa;
  2872. if (!template) {
  2873. return {};
  2874. }
  2875. const {
  2876. excerpt,
  2877. slug,
  2878. title,
  2879. area
  2880. } = template;
  2881. const {
  2882. title: defaultTitle,
  2883. description: defaultDescription
  2884. } = __experimentalGetDefaultTemplateType(state, slug);
  2885. const templateTitle = (0,external_lodash_namespaceObject.isString)(title) ? title : title === null || title === void 0 ? void 0 : title.rendered;
  2886. const templateDescription = (0,external_lodash_namespaceObject.isString)(excerpt) ? excerpt : excerpt === null || excerpt === void 0 ? void 0 : excerpt.raw;
  2887. const templateIcon = ((_experimentalGetDefa = __experimentalGetDefaultTemplatePartAreas(state).find(item => area === item.area)) === null || _experimentalGetDefa === void 0 ? void 0 : _experimentalGetDefa.icon) || library_layout;
  2888. return {
  2889. title: templateTitle && templateTitle !== slug ? templateTitle : defaultTitle || slug,
  2890. description: templateDescription || defaultDescription,
  2891. icon: templateIcon
  2892. };
  2893. }
  2894. /**
  2895. * Returns a post type label depending on the current post.
  2896. *
  2897. * @param {Object} state Global application state.
  2898. *
  2899. * @return {string|undefined} The post type label if available, otherwise undefined.
  2900. */
  2901. const getPostTypeLabel = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
  2902. var _postType$labels;
  2903. const currentPostType = getCurrentPostType(state);
  2904. const postType = select(external_wp_coreData_namespaceObject.store).getPostType(currentPostType); // Disable reason: Post type labels object is shaped like this.
  2905. // eslint-disable-next-line camelcase
  2906. return postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : _postType$labels.singular_name;
  2907. });
  2908. ;// CONCATENATED MODULE: external ["wp","apiFetch"]
  2909. var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
  2910. var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
  2911. ;// CONCATENATED MODULE: external ["wp","notices"]
  2912. var external_wp_notices_namespaceObject = window["wp"]["notices"];
  2913. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/local-autosave.js
  2914. /**
  2915. * Function returning a sessionStorage key to set or retrieve a given post's
  2916. * automatic session backup.
  2917. *
  2918. * Keys are crucially prefixed with 'wp-autosave-' so that wp-login.php's
  2919. * `loggedout` handler can clear sessionStorage of any user-private content.
  2920. *
  2921. * @see https://github.com/WordPress/wordpress-develop/blob/6dad32d2aed47e6c0cf2aee8410645f6d7aba6bd/src/wp-login.php#L103
  2922. *
  2923. * @param {string} postId Post ID.
  2924. * @param {boolean} isPostNew Whether post new.
  2925. *
  2926. * @return {string} sessionStorage key
  2927. */
  2928. function postKey(postId, isPostNew) {
  2929. return `wp-autosave-block-editor-post-${isPostNew ? 'auto-draft' : postId}`;
  2930. }
  2931. function localAutosaveGet(postId, isPostNew) {
  2932. return window.sessionStorage.getItem(postKey(postId, isPostNew));
  2933. }
  2934. function localAutosaveSet(postId, isPostNew, title, content, excerpt) {
  2935. window.sessionStorage.setItem(postKey(postId, isPostNew), JSON.stringify({
  2936. post_title: title,
  2937. content,
  2938. excerpt
  2939. }));
  2940. }
  2941. function localAutosaveClear(postId, isPostNew) {
  2942. window.sessionStorage.removeItem(postKey(postId, isPostNew));
  2943. }
  2944. ;// CONCATENATED MODULE: external ["wp","i18n"]
  2945. var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  2946. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/utils/notice-builder.js
  2947. /**
  2948. * WordPress dependencies
  2949. */
  2950. /**
  2951. * Internal dependencies
  2952. */
  2953. /**
  2954. * External dependencies
  2955. */
  2956. /**
  2957. * Builds the arguments for a success notification dispatch.
  2958. *
  2959. * @param {Object} data Incoming data to build the arguments from.
  2960. *
  2961. * @return {Array} Arguments for dispatch. An empty array signals no
  2962. * notification should be sent.
  2963. */
  2964. function getNotificationArgumentsForSaveSuccess(data) {
  2965. const {
  2966. previousPost,
  2967. post,
  2968. postType
  2969. } = data; // Autosaves are neither shown a notice nor redirected.
  2970. if ((0,external_lodash_namespaceObject.get)(data.options, ['isAutosave'])) {
  2971. return [];
  2972. } // No notice is shown after trashing a post
  2973. if (post.status === 'trash' && previousPost.status !== 'trash') {
  2974. return [];
  2975. }
  2976. const publishStatus = ['publish', 'private', 'future'];
  2977. const isPublished = (0,external_lodash_namespaceObject.includes)(publishStatus, previousPost.status);
  2978. const willPublish = (0,external_lodash_namespaceObject.includes)(publishStatus, post.status);
  2979. let noticeMessage;
  2980. let shouldShowLink = (0,external_lodash_namespaceObject.get)(postType, ['viewable'], false);
  2981. let isDraft; // Always should a notice, which will be spoken for accessibility.
  2982. if (!isPublished && !willPublish) {
  2983. // If saving a non-published post, don't show notice.
  2984. noticeMessage = (0,external_wp_i18n_namespaceObject.__)('Draft saved.');
  2985. isDraft = true;
  2986. } else if (isPublished && !willPublish) {
  2987. // If undoing publish status, show specific notice.
  2988. noticeMessage = postType.labels.item_reverted_to_draft;
  2989. shouldShowLink = false;
  2990. } else if (!isPublished && willPublish) {
  2991. // If publishing or scheduling a post, show the corresponding
  2992. // publish message.
  2993. noticeMessage = {
  2994. publish: postType.labels.item_published,
  2995. private: postType.labels.item_published_privately,
  2996. future: postType.labels.item_scheduled
  2997. }[post.status];
  2998. } else {
  2999. // Generic fallback notice.
  3000. noticeMessage = postType.labels.item_updated;
  3001. }
  3002. const actions = [];
  3003. if (shouldShowLink) {
  3004. actions.push({
  3005. label: isDraft ? (0,external_wp_i18n_namespaceObject.__)('View Preview') : postType.labels.view_item,
  3006. url: post.link
  3007. });
  3008. }
  3009. return [noticeMessage, {
  3010. id: SAVE_POST_NOTICE_ID,
  3011. type: 'snackbar',
  3012. actions
  3013. }];
  3014. }
  3015. /**
  3016. * Builds the fail notification arguments for dispatch.
  3017. *
  3018. * @param {Object} data Incoming data to build the arguments with.
  3019. *
  3020. * @return {Array} Arguments for dispatch. An empty array signals no
  3021. * notification should be sent.
  3022. */
  3023. function getNotificationArgumentsForSaveFail(data) {
  3024. const {
  3025. post,
  3026. edits,
  3027. error
  3028. } = data;
  3029. if (error && 'rest_autosave_no_changes' === error.code) {
  3030. // Autosave requested a new autosave, but there were no changes. This shouldn't
  3031. // result in an error notice for the user.
  3032. return [];
  3033. }
  3034. const publishStatus = ['publish', 'private', 'future'];
  3035. const isPublished = publishStatus.indexOf(post.status) !== -1; // If the post was being published, we show the corresponding publish error message
  3036. // Unless we publish an "updating failed" message.
  3037. const messages = {
  3038. publish: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'),
  3039. private: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'),
  3040. future: (0,external_wp_i18n_namespaceObject.__)('Scheduling failed.')
  3041. };
  3042. let noticeMessage = !isPublished && publishStatus.indexOf(edits.status) !== -1 ? messages[edits.status] : (0,external_wp_i18n_namespaceObject.__)('Updating failed.'); // Check if message string contains HTML. Notice text is currently only
  3043. // supported as plaintext, and stripping the tags may muddle the meaning.
  3044. if (error.message && !/<\/?[^>]*>/.test(error.message)) {
  3045. noticeMessage = [noticeMessage, error.message].join(' ');
  3046. }
  3047. return [noticeMessage, {
  3048. id: SAVE_POST_NOTICE_ID
  3049. }];
  3050. }
  3051. /**
  3052. * Builds the trash fail notification arguments for dispatch.
  3053. *
  3054. * @param {Object} data
  3055. *
  3056. * @return {Array} Arguments for dispatch.
  3057. */
  3058. function getNotificationArgumentsForTrashFail(data) {
  3059. return [data.error.message && data.error.code !== 'unknown_error' ? data.error.message : (0,external_wp_i18n_namespaceObject.__)('Trashing failed'), {
  3060. id: TRASH_POST_NOTICE_ID
  3061. }];
  3062. }
  3063. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/actions.js
  3064. /**
  3065. * External dependencies
  3066. */
  3067. /**
  3068. * WordPress dependencies
  3069. */
  3070. /**
  3071. * Internal dependencies
  3072. */
  3073. /**
  3074. * Returns an action generator used in signalling that editor has initialized with
  3075. * the specified post object and editor settings.
  3076. *
  3077. * @param {Object} post Post object.
  3078. * @param {Object} edits Initial edited attributes object.
  3079. * @param {Array?} template Block Template.
  3080. */
  3081. const setupEditor = (post, edits, template) => _ref => {
  3082. let {
  3083. dispatch
  3084. } = _ref;
  3085. dispatch.setupEditorState(post); // Apply a template for new posts only, if exists.
  3086. const isNewPost = post.status === 'auto-draft';
  3087. if (isNewPost && template) {
  3088. // In order to ensure maximum of a single parse during setup, edits are
  3089. // included as part of editor setup action. Assume edited content as
  3090. // canonical if provided, falling back to post.
  3091. let content;
  3092. if ((0,external_lodash_namespaceObject.has)(edits, ['content'])) {
  3093. content = edits.content;
  3094. } else {
  3095. content = post.content.raw;
  3096. }
  3097. let blocks = (0,external_wp_blocks_namespaceObject.parse)(content);
  3098. blocks = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(blocks, template);
  3099. dispatch.resetEditorBlocks(blocks, {
  3100. __unstableShouldCreateUndoLevel: false
  3101. });
  3102. }
  3103. if (edits && Object.values(edits).some(_ref2 => {
  3104. var _post$key$raw, _post$key;
  3105. let [key, edit] = _ref2;
  3106. return edit !== ((_post$key$raw = (_post$key = post[key]) === null || _post$key === void 0 ? void 0 : _post$key.raw) !== null && _post$key$raw !== void 0 ? _post$key$raw : post[key]);
  3107. })) {
  3108. dispatch.editPost(edits);
  3109. }
  3110. };
  3111. /**
  3112. * Returns an action object signalling that the editor is being destroyed and
  3113. * that any necessary state or side-effect cleanup should occur.
  3114. *
  3115. * @return {Object} Action object.
  3116. */
  3117. function __experimentalTearDownEditor() {
  3118. return {
  3119. type: 'TEAR_DOWN_EDITOR'
  3120. };
  3121. }
  3122. /**
  3123. * Returns an action object used in signalling that the latest version of the
  3124. * post has been received, either by initialization or save.
  3125. *
  3126. * @deprecated Since WordPress 6.0.
  3127. */
  3128. function resetPost() {
  3129. external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).resetPost", {
  3130. since: '6.0',
  3131. version: '6.3',
  3132. alternative: 'Initialize the editor with the setupEditorState action'
  3133. });
  3134. return {
  3135. type: 'DO_NOTHING'
  3136. };
  3137. }
  3138. /**
  3139. * Returns an action object used in signalling that a patch of updates for the
  3140. * latest version of the post have been received.
  3141. *
  3142. * @return {Object} Action object.
  3143. * @deprecated since Gutenberg 9.7.0.
  3144. */
  3145. function updatePost() {
  3146. external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).updatePost", {
  3147. since: '5.7',
  3148. alternative: 'Use the core entities store instead'
  3149. });
  3150. return {
  3151. type: 'DO_NOTHING'
  3152. };
  3153. }
  3154. /**
  3155. * Returns an action object used to setup the editor state when first opening
  3156. * an editor.
  3157. *
  3158. * @param {Object} post Post object.
  3159. *
  3160. * @return {Object} Action object.
  3161. */
  3162. function setupEditorState(post) {
  3163. return {
  3164. type: 'SETUP_EDITOR_STATE',
  3165. post
  3166. };
  3167. }
  3168. /**
  3169. * Returns an action object used in signalling that attributes of the post have
  3170. * been edited.
  3171. *
  3172. * @param {Object} edits Post attributes to edit.
  3173. * @param {Object} options Options for the edit.
  3174. */
  3175. const editPost = (edits, options) => _ref3 => {
  3176. let {
  3177. select,
  3178. registry
  3179. } = _ref3;
  3180. const {
  3181. id,
  3182. type
  3183. } = select.getCurrentPost();
  3184. registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', type, id, edits, options);
  3185. };
  3186. /**
  3187. * Action for saving the current post in the editor.
  3188. *
  3189. * @param {Object} options
  3190. */
  3191. const savePost = function () {
  3192. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3193. return async _ref4 => {
  3194. let {
  3195. select,
  3196. dispatch,
  3197. registry
  3198. } = _ref4;
  3199. if (!select.isEditedPostSaveable()) {
  3200. return;
  3201. }
  3202. const content = select.getEditedPostContent();
  3203. if (!options.isAutosave) {
  3204. dispatch.editPost({
  3205. content
  3206. }, {
  3207. undoIgnore: true
  3208. });
  3209. }
  3210. const previousRecord = select.getCurrentPost();
  3211. const edits = {
  3212. id: previousRecord.id,
  3213. ...registry.select(external_wp_coreData_namespaceObject.store).getEntityRecordNonTransientEdits('postType', previousRecord.type, previousRecord.id),
  3214. content
  3215. };
  3216. dispatch({
  3217. type: 'REQUEST_POST_UPDATE_START',
  3218. options
  3219. });
  3220. await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', previousRecord.type, edits, options);
  3221. dispatch({
  3222. type: 'REQUEST_POST_UPDATE_FINISH',
  3223. options
  3224. });
  3225. const error = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', previousRecord.type, previousRecord.id);
  3226. if (error) {
  3227. const args = getNotificationArgumentsForSaveFail({
  3228. post: previousRecord,
  3229. edits,
  3230. error
  3231. });
  3232. if (args.length) {
  3233. registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...args);
  3234. }
  3235. } else {
  3236. const updatedRecord = select.getCurrentPost();
  3237. const args = getNotificationArgumentsForSaveSuccess({
  3238. previousPost: previousRecord,
  3239. post: updatedRecord,
  3240. postType: await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(updatedRecord.type),
  3241. options
  3242. });
  3243. if (args.length) {
  3244. registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(...args);
  3245. } // Make sure that any edits after saving create an undo level and are
  3246. // considered for change detection.
  3247. if (!options.isAutosave) {
  3248. registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableMarkLastChangeAsPersistent();
  3249. }
  3250. }
  3251. };
  3252. };
  3253. /**
  3254. * Action for refreshing the current post.
  3255. *
  3256. * @deprecated Since WordPress 6.0.
  3257. */
  3258. function refreshPost() {
  3259. external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).refreshPost", {
  3260. since: '6.0',
  3261. version: '6.3',
  3262. alternative: 'Use the core entities store instead'
  3263. });
  3264. return {
  3265. type: 'DO_NOTHING'
  3266. };
  3267. }
  3268. /**
  3269. * Action for trashing the current post in the editor.
  3270. */
  3271. const trashPost = () => async _ref5 => {
  3272. let {
  3273. select,
  3274. dispatch,
  3275. registry
  3276. } = _ref5;
  3277. const postTypeSlug = select.getCurrentPostType();
  3278. const postType = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
  3279. registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(TRASH_POST_NOTICE_ID);
  3280. try {
  3281. const post = select.getCurrentPost();
  3282. await external_wp_apiFetch_default()({
  3283. path: `/wp/v2/${postType.rest_base}/${post.id}`,
  3284. method: 'DELETE'
  3285. });
  3286. await dispatch.savePost();
  3287. } catch (error) {
  3288. registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...getNotificationArgumentsForTrashFail({
  3289. error
  3290. }));
  3291. }
  3292. };
  3293. /**
  3294. * Action that autosaves the current post. This
  3295. * includes server-side autosaving (default) and client-side (a.k.a. local)
  3296. * autosaving (e.g. on the Web, the post might be committed to Session
  3297. * Storage).
  3298. *
  3299. * @param {Object?} options Extra flags to identify the autosave.
  3300. */
  3301. const autosave = function () {
  3302. let {
  3303. local = false,
  3304. ...options
  3305. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3306. return async _ref6 => {
  3307. let {
  3308. select,
  3309. dispatch
  3310. } = _ref6;
  3311. if (local) {
  3312. const post = select.getCurrentPost();
  3313. const isPostNew = select.isEditedPostNew();
  3314. const title = select.getEditedPostAttribute('title');
  3315. const content = select.getEditedPostAttribute('content');
  3316. const excerpt = select.getEditedPostAttribute('excerpt');
  3317. localAutosaveSet(post.id, isPostNew, title, content, excerpt);
  3318. } else {
  3319. await dispatch.savePost({
  3320. isAutosave: true,
  3321. ...options
  3322. });
  3323. }
  3324. };
  3325. };
  3326. /**
  3327. * Action that restores last popped state in undo history.
  3328. */
  3329. const redo = () => _ref7 => {
  3330. let {
  3331. registry
  3332. } = _ref7;
  3333. registry.dispatch(external_wp_coreData_namespaceObject.store).redo();
  3334. };
  3335. /**
  3336. * Action that pops a record from undo history and undoes the edit.
  3337. */
  3338. const undo = () => _ref8 => {
  3339. let {
  3340. registry
  3341. } = _ref8;
  3342. registry.dispatch(external_wp_coreData_namespaceObject.store).undo();
  3343. };
  3344. /**
  3345. * Action that creates an undo history record.
  3346. *
  3347. * @deprecated Since WordPress 6.0
  3348. */
  3349. function createUndoLevel() {
  3350. external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).createUndoLevel", {
  3351. since: '6.0',
  3352. version: '6.3',
  3353. alternative: 'Use the core entities store instead'
  3354. });
  3355. return {
  3356. type: 'DO_NOTHING'
  3357. };
  3358. }
  3359. /**
  3360. * Action that locks the editor.
  3361. *
  3362. * @param {Object} lock Details about the post lock status, user, and nonce.
  3363. * @return {Object} Action object.
  3364. */
  3365. function updatePostLock(lock) {
  3366. return {
  3367. type: 'UPDATE_POST_LOCK',
  3368. lock
  3369. };
  3370. }
  3371. /**
  3372. * Enable the publish sidebar.
  3373. */
  3374. const enablePublishSidebar = () => _ref9 => {
  3375. let {
  3376. registry
  3377. } = _ref9;
  3378. registry.dispatch(external_wp_preferences_namespaceObject.store).set('core/edit-post', 'isPublishSidebarEnabled', true);
  3379. };
  3380. /**
  3381. * Disables the publish sidebar.
  3382. */
  3383. const disablePublishSidebar = () => _ref10 => {
  3384. let {
  3385. registry
  3386. } = _ref10;
  3387. registry.dispatch(external_wp_preferences_namespaceObject.store).set('core/edit-post', 'isPublishSidebarEnabled', false);
  3388. };
  3389. /**
  3390. * Action that locks post saving.
  3391. *
  3392. * @param {string} lockName The lock name.
  3393. *
  3394. * @example
  3395. * ```
  3396. * const { subscribe } = wp.data;
  3397. *
  3398. * const initialPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
  3399. *
  3400. * // Only allow publishing posts that are set to a future date.
  3401. * if ( 'publish' !== initialPostStatus ) {
  3402. *
  3403. * // Track locking.
  3404. * let locked = false;
  3405. *
  3406. * // Watch for the publish event.
  3407. * let unssubscribe = subscribe( () => {
  3408. * const currentPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
  3409. * if ( 'publish' !== currentPostStatus ) {
  3410. *
  3411. * // Compare the post date to the current date, lock the post if the date isn't in the future.
  3412. * const postDate = new Date( wp.data.select( 'core/editor' ).getEditedPostAttribute( 'date' ) );
  3413. * const currentDate = new Date();
  3414. * if ( postDate.getTime() <= currentDate.getTime() ) {
  3415. * if ( ! locked ) {
  3416. * locked = true;
  3417. * wp.data.dispatch( 'core/editor' ).lockPostSaving( 'futurelock' );
  3418. * }
  3419. * } else {
  3420. * if ( locked ) {
  3421. * locked = false;
  3422. * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'futurelock' );
  3423. * }
  3424. * }
  3425. * }
  3426. * } );
  3427. * }
  3428. * ```
  3429. *
  3430. * @return {Object} Action object
  3431. */
  3432. function lockPostSaving(lockName) {
  3433. return {
  3434. type: 'LOCK_POST_SAVING',
  3435. lockName
  3436. };
  3437. }
  3438. /**
  3439. * Action that unlocks post saving.
  3440. *
  3441. * @param {string} lockName The lock name.
  3442. *
  3443. * @example
  3444. * ```
  3445. * // Unlock post saving with the lock key `mylock`:
  3446. * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'mylock' );
  3447. * ```
  3448. *
  3449. * @return {Object} Action object
  3450. */
  3451. function unlockPostSaving(lockName) {
  3452. return {
  3453. type: 'UNLOCK_POST_SAVING',
  3454. lockName
  3455. };
  3456. }
  3457. /**
  3458. * Action that locks post autosaving.
  3459. *
  3460. * @param {string} lockName The lock name.
  3461. *
  3462. * @example
  3463. * ```
  3464. * // Lock post autosaving with the lock key `mylock`:
  3465. * wp.data.dispatch( 'core/editor' ).lockPostAutosaving( 'mylock' );
  3466. * ```
  3467. *
  3468. * @return {Object} Action object
  3469. */
  3470. function lockPostAutosaving(lockName) {
  3471. return {
  3472. type: 'LOCK_POST_AUTOSAVING',
  3473. lockName
  3474. };
  3475. }
  3476. /**
  3477. * Action that unlocks post autosaving.
  3478. *
  3479. * @param {string} lockName The lock name.
  3480. *
  3481. * @example
  3482. * ```
  3483. * // Unlock post saving with the lock key `mylock`:
  3484. * wp.data.dispatch( 'core/editor' ).unlockPostAutosaving( 'mylock' );
  3485. * ```
  3486. *
  3487. * @return {Object} Action object
  3488. */
  3489. function unlockPostAutosaving(lockName) {
  3490. return {
  3491. type: 'UNLOCK_POST_AUTOSAVING',
  3492. lockName
  3493. };
  3494. }
  3495. /**
  3496. * Returns an action object used to signal that the blocks have been updated.
  3497. *
  3498. * @param {Array} blocks Block Array.
  3499. * @param {?Object} options Optional options.
  3500. */
  3501. const resetEditorBlocks = function (blocks) {
  3502. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  3503. return _ref11 => {
  3504. let {
  3505. select,
  3506. dispatch,
  3507. registry
  3508. } = _ref11;
  3509. const {
  3510. __unstableShouldCreateUndoLevel,
  3511. selection
  3512. } = options;
  3513. const edits = {
  3514. blocks,
  3515. selection
  3516. };
  3517. if (__unstableShouldCreateUndoLevel !== false) {
  3518. const {
  3519. id,
  3520. type
  3521. } = select.getCurrentPost();
  3522. const noChange = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', type, id).blocks === edits.blocks;
  3523. if (noChange) {
  3524. registry.dispatch(external_wp_coreData_namespaceObject.store).__unstableCreateUndoLevel('postType', type, id);
  3525. return;
  3526. } // We create a new function here on every persistent edit
  3527. // to make sure the edit makes the post dirty and creates
  3528. // a new undo level.
  3529. edits.content = _ref12 => {
  3530. let {
  3531. blocks: blocksForSerialization = []
  3532. } = _ref12;
  3533. return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
  3534. };
  3535. }
  3536. dispatch.editPost(edits);
  3537. };
  3538. };
  3539. /*
  3540. * Returns an action object used in signalling that the post editor settings have been updated.
  3541. *
  3542. * @param {Object} settings Updated settings
  3543. *
  3544. * @return {Object} Action object
  3545. */
  3546. function updateEditorSettings(settings) {
  3547. return {
  3548. type: 'UPDATE_EDITOR_SETTINGS',
  3549. settings
  3550. };
  3551. }
  3552. /**
  3553. * Backward compatibility
  3554. */
  3555. const getBlockEditorAction = name => function () {
  3556. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  3557. args[_key] = arguments[_key];
  3558. }
  3559. return _ref13 => {
  3560. let {
  3561. registry
  3562. } = _ref13;
  3563. external_wp_deprecated_default()("`wp.data.dispatch( 'core/editor' )." + name + '`', {
  3564. since: '5.3',
  3565. alternative: "`wp.data.dispatch( 'core/block-editor' )." + name + '`',
  3566. version: '6.2'
  3567. });
  3568. registry.dispatch(external_wp_blockEditor_namespaceObject.store)[name](...args);
  3569. };
  3570. };
  3571. /**
  3572. * @see resetBlocks in core/block-editor store.
  3573. */
  3574. const resetBlocks = getBlockEditorAction('resetBlocks');
  3575. /**
  3576. * @see receiveBlocks in core/block-editor store.
  3577. */
  3578. const receiveBlocks = getBlockEditorAction('receiveBlocks');
  3579. /**
  3580. * @see updateBlock in core/block-editor store.
  3581. */
  3582. const updateBlock = getBlockEditorAction('updateBlock');
  3583. /**
  3584. * @see updateBlockAttributes in core/block-editor store.
  3585. */
  3586. const updateBlockAttributes = getBlockEditorAction('updateBlockAttributes');
  3587. /**
  3588. * @see selectBlock in core/block-editor store.
  3589. */
  3590. const selectBlock = getBlockEditorAction('selectBlock');
  3591. /**
  3592. * @see startMultiSelect in core/block-editor store.
  3593. */
  3594. const startMultiSelect = getBlockEditorAction('startMultiSelect');
  3595. /**
  3596. * @see stopMultiSelect in core/block-editor store.
  3597. */
  3598. const stopMultiSelect = getBlockEditorAction('stopMultiSelect');
  3599. /**
  3600. * @see multiSelect in core/block-editor store.
  3601. */
  3602. const multiSelect = getBlockEditorAction('multiSelect');
  3603. /**
  3604. * @see clearSelectedBlock in core/block-editor store.
  3605. */
  3606. const clearSelectedBlock = getBlockEditorAction('clearSelectedBlock');
  3607. /**
  3608. * @see toggleSelection in core/block-editor store.
  3609. */
  3610. const toggleSelection = getBlockEditorAction('toggleSelection');
  3611. /**
  3612. * @see replaceBlocks in core/block-editor store.
  3613. */
  3614. const replaceBlocks = getBlockEditorAction('replaceBlocks');
  3615. /**
  3616. * @see replaceBlock in core/block-editor store.
  3617. */
  3618. const replaceBlock = getBlockEditorAction('replaceBlock');
  3619. /**
  3620. * @see moveBlocksDown in core/block-editor store.
  3621. */
  3622. const moveBlocksDown = getBlockEditorAction('moveBlocksDown');
  3623. /**
  3624. * @see moveBlocksUp in core/block-editor store.
  3625. */
  3626. const moveBlocksUp = getBlockEditorAction('moveBlocksUp');
  3627. /**
  3628. * @see moveBlockToPosition in core/block-editor store.
  3629. */
  3630. const moveBlockToPosition = getBlockEditorAction('moveBlockToPosition');
  3631. /**
  3632. * @see insertBlock in core/block-editor store.
  3633. */
  3634. const insertBlock = getBlockEditorAction('insertBlock');
  3635. /**
  3636. * @see insertBlocks in core/block-editor store.
  3637. */
  3638. const insertBlocks = getBlockEditorAction('insertBlocks');
  3639. /**
  3640. * @see showInsertionPoint in core/block-editor store.
  3641. */
  3642. const showInsertionPoint = getBlockEditorAction('showInsertionPoint');
  3643. /**
  3644. * @see hideInsertionPoint in core/block-editor store.
  3645. */
  3646. const hideInsertionPoint = getBlockEditorAction('hideInsertionPoint');
  3647. /**
  3648. * @see setTemplateValidity in core/block-editor store.
  3649. */
  3650. const setTemplateValidity = getBlockEditorAction('setTemplateValidity');
  3651. /**
  3652. * @see synchronizeTemplate in core/block-editor store.
  3653. */
  3654. const synchronizeTemplate = getBlockEditorAction('synchronizeTemplate');
  3655. /**
  3656. * @see mergeBlocks in core/block-editor store.
  3657. */
  3658. const mergeBlocks = getBlockEditorAction('mergeBlocks');
  3659. /**
  3660. * @see removeBlocks in core/block-editor store.
  3661. */
  3662. const removeBlocks = getBlockEditorAction('removeBlocks');
  3663. /**
  3664. * @see removeBlock in core/block-editor store.
  3665. */
  3666. const removeBlock = getBlockEditorAction('removeBlock');
  3667. /**
  3668. * @see toggleBlockMode in core/block-editor store.
  3669. */
  3670. const toggleBlockMode = getBlockEditorAction('toggleBlockMode');
  3671. /**
  3672. * @see startTyping in core/block-editor store.
  3673. */
  3674. const startTyping = getBlockEditorAction('startTyping');
  3675. /**
  3676. * @see stopTyping in core/block-editor store.
  3677. */
  3678. const stopTyping = getBlockEditorAction('stopTyping');
  3679. /**
  3680. * @see enterFormattedText in core/block-editor store.
  3681. */
  3682. const enterFormattedText = getBlockEditorAction('enterFormattedText');
  3683. /**
  3684. * @see exitFormattedText in core/block-editor store.
  3685. */
  3686. const exitFormattedText = getBlockEditorAction('exitFormattedText');
  3687. /**
  3688. * @see insertDefaultBlock in core/block-editor store.
  3689. */
  3690. const insertDefaultBlock = getBlockEditorAction('insertDefaultBlock');
  3691. /**
  3692. * @see updateBlockListSettings in core/block-editor store.
  3693. */
  3694. const updateBlockListSettings = getBlockEditorAction('updateBlockListSettings');
  3695. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/index.js
  3696. /**
  3697. * WordPress dependencies
  3698. */
  3699. /**
  3700. * Internal dependencies
  3701. */
  3702. /**
  3703. * Post editor data store configuration.
  3704. *
  3705. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
  3706. *
  3707. * @type {Object}
  3708. */
  3709. const storeConfig = {
  3710. reducer: reducer,
  3711. selectors: selectors_namespaceObject,
  3712. actions: actions_namespaceObject
  3713. };
  3714. /**
  3715. * Store definition for the editor namespace.
  3716. *
  3717. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  3718. *
  3719. * @type {Object}
  3720. */
  3721. const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { ...storeConfig
  3722. });
  3723. (0,external_wp_data_namespaceObject.register)(store_store);
  3724. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/hooks/custom-sources-backwards-compatibility.js
  3725. /**
  3726. * External dependencies
  3727. */
  3728. /**
  3729. * WordPress dependencies
  3730. */
  3731. /**
  3732. * Internal dependencies
  3733. */
  3734. /** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */
  3735. /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
  3736. /**
  3737. * Object whose keys are the names of block attributes, where each value
  3738. * represents the meta key to which the block attribute is intended to save.
  3739. *
  3740. * @see https://developer.wordpress.org/reference/functions/register_meta/
  3741. *
  3742. * @typedef {Object<string,string>} WPMetaAttributeMapping
  3743. */
  3744. /**
  3745. * Given a mapping of attribute names (meta source attributes) to their
  3746. * associated meta key, returns a higher order component that overrides its
  3747. * `attributes` and `setAttributes` props to sync any changes with the edited
  3748. * post's meta keys.
  3749. *
  3750. * @param {WPMetaAttributeMapping} metaAttributes Meta attribute mapping.
  3751. *
  3752. * @return {WPHigherOrderComponent} Higher-order component.
  3753. */
  3754. const createWithMetaAttributeSource = metaAttributes => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => _ref => {
  3755. let {
  3756. attributes,
  3757. setAttributes,
  3758. ...props
  3759. } = _ref;
  3760. const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
  3761. const [meta, setMeta] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', postType, 'meta');
  3762. const mergedAttributes = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...attributes,
  3763. ...(0,external_lodash_namespaceObject.mapValues)(metaAttributes, metaKey => meta[metaKey])
  3764. }), [attributes, meta]);
  3765. return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({
  3766. attributes: mergedAttributes,
  3767. setAttributes: nextAttributes => {
  3768. const nextMeta = (0,external_lodash_namespaceObject.mapKeys)( // Filter to intersection of keys between the updated
  3769. // attributes and those with an associated meta key.
  3770. (0,external_lodash_namespaceObject.pickBy)(nextAttributes, (value, key) => metaAttributes[key]), // Rename the keys to the expected meta key name.
  3771. (value, attributeKey) => metaAttributes[attributeKey]);
  3772. if (!(0,external_lodash_namespaceObject.isEmpty)(nextMeta)) {
  3773. setMeta(nextMeta);
  3774. }
  3775. setAttributes(nextAttributes);
  3776. }
  3777. }, props));
  3778. }, 'withMetaAttributeSource');
  3779. /**
  3780. * Filters a registered block's settings to enhance a block's `edit` component
  3781. * to upgrade meta-sourced attributes to use the post's meta entity property.
  3782. *
  3783. * @param {WPBlockSettings} settings Registered block settings.
  3784. *
  3785. * @return {WPBlockSettings} Filtered block settings.
  3786. */
  3787. function shimAttributeSource(settings) {
  3788. /** @type {WPMetaAttributeMapping} */
  3789. const metaAttributes = (0,external_lodash_namespaceObject.mapValues)((0,external_lodash_namespaceObject.pickBy)(settings.attributes, {
  3790. source: 'meta'
  3791. }), 'meta');
  3792. if (!(0,external_lodash_namespaceObject.isEmpty)(metaAttributes)) {
  3793. settings.edit = createWithMetaAttributeSource(metaAttributes)(settings.edit);
  3794. }
  3795. return settings;
  3796. }
  3797. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/editor/custom-sources-backwards-compatibility/shim-attribute-source', shimAttributeSource); // The above filter will only capture blocks registered after the filter was
  3798. // added. There may already be blocks registered by this point, and those must
  3799. // be updated to apply the shim.
  3800. //
  3801. // The following implementation achieves this, albeit with a couple caveats:
  3802. // - Only blocks registered on the global store will be modified.
  3803. // - The block settings are directly mutated, since there is currently no
  3804. // mechanism to update an existing block registration. This is the reason for
  3805. // `getBlockType` separate from `getBlockTypes`, since the latter returns a
  3806. // _copy_ of the block registration (i.e. the mutation would not affect the
  3807. // actual registered block settings).
  3808. //
  3809. // `getBlockTypes` or `getBlockType` implementation could change in the future
  3810. // in regards to creating settings clones, but the corresponding end-to-end
  3811. // tests for meta blocks should cover against any potential regressions.
  3812. //
  3813. // In the future, we could support updating block settings, at which point this
  3814. // implementation could use that mechanism instead.
  3815. (0,external_wp_data_namespaceObject.select)(external_wp_blocks_namespaceObject.store).getBlockTypes().map(_ref2 => {
  3816. let {
  3817. name
  3818. } = _ref2;
  3819. return (0,external_wp_data_namespaceObject.select)(external_wp_blocks_namespaceObject.store).getBlockType(name);
  3820. }).forEach(shimAttributeSource);
  3821. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autocompleters/user.js
  3822. /**
  3823. * WordPress dependencies
  3824. */
  3825. /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
  3826. function getUserLabel(user) {
  3827. const avatar = user.avatar_urls && user.avatar_urls[24] ? (0,external_wp_element_namespaceObject.createElement)("img", {
  3828. className: "editor-autocompleters__user-avatar",
  3829. alt: "",
  3830. src: user.avatar_urls[24]
  3831. }) : (0,external_wp_element_namespaceObject.createElement)("span", {
  3832. className: "editor-autocompleters__no-avatar"
  3833. });
  3834. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, avatar, (0,external_wp_element_namespaceObject.createElement)("span", {
  3835. className: "editor-autocompleters__user-name"
  3836. }, user.name), (0,external_wp_element_namespaceObject.createElement)("span", {
  3837. className: "editor-autocompleters__user-slug"
  3838. }, user.slug));
  3839. }
  3840. /**
  3841. * A user mentions completer.
  3842. *
  3843. * @type {WPCompleter}
  3844. */
  3845. /* harmony default export */ var user = ({
  3846. name: 'users',
  3847. className: 'editor-autocompleters__user',
  3848. triggerPrefix: '@',
  3849. useItems(filterValue) {
  3850. const users = (0,external_wp_data_namespaceObject.useSelect)(select => {
  3851. const {
  3852. getUsers
  3853. } = select(external_wp_coreData_namespaceObject.store);
  3854. return getUsers({
  3855. context: 'view',
  3856. search: encodeURIComponent(filterValue)
  3857. });
  3858. }, [filterValue]);
  3859. const options = (0,external_wp_element_namespaceObject.useMemo)(() => users ? users.map(user => ({
  3860. key: `user-${user.slug}`,
  3861. value: user,
  3862. label: getUserLabel(user)
  3863. })) : [], [users]);
  3864. return [options];
  3865. },
  3866. getOptionCompletion(user) {
  3867. return `@${user.slug}`;
  3868. }
  3869. });
  3870. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/hooks/default-autocompleters.js
  3871. /**
  3872. * External dependencies
  3873. */
  3874. /**
  3875. * WordPress dependencies
  3876. */
  3877. /**
  3878. * Internal dependencies
  3879. */
  3880. function setDefaultCompleters() {
  3881. let completers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  3882. // Provide copies so filters may directly modify them.
  3883. completers.push((0,external_lodash_namespaceObject.clone)(user));
  3884. return completers;
  3885. }
  3886. (0,external_wp_hooks_namespaceObject.addFilter)('editor.Autocomplete.completers', 'editor/autocompleters/set-default-completers', setDefaultCompleters);
  3887. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/hooks/index.js
  3888. /**
  3889. * Internal dependencies
  3890. */
  3891. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autocompleters/index.js
  3892. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autosave-monitor/index.js
  3893. /**
  3894. * WordPress dependencies
  3895. */
  3896. /**
  3897. * Internal dependencies
  3898. */
  3899. /**
  3900. * AutosaveMonitor invokes `props.autosave()` within at most `interval` seconds after an unsaved change is detected.
  3901. *
  3902. * The logic is straightforward: a check is performed every `props.interval` seconds. If any changes are detected, `props.autosave()` is called.
  3903. * The time between the change and the autosave varies but is no larger than `props.interval` seconds. Refer to the code below for more details, such as
  3904. * the specific way of detecting changes.
  3905. *
  3906. * There are two caveats:
  3907. * * If `props.isAutosaveable` happens to be false at a time of checking for changes, the check is retried every second.
  3908. * * The timer may be disabled by setting `props.disableIntervalChecks` to `true`. In that mode, any change will immediately trigger `props.autosave()`.
  3909. */
  3910. class AutosaveMonitor extends external_wp_element_namespaceObject.Component {
  3911. constructor(props) {
  3912. super(props);
  3913. this.needsAutosave = !!(props.isDirty && props.isAutosaveable);
  3914. }
  3915. componentDidMount() {
  3916. if (!this.props.disableIntervalChecks) {
  3917. this.setAutosaveTimer();
  3918. }
  3919. }
  3920. componentDidUpdate(prevProps) {
  3921. if (this.props.disableIntervalChecks) {
  3922. if (this.props.editsReference !== prevProps.editsReference) {
  3923. this.props.autosave();
  3924. }
  3925. return;
  3926. }
  3927. if (this.props.interval !== prevProps.interval) {
  3928. clearTimeout(this.timerId);
  3929. this.setAutosaveTimer();
  3930. }
  3931. if (!this.props.isDirty) {
  3932. this.needsAutosave = false;
  3933. return;
  3934. }
  3935. if (this.props.isAutosaving && !prevProps.isAutosaving) {
  3936. this.needsAutosave = false;
  3937. return;
  3938. }
  3939. if (this.props.editsReference !== prevProps.editsReference) {
  3940. this.needsAutosave = true;
  3941. }
  3942. }
  3943. componentWillUnmount() {
  3944. clearTimeout(this.timerId);
  3945. }
  3946. setAutosaveTimer() {
  3947. let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props.interval * 1000;
  3948. this.timerId = setTimeout(() => {
  3949. this.autosaveTimerHandler();
  3950. }, timeout);
  3951. }
  3952. autosaveTimerHandler() {
  3953. if (!this.props.isAutosaveable) {
  3954. this.setAutosaveTimer(1000);
  3955. return;
  3956. }
  3957. if (this.needsAutosave) {
  3958. this.needsAutosave = false;
  3959. this.props.autosave();
  3960. }
  3961. this.setAutosaveTimer();
  3962. }
  3963. render() {
  3964. return null;
  3965. }
  3966. }
  3967. /* harmony default export */ var autosave_monitor = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, ownProps) => {
  3968. const {
  3969. getReferenceByDistinctEdits
  3970. } = select(external_wp_coreData_namespaceObject.store);
  3971. const {
  3972. isEditedPostDirty,
  3973. isEditedPostAutosaveable,
  3974. isAutosavingPost,
  3975. getEditorSettings
  3976. } = select(store_store);
  3977. const {
  3978. interval = getEditorSettings().autosaveInterval
  3979. } = ownProps;
  3980. return {
  3981. editsReference: getReferenceByDistinctEdits(),
  3982. isDirty: isEditedPostDirty(),
  3983. isAutosaveable: isEditedPostAutosaveable(),
  3984. isAutosaving: isAutosavingPost(),
  3985. interval
  3986. };
  3987. }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps) => ({
  3988. autosave() {
  3989. const {
  3990. autosave = dispatch(store_store).autosave
  3991. } = ownProps;
  3992. autosave();
  3993. }
  3994. }))])(AutosaveMonitor));
  3995. ;// CONCATENATED MODULE: external ["wp","richText"]
  3996. var external_wp_richText_namespaceObject = window["wp"]["richText"];
  3997. // EXTERNAL MODULE: ./node_modules/classnames/index.js
  3998. var classnames = __webpack_require__(4403);
  3999. var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
  4000. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/document-outline/item.js
  4001. /**
  4002. * External dependencies
  4003. */
  4004. const TableOfContentsItem = _ref => {
  4005. let {
  4006. children,
  4007. isValid,
  4008. level,
  4009. href,
  4010. onSelect
  4011. } = _ref;
  4012. return (0,external_wp_element_namespaceObject.createElement)("li", {
  4013. className: classnames_default()('document-outline__item', `is-${level.toLowerCase()}`, {
  4014. 'is-invalid': !isValid
  4015. })
  4016. }, (0,external_wp_element_namespaceObject.createElement)("a", {
  4017. href: href,
  4018. className: "document-outline__button",
  4019. onClick: onSelect
  4020. }, (0,external_wp_element_namespaceObject.createElement)("span", {
  4021. className: "document-outline__emdash",
  4022. "aria-hidden": "true"
  4023. }), (0,external_wp_element_namespaceObject.createElement)("strong", {
  4024. className: "document-outline__level"
  4025. }, level), (0,external_wp_element_namespaceObject.createElement)("span", {
  4026. className: "document-outline__item-content"
  4027. }, children)));
  4028. };
  4029. /* harmony default export */ var document_outline_item = (TableOfContentsItem);
  4030. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/document-outline/index.js
  4031. /**
  4032. * External dependencies
  4033. */
  4034. /**
  4035. * WordPress dependencies
  4036. */
  4037. /**
  4038. * Internal dependencies
  4039. */
  4040. /**
  4041. * Module constants
  4042. */
  4043. const emptyHeadingContent = (0,external_wp_element_namespaceObject.createElement)("em", null, (0,external_wp_i18n_namespaceObject.__)('(Empty heading)'));
  4044. const incorrectLevelContent = [(0,external_wp_element_namespaceObject.createElement)("br", {
  4045. key: "incorrect-break"
  4046. }), (0,external_wp_element_namespaceObject.createElement)("em", {
  4047. key: "incorrect-message"
  4048. }, (0,external_wp_i18n_namespaceObject.__)('(Incorrect heading level)'))];
  4049. const singleH1Headings = [(0,external_wp_element_namespaceObject.createElement)("br", {
  4050. key: "incorrect-break-h1"
  4051. }), (0,external_wp_element_namespaceObject.createElement)("em", {
  4052. key: "incorrect-message-h1"
  4053. }, (0,external_wp_i18n_namespaceObject.__)('(Your theme may already use a H1 for the post title)'))];
  4054. const multipleH1Headings = [(0,external_wp_element_namespaceObject.createElement)("br", {
  4055. key: "incorrect-break-multiple-h1"
  4056. }), (0,external_wp_element_namespaceObject.createElement)("em", {
  4057. key: "incorrect-message-multiple-h1"
  4058. }, (0,external_wp_i18n_namespaceObject.__)('(Multiple H1 headings are not recommended)'))];
  4059. /**
  4060. * Returns an array of heading blocks enhanced with the following properties:
  4061. * level - An integer with the heading level.
  4062. * isEmpty - Flag indicating if the heading has no content.
  4063. *
  4064. * @param {?Array} blocks An array of blocks.
  4065. *
  4066. * @return {Array} An array of heading blocks enhanced with the properties described above.
  4067. */
  4068. const computeOutlineHeadings = function () {
  4069. let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  4070. return (0,external_lodash_namespaceObject.flatMap)(blocks, function () {
  4071. let block = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4072. if (block.name === 'core/heading') {
  4073. return { ...block,
  4074. level: block.attributes.level,
  4075. isEmpty: isEmptyHeading(block)
  4076. };
  4077. }
  4078. return computeOutlineHeadings(block.innerBlocks);
  4079. });
  4080. };
  4081. const isEmptyHeading = heading => !heading.attributes.content || heading.attributes.content.length === 0;
  4082. const DocumentOutline = _ref => {
  4083. let {
  4084. blocks = [],
  4085. title,
  4086. onSelect,
  4087. isTitleSupported,
  4088. hasOutlineItemsDisabled
  4089. } = _ref;
  4090. const headings = computeOutlineHeadings(blocks);
  4091. if (headings.length < 1) {
  4092. return null;
  4093. }
  4094. let prevHeadingLevel = 1; // Not great but it's the simplest way to locate the title right now.
  4095. const titleNode = document.querySelector('.editor-post-title__input');
  4096. const hasTitle = isTitleSupported && title && titleNode;
  4097. const countByLevel = (0,external_lodash_namespaceObject.countBy)(headings, 'level');
  4098. const hasMultipleH1 = countByLevel[1] > 1;
  4099. return (0,external_wp_element_namespaceObject.createElement)("div", {
  4100. className: "document-outline"
  4101. }, (0,external_wp_element_namespaceObject.createElement)("ul", null, hasTitle && (0,external_wp_element_namespaceObject.createElement)(document_outline_item, {
  4102. level: (0,external_wp_i18n_namespaceObject.__)('Title'),
  4103. isValid: true,
  4104. onSelect: onSelect,
  4105. href: `#${titleNode.id}`,
  4106. isDisabled: hasOutlineItemsDisabled
  4107. }, title), headings.map((item, index) => {
  4108. // Headings remain the same, go up by one, or down by any amount.
  4109. // Otherwise there are missing levels.
  4110. const isIncorrectLevel = item.level > prevHeadingLevel + 1;
  4111. const isValid = !item.isEmpty && !isIncorrectLevel && !!item.level && (item.level !== 1 || !hasMultipleH1 && !hasTitle);
  4112. prevHeadingLevel = item.level;
  4113. return (0,external_wp_element_namespaceObject.createElement)(document_outline_item, {
  4114. key: index,
  4115. level: `H${item.level}`,
  4116. isValid: isValid,
  4117. isDisabled: hasOutlineItemsDisabled,
  4118. href: `#block-${item.clientId}`,
  4119. onSelect: onSelect
  4120. }, item.isEmpty ? emptyHeadingContent : (0,external_wp_richText_namespaceObject.getTextContent)((0,external_wp_richText_namespaceObject.create)({
  4121. html: item.attributes.content
  4122. })), isIncorrectLevel && incorrectLevelContent, item.level === 1 && hasMultipleH1 && multipleH1Headings, hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings);
  4123. })));
  4124. };
  4125. /* harmony default export */ var document_outline = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => {
  4126. const {
  4127. getBlocks
  4128. } = select(external_wp_blockEditor_namespaceObject.store);
  4129. const {
  4130. getEditedPostAttribute
  4131. } = select(store_store);
  4132. const {
  4133. getPostType
  4134. } = select(external_wp_coreData_namespaceObject.store);
  4135. const postType = getPostType(getEditedPostAttribute('type'));
  4136. return {
  4137. title: getEditedPostAttribute('title'),
  4138. blocks: getBlocks(),
  4139. isTitleSupported: (0,external_lodash_namespaceObject.get)(postType, ['supports', 'title'], false)
  4140. };
  4141. }))(DocumentOutline));
  4142. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/document-outline/check.js
  4143. /**
  4144. * External dependencies
  4145. */
  4146. /**
  4147. * WordPress dependencies
  4148. */
  4149. function DocumentOutlineCheck(_ref) {
  4150. let {
  4151. blocks,
  4152. children
  4153. } = _ref;
  4154. const headings = (0,external_lodash_namespaceObject.filter)(blocks, block => block.name === 'core/heading');
  4155. if (headings.length < 1) {
  4156. return null;
  4157. }
  4158. return children;
  4159. }
  4160. /* harmony default export */ var check = ((0,external_wp_data_namespaceObject.withSelect)(select => ({
  4161. blocks: select(external_wp_blockEditor_namespaceObject.store).getBlocks()
  4162. }))(DocumentOutlineCheck));
  4163. ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
  4164. var external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
  4165. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/global-keyboard-shortcuts/save-shortcut.js
  4166. /**
  4167. * WordPress dependencies
  4168. */
  4169. /**
  4170. * Internal dependencies
  4171. */
  4172. function SaveShortcut(_ref) {
  4173. let {
  4174. resetBlocksOnSave
  4175. } = _ref;
  4176. const {
  4177. resetEditorBlocks,
  4178. savePost
  4179. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  4180. const {
  4181. isEditedPostDirty,
  4182. getPostEdits,
  4183. isPostSavingLocked
  4184. } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
  4185. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/save', event => {
  4186. event.preventDefault();
  4187. /**
  4188. * Do not save the post if post saving is locked.
  4189. */
  4190. if (isPostSavingLocked()) {
  4191. return;
  4192. } // TODO: This should be handled in the `savePost` effect in
  4193. // considering `isSaveable`. See note on `isEditedPostSaveable`
  4194. // selector about dirtiness and meta-boxes.
  4195. //
  4196. // See: `isEditedPostSaveable`
  4197. if (!isEditedPostDirty()) {
  4198. return;
  4199. } // The text editor requires that editor blocks are updated for a
  4200. // save to work correctly. Usually this happens when the textarea
  4201. // for the code editors blurs, but the shortcut can be used without
  4202. // blurring the textarea.
  4203. if (resetBlocksOnSave) {
  4204. const postEdits = getPostEdits();
  4205. if (postEdits.content && typeof postEdits.content === 'string') {
  4206. const blocks = (0,external_wp_blocks_namespaceObject.parse)(postEdits.content);
  4207. resetEditorBlocks(blocks);
  4208. }
  4209. }
  4210. savePost();
  4211. });
  4212. return null;
  4213. }
  4214. /* harmony default export */ var save_shortcut = (SaveShortcut);
  4215. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js
  4216. /**
  4217. * WordPress dependencies
  4218. */
  4219. /**
  4220. * Internal dependencies
  4221. */
  4222. function VisualEditorGlobalKeyboardShortcuts() {
  4223. const {
  4224. redo,
  4225. undo
  4226. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  4227. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/undo', event => {
  4228. undo();
  4229. event.preventDefault();
  4230. });
  4231. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/redo', event => {
  4232. redo();
  4233. event.preventDefault();
  4234. });
  4235. return (0,external_wp_element_namespaceObject.createElement)(save_shortcut, null);
  4236. }
  4237. /* harmony default export */ var visual_editor_shortcuts = (VisualEditorGlobalKeyboardShortcuts);
  4238. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/global-keyboard-shortcuts/text-editor-shortcuts.js
  4239. /**
  4240. * Internal dependencies
  4241. */
  4242. function TextEditorGlobalKeyboardShortcuts() {
  4243. return (0,external_wp_element_namespaceObject.createElement)(save_shortcut, {
  4244. resetBlocksOnSave: true
  4245. });
  4246. }
  4247. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/global-keyboard-shortcuts/register-shortcuts.js
  4248. /**
  4249. * WordPress dependencies
  4250. */
  4251. function EditorKeyboardShortcutsRegister() {
  4252. // Registering the shortcuts.
  4253. const {
  4254. registerShortcut
  4255. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
  4256. (0,external_wp_element_namespaceObject.useEffect)(() => {
  4257. registerShortcut({
  4258. name: 'core/editor/save',
  4259. category: 'global',
  4260. description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'),
  4261. keyCombination: {
  4262. modifier: 'primary',
  4263. character: 's'
  4264. }
  4265. });
  4266. registerShortcut({
  4267. name: 'core/editor/undo',
  4268. category: 'global',
  4269. description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'),
  4270. keyCombination: {
  4271. modifier: 'primary',
  4272. character: 'z'
  4273. }
  4274. });
  4275. registerShortcut({
  4276. name: 'core/editor/redo',
  4277. category: 'global',
  4278. description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'),
  4279. keyCombination: {
  4280. modifier: 'primaryShift',
  4281. character: 'z'
  4282. }
  4283. });
  4284. }, [registerShortcut]);
  4285. return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts.Register, null);
  4286. }
  4287. /* harmony default export */ var register_shortcuts = (EditorKeyboardShortcutsRegister);
  4288. ;// CONCATENATED MODULE: external ["wp","components"]
  4289. var external_wp_components_namespaceObject = window["wp"]["components"];
  4290. ;// CONCATENATED MODULE: external ["wp","keycodes"]
  4291. var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
  4292. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/redo.js
  4293. /**
  4294. * WordPress dependencies
  4295. */
  4296. const redo_redo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  4297. xmlns: "http://www.w3.org/2000/svg",
  4298. viewBox: "0 0 24 24"
  4299. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  4300. 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"
  4301. }));
  4302. /* harmony default export */ var library_redo = (redo_redo);
  4303. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/undo.js
  4304. /**
  4305. * WordPress dependencies
  4306. */
  4307. const undo_undo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  4308. xmlns: "http://www.w3.org/2000/svg",
  4309. viewBox: "0 0 24 24"
  4310. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  4311. 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"
  4312. }));
  4313. /* harmony default export */ var library_undo = (undo_undo);
  4314. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/editor-history/redo.js
  4315. /**
  4316. * WordPress dependencies
  4317. */
  4318. /**
  4319. * Internal dependencies
  4320. */
  4321. function EditorHistoryRedo(props, ref) {
  4322. const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorRedo(), []);
  4323. const {
  4324. redo
  4325. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  4326. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, {
  4327. ref: ref,
  4328. icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo
  4329. /* translators: button label text should, if possible, be under 16 characters. */
  4330. ,
  4331. label: (0,external_wp_i18n_namespaceObject.__)('Redo'),
  4332. shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') // If there are no redo levels we don't want to actually disable this
  4333. // button, because it will remove focus for keyboard users.
  4334. // See: https://github.com/WordPress/gutenberg/issues/3486
  4335. ,
  4336. "aria-disabled": !hasRedo,
  4337. onClick: hasRedo ? redo : undefined,
  4338. className: "editor-history__redo"
  4339. }));
  4340. }
  4341. /* harmony default export */ var editor_history_redo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryRedo));
  4342. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/editor-history/undo.js
  4343. /**
  4344. * WordPress dependencies
  4345. */
  4346. /**
  4347. * Internal dependencies
  4348. */
  4349. function EditorHistoryUndo(props, ref) {
  4350. const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorUndo(), []);
  4351. const {
  4352. undo
  4353. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  4354. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, {
  4355. ref: ref,
  4356. icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo
  4357. /* translators: button label text should, if possible, be under 16 characters. */
  4358. ,
  4359. label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
  4360. shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z') // If there are no undo levels we don't want to actually disable this
  4361. // button, because it will remove focus for keyboard users.
  4362. // See: https://github.com/WordPress/gutenberg/issues/3486
  4363. ,
  4364. "aria-disabled": !hasUndo,
  4365. onClick: hasUndo ? undo : undefined,
  4366. className: "editor-history__undo"
  4367. }));
  4368. }
  4369. /* harmony default export */ var editor_history_undo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryUndo));
  4370. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/template-validation-notice/index.js
  4371. /**
  4372. * WordPress dependencies
  4373. */
  4374. function TemplateValidationNotice(_ref) {
  4375. let {
  4376. isValid,
  4377. ...props
  4378. } = _ref;
  4379. if (isValid) {
  4380. return null;
  4381. }
  4382. const confirmSynchronization = () => {
  4383. if ( // eslint-disable-next-line no-alert
  4384. window.confirm((0,external_wp_i18n_namespaceObject.__)('Resetting the template may result in loss of content, do you want to continue?'))) {
  4385. props.synchronizeTemplate();
  4386. }
  4387. };
  4388. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Notice, {
  4389. className: "editor-template-validation-notice",
  4390. isDismissible: false,
  4391. status: "warning",
  4392. actions: [{
  4393. label: (0,external_wp_i18n_namespaceObject.__)('Keep it as is'),
  4394. onClick: props.resetTemplateValidity
  4395. }, {
  4396. label: (0,external_wp_i18n_namespaceObject.__)('Reset the template'),
  4397. onClick: confirmSynchronization
  4398. }]
  4399. }, (0,external_wp_i18n_namespaceObject.__)('The content of your post doesn’t match the template assigned to your post type.'));
  4400. }
  4401. /* harmony default export */ var template_validation_notice = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => ({
  4402. isValid: select(external_wp_blockEditor_namespaceObject.store).isValidTemplate()
  4403. })), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
  4404. const {
  4405. setTemplateValidity,
  4406. synchronizeTemplate
  4407. } = dispatch(external_wp_blockEditor_namespaceObject.store);
  4408. return {
  4409. resetTemplateValidity: () => setTemplateValidity(true),
  4410. synchronizeTemplate
  4411. };
  4412. })])(TemplateValidationNotice));
  4413. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/editor-notices/index.js
  4414. /**
  4415. * External dependencies
  4416. */
  4417. /**
  4418. * WordPress dependencies
  4419. */
  4420. /**
  4421. * Internal dependencies
  4422. */
  4423. function EditorNotices(_ref) {
  4424. let {
  4425. notices,
  4426. onRemove
  4427. } = _ref;
  4428. const dismissibleNotices = (0,external_lodash_namespaceObject.filter)(notices, {
  4429. isDismissible: true,
  4430. type: 'default'
  4431. });
  4432. const nonDismissibleNotices = (0,external_lodash_namespaceObject.filter)(notices, {
  4433. isDismissible: false,
  4434. type: 'default'
  4435. });
  4436. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NoticeList, {
  4437. notices: nonDismissibleNotices,
  4438. className: "components-editor-notices__pinned"
  4439. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NoticeList, {
  4440. notices: dismissibleNotices,
  4441. className: "components-editor-notices__dismissible",
  4442. onRemove: onRemove
  4443. }, (0,external_wp_element_namespaceObject.createElement)(template_validation_notice, null)));
  4444. }
  4445. /* harmony default export */ var editor_notices = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => ({
  4446. notices: select(external_wp_notices_namespaceObject.store).getNotices()
  4447. })), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
  4448. onRemove: dispatch(external_wp_notices_namespaceObject.store).removeNotice
  4449. }))])(EditorNotices));
  4450. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/editor-snackbars/index.js
  4451. /**
  4452. * External dependencies
  4453. */
  4454. /**
  4455. * WordPress dependencies
  4456. */
  4457. function EditorSnackbars() {
  4458. const notices = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_notices_namespaceObject.store).getNotices(), []);
  4459. const {
  4460. removeNotice
  4461. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
  4462. const snackbarNotices = (0,external_lodash_namespaceObject.filter)(notices, {
  4463. type: 'snackbar'
  4464. });
  4465. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SnackbarList, {
  4466. notices: snackbarNotices,
  4467. className: "components-editor-notices__snackbar",
  4468. onRemove: removeNotice
  4469. });
  4470. }
  4471. ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
  4472. var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
  4473. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/entities-saved-states/entity-record-item.js
  4474. /**
  4475. * WordPress dependencies
  4476. */
  4477. /**
  4478. * Internal dependencies
  4479. */
  4480. function EntityRecordItem(_ref) {
  4481. let {
  4482. record,
  4483. checked,
  4484. onChange,
  4485. closePanel
  4486. } = _ref;
  4487. const {
  4488. name,
  4489. kind,
  4490. title,
  4491. key
  4492. } = record;
  4493. const parentBlockId = (0,external_wp_data_namespaceObject.useSelect)(select => {
  4494. var _blocks$;
  4495. // Get entity's blocks.
  4496. const {
  4497. blocks = []
  4498. } = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(kind, name, key); // Get parents of the entity's first block.
  4499. const parents = select(external_wp_blockEditor_namespaceObject.store).getBlockParents((_blocks$ = blocks[0]) === null || _blocks$ === void 0 ? void 0 : _blocks$.clientId); // Return closest parent block's clientId.
  4500. return parents[parents.length - 1];
  4501. }, []); // Handle templates that might use default descriptive titles.
  4502. const entityRecordTitle = (0,external_wp_data_namespaceObject.useSelect)(select => {
  4503. if ('postType' !== kind || 'wp_template' !== name) {
  4504. return title;
  4505. }
  4506. const template = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(kind, name, key);
  4507. return select(store_store).__experimentalGetTemplateInfo(template).title;
  4508. }, [name, kind, title, key]);
  4509. const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => {
  4510. const selectedBlockId = select(external_wp_blockEditor_namespaceObject.store).getSelectedBlockClientId();
  4511. return selectedBlockId === parentBlockId;
  4512. }, [parentBlockId]);
  4513. const isSelectedText = isSelected ? (0,external_wp_i18n_namespaceObject.__)('Selected') : (0,external_wp_i18n_namespaceObject.__)('Select');
  4514. const {
  4515. selectBlock
  4516. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
  4517. const selectParentBlock = (0,external_wp_element_namespaceObject.useCallback)(() => selectBlock(parentBlockId), [parentBlockId]);
  4518. const selectAndDismiss = (0,external_wp_element_namespaceObject.useCallback)(() => {
  4519. selectBlock(parentBlockId);
  4520. closePanel();
  4521. }, [parentBlockId]);
  4522. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
  4523. label: (0,external_wp_element_namespaceObject.createElement)("strong", null, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(entityRecordTitle) || (0,external_wp_i18n_namespaceObject.__)('Untitled')),
  4524. checked: checked,
  4525. onChange: onChange
  4526. }), parentBlockId ? (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  4527. onClick: selectParentBlock,
  4528. className: "entities-saved-states__find-entity",
  4529. disabled: isSelected
  4530. }, isSelectedText), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  4531. onClick: selectAndDismiss,
  4532. className: "entities-saved-states__find-entity-small",
  4533. disabled: isSelected
  4534. }, isSelectedText)) : null);
  4535. }
  4536. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/entities-saved-states/entity-type-list.js
  4537. /**
  4538. * External dependencies
  4539. */
  4540. /**
  4541. * WordPress dependencies
  4542. */
  4543. /**
  4544. * Internal dependencies
  4545. */
  4546. function getEntityDescription(entity, count) {
  4547. switch (entity) {
  4548. case 'site':
  4549. return 1 === count ? (0,external_wp_i18n_namespaceObject.__)('This change will affect your whole site.') : (0,external_wp_i18n_namespaceObject.__)('These changes will affect your whole site.');
  4550. case 'wp_template':
  4551. return (0,external_wp_i18n_namespaceObject.__)('This change will affect pages and posts that use this template.');
  4552. case 'page':
  4553. case 'post':
  4554. return (0,external_wp_i18n_namespaceObject.__)('The following content has been modified.');
  4555. }
  4556. }
  4557. function EntityTypeList(_ref) {
  4558. let {
  4559. list,
  4560. unselectedEntities,
  4561. setUnselectedEntities,
  4562. closePanel
  4563. } = _ref;
  4564. const count = list.length;
  4565. const firstRecord = list[0];
  4566. const entityConfig = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityConfig(firstRecord.kind, firstRecord.name), [firstRecord.kind, firstRecord.name]);
  4567. const {
  4568. name
  4569. } = firstRecord;
  4570. let entityLabel = entityConfig.label;
  4571. if (name === 'wp_template_part') {
  4572. entityLabel = 1 === count ? (0,external_wp_i18n_namespaceObject.__)('Template Part') : (0,external_wp_i18n_namespaceObject.__)('Template Parts');
  4573. } // Set description based on type of entity.
  4574. const description = getEntityDescription(name, count);
  4575. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
  4576. title: entityLabel,
  4577. initialOpen: true
  4578. }, description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, null, description), list.map(record => {
  4579. return (0,external_wp_element_namespaceObject.createElement)(EntityRecordItem, {
  4580. key: record.key || record.property,
  4581. record: record,
  4582. checked: !(0,external_lodash_namespaceObject.some)(unselectedEntities, elt => elt.kind === record.kind && elt.name === record.name && elt.key === record.key && elt.property === record.property),
  4583. onChange: value => setUnselectedEntities(record, value),
  4584. closePanel: closePanel
  4585. });
  4586. }));
  4587. }
  4588. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/entities-saved-states/index.js
  4589. /**
  4590. * External dependencies
  4591. */
  4592. /**
  4593. * WordPress dependencies
  4594. */
  4595. /**
  4596. * Internal dependencies
  4597. */
  4598. const TRANSLATED_SITE_PROPERTIES = {
  4599. title: (0,external_wp_i18n_namespaceObject.__)('Title'),
  4600. description: (0,external_wp_i18n_namespaceObject.__)('Tagline'),
  4601. site_logo: (0,external_wp_i18n_namespaceObject.__)('Logo'),
  4602. site_icon: (0,external_wp_i18n_namespaceObject.__)('Icon'),
  4603. show_on_front: (0,external_wp_i18n_namespaceObject.__)('Show on front'),
  4604. page_on_front: (0,external_wp_i18n_namespaceObject.__)('Page on front')
  4605. };
  4606. const PUBLISH_ON_SAVE_ENTITIES = [{
  4607. kind: 'postType',
  4608. name: 'wp_navigation'
  4609. }];
  4610. function EntitiesSavedStates(_ref) {
  4611. let {
  4612. close
  4613. } = _ref;
  4614. const saveButtonRef = (0,external_wp_element_namespaceObject.useRef)();
  4615. const {
  4616. dirtyEntityRecords
  4617. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  4618. const dirtyRecords = select(external_wp_coreData_namespaceObject.store).__experimentalGetDirtyEntityRecords(); // Remove site object and decouple into its edited pieces.
  4619. const dirtyRecordsWithoutSite = dirtyRecords.filter(record => !(record.kind === 'root' && record.name === 'site'));
  4620. const siteEdits = select(external_wp_coreData_namespaceObject.store).getEntityRecordEdits('root', 'site');
  4621. const siteEditsAsEntities = [];
  4622. for (const property in siteEdits) {
  4623. siteEditsAsEntities.push({
  4624. kind: 'root',
  4625. name: 'site',
  4626. title: TRANSLATED_SITE_PROPERTIES[property] || property,
  4627. property
  4628. });
  4629. }
  4630. const dirtyRecordsWithSiteItems = [...dirtyRecordsWithoutSite, ...siteEditsAsEntities];
  4631. return {
  4632. dirtyEntityRecords: dirtyRecordsWithSiteItems
  4633. };
  4634. }, []);
  4635. const {
  4636. editEntityRecord,
  4637. saveEditedEntityRecord,
  4638. __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits
  4639. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
  4640. const {
  4641. __unstableMarkLastChangeAsPersistent
  4642. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
  4643. const {
  4644. createSuccessNotice,
  4645. createErrorNotice
  4646. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); // To group entities by type.
  4647. const partitionedSavables = (0,external_lodash_namespaceObject.groupBy)(dirtyEntityRecords, 'name'); // Sort entity groups.
  4648. const {
  4649. site: siteSavables,
  4650. wp_template: templateSavables,
  4651. wp_template_part: templatePartSavables,
  4652. ...contentSavables
  4653. } = partitionedSavables;
  4654. const sortedPartitionedSavables = [siteSavables, templateSavables, templatePartSavables, ...Object.values(contentSavables)].filter(Array.isArray); // Unchecked entities to be ignored by save function.
  4655. const [unselectedEntities, _setUnselectedEntities] = (0,external_wp_element_namespaceObject.useState)([]);
  4656. const setUnselectedEntities = (_ref2, checked) => {
  4657. let {
  4658. kind,
  4659. name,
  4660. key,
  4661. property
  4662. } = _ref2;
  4663. if (checked) {
  4664. _setUnselectedEntities(unselectedEntities.filter(elt => elt.kind !== kind || elt.name !== name || elt.key !== key || elt.property !== property));
  4665. } else {
  4666. _setUnselectedEntities([...unselectedEntities, {
  4667. kind,
  4668. name,
  4669. key,
  4670. property
  4671. }]);
  4672. }
  4673. };
  4674. const saveCheckedEntities = () => {
  4675. const entitiesToSave = dirtyEntityRecords.filter(_ref3 => {
  4676. let {
  4677. kind,
  4678. name,
  4679. key,
  4680. property
  4681. } = _ref3;
  4682. return !(0,external_lodash_namespaceObject.some)(unselectedEntities, elt => elt.kind === kind && elt.name === name && elt.key === key && elt.property === property);
  4683. });
  4684. close(entitiesToSave);
  4685. const siteItemsToSave = [];
  4686. const pendingSavedRecords = [];
  4687. entitiesToSave.forEach(_ref4 => {
  4688. let {
  4689. kind,
  4690. name,
  4691. key,
  4692. property
  4693. } = _ref4;
  4694. if ('root' === kind && 'site' === name) {
  4695. siteItemsToSave.push(property);
  4696. } else {
  4697. if (PUBLISH_ON_SAVE_ENTITIES.some(typeToPublish => typeToPublish.kind === kind && typeToPublish.name === name)) {
  4698. editEntityRecord(kind, name, key, {
  4699. status: 'publish'
  4700. });
  4701. }
  4702. pendingSavedRecords.push(saveEditedEntityRecord(kind, name, key));
  4703. }
  4704. });
  4705. if (siteItemsToSave.length) {
  4706. pendingSavedRecords.push(saveSpecifiedEntityEdits('root', 'site', undefined, siteItemsToSave));
  4707. }
  4708. __unstableMarkLastChangeAsPersistent();
  4709. Promise.all(pendingSavedRecords).then(values => {
  4710. if (values.some(value => typeof value === 'undefined')) {
  4711. createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Saving failed.'));
  4712. } else {
  4713. createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Site updated.'), {
  4714. type: 'snackbar'
  4715. });
  4716. }
  4717. }).catch(error => createErrorNotice(`${(0,external_wp_i18n_namespaceObject.__)('Saving failed.')} ${error}`));
  4718. }; // Explicitly define this with no argument passed. Using `close` on
  4719. // its own will use the event object in place of the expected saved entities.
  4720. const dismissPanel = (0,external_wp_element_namespaceObject.useCallback)(() => close(), [close]);
  4721. const [saveDialogRef, saveDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
  4722. onClose: () => dismissPanel()
  4723. });
  4724. return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
  4725. ref: saveDialogRef
  4726. }, saveDialogProps, {
  4727. className: "entities-saved-states__panel"
  4728. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
  4729. className: "entities-saved-states__panel-header",
  4730. gap: 2
  4731. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
  4732. isBlock: true,
  4733. as: external_wp_components_namespaceObject.Button,
  4734. ref: saveButtonRef,
  4735. variant: "primary",
  4736. disabled: dirtyEntityRecords.length - unselectedEntities.length === 0,
  4737. onClick: saveCheckedEntities,
  4738. className: "editor-entities-saved-states__save-button"
  4739. }, (0,external_wp_i18n_namespaceObject.__)('Save')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
  4740. isBlock: true,
  4741. as: external_wp_components_namespaceObject.Button,
  4742. variant: "secondary",
  4743. onClick: dismissPanel
  4744. }, (0,external_wp_i18n_namespaceObject.__)('Cancel'))), (0,external_wp_element_namespaceObject.createElement)("div", {
  4745. className: "entities-saved-states__text-prompt"
  4746. }, (0,external_wp_element_namespaceObject.createElement)("strong", null, (0,external_wp_i18n_namespaceObject.__)('Are you ready to save?')), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('The following changes have been made to your site, templates, and content.'))), sortedPartitionedSavables.map(list => {
  4747. return (0,external_wp_element_namespaceObject.createElement)(EntityTypeList, {
  4748. key: list[0].name,
  4749. list: list,
  4750. closePanel: dismissPanel,
  4751. unselectedEntities: unselectedEntities,
  4752. setUnselectedEntities: setUnselectedEntities
  4753. });
  4754. }));
  4755. }
  4756. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/error-boundary/index.js
  4757. /**
  4758. * WordPress dependencies
  4759. */
  4760. /**
  4761. * Internal dependencies
  4762. */
  4763. function CopyButton(_ref) {
  4764. let {
  4765. text,
  4766. children
  4767. } = _ref;
  4768. const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text);
  4769. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  4770. variant: "secondary",
  4771. ref: ref
  4772. }, children);
  4773. }
  4774. class ErrorBoundary extends external_wp_element_namespaceObject.Component {
  4775. constructor() {
  4776. super(...arguments);
  4777. this.reboot = this.reboot.bind(this);
  4778. this.getContent = this.getContent.bind(this);
  4779. this.state = {
  4780. error: null
  4781. };
  4782. }
  4783. componentDidCatch(error) {
  4784. this.setState({
  4785. error
  4786. });
  4787. }
  4788. reboot() {
  4789. this.props.onError();
  4790. }
  4791. getContent() {
  4792. try {
  4793. // While `select` in a component is generally discouraged, it is
  4794. // used here because it (a) reduces the chance of data loss in the
  4795. // case of additional errors by performing a direct retrieval and
  4796. // (b) avoids the performance cost associated with unnecessary
  4797. // content serialization throughout the lifetime of a non-erroring
  4798. // application.
  4799. return (0,external_wp_data_namespaceObject.select)(store_store).getEditedPostContent();
  4800. } catch (error) {}
  4801. }
  4802. render() {
  4803. const {
  4804. error
  4805. } = this.state;
  4806. if (!error) {
  4807. return this.props.children;
  4808. }
  4809. return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, {
  4810. className: "editor-error-boundary",
  4811. actions: [(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  4812. key: "recovery",
  4813. onClick: this.reboot,
  4814. variant: "secondary"
  4815. }, (0,external_wp_i18n_namespaceObject.__)('Attempt Recovery')), (0,external_wp_element_namespaceObject.createElement)(CopyButton, {
  4816. key: "copy-post",
  4817. text: this.getContent
  4818. }, (0,external_wp_i18n_namespaceObject.__)('Copy Post Text')), (0,external_wp_element_namespaceObject.createElement)(CopyButton, {
  4819. key: "copy-error",
  4820. text: error.stack
  4821. }, (0,external_wp_i18n_namespaceObject.__)('Copy Error'))]
  4822. }, (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.'));
  4823. }
  4824. }
  4825. /* harmony default export */ var error_boundary = (ErrorBoundary);
  4826. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/local-autosave-monitor/index.js
  4827. /**
  4828. * External dependencies
  4829. */
  4830. /**
  4831. * WordPress dependencies
  4832. */
  4833. /**
  4834. * Internal dependencies
  4835. */
  4836. const requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame;
  4837. /**
  4838. * Function which returns true if the current environment supports browser
  4839. * sessionStorage, or false otherwise. The result of this function is cached and
  4840. * reused in subsequent invocations.
  4841. */
  4842. const hasSessionStorageSupport = (0,external_lodash_namespaceObject.once)(() => {
  4843. try {
  4844. // Private Browsing in Safari 10 and earlier will throw an error when
  4845. // attempting to set into sessionStorage. The test here is intentional in
  4846. // causing a thrown error as condition bailing from local autosave.
  4847. window.sessionStorage.setItem('__wpEditorTestSessionStorage', '');
  4848. window.sessionStorage.removeItem('__wpEditorTestSessionStorage');
  4849. return true;
  4850. } catch (error) {
  4851. return false;
  4852. }
  4853. });
  4854. /**
  4855. * Custom hook which manages the creation of a notice prompting the user to
  4856. * restore a local autosave, if one exists.
  4857. */
  4858. function useAutosaveNotice() {
  4859. const {
  4860. postId,
  4861. isEditedPostNew,
  4862. hasRemoteAutosave
  4863. } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
  4864. postId: select(store_store).getCurrentPostId(),
  4865. isEditedPostNew: select(store_store).isEditedPostNew(),
  4866. hasRemoteAutosave: !!select(store_store).getEditorSettings().autosave
  4867. }), []);
  4868. const {
  4869. getEditedPostAttribute
  4870. } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
  4871. const {
  4872. createWarningNotice,
  4873. removeNotice
  4874. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
  4875. const {
  4876. editPost,
  4877. resetEditorBlocks
  4878. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  4879. (0,external_wp_element_namespaceObject.useEffect)(() => {
  4880. let localAutosave = localAutosaveGet(postId, isEditedPostNew);
  4881. if (!localAutosave) {
  4882. return;
  4883. }
  4884. try {
  4885. localAutosave = JSON.parse(localAutosave);
  4886. } catch (error) {
  4887. // Not usable if it can't be parsed.
  4888. return;
  4889. }
  4890. const {
  4891. post_title: title,
  4892. content,
  4893. excerpt
  4894. } = localAutosave;
  4895. const edits = {
  4896. title,
  4897. content,
  4898. excerpt
  4899. };
  4900. {
  4901. // Only display a notice if there is a difference between what has been
  4902. // saved and that which is stored in sessionStorage.
  4903. const hasDifference = Object.keys(edits).some(key => {
  4904. return edits[key] !== getEditedPostAttribute(key);
  4905. });
  4906. if (!hasDifference) {
  4907. // If there is no difference, it can be safely ejected from storage.
  4908. localAutosaveClear(postId, isEditedPostNew);
  4909. return;
  4910. }
  4911. }
  4912. if (hasRemoteAutosave) {
  4913. return;
  4914. }
  4915. const noticeId = (0,external_lodash_namespaceObject.uniqueId)('wpEditorAutosaveRestore');
  4916. createWarningNotice((0,external_wp_i18n_namespaceObject.__)('The backup of this post in your browser is different from the version below.'), {
  4917. id: noticeId,
  4918. actions: [{
  4919. label: (0,external_wp_i18n_namespaceObject.__)('Restore the backup'),
  4920. onClick() {
  4921. editPost((0,external_lodash_namespaceObject.omit)(edits, ['content']));
  4922. resetEditorBlocks((0,external_wp_blocks_namespaceObject.parse)(edits.content));
  4923. removeNotice(noticeId);
  4924. }
  4925. }]
  4926. });
  4927. }, [isEditedPostNew, postId]);
  4928. }
  4929. /**
  4930. * Custom hook which ejects a local autosave after a successful save occurs.
  4931. */
  4932. function useAutosavePurge() {
  4933. const {
  4934. postId,
  4935. isEditedPostNew,
  4936. isDirty,
  4937. isAutosaving,
  4938. didError
  4939. } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
  4940. postId: select(store_store).getCurrentPostId(),
  4941. isEditedPostNew: select(store_store).isEditedPostNew(),
  4942. isDirty: select(store_store).isEditedPostDirty(),
  4943. isAutosaving: select(store_store).isAutosavingPost(),
  4944. didError: select(store_store).didPostSaveRequestFail()
  4945. }), []);
  4946. const lastIsDirty = (0,external_wp_element_namespaceObject.useRef)(isDirty);
  4947. const lastIsAutosaving = (0,external_wp_element_namespaceObject.useRef)(isAutosaving);
  4948. (0,external_wp_element_namespaceObject.useEffect)(() => {
  4949. if (!didError && (lastIsAutosaving.current && !isAutosaving || lastIsDirty.current && !isDirty)) {
  4950. localAutosaveClear(postId, isEditedPostNew);
  4951. }
  4952. lastIsDirty.current = isDirty;
  4953. lastIsAutosaving.current = isAutosaving;
  4954. }, [isDirty, isAutosaving, didError]); // Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.
  4955. const wasEditedPostNew = (0,external_wp_compose_namespaceObject.usePrevious)(isEditedPostNew);
  4956. const prevPostId = (0,external_wp_compose_namespaceObject.usePrevious)(postId);
  4957. (0,external_wp_element_namespaceObject.useEffect)(() => {
  4958. if (prevPostId === postId && wasEditedPostNew && !isEditedPostNew) {
  4959. localAutosaveClear(postId, true);
  4960. }
  4961. }, [isEditedPostNew, postId]);
  4962. }
  4963. function LocalAutosaveMonitor() {
  4964. const {
  4965. autosave
  4966. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  4967. const deferredAutosave = (0,external_wp_element_namespaceObject.useCallback)(() => {
  4968. requestIdleCallback(() => autosave({
  4969. local: true
  4970. }));
  4971. }, []);
  4972. useAutosaveNotice();
  4973. useAutosavePurge();
  4974. const {
  4975. localAutosaveInterval
  4976. } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
  4977. localAutosaveInterval: select(store_store).getEditorSettings().localAutosaveInterval
  4978. }), []);
  4979. return (0,external_wp_element_namespaceObject.createElement)(autosave_monitor, {
  4980. interval: localAutosaveInterval,
  4981. autosave: deferredAutosave
  4982. });
  4983. }
  4984. /* harmony default export */ var local_autosave_monitor = ((0,external_wp_compose_namespaceObject.ifCondition)(hasSessionStorageSupport)(LocalAutosaveMonitor));
  4985. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/page-attributes/check.js
  4986. /**
  4987. * External dependencies
  4988. */
  4989. /**
  4990. * WordPress dependencies
  4991. */
  4992. /**
  4993. * Internal dependencies
  4994. */
  4995. function PageAttributesCheck(_ref) {
  4996. let {
  4997. children
  4998. } = _ref;
  4999. const postType = (0,external_wp_data_namespaceObject.useSelect)(select => {
  5000. const {
  5001. getEditedPostAttribute
  5002. } = select(store_store);
  5003. const {
  5004. getPostType
  5005. } = select(external_wp_coreData_namespaceObject.store);
  5006. return getPostType(getEditedPostAttribute('type'));
  5007. }, []);
  5008. const supportsPageAttributes = (0,external_lodash_namespaceObject.get)(postType, ['supports', 'page-attributes'], false); // Only render fields if post type supports page attributes or available templates exist.
  5009. if (!supportsPageAttributes) {
  5010. return null;
  5011. }
  5012. return children;
  5013. }
  5014. /* harmony default export */ var page_attributes_check = (PageAttributesCheck);
  5015. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-type-support-check/index.js
  5016. /**
  5017. * External dependencies
  5018. */
  5019. /**
  5020. * WordPress dependencies
  5021. */
  5022. /**
  5023. * Internal dependencies
  5024. */
  5025. /**
  5026. * A component which renders its own children only if the current editor post
  5027. * type supports one of the given `supportKeys` prop.
  5028. *
  5029. * @param {Object} props Props.
  5030. * @param {string} [props.postType] Current post type.
  5031. * @param {WPElement} props.children Children to be rendered if post
  5032. * type supports.
  5033. * @param {(string|string[])} props.supportKeys String or string array of keys
  5034. * to test.
  5035. *
  5036. * @return {WPComponent} The component to be rendered.
  5037. */
  5038. function PostTypeSupportCheck(_ref) {
  5039. let {
  5040. postType,
  5041. children,
  5042. supportKeys
  5043. } = _ref;
  5044. let isSupported = true;
  5045. if (postType) {
  5046. isSupported = (0,external_lodash_namespaceObject.some)((0,external_lodash_namespaceObject.castArray)(supportKeys), key => !!postType.supports[key]);
  5047. }
  5048. if (!isSupported) {
  5049. return null;
  5050. }
  5051. return children;
  5052. }
  5053. /* harmony default export */ var post_type_support_check = ((0,external_wp_data_namespaceObject.withSelect)(select => {
  5054. const {
  5055. getEditedPostAttribute
  5056. } = select(store_store);
  5057. const {
  5058. getPostType
  5059. } = select(external_wp_coreData_namespaceObject.store);
  5060. return {
  5061. postType: getPostType(getEditedPostAttribute('type'))
  5062. };
  5063. })(PostTypeSupportCheck));
  5064. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/page-attributes/order.js
  5065. /**
  5066. * External dependencies
  5067. */
  5068. /**
  5069. * WordPress dependencies
  5070. */
  5071. /**
  5072. * Internal dependencies
  5073. */
  5074. const PageAttributesOrder = _ref => {
  5075. let {
  5076. onUpdateOrder,
  5077. order = 0
  5078. } = _ref;
  5079. const [orderInput, setOrderInput] = (0,external_wp_element_namespaceObject.useState)(null);
  5080. const setUpdatedOrder = value => {
  5081. setOrderInput(value);
  5082. const newOrder = Number(value);
  5083. if (Number.isInteger(newOrder) && (0,external_lodash_namespaceObject.invoke)(value, ['trim']) !== '') {
  5084. onUpdateOrder(Number(value));
  5085. }
  5086. };
  5087. const value = orderInput === null ? order : orderInput;
  5088. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  5089. className: "editor-page-attributes__order",
  5090. type: "number",
  5091. label: (0,external_wp_i18n_namespaceObject.__)('Order'),
  5092. value: value,
  5093. onChange: setUpdatedOrder,
  5094. size: 6,
  5095. onBlur: () => {
  5096. setOrderInput(null);
  5097. }
  5098. });
  5099. };
  5100. function PageAttributesOrderWithChecks(props) {
  5101. return (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, {
  5102. supportKeys: "page-attributes"
  5103. }, (0,external_wp_element_namespaceObject.createElement)(PageAttributesOrder, props));
  5104. }
  5105. /* harmony default export */ var order = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
  5106. return {
  5107. order: select(store_store).getEditedPostAttribute('menu_order')
  5108. };
  5109. }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
  5110. onUpdateOrder(order) {
  5111. dispatch(store_store).editPost({
  5112. menu_order: order
  5113. });
  5114. }
  5115. }))])(PageAttributesOrderWithChecks));
  5116. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/terms.js
  5117. /**
  5118. * External dependencies
  5119. */
  5120. /**
  5121. * Returns terms in a tree form.
  5122. *
  5123. * @param {Array} flatTerms Array of terms in flat format.
  5124. *
  5125. * @return {Array} Array of terms in tree format.
  5126. */
  5127. function buildTermsTree(flatTerms) {
  5128. const flatTermsWithParentAndChildren = flatTerms.map(term => {
  5129. return {
  5130. children: [],
  5131. parent: null,
  5132. ...term
  5133. };
  5134. });
  5135. const termsByParent = (0,external_lodash_namespaceObject.groupBy)(flatTermsWithParentAndChildren, 'parent');
  5136. if (termsByParent.null && termsByParent.null.length) {
  5137. return flatTermsWithParentAndChildren;
  5138. }
  5139. const fillWithChildren = terms => {
  5140. return terms.map(term => {
  5141. const children = termsByParent[term.id];
  5142. return { ...term,
  5143. children: children && children.length ? fillWithChildren(children) : []
  5144. };
  5145. });
  5146. };
  5147. return fillWithChildren(termsByParent['0'] || []);
  5148. } // Lodash unescape function handles &#39; but not &#039; which may be return in some API requests.
  5149. const unescapeString = arg => {
  5150. return (0,external_lodash_namespaceObject.unescape)(arg.replace('&#039;', "'"));
  5151. };
  5152. /**
  5153. * Returns a term object with name unescaped.
  5154. * The unescape of the name property is done using lodash unescape function.
  5155. *
  5156. * @param {Object} term The term object to unescape.
  5157. *
  5158. * @return {Object} Term object with name property unescaped.
  5159. */
  5160. const unescapeTerm = term => {
  5161. return { ...term,
  5162. name: unescapeString(term.name)
  5163. };
  5164. };
  5165. /**
  5166. * Returns an array of term objects with names unescaped.
  5167. * The unescape of each term is performed using the unescapeTerm function.
  5168. *
  5169. * @param {Object[]} terms Array of term objects to unescape.
  5170. *
  5171. * @return {Object[]} Array of term objects unescaped.
  5172. */
  5173. const unescapeTerms = terms => {
  5174. return (0,external_lodash_namespaceObject.map)(terms, unescapeTerm);
  5175. };
  5176. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/page-attributes/parent.js
  5177. /**
  5178. * External dependencies
  5179. */
  5180. /**
  5181. * WordPress dependencies
  5182. */
  5183. /**
  5184. * Internal dependencies
  5185. */
  5186. function getTitle(post) {
  5187. var _post$title;
  5188. return post !== null && post !== void 0 && (_post$title = post.title) !== null && _post$title !== void 0 && _post$title.rendered ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title.rendered) : `#${post.id} (${(0,external_wp_i18n_namespaceObject.__)('no title')})`;
  5189. }
  5190. const getItemPriority = (name, searchValue) => {
  5191. const normalizedName = (0,external_lodash_namespaceObject.deburr)(name).toLowerCase();
  5192. const normalizedSearch = (0,external_lodash_namespaceObject.deburr)(searchValue).toLowerCase();
  5193. if (normalizedName === normalizedSearch) {
  5194. return 0;
  5195. }
  5196. if (normalizedName.startsWith(normalizedSearch)) {
  5197. return normalizedName.length;
  5198. }
  5199. return Infinity;
  5200. };
  5201. function PageAttributesParent() {
  5202. const {
  5203. editPost
  5204. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  5205. const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)(false);
  5206. const {
  5207. parentPost,
  5208. parentPostId,
  5209. items,
  5210. postType
  5211. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  5212. const {
  5213. getPostType,
  5214. getEntityRecords,
  5215. getEntityRecord
  5216. } = select(external_wp_coreData_namespaceObject.store);
  5217. const {
  5218. getCurrentPostId,
  5219. getEditedPostAttribute
  5220. } = select(store_store);
  5221. const postTypeSlug = getEditedPostAttribute('type');
  5222. const pageId = getEditedPostAttribute('parent');
  5223. const pType = getPostType(postTypeSlug);
  5224. const postId = getCurrentPostId();
  5225. const isHierarchical = (0,external_lodash_namespaceObject.get)(pType, ['hierarchical'], false);
  5226. const query = {
  5227. per_page: 100,
  5228. exclude: postId,
  5229. parent_exclude: postId,
  5230. orderby: 'menu_order',
  5231. order: 'asc',
  5232. _fields: 'id,title,parent'
  5233. }; // Perform a search when the field is changed.
  5234. if (!!fieldValue) {
  5235. query.search = fieldValue;
  5236. }
  5237. return {
  5238. parentPostId: pageId,
  5239. parentPost: pageId ? getEntityRecord('postType', postTypeSlug, pageId) : null,
  5240. items: isHierarchical ? getEntityRecords('postType', postTypeSlug, query) : [],
  5241. postType: pType
  5242. };
  5243. }, [fieldValue]);
  5244. const isHierarchical = (0,external_lodash_namespaceObject.get)(postType, ['hierarchical'], false);
  5245. const parentPageLabel = (0,external_lodash_namespaceObject.get)(postType, ['labels', 'parent_item_colon']);
  5246. const pageItems = items || [];
  5247. const parentOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
  5248. const getOptionsFromTree = function (tree) {
  5249. let level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  5250. const mappedNodes = tree.map(treeNode => [{
  5251. value: treeNode.id,
  5252. label: (0,external_lodash_namespaceObject.repeat)('— ', level) + (0,external_lodash_namespaceObject.unescape)(treeNode.name),
  5253. rawName: treeNode.name
  5254. }, ...getOptionsFromTree(treeNode.children || [], level + 1)]);
  5255. const sortedNodes = mappedNodes.sort((_ref, _ref2) => {
  5256. let [a] = _ref;
  5257. let [b] = _ref2;
  5258. const priorityA = getItemPriority(a.rawName, fieldValue);
  5259. const priorityB = getItemPriority(b.rawName, fieldValue);
  5260. return priorityA >= priorityB ? 1 : -1;
  5261. });
  5262. return (0,external_lodash_namespaceObject.flatten)(sortedNodes);
  5263. };
  5264. let tree = pageItems.map(item => ({
  5265. id: item.id,
  5266. parent: item.parent,
  5267. name: getTitle(item)
  5268. })); // Only build a hierarchical tree when not searching.
  5269. if (!fieldValue) {
  5270. tree = buildTermsTree(tree);
  5271. }
  5272. const opts = getOptionsFromTree(tree); // Ensure the current parent is in the options list.
  5273. const optsHasParent = (0,external_lodash_namespaceObject.find)(opts, item => item.value === parentPostId);
  5274. if (parentPost && !optsHasParent) {
  5275. opts.unshift({
  5276. value: parentPostId,
  5277. label: getTitle(parentPost)
  5278. });
  5279. }
  5280. return opts;
  5281. }, [pageItems, fieldValue]);
  5282. if (!isHierarchical || !parentPageLabel) {
  5283. return null;
  5284. }
  5285. /**
  5286. * Handle user input.
  5287. *
  5288. * @param {string} inputValue The current value of the input field.
  5289. */
  5290. const handleKeydown = inputValue => {
  5291. setFieldValue(inputValue);
  5292. };
  5293. /**
  5294. * Handle author selection.
  5295. *
  5296. * @param {Object} selectedPostId The selected Author.
  5297. */
  5298. const handleChange = selectedPostId => {
  5299. editPost({
  5300. parent: selectedPostId
  5301. });
  5302. };
  5303. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ComboboxControl, {
  5304. className: "editor-page-attributes__parent",
  5305. label: parentPageLabel,
  5306. value: parentPostId,
  5307. options: parentOptions,
  5308. onFilterValueChange: (0,external_lodash_namespaceObject.debounce)(handleKeydown, 300),
  5309. onChange: handleChange
  5310. });
  5311. }
  5312. /* harmony default export */ var page_attributes_parent = (PageAttributesParent);
  5313. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-template/index.js
  5314. /**
  5315. * External dependencies
  5316. */
  5317. /**
  5318. * WordPress dependencies
  5319. */
  5320. /**
  5321. * Internal dependencies
  5322. */
  5323. function PostTemplate(_ref) {
  5324. let {} = _ref;
  5325. const {
  5326. availableTemplates,
  5327. selectedTemplate,
  5328. isViewable
  5329. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  5330. var _getPostType$viewable, _getPostType;
  5331. const {
  5332. getEditedPostAttribute,
  5333. getEditorSettings,
  5334. getCurrentPostType
  5335. } = select(store_store);
  5336. const {
  5337. getPostType
  5338. } = select(external_wp_coreData_namespaceObject.store);
  5339. return {
  5340. selectedTemplate: getEditedPostAttribute('template'),
  5341. availableTemplates: getEditorSettings().availableTemplates,
  5342. isViewable: (_getPostType$viewable = (_getPostType = getPostType(getCurrentPostType())) === null || _getPostType === void 0 ? void 0 : _getPostType.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false
  5343. };
  5344. }, []);
  5345. const {
  5346. editPost
  5347. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  5348. if (!isViewable || (0,external_lodash_namespaceObject.isEmpty)(availableTemplates)) {
  5349. return null;
  5350. }
  5351. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
  5352. label: (0,external_wp_i18n_namespaceObject.__)('Template:'),
  5353. value: selectedTemplate,
  5354. onChange: templateSlug => {
  5355. editPost({
  5356. template: templateSlug || ''
  5357. });
  5358. },
  5359. options: (0,external_lodash_namespaceObject.map)(availableTemplates, (templateName, templateSlug) => ({
  5360. value: templateSlug,
  5361. label: templateName
  5362. }))
  5363. });
  5364. }
  5365. /* harmony default export */ var post_template = (PostTemplate);
  5366. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/constants.js
  5367. const AUTHORS_QUERY = {
  5368. who: 'authors',
  5369. per_page: 50,
  5370. _fields: 'id,name',
  5371. context: 'view' // Allows non-admins to perform requests.
  5372. };
  5373. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/combobox.js
  5374. /**
  5375. * External dependencies
  5376. */
  5377. /**
  5378. * WordPress dependencies
  5379. */
  5380. /**
  5381. * Internal dependencies
  5382. */
  5383. function PostAuthorCombobox() {
  5384. const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)();
  5385. const {
  5386. authorId,
  5387. isLoading,
  5388. authors,
  5389. postAuthor
  5390. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  5391. const {
  5392. getUser,
  5393. getUsers,
  5394. isResolving
  5395. } = select(external_wp_coreData_namespaceObject.store);
  5396. const {
  5397. getEditedPostAttribute
  5398. } = select(store_store);
  5399. const author = getUser(getEditedPostAttribute('author'), {
  5400. context: 'view'
  5401. });
  5402. const query = { ...AUTHORS_QUERY
  5403. };
  5404. if (fieldValue) {
  5405. query.search = fieldValue;
  5406. }
  5407. return {
  5408. authorId: getEditedPostAttribute('author'),
  5409. postAuthor: author,
  5410. authors: getUsers(query),
  5411. isLoading: isResolving('core', 'getUsers', [query])
  5412. };
  5413. }, [fieldValue]);
  5414. const {
  5415. editPost
  5416. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  5417. const authorOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
  5418. const fetchedAuthors = (authors !== null && authors !== void 0 ? authors : []).map(author => {
  5419. return {
  5420. value: author.id,
  5421. label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(author.name)
  5422. };
  5423. }); // Ensure the current author is included in the dropdown list.
  5424. const foundAuthor = fetchedAuthors.findIndex(_ref => {
  5425. let {
  5426. value
  5427. } = _ref;
  5428. return (postAuthor === null || postAuthor === void 0 ? void 0 : postAuthor.id) === value;
  5429. });
  5430. if (foundAuthor < 0 && postAuthor) {
  5431. return [{
  5432. value: postAuthor.id,
  5433. label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postAuthor.name)
  5434. }, ...fetchedAuthors];
  5435. }
  5436. return fetchedAuthors;
  5437. }, [authors, postAuthor]);
  5438. /**
  5439. * Handle author selection.
  5440. *
  5441. * @param {number} postAuthorId The selected Author.
  5442. */
  5443. const handleSelect = postAuthorId => {
  5444. if (!postAuthorId) {
  5445. return;
  5446. }
  5447. editPost({
  5448. author: postAuthorId
  5449. });
  5450. };
  5451. /**
  5452. * Handle user input.
  5453. *
  5454. * @param {string} inputValue The current value of the input field.
  5455. */
  5456. const handleKeydown = inputValue => {
  5457. setFieldValue(inputValue);
  5458. };
  5459. if (!postAuthor) {
  5460. return null;
  5461. }
  5462. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ComboboxControl, {
  5463. label: (0,external_wp_i18n_namespaceObject.__)('Author'),
  5464. options: authorOptions,
  5465. value: authorId,
  5466. onFilterValueChange: (0,external_lodash_namespaceObject.debounce)(handleKeydown, 300),
  5467. onChange: handleSelect,
  5468. isLoading: isLoading,
  5469. allowReset: false
  5470. });
  5471. }
  5472. /* harmony default export */ var combobox = (PostAuthorCombobox);
  5473. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/select.js
  5474. /**
  5475. * WordPress dependencies
  5476. */
  5477. /**
  5478. * Internal dependencies
  5479. */
  5480. function PostAuthorSelect() {
  5481. const {
  5482. editPost
  5483. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  5484. const {
  5485. postAuthor,
  5486. authors
  5487. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  5488. return {
  5489. postAuthor: select(store_store).getEditedPostAttribute('author'),
  5490. authors: select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY)
  5491. };
  5492. }, []);
  5493. const authorOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
  5494. return (authors !== null && authors !== void 0 ? authors : []).map(author => {
  5495. return {
  5496. value: author.id,
  5497. label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(author.name)
  5498. };
  5499. });
  5500. }, [authors]);
  5501. const setAuthorId = value => {
  5502. const author = Number(value);
  5503. editPost({
  5504. author
  5505. });
  5506. };
  5507. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
  5508. className: "post-author-selector",
  5509. label: (0,external_wp_i18n_namespaceObject.__)('Author'),
  5510. options: authorOptions,
  5511. onChange: setAuthorId,
  5512. value: postAuthor
  5513. });
  5514. }
  5515. /* harmony default export */ var post_author_select = (PostAuthorSelect);
  5516. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/index.js
  5517. /**
  5518. * WordPress dependencies
  5519. */
  5520. /**
  5521. * Internal dependencies
  5522. */
  5523. const minimumUsersForCombobox = 25;
  5524. function PostAuthor() {
  5525. const showCombobox = (0,external_wp_data_namespaceObject.useSelect)(select => {
  5526. const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY);
  5527. return (authors === null || authors === void 0 ? void 0 : authors.length) >= minimumUsersForCombobox;
  5528. }, []);
  5529. if (showCombobox) {
  5530. return (0,external_wp_element_namespaceObject.createElement)(combobox, null);
  5531. }
  5532. return (0,external_wp_element_namespaceObject.createElement)(post_author_select, null);
  5533. }
  5534. /* harmony default export */ var post_author = (PostAuthor);
  5535. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/check.js
  5536. /**
  5537. * External dependencies
  5538. */
  5539. /**
  5540. * WordPress dependencies
  5541. */
  5542. /**
  5543. * Internal dependencies
  5544. */
  5545. function PostAuthorCheck(_ref) {
  5546. let {
  5547. children
  5548. } = _ref;
  5549. const {
  5550. hasAssignAuthorAction,
  5551. hasAuthors
  5552. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  5553. const post = select(store_store).getCurrentPost();
  5554. const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY);
  5555. return {
  5556. hasAssignAuthorAction: (0,external_lodash_namespaceObject.get)(post, ['_links', 'wp:action-assign-author'], false),
  5557. hasAuthors: (authors === null || authors === void 0 ? void 0 : authors.length) >= 1
  5558. };
  5559. }, []);
  5560. if (!hasAssignAuthorAction || !hasAuthors) {
  5561. return null;
  5562. }
  5563. return (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, {
  5564. supportKeys: "author"
  5565. }, children);
  5566. }
  5567. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-comments/index.js
  5568. /**
  5569. * WordPress dependencies
  5570. */
  5571. /**
  5572. * Internal dependencies
  5573. */
  5574. function PostComments(_ref) {
  5575. let {
  5576. commentStatus = 'open',
  5577. ...props
  5578. } = _ref;
  5579. const onToggleComments = () => props.editPost({
  5580. comment_status: commentStatus === 'open' ? 'closed' : 'open'
  5581. });
  5582. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
  5583. label: (0,external_wp_i18n_namespaceObject.__)('Allow comments'),
  5584. checked: commentStatus === 'open',
  5585. onChange: onToggleComments
  5586. });
  5587. }
  5588. /* harmony default export */ var post_comments = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
  5589. return {
  5590. commentStatus: select(store_store).getEditedPostAttribute('comment_status')
  5591. };
  5592. }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
  5593. editPost: dispatch(store_store).editPost
  5594. }))])(PostComments));
  5595. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-excerpt/index.js
  5596. /**
  5597. * WordPress dependencies
  5598. */
  5599. /**
  5600. * Internal dependencies
  5601. */
  5602. function PostExcerpt(_ref) {
  5603. let {
  5604. excerpt,
  5605. onUpdateExcerpt
  5606. } = _ref;
  5607. return (0,external_wp_element_namespaceObject.createElement)("div", {
  5608. className: "editor-post-excerpt"
  5609. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextareaControl, {
  5610. label: (0,external_wp_i18n_namespaceObject.__)('Write an excerpt (optional)'),
  5611. className: "editor-post-excerpt__textarea",
  5612. onChange: value => onUpdateExcerpt(value),
  5613. value: excerpt
  5614. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
  5615. href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/settings-sidebar/#excerpt')
  5616. }, (0,external_wp_i18n_namespaceObject.__)('Learn more about manual excerpts')));
  5617. }
  5618. /* harmony default export */ var post_excerpt = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
  5619. return {
  5620. excerpt: select(store_store).getEditedPostAttribute('excerpt')
  5621. };
  5622. }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
  5623. onUpdateExcerpt(excerpt) {
  5624. dispatch(store_store).editPost({
  5625. excerpt
  5626. });
  5627. }
  5628. }))])(PostExcerpt));
  5629. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-excerpt/check.js
  5630. /**
  5631. * Internal dependencies
  5632. */
  5633. function PostExcerptCheck(props) {
  5634. return (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, _extends({}, props, {
  5635. supportKeys: "excerpt"
  5636. }));
  5637. }
  5638. /* harmony default export */ var post_excerpt_check = (PostExcerptCheck);
  5639. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/theme-support-check/index.js
  5640. /**
  5641. * External dependencies
  5642. */
  5643. /**
  5644. * WordPress dependencies
  5645. */
  5646. /**
  5647. * Internal dependencies
  5648. */
  5649. function ThemeSupportCheck(_ref) {
  5650. let {
  5651. themeSupports,
  5652. children,
  5653. postType,
  5654. supportKeys
  5655. } = _ref;
  5656. const isSupported = (0,external_lodash_namespaceObject.some)((0,external_lodash_namespaceObject.castArray)(supportKeys), key => {
  5657. const supported = (0,external_lodash_namespaceObject.get)(themeSupports, [key], false); // 'post-thumbnails' can be boolean or an array of post types.
  5658. // In the latter case, we need to verify `postType` exists
  5659. // within `supported`. If `postType` isn't passed, then the check
  5660. // should fail.
  5661. if ('post-thumbnails' === key && (0,external_lodash_namespaceObject.isArray)(supported)) {
  5662. return (0,external_lodash_namespaceObject.includes)(supported, postType);
  5663. }
  5664. return supported;
  5665. });
  5666. if (!isSupported) {
  5667. return null;
  5668. }
  5669. return children;
  5670. }
  5671. /* harmony default export */ var theme_support_check = ((0,external_wp_data_namespaceObject.withSelect)(select => {
  5672. const {
  5673. getThemeSupports
  5674. } = select(external_wp_coreData_namespaceObject.store);
  5675. const {
  5676. getEditedPostAttribute
  5677. } = select(store_store);
  5678. return {
  5679. postType: getEditedPostAttribute('type'),
  5680. themeSupports: getThemeSupports()
  5681. };
  5682. })(ThemeSupportCheck));
  5683. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-featured-image/check.js
  5684. /**
  5685. * Internal dependencies
  5686. */
  5687. function PostFeaturedImageCheck(props) {
  5688. return (0,external_wp_element_namespaceObject.createElement)(theme_support_check, {
  5689. supportKeys: "post-thumbnails"
  5690. }, (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, _extends({}, props, {
  5691. supportKeys: "thumbnail"
  5692. })));
  5693. }
  5694. /* harmony default export */ var post_featured_image_check = (PostFeaturedImageCheck);
  5695. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-featured-image/index.js
  5696. /**
  5697. * External dependencies
  5698. */
  5699. /**
  5700. * WordPress dependencies
  5701. */
  5702. /**
  5703. * Internal dependencies
  5704. */
  5705. const ALLOWED_MEDIA_TYPES = ['image']; // Used when labels from post type were not yet loaded or when they are not present.
  5706. const DEFAULT_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Featured image');
  5707. const DEFAULT_SET_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Set featured image');
  5708. const DEFAULT_REMOVE_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Remove image');
  5709. function PostFeaturedImage(_ref) {
  5710. var _media$media_details$, _media$media_details$2;
  5711. let {
  5712. currentPostId,
  5713. featuredImageId,
  5714. onUpdateImage,
  5715. onDropImage,
  5716. onRemoveImage,
  5717. media,
  5718. postType,
  5719. noticeUI
  5720. } = _ref;
  5721. const postLabel = (0,external_lodash_namespaceObject.get)(postType, ['labels'], {});
  5722. const instructions = (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('To edit the featured image, you need permission to upload media.'));
  5723. let mediaWidth, mediaHeight, mediaSourceUrl;
  5724. if (media) {
  5725. const mediaSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'post-thumbnail', media.id, currentPostId);
  5726. if ((0,external_lodash_namespaceObject.has)(media, ['media_details', 'sizes', mediaSize])) {
  5727. // Use mediaSize when available.
  5728. mediaWidth = media.media_details.sizes[mediaSize].width;
  5729. mediaHeight = media.media_details.sizes[mediaSize].height;
  5730. mediaSourceUrl = media.media_details.sizes[mediaSize].source_url;
  5731. } else {
  5732. // Get fallbackMediaSize if mediaSize is not available.
  5733. const fallbackMediaSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'thumbnail', media.id, currentPostId);
  5734. if ((0,external_lodash_namespaceObject.has)(media, ['media_details', 'sizes', fallbackMediaSize])) {
  5735. // Use fallbackMediaSize when mediaSize is not available.
  5736. mediaWidth = media.media_details.sizes[fallbackMediaSize].width;
  5737. mediaHeight = media.media_details.sizes[fallbackMediaSize].height;
  5738. mediaSourceUrl = media.media_details.sizes[fallbackMediaSize].source_url;
  5739. } else {
  5740. // Use full image size when mediaFallbackSize and mediaSize are not available.
  5741. mediaWidth = media.media_details.width;
  5742. mediaHeight = media.media_details.height;
  5743. mediaSourceUrl = media.source_url;
  5744. }
  5745. }
  5746. }
  5747. return (0,external_wp_element_namespaceObject.createElement)(post_featured_image_check, null, noticeUI, (0,external_wp_element_namespaceObject.createElement)("div", {
  5748. className: "editor-post-featured-image"
  5749. }, media && (0,external_wp_element_namespaceObject.createElement)("div", {
  5750. id: `editor-post-featured-image-${featuredImageId}-describedby`,
  5751. className: "hidden"
  5752. }, media.alt_text && (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %s: The selected image alt text.
  5753. (0,external_wp_i18n_namespaceObject.__)('Current image: %s'), media.alt_text), !media.alt_text && (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %s: The selected image filename.
  5754. (0,external_wp_i18n_namespaceObject.__)('The current image has no alternative text. The file name is: %s'), ((_media$media_details$ = media.media_details.sizes) === null || _media$media_details$ === void 0 ? void 0 : (_media$media_details$2 = _media$media_details$.full) === null || _media$media_details$2 === void 0 ? void 0 : _media$media_details$2.file) || media.slug)), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUploadCheck, {
  5755. fallback: instructions
  5756. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUpload, {
  5757. title: postLabel.featured_image || DEFAULT_FEATURE_IMAGE_LABEL,
  5758. onSelect: onUpdateImage,
  5759. unstableFeaturedImageFlow: true,
  5760. allowedTypes: ALLOWED_MEDIA_TYPES,
  5761. modalClass: "editor-post-featured-image__media-modal",
  5762. render: _ref2 => {
  5763. let {
  5764. open
  5765. } = _ref2;
  5766. return (0,external_wp_element_namespaceObject.createElement)("div", {
  5767. className: "editor-post-featured-image__container"
  5768. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  5769. className: !featuredImageId ? 'editor-post-featured-image__toggle' : 'editor-post-featured-image__preview',
  5770. onClick: open,
  5771. "aria-label": !featuredImageId ? null : (0,external_wp_i18n_namespaceObject.__)('Edit or update the image'),
  5772. "aria-describedby": !featuredImageId ? null : `editor-post-featured-image-${featuredImageId}-describedby`
  5773. }, !!featuredImageId && media && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ResponsiveWrapper, {
  5774. naturalWidth: mediaWidth,
  5775. naturalHeight: mediaHeight,
  5776. isInline: true
  5777. }, (0,external_wp_element_namespaceObject.createElement)("img", {
  5778. src: mediaSourceUrl,
  5779. alt: ""
  5780. })), !!featuredImageId && !media && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null), !featuredImageId && (postLabel.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropZone, {
  5781. onFilesDrop: onDropImage
  5782. }));
  5783. },
  5784. value: featuredImageId
  5785. })), !!featuredImageId && media && !media.isLoading && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUploadCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUpload, {
  5786. title: postLabel.featured_image || DEFAULT_FEATURE_IMAGE_LABEL,
  5787. onSelect: onUpdateImage,
  5788. unstableFeaturedImageFlow: true,
  5789. allowedTypes: ALLOWED_MEDIA_TYPES,
  5790. modalClass: "editor-post-featured-image__media-modal",
  5791. render: _ref3 => {
  5792. let {
  5793. open
  5794. } = _ref3;
  5795. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  5796. onClick: open,
  5797. variant: "secondary"
  5798. }, (0,external_wp_i18n_namespaceObject.__)('Replace Image'));
  5799. }
  5800. })), !!featuredImageId && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUploadCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  5801. onClick: onRemoveImage,
  5802. variant: "link",
  5803. isDestructive: true
  5804. }, postLabel.remove_featured_image || DEFAULT_REMOVE_FEATURE_IMAGE_LABEL))));
  5805. }
  5806. const applyWithSelect = (0,external_wp_data_namespaceObject.withSelect)(select => {
  5807. const {
  5808. getMedia,
  5809. getPostType
  5810. } = select(external_wp_coreData_namespaceObject.store);
  5811. const {
  5812. getCurrentPostId,
  5813. getEditedPostAttribute
  5814. } = select(store_store);
  5815. const featuredImageId = getEditedPostAttribute('featured_media');
  5816. return {
  5817. media: featuredImageId ? getMedia(featuredImageId, {
  5818. context: 'view'
  5819. }) : null,
  5820. currentPostId: getCurrentPostId(),
  5821. postType: getPostType(getEditedPostAttribute('type')),
  5822. featuredImageId
  5823. };
  5824. });
  5825. const applyWithDispatch = (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref4, _ref5) => {
  5826. let {
  5827. noticeOperations
  5828. } = _ref4;
  5829. let {
  5830. select
  5831. } = _ref5;
  5832. const {
  5833. editPost
  5834. } = dispatch(store_store);
  5835. return {
  5836. onUpdateImage(image) {
  5837. editPost({
  5838. featured_media: image.id
  5839. });
  5840. },
  5841. onDropImage(filesList) {
  5842. select(external_wp_blockEditor_namespaceObject.store).getSettings().mediaUpload({
  5843. allowedTypes: ['image'],
  5844. filesList,
  5845. onFileChange(_ref6) {
  5846. let [image] = _ref6;
  5847. editPost({
  5848. featured_media: image.id
  5849. });
  5850. },
  5851. onError(message) {
  5852. noticeOperations.removeAllNotices();
  5853. noticeOperations.createErrorNotice(message);
  5854. }
  5855. });
  5856. },
  5857. onRemoveImage() {
  5858. editPost({
  5859. featured_media: 0
  5860. });
  5861. }
  5862. };
  5863. });
  5864. /* harmony default export */ var post_featured_image = ((0,external_wp_compose_namespaceObject.compose)(external_wp_components_namespaceObject.withNotices, applyWithSelect, applyWithDispatch, (0,external_wp_components_namespaceObject.withFilters)('editor.PostFeaturedImage'))(PostFeaturedImage));
  5865. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-format/check.js
  5866. /**
  5867. * WordPress dependencies
  5868. */
  5869. /**
  5870. * Internal dependencies
  5871. */
  5872. function PostFormatCheck(_ref) {
  5873. let {
  5874. disablePostFormats,
  5875. ...props
  5876. } = _ref;
  5877. return !disablePostFormats && (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, _extends({}, props, {
  5878. supportKeys: "post-formats"
  5879. }));
  5880. }
  5881. /* harmony default export */ var post_format_check = ((0,external_wp_data_namespaceObject.withSelect)(select => {
  5882. const editorSettings = select(store_store).getEditorSettings();
  5883. return {
  5884. disablePostFormats: editorSettings.disablePostFormats
  5885. };
  5886. })(PostFormatCheck));
  5887. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-format/index.js
  5888. /**
  5889. * External dependencies
  5890. */
  5891. /**
  5892. * WordPress dependencies
  5893. */
  5894. /**
  5895. * Internal dependencies
  5896. */
  5897. // All WP post formats, sorted alphabetically by translated name.
  5898. const POST_FORMATS = [{
  5899. id: 'aside',
  5900. caption: (0,external_wp_i18n_namespaceObject.__)('Aside')
  5901. }, {
  5902. id: 'audio',
  5903. caption: (0,external_wp_i18n_namespaceObject.__)('Audio')
  5904. }, {
  5905. id: 'chat',
  5906. caption: (0,external_wp_i18n_namespaceObject.__)('Chat')
  5907. }, {
  5908. id: 'gallery',
  5909. caption: (0,external_wp_i18n_namespaceObject.__)('Gallery')
  5910. }, {
  5911. id: 'image',
  5912. caption: (0,external_wp_i18n_namespaceObject.__)('Image')
  5913. }, {
  5914. id: 'link',
  5915. caption: (0,external_wp_i18n_namespaceObject.__)('Link')
  5916. }, {
  5917. id: 'quote',
  5918. caption: (0,external_wp_i18n_namespaceObject.__)('Quote')
  5919. }, {
  5920. id: 'standard',
  5921. caption: (0,external_wp_i18n_namespaceObject.__)('Standard')
  5922. }, {
  5923. id: 'status',
  5924. caption: (0,external_wp_i18n_namespaceObject.__)('Status')
  5925. }, {
  5926. id: 'video',
  5927. caption: (0,external_wp_i18n_namespaceObject.__)('Video')
  5928. }].sort((a, b) => {
  5929. const normalizedA = a.caption.toUpperCase();
  5930. const normalizedB = b.caption.toUpperCase();
  5931. if (normalizedA < normalizedB) {
  5932. return -1;
  5933. }
  5934. if (normalizedA > normalizedB) {
  5935. return 1;
  5936. }
  5937. return 0;
  5938. });
  5939. function PostFormat() {
  5940. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostFormat);
  5941. const postFormatSelectorId = `post-format-selector-${instanceId}`;
  5942. const {
  5943. postFormat,
  5944. suggestedFormat,
  5945. supportedFormats
  5946. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  5947. const {
  5948. getEditedPostAttribute,
  5949. getSuggestedPostFormat
  5950. } = select(store_store);
  5951. const _postFormat = getEditedPostAttribute('format');
  5952. const themeSupports = select(external_wp_coreData_namespaceObject.store).getThemeSupports();
  5953. return {
  5954. postFormat: _postFormat !== null && _postFormat !== void 0 ? _postFormat : 'standard',
  5955. suggestedFormat: getSuggestedPostFormat(),
  5956. supportedFormats: themeSupports.formats
  5957. };
  5958. }, []);
  5959. const formats = POST_FORMATS.filter(format => {
  5960. // Ensure current format is always in the set.
  5961. // The current format may not be a format supported by the theme.
  5962. return (0,external_lodash_namespaceObject.includes)(supportedFormats, format.id) || postFormat === format.id;
  5963. });
  5964. const suggestion = (0,external_lodash_namespaceObject.find)(formats, format => format.id === suggestedFormat);
  5965. const {
  5966. editPost
  5967. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  5968. const onUpdatePostFormat = format => editPost({
  5969. format
  5970. });
  5971. return (0,external_wp_element_namespaceObject.createElement)(post_format_check, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  5972. className: "editor-post-format"
  5973. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  5974. className: "editor-post-format__content"
  5975. }, (0,external_wp_element_namespaceObject.createElement)("label", {
  5976. htmlFor: postFormatSelectorId
  5977. }, (0,external_wp_i18n_namespaceObject.__)('Post Format')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
  5978. value: postFormat,
  5979. onChange: format => onUpdatePostFormat(format),
  5980. id: postFormatSelectorId,
  5981. options: formats.map(format => ({
  5982. label: format.caption,
  5983. value: format.id
  5984. }))
  5985. })), suggestion && suggestion.id !== postFormat && (0,external_wp_element_namespaceObject.createElement)("div", {
  5986. className: "editor-post-format__suggestion"
  5987. }, (0,external_wp_i18n_namespaceObject.__)('Suggestion:'), ' ', (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  5988. variant: "link",
  5989. onClick: () => onUpdatePostFormat(suggestion.id)
  5990. }, (0,external_wp_i18n_namespaceObject.sprintf)(
  5991. /* translators: %s: post format */
  5992. (0,external_wp_i18n_namespaceObject.__)('Apply format: %s'), suggestion.caption)))));
  5993. }
  5994. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/backup.js
  5995. /**
  5996. * WordPress dependencies
  5997. */
  5998. const backup = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  5999. xmlns: "http://www.w3.org/2000/svg",
  6000. viewBox: "0 0 24 24"
  6001. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  6002. d: "M5.5 12h1.75l-2.5 3-2.5-3H4a8 8 0 113.134 6.35l.907-1.194A6.5 6.5 0 105.5 12zm9.53 1.97l-2.28-2.28V8.5a.75.75 0 00-1.5 0V12a.747.747 0 00.218.529l1.282-.84-1.28.842 2.5 2.5a.75.75 0 101.06-1.061z"
  6003. }));
  6004. /* harmony default export */ var library_backup = (backup);
  6005. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-last-revision/check.js
  6006. /**
  6007. * WordPress dependencies
  6008. */
  6009. /**
  6010. * Internal dependencies
  6011. */
  6012. function PostLastRevisionCheck(_ref) {
  6013. let {
  6014. lastRevisionId,
  6015. revisionsCount,
  6016. children
  6017. } = _ref;
  6018. if (!lastRevisionId || revisionsCount < 2) {
  6019. return null;
  6020. }
  6021. return (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, {
  6022. supportKeys: "revisions"
  6023. }, children);
  6024. }
  6025. /* harmony default export */ var post_last_revision_check = ((0,external_wp_data_namespaceObject.withSelect)(select => {
  6026. const {
  6027. getCurrentPostLastRevisionId,
  6028. getCurrentPostRevisionsCount
  6029. } = select(store_store);
  6030. return {
  6031. lastRevisionId: getCurrentPostLastRevisionId(),
  6032. revisionsCount: getCurrentPostRevisionsCount()
  6033. };
  6034. })(PostLastRevisionCheck));
  6035. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-last-revision/index.js
  6036. /**
  6037. * WordPress dependencies
  6038. */
  6039. /**
  6040. * Internal dependencies
  6041. */
  6042. function LastRevision(_ref) {
  6043. let {
  6044. lastRevisionId,
  6045. revisionsCount
  6046. } = _ref;
  6047. return (0,external_wp_element_namespaceObject.createElement)(post_last_revision_check, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  6048. href: (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
  6049. revision: lastRevisionId,
  6050. gutenberg: true
  6051. }),
  6052. className: "editor-post-last-revision__title",
  6053. icon: library_backup
  6054. }, (0,external_wp_i18n_namespaceObject.sprintf)(
  6055. /* translators: %d: number of revisions */
  6056. (0,external_wp_i18n_namespaceObject._n)('%d Revision', '%d Revisions', revisionsCount), revisionsCount)));
  6057. }
  6058. /* harmony default export */ var post_last_revision = ((0,external_wp_data_namespaceObject.withSelect)(select => {
  6059. const {
  6060. getCurrentPostLastRevisionId,
  6061. getCurrentPostRevisionsCount
  6062. } = select(store_store);
  6063. return {
  6064. lastRevisionId: getCurrentPostLastRevisionId(),
  6065. revisionsCount: getCurrentPostRevisionsCount()
  6066. };
  6067. })(LastRevision));
  6068. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-locked-modal/index.js
  6069. /**
  6070. * External dependencies
  6071. */
  6072. /**
  6073. * WordPress dependencies
  6074. */
  6075. /**
  6076. * Internal dependencies
  6077. */
  6078. function PostLockedModal() {
  6079. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostLockedModal);
  6080. const hookName = 'core/editor/post-locked-modal-' + instanceId;
  6081. const {
  6082. autosave,
  6083. updatePostLock
  6084. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  6085. const {
  6086. isLocked,
  6087. isTakeover,
  6088. user,
  6089. postId,
  6090. postLockUtils,
  6091. activePostLock,
  6092. postType,
  6093. previewLink
  6094. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  6095. const {
  6096. isPostLocked,
  6097. isPostLockTakeover,
  6098. getPostLockUser,
  6099. getCurrentPostId,
  6100. getActivePostLock,
  6101. getEditedPostAttribute,
  6102. getEditedPostPreviewLink,
  6103. getEditorSettings
  6104. } = select(store_store);
  6105. const {
  6106. getPostType
  6107. } = select(external_wp_coreData_namespaceObject.store);
  6108. return {
  6109. isLocked: isPostLocked(),
  6110. isTakeover: isPostLockTakeover(),
  6111. user: getPostLockUser(),
  6112. postId: getCurrentPostId(),
  6113. postLockUtils: getEditorSettings().postLockUtils,
  6114. activePostLock: getActivePostLock(),
  6115. postType: getPostType(getEditedPostAttribute('type')),
  6116. previewLink: getEditedPostPreviewLink()
  6117. };
  6118. }, []);
  6119. (0,external_wp_element_namespaceObject.useEffect)(() => {
  6120. /**
  6121. * Keep the lock refreshed.
  6122. *
  6123. * When the user does not send a heartbeat in a heartbeat-tick
  6124. * the user is no longer editing and another user can start editing.
  6125. *
  6126. * @param {Object} data Data to send in the heartbeat request.
  6127. */
  6128. function sendPostLock(data) {
  6129. if (isLocked) {
  6130. return;
  6131. }
  6132. data['wp-refresh-post-lock'] = {
  6133. lock: activePostLock,
  6134. post_id: postId
  6135. };
  6136. }
  6137. /**
  6138. * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing.
  6139. *
  6140. * @param {Object} data Data received in the heartbeat request
  6141. */
  6142. function receivePostLock(data) {
  6143. if (!data['wp-refresh-post-lock']) {
  6144. return;
  6145. }
  6146. const received = data['wp-refresh-post-lock'];
  6147. if (received.lock_error) {
  6148. // Auto save and display the takeover modal.
  6149. autosave();
  6150. updatePostLock({
  6151. isLocked: true,
  6152. isTakeover: true,
  6153. user: {
  6154. name: received.lock_error.name,
  6155. avatar: received.lock_error.avatar_src_2x
  6156. }
  6157. });
  6158. } else if (received.new_lock) {
  6159. updatePostLock({
  6160. isLocked: false,
  6161. activePostLock: received.new_lock
  6162. });
  6163. }
  6164. }
  6165. /**
  6166. * Unlock the post before the window is exited.
  6167. */
  6168. function releasePostLock() {
  6169. if (isLocked || !activePostLock) {
  6170. return;
  6171. }
  6172. const data = new window.FormData();
  6173. data.append('action', 'wp-remove-post-lock');
  6174. data.append('_wpnonce', postLockUtils.unlockNonce);
  6175. data.append('post_ID', postId);
  6176. data.append('active_post_lock', activePostLock);
  6177. if (window.navigator.sendBeacon) {
  6178. window.navigator.sendBeacon(postLockUtils.ajaxUrl, data);
  6179. } else {
  6180. const xhr = new window.XMLHttpRequest();
  6181. xhr.open('POST', postLockUtils.ajaxUrl, false);
  6182. xhr.send(data);
  6183. }
  6184. } // Details on these events on the Heartbeat API docs
  6185. // https://developer.wordpress.org/plugins/javascript/heartbeat-api/
  6186. (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.send', hookName, sendPostLock);
  6187. (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.tick', hookName, receivePostLock);
  6188. window.addEventListener('beforeunload', releasePostLock);
  6189. return () => {
  6190. (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.send', hookName);
  6191. (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.tick', hookName);
  6192. window.removeEventListener('beforeunload', releasePostLock);
  6193. };
  6194. }, []);
  6195. if (!isLocked) {
  6196. return null;
  6197. }
  6198. const userDisplayName = user.name;
  6199. const userAvatar = user.avatar;
  6200. const unlockUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('post.php', {
  6201. 'get-post-lock': '1',
  6202. lockKey: true,
  6203. post: postId,
  6204. action: 'edit',
  6205. _wpnonce: postLockUtils.nonce
  6206. });
  6207. const allPostsUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
  6208. post_type: (0,external_lodash_namespaceObject.get)(postType, ['slug'])
  6209. });
  6210. const allPostsLabel = (0,external_wp_i18n_namespaceObject.__)('Exit editor');
  6211. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
  6212. title: isTakeover ? (0,external_wp_i18n_namespaceObject.__)('Someone else has taken over this post') : (0,external_wp_i18n_namespaceObject.__)('This post is already being edited'),
  6213. focusOnMount: true,
  6214. shouldCloseOnClickOutside: false,
  6215. shouldCloseOnEsc: false,
  6216. isDismissible: false,
  6217. className: "editor-post-locked-modal"
  6218. }, !!userAvatar && (0,external_wp_element_namespaceObject.createElement)("img", {
  6219. src: userAvatar,
  6220. alt: (0,external_wp_i18n_namespaceObject.__)('Avatar'),
  6221. className: "editor-post-locked-modal__avatar",
  6222. width: 64,
  6223. height: 64
  6224. }), (0,external_wp_element_namespaceObject.createElement)("div", null, !!isTakeover && (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)(
  6225. /* translators: %s: user's display name */
  6226. (0,external_wp_i18n_namespaceObject.__)('<strong>%s</strong> now has editing control of this posts (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'), userDisplayName) : (0,external_wp_i18n_namespaceObject.__)('Another user now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'), {
  6227. strong: (0,external_wp_element_namespaceObject.createElement)("strong", null),
  6228. PreviewLink: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
  6229. href: previewLink
  6230. }, (0,external_wp_i18n_namespaceObject.__)('preview'))
  6231. })), !isTakeover && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)(
  6232. /* translators: %s: user's display name */
  6233. (0,external_wp_i18n_namespaceObject.__)('<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'), userDisplayName) : (0,external_wp_i18n_namespaceObject.__)('Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'), {
  6234. strong: (0,external_wp_element_namespaceObject.createElement)("strong", null),
  6235. PreviewLink: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
  6236. href: previewLink
  6237. }, (0,external_wp_i18n_namespaceObject.__)('preview'))
  6238. })), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('If you take over, the other user will lose editing control to the post, but their changes will be saved.'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
  6239. className: "editor-post-locked-modal__buttons",
  6240. justify: "flex-end",
  6241. expanded: false
  6242. }, !isTakeover && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  6243. variant: "tertiary",
  6244. href: unlockUrl
  6245. }, (0,external_wp_i18n_namespaceObject.__)('Take over'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  6246. variant: "primary",
  6247. href: allPostsUrl
  6248. }, allPostsLabel)))));
  6249. }
  6250. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-pending-status/check.js
  6251. /**
  6252. * External dependencies
  6253. */
  6254. /**
  6255. * WordPress dependencies
  6256. */
  6257. /**
  6258. * Internal dependencies
  6259. */
  6260. function PostPendingStatusCheck(_ref) {
  6261. let {
  6262. hasPublishAction,
  6263. isPublished,
  6264. children
  6265. } = _ref;
  6266. if (isPublished || !hasPublishAction) {
  6267. return null;
  6268. }
  6269. return children;
  6270. }
  6271. /* harmony default export */ var post_pending_status_check = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => {
  6272. const {
  6273. isCurrentPostPublished,
  6274. getCurrentPostType,
  6275. getCurrentPost
  6276. } = select(store_store);
  6277. return {
  6278. hasPublishAction: (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
  6279. isPublished: isCurrentPostPublished(),
  6280. postType: getCurrentPostType()
  6281. };
  6282. }))(PostPendingStatusCheck));
  6283. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-pending-status/index.js
  6284. /**
  6285. * WordPress dependencies
  6286. */
  6287. /**
  6288. * Internal dependencies
  6289. */
  6290. function PostPendingStatus(_ref) {
  6291. let {
  6292. status,
  6293. onUpdateStatus
  6294. } = _ref;
  6295. const togglePendingStatus = () => {
  6296. const updatedStatus = status === 'pending' ? 'draft' : 'pending';
  6297. onUpdateStatus(updatedStatus);
  6298. };
  6299. return (0,external_wp_element_namespaceObject.createElement)(post_pending_status_check, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
  6300. label: (0,external_wp_i18n_namespaceObject.__)('Pending review'),
  6301. checked: status === 'pending',
  6302. onChange: togglePendingStatus
  6303. }));
  6304. }
  6305. /* harmony default export */ var post_pending_status = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => ({
  6306. status: select(store_store).getEditedPostAttribute('status')
  6307. })), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
  6308. onUpdateStatus(status) {
  6309. dispatch(store_store).editPost({
  6310. status
  6311. });
  6312. }
  6313. })))(PostPendingStatus));
  6314. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-pingbacks/index.js
  6315. /**
  6316. * WordPress dependencies
  6317. */
  6318. /**
  6319. * Internal dependencies
  6320. */
  6321. function PostPingbacks(_ref) {
  6322. let {
  6323. pingStatus = 'open',
  6324. ...props
  6325. } = _ref;
  6326. const onTogglePingback = () => props.editPost({
  6327. ping_status: pingStatus === 'open' ? 'closed' : 'open'
  6328. });
  6329. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
  6330. label: (0,external_wp_i18n_namespaceObject.__)('Allow pingbacks & trackbacks'),
  6331. checked: pingStatus === 'open',
  6332. onChange: onTogglePingback
  6333. });
  6334. }
  6335. /* harmony default export */ var post_pingbacks = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
  6336. return {
  6337. pingStatus: select(store_store).getEditedPostAttribute('ping_status')
  6338. };
  6339. }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
  6340. editPost: dispatch(store_store).editPost
  6341. }))])(PostPingbacks));
  6342. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-preview-button/index.js
  6343. /**
  6344. * External dependencies
  6345. */
  6346. /**
  6347. * WordPress dependencies
  6348. */
  6349. /**
  6350. * Internal dependencies
  6351. */
  6352. function writeInterstitialMessage(targetDocument) {
  6353. let markup = (0,external_wp_element_namespaceObject.renderToString)((0,external_wp_element_namespaceObject.createElement)("div", {
  6354. className: "editor-post-preview-button__interstitial-message"
  6355. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  6356. xmlns: "http://www.w3.org/2000/svg",
  6357. viewBox: "0 0 96 96"
  6358. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  6359. className: "outer",
  6360. d: "M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36",
  6361. fill: "none"
  6362. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  6363. className: "inner",
  6364. d: "M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z",
  6365. fill: "none"
  6366. })), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Generating preview…'))));
  6367. markup += `
  6368. <style>
  6369. body {
  6370. margin: 0;
  6371. }
  6372. .editor-post-preview-button__interstitial-message {
  6373. display: flex;
  6374. flex-direction: column;
  6375. align-items: center;
  6376. justify-content: center;
  6377. height: 100vh;
  6378. width: 100vw;
  6379. }
  6380. @-webkit-keyframes paint {
  6381. 0% {
  6382. stroke-dashoffset: 0;
  6383. }
  6384. }
  6385. @-moz-keyframes paint {
  6386. 0% {
  6387. stroke-dashoffset: 0;
  6388. }
  6389. }
  6390. @-o-keyframes paint {
  6391. 0% {
  6392. stroke-dashoffset: 0;
  6393. }
  6394. }
  6395. @keyframes paint {
  6396. 0% {
  6397. stroke-dashoffset: 0;
  6398. }
  6399. }
  6400. .editor-post-preview-button__interstitial-message svg {
  6401. width: 192px;
  6402. height: 192px;
  6403. stroke: #555d66;
  6404. stroke-width: 0.75;
  6405. }
  6406. .editor-post-preview-button__interstitial-message svg .outer,
  6407. .editor-post-preview-button__interstitial-message svg .inner {
  6408. stroke-dasharray: 280;
  6409. stroke-dashoffset: 280;
  6410. -webkit-animation: paint 1.5s ease infinite alternate;
  6411. -moz-animation: paint 1.5s ease infinite alternate;
  6412. -o-animation: paint 1.5s ease infinite alternate;
  6413. animation: paint 1.5s ease infinite alternate;
  6414. }
  6415. p {
  6416. text-align: center;
  6417. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  6418. }
  6419. </style>
  6420. `;
  6421. /**
  6422. * Filters the interstitial message shown when generating previews.
  6423. *
  6424. * @param {string} markup The preview interstitial markup.
  6425. */
  6426. markup = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostPreview.interstitialMarkup', markup);
  6427. targetDocument.write(markup);
  6428. targetDocument.title = (0,external_wp_i18n_namespaceObject.__)('Generating preview…');
  6429. targetDocument.close();
  6430. }
  6431. class PostPreviewButton extends external_wp_element_namespaceObject.Component {
  6432. constructor() {
  6433. super(...arguments);
  6434. this.buttonRef = (0,external_wp_element_namespaceObject.createRef)();
  6435. this.openPreviewWindow = this.openPreviewWindow.bind(this);
  6436. }
  6437. componentDidUpdate(prevProps) {
  6438. const {
  6439. previewLink
  6440. } = this.props; // This relies on the window being responsible to unset itself when
  6441. // navigation occurs or a new preview window is opened, to avoid
  6442. // unintentional forceful redirects.
  6443. if (previewLink && !prevProps.previewLink) {
  6444. this.setPreviewWindowLink(previewLink);
  6445. }
  6446. }
  6447. /**
  6448. * Sets the preview window's location to the given URL, if a preview window
  6449. * exists and is not closed.
  6450. *
  6451. * @param {string} url URL to assign as preview window location.
  6452. */
  6453. setPreviewWindowLink(url) {
  6454. const {
  6455. previewWindow
  6456. } = this;
  6457. if (previewWindow && !previewWindow.closed) {
  6458. previewWindow.location = url;
  6459. if (this.buttonRef.current) {
  6460. this.buttonRef.current.focus();
  6461. }
  6462. }
  6463. }
  6464. getWindowTarget() {
  6465. const {
  6466. postId
  6467. } = this.props;
  6468. return `wp-preview-${postId}`;
  6469. }
  6470. openPreviewWindow(event) {
  6471. // Our Preview button has its 'href' and 'target' set correctly for a11y
  6472. // purposes. Unfortunately, though, we can't rely on the default 'click'
  6473. // handler since sometimes it incorrectly opens a new tab instead of reusing
  6474. // the existing one.
  6475. // https://github.com/WordPress/gutenberg/pull/8330
  6476. event.preventDefault(); // Open up a Preview tab if needed. This is where we'll show the preview.
  6477. if (!this.previewWindow || this.previewWindow.closed) {
  6478. this.previewWindow = window.open('', this.getWindowTarget());
  6479. } // Focus the Preview tab. This might not do anything, depending on the browser's
  6480. // and user's preferences.
  6481. // https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus
  6482. this.previewWindow.focus();
  6483. if ( // If we don't need to autosave the post before previewing, then we simply
  6484. // load the Preview URL in the Preview tab.
  6485. !this.props.isAutosaveable || // Do not save or overwrite the post, if the post is already locked.
  6486. this.props.isPostLocked) {
  6487. this.setPreviewWindowLink(event.target.href);
  6488. return;
  6489. } // Request an autosave. This happens asynchronously and causes the component
  6490. // to update when finished.
  6491. if (this.props.isDraft) {
  6492. this.props.savePost({
  6493. isPreview: true
  6494. });
  6495. } else {
  6496. this.props.autosave({
  6497. isPreview: true
  6498. });
  6499. } // Display a 'Generating preview' message in the Preview tab while we wait for the
  6500. // autosave to finish.
  6501. writeInterstitialMessage(this.previewWindow.document);
  6502. }
  6503. render() {
  6504. const {
  6505. previewLink,
  6506. currentPostLink,
  6507. isSaveable,
  6508. role
  6509. } = this.props; // Link to the `?preview=true` URL if we have it, since this lets us see
  6510. // changes that were autosaved since the post was last published. Otherwise,
  6511. // just link to the post's URL.
  6512. const href = previewLink || currentPostLink;
  6513. const classNames = classnames_default()({
  6514. 'editor-post-preview': !this.props.className
  6515. }, this.props.className);
  6516. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  6517. variant: !this.props.className ? 'tertiary' : undefined,
  6518. className: classNames,
  6519. href: href,
  6520. target: this.getWindowTarget(),
  6521. disabled: !isSaveable,
  6522. onClick: this.openPreviewWindow,
  6523. ref: this.buttonRef,
  6524. role: role
  6525. }, this.props.textContent ? this.props.textContent : (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject._x)('Preview', 'imperative verb'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  6526. as: "span"
  6527. },
  6528. /* translators: accessibility text */
  6529. (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)'))));
  6530. }
  6531. }
  6532. /* harmony default export */ var post_preview_button = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, _ref) => {
  6533. let {
  6534. forcePreviewLink,
  6535. forceIsAutosaveable
  6536. } = _ref;
  6537. const {
  6538. getCurrentPostId,
  6539. getCurrentPostAttribute,
  6540. getEditedPostAttribute,
  6541. isEditedPostSaveable,
  6542. isEditedPostAutosaveable,
  6543. getEditedPostPreviewLink,
  6544. isPostLocked
  6545. } = select(store_store);
  6546. const {
  6547. getPostType
  6548. } = select(external_wp_coreData_namespaceObject.store);
  6549. const previewLink = getEditedPostPreviewLink();
  6550. const postType = getPostType(getEditedPostAttribute('type'));
  6551. return {
  6552. postId: getCurrentPostId(),
  6553. currentPostLink: getCurrentPostAttribute('link'),
  6554. previewLink: forcePreviewLink !== undefined ? forcePreviewLink : previewLink,
  6555. isSaveable: isEditedPostSaveable(),
  6556. isAutosaveable: forceIsAutosaveable || isEditedPostAutosaveable(),
  6557. isViewable: (0,external_lodash_namespaceObject.get)(postType, ['viewable'], false),
  6558. isDraft: ['draft', 'auto-draft'].indexOf(getEditedPostAttribute('status')) !== -1,
  6559. isPostLocked: isPostLocked()
  6560. };
  6561. }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
  6562. autosave: dispatch(store_store).autosave,
  6563. savePost: dispatch(store_store).savePost
  6564. })), (0,external_wp_compose_namespaceObject.ifCondition)(_ref2 => {
  6565. let {
  6566. isViewable
  6567. } = _ref2;
  6568. return isViewable;
  6569. })])(PostPreviewButton));
  6570. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-button/label.js
  6571. /**
  6572. * External dependencies
  6573. */
  6574. /**
  6575. * WordPress dependencies
  6576. */
  6577. /**
  6578. * Internal dependencies
  6579. */
  6580. function PublishButtonLabel(_ref) {
  6581. let {
  6582. isPublished,
  6583. isBeingScheduled,
  6584. isSaving,
  6585. isPublishing,
  6586. hasPublishAction,
  6587. isAutosaving,
  6588. hasNonPostEntityChanges
  6589. } = _ref;
  6590. if (isPublishing) {
  6591. /* translators: button label text should, if possible, be under 16 characters. */
  6592. return (0,external_wp_i18n_namespaceObject.__)('Publishing…');
  6593. } else if (isPublished && isSaving && !isAutosaving) {
  6594. /* translators: button label text should, if possible, be under 16 characters. */
  6595. return (0,external_wp_i18n_namespaceObject.__)('Updating…');
  6596. } else if (isBeingScheduled && isSaving && !isAutosaving) {
  6597. /* translators: button label text should, if possible, be under 16 characters. */
  6598. return (0,external_wp_i18n_namespaceObject.__)('Scheduling…');
  6599. }
  6600. if (!hasPublishAction) {
  6601. return hasNonPostEntityChanges ? (0,external_wp_i18n_namespaceObject.__)('Submit for Review…') : (0,external_wp_i18n_namespaceObject.__)('Submit for Review');
  6602. } else if (isPublished) {
  6603. return hasNonPostEntityChanges ? (0,external_wp_i18n_namespaceObject.__)('Update…') : (0,external_wp_i18n_namespaceObject.__)('Update');
  6604. } else if (isBeingScheduled) {
  6605. return hasNonPostEntityChanges ? (0,external_wp_i18n_namespaceObject.__)('Schedule…') : (0,external_wp_i18n_namespaceObject.__)('Schedule');
  6606. }
  6607. return (0,external_wp_i18n_namespaceObject.__)('Publish');
  6608. }
  6609. /* harmony default export */ var label = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, _ref2) => {
  6610. let {
  6611. forceIsSaving
  6612. } = _ref2;
  6613. const {
  6614. isCurrentPostPublished,
  6615. isEditedPostBeingScheduled,
  6616. isSavingPost,
  6617. isPublishingPost,
  6618. getCurrentPost,
  6619. getCurrentPostType,
  6620. isAutosavingPost
  6621. } = select(store_store);
  6622. return {
  6623. isPublished: isCurrentPostPublished(),
  6624. isBeingScheduled: isEditedPostBeingScheduled(),
  6625. isSaving: forceIsSaving || isSavingPost(),
  6626. isPublishing: isPublishingPost(),
  6627. hasPublishAction: (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
  6628. postType: getCurrentPostType(),
  6629. isAutosaving: isAutosavingPost()
  6630. };
  6631. })])(PublishButtonLabel));
  6632. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-button/index.js
  6633. /**
  6634. * External dependencies
  6635. */
  6636. /**
  6637. * WordPress dependencies
  6638. */
  6639. /**
  6640. * Internal dependencies
  6641. */
  6642. class PostPublishButton extends external_wp_element_namespaceObject.Component {
  6643. constructor(props) {
  6644. super(props);
  6645. this.buttonNode = (0,external_wp_element_namespaceObject.createRef)();
  6646. this.createOnClick = this.createOnClick.bind(this);
  6647. this.closeEntitiesSavedStates = this.closeEntitiesSavedStates.bind(this);
  6648. this.state = {
  6649. entitiesSavedStatesCallback: false
  6650. };
  6651. }
  6652. componentDidMount() {
  6653. if (this.props.focusOnMount) {
  6654. this.buttonNode.current.focus();
  6655. }
  6656. }
  6657. createOnClick(callback) {
  6658. var _this = this;
  6659. return function () {
  6660. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  6661. args[_key] = arguments[_key];
  6662. }
  6663. const {
  6664. hasNonPostEntityChanges,
  6665. setEntitiesSavedStatesCallback
  6666. } = _this.props; // If a post with non-post entities is published, but the user
  6667. // elects to not save changes to the non-post entities, those
  6668. // entities will still be dirty when the Publish button is clicked.
  6669. // We also need to check that the `setEntitiesSavedStatesCallback`
  6670. // prop was passed. See https://github.com/WordPress/gutenberg/pull/37383
  6671. if (hasNonPostEntityChanges && setEntitiesSavedStatesCallback) {
  6672. // The modal for multiple entity saving will open,
  6673. // hold the callback for saving/publishing the post
  6674. // so that we can call it if the post entity is checked.
  6675. _this.setState({
  6676. entitiesSavedStatesCallback: () => callback(...args)
  6677. }); // Open the save panel by setting its callback.
  6678. // To set a function on the useState hook, we must set it
  6679. // with another function (() => myFunction). Passing the
  6680. // function on its own will cause an error when called.
  6681. setEntitiesSavedStatesCallback(() => _this.closeEntitiesSavedStates);
  6682. return external_lodash_namespaceObject.noop;
  6683. }
  6684. return callback(...args);
  6685. };
  6686. }
  6687. closeEntitiesSavedStates(savedEntities) {
  6688. const {
  6689. postType,
  6690. postId
  6691. } = this.props;
  6692. const {
  6693. entitiesSavedStatesCallback
  6694. } = this.state;
  6695. this.setState({
  6696. entitiesSavedStatesCallback: false
  6697. }, () => {
  6698. if (savedEntities && (0,external_lodash_namespaceObject.some)(savedEntities, elt => elt.kind === 'postType' && elt.name === postType && elt.key === postId)) {
  6699. // The post entity was checked, call the held callback from `createOnClick`.
  6700. entitiesSavedStatesCallback();
  6701. }
  6702. });
  6703. }
  6704. render() {
  6705. const {
  6706. forceIsDirty,
  6707. forceIsSaving,
  6708. hasPublishAction,
  6709. isBeingScheduled,
  6710. isOpen,
  6711. isPostSavingLocked,
  6712. isPublishable,
  6713. isPublished,
  6714. isSaveable,
  6715. isSaving,
  6716. isAutoSaving,
  6717. isToggle,
  6718. onSave,
  6719. onStatusChange,
  6720. onSubmit = external_lodash_namespaceObject.noop,
  6721. onToggle,
  6722. visibility,
  6723. hasNonPostEntityChanges,
  6724. isSavingNonPostEntityChanges
  6725. } = this.props;
  6726. const isButtonDisabled = (isSaving || forceIsSaving || !isSaveable || isPostSavingLocked || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
  6727. const isToggleDisabled = (isPublished || isSaving || forceIsSaving || !isSaveable || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
  6728. let publishStatus;
  6729. if (!hasPublishAction) {
  6730. publishStatus = 'pending';
  6731. } else if (visibility === 'private') {
  6732. publishStatus = 'private';
  6733. } else if (isBeingScheduled) {
  6734. publishStatus = 'future';
  6735. } else {
  6736. publishStatus = 'publish';
  6737. }
  6738. const onClickButton = () => {
  6739. if (isButtonDisabled) {
  6740. return;
  6741. }
  6742. onSubmit();
  6743. onStatusChange(publishStatus);
  6744. onSave();
  6745. };
  6746. const onClickToggle = () => {
  6747. if (isToggleDisabled) {
  6748. return;
  6749. }
  6750. onToggle();
  6751. };
  6752. const buttonProps = {
  6753. 'aria-disabled': isButtonDisabled,
  6754. className: 'editor-post-publish-button',
  6755. isBusy: !isAutoSaving && isSaving && isPublished,
  6756. variant: 'primary',
  6757. onClick: this.createOnClick(onClickButton)
  6758. };
  6759. const toggleProps = {
  6760. 'aria-disabled': isToggleDisabled,
  6761. 'aria-expanded': isOpen,
  6762. className: 'editor-post-publish-panel__toggle',
  6763. isBusy: isSaving && isPublished,
  6764. variant: 'primary',
  6765. onClick: this.createOnClick(onClickToggle)
  6766. };
  6767. const toggleChildren = isBeingScheduled ? (0,external_wp_i18n_namespaceObject.__)('Schedule…') : (0,external_wp_i18n_namespaceObject.__)('Publish');
  6768. const buttonChildren = (0,external_wp_element_namespaceObject.createElement)(label, {
  6769. forceIsSaving: forceIsSaving,
  6770. hasNonPostEntityChanges: hasNonPostEntityChanges
  6771. });
  6772. const componentProps = isToggle ? toggleProps : buttonProps;
  6773. const componentChildren = isToggle ? toggleChildren : buttonChildren;
  6774. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
  6775. ref: this.buttonNode
  6776. }, componentProps, {
  6777. className: classnames_default()(componentProps.className, 'editor-post-publish-button__button', {
  6778. 'has-changes-dot': hasNonPostEntityChanges
  6779. })
  6780. }), componentChildren));
  6781. }
  6782. }
  6783. /* harmony default export */ var post_publish_button = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
  6784. const {
  6785. isSavingPost,
  6786. isAutosavingPost,
  6787. isEditedPostBeingScheduled,
  6788. getEditedPostVisibility,
  6789. isCurrentPostPublished,
  6790. isEditedPostSaveable,
  6791. isEditedPostPublishable,
  6792. isPostSavingLocked,
  6793. getCurrentPost,
  6794. getCurrentPostType,
  6795. getCurrentPostId,
  6796. hasNonPostEntityChanges,
  6797. isSavingNonPostEntityChanges
  6798. } = select(store_store);
  6799. const _isAutoSaving = isAutosavingPost();
  6800. return {
  6801. isSaving: isSavingPost() || _isAutoSaving,
  6802. isAutoSaving: _isAutoSaving,
  6803. isBeingScheduled: isEditedPostBeingScheduled(),
  6804. visibility: getEditedPostVisibility(),
  6805. isSaveable: isEditedPostSaveable(),
  6806. isPostSavingLocked: isPostSavingLocked(),
  6807. isPublishable: isEditedPostPublishable(),
  6808. isPublished: isCurrentPostPublished(),
  6809. hasPublishAction: (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
  6810. postType: getCurrentPostType(),
  6811. postId: getCurrentPostId(),
  6812. hasNonPostEntityChanges: hasNonPostEntityChanges(),
  6813. isSavingNonPostEntityChanges: isSavingNonPostEntityChanges()
  6814. };
  6815. }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
  6816. const {
  6817. editPost,
  6818. savePost
  6819. } = dispatch(store_store);
  6820. return {
  6821. onStatusChange: status => editPost({
  6822. status
  6823. }, {
  6824. undoIgnore: true
  6825. }),
  6826. onSave: savePost
  6827. };
  6828. })])(PostPublishButton));
  6829. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close-small.js
  6830. /**
  6831. * WordPress dependencies
  6832. */
  6833. const closeSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  6834. xmlns: "http://www.w3.org/2000/svg",
  6835. viewBox: "0 0 24 24"
  6836. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  6837. 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"
  6838. }));
  6839. /* harmony default export */ var close_small = (closeSmall);
  6840. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/wordpress.js
  6841. /**
  6842. * WordPress dependencies
  6843. */
  6844. const wordpress = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  6845. xmlns: "http://www.w3.org/2000/svg",
  6846. viewBox: "-2 -2 24 24"
  6847. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  6848. d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z"
  6849. }));
  6850. /* harmony default export */ var library_wordpress = (wordpress);
  6851. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
  6852. function _defineProperty(obj, key, value) {
  6853. if (key in obj) {
  6854. Object.defineProperty(obj, key, {
  6855. value: value,
  6856. enumerable: true,
  6857. configurable: true,
  6858. writable: true
  6859. });
  6860. } else {
  6861. obj[key] = value;
  6862. }
  6863. return obj;
  6864. }
  6865. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/utils.js
  6866. /**
  6867. * WordPress dependencies
  6868. */
  6869. const visibilityOptions = [{
  6870. value: 'public',
  6871. label: (0,external_wp_i18n_namespaceObject.__)('Public'),
  6872. info: (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.')
  6873. }, {
  6874. value: 'private',
  6875. label: (0,external_wp_i18n_namespaceObject.__)('Private'),
  6876. info: (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.')
  6877. }, {
  6878. value: 'password',
  6879. label: (0,external_wp_i18n_namespaceObject.__)('Password Protected'),
  6880. info: (0,external_wp_i18n_namespaceObject.__)('Protected with a password you choose. Only those with the password can view this post.')
  6881. }];
  6882. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/index.js
  6883. /**
  6884. * WordPress dependencies
  6885. */
  6886. /**
  6887. * Internal dependencies
  6888. */
  6889. class PostVisibility extends external_wp_element_namespaceObject.Component {
  6890. constructor(props) {
  6891. super(...arguments);
  6892. _defineProperty(this, "confirmPrivate", () => {
  6893. const {
  6894. onUpdateVisibility,
  6895. onSave
  6896. } = this.props;
  6897. onUpdateVisibility('private');
  6898. this.setState({
  6899. hasPassword: false,
  6900. showPrivateConfirmDialog: false
  6901. });
  6902. onSave();
  6903. });
  6904. _defineProperty(this, "handleDialogCancel", () => {
  6905. this.setState({
  6906. showPrivateConfirmDialog: false
  6907. });
  6908. });
  6909. this.setPublic = this.setPublic.bind(this);
  6910. this.setPrivate = this.setPrivate.bind(this);
  6911. this.setPasswordProtected = this.setPasswordProtected.bind(this);
  6912. this.updatePassword = this.updatePassword.bind(this);
  6913. this.state = {
  6914. hasPassword: !!props.password,
  6915. showPrivateConfirmDialog: false
  6916. };
  6917. }
  6918. setPublic() {
  6919. const {
  6920. visibility,
  6921. onUpdateVisibility,
  6922. status
  6923. } = this.props;
  6924. onUpdateVisibility(visibility === 'private' ? 'draft' : status);
  6925. this.setState({
  6926. hasPassword: false
  6927. });
  6928. }
  6929. setPrivate() {
  6930. this.setState({
  6931. showPrivateConfirmDialog: true
  6932. });
  6933. }
  6934. setPasswordProtected() {
  6935. const {
  6936. visibility,
  6937. onUpdateVisibility,
  6938. status,
  6939. password
  6940. } = this.props;
  6941. onUpdateVisibility(visibility === 'private' ? 'draft' : status, password || '');
  6942. this.setState({
  6943. hasPassword: true
  6944. });
  6945. }
  6946. updatePassword(event) {
  6947. const {
  6948. status,
  6949. onUpdateVisibility
  6950. } = this.props;
  6951. onUpdateVisibility(status, event.target.value);
  6952. }
  6953. render() {
  6954. const {
  6955. visibility,
  6956. password,
  6957. instanceId
  6958. } = this.props;
  6959. const visibilityHandlers = {
  6960. public: {
  6961. onSelect: this.setPublic,
  6962. checked: visibility === 'public' && !this.state.hasPassword
  6963. },
  6964. private: {
  6965. onSelect: this.setPrivate,
  6966. checked: visibility === 'private'
  6967. },
  6968. password: {
  6969. onSelect: this.setPasswordProtected,
  6970. checked: this.state.hasPassword
  6971. }
  6972. };
  6973. return [(0,external_wp_element_namespaceObject.createElement)("fieldset", {
  6974. key: "visibility-selector",
  6975. className: "editor-post-visibility__dialog-fieldset"
  6976. }, (0,external_wp_element_namespaceObject.createElement)("legend", {
  6977. className: "editor-post-visibility__dialog-legend"
  6978. }, (0,external_wp_i18n_namespaceObject.__)('Post Visibility')), visibilityOptions.map(_ref => {
  6979. let {
  6980. value,
  6981. label,
  6982. info
  6983. } = _ref;
  6984. return (0,external_wp_element_namespaceObject.createElement)("div", {
  6985. key: value,
  6986. className: "editor-post-visibility__choice"
  6987. }, (0,external_wp_element_namespaceObject.createElement)("input", {
  6988. type: "radio",
  6989. name: `editor-post-visibility__setting-${instanceId}`,
  6990. value: value,
  6991. onChange: visibilityHandlers[value].onSelect,
  6992. checked: visibilityHandlers[value].checked,
  6993. id: `editor-post-${value}-${instanceId}`,
  6994. "aria-describedby": `editor-post-${value}-${instanceId}-description`,
  6995. className: "editor-post-visibility__dialog-radio"
  6996. }), (0,external_wp_element_namespaceObject.createElement)("label", {
  6997. htmlFor: `editor-post-${value}-${instanceId}`,
  6998. className: "editor-post-visibility__dialog-label"
  6999. }, label), (0,external_wp_element_namespaceObject.createElement)("p", {
  7000. id: `editor-post-${value}-${instanceId}-description`,
  7001. className: "editor-post-visibility__dialog-info"
  7002. }, info));
  7003. })), this.state.hasPassword && (0,external_wp_element_namespaceObject.createElement)("div", {
  7004. className: "editor-post-visibility__dialog-password",
  7005. key: "password-selector"
  7006. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  7007. as: "label",
  7008. htmlFor: `editor-post-visibility__dialog-password-input-${instanceId}`
  7009. }, (0,external_wp_i18n_namespaceObject.__)('Create password')), (0,external_wp_element_namespaceObject.createElement)("input", {
  7010. className: "editor-post-visibility__dialog-password-input",
  7011. id: `editor-post-visibility__dialog-password-input-${instanceId}`,
  7012. type: "text",
  7013. onChange: this.updatePassword,
  7014. value: password,
  7015. placeholder: (0,external_wp_i18n_namespaceObject.__)('Use a secure password')
  7016. })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
  7017. key: "private-publish-confirmation",
  7018. isOpen: this.state.showPrivateConfirmDialog,
  7019. onConfirm: this.confirmPrivate,
  7020. onCancel: this.handleDialogCancel
  7021. }, (0,external_wp_i18n_namespaceObject.__)('Would you like to privately publish this post now?'))];
  7022. }
  7023. }
  7024. /* harmony default export */ var post_visibility = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
  7025. const {
  7026. getEditedPostAttribute,
  7027. getEditedPostVisibility
  7028. } = select(store_store);
  7029. return {
  7030. status: getEditedPostAttribute('status'),
  7031. visibility: getEditedPostVisibility(),
  7032. password: getEditedPostAttribute('password')
  7033. };
  7034. }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
  7035. const {
  7036. savePost,
  7037. editPost
  7038. } = dispatch(store_store);
  7039. return {
  7040. onSave: savePost,
  7041. onUpdateVisibility(status) {
  7042. let password = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  7043. editPost({
  7044. status,
  7045. password
  7046. });
  7047. }
  7048. };
  7049. }), external_wp_compose_namespaceObject.withInstanceId])(PostVisibility));
  7050. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/label.js
  7051. /**
  7052. * External dependencies
  7053. */
  7054. /**
  7055. * WordPress dependencies
  7056. */
  7057. /**
  7058. * Internal dependencies
  7059. */
  7060. function PostVisibilityLabel(_ref) {
  7061. let {
  7062. visibility
  7063. } = _ref;
  7064. const getVisibilityLabel = () => (0,external_lodash_namespaceObject.find)(visibilityOptions, {
  7065. value: visibility
  7066. }).label;
  7067. return getVisibilityLabel(visibility);
  7068. }
  7069. /* harmony default export */ var post_visibility_label = ((0,external_wp_data_namespaceObject.withSelect)(select => ({
  7070. visibility: select(store_store).getEditedPostVisibility()
  7071. }))(PostVisibilityLabel));
  7072. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-schedule/index.js
  7073. /**
  7074. * WordPress dependencies
  7075. */
  7076. /**
  7077. * Internal dependencies
  7078. */
  7079. function getDayOfTheMonth() {
  7080. let date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
  7081. let firstDay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  7082. const d = new Date(date);
  7083. return new Date(d.getFullYear(), d.getMonth() + (firstDay ? 0 : 1), firstDay ? 1 : 0).toISOString();
  7084. }
  7085. function PostSchedule() {
  7086. const {
  7087. postDate,
  7088. postType
  7089. } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
  7090. postDate: select(store_store).getEditedPostAttribute('date'),
  7091. postType: select(store_store).getCurrentPostType()
  7092. }), []);
  7093. const {
  7094. editPost
  7095. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  7096. const onUpdateDate = date => editPost({
  7097. date
  7098. });
  7099. const [previewedMonth, setPreviewedMonth] = (0,external_wp_element_namespaceObject.useState)(getDayOfTheMonth(postDate)); // Pick up published and schduled site posts.
  7100. const eventsByPostType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', postType, {
  7101. status: 'publish,future',
  7102. after: getDayOfTheMonth(previewedMonth),
  7103. before: getDayOfTheMonth(previewedMonth, false),
  7104. exclude: [select(store_store).getCurrentPostId()]
  7105. }), [previewedMonth, postType]);
  7106. const events = (0,external_wp_element_namespaceObject.useMemo)(() => (eventsByPostType || []).map(_ref => {
  7107. let {
  7108. title,
  7109. type,
  7110. date: eventDate
  7111. } = _ref;
  7112. return {
  7113. title: title === null || title === void 0 ? void 0 : title.rendered,
  7114. type,
  7115. date: new Date(eventDate)
  7116. };
  7117. }), [eventsByPostType]);
  7118. const ref = (0,external_wp_element_namespaceObject.useRef)();
  7119. const settings = (0,external_wp_date_namespaceObject.__experimentalGetSettings)(); // To know if the current timezone is a 12 hour time with look for "a" in the time format
  7120. // We also make sure this a is not escaped by a "/"
  7121. const is12HourTime = /a(?!\\)/i.test(settings.formats.time.toLowerCase() // Test only the lower case a.
  7122. .replace(/\\\\/g, '') // Replace "//" with empty strings.
  7123. .split('').reverse().join('') // Reverse the string and test for "a" not followed by a slash.
  7124. );
  7125. function onChange(newDate) {
  7126. onUpdateDate(newDate);
  7127. const {
  7128. ownerDocument
  7129. } = ref.current;
  7130. ownerDocument.activeElement.blur();
  7131. }
  7132. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DateTimePicker, {
  7133. ref: ref,
  7134. currentDate: postDate,
  7135. onChange: onChange,
  7136. is12Hour: is12HourTime,
  7137. events: events,
  7138. onMonthPreviewed: setPreviewedMonth
  7139. });
  7140. }
  7141. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-schedule/label.js
  7142. /**
  7143. * WordPress dependencies
  7144. */
  7145. /**
  7146. * Internal dependencies
  7147. */
  7148. function PostScheduleLabel(_ref) {
  7149. let {
  7150. date,
  7151. isFloating
  7152. } = _ref;
  7153. const settings = (0,external_wp_date_namespaceObject.__experimentalGetSettings)();
  7154. return date && !isFloating ? (0,external_wp_date_namespaceObject.format)(`${settings.formats.date} ${settings.formats.time}`, date) : (0,external_wp_i18n_namespaceObject.__)('Immediately');
  7155. }
  7156. /* harmony default export */ var post_schedule_label = ((0,external_wp_data_namespaceObject.withSelect)(select => {
  7157. return {
  7158. date: select(store_store).getEditedPostAttribute('date'),
  7159. isFloating: select(store_store).isEditedPostDateFloating()
  7160. };
  7161. })(PostScheduleLabel));
  7162. ;// CONCATENATED MODULE: external ["wp","a11y"]
  7163. var external_wp_a11y_namespaceObject = window["wp"]["a11y"];
  7164. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/most-used-terms.js
  7165. /**
  7166. * External dependencies
  7167. */
  7168. /**
  7169. * WordPress dependencies
  7170. */
  7171. /**
  7172. * Internal dependencies
  7173. */
  7174. const MIN_MOST_USED_TERMS = 3;
  7175. const DEFAULT_QUERY = {
  7176. per_page: 10,
  7177. orderby: 'count',
  7178. order: 'desc',
  7179. hide_empty: true,
  7180. _fields: 'id,name,count',
  7181. context: 'view'
  7182. };
  7183. function MostUsedTerms(_ref) {
  7184. let {
  7185. onSelect,
  7186. taxonomy
  7187. } = _ref;
  7188. const {
  7189. _terms,
  7190. showTerms
  7191. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  7192. const mostUsedTerms = select(external_wp_coreData_namespaceObject.store).getEntityRecords('taxonomy', taxonomy.slug, DEFAULT_QUERY);
  7193. return {
  7194. _terms: mostUsedTerms,
  7195. showTerms: (mostUsedTerms === null || mostUsedTerms === void 0 ? void 0 : mostUsedTerms.length) >= MIN_MOST_USED_TERMS
  7196. };
  7197. }, []);
  7198. if (!showTerms) {
  7199. return null;
  7200. }
  7201. const terms = unescapeTerms(_terms);
  7202. const label = (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', 'most_used']);
  7203. return (0,external_wp_element_namespaceObject.createElement)("div", {
  7204. className: "editor-post-taxonomies__flat-term-most-used"
  7205. }, (0,external_wp_element_namespaceObject.createElement)("h3", {
  7206. className: "editor-post-taxonomies__flat-term-most-used-label"
  7207. }, label), (0,external_wp_element_namespaceObject.createElement)("ul", {
  7208. role: "list",
  7209. className: "editor-post-taxonomies__flat-term-most-used-list"
  7210. }, terms.map(term => (0,external_wp_element_namespaceObject.createElement)("li", {
  7211. key: term.id
  7212. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  7213. variant: "link",
  7214. onClick: () => onSelect(term)
  7215. }, term.name)))));
  7216. }
  7217. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/flat-term-selector.js
  7218. /**
  7219. * External dependencies
  7220. */
  7221. /**
  7222. * WordPress dependencies
  7223. */
  7224. /**
  7225. * Internal dependencies
  7226. */
  7227. /**
  7228. * Shared reference to an empty array for cases where it is important to avoid
  7229. * returning a new array reference on every invocation.
  7230. *
  7231. * @type {Array<any>}
  7232. */
  7233. const flat_term_selector_EMPTY_ARRAY = [];
  7234. /**
  7235. * Module constants
  7236. */
  7237. const MAX_TERMS_SUGGESTIONS = 20;
  7238. const flat_term_selector_DEFAULT_QUERY = {
  7239. per_page: MAX_TERMS_SUGGESTIONS,
  7240. orderby: 'count',
  7241. order: 'desc',
  7242. _fields: 'id,name',
  7243. context: 'view'
  7244. };
  7245. const isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase();
  7246. const termNamesToIds = (names, terms) => {
  7247. return names.map(termName => (0,external_lodash_namespaceObject.find)(terms, term => isSameTermName(term.name, termName)).id);
  7248. }; // Tries to create a term or fetch it if it already exists.
  7249. function findOrCreateTerm(termName, restBase) {
  7250. const escapedTermName = (0,external_lodash_namespaceObject.escape)(termName);
  7251. return external_wp_apiFetch_default()({
  7252. path: `/wp/v2/${restBase}`,
  7253. method: 'POST',
  7254. data: {
  7255. name: escapedTermName
  7256. }
  7257. }).catch(error => {
  7258. const errorCode = error.code;
  7259. if (errorCode === 'term_exists') {
  7260. // If the terms exist, fetch it instead of creating a new one.
  7261. const addRequest = external_wp_apiFetch_default()({
  7262. path: (0,external_wp_url_namespaceObject.addQueryArgs)(`/wp/v2/${restBase}`, { ...flat_term_selector_DEFAULT_QUERY,
  7263. search: escapedTermName
  7264. })
  7265. }).then(unescapeTerms);
  7266. return addRequest.then(searchResult => {
  7267. return (0,external_lodash_namespaceObject.find)(searchResult, result => isSameTermName(result.name, termName));
  7268. });
  7269. }
  7270. return Promise.reject(error);
  7271. }).then(unescapeTerm);
  7272. }
  7273. function FlatTermSelector(_ref) {
  7274. let {
  7275. slug
  7276. } = _ref;
  7277. const [values, setValues] = (0,external_wp_element_namespaceObject.useState)([]);
  7278. const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)('');
  7279. const debouncedSearch = (0,external_wp_compose_namespaceObject.useDebounce)(setSearch, 500);
  7280. const {
  7281. terms,
  7282. termIds,
  7283. taxonomy,
  7284. hasAssignAction,
  7285. hasCreateAction,
  7286. hasResolvedTerms
  7287. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  7288. const {
  7289. getCurrentPost,
  7290. getEditedPostAttribute
  7291. } = select(store_store);
  7292. const {
  7293. getEntityRecords,
  7294. getTaxonomy,
  7295. hasFinishedResolution
  7296. } = select(external_wp_coreData_namespaceObject.store);
  7297. const post = getCurrentPost();
  7298. const _taxonomy = getTaxonomy(slug);
  7299. const _termIds = _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : flat_term_selector_EMPTY_ARRAY;
  7300. const query = { ...flat_term_selector_DEFAULT_QUERY,
  7301. include: _termIds.join(','),
  7302. per_page: -1
  7303. };
  7304. return {
  7305. hasCreateAction: _taxonomy ? (0,external_lodash_namespaceObject.get)(post, ['_links', 'wp:action-create-' + _taxonomy.rest_base], false) : false,
  7306. hasAssignAction: _taxonomy ? (0,external_lodash_namespaceObject.get)(post, ['_links', 'wp:action-assign-' + _taxonomy.rest_base], false) : false,
  7307. taxonomy: _taxonomy,
  7308. termIds: _termIds,
  7309. terms: _termIds.length ? getEntityRecords('taxonomy', slug, query) : flat_term_selector_EMPTY_ARRAY,
  7310. hasResolvedTerms: hasFinishedResolution('getEntityRecords', ['taxonomy', slug, query])
  7311. };
  7312. }, [slug]);
  7313. const {
  7314. searchResults
  7315. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  7316. const {
  7317. getEntityRecords
  7318. } = select(external_wp_coreData_namespaceObject.store);
  7319. return {
  7320. searchResults: !!search ? getEntityRecords('taxonomy', slug, { ...flat_term_selector_DEFAULT_QUERY,
  7321. search
  7322. }) : flat_term_selector_EMPTY_ARRAY
  7323. };
  7324. }, [search]); // Update terms state only after the selectors are resolved.
  7325. // We're using this to avoid terms temporarily disappearing on slow networks
  7326. // while core data makes REST API requests.
  7327. (0,external_wp_element_namespaceObject.useEffect)(() => {
  7328. if (hasResolvedTerms) {
  7329. const newValues = (terms !== null && terms !== void 0 ? terms : []).map(term => unescapeString(term.name));
  7330. setValues(newValues);
  7331. }
  7332. }, [terms, hasResolvedTerms]);
  7333. const suggestions = (0,external_wp_element_namespaceObject.useMemo)(() => {
  7334. return (searchResults !== null && searchResults !== void 0 ? searchResults : []).map(term => unescapeString(term.name));
  7335. }, [searchResults]);
  7336. const {
  7337. editPost
  7338. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  7339. if (!hasAssignAction) {
  7340. return null;
  7341. }
  7342. function onUpdateTerms(newTermIds) {
  7343. editPost({
  7344. [taxonomy.rest_base]: newTermIds
  7345. });
  7346. }
  7347. function onChange(termNames) {
  7348. const availableTerms = [...(terms !== null && terms !== void 0 ? terms : []), ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])];
  7349. const uniqueTerms = (0,external_lodash_namespaceObject.uniqBy)(termNames, term => term.toLowerCase());
  7350. const newTermNames = uniqueTerms.filter(termName => !(0,external_lodash_namespaceObject.find)(availableTerms, term => isSameTermName(term.name, termName))); // Optimistically update term values.
  7351. // The selector will always re-fetch terms later.
  7352. setValues(uniqueTerms);
  7353. if (newTermNames.length === 0) {
  7354. return onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
  7355. }
  7356. if (!hasCreateAction) {
  7357. return;
  7358. }
  7359. Promise.all(newTermNames.map(termName => findOrCreateTerm(termName, taxonomy.rest_base))).then(newTerms => {
  7360. const newAvailableTerms = availableTerms.concat(newTerms);
  7361. return onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms));
  7362. });
  7363. }
  7364. function appendTerm(newTerm) {
  7365. if (termIds.includes(newTerm.id)) {
  7366. return;
  7367. }
  7368. const newTermIds = [...termIds, newTerm.id];
  7369. const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
  7370. /* translators: %s: term name. */
  7371. (0,external_wp_i18n_namespaceObject._x)('%s added', 'term'), (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', 'singular_name'], slug === 'post_tag' ? (0,external_wp_i18n_namespaceObject.__)('Tag') : (0,external_wp_i18n_namespaceObject.__)('Term')));
  7372. (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive');
  7373. onUpdateTerms(newTermIds);
  7374. }
  7375. const newTermLabel = (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', 'add_new_item'], slug === 'post_tag' ? (0,external_wp_i18n_namespaceObject.__)('Add new tag') : (0,external_wp_i18n_namespaceObject.__)('Add new Term'));
  7376. const singularName = (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', 'singular_name'], slug === 'post_tag' ? (0,external_wp_i18n_namespaceObject.__)('Tag') : (0,external_wp_i18n_namespaceObject.__)('Term'));
  7377. const termAddedLabel = (0,external_wp_i18n_namespaceObject.sprintf)(
  7378. /* translators: %s: term name. */
  7379. (0,external_wp_i18n_namespaceObject._x)('%s added', 'term'), singularName);
  7380. const termRemovedLabel = (0,external_wp_i18n_namespaceObject.sprintf)(
  7381. /* translators: %s: term name. */
  7382. (0,external_wp_i18n_namespaceObject._x)('%s removed', 'term'), singularName);
  7383. const removeTermLabel = (0,external_wp_i18n_namespaceObject.sprintf)(
  7384. /* translators: %s: term name. */
  7385. (0,external_wp_i18n_namespaceObject._x)('Remove %s', 'term'), singularName);
  7386. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FormTokenField, {
  7387. value: values,
  7388. suggestions: suggestions,
  7389. onChange: onChange,
  7390. onInputChange: debouncedSearch,
  7391. maxSuggestions: MAX_TERMS_SUGGESTIONS,
  7392. label: newTermLabel,
  7393. messages: {
  7394. added: termAddedLabel,
  7395. removed: termRemovedLabel,
  7396. remove: removeTermLabel
  7397. }
  7398. }), (0,external_wp_element_namespaceObject.createElement)(MostUsedTerms, {
  7399. taxonomy: taxonomy,
  7400. onSelect: appendTerm
  7401. }));
  7402. }
  7403. /* harmony default export */ var flat_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(FlatTermSelector));
  7404. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/maybe-tags-panel.js
  7405. /**
  7406. * External dependencies
  7407. */
  7408. /**
  7409. * WordPress dependencies
  7410. */
  7411. /**
  7412. * Internal dependencies
  7413. */
  7414. const TagsPanel = () => {
  7415. const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), (0,external_wp_element_namespaceObject.createElement)("span", {
  7416. className: "editor-post-publish-panel__link",
  7417. key: "label"
  7418. }, (0,external_wp_i18n_namespaceObject.__)('Add tags'))];
  7419. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
  7420. initialOpen: false,
  7421. title: panelBodyTitle
  7422. }, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Tags help users and search engines navigate your site and find your content. Add a few keywords to describe your post.')), (0,external_wp_element_namespaceObject.createElement)(flat_term_selector, {
  7423. slug: 'post_tag'
  7424. }));
  7425. };
  7426. class MaybeTagsPanel extends external_wp_element_namespaceObject.Component {
  7427. constructor(props) {
  7428. super(props);
  7429. this.state = {
  7430. hadTagsWhenOpeningThePanel: props.hasTags
  7431. };
  7432. }
  7433. /*
  7434. * We only want to show the tag panel if the post didn't have
  7435. * any tags when the user hit the Publish button.
  7436. *
  7437. * We can't use the prop.hasTags because it'll change to true
  7438. * if the user adds a new tag within the pre-publish panel.
  7439. * This would force a re-render and a new prop.hasTags check,
  7440. * hiding this panel and keeping the user from adding
  7441. * more than one tag.
  7442. */
  7443. render() {
  7444. if (!this.state.hadTagsWhenOpeningThePanel) {
  7445. return (0,external_wp_element_namespaceObject.createElement)(TagsPanel, null);
  7446. }
  7447. return null;
  7448. }
  7449. }
  7450. /* harmony default export */ var maybe_tags_panel = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => {
  7451. const postType = select(store_store).getCurrentPostType();
  7452. const tagsTaxonomy = select(external_wp_coreData_namespaceObject.store).getTaxonomy('post_tag');
  7453. const tags = tagsTaxonomy && select(store_store).getEditedPostAttribute(tagsTaxonomy.rest_base);
  7454. return {
  7455. areTagsFetched: tagsTaxonomy !== undefined,
  7456. isPostTypeSupported: tagsTaxonomy && (0,external_lodash_namespaceObject.some)(tagsTaxonomy.types, type => type === postType),
  7457. hasTags: tags && tags.length
  7458. };
  7459. }), (0,external_wp_compose_namespaceObject.ifCondition)(_ref => {
  7460. let {
  7461. areTagsFetched,
  7462. isPostTypeSupported
  7463. } = _ref;
  7464. return isPostTypeSupported && areTagsFetched;
  7465. }))(MaybeTagsPanel));
  7466. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/maybe-post-format-panel.js
  7467. /**
  7468. * External dependencies
  7469. */
  7470. /**
  7471. * WordPress dependencies
  7472. */
  7473. /**
  7474. * Internal dependencies
  7475. */
  7476. const getSuggestion = (supportedFormats, suggestedPostFormat) => {
  7477. const formats = POST_FORMATS.filter(format => (0,external_lodash_namespaceObject.includes)(supportedFormats, format.id));
  7478. return (0,external_lodash_namespaceObject.find)(formats, format => format.id === suggestedPostFormat);
  7479. };
  7480. const PostFormatSuggestion = _ref => {
  7481. let {
  7482. suggestedPostFormat,
  7483. suggestionText,
  7484. onUpdatePostFormat
  7485. } = _ref;
  7486. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  7487. variant: "link",
  7488. onClick: () => onUpdatePostFormat(suggestedPostFormat)
  7489. }, suggestionText);
  7490. };
  7491. function PostFormatPanel() {
  7492. const {
  7493. currentPostFormat,
  7494. suggestion
  7495. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  7496. const {
  7497. getEditedPostAttribute,
  7498. getSuggestedPostFormat
  7499. } = select(store_store);
  7500. const supportedFormats = (0,external_lodash_namespaceObject.get)(select(external_wp_coreData_namespaceObject.store).getThemeSupports(), ['formats'], []);
  7501. return {
  7502. currentPostFormat: getEditedPostAttribute('format'),
  7503. suggestion: getSuggestion(supportedFormats, getSuggestedPostFormat())
  7504. };
  7505. }, []);
  7506. const {
  7507. editPost
  7508. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  7509. const onUpdatePostFormat = format => editPost({
  7510. format
  7511. });
  7512. const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), (0,external_wp_element_namespaceObject.createElement)("span", {
  7513. className: "editor-post-publish-panel__link",
  7514. key: "label"
  7515. }, (0,external_wp_i18n_namespaceObject.__)('Use a post format'))];
  7516. if (!suggestion || suggestion.id === currentPostFormat) {
  7517. return null;
  7518. }
  7519. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
  7520. initialOpen: false,
  7521. title: panelBodyTitle
  7522. }, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Your theme uses post formats to highlight different kinds of content, like images or videos. Apply a post format to see this special styling.')), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_element_namespaceObject.createElement)(PostFormatSuggestion, {
  7523. onUpdatePostFormat: onUpdatePostFormat,
  7524. suggestedPostFormat: suggestion.id,
  7525. suggestionText: (0,external_wp_i18n_namespaceObject.sprintf)(
  7526. /* translators: %s: post format */
  7527. (0,external_wp_i18n_namespaceObject.__)('Apply the "%1$s" format.'), suggestion.caption)
  7528. })));
  7529. }
  7530. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/hierarchical-term-selector.js
  7531. /**
  7532. * External dependencies
  7533. */
  7534. /**
  7535. * WordPress dependencies
  7536. */
  7537. /**
  7538. * Internal dependencies
  7539. */
  7540. /**
  7541. * Module Constants
  7542. */
  7543. const hierarchical_term_selector_DEFAULT_QUERY = {
  7544. per_page: -1,
  7545. orderby: 'name',
  7546. order: 'asc',
  7547. _fields: 'id,name,parent',
  7548. context: 'view'
  7549. };
  7550. const MIN_TERMS_COUNT_FOR_FILTER = 8;
  7551. const hierarchical_term_selector_EMPTY_ARRAY = [];
  7552. /**
  7553. * Sort Terms by Selected.
  7554. *
  7555. * @param {Object[]} termsTree Array of terms in tree format.
  7556. * @param {number[]} terms Selected terms.
  7557. *
  7558. * @return {Object[]} Sorted array of terms.
  7559. */
  7560. function sortBySelected(termsTree, terms) {
  7561. const treeHasSelection = termTree => {
  7562. if (terms.indexOf(termTree.id) !== -1) {
  7563. return true;
  7564. }
  7565. if (undefined === termTree.children) {
  7566. return false;
  7567. }
  7568. return termTree.children.map(treeHasSelection).filter(child => child).length > 0;
  7569. };
  7570. const termOrChildIsSelected = (termA, termB) => {
  7571. const termASelected = treeHasSelection(termA);
  7572. const termBSelected = treeHasSelection(termB);
  7573. if (termASelected === termBSelected) {
  7574. return 0;
  7575. }
  7576. if (termASelected && !termBSelected) {
  7577. return -1;
  7578. }
  7579. if (!termASelected && termBSelected) {
  7580. return 1;
  7581. }
  7582. return 0;
  7583. };
  7584. const newTermTree = [...termsTree];
  7585. newTermTree.sort(termOrChildIsSelected);
  7586. return newTermTree;
  7587. }
  7588. /**
  7589. * Find term by parent id or name.
  7590. *
  7591. * @param {Object[]} terms Array of Terms.
  7592. * @param {number|string} parent id.
  7593. * @param {string} name Term name.
  7594. * @return {Object} Term object.
  7595. */
  7596. function findTerm(terms, parent, name) {
  7597. return (0,external_lodash_namespaceObject.find)(terms, term => {
  7598. return (!term.parent && !parent || parseInt(term.parent) === parseInt(parent)) && term.name.toLowerCase() === name.toLowerCase();
  7599. });
  7600. }
  7601. /**
  7602. * Get filter matcher function.
  7603. *
  7604. * @param {string} filterValue Filter value.
  7605. * @return {(function(Object): (Object|boolean))} Matcher function.
  7606. */
  7607. function getFilterMatcher(filterValue) {
  7608. const matchTermsForFilter = originalTerm => {
  7609. if ('' === filterValue) {
  7610. return originalTerm;
  7611. } // Shallow clone, because we'll be filtering the term's children and
  7612. // don't want to modify the original term.
  7613. const term = { ...originalTerm
  7614. }; // Map and filter the children, recursive so we deal with grandchildren
  7615. // and any deeper levels.
  7616. if (term.children.length > 0) {
  7617. term.children = term.children.map(matchTermsForFilter).filter(child => child);
  7618. } // If the term's name contains the filterValue, or it has children
  7619. // (i.e. some child matched at some point in the tree) then return it.
  7620. if (-1 !== term.name.toLowerCase().indexOf(filterValue.toLowerCase()) || term.children.length > 0) {
  7621. return term;
  7622. } // Otherwise, return false. After mapping, the list of terms will need
  7623. // to have false values filtered out.
  7624. return false;
  7625. };
  7626. return matchTermsForFilter;
  7627. }
  7628. /**
  7629. * Hierarchical term selector.
  7630. *
  7631. * @param {Object} props Component props.
  7632. * @param {string} props.slug Taxonomy slug.
  7633. * @return {WPElement} Hierarchical term selector component.
  7634. */
  7635. function HierarchicalTermSelector(_ref) {
  7636. let {
  7637. slug
  7638. } = _ref;
  7639. const [adding, setAdding] = (0,external_wp_element_namespaceObject.useState)(false);
  7640. const [formName, setFormName] = (0,external_wp_element_namespaceObject.useState)('');
  7641. /**
  7642. * @type {[number|'', Function]}
  7643. */
  7644. const [formParent, setFormParent] = (0,external_wp_element_namespaceObject.useState)('');
  7645. const [showForm, setShowForm] = (0,external_wp_element_namespaceObject.useState)(false);
  7646. const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
  7647. const [filteredTermsTree, setFilteredTermsTree] = (0,external_wp_element_namespaceObject.useState)([]);
  7648. const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
  7649. const {
  7650. hasCreateAction,
  7651. hasAssignAction,
  7652. terms,
  7653. loading,
  7654. availableTerms,
  7655. taxonomy
  7656. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  7657. const {
  7658. getCurrentPost,
  7659. getEditedPostAttribute
  7660. } = select(store_store);
  7661. const {
  7662. getTaxonomy,
  7663. getEntityRecords,
  7664. isResolving
  7665. } = select(external_wp_coreData_namespaceObject.store);
  7666. const _taxonomy = getTaxonomy(slug);
  7667. return {
  7668. hasCreateAction: _taxonomy ? (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-create-' + _taxonomy.rest_base], false) : false,
  7669. hasAssignAction: _taxonomy ? (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-assign-' + _taxonomy.rest_base], false) : false,
  7670. terms: _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : hierarchical_term_selector_EMPTY_ARRAY,
  7671. loading: isResolving('getEntityRecords', ['taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY]),
  7672. availableTerms: getEntityRecords('taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY) || hierarchical_term_selector_EMPTY_ARRAY,
  7673. taxonomy: _taxonomy
  7674. };
  7675. }, [slug]);
  7676. const {
  7677. editPost
  7678. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  7679. const {
  7680. saveEntityRecord
  7681. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
  7682. const availableTermsTree = (0,external_wp_element_namespaceObject.useMemo)(() => sortBySelected(buildTermsTree(availableTerms), terms), // Remove `terms` from the dependency list to avoid reordering every time
  7683. // checking or unchecking a term.
  7684. [availableTerms]);
  7685. if (!hasAssignAction) {
  7686. return null;
  7687. }
  7688. /**
  7689. * Append new term.
  7690. *
  7691. * @param {Object} term Term object.
  7692. * @return {Promise} A promise that resolves to save term object.
  7693. */
  7694. const addTerm = term => {
  7695. return saveEntityRecord('taxonomy', slug, term);
  7696. };
  7697. /**
  7698. * Update terms for post.
  7699. *
  7700. * @param {number[]} termIds Term ids.
  7701. */
  7702. const onUpdateTerms = termIds => {
  7703. editPost({
  7704. [taxonomy.rest_base]: termIds
  7705. });
  7706. };
  7707. /**
  7708. * Handler for checking term.
  7709. *
  7710. * @param {number} termId
  7711. */
  7712. const onChange = termId => {
  7713. const hasTerm = terms.includes(termId);
  7714. const newTerms = hasTerm ? (0,external_lodash_namespaceObject.without)(terms, termId) : [...terms, termId];
  7715. onUpdateTerms(newTerms);
  7716. };
  7717. const onChangeFormName = value => {
  7718. setFormName(value);
  7719. };
  7720. /**
  7721. * Handler for changing form parent.
  7722. *
  7723. * @param {number|''} parentId Parent post id.
  7724. */
  7725. const onChangeFormParent = parentId => {
  7726. setFormParent(parentId);
  7727. };
  7728. const onToggleForm = () => {
  7729. setShowForm(!showForm);
  7730. };
  7731. const onAddTerm = async event => {
  7732. event.preventDefault();
  7733. if (formName === '' || adding) {
  7734. return;
  7735. } // Check if the term we are adding already exists.
  7736. const existingTerm = findTerm(availableTerms, formParent, formName);
  7737. if (existingTerm) {
  7738. // If the term we are adding exists but is not selected select it.
  7739. if (!(0,external_lodash_namespaceObject.some)(terms, term => term === existingTerm.id)) {
  7740. onUpdateTerms([...terms, existingTerm.id]);
  7741. }
  7742. setFormName('');
  7743. setFormParent('');
  7744. return;
  7745. }
  7746. setAdding(true);
  7747. const newTerm = await addTerm({
  7748. name: formName,
  7749. parent: formParent ? formParent : undefined
  7750. });
  7751. const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
  7752. /* translators: %s: taxonomy name */
  7753. (0,external_wp_i18n_namespaceObject._x)('%s added', 'term'), (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', 'singular_name'], slug === 'category' ? (0,external_wp_i18n_namespaceObject.__)('Category') : (0,external_wp_i18n_namespaceObject.__)('Term')));
  7754. (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive');
  7755. setAdding(false);
  7756. setFormName('');
  7757. setFormParent('');
  7758. onUpdateTerms([...terms, newTerm.id]);
  7759. };
  7760. const setFilter = value => {
  7761. const newFilteredTermsTree = availableTermsTree.map(getFilterMatcher(value)).filter(term => term);
  7762. const getResultCount = termsTree => {
  7763. let count = 0;
  7764. for (let i = 0; i < termsTree.length; i++) {
  7765. count++;
  7766. if (undefined !== termsTree[i].children) {
  7767. count += getResultCount(termsTree[i].children);
  7768. }
  7769. }
  7770. return count;
  7771. };
  7772. setFilterValue(value);
  7773. setFilteredTermsTree(newFilteredTermsTree);
  7774. const resultCount = getResultCount(newFilteredTermsTree);
  7775. const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
  7776. /* translators: %d: number of results */
  7777. (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', resultCount), resultCount);
  7778. debouncedSpeak(resultsFoundMessage, 'assertive');
  7779. };
  7780. const renderTerms = renderedTerms => {
  7781. return renderedTerms.map(term => {
  7782. return (0,external_wp_element_namespaceObject.createElement)("div", {
  7783. key: term.id,
  7784. className: "editor-post-taxonomies__hierarchical-terms-choice"
  7785. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
  7786. checked: terms.indexOf(term.id) !== -1,
  7787. onChange: () => {
  7788. const termId = parseInt(term.id, 10);
  7789. onChange(termId);
  7790. },
  7791. label: (0,external_lodash_namespaceObject.unescape)(term.name)
  7792. }), !!term.children.length && (0,external_wp_element_namespaceObject.createElement)("div", {
  7793. className: "editor-post-taxonomies__hierarchical-terms-subchoices"
  7794. }, renderTerms(term.children)));
  7795. });
  7796. };
  7797. const labelWithFallback = (labelProperty, fallbackIsCategory, fallbackIsNotCategory) => (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', labelProperty], slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory);
  7798. const newTermButtonLabel = labelWithFallback('add_new_item', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term'));
  7799. const newTermLabel = labelWithFallback('new_item_name', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term'));
  7800. const parentSelectLabel = labelWithFallback('parent_item', (0,external_wp_i18n_namespaceObject.__)('Parent Category'), (0,external_wp_i18n_namespaceObject.__)('Parent Term'));
  7801. const noParentOption = `— ${parentSelectLabel} —`;
  7802. const newTermSubmitLabel = newTermButtonLabel;
  7803. const filterLabel = (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', 'search_items'], (0,external_wp_i18n_namespaceObject.__)('Search Terms'));
  7804. const groupLabel = (0,external_lodash_namespaceObject.get)(taxonomy, ['name'], (0,external_wp_i18n_namespaceObject.__)('Terms'));
  7805. const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;
  7806. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, showFilter && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  7807. className: "editor-post-taxonomies__hierarchical-terms-filter",
  7808. label: filterLabel,
  7809. value: filterValue,
  7810. onChange: setFilter
  7811. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  7812. className: "editor-post-taxonomies__hierarchical-terms-list",
  7813. tabIndex: "0",
  7814. role: "group",
  7815. "aria-label": groupLabel
  7816. }, renderTerms('' !== filterValue ? filteredTermsTree : availableTermsTree)), !loading && hasCreateAction && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  7817. onClick: onToggleForm,
  7818. className: "editor-post-taxonomies__hierarchical-terms-add",
  7819. "aria-expanded": showForm,
  7820. variant: "link"
  7821. }, newTermButtonLabel), showForm && (0,external_wp_element_namespaceObject.createElement)("form", {
  7822. onSubmit: onAddTerm
  7823. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  7824. className: "editor-post-taxonomies__hierarchical-terms-input",
  7825. label: newTermLabel,
  7826. value: formName,
  7827. onChange: onChangeFormName,
  7828. required: true
  7829. }), !!availableTerms.length && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TreeSelect, {
  7830. label: parentSelectLabel,
  7831. noOptionLabel: noParentOption,
  7832. onChange: onChangeFormParent,
  7833. selectedId: formParent,
  7834. tree: availableTermsTree
  7835. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  7836. variant: "secondary",
  7837. type: "submit",
  7838. className: "editor-post-taxonomies__hierarchical-terms-submit"
  7839. }, newTermSubmitLabel)));
  7840. }
  7841. /* harmony default export */ var hierarchical_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(HierarchicalTermSelector));
  7842. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/maybe-category-panel.js
  7843. /**
  7844. * External dependencies
  7845. */
  7846. /**
  7847. * WordPress dependencies
  7848. */
  7849. /**
  7850. * Internal dependencies
  7851. */
  7852. function MaybeCategoryPanel() {
  7853. const hasNoCategory = (0,external_wp_data_namespaceObject.useSelect)(select => {
  7854. var _select$getEntityReco;
  7855. const postType = select(store_store).getCurrentPostType();
  7856. const categoriesTaxonomy = select(external_wp_coreData_namespaceObject.store).getTaxonomy('category');
  7857. const defaultCategorySlug = 'uncategorized';
  7858. const defaultCategory = (_select$getEntityReco = select(external_wp_coreData_namespaceObject.store).getEntityRecords('taxonomy', 'category', {
  7859. slug: defaultCategorySlug
  7860. })) === null || _select$getEntityReco === void 0 ? void 0 : _select$getEntityReco[0];
  7861. const postTypeSupportsCategories = categoriesTaxonomy && (0,external_lodash_namespaceObject.some)(categoriesTaxonomy.types, type => type === postType);
  7862. const categories = categoriesTaxonomy && select(store_store).getEditedPostAttribute(categoriesTaxonomy.rest_base); // This boolean should return true if everything is loaded
  7863. // ( categoriesTaxonomy, defaultCategory )
  7864. // and the post has not been assigned a category different than "uncategorized".
  7865. return !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && ((categories === null || categories === void 0 ? void 0 : categories.length) === 0 || (categories === null || categories === void 0 ? void 0 : categories.length) === 1 && defaultCategory.id === categories[0]);
  7866. }, []);
  7867. const [shouldShowPanel, setShouldShowPanel] = (0,external_wp_element_namespaceObject.useState)(false);
  7868. (0,external_wp_element_namespaceObject.useEffect)(() => {
  7869. // We use state to avoid hiding the panel if the user edits the categories
  7870. // and adds one within the panel itself (while visible).
  7871. if (hasNoCategory) {
  7872. setShouldShowPanel(true);
  7873. }
  7874. }, [hasNoCategory]);
  7875. if (!shouldShowPanel) {
  7876. return null;
  7877. }
  7878. const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), (0,external_wp_element_namespaceObject.createElement)("span", {
  7879. className: "editor-post-publish-panel__link",
  7880. key: "label"
  7881. }, (0,external_wp_i18n_namespaceObject.__)('Assign a category'))];
  7882. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
  7883. initialOpen: false,
  7884. title: panelBodyTitle
  7885. }, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about.')), (0,external_wp_element_namespaceObject.createElement)(hierarchical_term_selector, {
  7886. slug: "category"
  7887. }));
  7888. }
  7889. /* harmony default export */ var maybe_category_panel = (MaybeCategoryPanel);
  7890. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/prepublish.js
  7891. /**
  7892. * External dependencies
  7893. */
  7894. /**
  7895. * WordPress dependencies
  7896. */
  7897. /**
  7898. * Internal dependencies
  7899. */
  7900. function PostPublishPanelPrepublish(_ref) {
  7901. let {
  7902. children
  7903. } = _ref;
  7904. const {
  7905. isBeingScheduled,
  7906. isRequestingSiteIcon,
  7907. hasPublishAction,
  7908. siteIconUrl,
  7909. siteTitle,
  7910. siteHome
  7911. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  7912. const {
  7913. getCurrentPost,
  7914. isEditedPostBeingScheduled
  7915. } = select(store_store);
  7916. const {
  7917. getEntityRecord,
  7918. isResolving
  7919. } = select(external_wp_coreData_namespaceObject.store);
  7920. const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
  7921. return {
  7922. hasPublishAction: (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
  7923. isBeingScheduled: isEditedPostBeingScheduled(),
  7924. isRequestingSiteIcon: isResolving('getEntityRecord', ['root', '__unstableBase', undefined]),
  7925. siteIconUrl: siteData.site_icon_url,
  7926. siteTitle: siteData.name,
  7927. siteHome: siteData.home && (0,external_wp_url_namespaceObject.filterURLForDisplay)(siteData.home)
  7928. };
  7929. }, []);
  7930. let siteIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
  7931. className: "components-site-icon",
  7932. size: "36px",
  7933. icon: library_wordpress
  7934. });
  7935. if (siteIconUrl) {
  7936. siteIcon = (0,external_wp_element_namespaceObject.createElement)("img", {
  7937. alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'),
  7938. className: "components-site-icon",
  7939. src: siteIconUrl
  7940. });
  7941. }
  7942. if (isRequestingSiteIcon) {
  7943. siteIcon = null;
  7944. }
  7945. let prePublishTitle, prePublishBodyText;
  7946. if (!hasPublishAction) {
  7947. prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to submit for review?');
  7948. prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('When you’re ready, submit your work for review, and an Editor will be able to approve it for you.');
  7949. } else if (isBeingScheduled) {
  7950. prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to schedule?');
  7951. prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Your work will be published at the specified date and time.');
  7952. } else {
  7953. prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to publish?');
  7954. prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Double-check your settings before publishing.');
  7955. }
  7956. return (0,external_wp_element_namespaceObject.createElement)("div", {
  7957. className: "editor-post-publish-panel__prepublish"
  7958. }, (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_element_namespaceObject.createElement)("strong", null, prePublishTitle)), (0,external_wp_element_namespaceObject.createElement)("p", null, prePublishBodyText), (0,external_wp_element_namespaceObject.createElement)("div", {
  7959. className: "components-site-card"
  7960. }, siteIcon, (0,external_wp_element_namespaceObject.createElement)("div", {
  7961. className: "components-site-info"
  7962. }, (0,external_wp_element_namespaceObject.createElement)("span", {
  7963. className: "components-site-name"
  7964. }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle) || (0,external_wp_i18n_namespaceObject.__)('(Untitled)')), (0,external_wp_element_namespaceObject.createElement)("span", {
  7965. className: "components-site-home"
  7966. }, siteHome))), hasPublishAction && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
  7967. initialOpen: false,
  7968. title: [(0,external_wp_i18n_namespaceObject.__)('Visibility:'), (0,external_wp_element_namespaceObject.createElement)("span", {
  7969. className: "editor-post-publish-panel__link",
  7970. key: "label"
  7971. }, (0,external_wp_element_namespaceObject.createElement)(post_visibility_label, null))]
  7972. }, (0,external_wp_element_namespaceObject.createElement)(post_visibility, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
  7973. initialOpen: false,
  7974. title: [(0,external_wp_i18n_namespaceObject.__)('Publish:'), (0,external_wp_element_namespaceObject.createElement)("span", {
  7975. className: "editor-post-publish-panel__link",
  7976. key: "label"
  7977. }, (0,external_wp_element_namespaceObject.createElement)(post_schedule_label, null))]
  7978. }, (0,external_wp_element_namespaceObject.createElement)(PostSchedule, null))), (0,external_wp_element_namespaceObject.createElement)(PostFormatPanel, null), (0,external_wp_element_namespaceObject.createElement)(maybe_tags_panel, null), (0,external_wp_element_namespaceObject.createElement)(maybe_category_panel, null), children);
  7979. }
  7980. /* harmony default export */ var prepublish = (PostPublishPanelPrepublish);
  7981. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/postpublish.js
  7982. /**
  7983. * External dependencies
  7984. */
  7985. /**
  7986. * WordPress dependencies
  7987. */
  7988. /**
  7989. * Internal dependencies
  7990. */
  7991. const POSTNAME = '%postname%';
  7992. /**
  7993. * Returns URL for a future post.
  7994. *
  7995. * @param {Object} post Post object.
  7996. *
  7997. * @return {string} PostPublish URL.
  7998. */
  7999. const getFuturePostUrl = post => {
  8000. const {
  8001. slug
  8002. } = post;
  8003. if (post.permalink_template.includes(POSTNAME)) {
  8004. return post.permalink_template.replace(POSTNAME, slug);
  8005. }
  8006. return post.permalink_template;
  8007. };
  8008. function postpublish_CopyButton(_ref) {
  8009. let {
  8010. text,
  8011. onCopy,
  8012. children
  8013. } = _ref;
  8014. const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text, onCopy);
  8015. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  8016. variant: "secondary",
  8017. ref: ref
  8018. }, children);
  8019. }
  8020. class PostPublishPanelPostpublish extends external_wp_element_namespaceObject.Component {
  8021. constructor() {
  8022. super(...arguments);
  8023. this.state = {
  8024. showCopyConfirmation: false
  8025. };
  8026. this.onCopy = this.onCopy.bind(this);
  8027. this.onSelectInput = this.onSelectInput.bind(this);
  8028. this.postLink = (0,external_wp_element_namespaceObject.createRef)();
  8029. }
  8030. componentDidMount() {
  8031. if (this.props.focusOnMount) {
  8032. this.postLink.current.focus();
  8033. }
  8034. }
  8035. componentWillUnmount() {
  8036. clearTimeout(this.dismissCopyConfirmation);
  8037. }
  8038. onCopy() {
  8039. this.setState({
  8040. showCopyConfirmation: true
  8041. });
  8042. clearTimeout(this.dismissCopyConfirmation);
  8043. this.dismissCopyConfirmation = setTimeout(() => {
  8044. this.setState({
  8045. showCopyConfirmation: false
  8046. });
  8047. }, 4000);
  8048. }
  8049. onSelectInput(event) {
  8050. event.target.select();
  8051. }
  8052. render() {
  8053. const {
  8054. children,
  8055. isScheduled,
  8056. post,
  8057. postType
  8058. } = this.props;
  8059. const postLabel = (0,external_lodash_namespaceObject.get)(postType, ['labels', 'singular_name']);
  8060. const viewPostLabel = (0,external_lodash_namespaceObject.get)(postType, ['labels', 'view_item']);
  8061. const addNewPostLabel = (0,external_lodash_namespaceObject.get)(postType, ['labels', 'add_new_item']);
  8062. const link = post.status === 'future' ? getFuturePostUrl(post) : post.link;
  8063. const addLink = (0,external_wp_url_namespaceObject.addQueryArgs)('post-new.php', {
  8064. post_type: post.type
  8065. });
  8066. const postPublishNonLinkHeader = isScheduled ? (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('is now scheduled. It will go live on'), ' ', (0,external_wp_element_namespaceObject.createElement)(post_schedule_label, null), ".") : (0,external_wp_i18n_namespaceObject.__)('is now live.');
  8067. return (0,external_wp_element_namespaceObject.createElement)("div", {
  8068. className: "post-publish-panel__postpublish"
  8069. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
  8070. className: "post-publish-panel__postpublish-header"
  8071. }, (0,external_wp_element_namespaceObject.createElement)("a", {
  8072. ref: this.postLink,
  8073. href: link
  8074. }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title) || (0,external_wp_i18n_namespaceObject.__)('(no title)')), ' ', postPublishNonLinkHeader), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, null, (0,external_wp_element_namespaceObject.createElement)("p", {
  8075. className: "post-publish-panel__postpublish-subheader"
  8076. }, (0,external_wp_element_namespaceObject.createElement)("strong", null, (0,external_wp_i18n_namespaceObject.__)('What’s next?'))), (0,external_wp_element_namespaceObject.createElement)("div", {
  8077. className: "post-publish-panel__postpublish-post-address-container"
  8078. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  8079. className: "post-publish-panel__postpublish-post-address",
  8080. readOnly: true,
  8081. label: (0,external_wp_i18n_namespaceObject.sprintf)(
  8082. /* translators: %s: post type singular name */
  8083. (0,external_wp_i18n_namespaceObject.__)('%s address'), postLabel),
  8084. value: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(link),
  8085. onFocus: this.onSelectInput
  8086. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  8087. className: "post-publish-panel__postpublish-post-address__copy-button-wrap"
  8088. }, (0,external_wp_element_namespaceObject.createElement)(postpublish_CopyButton, {
  8089. text: link,
  8090. onCopy: this.onCopy
  8091. }, this.state.showCopyConfirmation ? (0,external_wp_i18n_namespaceObject.__)('Copied!') : (0,external_wp_i18n_namespaceObject.__)('Copy')))), (0,external_wp_element_namespaceObject.createElement)("div", {
  8092. className: "post-publish-panel__postpublish-buttons"
  8093. }, !isScheduled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  8094. variant: "primary",
  8095. href: link
  8096. }, viewPostLabel), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  8097. variant: isScheduled ? 'primary' : 'secondary',
  8098. href: addLink
  8099. }, addNewPostLabel))), children);
  8100. }
  8101. }
  8102. /* harmony default export */ var postpublish = ((0,external_wp_data_namespaceObject.withSelect)(select => {
  8103. const {
  8104. getEditedPostAttribute,
  8105. getCurrentPost,
  8106. isCurrentPostScheduled
  8107. } = select(store_store);
  8108. const {
  8109. getPostType
  8110. } = select(external_wp_coreData_namespaceObject.store);
  8111. return {
  8112. post: getCurrentPost(),
  8113. postType: getPostType(getEditedPostAttribute('type')),
  8114. isScheduled: isCurrentPostScheduled()
  8115. };
  8116. })(PostPublishPanelPostpublish));
  8117. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/index.js
  8118. /**
  8119. * External dependencies
  8120. */
  8121. /**
  8122. * WordPress dependencies
  8123. */
  8124. /**
  8125. * Internal dependencies
  8126. */
  8127. class PostPublishPanel extends external_wp_element_namespaceObject.Component {
  8128. constructor() {
  8129. super(...arguments);
  8130. this.onSubmit = this.onSubmit.bind(this);
  8131. }
  8132. componentDidUpdate(prevProps) {
  8133. // Automatically collapse the publish sidebar when a post
  8134. // is published and the user makes an edit.
  8135. if (prevProps.isPublished && !this.props.isSaving && this.props.isDirty) {
  8136. this.props.onClose();
  8137. }
  8138. }
  8139. onSubmit() {
  8140. const {
  8141. onClose,
  8142. hasPublishAction,
  8143. isPostTypeViewable
  8144. } = this.props;
  8145. if (!hasPublishAction || !isPostTypeViewable) {
  8146. onClose();
  8147. }
  8148. }
  8149. render() {
  8150. const {
  8151. forceIsDirty,
  8152. forceIsSaving,
  8153. isBeingScheduled,
  8154. isPublished,
  8155. isPublishSidebarEnabled,
  8156. isScheduled,
  8157. isSaving,
  8158. isSavingNonPostEntityChanges,
  8159. onClose,
  8160. onTogglePublishSidebar,
  8161. PostPublishExtension,
  8162. PrePublishExtension,
  8163. ...additionalProps
  8164. } = this.props;
  8165. const propsForPanel = (0,external_lodash_namespaceObject.omit)(additionalProps, ['hasPublishAction', 'isDirty', 'isPostTypeViewable']);
  8166. const isPublishedOrScheduled = isPublished || isScheduled && isBeingScheduled;
  8167. const isPrePublish = !isPublishedOrScheduled && !isSaving;
  8168. const isPostPublish = isPublishedOrScheduled && !isSaving;
  8169. return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
  8170. className: "editor-post-publish-panel"
  8171. }, propsForPanel), (0,external_wp_element_namespaceObject.createElement)("div", {
  8172. className: "editor-post-publish-panel__header"
  8173. }, isPostPublish ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  8174. onClick: onClose,
  8175. icon: close_small,
  8176. label: (0,external_wp_i18n_namespaceObject.__)('Close panel')
  8177. }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  8178. className: "editor-post-publish-panel__header-publish-button"
  8179. }, (0,external_wp_element_namespaceObject.createElement)(post_publish_button, {
  8180. focusOnMount: true,
  8181. onSubmit: this.onSubmit,
  8182. forceIsDirty: forceIsDirty,
  8183. forceIsSaving: forceIsSaving
  8184. })), (0,external_wp_element_namespaceObject.createElement)("div", {
  8185. className: "editor-post-publish-panel__header-cancel-button"
  8186. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  8187. disabled: isSavingNonPostEntityChanges,
  8188. onClick: onClose,
  8189. variant: "secondary"
  8190. }, (0,external_wp_i18n_namespaceObject.__)('Cancel'))))), (0,external_wp_element_namespaceObject.createElement)("div", {
  8191. className: "editor-post-publish-panel__content"
  8192. }, isPrePublish && (0,external_wp_element_namespaceObject.createElement)(prepublish, null, PrePublishExtension && (0,external_wp_element_namespaceObject.createElement)(PrePublishExtension, null)), isPostPublish && (0,external_wp_element_namespaceObject.createElement)(postpublish, {
  8193. focusOnMount: true
  8194. }, PostPublishExtension && (0,external_wp_element_namespaceObject.createElement)(PostPublishExtension, null)), isSaving && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null)), (0,external_wp_element_namespaceObject.createElement)("div", {
  8195. className: "editor-post-publish-panel__footer"
  8196. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
  8197. label: (0,external_wp_i18n_namespaceObject.__)('Always show pre-publish checks.'),
  8198. checked: isPublishSidebarEnabled,
  8199. onChange: onTogglePublishSidebar
  8200. })));
  8201. }
  8202. }
  8203. /* harmony default export */ var post_publish_panel = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
  8204. const {
  8205. getPostType
  8206. } = select(external_wp_coreData_namespaceObject.store);
  8207. const {
  8208. getCurrentPost,
  8209. getEditedPostAttribute,
  8210. isCurrentPostPublished,
  8211. isCurrentPostScheduled,
  8212. isEditedPostBeingScheduled,
  8213. isEditedPostDirty,
  8214. isSavingPost,
  8215. isSavingNonPostEntityChanges
  8216. } = select(store_store);
  8217. const {
  8218. isPublishSidebarEnabled
  8219. } = select(store_store);
  8220. const postType = getPostType(getEditedPostAttribute('type'));
  8221. return {
  8222. hasPublishAction: (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
  8223. isPostTypeViewable: (0,external_lodash_namespaceObject.get)(postType, ['viewable'], false),
  8224. isBeingScheduled: isEditedPostBeingScheduled(),
  8225. isDirty: isEditedPostDirty(),
  8226. isPublished: isCurrentPostPublished(),
  8227. isPublishSidebarEnabled: isPublishSidebarEnabled(),
  8228. isSaving: isSavingPost(),
  8229. isSavingNonPostEntityChanges: isSavingNonPostEntityChanges(),
  8230. isScheduled: isCurrentPostScheduled()
  8231. };
  8232. }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref) => {
  8233. let {
  8234. isPublishSidebarEnabled
  8235. } = _ref;
  8236. const {
  8237. disablePublishSidebar,
  8238. enablePublishSidebar
  8239. } = dispatch(store_store);
  8240. return {
  8241. onTogglePublishSidebar: () => {
  8242. if (isPublishSidebarEnabled) {
  8243. disablePublishSidebar();
  8244. } else {
  8245. enablePublishSidebar();
  8246. }
  8247. }
  8248. };
  8249. }), external_wp_components_namespaceObject.withFocusReturn, external_wp_components_namespaceObject.withConstrainedTabbing])(PostPublishPanel));
  8250. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/cloud-upload.js
  8251. /**
  8252. * WordPress dependencies
  8253. */
  8254. const cloudUpload = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8255. xmlns: "http://www.w3.org/2000/svg",
  8256. viewBox: "0 0 24 24"
  8257. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8258. d: "M17.3 10.1c0-2.5-2.1-4.4-4.8-4.4-2.2 0-4.1 1.4-4.6 3.3h-.2C5.7 9 4 10.7 4 12.8c0 2.1 1.7 3.8 3.7 3.8h9c1.8 0 3.2-1.5 3.2-3.3.1-1.6-1.1-2.9-2.6-3.2zm-.5 5.1h-4v-2.4L14 14l1-1-3-3-3 3 1 1 1.2-1.2v2.4H7.7c-1.2 0-2.2-1.1-2.2-2.3s1-2.4 2.2-2.4H9l.3-1.1c.4-1.3 1.7-2.2 3.2-2.2 1.8 0 3.3 1.3 3.3 2.9v1.3l1.3.2c.8.1 1.4.9 1.4 1.8 0 1-.8 1.8-1.7 1.8z"
  8259. }));
  8260. /* harmony default export */ var cloud_upload = (cloudUpload);
  8261. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js
  8262. /**
  8263. * WordPress dependencies
  8264. */
  8265. /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
  8266. /**
  8267. * Return an SVG icon.
  8268. *
  8269. * @param {IconProps} props icon is the SVG component to render
  8270. * size is a number specifiying the icon size in pixels
  8271. * Other props will be passed to wrapped SVG component
  8272. *
  8273. * @return {JSX.Element} Icon component
  8274. */
  8275. function Icon(_ref) {
  8276. let {
  8277. icon,
  8278. size = 24,
  8279. ...props
  8280. } = _ref;
  8281. return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
  8282. width: size,
  8283. height: size,
  8284. ...props
  8285. });
  8286. }
  8287. /* harmony default export */ var icon = (Icon);
  8288. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/check.js
  8289. /**
  8290. * WordPress dependencies
  8291. */
  8292. const check_check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8293. xmlns: "http://www.w3.org/2000/svg",
  8294. viewBox: "0 0 24 24"
  8295. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8296. d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
  8297. }));
  8298. /* harmony default export */ var library_check = (check_check);
  8299. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/cloud.js
  8300. /**
  8301. * WordPress dependencies
  8302. */
  8303. const cloud = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  8304. xmlns: "http://www.w3.org/2000/svg",
  8305. viewBox: "0 0 24 24"
  8306. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  8307. d: "M17.3 10.1c0-2.5-2.1-4.4-4.8-4.4-2.2 0-4.1 1.4-4.6 3.3h-.2C5.7 9 4 10.7 4 12.8c0 2.1 1.7 3.8 3.7 3.8h9c1.8 0 3.2-1.5 3.2-3.3.1-1.6-1.1-2.9-2.6-3.2zm-.5 5.1h-9c-1.2 0-2.2-1.1-2.2-2.3s1-2.4 2.2-2.4h1.3l.3-1.1c.4-1.3 1.7-2.2 3.2-2.2 1.8 0 3.3 1.3 3.3 2.9v1.3l1.3.2c.8.1 1.4.9 1.4 1.8-.1 1-.9 1.8-1.8 1.8z"
  8308. }));
  8309. /* harmony default export */ var library_cloud = (cloud);
  8310. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-switch-to-draft-button/index.js
  8311. /**
  8312. * WordPress dependencies
  8313. */
  8314. /**
  8315. * Internal dependencies
  8316. */
  8317. function PostSwitchToDraftButton(_ref) {
  8318. let {
  8319. isSaving,
  8320. isPublished,
  8321. isScheduled,
  8322. onClick
  8323. } = _ref;
  8324. const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<');
  8325. const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
  8326. if (!isPublished && !isScheduled) {
  8327. return null;
  8328. }
  8329. let alertMessage;
  8330. if (isPublished) {
  8331. alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unpublish this post?');
  8332. } else if (isScheduled) {
  8333. alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unschedule this post?');
  8334. }
  8335. const handleConfirm = () => {
  8336. setShowConfirmDialog(false);
  8337. onClick();
  8338. };
  8339. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  8340. className: "editor-post-switch-to-draft",
  8341. onClick: () => {
  8342. setShowConfirmDialog(true);
  8343. },
  8344. disabled: isSaving,
  8345. variant: "tertiary"
  8346. }, isMobileViewport ? (0,external_wp_i18n_namespaceObject.__)('Draft') : (0,external_wp_i18n_namespaceObject.__)('Switch to draft')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
  8347. isOpen: showConfirmDialog,
  8348. onConfirm: handleConfirm,
  8349. onCancel: () => setShowConfirmDialog(false)
  8350. }, alertMessage));
  8351. }
  8352. /* harmony default export */ var post_switch_to_draft_button = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
  8353. const {
  8354. isSavingPost,
  8355. isCurrentPostPublished,
  8356. isCurrentPostScheduled
  8357. } = select(store_store);
  8358. return {
  8359. isSaving: isSavingPost(),
  8360. isPublished: isCurrentPostPublished(),
  8361. isScheduled: isCurrentPostScheduled()
  8362. };
  8363. }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
  8364. const {
  8365. editPost,
  8366. savePost
  8367. } = dispatch(store_store);
  8368. return {
  8369. onClick: () => {
  8370. editPost({
  8371. status: 'draft'
  8372. });
  8373. savePost();
  8374. }
  8375. };
  8376. })])(PostSwitchToDraftButton));
  8377. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-saved-state/index.js
  8378. /**
  8379. * External dependencies
  8380. */
  8381. /**
  8382. * WordPress dependencies
  8383. */
  8384. /**
  8385. * Internal dependencies
  8386. */
  8387. /**
  8388. * Component showing whether the post is saved or not and providing save
  8389. * buttons.
  8390. *
  8391. * @param {Object} props Component props.
  8392. * @param {?boolean} props.forceIsDirty Whether to force the post to be marked
  8393. * as dirty.
  8394. * @param {?boolean} props.forceIsSaving Whether to force the post to be marked
  8395. * as being saved.
  8396. * @param {?boolean} props.showIconLabels Whether interface buttons show labels instead of icons
  8397. * @return {import('@wordpress/element').WPComponent} The component.
  8398. */
  8399. function PostSavedState(_ref) {
  8400. let {
  8401. forceIsDirty,
  8402. forceIsSaving,
  8403. showIconLabels = false
  8404. } = _ref;
  8405. const [forceSavedMessage, setForceSavedMessage] = (0,external_wp_element_namespaceObject.useState)(false);
  8406. const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small');
  8407. const {
  8408. isAutosaving,
  8409. isDirty,
  8410. isNew,
  8411. isPending,
  8412. isPublished,
  8413. isSaveable,
  8414. isSaving,
  8415. isScheduled,
  8416. hasPublishAction
  8417. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  8418. var _getCurrentPost$_link, _getCurrentPost, _getCurrentPost$_link2;
  8419. const {
  8420. isEditedPostNew,
  8421. isCurrentPostPublished,
  8422. isCurrentPostScheduled,
  8423. isEditedPostDirty,
  8424. isSavingPost,
  8425. isEditedPostSaveable,
  8426. getCurrentPost,
  8427. isAutosavingPost,
  8428. getEditedPostAttribute
  8429. } = select(store_store);
  8430. return {
  8431. isAutosaving: isAutosavingPost(),
  8432. isDirty: forceIsDirty || isEditedPostDirty(),
  8433. isNew: isEditedPostNew(),
  8434. isPending: 'pending' === getEditedPostAttribute('status'),
  8435. isPublished: isCurrentPostPublished(),
  8436. isSaving: forceIsSaving || isSavingPost(),
  8437. isSaveable: isEditedPostSaveable(),
  8438. isScheduled: isCurrentPostScheduled(),
  8439. hasPublishAction: (_getCurrentPost$_link = (_getCurrentPost = getCurrentPost()) === null || _getCurrentPost === void 0 ? void 0 : (_getCurrentPost$_link2 = _getCurrentPost._links) === null || _getCurrentPost$_link2 === void 0 ? void 0 : _getCurrentPost$_link2['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false
  8440. };
  8441. }, [forceIsDirty, forceIsSaving]);
  8442. const {
  8443. savePost
  8444. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  8445. const wasSaving = (0,external_wp_compose_namespaceObject.usePrevious)(isSaving);
  8446. (0,external_wp_element_namespaceObject.useEffect)(() => {
  8447. let timeoutId;
  8448. if (wasSaving && !isSaving) {
  8449. setForceSavedMessage(true);
  8450. timeoutId = setTimeout(() => {
  8451. setForceSavedMessage(false);
  8452. }, 1000);
  8453. }
  8454. return () => clearTimeout(timeoutId);
  8455. }, [isSaving]); // Once the post has been submitted for review this button
  8456. // is not needed for the contributor role.
  8457. if (!hasPublishAction && isPending) {
  8458. return null;
  8459. }
  8460. if (isPublished || isScheduled) {
  8461. return (0,external_wp_element_namespaceObject.createElement)(post_switch_to_draft_button, null);
  8462. }
  8463. /* translators: button label text should, if possible, be under 16 characters. */
  8464. const label = isPending ? (0,external_wp_i18n_namespaceObject.__)('Save as pending') : (0,external_wp_i18n_namespaceObject.__)('Save draft');
  8465. /* translators: button label text should, if possible, be under 16 characters. */
  8466. const shortLabel = (0,external_wp_i18n_namespaceObject.__)('Save');
  8467. const isSaved = forceSavedMessage || !isNew && !isDirty;
  8468. const isSavedState = isSaving || isSaved;
  8469. const isDisabled = isSaving || isSaved || !isSaveable;
  8470. let text;
  8471. if (isSaving) {
  8472. text = isAutosaving ? (0,external_wp_i18n_namespaceObject.__)('Autosaving') : (0,external_wp_i18n_namespaceObject.__)('Saving');
  8473. } else if (isSaved) {
  8474. text = (0,external_wp_i18n_namespaceObject.__)('Saved');
  8475. } else if (isLargeViewport) {
  8476. text = label;
  8477. } else if (showIconLabels) {
  8478. text = shortLabel;
  8479. } // Use common Button instance for all saved states so that focus is not
  8480. // lost.
  8481. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  8482. className: isSaveable || isSaving ? classnames_default()({
  8483. 'editor-post-save-draft': !isSavedState,
  8484. 'editor-post-saved-state': isSavedState,
  8485. 'is-saving': isSaving,
  8486. 'is-autosaving': isAutosaving,
  8487. 'is-saved': isSaved,
  8488. [(0,external_wp_components_namespaceObject.__unstableGetAnimateClassName)({
  8489. type: 'loading'
  8490. })]: isSaving
  8491. }) : undefined,
  8492. onClick: isDisabled ? undefined : () => savePost(),
  8493. shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('s'),
  8494. variant: isLargeViewport ? 'tertiary' : undefined,
  8495. icon: isLargeViewport ? undefined : cloud_upload,
  8496. label: showIconLabels ? undefined : label,
  8497. "aria-disabled": isDisabled
  8498. }, isSavedState && (0,external_wp_element_namespaceObject.createElement)(icon, {
  8499. icon: isSaved ? library_check : library_cloud
  8500. }), text);
  8501. }
  8502. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-schedule/check.js
  8503. /**
  8504. * External dependencies
  8505. */
  8506. /**
  8507. * WordPress dependencies
  8508. */
  8509. /**
  8510. * Internal dependencies
  8511. */
  8512. function PostScheduleCheck(_ref) {
  8513. let {
  8514. hasPublishAction,
  8515. children
  8516. } = _ref;
  8517. if (!hasPublishAction) {
  8518. return null;
  8519. }
  8520. return children;
  8521. }
  8522. /* harmony default export */ var post_schedule_check = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
  8523. const {
  8524. getCurrentPost,
  8525. getCurrentPostType
  8526. } = select(store_store);
  8527. return {
  8528. hasPublishAction: (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
  8529. postType: getCurrentPostType()
  8530. };
  8531. })])(PostScheduleCheck));
  8532. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-slug/check.js
  8533. /**
  8534. * Internal dependencies
  8535. */
  8536. function PostSlugCheck(_ref) {
  8537. let {
  8538. children
  8539. } = _ref;
  8540. return (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, {
  8541. supportKeys: "slug"
  8542. }, children);
  8543. }
  8544. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-slug/index.js
  8545. /**
  8546. * WordPress dependencies
  8547. */
  8548. /**
  8549. * Internal dependencies
  8550. */
  8551. class PostSlug extends external_wp_element_namespaceObject.Component {
  8552. constructor(_ref) {
  8553. let {
  8554. postSlug,
  8555. postTitle,
  8556. postID
  8557. } = _ref;
  8558. super(...arguments);
  8559. this.state = {
  8560. editedSlug: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(postSlug) || (0,external_wp_url_namespaceObject.cleanForSlug)(postTitle) || postID
  8561. };
  8562. this.setSlug = this.setSlug.bind(this);
  8563. }
  8564. setSlug(event) {
  8565. const {
  8566. postSlug,
  8567. onUpdateSlug
  8568. } = this.props;
  8569. const {
  8570. value
  8571. } = event.target;
  8572. const editedSlug = (0,external_wp_url_namespaceObject.cleanForSlug)(value);
  8573. if (editedSlug === postSlug) {
  8574. return;
  8575. }
  8576. onUpdateSlug(editedSlug);
  8577. }
  8578. render() {
  8579. const {
  8580. instanceId
  8581. } = this.props;
  8582. const {
  8583. editedSlug
  8584. } = this.state;
  8585. const inputId = 'editor-post-slug-' + instanceId;
  8586. return (0,external_wp_element_namespaceObject.createElement)(PostSlugCheck, null, (0,external_wp_element_namespaceObject.createElement)("label", {
  8587. htmlFor: inputId
  8588. }, (0,external_wp_i18n_namespaceObject.__)('Slug')), (0,external_wp_element_namespaceObject.createElement)("input", {
  8589. autoComplete: "off",
  8590. spellCheck: "false",
  8591. type: "text",
  8592. id: inputId,
  8593. value: editedSlug,
  8594. onChange: event => this.setState({
  8595. editedSlug: event.target.value
  8596. }),
  8597. onBlur: this.setSlug,
  8598. className: "editor-post-slug__input"
  8599. }));
  8600. }
  8601. }
  8602. /* harmony default export */ var post_slug = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
  8603. const {
  8604. getCurrentPost,
  8605. getEditedPostAttribute
  8606. } = select(store_store);
  8607. const {
  8608. id
  8609. } = getCurrentPost();
  8610. return {
  8611. postSlug: getEditedPostAttribute('slug'),
  8612. postTitle: getEditedPostAttribute('title'),
  8613. postID: id
  8614. };
  8615. }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
  8616. const {
  8617. editPost
  8618. } = dispatch(store_store);
  8619. return {
  8620. onUpdateSlug(slug) {
  8621. editPost({
  8622. slug
  8623. });
  8624. }
  8625. };
  8626. }), external_wp_compose_namespaceObject.withInstanceId])(PostSlug));
  8627. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-sticky/check.js
  8628. /**
  8629. * External dependencies
  8630. */
  8631. /**
  8632. * WordPress dependencies
  8633. */
  8634. /**
  8635. * Internal dependencies
  8636. */
  8637. function PostStickyCheck(_ref) {
  8638. let {
  8639. hasStickyAction,
  8640. postType,
  8641. children
  8642. } = _ref;
  8643. if (postType !== 'post' || !hasStickyAction) {
  8644. return null;
  8645. }
  8646. return children;
  8647. }
  8648. /* harmony default export */ var post_sticky_check = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
  8649. const post = select(store_store).getCurrentPost();
  8650. return {
  8651. hasStickyAction: (0,external_lodash_namespaceObject.get)(post, ['_links', 'wp:action-sticky'], false),
  8652. postType: select(store_store).getCurrentPostType()
  8653. };
  8654. })])(PostStickyCheck));
  8655. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-sticky/index.js
  8656. /**
  8657. * WordPress dependencies
  8658. */
  8659. /**
  8660. * Internal dependencies
  8661. */
  8662. function PostSticky(_ref) {
  8663. let {
  8664. onUpdateSticky,
  8665. postSticky = false
  8666. } = _ref;
  8667. return (0,external_wp_element_namespaceObject.createElement)(post_sticky_check, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
  8668. label: (0,external_wp_i18n_namespaceObject.__)('Stick to the top of the blog'),
  8669. checked: postSticky,
  8670. onChange: () => onUpdateSticky(!postSticky)
  8671. }));
  8672. }
  8673. /* harmony default export */ var post_sticky = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
  8674. return {
  8675. postSticky: select(store_store).getEditedPostAttribute('sticky')
  8676. };
  8677. }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
  8678. return {
  8679. onUpdateSticky(postSticky) {
  8680. dispatch(store_store).editPost({
  8681. sticky: postSticky
  8682. });
  8683. }
  8684. };
  8685. })])(PostSticky));
  8686. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/index.js
  8687. /**
  8688. * External dependencies
  8689. */
  8690. /**
  8691. * WordPress dependencies
  8692. */
  8693. /**
  8694. * Internal dependencies
  8695. */
  8696. function PostTaxonomies(_ref) {
  8697. let {
  8698. postType,
  8699. taxonomies,
  8700. taxonomyWrapper = external_lodash_namespaceObject.identity
  8701. } = _ref;
  8702. const availableTaxonomies = (0,external_lodash_namespaceObject.filter)(taxonomies, taxonomy => (0,external_lodash_namespaceObject.includes)(taxonomy.types, postType));
  8703. const visibleTaxonomies = (0,external_lodash_namespaceObject.filter)(availableTaxonomies, // In some circumstances .visibility can end up as undefined so optional chaining operator required.
  8704. // https://github.com/WordPress/gutenberg/issues/40326
  8705. taxonomy => {
  8706. var _taxonomy$visibility;
  8707. return (_taxonomy$visibility = taxonomy.visibility) === null || _taxonomy$visibility === void 0 ? void 0 : _taxonomy$visibility.show_ui;
  8708. });
  8709. return visibleTaxonomies.map(taxonomy => {
  8710. const TaxonomyComponent = taxonomy.hierarchical ? hierarchical_term_selector : flat_term_selector;
  8711. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, {
  8712. key: `taxonomy-${taxonomy.slug}`
  8713. }, taxonomyWrapper((0,external_wp_element_namespaceObject.createElement)(TaxonomyComponent, {
  8714. slug: taxonomy.slug
  8715. }), taxonomy));
  8716. });
  8717. }
  8718. /* harmony default export */ var post_taxonomies = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
  8719. return {
  8720. postType: select(store_store).getCurrentPostType(),
  8721. taxonomies: select(external_wp_coreData_namespaceObject.store).getTaxonomies({
  8722. per_page: -1
  8723. })
  8724. };
  8725. })])(PostTaxonomies));
  8726. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/check.js
  8727. /**
  8728. * External dependencies
  8729. */
  8730. /**
  8731. * WordPress dependencies
  8732. */
  8733. /**
  8734. * Internal dependencies
  8735. */
  8736. function PostTaxonomiesCheck(_ref) {
  8737. let {
  8738. postType,
  8739. taxonomies,
  8740. children
  8741. } = _ref;
  8742. const hasTaxonomies = (0,external_lodash_namespaceObject.some)(taxonomies, taxonomy => (0,external_lodash_namespaceObject.includes)(taxonomy.types, postType));
  8743. if (!hasTaxonomies) {
  8744. return null;
  8745. }
  8746. return children;
  8747. }
  8748. /* harmony default export */ var post_taxonomies_check = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
  8749. return {
  8750. postType: select(store_store).getCurrentPostType(),
  8751. taxonomies: select(external_wp_coreData_namespaceObject.store).getTaxonomies({
  8752. per_page: -1
  8753. })
  8754. };
  8755. })])(PostTaxonomiesCheck));
  8756. // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
  8757. var lib = __webpack_require__(773);
  8758. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-text-editor/index.js
  8759. /**
  8760. * External dependencies
  8761. */
  8762. /**
  8763. * WordPress dependencies
  8764. */
  8765. /**
  8766. * Internal dependencies
  8767. */
  8768. function PostTextEditor() {
  8769. const postContent = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostContent(), []);
  8770. const {
  8771. editPost,
  8772. resetEditorBlocks
  8773. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  8774. const [value, setValue] = (0,external_wp_element_namespaceObject.useState)(postContent);
  8775. const [isDirty, setIsDirty] = (0,external_wp_element_namespaceObject.useState)(false);
  8776. const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostTextEditor);
  8777. const valueRef = (0,external_wp_element_namespaceObject.useRef)();
  8778. if (!isDirty && value !== postContent) {
  8779. setValue(postContent);
  8780. }
  8781. /**
  8782. * Handles a textarea change event to notify the onChange prop callback and
  8783. * reflect the new value in the component's own state. This marks the start
  8784. * of the user's edits, if not already changed, preventing future props
  8785. * changes to value from replacing the rendered value. This is expected to
  8786. * be followed by a reset to dirty state via `stopEditing`.
  8787. *
  8788. * @see stopEditing
  8789. *
  8790. * @param {Event} event Change event.
  8791. */
  8792. const onChange = event => {
  8793. const newValue = event.target.value;
  8794. editPost({
  8795. content: newValue
  8796. });
  8797. setValue(newValue);
  8798. setIsDirty(true);
  8799. };
  8800. /**
  8801. * Function called when the user has completed their edits, responsible for
  8802. * ensuring that changes, if made, are surfaced to the onPersist prop
  8803. * callback and resetting dirty state.
  8804. */
  8805. const stopEditing = () => {
  8806. if (isDirty) {
  8807. const blocks = (0,external_wp_blocks_namespaceObject.parse)(value);
  8808. resetEditorBlocks(blocks);
  8809. setIsDirty(false);
  8810. }
  8811. };
  8812. (0,external_wp_element_namespaceObject.useEffect)(() => {
  8813. valueRef.current = value;
  8814. }, [value]); // Ensure changes aren't lost when component unmounts.
  8815. (0,external_wp_element_namespaceObject.useEffect)(() => {
  8816. return () => {
  8817. const blocks = (0,external_wp_blocks_namespaceObject.parse)(valueRef.current);
  8818. resetEditorBlocks(blocks);
  8819. };
  8820. }, []);
  8821. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  8822. as: "label",
  8823. htmlFor: `post-content-${instanceId}`
  8824. }, (0,external_wp_i18n_namespaceObject.__)('Type text or HTML')), (0,external_wp_element_namespaceObject.createElement)(lib/* default */.Z, {
  8825. autoComplete: "off",
  8826. dir: "auto",
  8827. value: value,
  8828. onChange: onChange,
  8829. onBlur: stopEditing,
  8830. className: "editor-post-text-editor",
  8831. id: `post-content-${instanceId}`,
  8832. placeholder: (0,external_wp_i18n_namespaceObject.__)('Start writing with text or HTML')
  8833. }));
  8834. }
  8835. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-title/index.js
  8836. /**
  8837. * External dependencies
  8838. */
  8839. /**
  8840. * WordPress dependencies
  8841. */
  8842. /**
  8843. * Internal dependencies
  8844. */
  8845. /**
  8846. * Constants
  8847. */
  8848. const REGEXP_NEWLINES = /[\r\n]+/g;
  8849. function PostTitle() {
  8850. const ref = (0,external_wp_element_namespaceObject.useRef)();
  8851. const [isSelected, setIsSelected] = (0,external_wp_element_namespaceObject.useState)(false);
  8852. const {
  8853. editPost
  8854. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  8855. const {
  8856. insertDefaultBlock,
  8857. clearSelectedBlock,
  8858. insertBlocks
  8859. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
  8860. const {
  8861. isCleanNewPost,
  8862. title,
  8863. placeholder,
  8864. isFocusMode,
  8865. hasFixedToolbar
  8866. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  8867. const {
  8868. getEditedPostAttribute,
  8869. isCleanNewPost: _isCleanNewPost
  8870. } = select(store_store);
  8871. const {
  8872. getSettings
  8873. } = select(external_wp_blockEditor_namespaceObject.store);
  8874. const {
  8875. titlePlaceholder,
  8876. focusMode,
  8877. hasFixedToolbar: _hasFixedToolbar
  8878. } = getSettings();
  8879. return {
  8880. isCleanNewPost: _isCleanNewPost(),
  8881. title: getEditedPostAttribute('title'),
  8882. placeholder: titlePlaceholder,
  8883. isFocusMode: focusMode,
  8884. hasFixedToolbar: _hasFixedToolbar
  8885. };
  8886. }, []);
  8887. (0,external_wp_element_namespaceObject.useEffect)(() => {
  8888. if (!ref.current) {
  8889. return;
  8890. }
  8891. const {
  8892. ownerDocument
  8893. } = ref.current;
  8894. const {
  8895. activeElement,
  8896. body
  8897. } = ownerDocument; // Only autofocus the title when the post is entirely empty. This should
  8898. // only happen for a new post, which means we focus the title on new
  8899. // post so the author can start typing right away, without needing to
  8900. // click anything.
  8901. if (isCleanNewPost && (!activeElement || body === activeElement)) {
  8902. ref.current.focus();
  8903. }
  8904. }, [isCleanNewPost]);
  8905. function onEnterPress() {
  8906. insertDefaultBlock(undefined, undefined, 0);
  8907. }
  8908. function onInsertBlockAfter(blocks) {
  8909. insertBlocks(blocks, 0);
  8910. }
  8911. function onUpdate(newTitle) {
  8912. editPost({
  8913. title: newTitle
  8914. });
  8915. }
  8916. const [selection, setSelection] = (0,external_wp_element_namespaceObject.useState)({});
  8917. function onSelect() {
  8918. setIsSelected(true);
  8919. clearSelectedBlock();
  8920. }
  8921. function onUnselect() {
  8922. setIsSelected(false);
  8923. setSelection({});
  8924. }
  8925. function onChange(value) {
  8926. onUpdate(value.replace(REGEXP_NEWLINES, ' '));
  8927. }
  8928. function onKeyDown(event) {
  8929. if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) {
  8930. event.preventDefault();
  8931. onEnterPress();
  8932. }
  8933. }
  8934. function onPaste(event) {
  8935. const clipboardData = event.clipboardData;
  8936. let plainText = '';
  8937. let html = ''; // IE11 only supports `Text` as an argument for `getData` and will
  8938. // otherwise throw an invalid argument error, so we try the standard
  8939. // arguments first, then fallback to `Text` if they fail.
  8940. try {
  8941. plainText = clipboardData.getData('text/plain');
  8942. html = clipboardData.getData('text/html');
  8943. } catch (error1) {
  8944. try {
  8945. html = clipboardData.getData('Text');
  8946. } catch (error2) {
  8947. // Some browsers like UC Browser paste plain text by default and
  8948. // don't support clipboardData at all, so allow default
  8949. // behaviour.
  8950. return;
  8951. }
  8952. } // Allows us to ask for this information when we get a report.
  8953. window.console.log('Received HTML:\n\n', html);
  8954. window.console.log('Received plain text:\n\n', plainText);
  8955. const content = (0,external_wp_blocks_namespaceObject.pasteHandler)({
  8956. HTML: html,
  8957. plainText
  8958. });
  8959. if (typeof content !== 'string' && content.length) {
  8960. event.preventDefault();
  8961. const [firstBlock] = content;
  8962. if (!title && (firstBlock.name === 'core/heading' || firstBlock.name === 'core/paragraph')) {
  8963. onUpdate(firstBlock.attributes.content);
  8964. onInsertBlockAfter(content.slice(1));
  8965. } else {
  8966. onInsertBlockAfter(content);
  8967. }
  8968. }
  8969. } // The wp-block className is important for editor styles.
  8970. // This same block is used in both the visual and the code editor.
  8971. const className = classnames_default()('wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text', {
  8972. 'is-selected': isSelected,
  8973. 'is-focus-mode': isFocusMode,
  8974. 'has-fixed-toolbar': hasFixedToolbar
  8975. });
  8976. const decodedPlaceholder = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Add title');
  8977. const {
  8978. ref: richTextRef
  8979. } = (0,external_wp_richText_namespaceObject.__unstableUseRichText)({
  8980. value: title,
  8981. onChange,
  8982. placeholder: decodedPlaceholder,
  8983. selectionStart: selection.start,
  8984. selectionEnd: selection.end,
  8985. onSelectionChange(newStart, newEnd) {
  8986. setSelection(sel => {
  8987. const {
  8988. start,
  8989. end
  8990. } = sel;
  8991. if (start === newStart && end === newEnd) {
  8992. return sel;
  8993. }
  8994. return {
  8995. start: newStart,
  8996. end: newEnd
  8997. };
  8998. });
  8999. },
  9000. __unstableDisableFormats: true,
  9001. preserveWhiteSpace: true
  9002. });
  9003. /* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
  9004. return (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, {
  9005. supportKeys: "title"
  9006. }, (0,external_wp_element_namespaceObject.createElement)("h1", {
  9007. ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([richTextRef, ref]),
  9008. contentEditable: true,
  9009. className: className,
  9010. "aria-label": decodedPlaceholder,
  9011. role: "textbox",
  9012. "aria-multiline": "true",
  9013. onFocus: onSelect,
  9014. onBlur: onUnselect,
  9015. onKeyDown: onKeyDown,
  9016. onKeyPress: onUnselect,
  9017. onPaste: onPaste
  9018. }));
  9019. /* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
  9020. }
  9021. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-trash/index.js
  9022. /**
  9023. * WordPress dependencies
  9024. */
  9025. /**
  9026. * Internal dependencies
  9027. */
  9028. function PostTrash() {
  9029. const {
  9030. isNew,
  9031. postId
  9032. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  9033. const store = select(store_store);
  9034. return {
  9035. isNew: store.isEditedPostNew(),
  9036. postId: store.getCurrentPostId()
  9037. };
  9038. }, []);
  9039. const {
  9040. trashPost
  9041. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  9042. if (isNew || !postId) {
  9043. return null;
  9044. }
  9045. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  9046. className: "editor-post-trash",
  9047. isDestructive: true,
  9048. variant: "secondary",
  9049. onClick: () => trashPost()
  9050. }, (0,external_wp_i18n_namespaceObject.__)('Move to trash'));
  9051. }
  9052. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-trash/check.js
  9053. /**
  9054. * WordPress dependencies
  9055. */
  9056. /**
  9057. * Internal dependencies
  9058. */
  9059. function PostTrashCheck(_ref) {
  9060. let {
  9061. isNew,
  9062. postId,
  9063. canUserDelete,
  9064. children
  9065. } = _ref;
  9066. if (isNew || !postId || !canUserDelete) {
  9067. return null;
  9068. }
  9069. return children;
  9070. }
  9071. /* harmony default export */ var post_trash_check = ((0,external_wp_data_namespaceObject.withSelect)(select => {
  9072. const {
  9073. isEditedPostNew,
  9074. getCurrentPostId,
  9075. getCurrentPostType
  9076. } = select(store_store);
  9077. const {
  9078. getPostType,
  9079. canUser
  9080. } = select(external_wp_coreData_namespaceObject.store);
  9081. const postId = getCurrentPostId();
  9082. const postType = getPostType(getCurrentPostType());
  9083. const resource = (postType === null || postType === void 0 ? void 0 : postType.rest_base) || ''; // eslint-disable-line camelcase
  9084. return {
  9085. isNew: isEditedPostNew(),
  9086. postId,
  9087. canUserDelete: postId && resource ? canUser('delete', resource, postId) : false
  9088. };
  9089. })(PostTrashCheck));
  9090. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/check.js
  9091. /**
  9092. * External dependencies
  9093. */
  9094. /**
  9095. * WordPress dependencies
  9096. */
  9097. /**
  9098. * Internal dependencies
  9099. */
  9100. function PostVisibilityCheck(_ref) {
  9101. let {
  9102. hasPublishAction,
  9103. render
  9104. } = _ref;
  9105. const canEdit = hasPublishAction;
  9106. return render({
  9107. canEdit
  9108. });
  9109. }
  9110. /* harmony default export */ var post_visibility_check = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
  9111. const {
  9112. getCurrentPost,
  9113. getCurrentPostType
  9114. } = select(store_store);
  9115. return {
  9116. hasPublishAction: (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
  9117. postType: getCurrentPostType()
  9118. };
  9119. })])(PostVisibilityCheck));
  9120. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/info.js
  9121. /**
  9122. * WordPress dependencies
  9123. */
  9124. const info = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  9125. xmlns: "http://www.w3.org/2000/svg",
  9126. viewBox: "0 0 24 24"
  9127. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  9128. d: "M12 3.2c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z"
  9129. }));
  9130. /* harmony default export */ var library_info = (info);
  9131. ;// CONCATENATED MODULE: external ["wp","wordcount"]
  9132. var external_wp_wordcount_namespaceObject = window["wp"]["wordcount"];
  9133. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/word-count/index.js
  9134. /**
  9135. * WordPress dependencies
  9136. */
  9137. /**
  9138. * Internal dependencies
  9139. */
  9140. function WordCount() {
  9141. const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
  9142. /*
  9143. * translators: If your word count is based on single characters (e.g. East Asian characters),
  9144. * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
  9145. * Do not translate into your own language.
  9146. */
  9147. const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
  9148. return (0,external_wp_element_namespaceObject.createElement)("span", {
  9149. className: "word-count"
  9150. }, (0,external_wp_wordcount_namespaceObject.count)(content, wordCountType));
  9151. }
  9152. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/character-count/index.js
  9153. /**
  9154. * WordPress dependencies
  9155. */
  9156. /**
  9157. * Internal dependencies
  9158. */
  9159. function CharacterCount() {
  9160. const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
  9161. return (0,external_wp_wordcount_namespaceObject.count)(content, 'characters_including_spaces');
  9162. }
  9163. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/table-of-contents/panel.js
  9164. /**
  9165. * WordPress dependencies
  9166. */
  9167. /**
  9168. * Internal dependencies
  9169. */
  9170. function TableOfContentsPanel(_ref) {
  9171. let {
  9172. hasOutlineItemsDisabled,
  9173. onRequestClose
  9174. } = _ref;
  9175. const {
  9176. headingCount,
  9177. paragraphCount,
  9178. numberOfBlocks
  9179. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  9180. const {
  9181. getGlobalBlockCount
  9182. } = select(external_wp_blockEditor_namespaceObject.store);
  9183. return {
  9184. headingCount: getGlobalBlockCount('core/heading'),
  9185. paragraphCount: getGlobalBlockCount('core/paragraph'),
  9186. numberOfBlocks: getGlobalBlockCount()
  9187. };
  9188. }, []);
  9189. return (
  9190. /*
  9191. * Disable reason: The `list` ARIA role is redundant but
  9192. * Safari+VoiceOver won't announce the list otherwise.
  9193. */
  9194. /* eslint-disable jsx-a11y/no-redundant-roles */
  9195. (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  9196. className: "table-of-contents__wrapper",
  9197. role: "note",
  9198. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document Statistics'),
  9199. tabIndex: "0"
  9200. }, (0,external_wp_element_namespaceObject.createElement)("ul", {
  9201. role: "list",
  9202. className: "table-of-contents__counts"
  9203. }, (0,external_wp_element_namespaceObject.createElement)("li", {
  9204. className: "table-of-contents__count"
  9205. }, (0,external_wp_i18n_namespaceObject.__)('Characters'), (0,external_wp_element_namespaceObject.createElement)("span", {
  9206. className: "table-of-contents__number"
  9207. }, (0,external_wp_element_namespaceObject.createElement)(CharacterCount, null))), (0,external_wp_element_namespaceObject.createElement)("li", {
  9208. className: "table-of-contents__count"
  9209. }, (0,external_wp_i18n_namespaceObject.__)('Words'), (0,external_wp_element_namespaceObject.createElement)(WordCount, null)), (0,external_wp_element_namespaceObject.createElement)("li", {
  9210. className: "table-of-contents__count"
  9211. }, (0,external_wp_i18n_namespaceObject.__)('Headings'), (0,external_wp_element_namespaceObject.createElement)("span", {
  9212. className: "table-of-contents__number"
  9213. }, headingCount)), (0,external_wp_element_namespaceObject.createElement)("li", {
  9214. className: "table-of-contents__count"
  9215. }, (0,external_wp_i18n_namespaceObject.__)('Paragraphs'), (0,external_wp_element_namespaceObject.createElement)("span", {
  9216. className: "table-of-contents__number"
  9217. }, paragraphCount)), (0,external_wp_element_namespaceObject.createElement)("li", {
  9218. className: "table-of-contents__count"
  9219. }, (0,external_wp_i18n_namespaceObject.__)('Blocks'), (0,external_wp_element_namespaceObject.createElement)("span", {
  9220. className: "table-of-contents__number"
  9221. }, numberOfBlocks)))), headingCount > 0 && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("hr", null), (0,external_wp_element_namespaceObject.createElement)("h2", {
  9222. className: "table-of-contents__title"
  9223. }, (0,external_wp_i18n_namespaceObject.__)('Document Outline')), (0,external_wp_element_namespaceObject.createElement)(document_outline, {
  9224. onSelect: onRequestClose,
  9225. hasOutlineItemsDisabled: hasOutlineItemsDisabled
  9226. })))
  9227. /* eslint-enable jsx-a11y/no-redundant-roles */
  9228. );
  9229. }
  9230. /* harmony default export */ var panel = (TableOfContentsPanel);
  9231. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/table-of-contents/index.js
  9232. /**
  9233. * WordPress dependencies
  9234. */
  9235. /**
  9236. * Internal dependencies
  9237. */
  9238. function TableOfContents(_ref, ref) {
  9239. let {
  9240. hasOutlineItemsDisabled,
  9241. repositionDropdown,
  9242. ...props
  9243. } = _ref;
  9244. const hasBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_blockEditor_namespaceObject.store).getBlockCount(), []);
  9245. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
  9246. position: repositionDropdown ? 'middle right right' : 'bottom',
  9247. className: "table-of-contents",
  9248. contentClassName: "table-of-contents__popover",
  9249. renderToggle: _ref2 => {
  9250. let {
  9251. isOpen,
  9252. onToggle
  9253. } = _ref2;
  9254. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, {
  9255. ref: ref,
  9256. onClick: hasBlocks ? onToggle : undefined,
  9257. icon: library_info,
  9258. "aria-expanded": isOpen,
  9259. "aria-haspopup": "true"
  9260. /* translators: button label text should, if possible, be under 16 characters. */
  9261. ,
  9262. label: (0,external_wp_i18n_namespaceObject.__)('Details'),
  9263. tooltipPosition: "bottom",
  9264. "aria-disabled": !hasBlocks
  9265. }));
  9266. },
  9267. renderContent: _ref3 => {
  9268. let {
  9269. onClose
  9270. } = _ref3;
  9271. return (0,external_wp_element_namespaceObject.createElement)(panel, {
  9272. onRequestClose: onClose,
  9273. hasOutlineItemsDisabled: hasOutlineItemsDisabled
  9274. });
  9275. }
  9276. });
  9277. }
  9278. /* harmony default export */ var table_of_contents = ((0,external_wp_element_namespaceObject.forwardRef)(TableOfContents));
  9279. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/unsaved-changes-warning/index.js
  9280. /**
  9281. * WordPress dependencies
  9282. */
  9283. /**
  9284. * Warns the user if there are unsaved changes before leaving the editor.
  9285. * Compatible with Post Editor and Site Editor.
  9286. *
  9287. * @return {WPComponent} The component.
  9288. */
  9289. function UnsavedChangesWarning() {
  9290. const isDirty = (0,external_wp_data_namespaceObject.useSelect)(select => {
  9291. return () => {
  9292. const {
  9293. __experimentalGetDirtyEntityRecords
  9294. } = select(external_wp_coreData_namespaceObject.store);
  9295. const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
  9296. return dirtyEntityRecords.length > 0;
  9297. };
  9298. }, []);
  9299. /**
  9300. * Warns the user if there are unsaved changes before leaving the editor.
  9301. *
  9302. * @param {Event} event `beforeunload` event.
  9303. *
  9304. * @return {?string} Warning prompt message, if unsaved changes exist.
  9305. */
  9306. const warnIfUnsavedChanges = event => {
  9307. // We need to call the selector directly in the listener to avoid race
  9308. // conditions with `BrowserURL` where `componentDidUpdate` gets the
  9309. // new value of `isEditedPostDirty` before this component does,
  9310. // causing this component to incorrectly think a trashed post is still dirty.
  9311. if (isDirty()) {
  9312. event.returnValue = (0,external_wp_i18n_namespaceObject.__)('You have unsaved changes. If you proceed, they will be lost.');
  9313. return event.returnValue;
  9314. }
  9315. };
  9316. (0,external_wp_element_namespaceObject.useEffect)(() => {
  9317. window.addEventListener('beforeunload', warnIfUnsavedChanges);
  9318. return () => {
  9319. window.removeEventListener('beforeunload', warnIfUnsavedChanges);
  9320. };
  9321. }, []);
  9322. return null;
  9323. }
  9324. ;// CONCATENATED MODULE: external ["wp","reusableBlocks"]
  9325. var external_wp_reusableBlocks_namespaceObject = window["wp"]["reusableBlocks"];
  9326. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/provider/with-registry-provider.js
  9327. /**
  9328. * WordPress dependencies
  9329. */
  9330. /**
  9331. * Internal dependencies
  9332. */
  9333. const withRegistryProvider = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => (0,external_wp_data_namespaceObject.withRegistry)(props => {
  9334. const {
  9335. useSubRegistry = true,
  9336. registry,
  9337. ...additionalProps
  9338. } = props;
  9339. if (!useSubRegistry) {
  9340. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, additionalProps);
  9341. }
  9342. const [subRegistry, setSubRegistry] = (0,external_wp_element_namespaceObject.useState)(null);
  9343. (0,external_wp_element_namespaceObject.useEffect)(() => {
  9344. const newRegistry = (0,external_wp_data_namespaceObject.createRegistry)({
  9345. 'core/block-editor': external_wp_blockEditor_namespaceObject.storeConfig
  9346. }, registry);
  9347. newRegistry.registerStore('core/editor', storeConfig);
  9348. setSubRegistry(newRegistry);
  9349. }, [registry]);
  9350. if (!subRegistry) {
  9351. return null;
  9352. }
  9353. return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.RegistryProvider, {
  9354. value: subRegistry
  9355. }, (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, additionalProps));
  9356. }), 'withRegistryProvider');
  9357. /* harmony default export */ var with_registry_provider = (withRegistryProvider);
  9358. ;// CONCATENATED MODULE: external ["wp","mediaUtils"]
  9359. var external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"];
  9360. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/media-upload/index.js
  9361. /**
  9362. * External dependencies
  9363. */
  9364. /**
  9365. * WordPress dependencies
  9366. */
  9367. /**
  9368. * Internal dependencies
  9369. */
  9370. /**
  9371. * Upload a media file when the file upload button is activated.
  9372. * Wrapper around mediaUpload() that injects the current post ID.
  9373. *
  9374. * @param {Object} $0 Parameters object passed to the function.
  9375. * @param {?Object} $0.additionalData Additional data to include in the request.
  9376. * @param {string} $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.
  9377. * @param {Array} $0.filesList List of files.
  9378. * @param {?number} $0.maxUploadFileSize Maximum upload size in bytes allowed for the site.
  9379. * @param {Function} $0.onError Function called when an error happens.
  9380. * @param {Function} $0.onFileChange Function called each time a file or a temporary representation of the file is available.
  9381. */
  9382. function mediaUpload(_ref) {
  9383. let {
  9384. additionalData = {},
  9385. allowedTypes,
  9386. filesList,
  9387. maxUploadFileSize,
  9388. onError = external_lodash_namespaceObject.noop,
  9389. onFileChange
  9390. } = _ref;
  9391. const {
  9392. getCurrentPostId,
  9393. getEditorSettings
  9394. } = (0,external_wp_data_namespaceObject.select)(store_store);
  9395. const wpAllowedMimeTypes = getEditorSettings().allowedMimeTypes;
  9396. maxUploadFileSize = maxUploadFileSize || getEditorSettings().maxUploadFileSize;
  9397. (0,external_wp_mediaUtils_namespaceObject.uploadMedia)({
  9398. allowedTypes,
  9399. filesList,
  9400. onFileChange,
  9401. additionalData: {
  9402. post: getCurrentPostId(),
  9403. ...additionalData
  9404. },
  9405. maxUploadFileSize,
  9406. onError: _ref2 => {
  9407. let {
  9408. message
  9409. } = _ref2;
  9410. return onError(message);
  9411. },
  9412. wpAllowedMimeTypes
  9413. });
  9414. }
  9415. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/provider/use-block-editor-settings.js
  9416. /**
  9417. * External dependencies
  9418. */
  9419. /**
  9420. * WordPress dependencies
  9421. */
  9422. /**
  9423. * Internal dependencies
  9424. */
  9425. /**
  9426. * React hook used to compute the block editor settings to use for the post editor.
  9427. *
  9428. * @param {Object} settings EditorProvider settings prop.
  9429. * @param {boolean} hasTemplate Whether template mode is enabled.
  9430. *
  9431. * @return {Object} Block Editor Settings.
  9432. */
  9433. function useBlockEditorSettings(settings, hasTemplate) {
  9434. var _settings$__experimen, _settings$__experimen2;
  9435. const {
  9436. reusableBlocks,
  9437. hasUploadPermissions,
  9438. canUseUnfilteredHTML,
  9439. userCanCreatePages,
  9440. pageOnFront
  9441. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  9442. const {
  9443. canUserUseUnfilteredHTML
  9444. } = select(store_store);
  9445. const isWeb = external_wp_element_namespaceObject.Platform.OS === 'web';
  9446. const {
  9447. canUser,
  9448. getEntityRecord
  9449. } = select(external_wp_coreData_namespaceObject.store);
  9450. const siteSettings = getEntityRecord('root', 'site');
  9451. return {
  9452. canUseUnfilteredHTML: canUserUseUnfilteredHTML(),
  9453. reusableBlocks: isWeb ? select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_block', {
  9454. per_page: -1
  9455. }) : [],
  9456. // Reusable blocks are fetched in the native version of this hook.
  9457. hasUploadPermissions: (0,external_lodash_namespaceObject.defaultTo)(canUser('create', 'media'), true),
  9458. userCanCreatePages: canUser('create', 'pages'),
  9459. pageOnFront: siteSettings === null || siteSettings === void 0 ? void 0 : siteSettings.page_on_front
  9460. };
  9461. }, []);
  9462. const settingsBlockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : // WP 6.0
  9463. settings.__experimentalBlockPatterns; // WP 5.9
  9464. const settingsBlockPatternCategories = (_settings$__experimen2 = settings.__experimentalAdditionalBlockPatternCategories) !== null && _settings$__experimen2 !== void 0 ? _settings$__experimen2 : // WP 6.0
  9465. settings.__experimentalBlockPatternCategories; // WP 5.9
  9466. const {
  9467. restBlockPatterns,
  9468. restBlockPatternCategories
  9469. } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
  9470. restBlockPatterns: select(external_wp_coreData_namespaceObject.store).getBlockPatterns(),
  9471. restBlockPatternCategories: select(external_wp_coreData_namespaceObject.store).getBlockPatternCategories()
  9472. }), []);
  9473. const blockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_lodash_namespaceObject.unionBy)(settingsBlockPatterns, restBlockPatterns, 'name'), [settingsBlockPatterns, restBlockPatterns]);
  9474. const blockPatternCategories = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_lodash_namespaceObject.unionBy)(settingsBlockPatternCategories, restBlockPatternCategories, 'name'), [settingsBlockPatternCategories, restBlockPatternCategories]);
  9475. const {
  9476. undo
  9477. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  9478. const {
  9479. saveEntityRecord
  9480. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
  9481. /**
  9482. * Creates a Post entity.
  9483. * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.
  9484. *
  9485. * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.
  9486. * @return {Object} the post type object that was created.
  9487. */
  9488. const createPageEntity = options => {
  9489. if (!userCanCreatePages) {
  9490. return Promise.reject({
  9491. message: (0,external_wp_i18n_namespaceObject.__)('You do not have permission to create Pages.')
  9492. });
  9493. }
  9494. return saveEntityRecord('postType', 'page', options);
  9495. };
  9496. return (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...(0,external_lodash_namespaceObject.pick)(settings, ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalPreferredStyleVariations', '__experimentalSetIsInserterOpened', '__unstableGalleryWithImageBlocks', 'alignWide', 'allowedBlockTypes', 'bodyPlaceholder', 'canLockBlocks', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomGradients', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'focusMode', 'fontSizes', 'gradients', 'generateAnchors', 'hasFixedToolbar', 'hasReducedUI', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'keepCaretInsideBlock', 'maxWidth', 'onUpdateDefaultBlockStyles', 'styles', 'template', 'templateLock', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock', '__unstableResolvedAssets']),
  9497. mediaUpload: hasUploadPermissions ? mediaUpload : undefined,
  9498. __experimentalReusableBlocks: reusableBlocks,
  9499. __experimentalBlockPatterns: blockPatterns,
  9500. __experimentalBlockPatternCategories: blockPatternCategories,
  9501. __experimentalFetchLinkSuggestions: (search, searchOptions) => (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings),
  9502. __experimentalFetchRichUrlData: external_wp_coreData_namespaceObject.__experimentalFetchUrlData,
  9503. __experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,
  9504. __experimentalUndo: undo,
  9505. outlineMode: hasTemplate,
  9506. __experimentalCreatePageEntity: createPageEntity,
  9507. __experimentalUserCanCreatePages: userCanCreatePages,
  9508. pageOnFront,
  9509. __experimentalPreferPatternsOnRoot: hasTemplate
  9510. }), [settings, hasUploadPermissions, reusableBlocks, blockPatterns, blockPatternCategories, canUseUnfilteredHTML, undo, hasTemplate, userCanCreatePages, pageOnFront]);
  9511. }
  9512. /* harmony default export */ var use_block_editor_settings = (useBlockEditorSettings);
  9513. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/provider/index.js
  9514. /**
  9515. * WordPress dependencies
  9516. */
  9517. /**
  9518. * Internal dependencies
  9519. */
  9520. function EditorProvider(_ref) {
  9521. let {
  9522. __unstableTemplate,
  9523. post,
  9524. settings,
  9525. recovery,
  9526. initialEdits,
  9527. children
  9528. } = _ref;
  9529. const defaultBlockContext = (0,external_wp_element_namespaceObject.useMemo)(() => {
  9530. if (post.type === 'wp_template') {
  9531. return {};
  9532. }
  9533. return {
  9534. postId: post.id,
  9535. postType: post.type
  9536. };
  9537. }, [post.id, post.type]);
  9538. const {
  9539. selection,
  9540. isReady
  9541. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  9542. const {
  9543. getEditorSelection,
  9544. __unstableIsEditorReady
  9545. } = select(store_store);
  9546. return {
  9547. isReady: __unstableIsEditorReady(),
  9548. selection: getEditorSelection()
  9549. };
  9550. }, []);
  9551. const {
  9552. id,
  9553. type
  9554. } = __unstableTemplate !== null && __unstableTemplate !== void 0 ? __unstableTemplate : post;
  9555. const [blocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', type, {
  9556. id
  9557. });
  9558. const editorSettings = use_block_editor_settings(settings, !!__unstableTemplate);
  9559. const {
  9560. updatePostLock,
  9561. setupEditor,
  9562. updateEditorSettings,
  9563. __experimentalTearDownEditor
  9564. } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
  9565. const {
  9566. createWarningNotice
  9567. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); // Initialize and tear down the editor.
  9568. // Ideally this should be synced on each change and not just something you do once.
  9569. (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
  9570. // Assume that we don't need to initialize in the case of an error recovery.
  9571. if (recovery) {
  9572. return;
  9573. }
  9574. updatePostLock(settings.postLock);
  9575. setupEditor(post, initialEdits, settings.template);
  9576. if (settings.autosave) {
  9577. createWarningNotice((0,external_wp_i18n_namespaceObject.__)('There is an autosave of this post that is more recent than the version below.'), {
  9578. id: 'autosave-exists',
  9579. actions: [{
  9580. label: (0,external_wp_i18n_namespaceObject.__)('View the autosave'),
  9581. url: settings.autosave.editLink
  9582. }]
  9583. });
  9584. }
  9585. return () => {
  9586. __experimentalTearDownEditor();
  9587. };
  9588. }, []); // Synchronize the editor settings as they change.
  9589. (0,external_wp_element_namespaceObject.useEffect)(() => {
  9590. updateEditorSettings(settings);
  9591. }, [settings]);
  9592. if (!isReady) {
  9593. return null;
  9594. }
  9595. return (0,external_wp_element_namespaceObject.createElement)(external_wp_coreData_namespaceObject.EntityProvider, {
  9596. kind: "root",
  9597. type: "site"
  9598. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_coreData_namespaceObject.EntityProvider, {
  9599. kind: "postType",
  9600. type: post.type,
  9601. id: post.id
  9602. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockContextProvider, {
  9603. value: defaultBlockContext
  9604. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, {
  9605. value: blocks,
  9606. onChange: onChange,
  9607. onInput: onInput,
  9608. selection: selection,
  9609. settings: editorSettings,
  9610. useSubRegistry: false
  9611. }, children, (0,external_wp_element_namespaceObject.createElement)(external_wp_reusableBlocks_namespaceObject.ReusableBlocksMenuItems, null)))));
  9612. }
  9613. /* harmony default export */ var provider = (with_registry_provider(EditorProvider));
  9614. ;// CONCATENATED MODULE: external ["wp","serverSideRender"]
  9615. var external_wp_serverSideRender_namespaceObject = window["wp"]["serverSideRender"];
  9616. var external_wp_serverSideRender_default = /*#__PURE__*/__webpack_require__.n(external_wp_serverSideRender_namespaceObject);
  9617. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/deprecated.js
  9618. // Block Creation Components.
  9619. /**
  9620. * WordPress dependencies
  9621. */
  9622. function deprecateComponent(name, Wrapped) {
  9623. let staticsToHoist = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
  9624. const Component = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
  9625. external_wp_deprecated_default()('wp.editor.' + name, {
  9626. since: '5.3',
  9627. alternative: 'wp.blockEditor.' + name,
  9628. version: '6.2'
  9629. });
  9630. return (0,external_wp_element_namespaceObject.createElement)(Wrapped, _extends({
  9631. ref: ref
  9632. }, props));
  9633. });
  9634. staticsToHoist.forEach(staticName => {
  9635. Component[staticName] = deprecateComponent(name + '.' + staticName, Wrapped[staticName]);
  9636. });
  9637. return Component;
  9638. }
  9639. function deprecateFunction(name, func) {
  9640. return function () {
  9641. external_wp_deprecated_default()('wp.editor.' + name, {
  9642. since: '5.3',
  9643. alternative: 'wp.blockEditor.' + name,
  9644. version: '6.2'
  9645. });
  9646. return func(...arguments);
  9647. };
  9648. }
  9649. const RichText = deprecateComponent('RichText', external_wp_blockEditor_namespaceObject.RichText, ['Content']);
  9650. RichText.isEmpty = deprecateFunction('RichText.isEmpty', external_wp_blockEditor_namespaceObject.RichText.isEmpty);
  9651. const Autocomplete = deprecateComponent('Autocomplete', external_wp_blockEditor_namespaceObject.Autocomplete);
  9652. const AlignmentToolbar = deprecateComponent('AlignmentToolbar', external_wp_blockEditor_namespaceObject.AlignmentToolbar);
  9653. const BlockAlignmentToolbar = deprecateComponent('BlockAlignmentToolbar', external_wp_blockEditor_namespaceObject.BlockAlignmentToolbar);
  9654. const BlockControls = deprecateComponent('BlockControls', external_wp_blockEditor_namespaceObject.BlockControls, ['Slot']);
  9655. const BlockEdit = deprecateComponent('BlockEdit', external_wp_blockEditor_namespaceObject.BlockEdit);
  9656. const BlockEditorKeyboardShortcuts = deprecateComponent('BlockEditorKeyboardShortcuts', external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts);
  9657. const BlockFormatControls = deprecateComponent('BlockFormatControls', external_wp_blockEditor_namespaceObject.BlockFormatControls, ['Slot']);
  9658. const BlockIcon = deprecateComponent('BlockIcon', external_wp_blockEditor_namespaceObject.BlockIcon);
  9659. const BlockInspector = deprecateComponent('BlockInspector', external_wp_blockEditor_namespaceObject.BlockInspector);
  9660. const BlockList = deprecateComponent('BlockList', external_wp_blockEditor_namespaceObject.BlockList);
  9661. const BlockMover = deprecateComponent('BlockMover', external_wp_blockEditor_namespaceObject.BlockMover);
  9662. const BlockNavigationDropdown = deprecateComponent('BlockNavigationDropdown', external_wp_blockEditor_namespaceObject.BlockNavigationDropdown);
  9663. const BlockSelectionClearer = deprecateComponent('BlockSelectionClearer', external_wp_blockEditor_namespaceObject.BlockSelectionClearer);
  9664. const BlockSettingsMenu = deprecateComponent('BlockSettingsMenu', external_wp_blockEditor_namespaceObject.BlockSettingsMenu);
  9665. const BlockTitle = deprecateComponent('BlockTitle', external_wp_blockEditor_namespaceObject.BlockTitle);
  9666. const BlockToolbar = deprecateComponent('BlockToolbar', external_wp_blockEditor_namespaceObject.BlockToolbar);
  9667. const ColorPalette = deprecateComponent('ColorPalette', external_wp_blockEditor_namespaceObject.ColorPalette);
  9668. const ContrastChecker = deprecateComponent('ContrastChecker', external_wp_blockEditor_namespaceObject.ContrastChecker);
  9669. const CopyHandler = deprecateComponent('CopyHandler', external_wp_blockEditor_namespaceObject.CopyHandler);
  9670. const DefaultBlockAppender = deprecateComponent('DefaultBlockAppender', external_wp_blockEditor_namespaceObject.DefaultBlockAppender);
  9671. const FontSizePicker = deprecateComponent('FontSizePicker', external_wp_blockEditor_namespaceObject.FontSizePicker);
  9672. const Inserter = deprecateComponent('Inserter', external_wp_blockEditor_namespaceObject.Inserter);
  9673. const InnerBlocks = deprecateComponent('InnerBlocks', external_wp_blockEditor_namespaceObject.InnerBlocks, ['ButtonBlockAppender', 'DefaultBlockAppender', 'Content']);
  9674. const InspectorAdvancedControls = deprecateComponent('InspectorAdvancedControls', external_wp_blockEditor_namespaceObject.InspectorAdvancedControls, ['Slot']);
  9675. const InspectorControls = deprecateComponent('InspectorControls', external_wp_blockEditor_namespaceObject.InspectorControls, ['Slot']);
  9676. const PanelColorSettings = deprecateComponent('PanelColorSettings', external_wp_blockEditor_namespaceObject.PanelColorSettings);
  9677. const PlainText = deprecateComponent('PlainText', external_wp_blockEditor_namespaceObject.PlainText);
  9678. const RichTextShortcut = deprecateComponent('RichTextShortcut', external_wp_blockEditor_namespaceObject.RichTextShortcut);
  9679. const RichTextToolbarButton = deprecateComponent('RichTextToolbarButton', external_wp_blockEditor_namespaceObject.RichTextToolbarButton);
  9680. const __unstableRichTextInputEvent = deprecateComponent('__unstableRichTextInputEvent', external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent);
  9681. const MediaPlaceholder = deprecateComponent('MediaPlaceholder', external_wp_blockEditor_namespaceObject.MediaPlaceholder);
  9682. const MediaUpload = deprecateComponent('MediaUpload', external_wp_blockEditor_namespaceObject.MediaUpload);
  9683. const MediaUploadCheck = deprecateComponent('MediaUploadCheck', external_wp_blockEditor_namespaceObject.MediaUploadCheck);
  9684. const MultiSelectScrollIntoView = deprecateComponent('MultiSelectScrollIntoView', external_wp_blockEditor_namespaceObject.MultiSelectScrollIntoView);
  9685. const NavigableToolbar = deprecateComponent('NavigableToolbar', external_wp_blockEditor_namespaceObject.NavigableToolbar);
  9686. const ObserveTyping = deprecateComponent('ObserveTyping', external_wp_blockEditor_namespaceObject.ObserveTyping);
  9687. const SkipToSelectedBlock = deprecateComponent('SkipToSelectedBlock', external_wp_blockEditor_namespaceObject.SkipToSelectedBlock);
  9688. const URLInput = deprecateComponent('URLInput', external_wp_blockEditor_namespaceObject.URLInput);
  9689. const URLInputButton = deprecateComponent('URLInputButton', external_wp_blockEditor_namespaceObject.URLInputButton);
  9690. const URLPopover = deprecateComponent('URLPopover', external_wp_blockEditor_namespaceObject.URLPopover);
  9691. const Warning = deprecateComponent('Warning', external_wp_blockEditor_namespaceObject.Warning);
  9692. const WritingFlow = deprecateComponent('WritingFlow', external_wp_blockEditor_namespaceObject.WritingFlow);
  9693. const createCustomColorsHOC = deprecateFunction('createCustomColorsHOC', external_wp_blockEditor_namespaceObject.createCustomColorsHOC);
  9694. const getColorClassName = deprecateFunction('getColorClassName', external_wp_blockEditor_namespaceObject.getColorClassName);
  9695. const getColorObjectByAttributeValues = deprecateFunction('getColorObjectByAttributeValues', external_wp_blockEditor_namespaceObject.getColorObjectByAttributeValues);
  9696. const getColorObjectByColorValue = deprecateFunction('getColorObjectByColorValue', external_wp_blockEditor_namespaceObject.getColorObjectByColorValue);
  9697. const getFontSize = deprecateFunction('getFontSize', external_wp_blockEditor_namespaceObject.getFontSize);
  9698. const getFontSizeClass = deprecateFunction('getFontSizeClass', external_wp_blockEditor_namespaceObject.getFontSizeClass);
  9699. const withColorContext = deprecateFunction('withColorContext', external_wp_blockEditor_namespaceObject.withColorContext);
  9700. const withColors = deprecateFunction('withColors', external_wp_blockEditor_namespaceObject.withColors);
  9701. const withFontSizes = deprecateFunction('withFontSizes', external_wp_blockEditor_namespaceObject.withFontSizes);
  9702. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/index.js
  9703. // Block Creation Components.
  9704. // Post Related Components.
  9705. // State Related Components.
  9706. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/url.js
  9707. /**
  9708. * WordPress dependencies
  9709. */
  9710. /**
  9711. * Performs some basic cleanup of a string for use as a post slug
  9712. *
  9713. * This replicates some of what sanitize_title() does in WordPress core, but
  9714. * is only designed to approximate what the slug will be.
  9715. *
  9716. * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin letters.
  9717. * Removes combining diacritical marks. Converts whitespace, periods,
  9718. * and forward slashes to hyphens. Removes any remaining non-word characters
  9719. * except hyphens and underscores. Converts remaining string to lowercase.
  9720. * It does not account for octets, HTML entities, or other encoded characters.
  9721. *
  9722. * @param {string} string Title or slug to be processed
  9723. *
  9724. * @return {string} Processed string
  9725. */
  9726. function cleanForSlug(string) {
  9727. external_wp_deprecated_default()('wp.editor.cleanForSlug', {
  9728. since: '12.7',
  9729. plugin: 'Gutenberg',
  9730. alternative: 'wp.url.cleanForSlug'
  9731. });
  9732. return (0,external_wp_url_namespaceObject.cleanForSlug)(string);
  9733. }
  9734. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/index.js
  9735. /**
  9736. * Internal dependencies
  9737. */
  9738. ;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/index.js
  9739. /**
  9740. * Internal dependencies
  9741. */
  9742. /*
  9743. * Backward compatibility
  9744. */
  9745. }();
  9746. (window.wp = window.wp || {}).editor = __webpack_exports__;
  9747. /******/ })()
  9748. ;