|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236 |
- /**
- * Draft v0.11.5
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- (function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory(require("immutable"), require("react"), require("react-dom"));
- else if(typeof define === 'function' && define.amd)
- define(["immutable", "react", "react-dom"], factory);
- else if(typeof exports === 'object')
- exports["Draft"] = factory(require("immutable"), require("react"), require("react-dom"));
- else
- root["Draft"] = factory(root["Immutable"], root["React"], root["ReactDOM"]);
- })(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_8__, __WEBPACK_EXTERNAL_MODULE_161__) {
- return /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, {
- /******/ configurable: false,
- /******/ enumerable: true,
- /******/ get: getter
- /******/ });
- /******/ }
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 78);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */
- /***/ (function(module, exports) {
-
- module.exports = __WEBPACK_EXTERNAL_MODULE_0__;
-
- /***/ }),
- /* 1 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- */
-
-
- var validateFormat = true ? function (format) {} : function (format) {
- if (format === undefined) {
- throw new Error('invariant(...): Second argument must be a string.');
- }
- };
- /**
- * Use invariant() to assert state which your program assumes to be true.
- *
- * Provide sprintf-style format (only %s is supported) and arguments to provide
- * information about what broke and what you were expecting.
- *
- * The invariant message will be stripped in production, but the invariant will
- * remain to ensure logic does not differ in production.
- */
-
- function invariant(condition, format) {
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
- args[_key - 2] = arguments[_key];
- }
-
- validateFormat(format);
-
- if (!condition) {
- var error;
-
- if (format === undefined) {
- error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
- } else {
- var argIndex = 0;
- error = new Error(format.replace(/%s/g, function () {
- return String(args[argIndex++]);
- }));
- error.name = 'Invariant Violation';
- }
-
- error.framesToPop = 1; // Skip invariant's own stack frame.
-
- throw error;
- }
- }
-
- module.exports = invariant;
-
- /***/ }),
- /* 2 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- var BlockTree = __webpack_require__(90);
-
- var ContentState = __webpack_require__(32);
-
- var EditorBidiService = __webpack_require__(91);
-
- var SelectionState = __webpack_require__(23);
-
- var Immutable = __webpack_require__(0);
-
- var OrderedSet = Immutable.OrderedSet,
- Record = Immutable.Record,
- Stack = Immutable.Stack; // When configuring an editor, the user can chose to provide or not provide
- // basically all keys. `currentContent` varies, so this type doesn't include it.
- // (See the types defined below.)
-
- var defaultRecord = {
- allowUndo: true,
- currentContent: null,
- decorator: null,
- directionMap: null,
- forceSelection: false,
- inCompositionMode: false,
- inlineStyleOverride: null,
- lastChangeType: null,
- nativelyRenderedContent: null,
- redoStack: Stack(),
- selection: null,
- treeMap: null,
- undoStack: Stack()
- };
- var EditorStateRecord = Record(defaultRecord);
-
- var EditorState =
- /*#__PURE__*/
- function () {
- EditorState.createEmpty = function createEmpty(decorator) {
- return EditorState.createWithContent(ContentState.createFromText(''), decorator);
- };
-
- EditorState.createWithContent = function createWithContent(contentState, decorator) {
- if (contentState.getBlockMap().count() === 0) {
- return EditorState.createEmpty(decorator);
- }
-
- var firstKey = contentState.getBlockMap().first().getKey();
- return EditorState.create({
- currentContent: contentState,
- undoStack: Stack(),
- redoStack: Stack(),
- decorator: decorator || null,
- selection: SelectionState.createEmpty(firstKey)
- });
- };
-
- EditorState.create = function create(config) {
- var currentContent = config.currentContent,
- decorator = config.decorator;
-
- var recordConfig = _objectSpread({}, config, {
- treeMap: generateNewTreeMap(currentContent, decorator),
- directionMap: EditorBidiService.getDirectionMap(currentContent)
- });
-
- return new EditorState(new EditorStateRecord(recordConfig));
- };
-
- EditorState.set = function set(editorState, put) {
- var map = editorState.getImmutable().withMutations(function (state) {
- var existingDecorator = state.get('decorator');
- var decorator = existingDecorator;
-
- if (put.decorator === null) {
- decorator = null;
- } else if (put.decorator) {
- decorator = put.decorator;
- }
-
- var newContent = put.currentContent || editorState.getCurrentContent();
-
- if (decorator !== existingDecorator) {
- var treeMap = state.get('treeMap');
- var newTreeMap;
-
- if (decorator && existingDecorator) {
- newTreeMap = regenerateTreeForNewDecorator(newContent, newContent.getBlockMap(), treeMap, decorator, existingDecorator);
- } else {
- newTreeMap = generateNewTreeMap(newContent, decorator);
- }
-
- state.merge({
- decorator: decorator,
- treeMap: newTreeMap,
- nativelyRenderedContent: null
- });
- return;
- }
-
- var existingContent = editorState.getCurrentContent();
-
- if (newContent !== existingContent) {
- state.set('treeMap', regenerateTreeForNewBlocks(editorState, newContent.getBlockMap(), newContent.getEntityMap(), decorator));
- }
-
- state.merge(put);
- });
- return new EditorState(map);
- };
-
- var _proto = EditorState.prototype;
-
- _proto.toJS = function toJS() {
- return this.getImmutable().toJS();
- };
-
- _proto.getAllowUndo = function getAllowUndo() {
- return this.getImmutable().get('allowUndo');
- };
-
- _proto.getCurrentContent = function getCurrentContent() {
- return this.getImmutable().get('currentContent');
- };
-
- _proto.getUndoStack = function getUndoStack() {
- return this.getImmutable().get('undoStack');
- };
-
- _proto.getRedoStack = function getRedoStack() {
- return this.getImmutable().get('redoStack');
- };
-
- _proto.getSelection = function getSelection() {
- return this.getImmutable().get('selection');
- };
-
- _proto.getDecorator = function getDecorator() {
- return this.getImmutable().get('decorator');
- };
-
- _proto.isInCompositionMode = function isInCompositionMode() {
- return this.getImmutable().get('inCompositionMode');
- };
-
- _proto.mustForceSelection = function mustForceSelection() {
- return this.getImmutable().get('forceSelection');
- };
-
- _proto.getNativelyRenderedContent = function getNativelyRenderedContent() {
- return this.getImmutable().get('nativelyRenderedContent');
- };
-
- _proto.getLastChangeType = function getLastChangeType() {
- return this.getImmutable().get('lastChangeType');
- }
- /**
- * While editing, the user may apply inline style commands with a collapsed
- * cursor, intending to type text that adopts the specified style. In this
- * case, we track the specified style as an "override" that takes precedence
- * over the inline style of the text adjacent to the cursor.
- *
- * If null, there is no override in place.
- */
- ;
-
- _proto.getInlineStyleOverride = function getInlineStyleOverride() {
- return this.getImmutable().get('inlineStyleOverride');
- };
-
- EditorState.setInlineStyleOverride = function setInlineStyleOverride(editorState, inlineStyleOverride) {
- return EditorState.set(editorState, {
- inlineStyleOverride: inlineStyleOverride
- });
- }
- /**
- * Get the appropriate inline style for the editor state. If an
- * override is in place, use it. Otherwise, the current style is
- * based on the location of the selection state.
- */
- ;
-
- _proto.getCurrentInlineStyle = function getCurrentInlineStyle() {
- var override = this.getInlineStyleOverride();
-
- if (override != null) {
- return override;
- }
-
- var content = this.getCurrentContent();
- var selection = this.getSelection();
-
- if (selection.isCollapsed()) {
- return getInlineStyleForCollapsedSelection(content, selection);
- }
-
- return getInlineStyleForNonCollapsedSelection(content, selection);
- };
-
- _proto.getBlockTree = function getBlockTree(blockKey) {
- return this.getImmutable().getIn(['treeMap', blockKey]);
- };
-
- _proto.isSelectionAtStartOfContent = function isSelectionAtStartOfContent() {
- var firstKey = this.getCurrentContent().getBlockMap().first().getKey();
- return this.getSelection().hasEdgeWithin(firstKey, 0, 0);
- };
-
- _proto.isSelectionAtEndOfContent = function isSelectionAtEndOfContent() {
- var content = this.getCurrentContent();
- var blockMap = content.getBlockMap();
- var last = blockMap.last();
- var end = last.getLength();
- return this.getSelection().hasEdgeWithin(last.getKey(), end, end);
- };
-
- _proto.getDirectionMap = function getDirectionMap() {
- return this.getImmutable().get('directionMap');
- }
- /**
- * Incorporate native DOM selection changes into the EditorState. This
- * method can be used when we simply want to accept whatever the DOM
- * has given us to represent selection, and we do not need to re-render
- * the editor.
- *
- * To forcibly move the DOM selection, see `EditorState.forceSelection`.
- */
- ;
-
- EditorState.acceptSelection = function acceptSelection(editorState, selection) {
- return updateSelection(editorState, selection, false);
- }
- /**
- * At times, we need to force the DOM selection to be where we
- * need it to be. This can occur when the anchor or focus nodes
- * are non-text nodes, for instance. In this case, we want to trigger
- * a re-render of the editor, which in turn forces selection into
- * the correct place in the DOM. The `forceSelection` method
- * accomplishes this.
- *
- * This method should be used in cases where you need to explicitly
- * move the DOM selection from one place to another without a change
- * in ContentState.
- */
- ;
-
- EditorState.forceSelection = function forceSelection(editorState, selection) {
- if (!selection.getHasFocus()) {
- selection = selection.set('hasFocus', true);
- }
-
- return updateSelection(editorState, selection, true);
- }
- /**
- * Move selection to the end of the editor without forcing focus.
- */
- ;
-
- EditorState.moveSelectionToEnd = function moveSelectionToEnd(editorState) {
- var content = editorState.getCurrentContent();
- var lastBlock = content.getLastBlock();
- var lastKey = lastBlock.getKey();
- var length = lastBlock.getLength();
- return EditorState.acceptSelection(editorState, new SelectionState({
- anchorKey: lastKey,
- anchorOffset: length,
- focusKey: lastKey,
- focusOffset: length,
- isBackward: false
- }));
- }
- /**
- * Force focus to the end of the editor. This is useful in scenarios
- * where we want to programmatically focus the input and it makes sense
- * to allow the user to continue working seamlessly.
- */
- ;
-
- EditorState.moveFocusToEnd = function moveFocusToEnd(editorState) {
- var afterSelectionMove = EditorState.moveSelectionToEnd(editorState);
- return EditorState.forceSelection(afterSelectionMove, afterSelectionMove.getSelection());
- }
- /**
- * Push the current ContentState onto the undo stack if it should be
- * considered a boundary state, and set the provided ContentState as the
- * new current content.
- */
- ;
-
- EditorState.push = function push(editorState, contentState, changeType) {
- var forceSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
-
- if (editorState.getCurrentContent() === contentState) {
- return editorState;
- }
-
- var directionMap = EditorBidiService.getDirectionMap(contentState, editorState.getDirectionMap());
-
- if (!editorState.getAllowUndo()) {
- return EditorState.set(editorState, {
- currentContent: contentState,
- directionMap: directionMap,
- lastChangeType: changeType,
- selection: contentState.getSelectionAfter(),
- forceSelection: forceSelection,
- inlineStyleOverride: null
- });
- }
-
- var selection = editorState.getSelection();
- var currentContent = editorState.getCurrentContent();
- var undoStack = editorState.getUndoStack();
- var newContent = contentState;
-
- if (selection !== currentContent.getSelectionAfter() || mustBecomeBoundary(editorState, changeType)) {
- undoStack = undoStack.push(currentContent);
- newContent = newContent.set('selectionBefore', selection);
- } else if (changeType === 'insert-characters' || changeType === 'backspace-character' || changeType === 'delete-character') {
- // Preserve the previous selection.
- newContent = newContent.set('selectionBefore', currentContent.getSelectionBefore());
- }
-
- var inlineStyleOverride = editorState.getInlineStyleOverride(); // Don't discard inline style overrides for the following change types:
-
- var overrideChangeTypes = ['adjust-depth', 'change-block-type', 'split-block'];
-
- if (overrideChangeTypes.indexOf(changeType) === -1) {
- inlineStyleOverride = null;
- }
-
- var editorStateChanges = {
- currentContent: newContent,
- directionMap: directionMap,
- undoStack: undoStack,
- redoStack: Stack(),
- lastChangeType: changeType,
- selection: contentState.getSelectionAfter(),
- forceSelection: forceSelection,
- inlineStyleOverride: inlineStyleOverride
- };
- return EditorState.set(editorState, editorStateChanges);
- }
- /**
- * Make the top ContentState in the undo stack the new current content and
- * push the current content onto the redo stack.
- */
- ;
-
- EditorState.undo = function undo(editorState) {
- if (!editorState.getAllowUndo()) {
- return editorState;
- }
-
- var undoStack = editorState.getUndoStack();
- var newCurrentContent = undoStack.peek();
-
- if (!newCurrentContent) {
- return editorState;
- }
-
- var currentContent = editorState.getCurrentContent();
- var directionMap = EditorBidiService.getDirectionMap(newCurrentContent, editorState.getDirectionMap());
- return EditorState.set(editorState, {
- currentContent: newCurrentContent,
- directionMap: directionMap,
- undoStack: undoStack.shift(),
- redoStack: editorState.getRedoStack().push(currentContent),
- forceSelection: true,
- inlineStyleOverride: null,
- lastChangeType: 'undo',
- nativelyRenderedContent: null,
- selection: currentContent.getSelectionBefore()
- });
- }
- /**
- * Make the top ContentState in the redo stack the new current content and
- * push the current content onto the undo stack.
- */
- ;
-
- EditorState.redo = function redo(editorState) {
- if (!editorState.getAllowUndo()) {
- return editorState;
- }
-
- var redoStack = editorState.getRedoStack();
- var newCurrentContent = redoStack.peek();
-
- if (!newCurrentContent) {
- return editorState;
- }
-
- var currentContent = editorState.getCurrentContent();
- var directionMap = EditorBidiService.getDirectionMap(newCurrentContent, editorState.getDirectionMap());
- return EditorState.set(editorState, {
- currentContent: newCurrentContent,
- directionMap: directionMap,
- undoStack: editorState.getUndoStack().push(currentContent),
- redoStack: redoStack.shift(),
- forceSelection: true,
- inlineStyleOverride: null,
- lastChangeType: 'redo',
- nativelyRenderedContent: null,
- selection: newCurrentContent.getSelectionAfter()
- });
- }
- /**
- * Not for public consumption.
- */
- ;
-
- function EditorState(immutable) {
- _defineProperty(this, "_immutable", void 0);
-
- this._immutable = immutable;
- }
- /**
- * Not for public consumption.
- */
-
-
- _proto.getImmutable = function getImmutable() {
- return this._immutable;
- };
-
- return EditorState;
- }();
- /**
- * Set the supplied SelectionState as the new current selection, and set
- * the `force` flag to trigger manual selection placement by the view.
- */
-
-
- function updateSelection(editorState, selection, forceSelection) {
- return EditorState.set(editorState, {
- selection: selection,
- forceSelection: forceSelection,
- nativelyRenderedContent: null,
- inlineStyleOverride: null
- });
- }
- /**
- * Regenerate the entire tree map for a given ContentState and decorator.
- * Returns an OrderedMap that maps all available ContentBlock objects.
- */
-
-
- function generateNewTreeMap(contentState, decorator) {
- return contentState.getBlockMap().map(function (block) {
- return BlockTree.generate(contentState, block, decorator);
- }).toOrderedMap();
- }
- /**
- * Regenerate tree map objects for all ContentBlocks that have changed
- * between the current editorState and newContent. Returns an OrderedMap
- * with only changed regenerated tree map objects.
- */
-
-
- function regenerateTreeForNewBlocks(editorState, newBlockMap, newEntityMap, decorator) {
- var contentState = editorState.getCurrentContent().set('entityMap', newEntityMap);
- var prevBlockMap = contentState.getBlockMap();
- var prevTreeMap = editorState.getImmutable().get('treeMap');
- return prevTreeMap.merge(newBlockMap.toSeq().filter(function (block, key) {
- return block !== prevBlockMap.get(key);
- }).map(function (block) {
- return BlockTree.generate(contentState, block, decorator);
- }));
- }
- /**
- * Generate tree map objects for a new decorator object, preserving any
- * decorations that are unchanged from the previous decorator.
- *
- * Note that in order for this to perform optimally, decoration Lists for
- * decorators should be preserved when possible to allow for direct immutable
- * List comparison.
- */
-
-
- function regenerateTreeForNewDecorator(content, blockMap, previousTreeMap, decorator, existingDecorator) {
- return previousTreeMap.merge(blockMap.toSeq().filter(function (block) {
- return decorator.getDecorations(block, content) !== existingDecorator.getDecorations(block, content);
- }).map(function (block) {
- return BlockTree.generate(content, block, decorator);
- }));
- }
- /**
- * Return whether a change should be considered a boundary state, given
- * the previous change type. Allows us to discard potential boundary states
- * during standard typing or deletion behavior.
- */
-
-
- function mustBecomeBoundary(editorState, changeType) {
- var lastChangeType = editorState.getLastChangeType();
- return changeType !== lastChangeType || changeType !== 'insert-characters' && changeType !== 'backspace-character' && changeType !== 'delete-character';
- }
-
- function getInlineStyleForCollapsedSelection(content, selection) {
- var startKey = selection.getStartKey();
- var startOffset = selection.getStartOffset();
- var startBlock = content.getBlockForKey(startKey); // If the cursor is not at the start of the block, look backward to
- // preserve the style of the preceding character.
-
- if (startOffset > 0) {
- return startBlock.getInlineStyleAt(startOffset - 1);
- } // The caret is at position zero in this block. If the block has any
- // text at all, use the style of the first character.
-
-
- if (startBlock.getLength()) {
- return startBlock.getInlineStyleAt(0);
- } // Otherwise, look upward in the document to find the closest character.
-
-
- return lookUpwardForInlineStyle(content, startKey);
- }
-
- function getInlineStyleForNonCollapsedSelection(content, selection) {
- var startKey = selection.getStartKey();
- var startOffset = selection.getStartOffset();
- var startBlock = content.getBlockForKey(startKey); // If there is a character just inside the selection, use its style.
-
- if (startOffset < startBlock.getLength()) {
- return startBlock.getInlineStyleAt(startOffset);
- } // Check if the selection at the end of a non-empty block. Use the last
- // style in the block.
-
-
- if (startOffset > 0) {
- return startBlock.getInlineStyleAt(startOffset - 1);
- } // Otherwise, look upward in the document to find the closest character.
-
-
- return lookUpwardForInlineStyle(content, startKey);
- }
-
- function lookUpwardForInlineStyle(content, fromKey) {
- var lastNonEmpty = content.getBlockMap().reverse().skipUntil(function (_, k) {
- return k === fromKey;
- }).skip(1).skipUntil(function (block, _) {
- return block.getLength();
- }).first();
-
- if (lastNonEmpty) {
- return lastNonEmpty.getInlineStyleAt(lastNonEmpty.getLength() - 1);
- }
-
- return OrderedSet();
- }
-
- module.exports = EditorState;
-
- /***/ }),
- /* 3 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var CharacterMetadata = __webpack_require__(6);
-
- var ContentStateInlineStyle = __webpack_require__(80);
-
- var applyEntityToContentState = __webpack_require__(81);
-
- var getCharacterRemovalRange = __webpack_require__(83);
-
- var getContentStateFragment = __webpack_require__(21);
-
- var Immutable = __webpack_require__(0);
-
- var insertFragmentIntoContentState = __webpack_require__(86);
-
- var insertTextIntoContentState = __webpack_require__(87);
-
- var invariant = __webpack_require__(1);
-
- var modifyBlockForContentState = __webpack_require__(44);
-
- var removeEntitiesAtEdges = __webpack_require__(42);
-
- var removeRangeFromContentState = __webpack_require__(88);
-
- var splitBlockInContentState = __webpack_require__(89);
-
- var OrderedSet = Immutable.OrderedSet;
- /**
- * `DraftModifier` provides a set of convenience methods that apply
- * modifications to a `ContentState` object based on a target `SelectionState`.
- *
- * Any change to a `ContentState` should be decomposable into a series of
- * transaction functions that apply the required changes and return output
- * `ContentState` objects.
- *
- * These functions encapsulate some of the most common transaction sequences.
- */
-
- var DraftModifier = {
- replaceText: function replaceText(contentState, rangeToReplace, text, inlineStyle, entityKey) {
- var withoutEntities = removeEntitiesAtEdges(contentState, rangeToReplace);
- var withoutText = removeRangeFromContentState(withoutEntities, rangeToReplace);
- var character = CharacterMetadata.create({
- style: inlineStyle || OrderedSet(),
- entity: entityKey || null
- });
- return insertTextIntoContentState(withoutText, withoutText.getSelectionAfter(), text, character);
- },
- insertText: function insertText(contentState, targetRange, text, inlineStyle, entityKey) {
- !targetRange.isCollapsed() ? true ? invariant(false, 'Target range must be collapsed for `insertText`.') : invariant(false) : void 0;
- return DraftModifier.replaceText(contentState, targetRange, text, inlineStyle, entityKey);
- },
- moveText: function moveText(contentState, removalRange, targetRange) {
- var movedFragment = getContentStateFragment(contentState, removalRange);
- var afterRemoval = DraftModifier.removeRange(contentState, removalRange, 'backward');
- return DraftModifier.replaceWithFragment(afterRemoval, targetRange, movedFragment);
- },
- replaceWithFragment: function replaceWithFragment(contentState, targetRange, fragment) {
- var mergeBlockData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'REPLACE_WITH_NEW_DATA';
- var withoutEntities = removeEntitiesAtEdges(contentState, targetRange);
- var withoutText = removeRangeFromContentState(withoutEntities, targetRange);
- return insertFragmentIntoContentState(withoutText, withoutText.getSelectionAfter(), fragment, mergeBlockData);
- },
- removeRange: function removeRange(contentState, rangeToRemove, removalDirection) {
- var startKey, endKey, startBlock, endBlock;
-
- if (rangeToRemove.getIsBackward()) {
- rangeToRemove = rangeToRemove.merge({
- anchorKey: rangeToRemove.getFocusKey(),
- anchorOffset: rangeToRemove.getFocusOffset(),
- focusKey: rangeToRemove.getAnchorKey(),
- focusOffset: rangeToRemove.getAnchorOffset(),
- isBackward: false
- });
- }
-
- startKey = rangeToRemove.getAnchorKey();
- endKey = rangeToRemove.getFocusKey();
- startBlock = contentState.getBlockForKey(startKey);
- endBlock = contentState.getBlockForKey(endKey);
- var startOffset = rangeToRemove.getStartOffset();
- var endOffset = rangeToRemove.getEndOffset();
- var startEntityKey = startBlock.getEntityAt(startOffset);
- var endEntityKey = endBlock.getEntityAt(endOffset - 1); // Check whether the selection state overlaps with a single entity.
- // If so, try to remove the appropriate substring of the entity text.
-
- if (startKey === endKey) {
- if (startEntityKey && startEntityKey === endEntityKey) {
- var adjustedRemovalRange = getCharacterRemovalRange(contentState.getEntityMap(), startBlock, endBlock, rangeToRemove, removalDirection);
- return removeRangeFromContentState(contentState, adjustedRemovalRange);
- }
- }
-
- var withoutEntities = removeEntitiesAtEdges(contentState, rangeToRemove);
- return removeRangeFromContentState(withoutEntities, rangeToRemove);
- },
- splitBlock: function splitBlock(contentState, selectionState) {
- var withoutEntities = removeEntitiesAtEdges(contentState, selectionState);
- var withoutText = removeRangeFromContentState(withoutEntities, selectionState);
- return splitBlockInContentState(withoutText, withoutText.getSelectionAfter());
- },
- applyInlineStyle: function applyInlineStyle(contentState, selectionState, inlineStyle) {
- return ContentStateInlineStyle.add(contentState, selectionState, inlineStyle);
- },
- removeInlineStyle: function removeInlineStyle(contentState, selectionState, inlineStyle) {
- return ContentStateInlineStyle.remove(contentState, selectionState, inlineStyle);
- },
- setBlockType: function setBlockType(contentState, selectionState, blockType) {
- return modifyBlockForContentState(contentState, selectionState, function (block) {
- return block.merge({
- type: blockType,
- depth: 0
- });
- });
- },
- setBlockData: function setBlockData(contentState, selectionState, blockData) {
- return modifyBlockForContentState(contentState, selectionState, function (block) {
- return block.merge({
- data: blockData
- });
- });
- },
- mergeBlockData: function mergeBlockData(contentState, selectionState, blockData) {
- return modifyBlockForContentState(contentState, selectionState, function (block) {
- return block.merge({
- data: block.getData().merge(blockData)
- });
- });
- },
- applyEntity: function applyEntity(contentState, selectionState, entityKey) {
- var withoutEntities = removeEntitiesAtEdges(contentState, selectionState);
- return applyEntityToContentState(withoutEntities, selectionState, entityKey);
- }
- };
- module.exports = DraftModifier;
-
- /***/ }),
- /* 4 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- */
- var nullthrows = function nullthrows(x) {
- if (x != null) {
- return x;
- }
-
- throw new Error("Got unexpected null or undefined");
- };
-
- module.exports = nullthrows;
-
- /***/ }),
- /* 5 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
-
-
- var UserAgentData = __webpack_require__(98);
-
- var VersionRange = __webpack_require__(101);
-
- var mapObject = __webpack_require__(102);
-
- var memoizeStringOnly = __webpack_require__(103);
- /**
- * Checks to see whether `name` and `version` satisfy `query`.
- *
- * @param {string} name Name of the browser, device, engine or platform
- * @param {?string} version Version of the browser, engine or platform
- * @param {string} query Query of form "Name [range expression]"
- * @param {?function} normalizer Optional pre-processor for range expression
- * @return {boolean}
- */
-
-
- function compare(name, version, query, normalizer) {
- // check for exact match with no version
- if (name === query) {
- return true;
- } // check for non-matching names
-
-
- if (!query.startsWith(name)) {
- return false;
- } // full comparison with version
-
-
- var range = query.slice(name.length);
-
- if (version) {
- range = normalizer ? normalizer(range) : range;
- return VersionRange.contains(range, version);
- }
-
- return false;
- }
- /**
- * Normalizes `version` by stripping any "NT" prefix, but only on the Windows
- * platform.
- *
- * Mimics the stripping performed by the `UserAgentWindowsPlatform` PHP class.
- *
- * @param {string} version
- * @return {string}
- */
-
-
- function normalizePlatformVersion(version) {
- if (UserAgentData.platformName === 'Windows') {
- return version.replace(/^\s*NT/, '');
- }
-
- return version;
- }
- /**
- * Provides client-side access to the authoritative PHP-generated User Agent
- * information supplied by the server.
- */
-
-
- var UserAgent = {
- /**
- * Check if the User Agent browser matches `query`.
- *
- * `query` should be a string like "Chrome" or "Chrome > 33".
- *
- * Valid browser names include:
- *
- * - ACCESS NetFront
- * - AOL
- * - Amazon Silk
- * - Android
- * - BlackBerry
- * - BlackBerry PlayBook
- * - Chrome
- * - Chrome for iOS
- * - Chrome frame
- * - Facebook PHP SDK
- * - Facebook for iOS
- * - Firefox
- * - IE
- * - IE Mobile
- * - Mobile Safari
- * - Motorola Internet Browser
- * - Nokia
- * - Openwave Mobile Browser
- * - Opera
- * - Opera Mini
- * - Opera Mobile
- * - Safari
- * - UIWebView
- * - Unknown
- * - webOS
- * - etc...
- *
- * An authoritative list can be found in the PHP `BrowserDetector` class and
- * related classes in the same file (see calls to `new UserAgentBrowser` here:
- * https://fburl.com/50728104).
- *
- * @note Function results are memoized
- *
- * @param {string} query Query of the form "Name [range expression]"
- * @return {boolean}
- */
- isBrowser: function isBrowser(query) {
- return compare(UserAgentData.browserName, UserAgentData.browserFullVersion, query);
- },
-
- /**
- * Check if the User Agent browser uses a 32 or 64 bit architecture.
- *
- * @note Function results are memoized
- *
- * @param {string} query Query of the form "32" or "64".
- * @return {boolean}
- */
- isBrowserArchitecture: function isBrowserArchitecture(query) {
- return compare(UserAgentData.browserArchitecture, null, query);
- },
-
- /**
- * Check if the User Agent device matches `query`.
- *
- * `query` should be a string like "iPhone" or "iPad".
- *
- * Valid device names include:
- *
- * - Kindle
- * - Kindle Fire
- * - Unknown
- * - iPad
- * - iPhone
- * - iPod
- * - etc...
- *
- * An authoritative list can be found in the PHP `DeviceDetector` class and
- * related classes in the same file (see calls to `new UserAgentDevice` here:
- * https://fburl.com/50728332).
- *
- * @note Function results are memoized
- *
- * @param {string} query Query of the form "Name"
- * @return {boolean}
- */
- isDevice: function isDevice(query) {
- return compare(UserAgentData.deviceName, null, query);
- },
-
- /**
- * Check if the User Agent rendering engine matches `query`.
- *
- * `query` should be a string like "WebKit" or "WebKit >= 537".
- *
- * Valid engine names include:
- *
- * - Gecko
- * - Presto
- * - Trident
- * - WebKit
- * - etc...
- *
- * An authoritative list can be found in the PHP `RenderingEngineDetector`
- * class related classes in the same file (see calls to `new
- * UserAgentRenderingEngine` here: https://fburl.com/50728617).
- *
- * @note Function results are memoized
- *
- * @param {string} query Query of the form "Name [range expression]"
- * @return {boolean}
- */
- isEngine: function isEngine(query) {
- return compare(UserAgentData.engineName, UserAgentData.engineVersion, query);
- },
-
- /**
- * Check if the User Agent platform matches `query`.
- *
- * `query` should be a string like "Windows" or "iOS 5 - 6".
- *
- * Valid platform names include:
- *
- * - Android
- * - BlackBerry OS
- * - Java ME
- * - Linux
- * - Mac OS X
- * - Mac OS X Calendar
- * - Mac OS X Internet Account
- * - Symbian
- * - SymbianOS
- * - Windows
- * - Windows Mobile
- * - Windows Phone
- * - iOS
- * - iOS Facebook Integration Account
- * - iOS Facebook Social Sharing UI
- * - webOS
- * - Chrome OS
- * - etc...
- *
- * An authoritative list can be found in the PHP `PlatformDetector` class and
- * related classes in the same file (see calls to `new UserAgentPlatform`
- * here: https://fburl.com/50729226).
- *
- * @note Function results are memoized
- *
- * @param {string} query Query of the form "Name [range expression]"
- * @return {boolean}
- */
- isPlatform: function isPlatform(query) {
- return compare(UserAgentData.platformName, UserAgentData.platformFullVersion, query, normalizePlatformVersion);
- },
-
- /**
- * Check if the User Agent platform is a 32 or 64 bit architecture.
- *
- * @note Function results are memoized
- *
- * @param {string} query Query of the form "32" or "64".
- * @return {boolean}
- */
- isPlatformArchitecture: function isPlatformArchitecture(query) {
- return compare(UserAgentData.platformArchitecture, null, query);
- }
- };
- module.exports = mapObject(UserAgent, memoizeStringOnly);
-
- /***/ }),
- /* 6 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- var _require = __webpack_require__(0),
- Map = _require.Map,
- OrderedSet = _require.OrderedSet,
- Record = _require.Record; // Immutable.map is typed such that the value for every key in the map
- // must be the same type
-
-
- var EMPTY_SET = OrderedSet();
- var defaultRecord = {
- style: EMPTY_SET,
- entity: null
- };
- var CharacterMetadataRecord = Record(defaultRecord);
-
- var CharacterMetadata =
- /*#__PURE__*/
- function (_CharacterMetadataRec) {
- _inheritsLoose(CharacterMetadata, _CharacterMetadataRec);
-
- function CharacterMetadata() {
- return _CharacterMetadataRec.apply(this, arguments) || this;
- }
-
- var _proto = CharacterMetadata.prototype;
-
- _proto.getStyle = function getStyle() {
- return this.get('style');
- };
-
- _proto.getEntity = function getEntity() {
- return this.get('entity');
- };
-
- _proto.hasStyle = function hasStyle(style) {
- return this.getStyle().includes(style);
- };
-
- CharacterMetadata.applyStyle = function applyStyle(record, style) {
- var withStyle = record.set('style', record.getStyle().add(style));
- return CharacterMetadata.create(withStyle);
- };
-
- CharacterMetadata.removeStyle = function removeStyle(record, style) {
- var withoutStyle = record.set('style', record.getStyle().remove(style));
- return CharacterMetadata.create(withoutStyle);
- };
-
- CharacterMetadata.applyEntity = function applyEntity(record, entityKey) {
- var withEntity = record.getEntity() === entityKey ? record : record.set('entity', entityKey);
- return CharacterMetadata.create(withEntity);
- }
- /**
- * Use this function instead of the `CharacterMetadata` constructor.
- * Since most content generally uses only a very small number of
- * style/entity permutations, we can reuse these objects as often as
- * possible.
- */
- ;
-
- CharacterMetadata.create = function create(config) {
- if (!config) {
- return EMPTY;
- }
-
- var defaultConfig = {
- style: EMPTY_SET,
- entity: null
- }; // Fill in unspecified properties, if necessary.
-
- var configMap = Map(defaultConfig).merge(config);
- var existing = pool.get(configMap);
-
- if (existing) {
- return existing;
- }
-
- var newCharacter = new CharacterMetadata(configMap);
- pool = pool.set(configMap, newCharacter);
- return newCharacter;
- };
-
- return CharacterMetadata;
- }(CharacterMetadataRecord);
-
- var EMPTY = new CharacterMetadata();
- var pool = Map([[Map(defaultRecord), EMPTY]]);
- CharacterMetadata.EMPTY = EMPTY;
- module.exports = CharacterMetadata;
-
- /***/ }),
- /* 7 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- *
- * This file is a fork of ContentBlock adding support for nesting references by
- * providing links to children, parent, prevSibling, and nextSibling.
- *
- * This is unstable and not part of the public API and should not be used by
- * production systems. This file may be update/removed without notice.
- */
-
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- var CharacterMetadata = __webpack_require__(6);
-
- var findRangesImmutable = __webpack_require__(18);
-
- var Immutable = __webpack_require__(0);
-
- var List = Immutable.List,
- Map = Immutable.Map,
- OrderedSet = Immutable.OrderedSet,
- Record = Immutable.Record,
- Repeat = Immutable.Repeat;
- var EMPTY_SET = OrderedSet();
- var defaultRecord = {
- parent: null,
- characterList: List(),
- data: Map(),
- depth: 0,
- key: '',
- text: '',
- type: 'unstyled',
- children: List(),
- prevSibling: null,
- nextSibling: null
- };
-
- var haveEqualStyle = function haveEqualStyle(charA, charB) {
- return charA.getStyle() === charB.getStyle();
- };
-
- var haveEqualEntity = function haveEqualEntity(charA, charB) {
- return charA.getEntity() === charB.getEntity();
- };
-
- var decorateCharacterList = function decorateCharacterList(config) {
- if (!config) {
- return config;
- }
-
- var characterList = config.characterList,
- text = config.text;
-
- if (text && !characterList) {
- config.characterList = List(Repeat(CharacterMetadata.EMPTY, text.length));
- }
-
- return config;
- };
-
- var ContentBlockNode =
- /*#__PURE__*/
- function (_ref) {
- _inheritsLoose(ContentBlockNode, _ref);
-
- function ContentBlockNode() {
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultRecord;
-
- /* eslint-disable-next-line constructor-super */
- return _ref.call(this, decorateCharacterList(props)) || this;
- }
-
- var _proto = ContentBlockNode.prototype;
-
- _proto.getKey = function getKey() {
- return this.get('key');
- };
-
- _proto.getType = function getType() {
- return this.get('type');
- };
-
- _proto.getText = function getText() {
- return this.get('text');
- };
-
- _proto.getCharacterList = function getCharacterList() {
- return this.get('characterList');
- };
-
- _proto.getLength = function getLength() {
- return this.getText().length;
- };
-
- _proto.getDepth = function getDepth() {
- return this.get('depth');
- };
-
- _proto.getData = function getData() {
- return this.get('data');
- };
-
- _proto.getInlineStyleAt = function getInlineStyleAt(offset) {
- var character = this.getCharacterList().get(offset);
- return character ? character.getStyle() : EMPTY_SET;
- };
-
- _proto.getEntityAt = function getEntityAt(offset) {
- var character = this.getCharacterList().get(offset);
- return character ? character.getEntity() : null;
- };
-
- _proto.getChildKeys = function getChildKeys() {
- return this.get('children');
- };
-
- _proto.getParentKey = function getParentKey() {
- return this.get('parent');
- };
-
- _proto.getPrevSiblingKey = function getPrevSiblingKey() {
- return this.get('prevSibling');
- };
-
- _proto.getNextSiblingKey = function getNextSiblingKey() {
- return this.get('nextSibling');
- };
-
- _proto.findStyleRanges = function findStyleRanges(filterFn, callback) {
- findRangesImmutable(this.getCharacterList(), haveEqualStyle, filterFn, callback);
- };
-
- _proto.findEntityRanges = function findEntityRanges(filterFn, callback) {
- findRangesImmutable(this.getCharacterList(), haveEqualEntity, filterFn, callback);
- };
-
- return ContentBlockNode;
- }(Record(defaultRecord));
-
- module.exports = ContentBlockNode;
-
- /***/ }),
- /* 8 */
- /***/ (function(module, exports) {
-
- module.exports = __WEBPACK_EXTERNAL_MODULE_8__;
-
- /***/ }),
- /* 9 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var seenKeys = {};
- var MULTIPLIER = Math.pow(2, 24);
-
- function generateRandomKey() {
- var key;
-
- while (key === undefined || seenKeys.hasOwnProperty(key) || !isNaN(+key)) {
- key = Math.floor(Math.random() * MULTIPLIER).toString(32);
- }
-
- seenKeys[key] = true;
- return key;
- }
-
- module.exports = generateRandomKey;
-
- /***/ }),
- /* 10 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var KEY_DELIMITER = '-';
- var DraftOffsetKey = {
- encode: function encode(blockKey, decoratorKey, leafKey) {
- return blockKey + KEY_DELIMITER + decoratorKey + KEY_DELIMITER + leafKey;
- },
- decode: function decode(offsetKey) {
- // Extracts the last two parts of offsetKey and captures the rest in blockKeyParts
- var _offsetKey$split$reve = offsetKey.split(KEY_DELIMITER).reverse(),
- leafKey = _offsetKey$split$reve[0],
- decoratorKey = _offsetKey$split$reve[1],
- blockKeyParts = _offsetKey$split$reve.slice(2);
-
- return {
- // Recomposes the parts of blockKey after reversing them
- blockKey: blockKeyParts.reverse().join(KEY_DELIMITER),
- decoratorKey: parseInt(decoratorKey, 10),
- leafKey: parseInt(leafKey, 10)
- };
- }
- };
- module.exports = DraftOffsetKey;
-
- /***/ }),
- /* 11 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- */
-
-
- module.exports = function (name) {
- if (typeof window !== 'undefined' && window.__DRAFT_GKX) {
- return !!window.__DRAFT_GKX[name];
- }
-
- return false;
- };
-
- /***/ }),
- /* 12 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- var CharacterMetadata = __webpack_require__(6);
-
- var findRangesImmutable = __webpack_require__(18);
-
- var Immutable = __webpack_require__(0);
-
- var List = Immutable.List,
- Map = Immutable.Map,
- OrderedSet = Immutable.OrderedSet,
- Record = Immutable.Record,
- Repeat = Immutable.Repeat;
- var EMPTY_SET = OrderedSet();
- var defaultRecord = {
- key: '',
- type: 'unstyled',
- text: '',
- characterList: List(),
- depth: 0,
- data: Map()
- };
- var ContentBlockRecord = Record(defaultRecord);
-
- var decorateCharacterList = function decorateCharacterList(config) {
- if (!config) {
- return config;
- }
-
- var characterList = config.characterList,
- text = config.text;
-
- if (text && !characterList) {
- config.characterList = List(Repeat(CharacterMetadata.EMPTY, text.length));
- }
-
- return config;
- };
-
- var ContentBlock =
- /*#__PURE__*/
- function (_ContentBlockRecord) {
- _inheritsLoose(ContentBlock, _ContentBlockRecord);
-
- function ContentBlock(config) {
- return _ContentBlockRecord.call(this, decorateCharacterList(config)) || this;
- }
-
- var _proto = ContentBlock.prototype;
-
- _proto.getKey = function getKey() {
- return this.get('key');
- };
-
- _proto.getType = function getType() {
- return this.get('type');
- };
-
- _proto.getText = function getText() {
- return this.get('text');
- };
-
- _proto.getCharacterList = function getCharacterList() {
- return this.get('characterList');
- };
-
- _proto.getLength = function getLength() {
- return this.getText().length;
- };
-
- _proto.getDepth = function getDepth() {
- return this.get('depth');
- };
-
- _proto.getData = function getData() {
- return this.get('data');
- };
-
- _proto.getInlineStyleAt = function getInlineStyleAt(offset) {
- var character = this.getCharacterList().get(offset);
- return character ? character.getStyle() : EMPTY_SET;
- };
-
- _proto.getEntityAt = function getEntityAt(offset) {
- var character = this.getCharacterList().get(offset);
- return character ? character.getEntity() : null;
- }
- /**
- * Execute a callback for every contiguous range of styles within the block.
- */
- ;
-
- _proto.findStyleRanges = function findStyleRanges(filterFn, callback) {
- findRangesImmutable(this.getCharacterList(), haveEqualStyle, filterFn, callback);
- }
- /**
- * Execute a callback for every contiguous range of entities within the block.
- */
- ;
-
- _proto.findEntityRanges = function findEntityRanges(filterFn, callback) {
- findRangesImmutable(this.getCharacterList(), haveEqualEntity, filterFn, callback);
- };
-
- return ContentBlock;
- }(ContentBlockRecord);
-
- function haveEqualStyle(charA, charB) {
- return charA.getStyle() === charB.getStyle();
- }
-
- function haveEqualEntity(charA, charB) {
- return charA.getEntity() === charB.getEntity();
- }
-
- module.exports = ContentBlock;
-
- /***/ }),
- /* 13 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
-
- /**
- * This function is used to mark string literals representing CSS class names
- * so that they can be transformed statically. This allows for modularization
- * and minification of CSS class names.
- *
- * In static_upstream, this function is actually implemented, but it should
- * eventually be replaced with something more descriptive, and the transform
- * that is used in the main stack should be ported for use elsewhere.
- *
- * @param string|object className to modularize, or an object of key/values.
- * In the object case, the values are conditions that
- * determine if the className keys should be included.
- * @param [string ...] Variable list of classNames in the string case.
- * @return string Renderable space-separated CSS className.
- */
- function cx(classNames) {
- if (typeof classNames == 'object') {
- return Object.keys(classNames).filter(function (className) {
- return classNames[className];
- }).map(replace).join(' ');
- }
-
- return Array.prototype.map.call(arguments, replace).join(' ');
- }
-
- function replace(str) {
- return str.replace(/\//g, '-');
- }
-
- module.exports = cx;
-
- /***/ }),
- /* 14 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /*
- object-assign
- (c) Sindre Sorhus
- @license MIT
- */
-
-
- /* eslint-disable no-unused-vars */
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
-
- function toObject(val) {
- if (val === null || val === undefined) {
- throw new TypeError('Object.assign cannot be called with null or undefined');
- }
-
- return Object(val);
- }
-
- function shouldUseNative() {
- try {
- if (!Object.assign) {
- return false;
- }
-
- // Detect buggy property enumeration order in older V8 versions.
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
- test1[5] = 'de';
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test2 = {};
- for (var i = 0; i < 10; i++) {
- test2['_' + String.fromCharCode(i)] = i;
- }
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
- return test2[n];
- });
- if (order2.join('') !== '0123456789') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test3 = {};
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
- test3[letter] = letter;
- });
- if (Object.keys(Object.assign({}, test3)).join('') !==
- 'abcdefghijklmnopqrst') {
- return false;
- }
-
- return true;
- } catch (err) {
- // We don't expect any of the above to throw, but better to be safe.
- return false;
- }
- }
-
- module.exports = shouldUseNative() ? Object.assign : function (target, source) {
- var from;
- var to = toObject(target);
- var symbols;
-
- for (var s = 1; s < arguments.length; s++) {
- from = Object(arguments[s]);
-
- for (var key in from) {
- if (hasOwnProperty.call(from, key)) {
- to[key] = from[key];
- }
- }
-
- if (getOwnPropertySymbols) {
- symbols = getOwnPropertySymbols(from);
- for (var i = 0; i < symbols.length; i++) {
- if (propIsEnumerable.call(from, symbols[i])) {
- to[symbols[i]] = from[symbols[i]];
- }
- }
- }
- }
-
- return to;
- };
-
-
- /***/ }),
- /* 15 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
- function isElement(node) {
- if (!node || !node.ownerDocument) {
- return false;
- }
-
- return node.nodeType === Node.ELEMENT_NODE;
- }
-
- module.exports = isElement;
-
- /***/ }),
- /* 16 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
- /**
- * Unicode-enabled replacesments for basic String functions.
- *
- * All the functions in this module assume that the input string is a valid
- * UTF-16 encoding of a Unicode sequence. If it's not the case, the behavior
- * will be undefined.
- *
- * WARNING: Since this module is typechecks-enforced, you may find new bugs
- * when replacing normal String functions with ones provided here.
- */
-
-
- var invariant = __webpack_require__(1); // These two ranges are consecutive so anything in [HIGH_START, LOW_END] is a
- // surrogate code unit.
-
-
- var SURROGATE_HIGH_START = 0xD800;
- var SURROGATE_HIGH_END = 0xDBFF;
- var SURROGATE_LOW_START = 0xDC00;
- var SURROGATE_LOW_END = 0xDFFF;
- var SURROGATE_UNITS_REGEX = /[\uD800-\uDFFF]/;
- /**
- * @param {number} codeUnit A Unicode code-unit, in range [0, 0x10FFFF]
- * @return {boolean} Whether code-unit is in a surrogate (hi/low) range
- */
-
- function isCodeUnitInSurrogateRange(codeUnit) {
- return SURROGATE_HIGH_START <= codeUnit && codeUnit <= SURROGATE_LOW_END;
- }
- /**
- * Returns whether the two characters starting at `index` form a surrogate pair.
- * For example, given the string s = "\uD83D\uDE0A", (s, 0) returns true and
- * (s, 1) returns false.
- *
- * @param {string} str
- * @param {number} index
- * @return {boolean}
- */
-
-
- function isSurrogatePair(str, index) {
- !(0 <= index && index < str.length) ? true ? invariant(false, 'isSurrogatePair: Invalid index %s for string length %s.', index, str.length) : invariant(false) : void 0;
-
- if (index + 1 === str.length) {
- return false;
- }
-
- var first = str.charCodeAt(index);
- var second = str.charCodeAt(index + 1);
- return SURROGATE_HIGH_START <= first && first <= SURROGATE_HIGH_END && SURROGATE_LOW_START <= second && second <= SURROGATE_LOW_END;
- }
- /**
- * @param {string} str Non-empty string
- * @return {boolean} True if the input includes any surrogate code units
- */
-
-
- function hasSurrogateUnit(str) {
- return SURROGATE_UNITS_REGEX.test(str);
- }
- /**
- * Return the length of the original Unicode character at given position in the
- * String by looking into the UTF-16 code unit; that is equal to 1 for any
- * non-surrogate characters in BMP ([U+0000..U+D7FF] and [U+E000, U+FFFF]); and
- * returns 2 for the hi/low surrogates ([U+D800..U+DFFF]), which are in fact
- * representing non-BMP characters ([U+10000..U+10FFFF]).
- *
- * Examples:
- * - '\u0020' => 1
- * - '\u3020' => 1
- * - '\uD835' => 2
- * - '\uD835\uDDEF' => 2
- * - '\uDDEF' => 2
- *
- * @param {string} str Non-empty string
- * @param {number} pos Position in the string to look for one code unit
- * @return {number} Number 1 or 2
- */
-
-
- function getUTF16Length(str, pos) {
- return 1 + isCodeUnitInSurrogateRange(str.charCodeAt(pos));
- }
- /**
- * Fully Unicode-enabled replacement for String#length
- *
- * @param {string} str Valid Unicode string
- * @return {number} The number of Unicode characters in the string
- */
-
-
- function strlen(str) {
- // Call the native functions if there's no surrogate char
- if (!hasSurrogateUnit(str)) {
- return str.length;
- }
-
- var len = 0;
-
- for (var pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) {
- len++;
- }
-
- return len;
- }
- /**
- * Fully Unicode-enabled replacement for String#substr()
- *
- * @param {string} str Valid Unicode string
- * @param {number} start Location in Unicode sequence to begin extracting
- * @param {?number} length The number of Unicode characters to extract
- * (default: to the end of the string)
- * @return {string} Extracted sub-string
- */
-
-
- function substr(str, start, length) {
- start = start || 0;
- length = length === undefined ? Infinity : length || 0; // Call the native functions if there's no surrogate char
-
- if (!hasSurrogateUnit(str)) {
- return str.substr(start, length);
- } // Obvious cases
-
-
- var size = str.length;
-
- if (size <= 0 || start > size || length <= 0) {
- return '';
- } // Find the actual starting position
-
-
- var posA = 0;
-
- if (start > 0) {
- for (; start > 0 && posA < size; start--) {
- posA += getUTF16Length(str, posA);
- }
-
- if (posA >= size) {
- return '';
- }
- } else if (start < 0) {
- for (posA = size; start < 0 && 0 < posA; start++) {
- posA -= getUTF16Length(str, posA - 1);
- }
-
- if (posA < 0) {
- posA = 0;
- }
- } // Find the actual ending position
-
-
- var posB = size;
-
- if (length < size) {
- for (posB = posA; length > 0 && posB < size; length--) {
- posB += getUTF16Length(str, posB);
- }
- }
-
- return str.substring(posA, posB);
- }
- /**
- * Fully Unicode-enabled replacement for String#substring()
- *
- * @param {string} str Valid Unicode string
- * @param {number} start Location in Unicode sequence to begin extracting
- * @param {?number} end Location in Unicode sequence to end extracting
- * (default: end of the string)
- * @return {string} Extracted sub-string
- */
-
-
- function substring(str, start, end) {
- start = start || 0;
- end = end === undefined ? Infinity : end || 0;
-
- if (start < 0) {
- start = 0;
- }
-
- if (end < 0) {
- end = 0;
- }
-
- var length = Math.abs(end - start);
- start = start < end ? start : end;
- return substr(str, start, length);
- }
- /**
- * Get a list of Unicode code-points from a String
- *
- * @param {string} str Valid Unicode string
- * @return {array<number>} A list of code-points in [0..0x10FFFF]
- */
-
-
- function getCodePoints(str) {
- var codePoints = [];
-
- for (var pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) {
- codePoints.push(str.codePointAt(pos));
- }
-
- return codePoints;
- }
-
- var UnicodeUtils = {
- getCodePoints: getCodePoints,
- getUTF16Length: getUTF16Length,
- hasSurrogateUnit: hasSurrogateUnit,
- isCodeUnitInSurrogateRange: isCodeUnitInSurrogateRange,
- isSurrogatePair: isSurrogatePair,
- strlen: strlen,
- substring: substring,
- substr: substr
- };
- module.exports = UnicodeUtils;
-
- /***/ }),
- /* 17 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var Immutable = __webpack_require__(0);
-
- var OrderedMap = Immutable.OrderedMap;
- var BlockMapBuilder = {
- createFromArray: function createFromArray(blocks) {
- return OrderedMap(blocks.map(function (block) {
- return [block.getKey(), block];
- }));
- }
- };
- module.exports = BlockMapBuilder;
-
- /***/ }),
- /* 18 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- /**
- * Search through an array to find contiguous stretches of elements that
- * match a specified filter function.
- *
- * When ranges are found, execute a specified `found` function to supply
- * the values to the caller.
- */
- function findRangesImmutable(haystack, areEqualFn, filterFn, foundFn) {
- if (!haystack.size) {
- return;
- }
-
- var cursor = 0;
- haystack.reduce(function (value, nextValue, nextIndex) {
- if (!areEqualFn(value, nextValue)) {
- if (filterFn(value)) {
- foundFn(cursor, nextIndex);
- }
-
- cursor = nextIndex;
- }
-
- return nextValue;
- });
- filterFn(haystack.last()) && foundFn(cursor, haystack.count());
- }
-
- module.exports = findRangesImmutable;
-
- /***/ }),
- /* 19 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
- function isHTMLElement(node) {
- if (!node || !node.ownerDocument) {
- return false;
- }
-
- if (!node.ownerDocument.defaultView) {
- return node instanceof HTMLElement;
- }
-
- if (node instanceof node.ownerDocument.defaultView.HTMLElement) {
- return true;
- }
-
- return false;
- }
-
- module.exports = isHTMLElement;
-
- /***/ }),
- /* 20 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftModifier = __webpack_require__(3);
-
- var gkx = __webpack_require__(11);
-
- var experimentalTreeDataSupport = gkx('draft_tree_data_support');
- /**
- * For a collapsed selection state, remove text based on the specified strategy.
- * If the selection state is not collapsed, remove the entire selected range.
- */
-
- function removeTextWithStrategy(editorState, strategy, direction) {
- var selection = editorState.getSelection();
- var content = editorState.getCurrentContent();
- var target = selection;
- var anchorKey = selection.getAnchorKey();
- var focusKey = selection.getFocusKey();
- var anchorBlock = content.getBlockForKey(anchorKey);
-
- if (experimentalTreeDataSupport) {
- if (direction === 'forward') {
- if (anchorKey !== focusKey) {
- // For now we ignore forward delete across blocks,
- // if there is demand for this we will implement it.
- return content;
- }
- }
- }
-
- if (selection.isCollapsed()) {
- if (direction === 'forward') {
- if (editorState.isSelectionAtEndOfContent()) {
- return content;
- }
-
- if (experimentalTreeDataSupport) {
- var isAtEndOfBlock = selection.getAnchorOffset() === content.getBlockForKey(anchorKey).getLength();
-
- if (isAtEndOfBlock) {
- var anchorBlockSibling = content.getBlockForKey(anchorBlock.nextSibling);
-
- if (!anchorBlockSibling || anchorBlockSibling.getLength() === 0) {
- // For now we ignore forward delete at the end of a block,
- // if there is demand for this we will implement it.
- return content;
- }
- }
- }
- } else if (editorState.isSelectionAtStartOfContent()) {
- return content;
- }
-
- target = strategy(editorState);
-
- if (target === selection) {
- return content;
- }
- }
-
- return DraftModifier.removeRange(content, target, direction);
- }
-
- module.exports = removeTextWithStrategy;
-
- /***/ }),
- /* 21 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var randomizeBlockMapKeys = __webpack_require__(41);
-
- var removeEntitiesAtEdges = __webpack_require__(42);
-
- var getContentStateFragment = function getContentStateFragment(contentState, selectionState) {
- var startKey = selectionState.getStartKey();
- var startOffset = selectionState.getStartOffset();
- var endKey = selectionState.getEndKey();
- var endOffset = selectionState.getEndOffset(); // Edge entities should be stripped to ensure that we don't preserve
- // invalid partial entities when the fragment is reused. We do, however,
- // preserve entities that are entirely within the selection range.
-
- var contentWithoutEdgeEntities = removeEntitiesAtEdges(contentState, selectionState);
- var blockMap = contentWithoutEdgeEntities.getBlockMap();
- var blockKeys = blockMap.keySeq();
- var startIndex = blockKeys.indexOf(startKey);
- var endIndex = blockKeys.indexOf(endKey) + 1;
- return randomizeBlockMapKeys(blockMap.slice(startIndex, endIndex).map(function (block, blockKey) {
- var text = block.getText();
- var chars = block.getCharacterList();
-
- if (startKey === endKey) {
- return block.merge({
- text: text.slice(startOffset, endOffset),
- characterList: chars.slice(startOffset, endOffset)
- });
- }
-
- if (blockKey === startKey) {
- return block.merge({
- text: text.slice(startOffset),
- characterList: chars.slice(startOffset)
- });
- }
-
- if (blockKey === endKey) {
- return block.merge({
- text: text.slice(0, endOffset),
- characterList: chars.slice(0, endOffset)
- });
- }
-
- return block;
- }));
- };
-
- module.exports = getContentStateFragment;
-
- /***/ }),
- /* 22 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
- var DraftEntityInstance = __webpack_require__(46);
-
- var Immutable = __webpack_require__(0);
-
- var invariant = __webpack_require__(1);
-
- var Map = Immutable.Map;
- var instances = Map();
- var instanceKey = 0;
- /**
- * Temporary utility for generating the warnings
- */
-
- function logWarning(oldMethodCall, newMethodCall) {
- console.warn('WARNING: ' + oldMethodCall + ' will be deprecated soon!\nPlease use "' + newMethodCall + '" instead.');
- }
-
- /**
- * A "document entity" is an object containing metadata associated with a
- * piece of text in a ContentBlock.
- *
- * For example, a `link` entity might include a `uri` property. When a
- * ContentBlock is rendered in the browser, text that refers to that link
- * entity may be rendered as an anchor, with the `uri` as the href value.
- *
- * In a ContentBlock, every position in the text may correspond to zero
- * or one entities. This correspondence is tracked using a key string,
- * generated via DraftEntity.create() and used to obtain entity metadata
- * via DraftEntity.get().
- */
- var DraftEntity = {
- /**
- * WARNING: This method will be deprecated soon!
- * Please use 'contentState.getLastCreatedEntityKey' instead.
- * ---
- * Get the random key string from whatever entity was last created.
- * We need this to support the new API, as part of transitioning to put Entity
- * storage in contentState.
- */
- getLastCreatedEntityKey: function getLastCreatedEntityKey() {
- logWarning('DraftEntity.getLastCreatedEntityKey', 'contentState.getLastCreatedEntityKey');
- return DraftEntity.__getLastCreatedEntityKey();
- },
-
- /**
- * WARNING: This method will be deprecated soon!
- * Please use 'contentState.createEntity' instead.
- * ---
- * Create a DraftEntityInstance and store it for later retrieval.
- *
- * A random key string will be generated and returned. This key may
- * be used to track the entity's usage in a ContentBlock, and for
- * retrieving data about the entity at render time.
- */
- create: function create(type, mutability, data) {
- logWarning('DraftEntity.create', 'contentState.createEntity');
- return DraftEntity.__create(type, mutability, data);
- },
-
- /**
- * WARNING: This method will be deprecated soon!
- * Please use 'contentState.addEntity' instead.
- * ---
- * Add an existing DraftEntityInstance to the DraftEntity map. This is
- * useful when restoring instances from the server.
- */
- add: function add(instance) {
- logWarning('DraftEntity.add', 'contentState.addEntity');
- return DraftEntity.__add(instance);
- },
-
- /**
- * WARNING: This method will be deprecated soon!
- * Please use 'contentState.getEntity' instead.
- * ---
- * Retrieve the entity corresponding to the supplied key string.
- */
- get: function get(key) {
- logWarning('DraftEntity.get', 'contentState.getEntity');
- return DraftEntity.__get(key);
- },
-
- /**
- * WARNING: This method will be deprecated soon!
- * Please use 'contentState.mergeEntityData' instead.
- * ---
- * Entity instances are immutable. If you need to update the data for an
- * instance, this method will merge your data updates and return a new
- * instance.
- */
- mergeData: function mergeData(key, toMerge) {
- logWarning('DraftEntity.mergeData', 'contentState.mergeEntityData');
- return DraftEntity.__mergeData(key, toMerge);
- },
-
- /**
- * WARNING: This method will be deprecated soon!
- * Please use 'contentState.replaceEntityData' instead.
- * ---
- * Completely replace the data for a given instance.
- */
- replaceData: function replaceData(key, newData) {
- logWarning('DraftEntity.replaceData', 'contentState.replaceEntityData');
- return DraftEntity.__replaceData(key, newData);
- },
- // ***********************************WARNING******************************
- // --- the above public API will be deprecated in the next version of Draft!
- // The methods below this line are private - don't call them directly.
-
- /**
- * Get the random key string from whatever entity was last created.
- * We need this to support the new API, as part of transitioning to put Entity
- * storage in contentState.
- */
- __getLastCreatedEntityKey: function __getLastCreatedEntityKey() {
- return '' + instanceKey;
- },
-
- /**
- * Create a DraftEntityInstance and store it for later retrieval.
- *
- * A random key string will be generated and returned. This key may
- * be used to track the entity's usage in a ContentBlock, and for
- * retrieving data about the entity at render time.
- */
- __create: function __create(type, mutability, data) {
- return DraftEntity.__add(new DraftEntityInstance({
- type: type,
- mutability: mutability,
- data: data || {}
- }));
- },
-
- /**
- * Add an existing DraftEntityInstance to the DraftEntity map. This is
- * useful when restoring instances from the server.
- */
- __add: function __add(instance) {
- var key = '' + ++instanceKey;
- instances = instances.set(key, instance);
- return key;
- },
-
- /**
- * Retrieve the entity corresponding to the supplied key string.
- */
- __get: function __get(key) {
- var instance = instances.get(key);
- !!!instance ? true ? invariant(false, 'Unknown DraftEntity key: %s.', key) : invariant(false) : void 0;
- return instance;
- },
-
- /**
- * Entity instances are immutable. If you need to update the data for an
- * instance, this method will merge your data updates and return a new
- * instance.
- */
- __mergeData: function __mergeData(key, toMerge) {
- var instance = DraftEntity.__get(key);
-
- var newData = _objectSpread({}, instance.getData(), toMerge);
-
- var newInstance = instance.set('data', newData);
- instances = instances.set(key, newInstance);
- return newInstance;
- },
-
- /**
- * Completely replace the data for a given instance.
- */
- __replaceData: function __replaceData(key, newData) {
- var instance = DraftEntity.__get(key);
-
- var newInstance = instance.set('data', newData);
- instances = instances.set(key, newInstance);
- return newInstance;
- }
- };
- module.exports = DraftEntity;
-
- /***/ }),
- /* 23 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- var Immutable = __webpack_require__(0);
-
- var Record = Immutable.Record;
- var defaultRecord = {
- anchorKey: '',
- anchorOffset: 0,
- focusKey: '',
- focusOffset: 0,
- isBackward: false,
- hasFocus: false
- };
- /* $FlowFixMe This comment suppresses an error found when automatically adding
- * a type annotation with the codemod Komodo/Annotate_exports. To see the error
- * delete this comment and run Flow. */
-
- var SelectionStateRecord = Record(defaultRecord);
-
- var SelectionState =
- /*#__PURE__*/
- function (_SelectionStateRecord) {
- _inheritsLoose(SelectionState, _SelectionStateRecord);
-
- function SelectionState() {
- return _SelectionStateRecord.apply(this, arguments) || this;
- }
-
- var _proto = SelectionState.prototype;
-
- _proto.serialize = function serialize() {
- return 'Anchor: ' + this.getAnchorKey() + ':' + this.getAnchorOffset() + ', ' + 'Focus: ' + this.getFocusKey() + ':' + this.getFocusOffset() + ', ' + 'Is Backward: ' + String(this.getIsBackward()) + ', ' + 'Has Focus: ' + String(this.getHasFocus());
- };
-
- _proto.getAnchorKey = function getAnchorKey() {
- return this.get('anchorKey');
- };
-
- _proto.getAnchorOffset = function getAnchorOffset() {
- return this.get('anchorOffset');
- };
-
- _proto.getFocusKey = function getFocusKey() {
- return this.get('focusKey');
- };
-
- _proto.getFocusOffset = function getFocusOffset() {
- return this.get('focusOffset');
- };
-
- _proto.getIsBackward = function getIsBackward() {
- return this.get('isBackward');
- };
-
- _proto.getHasFocus = function getHasFocus() {
- return this.get('hasFocus');
- }
- /**
- * Return whether the specified range overlaps with an edge of the
- * SelectionState.
- */
- ;
-
- _proto.hasEdgeWithin = function hasEdgeWithin(blockKey, start, end) {
- var anchorKey = this.getAnchorKey();
- var focusKey = this.getFocusKey();
-
- if (anchorKey === focusKey && anchorKey === blockKey) {
- var selectionStart = this.getStartOffset();
- var selectionEnd = this.getEndOffset();
- return start <= selectionStart && selectionStart <= end || // selectionStart is between start and end, or
- start <= selectionEnd && selectionEnd <= end // selectionEnd is between start and end
- ;
- }
-
- if (blockKey !== anchorKey && blockKey !== focusKey) {
- return false;
- }
-
- var offsetToCheck = blockKey === anchorKey ? this.getAnchorOffset() : this.getFocusOffset();
- return start <= offsetToCheck && end >= offsetToCheck;
- };
-
- _proto.isCollapsed = function isCollapsed() {
- return this.getAnchorKey() === this.getFocusKey() && this.getAnchorOffset() === this.getFocusOffset();
- };
-
- _proto.getStartKey = function getStartKey() {
- return this.getIsBackward() ? this.getFocusKey() : this.getAnchorKey();
- };
-
- _proto.getStartOffset = function getStartOffset() {
- return this.getIsBackward() ? this.getFocusOffset() : this.getAnchorOffset();
- };
-
- _proto.getEndKey = function getEndKey() {
- return this.getIsBackward() ? this.getAnchorKey() : this.getFocusKey();
- };
-
- _proto.getEndOffset = function getEndOffset() {
- return this.getIsBackward() ? this.getAnchorOffset() : this.getFocusOffset();
- };
-
- SelectionState.createEmpty = function createEmpty(key) {
- return new SelectionState({
- anchorKey: key,
- anchorOffset: 0,
- focusKey: key,
- focusOffset: 0,
- isBackward: false,
- hasFocus: false
- });
- };
-
- return SelectionState;
- }(SelectionStateRecord);
-
- module.exports = SelectionState;
-
- /***/ }),
- /* 24 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- *
- */
-
- /**
- * Constants to represent text directionality
- *
- * Also defines a *global* direciton, to be used in bidi algorithms as a
- * default fallback direciton, when no better direction is found or provided.
- *
- * NOTE: Use `setGlobalDir()`, or update `initGlobalDir()`, to set the initial
- * global direction value based on the application.
- *
- * Part of the implementation of Unicode Bidirectional Algorithm (UBA)
- * Unicode Standard Annex #9 (UAX9)
- * http://www.unicode.org/reports/tr9/
- */
-
-
- var invariant = __webpack_require__(1);
-
- var NEUTRAL = 'NEUTRAL'; // No strong direction
-
- var LTR = 'LTR'; // Left-to-Right direction
-
- var RTL = 'RTL'; // Right-to-Left direction
-
- var globalDir = null; // == Helpers ==
-
- /**
- * Check if a directionality value is a Strong one
- */
-
- function isStrong(dir) {
- return dir === LTR || dir === RTL;
- }
- /**
- * Get string value to be used for `dir` HTML attribute or `direction` CSS
- * property.
- */
-
-
- function getHTMLDir(dir) {
- !isStrong(dir) ? true ? invariant(false, '`dir` must be a strong direction to be converted to HTML Direction') : invariant(false) : void 0;
- return dir === LTR ? 'ltr' : 'rtl';
- }
- /**
- * Get string value to be used for `dir` HTML attribute or `direction` CSS
- * property, but returns null if `dir` has same value as `otherDir`.
- * `null`.
- */
-
-
- function getHTMLDirIfDifferent(dir, otherDir) {
- !isStrong(dir) ? true ? invariant(false, '`dir` must be a strong direction to be converted to HTML Direction') : invariant(false) : void 0;
- !isStrong(otherDir) ? true ? invariant(false, '`otherDir` must be a strong direction to be converted to HTML Direction') : invariant(false) : void 0;
- return dir === otherDir ? null : getHTMLDir(dir);
- } // == Global Direction ==
-
- /**
- * Set the global direction.
- */
-
-
- function setGlobalDir(dir) {
- globalDir = dir;
- }
- /**
- * Initialize the global direction
- */
-
-
- function initGlobalDir() {
- setGlobalDir(LTR);
- }
- /**
- * Get the global direction
- */
-
-
- function getGlobalDir() {
- if (!globalDir) {
- this.initGlobalDir();
- }
-
- !globalDir ? true ? invariant(false, 'Global direction not set.') : invariant(false) : void 0;
- return globalDir;
- }
-
- var UnicodeBidiDirection = {
- // Values
- NEUTRAL: NEUTRAL,
- LTR: LTR,
- RTL: RTL,
- // Helpers
- isStrong: isStrong,
- getHTMLDir: getHTMLDir,
- getHTMLDirIfDifferent: getHTMLDirIfDifferent,
- // Global Direction
- setGlobalDir: setGlobalDir,
- initGlobalDir: initGlobalDir,
- getGlobalDir: getGlobalDir
- };
- module.exports = UnicodeBidiDirection;
-
- /***/ }),
- /* 25 */
- /***/ (function(module, exports) {
-
- var g;
-
- // This works in non-strict mode
- g = (function() {
- return this;
- })();
-
- try {
- // This works if eval is allowed (see CSP)
- g = g || Function("return this")() || (1,eval)("this");
- } catch(e) {
- // This works if the window reference is available
- if(typeof window === "object")
- g = window;
- }
-
- // g can still be undefined, but nothing to do about it...
- // We return undefined, instead of nothing here, so it's
- // easier to handle this case. if(!global) { ...}
-
- module.exports = g;
-
-
- /***/ }),
- /* 26 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var getCorrectDocumentFromNode = __webpack_require__(27);
-
- var getSelectionOffsetKeyForNode = __webpack_require__(49);
- /**
- * Get the key from the node's nearest offset-aware ancestor.
- */
-
-
- function findAncestorOffsetKey(node) {
- var searchNode = node;
-
- while (searchNode && searchNode !== getCorrectDocumentFromNode(node).documentElement) {
- var key = getSelectionOffsetKeyForNode(searchNode);
-
- if (key != null) {
- return key;
- }
-
- searchNode = searchNode.parentNode;
- }
-
- return null;
- }
-
- module.exports = findAncestorOffsetKey;
-
- /***/ }),
- /* 27 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
- function getCorrectDocumentFromNode(node) {
- if (!node || !node.ownerDocument) {
- return document;
- }
-
- return node.ownerDocument;
- }
-
- module.exports = getCorrectDocumentFromNode;
-
- /***/ }),
- /* 28 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
- module.exports = {
- BACKSPACE: 8,
- TAB: 9,
- RETURN: 13,
- ALT: 18,
- ESC: 27,
- SPACE: 32,
- PAGE_UP: 33,
- PAGE_DOWN: 34,
- END: 35,
- HOME: 36,
- LEFT: 37,
- UP: 38,
- RIGHT: 39,
- DOWN: 40,
- DELETE: 46,
- COMMA: 188,
- PERIOD: 190,
- A: 65,
- Z: 90,
- ZERO: 48,
- NUMPAD_0: 96,
- NUMPAD_9: 105
- };
-
- /***/ }),
- /* 29 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
- var getStyleProperty = __webpack_require__(113);
- /**
- * @param {DOMNode} element [description]
- * @param {string} name Overflow style property name.
- * @return {boolean} True if the supplied ndoe is scrollable.
- */
-
-
- function _isNodeScrollable(element, name) {
- var overflow = Style.get(element, name);
- return overflow === 'auto' || overflow === 'scroll';
- }
- /**
- * Utilities for querying and mutating style properties.
- */
-
-
- var Style = {
- /**
- * Gets the style property for the supplied node. This will return either the
- * computed style, if available, or the declared style.
- *
- * @param {DOMNode} node
- * @param {string} name Style property name.
- * @return {?string} Style property value.
- */
- get: getStyleProperty,
-
- /**
- * Determines the nearest ancestor of a node that is scrollable.
- *
- * NOTE: This can be expensive if used repeatedly or on a node nested deeply.
- *
- * @param {?DOMNode} node Node from which to start searching.
- * @return {?DOMWindow|DOMElement} Scroll parent of the supplied node.
- */
- getScrollParent: function getScrollParent(node) {
- if (!node) {
- return null;
- }
-
- var ownerDocument = node.ownerDocument;
-
- while (node && node !== ownerDocument.body) {
- if (_isNodeScrollable(node, 'overflow') || _isNodeScrollable(node, 'overflowY') || _isNodeScrollable(node, 'overflowX')) {
- return node;
- }
-
- node = node.parentNode;
- }
-
- return ownerDocument.defaultView || ownerDocument.parentWindow;
- }
- };
- module.exports = Style;
-
- /***/ }),
- /* 30 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
-
- var getDocumentScrollElement = __webpack_require__(117);
-
- var getUnboundedScrollPosition = __webpack_require__(118);
- /**
- * Gets the scroll position of the supplied element or window.
- *
- * The return values are bounded. This means that if the scroll position is
- * negative or exceeds the element boundaries (which is possible using inertial
- * scrolling), you will get zero or the maximum scroll position, respectively.
- *
- * If you need the unbound scroll position, use `getUnboundedScrollPosition`.
- *
- * @param {DOMWindow|DOMElement} scrollable
- * @return {object} Map with `x` and `y` keys.
- */
-
-
- function getScrollPosition(scrollable) {
- var documentScrollElement = getDocumentScrollElement(scrollable.ownerDocument || scrollable.document);
-
- if (scrollable.Window && scrollable instanceof scrollable.Window) {
- scrollable = documentScrollElement;
- }
-
- var scrollPosition = getUnboundedScrollPosition(scrollable);
- var viewport = scrollable === documentScrollElement ? scrollable.ownerDocument.documentElement : scrollable;
- var xMax = scrollable.scrollWidth - viewport.clientWidth;
- var yMax = scrollable.scrollHeight - viewport.clientHeight;
- scrollPosition.x = Math.max(0, Math.min(scrollPosition.x, xMax));
- scrollPosition.y = Math.max(0, Math.min(scrollPosition.y, yMax));
- return scrollPosition;
- }
-
- module.exports = getScrollPosition;
-
- /***/ }),
- /* 31 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- /**
- * Utility method for determining whether or not the value returned
- * from a handler indicates that it was handled.
- */
- function isEventHandled(value) {
- return value === 'handled' || value === true;
- }
-
- module.exports = isEventHandled;
-
- /***/ }),
- /* 32 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- var BlockMapBuilder = __webpack_require__(17);
-
- var CharacterMetadata = __webpack_require__(6);
-
- var ContentBlock = __webpack_require__(12);
-
- var ContentBlockNode = __webpack_require__(7);
-
- var DraftEntity = __webpack_require__(22);
-
- var SelectionState = __webpack_require__(23);
-
- var generateRandomKey = __webpack_require__(9);
-
- var gkx = __webpack_require__(11);
-
- var Immutable = __webpack_require__(0);
-
- var sanitizeDraftText = __webpack_require__(47);
-
- var List = Immutable.List,
- Record = Immutable.Record,
- Repeat = Immutable.Repeat;
- var defaultRecord = {
- entityMap: null,
- blockMap: null,
- selectionBefore: null,
- selectionAfter: null
- };
- var ContentStateRecord = Record(defaultRecord);
-
- var ContentState =
- /*#__PURE__*/
- function (_ContentStateRecord) {
- _inheritsLoose(ContentState, _ContentStateRecord);
-
- function ContentState() {
- return _ContentStateRecord.apply(this, arguments) || this;
- }
-
- var _proto = ContentState.prototype;
-
- _proto.getEntityMap = function getEntityMap() {
- // TODO: update this when we fully remove DraftEntity
- return DraftEntity;
- };
-
- _proto.getBlockMap = function getBlockMap() {
- return this.get('blockMap');
- };
-
- _proto.getSelectionBefore = function getSelectionBefore() {
- return this.get('selectionBefore');
- };
-
- _proto.getSelectionAfter = function getSelectionAfter() {
- return this.get('selectionAfter');
- };
-
- _proto.getBlockForKey = function getBlockForKey(key) {
- var block = this.getBlockMap().get(key);
- return block;
- };
-
- _proto.getKeyBefore = function getKeyBefore(key) {
- return this.getBlockMap().reverse().keySeq().skipUntil(function (v) {
- return v === key;
- }).skip(1).first();
- };
-
- _proto.getKeyAfter = function getKeyAfter(key) {
- return this.getBlockMap().keySeq().skipUntil(function (v) {
- return v === key;
- }).skip(1).first();
- };
-
- _proto.getBlockAfter = function getBlockAfter(key) {
- return this.getBlockMap().skipUntil(function (_, k) {
- return k === key;
- }).skip(1).first();
- };
-
- _proto.getBlockBefore = function getBlockBefore(key) {
- return this.getBlockMap().reverse().skipUntil(function (_, k) {
- return k === key;
- }).skip(1).first();
- };
-
- _proto.getBlocksAsArray = function getBlocksAsArray() {
- return this.getBlockMap().toArray();
- };
-
- _proto.getFirstBlock = function getFirstBlock() {
- return this.getBlockMap().first();
- };
-
- _proto.getLastBlock = function getLastBlock() {
- return this.getBlockMap().last();
- };
-
- _proto.getPlainText = function getPlainText(delimiter) {
- return this.getBlockMap().map(function (block) {
- return block ? block.getText() : '';
- }).join(delimiter || '\n');
- };
-
- _proto.getLastCreatedEntityKey = function getLastCreatedEntityKey() {
- // TODO: update this when we fully remove DraftEntity
- return DraftEntity.__getLastCreatedEntityKey();
- };
-
- _proto.hasText = function hasText() {
- var blockMap = this.getBlockMap();
- return blockMap.size > 1 || // make sure that there are no zero width space chars
- escape(blockMap.first().getText()).replace(/%u200B/g, '').length > 0;
- };
-
- _proto.createEntity = function createEntity(type, mutability, data) {
- // TODO: update this when we fully remove DraftEntity
- DraftEntity.__create(type, mutability, data);
-
- return this;
- };
-
- _proto.mergeEntityData = function mergeEntityData(key, toMerge) {
- // TODO: update this when we fully remove DraftEntity
- DraftEntity.__mergeData(key, toMerge);
-
- return this;
- };
-
- _proto.replaceEntityData = function replaceEntityData(key, newData) {
- // TODO: update this when we fully remove DraftEntity
- DraftEntity.__replaceData(key, newData);
-
- return this;
- };
-
- _proto.addEntity = function addEntity(instance) {
- // TODO: update this when we fully remove DraftEntity
- DraftEntity.__add(instance);
-
- return this;
- };
-
- _proto.getEntity = function getEntity(key) {
- // TODO: update this when we fully remove DraftEntity
- return DraftEntity.__get(key);
- };
-
- ContentState.createFromBlockArray = function createFromBlockArray( // TODO: update flow type when we completely deprecate the old entity API
- blocks, entityMap) {
- // TODO: remove this when we completely deprecate the old entity API
- var theBlocks = Array.isArray(blocks) ? blocks : blocks.contentBlocks;
- var blockMap = BlockMapBuilder.createFromArray(theBlocks);
- var selectionState = blockMap.isEmpty() ? new SelectionState() : SelectionState.createEmpty(blockMap.first().getKey());
- return new ContentState({
- blockMap: blockMap,
- entityMap: entityMap || DraftEntity,
- selectionBefore: selectionState,
- selectionAfter: selectionState
- });
- };
-
- ContentState.createFromText = function createFromText(text) {
- var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : /\r\n?|\n/g;
- var strings = text.split(delimiter);
- var blocks = strings.map(function (block) {
- block = sanitizeDraftText(block);
- var ContentBlockNodeRecord = gkx('draft_tree_data_support') ? ContentBlockNode : ContentBlock;
- return new ContentBlockNodeRecord({
- key: generateRandomKey(),
- text: block,
- type: 'unstyled',
- characterList: List(Repeat(CharacterMetadata.EMPTY, block.length))
- });
- });
- return ContentState.createFromBlockArray(blocks);
- };
-
- return ContentState;
- }(ContentStateRecord);
-
- module.exports = ContentState;
-
- /***/ }),
- /* 33 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- *
- */
-
- /**
- * Basic (stateless) API for text direction detection
- *
- * Part of our implementation of Unicode Bidirectional Algorithm (UBA)
- * Unicode Standard Annex #9 (UAX9)
- * http://www.unicode.org/reports/tr9/
- */
-
-
- var UnicodeBidiDirection = __webpack_require__(24);
-
- var invariant = __webpack_require__(1);
-
- /**
- * RegExp ranges of characters with a *Strong* Bidi_Class value.
- *
- * Data is based on DerivedBidiClass.txt in UCD version 7.0.0.
- *
- * NOTE: For performance reasons, we only support Unicode's
- * Basic Multilingual Plane (BMP) for now.
- */
- var RANGE_BY_BIDI_TYPE = {
- L: "A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u01BA\u01BB" + "\u01BC-\u01BF\u01C0-\u01C3\u01C4-\u0293\u0294\u0295-\u02AF\u02B0-\u02B8" + "\u02BB-\u02C1\u02D0-\u02D1\u02E0-\u02E4\u02EE\u0370-\u0373\u0376-\u0377" + "\u037A\u037B-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1" + "\u03A3-\u03F5\u03F7-\u0481\u0482\u048A-\u052F\u0531-\u0556\u0559" + "\u055A-\u055F\u0561-\u0587\u0589\u0903\u0904-\u0939\u093B\u093D" + "\u093E-\u0940\u0949-\u094C\u094E-\u094F\u0950\u0958-\u0961\u0964-\u0965" + "\u0966-\u096F\u0970\u0971\u0972-\u0980\u0982-\u0983\u0985-\u098C" + "\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD" + "\u09BE-\u09C0\u09C7-\u09C8\u09CB-\u09CC\u09CE\u09D7\u09DC-\u09DD" + "\u09DF-\u09E1\u09E6-\u09EF\u09F0-\u09F1\u09F4-\u09F9\u09FA\u0A03" + "\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33" + "\u0A35-\u0A36\u0A38-\u0A39\u0A3E-\u0A40\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F" + "\u0A72-\u0A74\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0" + "\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0ABE-\u0AC0\u0AC9\u0ACB-\u0ACC\u0AD0" + "\u0AE0-\u0AE1\u0AE6-\u0AEF\u0AF0\u0B02-\u0B03\u0B05-\u0B0C\u0B0F-\u0B10" + "\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B3E\u0B40" + "\u0B47-\u0B48\u0B4B-\u0B4C\u0B57\u0B5C-\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F" + "\u0B70\u0B71\u0B72-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95" + "\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9" + "\u0BBE-\u0BBF\u0BC1-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0BD0\u0BD7" + "\u0BE6-\u0BEF\u0BF0-\u0BF2\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10" + "\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C41-\u0C44\u0C58-\u0C59\u0C60-\u0C61" + "\u0C66-\u0C6F\u0C7F\u0C82-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8" + "\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CBE\u0CBF\u0CC0-\u0CC4\u0CC6" + "\u0CC7-\u0CC8\u0CCA-\u0CCB\u0CD5-\u0CD6\u0CDE\u0CE0-\u0CE1\u0CE6-\u0CEF" + "\u0CF1-\u0CF2\u0D02-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D" + "\u0D3E-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D4E\u0D57\u0D60-\u0D61" + "\u0D66-\u0D6F\u0D70-\u0D75\u0D79\u0D7A-\u0D7F\u0D82-\u0D83\u0D85-\u0D96" + "\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCF-\u0DD1\u0DD8-\u0DDF" + "\u0DE6-\u0DEF\u0DF2-\u0DF3\u0DF4\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E45" + "\u0E46\u0E4F\u0E50-\u0E59\u0E5A-\u0E5B\u0E81-\u0E82\u0E84\u0E87-\u0E88" + "\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7" + "\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6" + "\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F01-\u0F03\u0F04-\u0F12\u0F13\u0F14" + "\u0F15-\u0F17\u0F1A-\u0F1F\u0F20-\u0F29\u0F2A-\u0F33\u0F34\u0F36\u0F38" + "\u0F3E-\u0F3F\u0F40-\u0F47\u0F49-\u0F6C\u0F7F\u0F85\u0F88-\u0F8C" + "\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE-\u0FCF\u0FD0-\u0FD4\u0FD5-\u0FD8" + "\u0FD9-\u0FDA\u1000-\u102A\u102B-\u102C\u1031\u1038\u103B-\u103C\u103F" + "\u1040-\u1049\u104A-\u104F\u1050-\u1055\u1056-\u1057\u105A-\u105D\u1061" + "\u1062-\u1064\u1065-\u1066\u1067-\u106D\u106E-\u1070\u1075-\u1081" + "\u1083-\u1084\u1087-\u108C\u108E\u108F\u1090-\u1099\u109A-\u109C" + "\u109E-\u109F\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FB\u10FC" + "\u10FD-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288" + "\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5" + "\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1360-\u1368" + "\u1369-\u137C\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166D-\u166E" + "\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EB-\u16ED\u16EE-\u16F0" + "\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1735-\u1736" + "\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17B6\u17BE-\u17C5" + "\u17C7-\u17C8\u17D4-\u17D6\u17D7\u17D8-\u17DA\u17DC\u17E0-\u17E9" + "\u1810-\u1819\u1820-\u1842\u1843\u1844-\u1877\u1880-\u18A8\u18AA" + "\u18B0-\u18F5\u1900-\u191E\u1923-\u1926\u1929-\u192B\u1930-\u1931" + "\u1933-\u1938\u1946-\u194F\u1950-\u196D\u1970-\u1974\u1980-\u19AB" + "\u19B0-\u19C0\u19C1-\u19C7\u19C8-\u19C9\u19D0-\u19D9\u19DA\u1A00-\u1A16" + "\u1A19-\u1A1A\u1A1E-\u1A1F\u1A20-\u1A54\u1A55\u1A57\u1A61\u1A63-\u1A64" + "\u1A6D-\u1A72\u1A80-\u1A89\u1A90-\u1A99\u1AA0-\u1AA6\u1AA7\u1AA8-\u1AAD" + "\u1B04\u1B05-\u1B33\u1B35\u1B3B\u1B3D-\u1B41\u1B43-\u1B44\u1B45-\u1B4B" + "\u1B50-\u1B59\u1B5A-\u1B60\u1B61-\u1B6A\u1B74-\u1B7C\u1B82\u1B83-\u1BA0" + "\u1BA1\u1BA6-\u1BA7\u1BAA\u1BAE-\u1BAF\u1BB0-\u1BB9\u1BBA-\u1BE5\u1BE7" + "\u1BEA-\u1BEC\u1BEE\u1BF2-\u1BF3\u1BFC-\u1BFF\u1C00-\u1C23\u1C24-\u1C2B" + "\u1C34-\u1C35\u1C3B-\u1C3F\u1C40-\u1C49\u1C4D-\u1C4F\u1C50-\u1C59" + "\u1C5A-\u1C77\u1C78-\u1C7D\u1C7E-\u1C7F\u1CC0-\u1CC7\u1CD3\u1CE1" + "\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF2-\u1CF3\u1CF5-\u1CF6\u1D00-\u1D2B" + "\u1D2C-\u1D6A\u1D6B-\u1D77\u1D78\u1D79-\u1D9A\u1D9B-\u1DBF\u1E00-\u1F15" + "\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D" + "\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC" + "\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200E" + "\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D" + "\u2124\u2126\u2128\u212A-\u212D\u212F-\u2134\u2135-\u2138\u2139" + "\u213C-\u213F\u2145-\u2149\u214E\u214F\u2160-\u2182\u2183-\u2184" + "\u2185-\u2188\u2336-\u237A\u2395\u249C-\u24E9\u26AC\u2800-\u28FF" + "\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2C7B\u2C7C-\u2C7D\u2C7E-\u2CE4" + "\u2CEB-\u2CEE\u2CF2-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F" + "\u2D70\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE" + "\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005\u3006\u3007" + "\u3021-\u3029\u302E-\u302F\u3031-\u3035\u3038-\u303A\u303B\u303C" + "\u3041-\u3096\u309D-\u309E\u309F\u30A1-\u30FA\u30FC-\u30FE\u30FF" + "\u3105-\u312D\u3131-\u318E\u3190-\u3191\u3192-\u3195\u3196-\u319F" + "\u31A0-\u31BA\u31F0-\u31FF\u3200-\u321C\u3220-\u3229\u322A-\u3247" + "\u3248-\u324F\u3260-\u327B\u327F\u3280-\u3289\u328A-\u32B0\u32C0-\u32CB" + "\u32D0-\u32FE\u3300-\u3376\u337B-\u33DD\u33E0-\u33FE\u3400-\u4DB5" + "\u4E00-\u9FCC\uA000-\uA014\uA015\uA016-\uA48C\uA4D0-\uA4F7\uA4F8-\uA4FD" + "\uA4FE-\uA4FF\uA500-\uA60B\uA60C\uA610-\uA61F\uA620-\uA629\uA62A-\uA62B" + "\uA640-\uA66D\uA66E\uA680-\uA69B\uA69C-\uA69D\uA6A0-\uA6E5\uA6E6-\uA6EF" + "\uA6F2-\uA6F7\uA722-\uA76F\uA770\uA771-\uA787\uA789-\uA78A\uA78B-\uA78E" + "\uA790-\uA7AD\uA7B0-\uA7B1\uA7F7\uA7F8-\uA7F9\uA7FA\uA7FB-\uA801" + "\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA823-\uA824\uA827\uA830-\uA835" + "\uA836-\uA837\uA840-\uA873\uA880-\uA881\uA882-\uA8B3\uA8B4-\uA8C3" + "\uA8CE-\uA8CF\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8F8-\uA8FA\uA8FB\uA900-\uA909" + "\uA90A-\uA925\uA92E-\uA92F\uA930-\uA946\uA952-\uA953\uA95F\uA960-\uA97C" + "\uA983\uA984-\uA9B2\uA9B4-\uA9B5\uA9BA-\uA9BB\uA9BD-\uA9C0\uA9C1-\uA9CD" + "\uA9CF\uA9D0-\uA9D9\uA9DE-\uA9DF\uA9E0-\uA9E4\uA9E6\uA9E7-\uA9EF" + "\uA9F0-\uA9F9\uA9FA-\uA9FE\uAA00-\uAA28\uAA2F-\uAA30\uAA33-\uAA34" + "\uAA40-\uAA42\uAA44-\uAA4B\uAA4D\uAA50-\uAA59\uAA5C-\uAA5F\uAA60-\uAA6F" + "\uAA70\uAA71-\uAA76\uAA77-\uAA79\uAA7A\uAA7B\uAA7D\uAA7E-\uAAAF\uAAB1" + "\uAAB5-\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADC\uAADD\uAADE-\uAADF" + "\uAAE0-\uAAEA\uAAEB\uAAEE-\uAAEF\uAAF0-\uAAF1\uAAF2\uAAF3-\uAAF4\uAAF5" + "\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E" + "\uAB30-\uAB5A\uAB5B\uAB5C-\uAB5F\uAB64-\uAB65\uABC0-\uABE2\uABE3-\uABE4" + "\uABE6-\uABE7\uABE9-\uABEA\uABEB\uABEC\uABF0-\uABF9\uAC00-\uD7A3" + "\uD7B0-\uD7C6\uD7CB-\uD7FB\uE000-\uF8FF\uF900-\uFA6D\uFA70-\uFAD9" + "\uFB00-\uFB06\uFB13-\uFB17\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFF6F\uFF70" + "\uFF71-\uFF9D\uFF9E-\uFF9F\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF" + "\uFFD2-\uFFD7\uFFDA-\uFFDC",
- R: "\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05D0-\u05EA\u05EB-\u05EF" + "\u05F0-\u05F2\u05F3-\u05F4\u05F5-\u05FF\u07C0-\u07C9\u07CA-\u07EA" + "\u07F4-\u07F5\u07FA\u07FB-\u07FF\u0800-\u0815\u081A\u0824\u0828" + "\u082E-\u082F\u0830-\u083E\u083F\u0840-\u0858\u085C-\u085D\u085E" + "\u085F-\u089F\u200F\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB37\uFB38-\uFB3C" + "\uFB3D\uFB3E\uFB3F\uFB40-\uFB41\uFB42\uFB43-\uFB44\uFB45\uFB46-\uFB4F",
- AL: "\u0608\u060B\u060D\u061B\u061C\u061D\u061E-\u061F\u0620-\u063F\u0640" + "\u0641-\u064A\u066D\u066E-\u066F\u0671-\u06D3\u06D4\u06D5\u06E5-\u06E6" + "\u06EE-\u06EF\u06FA-\u06FC\u06FD-\u06FE\u06FF\u0700-\u070D\u070E\u070F" + "\u0710\u0712-\u072F\u074B-\u074C\u074D-\u07A5\u07B1\u07B2-\u07BF" + "\u08A0-\u08B2\u08B3-\u08E3\uFB50-\uFBB1\uFBB2-\uFBC1\uFBC2-\uFBD2" + "\uFBD3-\uFD3D\uFD40-\uFD4F\uFD50-\uFD8F\uFD90-\uFD91\uFD92-\uFDC7" + "\uFDC8-\uFDCF\uFDF0-\uFDFB\uFDFC\uFDFE-\uFDFF\uFE70-\uFE74\uFE75" + "\uFE76-\uFEFC\uFEFD-\uFEFE"
- };
- var REGEX_STRONG = new RegExp('[' + RANGE_BY_BIDI_TYPE.L + RANGE_BY_BIDI_TYPE.R + RANGE_BY_BIDI_TYPE.AL + ']');
- var REGEX_RTL = new RegExp('[' + RANGE_BY_BIDI_TYPE.R + RANGE_BY_BIDI_TYPE.AL + ']');
- /**
- * Returns the first strong character (has Bidi_Class value of L, R, or AL).
- *
- * @param str A text block; e.g. paragraph, table cell, tag
- * @return A character with strong bidi direction, or null if not found
- */
-
- function firstStrongChar(str) {
- var match = REGEX_STRONG.exec(str);
- return match == null ? null : match[0];
- }
- /**
- * Returns the direction of a block of text, based on the direction of its
- * first strong character (has Bidi_Class value of L, R, or AL).
- *
- * @param str A text block; e.g. paragraph, table cell, tag
- * @return The resolved direction
- */
-
-
- function firstStrongCharDir(str) {
- var strongChar = firstStrongChar(str);
-
- if (strongChar == null) {
- return UnicodeBidiDirection.NEUTRAL;
- }
-
- return REGEX_RTL.exec(strongChar) ? UnicodeBidiDirection.RTL : UnicodeBidiDirection.LTR;
- }
- /**
- * Returns the direction of a block of text, based on the direction of its
- * first strong character (has Bidi_Class value of L, R, or AL), or a fallback
- * direction, if no strong character is found.
- *
- * This function is supposed to be used in respect to Higher-Level Protocol
- * rule HL1. (http://www.unicode.org/reports/tr9/#HL1)
- *
- * @param str A text block; e.g. paragraph, table cell, tag
- * @param fallback Fallback direction, used if no strong direction detected
- * for the block (default = NEUTRAL)
- * @return The resolved direction
- */
-
-
- function resolveBlockDir(str, fallback) {
- fallback = fallback || UnicodeBidiDirection.NEUTRAL;
-
- if (!str.length) {
- return fallback;
- }
-
- var blockDir = firstStrongCharDir(str);
- return blockDir === UnicodeBidiDirection.NEUTRAL ? fallback : blockDir;
- }
- /**
- * Returns the direction of a block of text, based on the direction of its
- * first strong character (has Bidi_Class value of L, R, or AL), or a fallback
- * direction, if no strong character is found.
- *
- * NOTE: This function is similar to resolveBlockDir(), but uses the global
- * direction as the fallback, so it *always* returns a Strong direction,
- * making it useful for integration in places that you need to make the final
- * decision, like setting some CSS class.
- *
- * This function is supposed to be used in respect to Higher-Level Protocol
- * rule HL1. (http://www.unicode.org/reports/tr9/#HL1)
- *
- * @param str A text block; e.g. paragraph, table cell
- * @param strongFallback Fallback direction, used if no strong direction
- * detected for the block (default = global direction)
- * @return The resolved Strong direction
- */
-
-
- function getDirection(str, strongFallback) {
- if (!strongFallback) {
- strongFallback = UnicodeBidiDirection.getGlobalDir();
- }
-
- !UnicodeBidiDirection.isStrong(strongFallback) ? true ? invariant(false, 'Fallback direction must be a strong direction') : invariant(false) : void 0;
- return resolveBlockDir(str, strongFallback);
- }
- /**
- * Returns true if getDirection(arguments...) returns LTR.
- *
- * @param str A text block; e.g. paragraph, table cell
- * @param strongFallback Fallback direction, used if no strong direction
- * detected for the block (default = global direction)
- * @return True if the resolved direction is LTR
- */
-
-
- function isDirectionLTR(str, strongFallback) {
- return getDirection(str, strongFallback) === UnicodeBidiDirection.LTR;
- }
- /**
- * Returns true if getDirection(arguments...) returns RTL.
- *
- * @param str A text block; e.g. paragraph, table cell
- * @param strongFallback Fallback direction, used if no strong direction
- * detected for the block (default = global direction)
- * @return True if the resolved direction is RTL
- */
-
-
- function isDirectionRTL(str, strongFallback) {
- return getDirection(str, strongFallback) === UnicodeBidiDirection.RTL;
- }
-
- var UnicodeBidi = {
- firstStrongChar: firstStrongChar,
- firstStrongCharDir: firstStrongCharDir,
- resolveBlockDir: resolveBlockDir,
- getDirection: getDirection,
- isDirectionLTR: isDirectionLTR,
- isDirectionRTL: isDirectionRTL
- };
- module.exports = UnicodeBidi;
-
- /***/ }),
- /* 34 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var React = __webpack_require__(8);
-
- var cx = __webpack_require__(13);
-
- var _require = __webpack_require__(0),
- Map = _require.Map;
-
- var UL_WRAP = React.createElement("ul", {
- className: cx('public/DraftStyleDefault/ul')
- });
- var OL_WRAP = React.createElement("ol", {
- className: cx('public/DraftStyleDefault/ol')
- });
- var PRE_WRAP = React.createElement("pre", {
- className: cx('public/DraftStyleDefault/pre')
- });
- var DefaultDraftBlockRenderMap = Map({
- 'header-one': {
- element: 'h1'
- },
- 'header-two': {
- element: 'h2'
- },
- 'header-three': {
- element: 'h3'
- },
- 'header-four': {
- element: 'h4'
- },
- 'header-five': {
- element: 'h5'
- },
- 'header-six': {
- element: 'h6'
- },
- section: {
- element: 'section'
- },
- article: {
- element: 'article'
- },
- 'unordered-list-item': {
- element: 'li',
- wrapper: UL_WRAP
- },
- 'ordered-list-item': {
- element: 'li',
- wrapper: OL_WRAP
- },
- blockquote: {
- element: 'blockquote'
- },
- atomic: {
- element: 'figure'
- },
- 'code-block': {
- element: 'pre',
- wrapper: PRE_WRAP
- },
- unstyled: {
- element: 'div',
- aliasedElements: ['p']
- }
- });
- module.exports = DefaultDraftBlockRenderMap;
-
- /***/ }),
- /* 35 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var _require = __webpack_require__(57),
- notEmptyKey = _require.notEmptyKey;
- /**
- * Return the entity key that should be used when inserting text for the
- * specified target selection, only if the entity is `MUTABLE`. `IMMUTABLE`
- * and `SEGMENTED` entities should not be used for insertion behavior.
- */
-
-
- function getEntityKeyForSelection(contentState, targetSelection) {
- var entityKey;
-
- if (targetSelection.isCollapsed()) {
- var key = targetSelection.getAnchorKey();
- var offset = targetSelection.getAnchorOffset();
-
- if (offset > 0) {
- entityKey = contentState.getBlockForKey(key).getEntityAt(offset - 1);
-
- if (entityKey !== contentState.getBlockForKey(key).getEntityAt(offset)) {
- return null;
- }
-
- return filterKey(contentState.getEntityMap(), entityKey);
- }
-
- return null;
- }
-
- var startKey = targetSelection.getStartKey();
- var startOffset = targetSelection.getStartOffset();
- var startBlock = contentState.getBlockForKey(startKey);
- entityKey = startOffset === startBlock.getLength() ? null : startBlock.getEntityAt(startOffset);
- return filterKey(contentState.getEntityMap(), entityKey);
- }
- /**
- * Determine whether an entity key corresponds to a `MUTABLE` entity. If so,
- * return it. If not, return null.
- */
-
-
- function filterKey(entityMap, entityKey) {
- if (notEmptyKey(entityKey)) {
- var entity = entityMap.__get(entityKey);
-
- return entity.getMutability() === 'MUTABLE' ? entityKey : null;
- }
-
- return null;
- }
-
- module.exports = getEntityKeyForSelection;
-
- /***/ }),
- /* 36 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- */
- var isTextNode = __webpack_require__(111);
- /*eslint-disable no-bitwise */
-
- /**
- * Checks if a given DOM node contains or is another DOM node.
- */
-
-
- function containsNode(outerNode, innerNode) {
- if (!outerNode || !innerNode) {
- return false;
- } else if (outerNode === innerNode) {
- return true;
- } else if (isTextNode(outerNode)) {
- return false;
- } else if (isTextNode(innerNode)) {
- return containsNode(outerNode, innerNode.parentNode);
- } else if ('contains' in outerNode) {
- return outerNode.contains(innerNode);
- } else if (outerNode.compareDocumentPosition) {
- return !!(outerNode.compareDocumentPosition(innerNode) & 16);
- } else {
- return false;
- }
- }
-
- module.exports = containsNode;
-
- /***/ }),
- /* 37 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
-
- /**
- * @param {DOMElement} element
- * @param {DOMDocument} doc
- * @return {boolean}
- */
- function _isViewportScrollElement(element, doc) {
- return !!doc && (element === doc.documentElement || element === doc.body);
- }
- /**
- * Scroll Module. This class contains 4 simple static functions
- * to be used to access Element.scrollTop/scrollLeft properties.
- * To solve the inconsistencies between browsers when either
- * document.body or document.documentElement is supplied,
- * below logic will be used to alleviate the issue:
- *
- * 1. If 'element' is either 'document.body' or 'document.documentElement,
- * get whichever element's 'scroll{Top,Left}' is larger.
- * 2. If 'element' is either 'document.body' or 'document.documentElement',
- * set the 'scroll{Top,Left}' on both elements.
- */
-
-
- var Scroll = {
- /**
- * @param {DOMElement} element
- * @return {number}
- */
- getTop: function getTop(element) {
- var doc = element.ownerDocument;
- return _isViewportScrollElement(element, doc) ? // In practice, they will either both have the same value,
- // or one will be zero and the other will be the scroll position
- // of the viewport. So we can use `X || Y` instead of `Math.max(X, Y)`
- doc.body.scrollTop || doc.documentElement.scrollTop : element.scrollTop;
- },
-
- /**
- * @param {DOMElement} element
- * @param {number} newTop
- */
- setTop: function setTop(element, newTop) {
- var doc = element.ownerDocument;
-
- if (_isViewportScrollElement(element, doc)) {
- doc.body.scrollTop = doc.documentElement.scrollTop = newTop;
- } else {
- element.scrollTop = newTop;
- }
- },
-
- /**
- * @param {DOMElement} element
- * @return {number}
- */
- getLeft: function getLeft(element) {
- var doc = element.ownerDocument;
- return _isViewportScrollElement(element, doc) ? doc.body.scrollLeft || doc.documentElement.scrollLeft : element.scrollLeft;
- },
-
- /**
- * @param {DOMElement} element
- * @param {number} newLeft
- */
- setLeft: function setLeft(element, newLeft) {
- var doc = element.ownerDocument;
-
- if (_isViewportScrollElement(element, doc)) {
- doc.body.scrollLeft = doc.documentElement.scrollLeft = newLeft;
- } else {
- element.scrollLeft = newLeft;
- }
- }
- };
- module.exports = Scroll;
-
- /***/ }),
- /* 38 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var warning = __webpack_require__(39);
- /**
- * Given a collapsed selection, move the focus `maxDistance` backward within
- * the selected block. If the selection will go beyond the start of the block,
- * move focus to the end of the previous block, but no further.
- *
- * This function is not Unicode-aware, so surrogate pairs will be treated
- * as having length 2.
- */
-
-
- function moveSelectionBackward(editorState, maxDistance) {
- var selection = editorState.getSelection(); // Should eventually make this an invariant
-
- true ? warning(selection.isCollapsed(), 'moveSelectionBackward should only be called with a collapsed SelectionState') : void 0;
- var content = editorState.getCurrentContent();
- var key = selection.getStartKey();
- var offset = selection.getStartOffset();
- var focusKey = key;
- var focusOffset = 0;
-
- if (maxDistance > offset) {
- var keyBefore = content.getKeyBefore(key);
-
- if (keyBefore == null) {
- focusKey = key;
- } else {
- focusKey = keyBefore;
- var blockBefore = content.getBlockForKey(keyBefore);
- focusOffset = blockBefore.getText().length;
- }
- } else {
- focusOffset = offset - maxDistance;
- }
-
- return selection.merge({
- focusKey: focusKey,
- focusOffset: focusOffset,
- isBackward: true
- });
- }
-
- module.exports = moveSelectionBackward;
-
- /***/ }),
- /* 39 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2014-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
-
-
- var emptyFunction = __webpack_require__(66);
- /**
- * Similar to invariant but only logs a warning if the condition is not met.
- * This can be used to log issues in development environments in critical
- * paths. Removing the logging code for production environments will keep the
- * same logic and follow the same code paths.
- */
-
-
- function printWarning(format) {
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- args[_key - 1] = arguments[_key];
- }
-
- var argIndex = 0;
- var message = 'Warning: ' + format.replace(/%s/g, function () {
- return args[argIndex++];
- });
-
- if (typeof console !== 'undefined') {
- console.error(message);
- }
-
- try {
- // --- Welcome to debugging React ---
- // This error was thrown as a convenience so that you can use this stack
- // to find the callsite that caused this warning to fire.
- throw new Error(message);
- } catch (x) {}
- }
-
- var warning = true ? function (condition, format) {
- if (format === undefined) {
- throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
- }
-
- if (!condition) {
- for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
- args[_key2 - 2] = arguments[_key2];
- }
-
- printWarning.apply(void 0, [format].concat(args));
- }
- } : emptyFunction;
- module.exports = warning;
-
- /***/ }),
- /* 40 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var UserAgent = __webpack_require__(5);
-
- var isSoftNewlineEvent = __webpack_require__(140);
-
- var isOSX = UserAgent.isPlatform('Mac OS X');
- var KeyBindingUtil = {
- /**
- * Check whether the ctrlKey modifier is *not* being used in conjunction with
- * the altKey modifier. If they are combined, the result is an `altGraph`
- * key modifier, which should not be handled by this set of key bindings.
- */
- isCtrlKeyCommand: function isCtrlKeyCommand(e) {
- return !!e.ctrlKey && !e.altKey;
- },
- isOptionKeyCommand: function isOptionKeyCommand(e) {
- return isOSX && e.altKey;
- },
- usesMacOSHeuristics: function usesMacOSHeuristics() {
- return isOSX;
- },
- hasCommandModifier: function hasCommandModifier(e) {
- return isOSX ? !!e.metaKey && !e.altKey : KeyBindingUtil.isCtrlKeyCommand(e);
- },
- isSoftNewlineEvent: isSoftNewlineEvent
- };
- module.exports = KeyBindingUtil;
-
- /***/ }),
- /* 41 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var ContentBlockNode = __webpack_require__(7);
-
- var generateRandomKey = __webpack_require__(9);
-
- var Immutable = __webpack_require__(0);
-
- var OrderedMap = Immutable.OrderedMap;
-
- var randomizeContentBlockNodeKeys = function randomizeContentBlockNodeKeys(blockMap) {
- var newKeysRef = {}; // we keep track of root blocks in order to update subsequent sibling links
-
- var lastRootBlock;
- return OrderedMap(blockMap.withMutations(function (blockMapState) {
- blockMapState.forEach(function (block, index) {
- var oldKey = block.getKey();
- var nextKey = block.getNextSiblingKey();
- var prevKey = block.getPrevSiblingKey();
- var childrenKeys = block.getChildKeys();
- var parentKey = block.getParentKey(); // new key that we will use to build linking
-
- var key = generateRandomKey(); // we will add it here to re-use it later
-
- newKeysRef[oldKey] = key;
-
- if (nextKey) {
- var nextBlock = blockMapState.get(nextKey);
-
- if (nextBlock) {
- blockMapState.setIn([nextKey, 'prevSibling'], key);
- } else {
- // this can happen when generating random keys for fragments
- blockMapState.setIn([oldKey, 'nextSibling'], null);
- }
- }
-
- if (prevKey) {
- var prevBlock = blockMapState.get(prevKey);
-
- if (prevBlock) {
- blockMapState.setIn([prevKey, 'nextSibling'], key);
- } else {
- // this can happen when generating random keys for fragments
- blockMapState.setIn([oldKey, 'prevSibling'], null);
- }
- }
-
- if (parentKey && blockMapState.get(parentKey)) {
- var parentBlock = blockMapState.get(parentKey);
- var parentChildrenList = parentBlock.getChildKeys();
- blockMapState.setIn([parentKey, 'children'], parentChildrenList.set(parentChildrenList.indexOf(block.getKey()), key));
- } else {
- // blocks will then be treated as root block nodes
- blockMapState.setIn([oldKey, 'parent'], null);
-
- if (lastRootBlock) {
- blockMapState.setIn([lastRootBlock.getKey(), 'nextSibling'], key);
- blockMapState.setIn([oldKey, 'prevSibling'], newKeysRef[lastRootBlock.getKey()]);
- }
-
- lastRootBlock = blockMapState.get(oldKey);
- }
-
- childrenKeys.forEach(function (childKey) {
- var childBlock = blockMapState.get(childKey);
-
- if (childBlock) {
- blockMapState.setIn([childKey, 'parent'], key);
- } else {
- blockMapState.setIn([oldKey, 'children'], block.getChildKeys().filter(function (child) {
- return child !== childKey;
- }));
- }
- });
- });
- }).toArray().map(function (block) {
- return [newKeysRef[block.getKey()], block.set('key', newKeysRef[block.getKey()])];
- }));
- };
-
- var randomizeContentBlockKeys = function randomizeContentBlockKeys(blockMap) {
- return OrderedMap(blockMap.toArray().map(function (block) {
- var key = generateRandomKey();
- return [key, block.set('key', key)];
- }));
- };
-
- var randomizeBlockMapKeys = function randomizeBlockMapKeys(blockMap) {
- var isTreeBasedBlockMap = blockMap.first() instanceof ContentBlockNode;
-
- if (!isTreeBasedBlockMap) {
- return randomizeContentBlockKeys(blockMap);
- }
-
- return randomizeContentBlockNodeKeys(blockMap);
- };
-
- module.exports = randomizeBlockMapKeys;
-
- /***/ }),
- /* 42 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var CharacterMetadata = __webpack_require__(6);
-
- var findRangesImmutable = __webpack_require__(18);
-
- var invariant = __webpack_require__(1);
-
- function removeEntitiesAtEdges(contentState, selectionState) {
- var blockMap = contentState.getBlockMap();
- var entityMap = contentState.getEntityMap();
- var updatedBlocks = {};
- var startKey = selectionState.getStartKey();
- var startOffset = selectionState.getStartOffset();
- var startBlock = blockMap.get(startKey);
- var updatedStart = removeForBlock(entityMap, startBlock, startOffset);
-
- if (updatedStart !== startBlock) {
- updatedBlocks[startKey] = updatedStart;
- }
-
- var endKey = selectionState.getEndKey();
- var endOffset = selectionState.getEndOffset();
- var endBlock = blockMap.get(endKey);
-
- if (startKey === endKey) {
- endBlock = updatedStart;
- }
-
- var updatedEnd = removeForBlock(entityMap, endBlock, endOffset);
-
- if (updatedEnd !== endBlock) {
- updatedBlocks[endKey] = updatedEnd;
- }
-
- if (!Object.keys(updatedBlocks).length) {
- return contentState.set('selectionAfter', selectionState);
- }
-
- return contentState.merge({
- blockMap: blockMap.merge(updatedBlocks),
- selectionAfter: selectionState
- });
- }
- /**
- * Given a list of characters and an offset that is in the middle of an entity,
- * returns the start and end of the entity that is overlapping the offset.
- * Note: This method requires that the offset be in an entity range.
- */
-
-
- function getRemovalRange(characters, entityKey, offset) {
- var removalRange; // Iterates through a list looking for ranges of matching items
- // based on the 'isEqual' callback.
- // Then instead of returning the result, call the 'found' callback
- // with each range.
- // Then filters those ranges based on the 'filter' callback
- //
- // Here we use it to find ranges of characters with the same entity key.
-
- findRangesImmutable(characters, // the list to iterate through
- function (a, b) {
- return a.getEntity() === b.getEntity();
- }, // 'isEqual' callback
- function (element) {
- return element.getEntity() === entityKey;
- }, // 'filter' callback
- function (start, end) {
- // 'found' callback
- if (start <= offset && end >= offset) {
- // this entity overlaps the offset index
- removalRange = {
- start: start,
- end: end
- };
- }
- });
- !(typeof removalRange === 'object') ? true ? invariant(false, 'Removal range must exist within character list.') : invariant(false) : void 0;
- return removalRange;
- }
-
- function removeForBlock(entityMap, block, offset) {
- var chars = block.getCharacterList();
- var charBefore = offset > 0 ? chars.get(offset - 1) : undefined;
- var charAfter = offset < chars.count() ? chars.get(offset) : undefined;
- var entityBeforeCursor = charBefore ? charBefore.getEntity() : undefined;
- var entityAfterCursor = charAfter ? charAfter.getEntity() : undefined;
-
- if (entityAfterCursor && entityAfterCursor === entityBeforeCursor) {
- var entity = entityMap.__get(entityAfterCursor);
-
- if (entity.getMutability() !== 'MUTABLE') {
- var _getRemovalRange = getRemovalRange(chars, entityAfterCursor, offset),
- start = _getRemovalRange.start,
- end = _getRemovalRange.end;
-
- var current;
-
- while (start < end) {
- current = chars.get(start);
- chars = chars.set(start, CharacterMetadata.applyEntity(current, null));
- start++;
- }
-
- return block.set('characterList', chars);
- }
- }
-
- return block;
- }
-
- module.exports = removeEntitiesAtEdges;
-
- /***/ }),
- /* 43 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- /**
- * Maintain persistence for target list when appending and prepending.
- */
- function insertIntoList(targetListArg, toInsert, offset) {
- var targetList = targetListArg;
-
- if (offset === targetList.count()) {
- toInsert.forEach(function (c) {
- targetList = targetList.push(c);
- });
- } else if (offset === 0) {
- toInsert.reverse().forEach(function (c) {
- targetList = targetList.unshift(c);
- });
- } else {
- var head = targetList.slice(0, offset);
- var tail = targetList.slice(offset);
- targetList = head.concat(toInsert, tail).toList();
- }
-
- return targetList;
- }
-
- module.exports = insertIntoList;
-
- /***/ }),
- /* 44 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var Immutable = __webpack_require__(0);
-
- var Map = Immutable.Map;
-
- function modifyBlockForContentState(contentState, selectionState, operation) {
- var startKey = selectionState.getStartKey();
- var endKey = selectionState.getEndKey();
- var blockMap = contentState.getBlockMap();
- var newBlocks = blockMap.toSeq().skipUntil(function (_, k) {
- return k === startKey;
- }).takeUntil(function (_, k) {
- return k === endKey;
- }).concat(Map([[endKey, blockMap.get(endKey)]])).map(operation);
- return contentState.merge({
- blockMap: blockMap.merge(newBlocks),
- selectionBefore: selectionState,
- selectionAfter: selectionState
- });
- }
-
- module.exports = modifyBlockForContentState;
-
- /***/ }),
- /* 45 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- *
- * This is unstable and not part of the public API and should not be used by
- * production systems. This file may be update/removed without notice.
- */
- var ContentBlockNode = __webpack_require__(7);
-
- var getNextDelimiterBlockKey = function getNextDelimiterBlockKey(block, blockMap) {
- var isExperimentalTreeBlock = block instanceof ContentBlockNode;
-
- if (!isExperimentalTreeBlock) {
- return null;
- }
-
- var nextSiblingKey = block.getNextSiblingKey();
-
- if (nextSiblingKey) {
- return nextSiblingKey;
- }
-
- var parent = block.getParentKey();
-
- if (!parent) {
- return null;
- }
-
- var nextNonDescendantBlock = blockMap.get(parent);
-
- while (nextNonDescendantBlock && !nextNonDescendantBlock.getNextSiblingKey()) {
- var parentKey = nextNonDescendantBlock.getParentKey();
- nextNonDescendantBlock = parentKey ? blockMap.get(parentKey) : null;
- }
-
- if (!nextNonDescendantBlock) {
- return null;
- }
-
- return nextNonDescendantBlock.getNextSiblingKey();
- };
-
- module.exports = getNextDelimiterBlockKey;
-
- /***/ }),
- /* 46 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @legacyServerCallableInstance
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- var Immutable = __webpack_require__(0);
-
- var Record = Immutable.Record;
- var DraftEntityInstanceRecord = Record({
- type: 'TOKEN',
- mutability: 'IMMUTABLE',
- data: Object
- });
- /**
- * An instance of a document entity, consisting of a `type` and relevant
- * `data`, metadata about the entity.
- *
- * For instance, a "link" entity might provide a URI, and a "mention"
- * entity might provide the mentioned user's ID. These pieces of data
- * may be used when rendering the entity as part of a ContentBlock DOM
- * representation. For a link, the data would be used as an href for
- * the rendered anchor. For a mention, the ID could be used to retrieve
- * a hovercard.
- */
-
- var DraftEntityInstance =
- /*#__PURE__*/
- function (_DraftEntityInstanceR) {
- _inheritsLoose(DraftEntityInstance, _DraftEntityInstanceR);
-
- function DraftEntityInstance() {
- return _DraftEntityInstanceR.apply(this, arguments) || this;
- }
-
- var _proto = DraftEntityInstance.prototype;
-
- _proto.getType = function getType() {
- return this.get('type');
- };
-
- _proto.getMutability = function getMutability() {
- return this.get('mutability');
- };
-
- _proto.getData = function getData() {
- return this.get('data');
- };
-
- return DraftEntityInstance;
- }(DraftEntityInstanceRecord);
-
- module.exports = DraftEntityInstance;
-
- /***/ }),
- /* 47 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var REGEX_BLOCK_DELIMITER = new RegExp('\r', 'g');
-
- function sanitizeDraftText(input) {
- return input.replace(REGEX_BLOCK_DELIMITER, '');
- }
-
- module.exports = sanitizeDraftText;
-
- /***/ }),
- /* 48 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- module.exports = {
- BOLD: {
- fontWeight: 'bold'
- },
- CODE: {
- fontFamily: 'monospace',
- wordWrap: 'break-word'
- },
- ITALIC: {
- fontStyle: 'italic'
- },
- STRIKETHROUGH: {
- textDecoration: 'line-through'
- },
- UNDERLINE: {
- textDecoration: 'underline'
- }
- };
-
- /***/ }),
- /* 49 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
- /**
- * Get offset key from a node or it's child nodes. Return the first offset key
- * found on the DOM tree of given node.
- */
-
- var isElement = __webpack_require__(15);
-
- function getSelectionOffsetKeyForNode(node) {
- if (isElement(node)) {
- var castedNode = node;
- var offsetKey = castedNode.getAttribute('data-offset-key');
-
- if (offsetKey) {
- return offsetKey;
- }
-
- for (var ii = 0; ii < castedNode.childNodes.length; ii++) {
- var childOffsetKey = getSelectionOffsetKeyForNode(castedNode.childNodes[ii]);
-
- if (childOffsetKey) {
- return childOffsetKey;
- }
- }
- }
-
- return null;
- }
-
- module.exports = getSelectionOffsetKeyForNode;
-
- /***/ }),
- /* 50 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
- function getWindowForNode(node) {
- if (!node || !node.ownerDocument || !node.ownerDocument.defaultView) {
- return window;
- }
-
- return node.ownerDocument.defaultView;
- }
-
- module.exports = getWindowForNode;
-
- /***/ }),
- /* 51 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftJsDebugLogging = __webpack_require__(52);
-
- var EditorState = __webpack_require__(2);
-
- var getContentEditableContainer = __webpack_require__(53);
-
- var getDraftEditorSelection = __webpack_require__(54);
-
- function editOnSelect(editor) {
- if (editor._blockSelectEvents || editor._latestEditorState !== editor.props.editorState) {
- if (editor._blockSelectEvents) {
- var _editorState = editor.props.editorState;
-
- var selectionState = _editorState.getSelection();
-
- DraftJsDebugLogging.logBlockedSelectionEvent({
- // For now I don't think we need any other info
- anonymizedDom: 'N/A',
- extraParams: JSON.stringify({
- stacktrace: new Error().stack
- }),
- selectionState: JSON.stringify(selectionState.toJS())
- });
- }
-
- return;
- }
-
- var editorState = editor.props.editorState;
- var documentSelection = getDraftEditorSelection(editorState, getContentEditableContainer(editor));
- var updatedSelectionState = documentSelection.selectionState;
-
- if (updatedSelectionState !== editorState.getSelection()) {
- if (documentSelection.needsRecovery) {
- editorState = EditorState.forceSelection(editorState, updatedSelectionState);
- } else {
- editorState = EditorState.acceptSelection(editorState, updatedSelectionState);
- }
-
- editor.update(editorState);
- }
- }
-
- module.exports = editOnSelect;
-
- /***/ }),
- /* 52 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
-
-
- module.exports = {
- logBlockedSelectionEvent: function logBlockedSelectionEvent() {
- return null;
- },
- logSelectionStateFailure: function logSelectionStateFailure() {
- return null;
- }
- };
-
- /***/ }),
- /* 53 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var invariant = __webpack_require__(1);
-
- var isHTMLElement = __webpack_require__(19);
-
- function getContentEditableContainer(editor) {
- var editorNode = editor.editorContainer;
- !editorNode ? true ? invariant(false, 'Missing editorNode') : invariant(false) : void 0;
- !isHTMLElement(editorNode.firstChild) ? true ? invariant(false, 'editorNode.firstChild is not an HTMLElement') : invariant(false) : void 0;
- var htmlElement = editorNode.firstChild;
- return htmlElement;
- }
-
- module.exports = getContentEditableContainer;
-
- /***/ }),
- /* 54 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var getDraftEditorSelectionWithNodes = __webpack_require__(55);
- /**
- * Convert the current selection range to an anchor/focus pair of offset keys
- * and values that can be interpreted by components.
- */
-
-
- function getDraftEditorSelection(editorState, root) {
- var selection = root.ownerDocument.defaultView.getSelection(); // No active selection.
-
- if (selection.rangeCount === 0) {
- return {
- selectionState: editorState.getSelection().set('hasFocus', false),
- needsRecovery: false
- };
- }
-
- return getDraftEditorSelectionWithNodes(editorState, root, selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset);
- }
-
- module.exports = getDraftEditorSelection;
-
- /***/ }),
- /* 55 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var findAncestorOffsetKey = __webpack_require__(26);
-
- var getSelectionOffsetKeyForNode = __webpack_require__(49);
-
- var getUpdatedSelectionState = __webpack_require__(56);
-
- var invariant = __webpack_require__(1);
-
- var isElement = __webpack_require__(15);
-
- var nullthrows = __webpack_require__(4);
-
- /**
- * Convert the current selection range to an anchor/focus pair of offset keys
- * and values that can be interpreted by components.
- */
- function getDraftEditorSelectionWithNodes(editorState, root, anchorNode, anchorOffset, focusNode, focusOffset) {
- var anchorIsTextNode = anchorNode.nodeType === Node.TEXT_NODE;
- var focusIsTextNode = focusNode.nodeType === Node.TEXT_NODE; // If the selection range lies only on text nodes, the task is simple.
- // Find the nearest offset-aware elements and use the
- // offset values supplied by the selection range.
-
- if (anchorIsTextNode && focusIsTextNode) {
- return {
- selectionState: getUpdatedSelectionState(editorState, nullthrows(findAncestorOffsetKey(anchorNode)), anchorOffset, nullthrows(findAncestorOffsetKey(focusNode)), focusOffset),
- needsRecovery: false
- };
- }
-
- var anchorPoint = null;
- var focusPoint = null;
- var needsRecovery = true; // An element is selected. Convert this selection range into leaf offset
- // keys and offset values for consumption at the component level. This
- // is common in Firefox, where select-all and triple click behavior leads
- // to entire elements being selected.
- //
- // Note that we use the `needsRecovery` parameter in the callback here. This
- // is because when certain elements are selected, the behavior for subsequent
- // cursor movement (e.g. via arrow keys) is uncertain and may not match
- // expectations at the component level. For example, if an entire <div> is
- // selected and the user presses the right arrow, Firefox keeps the selection
- // on the <div>. If we allow subsequent keypresses to insert characters
- // natively, they will be inserted into a browser-created text node to the
- // right of that <div>. This is obviously undesirable.
- //
- // With the `needsRecovery` flag, we inform the caller that it is responsible
- // for manually setting the selection state on the rendered document to
- // ensure proper selection state maintenance.
-
- if (anchorIsTextNode) {
- anchorPoint = {
- key: nullthrows(findAncestorOffsetKey(anchorNode)),
- offset: anchorOffset
- };
- focusPoint = getPointForNonTextNode(root, focusNode, focusOffset);
- } else if (focusIsTextNode) {
- focusPoint = {
- key: nullthrows(findAncestorOffsetKey(focusNode)),
- offset: focusOffset
- };
- anchorPoint = getPointForNonTextNode(root, anchorNode, anchorOffset);
- } else {
- anchorPoint = getPointForNonTextNode(root, anchorNode, anchorOffset);
- focusPoint = getPointForNonTextNode(root, focusNode, focusOffset); // If the selection is collapsed on an empty block, don't force recovery.
- // This way, on arrow key selection changes, the browser can move the
- // cursor from a non-zero offset on one block, through empty blocks,
- // to a matching non-zero offset on other text blocks.
-
- if (anchorNode === focusNode && anchorOffset === focusOffset) {
- needsRecovery = !!anchorNode.firstChild && anchorNode.firstChild.nodeName !== 'BR';
- }
- }
-
- return {
- selectionState: getUpdatedSelectionState(editorState, anchorPoint.key, anchorPoint.offset, focusPoint.key, focusPoint.offset),
- needsRecovery: needsRecovery
- };
- }
- /**
- * Identify the first leaf descendant for the given node.
- */
-
-
- function getFirstLeaf(node) {
- while (node.firstChild && ( // data-blocks has no offset
- isElement(node.firstChild) && node.firstChild.getAttribute('data-blocks') === 'true' || getSelectionOffsetKeyForNode(node.firstChild))) {
- node = node.firstChild;
- }
-
- return node;
- }
- /**
- * Identify the last leaf descendant for the given node.
- */
-
-
- function getLastLeaf(node) {
- while (node.lastChild && ( // data-blocks has no offset
- isElement(node.lastChild) && node.lastChild.getAttribute('data-blocks') === 'true' || getSelectionOffsetKeyForNode(node.lastChild))) {
- node = node.lastChild;
- }
-
- return node;
- }
-
- function getPointForNonTextNode(editorRoot, startNode, childOffset) {
- var node = startNode;
- var offsetKey = findAncestorOffsetKey(node);
- !(offsetKey != null || editorRoot && (editorRoot === node || editorRoot.firstChild === node)) ? true ? invariant(false, 'Unknown node in selection range.') : invariant(false) : void 0; // If the editorRoot is the selection, step downward into the content
- // wrapper.
-
- if (editorRoot === node) {
- node = node.firstChild;
- !isElement(node) ? true ? invariant(false, 'Invalid DraftEditorContents node.') : invariant(false) : void 0;
- var castedNode = node; // assignment only added for flow :/
- // otherwise it throws in line 200 saying that node can be null or undefined
-
- node = castedNode;
- !(node.getAttribute('data-contents') === 'true') ? true ? invariant(false, 'Invalid DraftEditorContents structure.') : invariant(false) : void 0;
-
- if (childOffset > 0) {
- childOffset = node.childNodes.length;
- }
- } // If the child offset is zero and we have an offset key, we're done.
- // If there's no offset key because the entire editor is selected,
- // find the leftmost ("first") leaf in the tree and use that as the offset
- // key.
-
-
- if (childOffset === 0) {
- var key = null;
-
- if (offsetKey != null) {
- key = offsetKey;
- } else {
- var firstLeaf = getFirstLeaf(node);
- key = nullthrows(getSelectionOffsetKeyForNode(firstLeaf));
- }
-
- return {
- key: key,
- offset: 0
- };
- }
-
- var nodeBeforeCursor = node.childNodes[childOffset - 1];
- var leafKey = null;
- var textLength = null;
-
- if (!getSelectionOffsetKeyForNode(nodeBeforeCursor)) {
- // Our target node may be a leaf or a text node, in which case we're
- // already where we want to be and can just use the child's length as
- // our offset.
- leafKey = nullthrows(offsetKey);
- textLength = getTextContentLength(nodeBeforeCursor);
- } else {
- // Otherwise, we'll look at the child to the left of the cursor and find
- // the last leaf node in its subtree.
- var lastLeaf = getLastLeaf(nodeBeforeCursor);
- leafKey = nullthrows(getSelectionOffsetKeyForNode(lastLeaf));
- textLength = getTextContentLength(lastLeaf);
- }
-
- return {
- key: leafKey,
- offset: textLength
- };
- }
- /**
- * Return the length of a node's textContent, regarding single newline
- * characters as zero-length. This allows us to avoid problems with identifying
- * the correct selection offset for empty blocks in IE, in which we
- * render newlines instead of break tags.
- */
-
-
- function getTextContentLength(node) {
- var textContent = node.textContent;
- return textContent === '\n' ? 0 : textContent.length;
- }
-
- module.exports = getDraftEditorSelectionWithNodes;
-
- /***/ }),
- /* 56 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftOffsetKey = __webpack_require__(10);
-
- var nullthrows = __webpack_require__(4);
-
- function getUpdatedSelectionState(editorState, anchorKey, anchorOffset, focusKey, focusOffset) {
- var selection = nullthrows(editorState.getSelection());
-
- if (true) {
- if (!anchorKey || !focusKey) {
- /* eslint-disable-next-line */
- console.warn('Invalid selection state.', arguments, editorState.toJS());
- return selection;
- }
- }
-
- var anchorPath = DraftOffsetKey.decode(anchorKey);
- var anchorBlockKey = anchorPath.blockKey;
- var anchorLeafBlockTree = editorState.getBlockTree(anchorBlockKey);
- var anchorLeaf = anchorLeafBlockTree && anchorLeafBlockTree.getIn([anchorPath.decoratorKey, 'leaves', anchorPath.leafKey]);
- var focusPath = DraftOffsetKey.decode(focusKey);
- var focusBlockKey = focusPath.blockKey;
- var focusLeafBlockTree = editorState.getBlockTree(focusBlockKey);
- var focusLeaf = focusLeafBlockTree && focusLeafBlockTree.getIn([focusPath.decoratorKey, 'leaves', focusPath.leafKey]);
-
- if (!anchorLeaf || !focusLeaf) {
- // If we cannot make sense of the updated selection state, stick to the current one.
- if (true) {
- /* eslint-disable-next-line */
- console.warn('Invalid selection state.', arguments, editorState.toJS());
- }
-
- return selection;
- }
-
- var anchorLeafStart = anchorLeaf.get('start');
- var focusLeafStart = focusLeaf.get('start');
- var anchorBlockOffset = anchorLeaf ? anchorLeafStart + anchorOffset : null;
- var focusBlockOffset = focusLeaf ? focusLeafStart + focusOffset : null;
- var areEqual = selection.getAnchorKey() === anchorBlockKey && selection.getAnchorOffset() === anchorBlockOffset && selection.getFocusKey() === focusBlockKey && selection.getFocusOffset() === focusBlockOffset;
-
- if (areEqual) {
- return selection;
- }
-
- var isBackward = false;
-
- if (anchorBlockKey === focusBlockKey) {
- var anchorLeafEnd = anchorLeaf.get('end');
- var focusLeafEnd = focusLeaf.get('end');
-
- if (focusLeafStart === anchorLeafStart && focusLeafEnd === anchorLeafEnd) {
- isBackward = focusOffset < anchorOffset;
- } else {
- isBackward = focusLeafStart < anchorLeafStart;
- }
- } else {
- var startKey = editorState.getCurrentContent().getBlockMap().keySeq().skipUntil(function (v) {
- return v === anchorBlockKey || v === focusBlockKey;
- }).first();
- isBackward = startKey === focusBlockKey;
- }
-
- return selection.merge({
- anchorKey: anchorBlockKey,
- anchorOffset: anchorBlockOffset,
- focusKey: focusBlockKey,
- focusOffset: focusBlockOffset,
- isBackward: isBackward
- });
- }
-
- module.exports = getUpdatedSelectionState;
-
- /***/ }),
- /* 57 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * Provides utilities for handling draftjs keys.
- *
- * @emails oncall+draft_js
- *
- * @format
- */
-
-
- function notEmptyKey(key) {
- return key != null && key != '';
- }
-
- module.exports = {
- notEmptyKey: notEmptyKey
- };
-
- /***/ }),
- /* 58 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var _assign = __webpack_require__(14);
-
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- var DraftEditorTextNode = __webpack_require__(109);
-
- var React = __webpack_require__(8);
-
- var invariant = __webpack_require__(1);
-
- var isHTMLBRElement = __webpack_require__(59);
-
- var setDraftEditorSelection = __webpack_require__(110).setDraftEditorSelection;
-
- /**
- * All leaf nodes in the editor are spans with single text nodes. Leaf
- * elements are styled based on the merging of an optional custom style map
- * and a default style map.
- *
- * `DraftEditorLeaf` also provides a wrapper for calling into the imperative
- * DOM Selection API. In this way, top-level components can declaratively
- * maintain the selection state.
- */
- var DraftEditorLeaf =
- /*#__PURE__*/
- function (_React$Component) {
- _inheritsLoose(DraftEditorLeaf, _React$Component);
-
- function DraftEditorLeaf() {
- var _this;
-
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
-
- _defineProperty(_assertThisInitialized(_this), "leaf", void 0);
-
- return _this;
- }
-
- var _proto = DraftEditorLeaf.prototype;
-
- _proto._setSelection = function _setSelection() {
- var selection = this.props.selection; // If selection state is irrelevant to the parent block, no-op.
-
- if (selection == null || !selection.getHasFocus()) {
- return;
- }
-
- var _this$props = this.props,
- block = _this$props.block,
- start = _this$props.start,
- text = _this$props.text;
- var blockKey = block.getKey();
- var end = start + text.length;
-
- if (!selection.hasEdgeWithin(blockKey, start, end)) {
- return;
- } // Determine the appropriate target node for selection. If the child
- // is not a text node, it is a <br /> spacer. In this case, use the
- // <span> itself as the selection target.
-
-
- var node = this.leaf;
- !node ? true ? invariant(false, 'Missing node') : invariant(false) : void 0;
- var child = node.firstChild;
- !child ? true ? invariant(false, 'Missing child') : invariant(false) : void 0;
- var targetNode;
-
- if (child.nodeType === Node.TEXT_NODE) {
- targetNode = child;
- } else if (isHTMLBRElement(child)) {
- targetNode = node;
- } else {
- targetNode = child.firstChild;
- !targetNode ? true ? invariant(false, 'Missing targetNode') : invariant(false) : void 0;
- }
-
- setDraftEditorSelection(selection, targetNode, blockKey, start, end);
- };
-
- _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
- var leafNode = this.leaf;
- !leafNode ? true ? invariant(false, 'Missing leafNode') : invariant(false) : void 0;
- var shouldUpdate = leafNode.textContent !== nextProps.text || nextProps.styleSet !== this.props.styleSet || nextProps.forceSelection;
- return shouldUpdate;
- };
-
- _proto.componentDidUpdate = function componentDidUpdate() {
- this._setSelection();
- };
-
- _proto.componentDidMount = function componentDidMount() {
- this._setSelection();
- };
-
- _proto.render = function render() {
- var _this2 = this;
-
- var block = this.props.block;
- var text = this.props.text; // If the leaf is at the end of its block and ends in a soft newline, append
- // an extra line feed character. Browsers collapse trailing newline
- // characters, which leaves the cursor in the wrong place after a
- // shift+enter. The extra character repairs this.
-
- if (text.endsWith('\n') && this.props.isLast) {
- text += '\n';
- }
-
- var _this$props2 = this.props,
- customStyleMap = _this$props2.customStyleMap,
- customStyleFn = _this$props2.customStyleFn,
- offsetKey = _this$props2.offsetKey,
- styleSet = _this$props2.styleSet;
- var styleObj = styleSet.reduce(function (map, styleName) {
- var mergedStyles = {};
- var style = customStyleMap[styleName];
-
- if (style !== undefined && map.textDecoration !== style.textDecoration) {
- // .trim() is necessary for IE9/10/11 and Edge
- mergedStyles.textDecoration = [map.textDecoration, style.textDecoration].join(' ').trim();
- }
-
- return _assign(map, style, mergedStyles);
- }, {});
-
- if (customStyleFn) {
- var newStyles = customStyleFn(styleSet, block);
- styleObj = _assign(styleObj, newStyles);
- }
-
- return React.createElement("span", {
- "data-offset-key": offsetKey,
- ref: function ref(_ref) {
- return _this2.leaf = _ref;
- },
- style: styleObj
- }, React.createElement(DraftEditorTextNode, null, text));
- };
-
- return DraftEditorLeaf;
- }(React.Component);
-
- module.exports = DraftEditorLeaf;
-
- /***/ }),
- /* 59 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
- var isElement = __webpack_require__(15);
-
- function isHTMLBRElement(node) {
- if (!node || !node.ownerDocument) {
- return false;
- }
-
- return isElement(node) && node.nodeName === 'BR';
- }
-
- module.exports = isHTMLBRElement;
-
- /***/ }),
- /* 60 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
-
-
- module.exports = {
- initODS: function initODS() {},
- handleExtensionCausedError: function handleExtensionCausedError() {}
- };
-
- /***/ }),
- /* 61 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
- /* eslint-disable fb-www/typeof-undefined */
-
- /**
- * Same as document.activeElement but wraps in a try-catch block. In IE it is
- * not safe to call document.activeElement if there is nothing focused.
- *
- * The activeElement will be null only if the document or document body is not
- * yet defined.
- *
- * @param {?DOMDocument} doc Defaults to current document.
- * @return {?DOMElement}
- */
- function getActiveElement(doc)
- /*?DOMElement*/
- {
- doc = doc || (typeof document !== 'undefined' ? document : undefined);
-
- if (typeof doc === 'undefined') {
- return null;
- }
-
- try {
- return doc.activeElement || doc.body;
- } catch (e) {
- return doc.body;
- }
- }
-
- module.exports = getActiveElement;
-
- /***/ }),
- /* 62 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
- var getElementRect = __webpack_require__(116);
- /**
- * Gets an element's position in pixels relative to the viewport. The returned
- * object represents the position of the element's top left corner.
- *
- * @param {DOMElement} element
- * @return {object}
- */
-
-
- function getElementPosition(element) {
- var rect = getElementRect(element);
- return {
- x: rect.left,
- y: rect.top,
- width: rect.right - rect.left,
- height: rect.bottom - rect.top
- };
- }
-
- module.exports = getElementPosition;
-
- /***/ }),
- /* 63 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- * @typechecks
- */
- function getViewportWidth() {
- var width;
-
- if (document.documentElement) {
- width = document.documentElement.clientWidth;
- }
-
- if (!width && document.body) {
- width = document.body.clientWidth;
- }
-
- return width || 0;
- }
-
- function getViewportHeight() {
- var height;
-
- if (document.documentElement) {
- height = document.documentElement.clientHeight;
- }
-
- if (!height && document.body) {
- height = document.body.clientHeight;
- }
-
- return height || 0;
- }
- /**
- * Gets the viewport dimensions including any scrollbars.
- */
-
-
- function getViewportDimensions() {
- return {
- width: window.innerWidth || getViewportWidth(),
- height: window.innerHeight || getViewportHeight()
- };
- }
- /**
- * Gets the viewport dimensions excluding any scrollbars.
- */
-
-
- getViewportDimensions.withoutScrollbars = function () {
- return {
- width: getViewportWidth(),
- height: getViewportHeight()
- };
- };
-
- module.exports = getViewportDimensions;
-
- /***/ }),
- /* 64 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var _assign = __webpack_require__(14);
-
- function _extends() { _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
-
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- var DraftEditorLeaf = __webpack_require__(58);
-
- var DraftOffsetKey = __webpack_require__(10);
-
- var React = __webpack_require__(8);
-
- var Scroll = __webpack_require__(37);
-
- var Style = __webpack_require__(29);
-
- var UnicodeBidi = __webpack_require__(33);
-
- var UnicodeBidiDirection = __webpack_require__(24);
-
- var cx = __webpack_require__(13);
-
- var getElementPosition = __webpack_require__(62);
-
- var getScrollPosition = __webpack_require__(30);
-
- var getViewportDimensions = __webpack_require__(63);
-
- var invariant = __webpack_require__(1);
-
- var isHTMLElement = __webpack_require__(19);
-
- var nullthrows = __webpack_require__(4);
-
- var SCROLL_BUFFER = 10;
-
- /**
- * Return whether a block overlaps with either edge of the `SelectionState`.
- */
- var isBlockOnSelectionEdge = function isBlockOnSelectionEdge(selection, key) {
- return selection.getAnchorKey() === key || selection.getFocusKey() === key;
- };
- /**
- * The default block renderer for a `DraftEditor` component.
- *
- * A `DraftEditorBlock` is able to render a given `ContentBlock` to its
- * appropriate decorator and inline style components.
- */
-
-
- var DraftEditorBlock =
- /*#__PURE__*/
- function (_React$Component) {
- _inheritsLoose(DraftEditorBlock, _React$Component);
-
- function DraftEditorBlock() {
- var _this;
-
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
-
- _defineProperty(_assertThisInitialized(_this), "_node", void 0);
-
- return _this;
- }
-
- var _proto = DraftEditorBlock.prototype;
-
- _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
- return this.props.block !== nextProps.block || this.props.tree !== nextProps.tree || this.props.direction !== nextProps.direction || isBlockOnSelectionEdge(nextProps.selection, nextProps.block.getKey()) && nextProps.forceSelection;
- }
- /**
- * When a block is mounted and overlaps the selection state, we need to make
- * sure that the cursor is visible to match native behavior. This may not
- * be the case if the user has pressed `RETURN` or pasted some content, since
- * programmatically creating these new blocks and setting the DOM selection
- * will miss out on the browser natively scrolling to that position.
- *
- * To replicate native behavior, if the block overlaps the selection state
- * on mount, force the scroll position. Check the scroll state of the scroll
- * parent, and adjust it to align the entire block to the bottom of the
- * scroll parent.
- */
- ;
-
- _proto.componentDidMount = function componentDidMount() {
- if (this.props.preventScroll) {
- return;
- }
-
- var selection = this.props.selection;
- var endKey = selection.getEndKey();
-
- if (!selection.getHasFocus() || endKey !== this.props.block.getKey()) {
- return;
- }
-
- var blockNode = this._node;
-
- if (blockNode == null) {
- return;
- }
-
- var scrollParent = Style.getScrollParent(blockNode);
- var scrollPosition = getScrollPosition(scrollParent);
- var scrollDelta;
-
- if (scrollParent === window) {
- var nodePosition = getElementPosition(blockNode);
- var nodeBottom = nodePosition.y + nodePosition.height;
- var viewportHeight = getViewportDimensions().height;
- scrollDelta = nodeBottom - viewportHeight;
-
- if (scrollDelta > 0) {
- window.scrollTo(scrollPosition.x, scrollPosition.y + scrollDelta + SCROLL_BUFFER);
- }
- } else {
- !isHTMLElement(blockNode) ? true ? invariant(false, 'blockNode is not an HTMLElement') : invariant(false) : void 0;
- var blockBottom = blockNode.offsetHeight + blockNode.offsetTop;
- var pOffset = scrollParent.offsetTop + scrollParent.offsetHeight;
- var scrollBottom = pOffset + scrollPosition.y;
- scrollDelta = blockBottom - scrollBottom;
-
- if (scrollDelta > 0) {
- Scroll.setTop(scrollParent, Scroll.getTop(scrollParent) + scrollDelta + SCROLL_BUFFER);
- }
- }
- };
-
- _proto._renderChildren = function _renderChildren() {
- var _this2 = this;
-
- var block = this.props.block;
- var blockKey = block.getKey();
- var text = block.getText();
- var lastLeafSet = this.props.tree.size - 1;
- var hasSelection = isBlockOnSelectionEdge(this.props.selection, blockKey);
- return this.props.tree.map(function (leafSet, ii) {
- var leavesForLeafSet = leafSet.get('leaves'); // T44088704
-
- if (leavesForLeafSet.size === 0) {
- return null;
- }
-
- var lastLeaf = leavesForLeafSet.size - 1;
- var leaves = leavesForLeafSet.map(function (leaf, jj) {
- var offsetKey = DraftOffsetKey.encode(blockKey, ii, jj);
- var start = leaf.get('start');
- var end = leaf.get('end');
- return React.createElement(DraftEditorLeaf, {
- key: offsetKey,
- offsetKey: offsetKey,
- block: block,
- start: start,
- selection: hasSelection ? _this2.props.selection : null,
- forceSelection: _this2.props.forceSelection,
- text: text.slice(start, end),
- styleSet: block.getInlineStyleAt(start),
- customStyleMap: _this2.props.customStyleMap,
- customStyleFn: _this2.props.customStyleFn,
- isLast: ii === lastLeafSet && jj === lastLeaf
- });
- }).toArray();
- var decoratorKey = leafSet.get('decoratorKey');
-
- if (decoratorKey == null) {
- return leaves;
- }
-
- if (!_this2.props.decorator) {
- return leaves;
- }
-
- var decorator = nullthrows(_this2.props.decorator);
- var DecoratorComponent = decorator.getComponentForKey(decoratorKey);
-
- if (!DecoratorComponent) {
- return leaves;
- }
-
- var decoratorProps = decorator.getPropsForKey(decoratorKey);
- var decoratorOffsetKey = DraftOffsetKey.encode(blockKey, ii, 0);
- var start = leavesForLeafSet.first().get('start');
- var end = leavesForLeafSet.last().get('end');
- var decoratedText = text.slice(start, end);
- var entityKey = block.getEntityAt(leafSet.get('start')); // Resetting dir to the same value on a child node makes Chrome/Firefox
- // confused on cursor movement. See http://jsfiddle.net/d157kLck/3/
-
- var dir = UnicodeBidiDirection.getHTMLDirIfDifferent(UnicodeBidi.getDirection(decoratedText), _this2.props.direction);
- var commonProps = {
- contentState: _this2.props.contentState,
- decoratedText: decoratedText,
- dir: dir,
- start: start,
- end: end,
- blockKey: blockKey,
- entityKey: entityKey,
- offsetKey: decoratorOffsetKey
- };
- return React.createElement(DecoratorComponent, _extends({}, decoratorProps, commonProps, {
- key: decoratorOffsetKey
- }), leaves);
- }).toArray();
- };
-
- _proto.render = function render() {
- var _this3 = this;
-
- var _this$props = this.props,
- direction = _this$props.direction,
- offsetKey = _this$props.offsetKey;
- var className = cx({
- 'public/DraftStyleDefault/block': true,
- 'public/DraftStyleDefault/ltr': direction === 'LTR',
- 'public/DraftStyleDefault/rtl': direction === 'RTL'
- });
- return React.createElement("div", {
- "data-offset-key": offsetKey,
- className: className,
- ref: function ref(_ref) {
- return _this3._node = _ref;
- }
- }, this._renderChildren());
- };
-
- return DraftEditorBlock;
- }(React.Component);
-
- module.exports = DraftEditorBlock;
-
- /***/ }),
- /* 65 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
- var PhotosMimeType = __webpack_require__(122);
-
- var createArrayFromMixed = __webpack_require__(123);
-
- var emptyFunction = __webpack_require__(66);
-
- var CR_LF_REGEX = new RegExp("\r\n", 'g');
- var LF_ONLY = "\n";
- var RICH_TEXT_TYPES = {
- 'text/rtf': 1,
- 'text/html': 1
- };
- /**
- * If DataTransferItem is a file then return the Blob of data.
- *
- * @param {object} item
- * @return {?blob}
- */
-
- function getFileFromDataTransfer(item) {
- if (item.kind == 'file') {
- return item.getAsFile();
- }
- }
-
- var DataTransfer =
- /*#__PURE__*/
- function () {
- /**
- * @param {object} data
- */
- function DataTransfer(data) {
- this.data = data; // Types could be DOMStringList or array
-
- this.types = data.types ? createArrayFromMixed(data.types) : [];
- }
- /**
- * Is this likely to be a rich text data transfer?
- *
- * @return {boolean}
- */
-
-
- var _proto = DataTransfer.prototype;
-
- _proto.isRichText = function isRichText() {
- // If HTML is available, treat this data as rich text. This way, we avoid
- // using a pasted image if it is packaged with HTML -- this may occur with
- // pastes from MS Word, for example. However this is only rich text if
- // there's accompanying text.
- if (this.getHTML() && this.getText()) {
- return true;
- } // When an image is copied from a preview window, you end up with two
- // DataTransferItems one of which is a file's metadata as text. Skip those.
-
-
- if (this.isImage()) {
- return false;
- }
-
- return this.types.some(function (type) {
- return RICH_TEXT_TYPES[type];
- });
- };
- /**
- * Get raw text.
- *
- * @return {?string}
- */
-
-
- _proto.getText = function getText() {
- var text;
-
- if (this.data.getData) {
- if (!this.types.length) {
- text = this.data.getData('Text');
- } else if (this.types.indexOf('text/plain') != -1) {
- text = this.data.getData('text/plain');
- }
- }
-
- return text ? text.replace(CR_LF_REGEX, LF_ONLY) : null;
- };
- /**
- * Get HTML paste data
- *
- * @return {?string}
- */
-
-
- _proto.getHTML = function getHTML() {
- if (this.data.getData) {
- if (!this.types.length) {
- return this.data.getData('Text');
- } else if (this.types.indexOf('text/html') != -1) {
- return this.data.getData('text/html');
- }
- }
- };
- /**
- * Is this a link data transfer?
- *
- * @return {boolean}
- */
-
-
- _proto.isLink = function isLink() {
- return this.types.some(function (type) {
- return type.indexOf('Url') != -1 || type.indexOf('text/uri-list') != -1 || type.indexOf('text/x-moz-url');
- });
- };
- /**
- * Get a link url.
- *
- * @return {?string}
- */
-
-
- _proto.getLink = function getLink() {
- if (this.data.getData) {
- if (this.types.indexOf('text/x-moz-url') != -1) {
- var url = this.data.getData('text/x-moz-url').split('\n');
- return url[0];
- }
-
- return this.types.indexOf('text/uri-list') != -1 ? this.data.getData('text/uri-list') : this.data.getData('url');
- }
-
- return null;
- };
- /**
- * Is this an image data transfer?
- *
- * @return {boolean}
- */
-
-
- _proto.isImage = function isImage() {
- var isImage = this.types.some(function (type) {
- // Firefox will have a type of application/x-moz-file for images during
- // dragging
- return type.indexOf('application/x-moz-file') != -1;
- });
-
- if (isImage) {
- return true;
- }
-
- var items = this.getFiles();
-
- for (var i = 0; i < items.length; i++) {
- var type = items[i].type;
-
- if (!PhotosMimeType.isImage(type)) {
- return false;
- }
- }
-
- return true;
- };
-
- _proto.getCount = function getCount() {
- if (this.data.hasOwnProperty('items')) {
- return this.data.items.length;
- } else if (this.data.hasOwnProperty('mozItemCount')) {
- return this.data.mozItemCount;
- } else if (this.data.files) {
- return this.data.files.length;
- }
-
- return null;
- };
- /**
- * Get files.
- *
- * @return {array}
- */
-
-
- _proto.getFiles = function getFiles() {
- if (this.data.items) {
- // createArrayFromMixed doesn't properly handle DataTransferItemLists.
- return Array.prototype.slice.call(this.data.items).map(getFileFromDataTransfer).filter(emptyFunction.thatReturnsArgument);
- } else if (this.data.files) {
- return Array.prototype.slice.call(this.data.files);
- } else {
- return [];
- }
- };
- /**
- * Are there any files to fetch?
- *
- * @return {boolean}
- */
-
-
- _proto.hasFiles = function hasFiles() {
- return this.getFiles().length > 0;
- };
-
- return DataTransfer;
- }();
-
- module.exports = DataTransfer;
-
- /***/ }),
- /* 66 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- */
- function makeEmptyFunction(arg) {
- return function () {
- return arg;
- };
- }
- /**
- * This function accepts and discards inputs; it has no side effects. This is
- * primarily useful idiomatically for overridable function endpoints which
- * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
- */
-
-
- var emptyFunction = function emptyFunction() {};
-
- emptyFunction.thatReturns = makeEmptyFunction;
- emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
- emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
- emptyFunction.thatReturnsNull = makeEmptyFunction(null);
-
- emptyFunction.thatReturnsThis = function () {
- return this;
- };
-
- emptyFunction.thatReturnsArgument = function (arg) {
- return arg;
- };
-
- module.exports = emptyFunction;
-
- /***/ }),
- /* 67 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /* WEBPACK VAR INJECTION */(function(global) {/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var invariant = __webpack_require__(1);
-
- var TEXT_CLIPPING_REGEX = /\.textClipping$/;
- var TEXT_TYPES = {
- 'text/plain': true,
- 'text/html': true,
- 'text/rtf': true
- }; // Somewhat arbitrary upper bound on text size. Let's not lock up the browser.
-
- var TEXT_SIZE_UPPER_BOUND = 5000;
- /**
- * Extract the text content from a file list.
- */
-
- function getTextContentFromFiles(files, callback) {
- var readCount = 0;
- var results = [];
- files.forEach(function (
- /*blob*/
- file) {
- readFile(file, function (
- /*string*/
- text) {
- readCount++;
- text && results.push(text.slice(0, TEXT_SIZE_UPPER_BOUND));
-
- if (readCount == files.length) {
- callback(results.join('\r'));
- }
- });
- });
- }
- /**
- * todo isaac: Do work to turn html/rtf into a content fragment.
- */
-
-
- function readFile(file, callback) {
- if (!global.FileReader || file.type && !(file.type in TEXT_TYPES)) {
- callback('');
- return;
- }
-
- if (file.type === '') {
- var _contents = ''; // Special-case text clippings, which have an empty type but include
- // `.textClipping` in the file name. `readAsText` results in an empty
- // string for text clippings, so we force the file name to serve
- // as the text value for the file.
-
- if (TEXT_CLIPPING_REGEX.test(file.name)) {
- _contents = file.name.replace(TEXT_CLIPPING_REGEX, '');
- }
-
- callback(_contents);
- return;
- }
-
- var reader = new FileReader();
-
- reader.onload = function () {
- var result = reader.result;
- !(typeof result === 'string') ? true ? invariant(false, 'We should be calling "FileReader.readAsText" which returns a string') : invariant(false) : void 0;
- callback(result);
- };
-
- reader.onerror = function () {
- callback('');
- };
-
- reader.readAsText(file);
- }
-
- module.exports = getTextContentFromFiles;
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(25)))
-
- /***/ }),
- /* 68 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var getContentStateFragment = __webpack_require__(21);
-
- function getFragmentFromSelection(editorState) {
- var selectionState = editorState.getSelection();
-
- if (selectionState.isCollapsed()) {
- return null;
- }
-
- return getContentStateFragment(editorState.getCurrentContent(), selectionState);
- }
-
- module.exports = getFragmentFromSelection;
-
- /***/ }),
- /* 69 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var EditorState = __webpack_require__(2);
-
- var UnicodeUtils = __webpack_require__(16);
-
- var moveSelectionBackward = __webpack_require__(38);
-
- var removeTextWithStrategy = __webpack_require__(20);
- /**
- * Remove the selected range. If the cursor is collapsed, remove the preceding
- * character. This operation is Unicode-aware, so removing a single character
- * will remove a surrogate pair properly as well.
- */
-
-
- function keyCommandPlainBackspace(editorState) {
- var afterRemoval = removeTextWithStrategy(editorState, function (strategyState) {
- var selection = strategyState.getSelection();
- var content = strategyState.getCurrentContent();
- var key = selection.getAnchorKey();
- var offset = selection.getAnchorOffset();
- var charBehind = content.getBlockForKey(key).getText()[offset - 1];
- return moveSelectionBackward(strategyState, charBehind ? UnicodeUtils.getUTF16Length(charBehind, 0) : 1);
- }, 'backward');
-
- if (afterRemoval === editorState.getCurrentContent()) {
- return editorState;
- }
-
- var selection = editorState.getSelection();
- return EditorState.push(editorState, afterRemoval.set('selectionBefore', selection), selection.isCollapsed() ? 'backspace-character' : 'remove-range');
- }
-
- module.exports = keyCommandPlainBackspace;
-
- /***/ }),
- /* 70 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var UserAgent = __webpack_require__(5);
-
- var invariant = __webpack_require__(1);
-
- var isChrome = UserAgent.isBrowser('Chrome'); // In Chrome, the client rects will include the entire bounds of all nodes that
- // begin (have a start tag) within the selection, even if the selection does
- // not overlap the entire node. To resolve this, we split the range at each
- // start tag and join the client rects together.
- // https://code.google.com/p/chromium/issues/detail?id=324437
-
- /* eslint-disable consistent-return */
-
- function getRangeClientRectsChrome(range) {
- var tempRange = range.cloneRange();
- var clientRects = [];
-
- for (var ancestor = range.endContainer; ancestor != null; ancestor = ancestor.parentNode) {
- // If we've climbed up to the common ancestor, we can now use the
- // original start point and stop climbing the tree.
- var atCommonAncestor = ancestor === range.commonAncestorContainer;
-
- if (atCommonAncestor) {
- tempRange.setStart(range.startContainer, range.startOffset);
- } else {
- tempRange.setStart(tempRange.endContainer, 0);
- }
-
- var rects = Array.from(tempRange.getClientRects());
- clientRects.push(rects);
-
- if (atCommonAncestor) {
- var _ref;
-
- clientRects.reverse();
- return (_ref = []).concat.apply(_ref, clientRects);
- }
-
- tempRange.setEndBefore(ancestor);
- }
-
- true ? true ? invariant(false, 'Found an unexpected detached subtree when getting range client rects.') : invariant(false) : void 0;
- }
- /* eslint-enable consistent-return */
-
- /**
- * Like range.getClientRects() but normalizes for browser bugs.
- */
-
-
- var getRangeClientRects = isChrome ? getRangeClientRectsChrome : function (range) {
- return Array.from(range.getClientRects());
- };
- module.exports = getRangeClientRects;
-
- /***/ }),
- /* 71 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var TokenizeUtil = __webpack_require__(145);
-
- var punctuation = TokenizeUtil.getPunctuation(); // The apostrophe and curly single quotes behave in a curious way: when
- // surrounded on both sides by word characters, they behave as word chars; when
- // either neighbor is punctuation or an end of the string, they behave as
- // punctuation.
-
- var CHAMELEON_CHARS = "['\u2018\u2019]"; // Remove the underscore, which should count as part of the removable word. The
- // "chameleon chars" also count as punctuation in this regex.
-
- var WHITESPACE_AND_PUNCTUATION = '\\s|(?![_])' + punctuation;
- var DELETE_STRING = '^' + '(?:' + WHITESPACE_AND_PUNCTUATION + ')*' + '(?:' + CHAMELEON_CHARS + '|(?!' + WHITESPACE_AND_PUNCTUATION + ').)*' + '(?:(?!' + WHITESPACE_AND_PUNCTUATION + ').)';
- var DELETE_REGEX = new RegExp(DELETE_STRING);
- var BACKSPACE_STRING = '(?:(?!' + WHITESPACE_AND_PUNCTUATION + ').)' + '(?:' + CHAMELEON_CHARS + '|(?!' + WHITESPACE_AND_PUNCTUATION + ').)*' + '(?:' + WHITESPACE_AND_PUNCTUATION + ')*' + '$';
- var BACKSPACE_REGEX = new RegExp(BACKSPACE_STRING);
-
- function getRemovableWord(text, isBackward) {
- var matches = isBackward ? BACKSPACE_REGEX.exec(text) : DELETE_REGEX.exec(text);
- return matches ? matches[0] : text;
- }
-
- var DraftRemovableWord = {
- getBackward: function getBackward(text) {
- return getRemovableWord(text, true);
- },
- getForward: function getForward(text) {
- return getRemovableWord(text, false);
- }
- };
- module.exports = DraftRemovableWord;
-
- /***/ }),
- /* 72 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var warning = __webpack_require__(39);
- /**
- * Given a collapsed selection, move the focus `maxDistance` forward within
- * the selected block. If the selection will go beyond the end of the block,
- * move focus to the start of the next block, but no further.
- *
- * This function is not Unicode-aware, so surrogate pairs will be treated
- * as having length 2.
- */
-
-
- function moveSelectionForward(editorState, maxDistance) {
- var selection = editorState.getSelection(); // Should eventually make this an invariant
-
- true ? warning(selection.isCollapsed(), 'moveSelectionForward should only be called with a collapsed SelectionState') : void 0;
- var key = selection.getStartKey();
- var offset = selection.getStartOffset();
- var content = editorState.getCurrentContent();
- var focusKey = key;
- var focusOffset;
- var block = content.getBlockForKey(key);
-
- if (maxDistance > block.getText().length - offset) {
- focusKey = content.getKeyAfter(key);
- focusOffset = 0;
- } else {
- focusOffset = offset + maxDistance;
- }
-
- return selection.merge({
- focusKey: focusKey,
- focusOffset: focusOffset
- });
- }
-
- module.exports = moveSelectionForward;
-
- /***/ }),
- /* 73 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var _knownListItemDepthCl;
-
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- var CharacterMetadata = __webpack_require__(6);
-
- var ContentBlock = __webpack_require__(12);
-
- var ContentBlockNode = __webpack_require__(7);
-
- var DefaultDraftBlockRenderMap = __webpack_require__(34);
-
- var DraftEntity = __webpack_require__(22);
-
- var URI = __webpack_require__(155);
-
- var cx = __webpack_require__(13);
-
- var generateRandomKey = __webpack_require__(9);
-
- var getSafeBodyFromHTML = __webpack_require__(74);
-
- var gkx = __webpack_require__(11);
-
- var _require = __webpack_require__(0),
- List = _require.List,
- Map = _require.Map,
- OrderedSet = _require.OrderedSet;
-
- var isHTMLAnchorElement = __webpack_require__(156);
-
- var isHTMLBRElement = __webpack_require__(59);
-
- var isHTMLElement = __webpack_require__(19);
-
- var isHTMLImageElement = __webpack_require__(157);
-
- var experimentalTreeDataSupport = gkx('draft_tree_data_support');
- var NBSP = ' ';
- var SPACE = ' '; // used for replacing characters in HTML
-
- var REGEX_CR = new RegExp('\r', 'g');
- var REGEX_LF = new RegExp('\n', 'g');
- var REGEX_LEADING_LF = new RegExp('^\n', 'g');
- var REGEX_NBSP = new RegExp(NBSP, 'g');
- var REGEX_CARRIAGE = new RegExp(' ?', 'g');
- var REGEX_ZWS = new RegExp('​?', 'g'); // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
-
- var boldValues = ['bold', 'bolder', '500', '600', '700', '800', '900'];
- var notBoldValues = ['light', 'lighter', 'normal', '100', '200', '300', '400'];
- var anchorAttr = ['className', 'href', 'rel', 'target', 'title'];
- var imgAttr = ['alt', 'className', 'height', 'src', 'width'];
- var knownListItemDepthClasses = (_knownListItemDepthCl = {}, _defineProperty(_knownListItemDepthCl, cx('public/DraftStyleDefault/depth0'), 0), _defineProperty(_knownListItemDepthCl, cx('public/DraftStyleDefault/depth1'), 1), _defineProperty(_knownListItemDepthCl, cx('public/DraftStyleDefault/depth2'), 2), _defineProperty(_knownListItemDepthCl, cx('public/DraftStyleDefault/depth3'), 3), _defineProperty(_knownListItemDepthCl, cx('public/DraftStyleDefault/depth4'), 4), _knownListItemDepthCl);
- var HTMLTagToRawInlineStyleMap = Map({
- b: 'BOLD',
- code: 'CODE',
- del: 'STRIKETHROUGH',
- em: 'ITALIC',
- i: 'ITALIC',
- s: 'STRIKETHROUGH',
- strike: 'STRIKETHROUGH',
- strong: 'BOLD',
- u: 'UNDERLINE',
- mark: 'HIGHLIGHT'
- });
-
- /**
- * Build a mapping from HTML tags to draftjs block types
- * out of a BlockRenderMap.
- *
- * The BlockTypeMap for the default BlockRenderMap looks like this:
- * Map({
- * h1: 'header-one',
- * h2: 'header-two',
- * h3: 'header-three',
- * h4: 'header-four',
- * h5: 'header-five',
- * h6: 'header-six',
- * blockquote: 'blockquote',
- * figure: 'atomic',
- * pre: ['code-block'],
- * div: 'unstyled',
- * p: 'unstyled',
- * li: ['ordered-list-item', 'unordered-list-item'],
- * })
- */
- var buildBlockTypeMap = function buildBlockTypeMap(blockRenderMap) {
- var blockTypeMap = {};
- blockRenderMap.mapKeys(function (blockType, desc) {
- var elements = [desc.element];
-
- if (desc.aliasedElements !== undefined) {
- elements.push.apply(elements, desc.aliasedElements);
- }
-
- elements.forEach(function (element) {
- if (blockTypeMap[element] === undefined) {
- blockTypeMap[element] = blockType;
- } else if (typeof blockTypeMap[element] === 'string') {
- blockTypeMap[element] = [blockTypeMap[element], blockType];
- } else {
- blockTypeMap[element].push(blockType);
- }
- });
- });
- return Map(blockTypeMap);
- };
- /**
- * If we're pasting from one DraftEditor to another we can check to see if
- * existing list item depth classes are being used and preserve this style
- */
-
-
- var getListItemDepth = function getListItemDepth(node) {
- var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
- Object.keys(knownListItemDepthClasses).some(function (depthClass) {
- if (node.classList.contains(depthClass)) {
- depth = knownListItemDepthClasses[depthClass];
- }
- });
- return depth;
- };
- /**
- * Return true if the provided HTML Element can be used to build a
- * Draftjs-compatible link.
- */
-
-
- var isValidAnchor = function isValidAnchor(node) {
- if (!isHTMLAnchorElement(node)) {
- return false;
- }
-
- var anchorNode = node;
- return !!(anchorNode.href && (anchorNode.protocol === 'http:' || anchorNode.protocol === 'https:' || anchorNode.protocol === 'mailto:'));
- };
- /**
- * Return true if the provided HTML Element can be used to build a
- * Draftjs-compatible image.
- */
-
-
- var isValidImage = function isValidImage(node) {
- if (!isHTMLImageElement(node)) {
- return false;
- }
-
- var imageNode = node;
- return !!(imageNode.attributes.getNamedItem('src') && imageNode.attributes.getNamedItem('src').value);
- };
- /**
- * Try to guess the inline style of an HTML element based on its css
- * styles (font-weight, font-style and text-decoration).
- */
-
-
- var styleFromNodeAttributes = function styleFromNodeAttributes(node, style) {
- if (!isHTMLElement(node)) {
- return style;
- }
-
- var htmlElement = node;
- var fontWeight = htmlElement.style.fontWeight;
- var fontStyle = htmlElement.style.fontStyle;
- var textDecoration = htmlElement.style.textDecoration;
- return style.withMutations(function (style) {
- if (boldValues.indexOf(fontWeight) >= 0) {
- style.add('BOLD');
- } else if (notBoldValues.indexOf(fontWeight) >= 0) {
- style.remove('BOLD');
- }
-
- if (fontStyle === 'italic') {
- style.add('ITALIC');
- } else if (fontStyle === 'normal') {
- style.remove('ITALIC');
- }
-
- if (textDecoration === 'underline') {
- style.add('UNDERLINE');
- }
-
- if (textDecoration === 'line-through') {
- style.add('STRIKETHROUGH');
- }
-
- if (textDecoration === 'none') {
- style.remove('UNDERLINE');
- style.remove('STRIKETHROUGH');
- }
- });
- };
- /**
- * Determine if a nodeName is a list type, 'ul' or 'ol'
- */
-
-
- var isListNode = function isListNode(nodeName) {
- return nodeName === 'ul' || nodeName === 'ol';
- };
- /**
- * ContentBlockConfig is a mutable data structure that holds all
- * the information required to build a ContentBlock and an array of
- * all the child nodes (childConfigs).
- * It is being used a temporary data structure by the
- * ContentBlocksBuilder class.
- */
-
-
- /**
- * ContentBlocksBuilder builds a list of ContentBlocks and an Entity Map
- * out of one (or several) HTMLElement(s).
- *
- * The algorithm has two passes: first it builds a tree of ContentBlockConfigs
- * by walking through the HTML nodes and their children, then it walks the
- * ContentBlockConfigs tree to compute parents/siblings and create
- * the actual ContentBlocks.
- *
- * Typical usage is:
- * new ContentBlocksBuilder()
- * .addDOMNode(someHTMLNode)
- * .addDOMNode(someOtherHTMLNode)
- * .getContentBlocks();
- *
- */
- var ContentBlocksBuilder =
- /*#__PURE__*/
- function () {
- // Most of the method in the class depend on the state of the content builder
- // (i.e. currentBlockType, currentDepth, currentEntity etc.). Though it may
- // be confusing at first, it made the code simpler than the alternative which
- // is to pass those values around in every call.
- // The following attributes are used to accumulate text and styles
- // as we are walking the HTML node tree.
- // Describes the future ContentState as a tree of content blocks
- // The content blocks generated from the blockConfigs
- // Entity map use to store links and images found in the HTML nodes
- // Map HTML tags to draftjs block types and disambiguation function
- function ContentBlocksBuilder(blockTypeMap, disambiguate) {
- _defineProperty(this, "characterList", List());
-
- _defineProperty(this, "currentBlockType", 'unstyled');
-
- _defineProperty(this, "currentDepth", 0);
-
- _defineProperty(this, "currentEntity", null);
-
- _defineProperty(this, "currentText", '');
-
- _defineProperty(this, "wrapper", null);
-
- _defineProperty(this, "blockConfigs", []);
-
- _defineProperty(this, "contentBlocks", []);
-
- _defineProperty(this, "entityMap", DraftEntity);
-
- _defineProperty(this, "blockTypeMap", void 0);
-
- _defineProperty(this, "disambiguate", void 0);
-
- this.clear();
- this.blockTypeMap = blockTypeMap;
- this.disambiguate = disambiguate;
- }
- /**
- * Clear the internal state of the ContentBlocksBuilder
- */
-
-
- var _proto = ContentBlocksBuilder.prototype;
-
- _proto.clear = function clear() {
- this.characterList = List();
- this.blockConfigs = [];
- this.currentBlockType = 'unstyled';
- this.currentDepth = 0;
- this.currentEntity = null;
- this.currentText = '';
- this.entityMap = DraftEntity;
- this.wrapper = null;
- this.contentBlocks = [];
- }
- /**
- * Add an HTMLElement to the ContentBlocksBuilder
- */
- ;
-
- _proto.addDOMNode = function addDOMNode(node) {
- var _this$blockConfigs;
-
- this.contentBlocks = [];
- this.currentDepth = 0; // Converts the HTML node to block config
-
- (_this$blockConfigs = this.blockConfigs).push.apply(_this$blockConfigs, this._toBlockConfigs([node], OrderedSet())); // There might be some left over text in the builder's
- // internal state, if so make a ContentBlock out of it.
-
-
- this._trimCurrentText();
-
- if (this.currentText !== '') {
- this.blockConfigs.push(this._makeBlockConfig());
- } // for chaining
-
-
- return this;
- }
- /**
- * Return the ContentBlocks and the EntityMap that corresponds
- * to the previously added HTML nodes.
- */
- ;
-
- _proto.getContentBlocks = function getContentBlocks() {
- if (this.contentBlocks.length === 0) {
- if (experimentalTreeDataSupport) {
- this._toContentBlocks(this.blockConfigs);
- } else {
- this._toFlatContentBlocks(this.blockConfigs);
- }
- }
-
- return {
- contentBlocks: this.contentBlocks,
- entityMap: this.entityMap
- };
- } // ***********************************WARNING******************************
- // The methods below this line are private - don't call them directly.
-
- /**
- * Generate a new ContentBlockConfig out of the current internal state
- * of the builder, then clears the internal state.
- */
- ;
-
- _proto._makeBlockConfig = function _makeBlockConfig() {
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- var key = config.key || generateRandomKey();
-
- var block = _objectSpread({
- key: key,
- type: this.currentBlockType,
- text: this.currentText,
- characterList: this.characterList,
- depth: this.currentDepth,
- parent: null,
- children: List(),
- prevSibling: null,
- nextSibling: null,
- childConfigs: []
- }, config);
-
- this.characterList = List();
- this.currentBlockType = 'unstyled';
- this.currentText = '';
- return block;
- }
- /**
- * Converts an array of HTML elements to a multi-root tree of content
- * block configs. Some text content may be left in the builders internal
- * state to enable chaining sucessive calls.
- */
- ;
-
- _proto._toBlockConfigs = function _toBlockConfigs(nodes, style) {
- var blockConfigs = [];
-
- for (var i = 0; i < nodes.length; i++) {
- var node = nodes[i];
- var nodeName = node.nodeName.toLowerCase();
-
- if (nodeName === 'body' || isListNode(nodeName)) {
- // body, ol and ul are 'block' type nodes so create a block config
- // with the text accumulated so far (if any)
- this._trimCurrentText();
-
- if (this.currentText !== '') {
- blockConfigs.push(this._makeBlockConfig());
- } // body, ol and ul nodes are ignored, but their children are inlined in
- // the parent block config.
-
-
- var wasCurrentDepth = this.currentDepth;
- var wasWrapper = this.wrapper;
-
- if (isListNode(nodeName)) {
- this.wrapper = nodeName;
-
- if (isListNode(wasWrapper)) {
- this.currentDepth++;
- }
- }
-
- blockConfigs.push.apply(blockConfigs, this._toBlockConfigs(Array.from(node.childNodes), style));
- this.currentDepth = wasCurrentDepth;
- this.wrapper = wasWrapper;
- continue;
- }
-
- var blockType = this.blockTypeMap.get(nodeName);
-
- if (blockType !== undefined) {
- // 'block' type node means we need to create a block config
- // with the text accumulated so far (if any)
- this._trimCurrentText();
-
- if (this.currentText !== '') {
- blockConfigs.push(this._makeBlockConfig());
- }
-
- var _wasCurrentDepth = this.currentDepth;
- var _wasWrapper = this.wrapper;
- this.wrapper = nodeName === 'pre' ? 'pre' : this.wrapper;
-
- if (typeof blockType !== 'string') {
- blockType = this.disambiguate(nodeName, this.wrapper) || blockType[0] || 'unstyled';
- }
-
- if (!experimentalTreeDataSupport && isHTMLElement(node) && (blockType === 'unordered-list-item' || blockType === 'ordered-list-item')) {
- var htmlElement = node;
- this.currentDepth = getListItemDepth(htmlElement, this.currentDepth);
- }
-
- var key = generateRandomKey();
-
- var childConfigs = this._toBlockConfigs(Array.from(node.childNodes), style);
-
- this._trimCurrentText();
-
- blockConfigs.push(this._makeBlockConfig({
- key: key,
- childConfigs: childConfigs,
- type: blockType
- }));
- this.currentDepth = _wasCurrentDepth;
- this.wrapper = _wasWrapper;
- continue;
- }
-
- if (nodeName === '#text') {
- this._addTextNode(node, style);
-
- continue;
- }
-
- if (nodeName === 'br') {
- this._addBreakNode(node, style);
-
- continue;
- }
-
- if (isValidImage(node)) {
- this._addImgNode(node, style);
-
- continue;
- }
-
- if (isValidAnchor(node)) {
- this._addAnchorNode(node, blockConfigs, style);
-
- continue;
- }
-
- var newStyle = style;
-
- if (HTMLTagToRawInlineStyleMap.has(nodeName)) {
- newStyle = newStyle.add(HTMLTagToRawInlineStyleMap.get(nodeName));
- }
-
- newStyle = styleFromNodeAttributes(node, newStyle);
- blockConfigs.push.apply(blockConfigs, this._toBlockConfigs(Array.from(node.childNodes), newStyle));
- }
-
- return blockConfigs;
- }
- /**
- * Append a string of text to the internal buffer.
- */
- ;
-
- _proto._appendText = function _appendText(text, style) {
- var _this$characterList;
-
- this.currentText += text;
- var characterMetadata = CharacterMetadata.create({
- style: style,
- entity: this.currentEntity
- });
- this.characterList = (_this$characterList = this.characterList).push.apply(_this$characterList, Array(text.length).fill(characterMetadata));
- }
- /**
- * Trim the text in the internal buffer.
- */
- ;
-
- _proto._trimCurrentText = function _trimCurrentText() {
- var l = this.currentText.length;
- var begin = l - this.currentText.trimLeft().length;
- var end = this.currentText.trimRight().length; // We should not trim whitespaces for which an entity is defined.
-
- var entity = this.characterList.findEntry(function (characterMetadata) {
- return characterMetadata.getEntity() !== null;
- });
- begin = entity !== undefined ? Math.min(begin, entity[0]) : begin;
- entity = this.characterList.reverse().findEntry(function (characterMetadata) {
- return characterMetadata.getEntity() !== null;
- });
- end = entity !== undefined ? Math.max(end, l - entity[0]) : end;
-
- if (begin > end) {
- this.currentText = '';
- this.characterList = List();
- } else {
- this.currentText = this.currentText.slice(begin, end);
- this.characterList = this.characterList.slice(begin, end);
- }
- }
- /**
- * Add the content of an HTML text node to the internal state
- */
- ;
-
- _proto._addTextNode = function _addTextNode(node, style) {
- var text = node.textContent;
- var trimmedText = text.trim(); // If we are not in a pre block and the trimmed content is empty,
- // normalize to a single space.
-
- if (trimmedText === '' && this.wrapper !== 'pre') {
- text = ' ';
- }
-
- if (this.wrapper !== 'pre') {
- // Trim leading line feed, which is invisible in HTML
- text = text.replace(REGEX_LEADING_LF, ''); // Can't use empty string because MSWord
-
- text = text.replace(REGEX_LF, SPACE);
- }
-
- this._appendText(text, style);
- };
-
- _proto._addBreakNode = function _addBreakNode(node, style) {
- if (!isHTMLBRElement(node)) {
- return;
- }
-
- this._appendText('\n', style);
- }
- /**
- * Add the content of an HTML img node to the internal state
- */
- ;
-
- _proto._addImgNode = function _addImgNode(node, style) {
- if (!isHTMLImageElement(node)) {
- return;
- }
-
- var image = node;
- var entityConfig = {};
- imgAttr.forEach(function (attr) {
- var imageAttribute = image.getAttribute(attr);
-
- if (imageAttribute) {
- entityConfig[attr] = imageAttribute;
- }
- }); // TODO: T15530363 update this when we remove DraftEntity entirely
-
- this.currentEntity = this.entityMap.__create('IMAGE', 'IMMUTABLE', entityConfig); // The child text node cannot just have a space or return as content (since
- // we strip those out), unless the image is for presentation only.
- // See https://github.com/facebook/draft-js/issues/231 for some context.
-
- if (gkx('draftjs_fix_paste_for_img')) {
- if (image.getAttribute('role') !== 'presentation') {
- this._appendText("\uD83D\uDCF7", style);
- }
- } else {
- this._appendText("\uD83D\uDCF7", style);
- }
-
- this.currentEntity = null;
- }
- /**
- * Add the content of an HTML 'a' node to the internal state. Child nodes
- * (if any) are converted to Block Configs and appended to the provided
- * blockConfig array.
- */
- ;
-
- _proto._addAnchorNode = function _addAnchorNode(node, blockConfigs, style) {
- // The check has already been made by isValidAnchor but
- // we have to do it again to keep flow happy.
- if (!isHTMLAnchorElement(node)) {
- return;
- }
-
- var anchor = node;
- var entityConfig = {};
- anchorAttr.forEach(function (attr) {
- var anchorAttribute = anchor.getAttribute(attr);
-
- if (anchorAttribute) {
- entityConfig[attr] = anchorAttribute;
- }
- });
- entityConfig.url = new URI(anchor.href).toString(); // TODO: T15530363 update this when we remove DraftEntity completely
-
- this.currentEntity = this.entityMap.__create('LINK', 'MUTABLE', entityConfig || {});
- blockConfigs.push.apply(blockConfigs, this._toBlockConfigs(Array.from(node.childNodes), style));
- this.currentEntity = null;
- }
- /**
- * Walk the BlockConfig tree, compute parent/children/siblings,
- * and generate the corresponding ContentBlockNode
- */
- ;
-
- _proto._toContentBlocks = function _toContentBlocks(blockConfigs) {
- var parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
- var l = blockConfigs.length - 1;
-
- for (var i = 0; i <= l; i++) {
- var config = blockConfigs[i];
- config.parent = parent;
- config.prevSibling = i > 0 ? blockConfigs[i - 1].key : null;
- config.nextSibling = i < l ? blockConfigs[i + 1].key : null;
- config.children = List(config.childConfigs.map(function (child) {
- return child.key;
- }));
- this.contentBlocks.push(new ContentBlockNode(_objectSpread({}, config)));
-
- this._toContentBlocks(config.childConfigs, config.key);
- }
- }
- /**
- * Remove 'useless' container nodes from the block config hierarchy, by
- * replacing them with their children.
- */
- ;
-
- _proto._hoistContainersInBlockConfigs = function _hoistContainersInBlockConfigs(blockConfigs) {
- var _this = this;
-
- var hoisted = List(blockConfigs).flatMap(function (blockConfig) {
- // Don't mess with useful blocks
- if (blockConfig.type !== 'unstyled' || blockConfig.text !== '') {
- return [blockConfig];
- }
-
- return _this._hoistContainersInBlockConfigs(blockConfig.childConfigs);
- });
- return hoisted;
- } // ***********************************************************************
- // The two methods below are used for backward compatibility when
- // experimentalTreeDataSupport is disabled.
-
- /**
- * Same as _toContentBlocks but replaces nested blocks by their
- * text content.
- */
- ;
-
- _proto._toFlatContentBlocks = function _toFlatContentBlocks(blockConfigs) {
- var _this2 = this;
-
- var cleanConfigs = this._hoistContainersInBlockConfigs(blockConfigs);
-
- cleanConfigs.forEach(function (config) {
- var _this2$_extractTextFr = _this2._extractTextFromBlockConfigs(config.childConfigs),
- text = _this2$_extractTextFr.text,
- characterList = _this2$_extractTextFr.characterList;
-
- _this2.contentBlocks.push(new ContentBlock(_objectSpread({}, config, {
- text: config.text + text,
- characterList: config.characterList.concat(characterList)
- })));
- });
- }
- /**
- * Extract the text and the associated inline styles form an
- * array of content block configs.
- */
- ;
-
- _proto._extractTextFromBlockConfigs = function _extractTextFromBlockConfigs(blockConfigs) {
- var l = blockConfigs.length - 1;
- var text = '';
- var characterList = List();
-
- for (var i = 0; i <= l; i++) {
- var config = blockConfigs[i];
- text += config.text;
- characterList = characterList.concat(config.characterList);
-
- if (text !== '' && config.type !== 'unstyled') {
- text += '\n';
- characterList = characterList.push(characterList.last());
- }
-
- var children = this._extractTextFromBlockConfigs(config.childConfigs);
-
- text += children.text;
- characterList = characterList.concat(children.characterList);
- }
-
- return {
- text: text,
- characterList: characterList
- };
- };
-
- return ContentBlocksBuilder;
- }();
- /**
- * Converts an HTML string to an array of ContentBlocks and an EntityMap
- * suitable to initialize the internal state of a Draftjs component.
- */
-
-
- var convertFromHTMLToContentBlocks = function convertFromHTMLToContentBlocks(html) {
- var DOMBuilder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getSafeBodyFromHTML;
- var blockRenderMap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DefaultDraftBlockRenderMap;
- // Be ABSOLUTELY SURE that the dom builder you pass here won't execute
- // arbitrary code in whatever environment you're running this in. For an
- // example of how we try to do this in-browser, see getSafeBodyFromHTML.
- // Remove funky characters from the HTML string
- html = html.trim().replace(REGEX_CR, '').replace(REGEX_NBSP, SPACE).replace(REGEX_CARRIAGE, '').replace(REGEX_ZWS, ''); // Build a DOM tree out of the HTML string
-
- var safeBody = DOMBuilder(html);
-
- if (!safeBody) {
- return null;
- } // Build a BlockTypeMap out of the BlockRenderMap
-
-
- var blockTypeMap = buildBlockTypeMap(blockRenderMap); // Select the proper block type for the cases where the blockRenderMap
- // uses multiple block types for the same html tag.
-
- var disambiguate = function disambiguate(tag, wrapper) {
- if (tag === 'li') {
- return wrapper === 'ol' ? 'ordered-list-item' : 'unordered-list-item';
- }
-
- return null;
- };
-
- return new ContentBlocksBuilder(blockTypeMap, disambiguate).addDOMNode(safeBody).getContentBlocks();
- };
-
- module.exports = convertFromHTMLToContentBlocks;
-
- /***/ }),
- /* 74 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var UserAgent = __webpack_require__(5);
-
- var invariant = __webpack_require__(1);
-
- var isOldIE = UserAgent.isBrowser('IE <= 9'); // Provides a dom node that will not execute scripts
- // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation.createHTMLDocument
- // https://developer.mozilla.org/en-US/Add-ons/Code_snippets/HTML_to_DOM
-
- function getSafeBodyFromHTML(html) {
- var doc;
- var root = null; // Provides a safe context
-
- if (!isOldIE && document.implementation && document.implementation.createHTMLDocument) {
- doc = document.implementation.createHTMLDocument('foo');
- !doc.documentElement ? true ? invariant(false, 'Missing doc.documentElement') : invariant(false) : void 0;
- doc.documentElement.innerHTML = html;
- root = doc.getElementsByTagName('body')[0];
- }
-
- return root;
- }
-
- module.exports = getSafeBodyFromHTML;
-
- /***/ }),
- /* 75 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftModifier = __webpack_require__(3);
-
- var EditorState = __webpack_require__(2);
-
- var adjustBlockDepthForContentState = __webpack_require__(158);
-
- var nullthrows = __webpack_require__(4);
-
- var RichTextEditorUtil = {
- currentBlockContainsLink: function currentBlockContainsLink(editorState) {
- var selection = editorState.getSelection();
- var contentState = editorState.getCurrentContent();
- var entityMap = contentState.getEntityMap();
- return contentState.getBlockForKey(selection.getAnchorKey()).getCharacterList().slice(selection.getStartOffset(), selection.getEndOffset()).some(function (v) {
- var entity = v.getEntity();
- return !!entity && entityMap.__get(entity).getType() === 'LINK';
- });
- },
- getCurrentBlockType: function getCurrentBlockType(editorState) {
- var selection = editorState.getSelection();
- return editorState.getCurrentContent().getBlockForKey(selection.getStartKey()).getType();
- },
- getDataObjectForLinkURL: function getDataObjectForLinkURL(uri) {
- return {
- url: uri.toString()
- };
- },
- handleKeyCommand: function handleKeyCommand(editorState, command, eventTimeStamp) {
- switch (command) {
- case 'bold':
- return RichTextEditorUtil.toggleInlineStyle(editorState, 'BOLD');
-
- case 'italic':
- return RichTextEditorUtil.toggleInlineStyle(editorState, 'ITALIC');
-
- case 'underline':
- return RichTextEditorUtil.toggleInlineStyle(editorState, 'UNDERLINE');
-
- case 'code':
- return RichTextEditorUtil.toggleCode(editorState);
-
- case 'backspace':
- case 'backspace-word':
- case 'backspace-to-start-of-line':
- return RichTextEditorUtil.onBackspace(editorState);
-
- case 'delete':
- case 'delete-word':
- case 'delete-to-end-of-block':
- return RichTextEditorUtil.onDelete(editorState);
-
- default:
- // they may have custom editor commands; ignore those
- return null;
- }
- },
- insertSoftNewline: function insertSoftNewline(editorState) {
- var contentState = DraftModifier.insertText(editorState.getCurrentContent(), editorState.getSelection(), '\n', editorState.getCurrentInlineStyle(), null);
- var newEditorState = EditorState.push(editorState, contentState, 'insert-characters');
- return EditorState.forceSelection(newEditorState, contentState.getSelectionAfter());
- },
-
- /**
- * For collapsed selections at the start of styled blocks, backspace should
- * just remove the existing style.
- */
- onBackspace: function onBackspace(editorState) {
- var selection = editorState.getSelection();
-
- if (!selection.isCollapsed() || selection.getAnchorOffset() || selection.getFocusOffset()) {
- return null;
- } // First, try to remove a preceding atomic block.
-
-
- var content = editorState.getCurrentContent();
- var startKey = selection.getStartKey();
- var blockBefore = content.getBlockBefore(startKey);
-
- if (blockBefore && blockBefore.getType() === 'atomic') {
- var blockMap = content.getBlockMap()["delete"](blockBefore.getKey());
- var withoutAtomicBlock = content.merge({
- blockMap: blockMap,
- selectionAfter: selection
- });
-
- if (withoutAtomicBlock !== content) {
- return EditorState.push(editorState, withoutAtomicBlock, 'remove-range');
- }
- } // If that doesn't succeed, try to remove the current block style.
-
-
- var withoutBlockStyle = RichTextEditorUtil.tryToRemoveBlockStyle(editorState);
-
- if (withoutBlockStyle) {
- return EditorState.push(editorState, withoutBlockStyle, 'change-block-type');
- }
-
- return null;
- },
- onDelete: function onDelete(editorState) {
- var selection = editorState.getSelection();
-
- if (!selection.isCollapsed()) {
- return null;
- }
-
- var content = editorState.getCurrentContent();
- var startKey = selection.getStartKey();
- var block = content.getBlockForKey(startKey);
- var length = block.getLength(); // The cursor is somewhere within the text. Behave normally.
-
- if (selection.getStartOffset() < length) {
- return null;
- }
-
- var blockAfter = content.getBlockAfter(startKey);
-
- if (!blockAfter || blockAfter.getType() !== 'atomic') {
- return null;
- }
-
- var atomicBlockTarget = selection.merge({
- focusKey: blockAfter.getKey(),
- focusOffset: blockAfter.getLength()
- });
- var withoutAtomicBlock = DraftModifier.removeRange(content, atomicBlockTarget, 'forward');
-
- if (withoutAtomicBlock !== content) {
- return EditorState.push(editorState, withoutAtomicBlock, 'remove-range');
- }
-
- return null;
- },
- onTab: function onTab(event, editorState, maxDepth) {
- var selection = editorState.getSelection();
- var key = selection.getAnchorKey();
-
- if (key !== selection.getFocusKey()) {
- return editorState;
- }
-
- var content = editorState.getCurrentContent();
- var block = content.getBlockForKey(key);
- var type = block.getType();
-
- if (type !== 'unordered-list-item' && type !== 'ordered-list-item') {
- return editorState;
- }
-
- event.preventDefault();
- var depth = block.getDepth();
-
- if (!event.shiftKey && depth === maxDepth) {
- return editorState;
- }
-
- var withAdjustment = adjustBlockDepthForContentState(content, selection, event.shiftKey ? -1 : 1, maxDepth);
- return EditorState.push(editorState, withAdjustment, 'adjust-depth');
- },
- toggleBlockType: function toggleBlockType(editorState, blockType) {
- var selection = editorState.getSelection();
- var startKey = selection.getStartKey();
- var endKey = selection.getEndKey();
- var content = editorState.getCurrentContent();
- var target = selection; // Triple-click can lead to a selection that includes offset 0 of the
- // following block. The `SelectionState` for this case is accurate, but
- // we should avoid toggling block type for the trailing block because it
- // is a confusing interaction.
-
- if (startKey !== endKey && selection.getEndOffset() === 0) {
- var blockBefore = nullthrows(content.getBlockBefore(endKey));
- endKey = blockBefore.getKey();
- target = target.merge({
- anchorKey: startKey,
- anchorOffset: selection.getStartOffset(),
- focusKey: endKey,
- focusOffset: blockBefore.getLength(),
- isBackward: false
- });
- }
-
- var hasAtomicBlock = content.getBlockMap().skipWhile(function (_, k) {
- return k !== startKey;
- }).reverse().skipWhile(function (_, k) {
- return k !== endKey;
- }).some(function (v) {
- return v.getType() === 'atomic';
- });
-
- if (hasAtomicBlock) {
- return editorState;
- }
-
- var typeToSet = content.getBlockForKey(startKey).getType() === blockType ? 'unstyled' : blockType;
- return EditorState.push(editorState, DraftModifier.setBlockType(content, target, typeToSet), 'change-block-type');
- },
- toggleCode: function toggleCode(editorState) {
- var selection = editorState.getSelection();
- var anchorKey = selection.getAnchorKey();
- var focusKey = selection.getFocusKey();
-
- if (selection.isCollapsed() || anchorKey !== focusKey) {
- return RichTextEditorUtil.toggleBlockType(editorState, 'code-block');
- }
-
- return RichTextEditorUtil.toggleInlineStyle(editorState, 'CODE');
- },
-
- /**
- * Toggle the specified inline style for the selection. If the
- * user's selection is collapsed, apply or remove the style for the
- * internal state. If it is not collapsed, apply the change directly
- * to the document state.
- */
- toggleInlineStyle: function toggleInlineStyle(editorState, inlineStyle) {
- var selection = editorState.getSelection();
- var currentStyle = editorState.getCurrentInlineStyle(); // If the selection is collapsed, toggle the specified style on or off and
- // set the result as the new inline style override. This will then be
- // used as the inline style for the next character to be inserted.
-
- if (selection.isCollapsed()) {
- return EditorState.setInlineStyleOverride(editorState, currentStyle.has(inlineStyle) ? currentStyle.remove(inlineStyle) : currentStyle.add(inlineStyle));
- } // If characters are selected, immediately apply or remove the
- // inline style on the document state itself.
-
-
- var content = editorState.getCurrentContent();
- var newContent; // If the style is already present for the selection range, remove it.
- // Otherwise, apply it.
-
- if (currentStyle.has(inlineStyle)) {
- newContent = DraftModifier.removeInlineStyle(content, selection, inlineStyle);
- } else {
- newContent = DraftModifier.applyInlineStyle(content, selection, inlineStyle);
- }
-
- return EditorState.push(editorState, newContent, 'change-inline-style');
- },
- toggleLink: function toggleLink(editorState, targetSelection, entityKey) {
- var withoutLink = DraftModifier.applyEntity(editorState.getCurrentContent(), targetSelection, entityKey);
- return EditorState.push(editorState, withoutLink, 'apply-entity');
- },
-
- /**
- * When a collapsed cursor is at the start of a styled block, changes block
- * type to 'unstyled'. Returns null if selection does not meet that criteria.
- */
- tryToRemoveBlockStyle: function tryToRemoveBlockStyle(editorState) {
- var selection = editorState.getSelection();
- var offset = selection.getAnchorOffset();
-
- if (selection.isCollapsed() && offset === 0) {
- var key = selection.getAnchorKey();
- var content = editorState.getCurrentContent();
- var block = content.getBlockForKey(key);
- var type = block.getType();
- var blockBefore = content.getBlockBefore(key);
-
- if (type === 'code-block' && blockBefore && blockBefore.getType() === 'code-block' && blockBefore.getLength() !== 0) {
- return null;
- }
-
- if (type !== 'unstyled') {
- return DraftModifier.setBlockType(content, selection, 'unstyled');
- }
- }
-
- return null;
- }
- };
- module.exports = RichTextEditorUtil;
-
- /***/ }),
- /* 76 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var KeyBindingUtil = __webpack_require__(40);
-
- var Keys = __webpack_require__(28);
-
- var UserAgent = __webpack_require__(5);
-
- var isOSX = UserAgent.isPlatform('Mac OS X'); // Firefox on OSX had a bug resulting in navigation instead of cursor movement.
- // This bug was fixed in Firefox 29. Feature detection is virtually impossible
- // so we just check the version number. See #342765.
-
- var shouldFixFirefoxMovement = isOSX && UserAgent.isBrowser('Firefox < 29');
- var hasCommandModifier = KeyBindingUtil.hasCommandModifier,
- isCtrlKeyCommand = KeyBindingUtil.isCtrlKeyCommand;
-
- function shouldRemoveWord(e) {
- return isOSX && e.altKey || isCtrlKeyCommand(e);
- }
- /**
- * Get the appropriate undo/redo command for a Z key command.
- */
-
-
- function getZCommand(e) {
- if (!hasCommandModifier(e)) {
- return null;
- }
-
- return e.shiftKey ? 'redo' : 'undo';
- }
-
- function getDeleteCommand(e) {
- // Allow default "cut" behavior for PCs on Shift + Delete.
- if (!isOSX && e.shiftKey) {
- return null;
- }
-
- return shouldRemoveWord(e) ? 'delete-word' : 'delete';
- }
-
- function getBackspaceCommand(e) {
- if (hasCommandModifier(e) && isOSX) {
- return 'backspace-to-start-of-line';
- }
-
- return shouldRemoveWord(e) ? 'backspace-word' : 'backspace';
- }
- /**
- * Retrieve a bound key command for the given event.
- */
-
-
- function getDefaultKeyBinding(e) {
- switch (e.keyCode) {
- case 66:
- // B
- return hasCommandModifier(e) ? 'bold' : null;
-
- case 68:
- // D
- return isCtrlKeyCommand(e) ? 'delete' : null;
-
- case 72:
- // H
- return isCtrlKeyCommand(e) ? 'backspace' : null;
-
- case 73:
- // I
- return hasCommandModifier(e) ? 'italic' : null;
-
- case 74:
- // J
- return hasCommandModifier(e) ? 'code' : null;
-
- case 75:
- // K
- return isOSX && isCtrlKeyCommand(e) ? 'secondary-cut' : null;
-
- case 77:
- // M
- return isCtrlKeyCommand(e) ? 'split-block' : null;
-
- case 79:
- // O
- return isCtrlKeyCommand(e) ? 'split-block' : null;
-
- case 84:
- // T
- return isOSX && isCtrlKeyCommand(e) ? 'transpose-characters' : null;
-
- case 85:
- // U
- return hasCommandModifier(e) ? 'underline' : null;
-
- case 87:
- // W
- return isOSX && isCtrlKeyCommand(e) ? 'backspace-word' : null;
-
- case 89:
- // Y
- if (isCtrlKeyCommand(e)) {
- return isOSX ? 'secondary-paste' : 'redo';
- }
-
- return null;
-
- case 90:
- // Z
- return getZCommand(e) || null;
-
- case Keys.RETURN:
- return 'split-block';
-
- case Keys.DELETE:
- return getDeleteCommand(e);
-
- case Keys.BACKSPACE:
- return getBackspaceCommand(e);
- // LEFT/RIGHT handlers serve as a workaround for a Firefox bug.
-
- case Keys.LEFT:
- return shouldFixFirefoxMovement && hasCommandModifier(e) ? 'move-selection-to-start-of-block' : null;
-
- case Keys.RIGHT:
- return shouldFixFirefoxMovement && hasCommandModifier(e) ? 'move-selection-to-end-of-block' : null;
-
- default:
- return null;
- }
- }
-
- module.exports = getDefaultKeyBinding;
-
- /***/ }),
- /* 77 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftStringKey = {
- stringify: function stringify(key) {
- return '_' + String(key);
- },
- unstringify: function unstringify(key) {
- return key.slice(1);
- }
- };
- module.exports = DraftStringKey;
-
- /***/ }),
- /* 78 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- */
-
-
- var AtomicBlockUtils = __webpack_require__(79);
-
- var BlockMapBuilder = __webpack_require__(17);
-
- var CharacterMetadata = __webpack_require__(6);
-
- var CompositeDraftDecorator = __webpack_require__(94);
-
- var ContentBlock = __webpack_require__(12);
-
- var ContentState = __webpack_require__(32);
-
- var DefaultDraftBlockRenderMap = __webpack_require__(34);
-
- var DefaultDraftInlineStyle = __webpack_require__(48);
-
- var DraftEditor = __webpack_require__(95);
-
- var DraftEditorBlock = __webpack_require__(64);
-
- var DraftEntity = __webpack_require__(22);
-
- var DraftModifier = __webpack_require__(3);
-
- var DraftEntityInstance = __webpack_require__(46);
-
- var EditorState = __webpack_require__(2);
-
- var KeyBindingUtil = __webpack_require__(40);
-
- var RawDraftContentState = __webpack_require__(163);
-
- var RichTextEditorUtil = __webpack_require__(75);
-
- var SelectionState = __webpack_require__(23);
-
- var convertFromDraftStateToRaw = __webpack_require__(164);
-
- var convertFromRawToDraftState = __webpack_require__(167);
-
- var generateRandomKey = __webpack_require__(9);
-
- var getDefaultKeyBinding = __webpack_require__(76);
-
- var getVisibleSelectionRect = __webpack_require__(173);
-
- var convertFromHTML = __webpack_require__(73);
-
- var DraftPublic = {
- Editor: DraftEditor,
- EditorBlock: DraftEditorBlock,
- EditorState: EditorState,
- CompositeDecorator: CompositeDraftDecorator,
- Entity: DraftEntity,
- EntityInstance: DraftEntityInstance,
- BlockMapBuilder: BlockMapBuilder,
- CharacterMetadata: CharacterMetadata,
- ContentBlock: ContentBlock,
- ContentState: ContentState,
- RawDraftContentState: RawDraftContentState,
- SelectionState: SelectionState,
- AtomicBlockUtils: AtomicBlockUtils,
- KeyBindingUtil: KeyBindingUtil,
- Modifier: DraftModifier,
- RichUtils: RichTextEditorUtil,
- DefaultDraftBlockRenderMap: DefaultDraftBlockRenderMap,
- DefaultDraftInlineStyle: DefaultDraftInlineStyle,
- convertFromHTML: convertFromHTML,
- convertFromRaw: convertFromRawToDraftState,
- convertToRaw: convertFromDraftStateToRaw,
- genKey: generateRandomKey,
- getDefaultKeyBinding: getDefaultKeyBinding,
- getVisibleSelectionRect: getVisibleSelectionRect
- };
- module.exports = DraftPublic;
-
- /***/ }),
- /* 79 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- var BlockMapBuilder = __webpack_require__(17);
-
- var CharacterMetadata = __webpack_require__(6);
-
- var ContentBlock = __webpack_require__(12);
-
- var ContentBlockNode = __webpack_require__(7);
-
- var DraftModifier = __webpack_require__(3);
-
- var EditorState = __webpack_require__(2);
-
- var generateRandomKey = __webpack_require__(9);
-
- var gkx = __webpack_require__(11);
-
- var Immutable = __webpack_require__(0);
-
- var moveBlockInContentState = __webpack_require__(93);
-
- var experimentalTreeDataSupport = gkx('draft_tree_data_support');
- var ContentBlockRecord = experimentalTreeDataSupport ? ContentBlockNode : ContentBlock;
- var List = Immutable.List,
- Repeat = Immutable.Repeat;
- var AtomicBlockUtils = {
- insertAtomicBlock: function insertAtomicBlock(editorState, entityKey, character) {
- var contentState = editorState.getCurrentContent();
- var selectionState = editorState.getSelection();
- var afterRemoval = DraftModifier.removeRange(contentState, selectionState, 'backward');
- var targetSelection = afterRemoval.getSelectionAfter();
- var afterSplit = DraftModifier.splitBlock(afterRemoval, targetSelection);
- var insertionTarget = afterSplit.getSelectionAfter();
- var asAtomicBlock = DraftModifier.setBlockType(afterSplit, insertionTarget, 'atomic');
- var charData = CharacterMetadata.create({
- entity: entityKey
- });
- var atomicBlockConfig = {
- key: generateRandomKey(),
- type: 'atomic',
- text: character,
- characterList: List(Repeat(charData, character.length))
- };
- var atomicDividerBlockConfig = {
- key: generateRandomKey(),
- type: 'unstyled'
- };
-
- if (experimentalTreeDataSupport) {
- atomicBlockConfig = _objectSpread({}, atomicBlockConfig, {
- nextSibling: atomicDividerBlockConfig.key
- });
- atomicDividerBlockConfig = _objectSpread({}, atomicDividerBlockConfig, {
- prevSibling: atomicBlockConfig.key
- });
- }
-
- var fragmentArray = [new ContentBlockRecord(atomicBlockConfig), new ContentBlockRecord(atomicDividerBlockConfig)];
- var fragment = BlockMapBuilder.createFromArray(fragmentArray);
- var withAtomicBlock = DraftModifier.replaceWithFragment(asAtomicBlock, insertionTarget, fragment);
- var newContent = withAtomicBlock.merge({
- selectionBefore: selectionState,
- selectionAfter: withAtomicBlock.getSelectionAfter().set('hasFocus', true)
- });
- return EditorState.push(editorState, newContent, 'insert-fragment');
- },
- moveAtomicBlock: function moveAtomicBlock(editorState, atomicBlock, targetRange, insertionMode) {
- var contentState = editorState.getCurrentContent();
- var selectionState = editorState.getSelection();
- var withMovedAtomicBlock;
-
- if (insertionMode === 'before' || insertionMode === 'after') {
- var targetBlock = contentState.getBlockForKey(insertionMode === 'before' ? targetRange.getStartKey() : targetRange.getEndKey());
- withMovedAtomicBlock = moveBlockInContentState(contentState, atomicBlock, targetBlock, insertionMode);
- } else {
- var afterRemoval = DraftModifier.removeRange(contentState, targetRange, 'backward');
- var selectionAfterRemoval = afterRemoval.getSelectionAfter();
-
- var _targetBlock = afterRemoval.getBlockForKey(selectionAfterRemoval.getFocusKey());
-
- if (selectionAfterRemoval.getStartOffset() === 0) {
- withMovedAtomicBlock = moveBlockInContentState(afterRemoval, atomicBlock, _targetBlock, 'before');
- } else if (selectionAfterRemoval.getEndOffset() === _targetBlock.getLength()) {
- withMovedAtomicBlock = moveBlockInContentState(afterRemoval, atomicBlock, _targetBlock, 'after');
- } else {
- var afterSplit = DraftModifier.splitBlock(afterRemoval, selectionAfterRemoval);
- var selectionAfterSplit = afterSplit.getSelectionAfter();
-
- var _targetBlock2 = afterSplit.getBlockForKey(selectionAfterSplit.getFocusKey());
-
- withMovedAtomicBlock = moveBlockInContentState(afterSplit, atomicBlock, _targetBlock2, 'before');
- }
- }
-
- var newContent = withMovedAtomicBlock.merge({
- selectionBefore: selectionState,
- selectionAfter: withMovedAtomicBlock.getSelectionAfter().set('hasFocus', true)
- });
- return EditorState.push(editorState, newContent, 'move-block');
- }
- };
- module.exports = AtomicBlockUtils;
-
- /***/ }),
- /* 80 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var CharacterMetadata = __webpack_require__(6);
-
- var _require = __webpack_require__(0),
- Map = _require.Map;
-
- var ContentStateInlineStyle = {
- add: function add(contentState, selectionState, inlineStyle) {
- return modifyInlineStyle(contentState, selectionState, inlineStyle, true);
- },
- remove: function remove(contentState, selectionState, inlineStyle) {
- return modifyInlineStyle(contentState, selectionState, inlineStyle, false);
- }
- };
-
- function modifyInlineStyle(contentState, selectionState, inlineStyle, addOrRemove) {
- var blockMap = contentState.getBlockMap();
- var startKey = selectionState.getStartKey();
- var startOffset = selectionState.getStartOffset();
- var endKey = selectionState.getEndKey();
- var endOffset = selectionState.getEndOffset();
- var newBlocks = blockMap.skipUntil(function (_, k) {
- return k === startKey;
- }).takeUntil(function (_, k) {
- return k === endKey;
- }).concat(Map([[endKey, blockMap.get(endKey)]])).map(function (block, blockKey) {
- var sliceStart;
- var sliceEnd;
-
- if (startKey === endKey) {
- sliceStart = startOffset;
- sliceEnd = endOffset;
- } else {
- sliceStart = blockKey === startKey ? startOffset : 0;
- sliceEnd = blockKey === endKey ? endOffset : block.getLength();
- }
-
- var chars = block.getCharacterList();
- var current;
-
- while (sliceStart < sliceEnd) {
- current = chars.get(sliceStart);
- chars = chars.set(sliceStart, addOrRemove ? CharacterMetadata.applyStyle(current, inlineStyle) : CharacterMetadata.removeStyle(current, inlineStyle));
- sliceStart++;
- }
-
- return block.set('characterList', chars);
- });
- return contentState.merge({
- blockMap: blockMap.merge(newBlocks),
- selectionBefore: selectionState,
- selectionAfter: selectionState
- });
- }
-
- module.exports = ContentStateInlineStyle;
-
- /***/ }),
- /* 81 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var applyEntityToContentBlock = __webpack_require__(82);
-
- var Immutable = __webpack_require__(0);
-
- function applyEntityToContentState(contentState, selectionState, entityKey) {
- var blockMap = contentState.getBlockMap();
- var startKey = selectionState.getStartKey();
- var startOffset = selectionState.getStartOffset();
- var endKey = selectionState.getEndKey();
- var endOffset = selectionState.getEndOffset();
- var newBlocks = blockMap.skipUntil(function (_, k) {
- return k === startKey;
- }).takeUntil(function (_, k) {
- return k === endKey;
- }).toOrderedMap().merge(Immutable.OrderedMap([[endKey, blockMap.get(endKey)]])).map(function (block, blockKey) {
- var sliceStart = blockKey === startKey ? startOffset : 0;
- var sliceEnd = blockKey === endKey ? endOffset : block.getLength();
- return applyEntityToContentBlock(block, sliceStart, sliceEnd, entityKey);
- });
- return contentState.merge({
- blockMap: blockMap.merge(newBlocks),
- selectionBefore: selectionState,
- selectionAfter: selectionState
- });
- }
-
- module.exports = applyEntityToContentState;
-
- /***/ }),
- /* 82 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var CharacterMetadata = __webpack_require__(6);
-
- function applyEntityToContentBlock(contentBlock, startArg, end, entityKey) {
- var start = startArg;
- var characterList = contentBlock.getCharacterList();
-
- while (start < end) {
- characterList = characterList.set(start, CharacterMetadata.applyEntity(characterList.get(start), entityKey));
- start++;
- }
-
- return contentBlock.set('characterList', characterList);
- }
-
- module.exports = applyEntityToContentBlock;
-
- /***/ }),
- /* 83 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftEntitySegments = __webpack_require__(84);
-
- var getRangesForDraftEntity = __webpack_require__(85);
-
- var invariant = __webpack_require__(1);
- /**
- * Given a SelectionState and a removal direction, determine the entire range
- * that should be removed from a ContentState. This is based on any entities
- * within the target, with their `mutability` values taken into account.
- *
- * For instance, if we are attempting to remove part of an "immutable" entity
- * range, the entire entity must be removed. The returned `SelectionState`
- * will be adjusted accordingly.
- */
-
-
- function getCharacterRemovalRange(entityMap, startBlock, endBlock, selectionState, direction) {
- var start = selectionState.getStartOffset();
- var end = selectionState.getEndOffset();
- var startEntityKey = startBlock.getEntityAt(start);
- var endEntityKey = endBlock.getEntityAt(end - 1);
-
- if (!startEntityKey && !endEntityKey) {
- return selectionState;
- }
-
- var newSelectionState = selectionState;
-
- if (startEntityKey && startEntityKey === endEntityKey) {
- newSelectionState = getEntityRemovalRange(entityMap, startBlock, newSelectionState, direction, startEntityKey, true, true);
- } else if (startEntityKey && endEntityKey) {
- var startSelectionState = getEntityRemovalRange(entityMap, startBlock, newSelectionState, direction, startEntityKey, false, true);
- var endSelectionState = getEntityRemovalRange(entityMap, endBlock, newSelectionState, direction, endEntityKey, false, false);
- newSelectionState = newSelectionState.merge({
- anchorOffset: startSelectionState.getAnchorOffset(),
- focusOffset: endSelectionState.getFocusOffset(),
- isBackward: false
- });
- } else if (startEntityKey) {
- var _startSelectionState = getEntityRemovalRange(entityMap, startBlock, newSelectionState, direction, startEntityKey, false, true);
-
- newSelectionState = newSelectionState.merge({
- anchorOffset: _startSelectionState.getStartOffset(),
- isBackward: false
- });
- } else if (endEntityKey) {
- var _endSelectionState = getEntityRemovalRange(entityMap, endBlock, newSelectionState, direction, endEntityKey, false, false);
-
- newSelectionState = newSelectionState.merge({
- focusOffset: _endSelectionState.getEndOffset(),
- isBackward: false
- });
- }
-
- return newSelectionState;
- }
-
- function getEntityRemovalRange(entityMap, block, selectionState, direction, entityKey, isEntireSelectionWithinEntity, isEntityAtStart) {
- var start = selectionState.getStartOffset();
- var end = selectionState.getEndOffset();
-
- var entity = entityMap.__get(entityKey);
-
- var mutability = entity.getMutability();
- var sideToConsider = isEntityAtStart ? start : end; // `MUTABLE` entities can just have the specified range of text removed
- // directly. No adjustments are needed.
-
- if (mutability === 'MUTABLE') {
- return selectionState;
- } // Find the entity range that overlaps with our removal range.
-
-
- var entityRanges = getRangesForDraftEntity(block, entityKey).filter(function (range) {
- return sideToConsider <= range.end && sideToConsider >= range.start;
- });
- !(entityRanges.length == 1) ? true ? invariant(false, 'There should only be one entity range within this removal range.') : invariant(false) : void 0;
- var entityRange = entityRanges[0]; // For `IMMUTABLE` entity types, we will remove the entire entity range.
-
- if (mutability === 'IMMUTABLE') {
- return selectionState.merge({
- anchorOffset: entityRange.start,
- focusOffset: entityRange.end,
- isBackward: false
- });
- } // For `SEGMENTED` entity types, determine the appropriate segment to
- // remove.
-
-
- if (!isEntireSelectionWithinEntity) {
- if (isEntityAtStart) {
- end = entityRange.end;
- } else {
- start = entityRange.start;
- }
- }
-
- var removalRange = DraftEntitySegments.getRemovalRange(start, end, block.getText().slice(entityRange.start, entityRange.end), entityRange.start, direction);
- return selectionState.merge({
- anchorOffset: removalRange.start,
- focusOffset: removalRange.end,
- isBackward: false
- });
- }
-
- module.exports = getCharacterRemovalRange;
-
- /***/ }),
- /* 84 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- /**
- * Identify the range to delete from a segmented entity.
- *
- * Rules:
- *
- * Example: 'John F. Kennedy'
- *
- * - Deletion from within any non-whitespace (i.e. ['John', 'F.', 'Kennedy'])
- * will return the range of that text.
- *
- * 'John F. Kennedy' -> 'John F.'
- * ^
- *
- * - Forward deletion of whitespace will remove the following section:
- *
- * 'John F. Kennedy' -> 'John Kennedy'
- * ^
- *
- * - Backward deletion of whitespace will remove the previous section:
- *
- * 'John F. Kennedy' -> 'F. Kennedy'
- * ^
- */
- var DraftEntitySegments = {
- getRemovalRange: function getRemovalRange(selectionStart, selectionEnd, text, entityStart, direction) {
- var segments = text.split(' ');
- segments = segments.map(function (
- /*string*/
- segment,
- /*number*/
- ii) {
- if (direction === 'forward') {
- if (ii > 0) {
- return ' ' + segment;
- }
- } else if (ii < segments.length - 1) {
- return segment + ' ';
- }
-
- return segment;
- });
- var segmentStart = entityStart;
- var segmentEnd;
- var segment;
- var removalStart = null;
- var removalEnd = null;
-
- for (var jj = 0; jj < segments.length; jj++) {
- segment = segments[jj];
- segmentEnd = segmentStart + segment.length; // Our selection overlaps this segment.
-
- if (selectionStart < segmentEnd && segmentStart < selectionEnd) {
- if (removalStart !== null) {
- removalEnd = segmentEnd;
- } else {
- removalStart = segmentStart;
- removalEnd = segmentEnd;
- }
- } else if (removalStart !== null) {
- break;
- }
-
- segmentStart = segmentEnd;
- }
-
- var entityEnd = entityStart + text.length;
- var atStart = removalStart === entityStart;
- var atEnd = removalEnd === entityEnd;
-
- if (!atStart && atEnd || atStart && !atEnd) {
- if (direction === 'forward') {
- if (removalEnd !== entityEnd) {
- removalEnd++;
- }
- } else if (removalStart !== entityStart) {
- removalStart--;
- }
- }
-
- return {
- start: removalStart,
- end: removalEnd
- };
- }
- };
- module.exports = DraftEntitySegments;
-
- /***/ }),
- /* 85 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var invariant = __webpack_require__(1);
- /**
- * Obtain the start and end positions of the range that has the
- * specified entity applied to it.
- *
- * Entity keys are applied only to contiguous stretches of text, so this
- * method searches for the first instance of the entity key and returns
- * the subsequent range.
- */
-
-
- function getRangesForDraftEntity(block, key) {
- var ranges = [];
- block.findEntityRanges(function (c) {
- return c.getEntity() === key;
- }, function (start, end) {
- ranges.push({
- start: start,
- end: end
- });
- });
- !!!ranges.length ? true ? invariant(false, 'Entity key not found in this range.') : invariant(false) : void 0;
- return ranges;
- }
-
- module.exports = getRangesForDraftEntity;
-
- /***/ }),
- /* 86 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var BlockMapBuilder = __webpack_require__(17);
-
- var ContentBlockNode = __webpack_require__(7);
-
- var Immutable = __webpack_require__(0);
-
- var insertIntoList = __webpack_require__(43);
-
- var invariant = __webpack_require__(1);
-
- var randomizeBlockMapKeys = __webpack_require__(41);
-
- var List = Immutable.List;
-
- var updateExistingBlock = function updateExistingBlock(contentState, selectionState, blockMap, fragmentBlock, targetKey, targetOffset) {
- var mergeBlockData = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 'REPLACE_WITH_NEW_DATA';
- var targetBlock = blockMap.get(targetKey);
- var text = targetBlock.getText();
- var chars = targetBlock.getCharacterList();
- var finalKey = targetKey;
- var finalOffset = targetOffset + fragmentBlock.getText().length;
- var data = null;
-
- switch (mergeBlockData) {
- case 'MERGE_OLD_DATA_TO_NEW_DATA':
- data = fragmentBlock.getData().merge(targetBlock.getData());
- break;
-
- case 'REPLACE_WITH_NEW_DATA':
- data = fragmentBlock.getData();
- break;
- }
-
- var newBlock = targetBlock.merge({
- text: text.slice(0, targetOffset) + fragmentBlock.getText() + text.slice(targetOffset),
- characterList: insertIntoList(chars, fragmentBlock.getCharacterList(), targetOffset),
- data: data
- });
- return contentState.merge({
- blockMap: blockMap.set(targetKey, newBlock),
- selectionBefore: selectionState,
- selectionAfter: selectionState.merge({
- anchorKey: finalKey,
- anchorOffset: finalOffset,
- focusKey: finalKey,
- focusOffset: finalOffset,
- isBackward: false
- })
- });
- };
- /**
- * Appends text/characterList from the fragment first block to
- * target block.
- */
-
-
- var updateHead = function updateHead(block, targetOffset, fragment) {
- var text = block.getText();
- var chars = block.getCharacterList(); // Modify head portion of block.
-
- var headText = text.slice(0, targetOffset);
- var headCharacters = chars.slice(0, targetOffset);
- var appendToHead = fragment.first();
- return block.merge({
- text: headText + appendToHead.getText(),
- characterList: headCharacters.concat(appendToHead.getCharacterList()),
- type: headText ? block.getType() : appendToHead.getType(),
- data: appendToHead.getData()
- });
- };
- /**
- * Appends offset text/characterList from the target block to the last
- * fragment block.
- */
-
-
- var updateTail = function updateTail(block, targetOffset, fragment) {
- // Modify tail portion of block.
- var text = block.getText();
- var chars = block.getCharacterList(); // Modify head portion of block.
-
- var blockSize = text.length;
- var tailText = text.slice(targetOffset, blockSize);
- var tailCharacters = chars.slice(targetOffset, blockSize);
- var prependToTail = fragment.last();
- return prependToTail.merge({
- text: prependToTail.getText() + tailText,
- characterList: prependToTail.getCharacterList().concat(tailCharacters),
- data: prependToTail.getData()
- });
- };
-
- var getRootBlocks = function getRootBlocks(block, blockMap) {
- var headKey = block.getKey();
- var rootBlock = block;
- var rootBlocks = []; // sometimes the fragment head block will not be part of the blockMap itself this can happen when
- // the fragment head is used to update the target block, however when this does not happen we need
- // to make sure that we include it on the rootBlocks since the first block of a fragment is always a
- // fragment root block
-
- if (blockMap.get(headKey)) {
- rootBlocks.push(headKey);
- }
-
- while (rootBlock && rootBlock.getNextSiblingKey()) {
- var lastSiblingKey = rootBlock.getNextSiblingKey();
-
- if (!lastSiblingKey) {
- break;
- }
-
- rootBlocks.push(lastSiblingKey);
- rootBlock = blockMap.get(lastSiblingKey);
- }
-
- return rootBlocks;
- };
-
- var updateBlockMapLinks = function updateBlockMapLinks(blockMap, originalBlockMap, targetBlock, fragmentHeadBlock) {
- return blockMap.withMutations(function (blockMapState) {
- var targetKey = targetBlock.getKey();
- var headKey = fragmentHeadBlock.getKey();
- var targetNextKey = targetBlock.getNextSiblingKey();
- var targetParentKey = targetBlock.getParentKey();
- var fragmentRootBlocks = getRootBlocks(fragmentHeadBlock, blockMap);
- var lastRootFragmentBlockKey = fragmentRootBlocks[fragmentRootBlocks.length - 1];
-
- if (blockMapState.get(headKey)) {
- // update the fragment head when it is part of the blockMap otherwise
- blockMapState.setIn([targetKey, 'nextSibling'], headKey);
- blockMapState.setIn([headKey, 'prevSibling'], targetKey);
- } else {
- // update the target block that had the fragment head contents merged into it
- blockMapState.setIn([targetKey, 'nextSibling'], fragmentHeadBlock.getNextSiblingKey());
- blockMapState.setIn([fragmentHeadBlock.getNextSiblingKey(), 'prevSibling'], targetKey);
- } // update the last root block fragment
-
-
- blockMapState.setIn([lastRootFragmentBlockKey, 'nextSibling'], targetNextKey); // update the original target next block
-
- if (targetNextKey) {
- blockMapState.setIn([targetNextKey, 'prevSibling'], lastRootFragmentBlockKey);
- } // update fragment parent links
-
-
- fragmentRootBlocks.forEach(function (blockKey) {
- return blockMapState.setIn([blockKey, 'parent'], targetParentKey);
- }); // update targetBlock parent child links
-
- if (targetParentKey) {
- var targetParent = blockMap.get(targetParentKey);
- var originalTargetParentChildKeys = targetParent.getChildKeys();
- var targetBlockIndex = originalTargetParentChildKeys.indexOf(targetKey);
- var insertionIndex = targetBlockIndex + 1;
- var newChildrenKeysArray = originalTargetParentChildKeys.toArray(); // insert fragment children
-
- newChildrenKeysArray.splice.apply(newChildrenKeysArray, [insertionIndex, 0].concat(fragmentRootBlocks));
- blockMapState.setIn([targetParentKey, 'children'], List(newChildrenKeysArray));
- }
- });
- };
-
- var insertFragment = function insertFragment(contentState, selectionState, blockMap, fragment, targetKey, targetOffset) {
- var isTreeBasedBlockMap = blockMap.first() instanceof ContentBlockNode;
- var newBlockArr = [];
- var fragmentSize = fragment.size;
- var target = blockMap.get(targetKey);
- var head = fragment.first();
- var tail = fragment.last();
- var finalOffset = tail.getLength();
- var finalKey = tail.getKey();
- var shouldNotUpdateFromFragmentBlock = isTreeBasedBlockMap && (!target.getChildKeys().isEmpty() || !head.getChildKeys().isEmpty());
- blockMap.forEach(function (block, blockKey) {
- if (blockKey !== targetKey) {
- newBlockArr.push(block);
- return;
- }
-
- if (shouldNotUpdateFromFragmentBlock) {
- newBlockArr.push(block);
- } else {
- newBlockArr.push(updateHead(block, targetOffset, fragment));
- } // Insert fragment blocks after the head and before the tail.
-
-
- fragment // when we are updating the target block with the head fragment block we skip the first fragment
- // head since its contents have already been merged with the target block otherwise we include
- // the whole fragment
- .slice(shouldNotUpdateFromFragmentBlock ? 0 : 1, fragmentSize - 1).forEach(function (fragmentBlock) {
- return newBlockArr.push(fragmentBlock);
- }); // update tail
-
- newBlockArr.push(updateTail(block, targetOffset, fragment));
- });
- var updatedBlockMap = BlockMapBuilder.createFromArray(newBlockArr);
-
- if (isTreeBasedBlockMap) {
- updatedBlockMap = updateBlockMapLinks(updatedBlockMap, blockMap, target, head);
- }
-
- return contentState.merge({
- blockMap: updatedBlockMap,
- selectionBefore: selectionState,
- selectionAfter: selectionState.merge({
- anchorKey: finalKey,
- anchorOffset: finalOffset,
- focusKey: finalKey,
- focusOffset: finalOffset,
- isBackward: false
- })
- });
- };
-
- var insertFragmentIntoContentState = function insertFragmentIntoContentState(contentState, selectionState, fragmentBlockMap) {
- var mergeBlockData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'REPLACE_WITH_NEW_DATA';
- !selectionState.isCollapsed() ? true ? invariant(false, '`insertFragment` should only be called with a collapsed selection state.') : invariant(false) : void 0;
- var blockMap = contentState.getBlockMap();
- var fragment = randomizeBlockMapKeys(fragmentBlockMap);
- var targetKey = selectionState.getStartKey();
- var targetOffset = selectionState.getStartOffset();
- var targetBlock = blockMap.get(targetKey);
-
- if (targetBlock instanceof ContentBlockNode) {
- !targetBlock.getChildKeys().isEmpty() ? true ? invariant(false, '`insertFragment` should not be called when a container node is selected.') : invariant(false) : void 0;
- } // When we insert a fragment with a single block we simply update the target block
- // with the contents of the inserted fragment block
-
-
- if (fragment.size === 1) {
- return updateExistingBlock(contentState, selectionState, blockMap, fragment.first(), targetKey, targetOffset, mergeBlockData);
- }
-
- return insertFragment(contentState, selectionState, blockMap, fragment, targetKey, targetOffset);
- };
-
- module.exports = insertFragmentIntoContentState;
-
- /***/ }),
- /* 87 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var Immutable = __webpack_require__(0);
-
- var insertIntoList = __webpack_require__(43);
-
- var invariant = __webpack_require__(1);
-
- var Repeat = Immutable.Repeat;
-
- function insertTextIntoContentState(contentState, selectionState, text, characterMetadata) {
- !selectionState.isCollapsed() ? true ? invariant(false, '`insertText` should only be called with a collapsed range.') : invariant(false) : void 0;
- var len = null;
-
- if (text != null) {
- len = text.length;
- }
-
- if (len == null || len === 0) {
- return contentState;
- }
-
- var blockMap = contentState.getBlockMap();
- var key = selectionState.getStartKey();
- var offset = selectionState.getStartOffset();
- var block = blockMap.get(key);
- var blockText = block.getText();
- var newBlock = block.merge({
- text: blockText.slice(0, offset) + text + blockText.slice(offset, block.getLength()),
- characterList: insertIntoList(block.getCharacterList(), Repeat(characterMetadata, len).toList(), offset)
- });
- var newOffset = offset + len;
- return contentState.merge({
- blockMap: blockMap.set(key, newBlock),
- selectionAfter: selectionState.merge({
- anchorOffset: newOffset,
- focusOffset: newOffset
- })
- });
- }
-
- module.exports = insertTextIntoContentState;
-
- /***/ }),
- /* 88 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var ContentBlockNode = __webpack_require__(7);
-
- var getNextDelimiterBlockKey = __webpack_require__(45);
-
- var Immutable = __webpack_require__(0);
-
- var List = Immutable.List,
- Map = Immutable.Map;
-
- var transformBlock = function transformBlock(key, blockMap, func) {
- if (!key) {
- return;
- }
-
- var block = blockMap.get(key);
-
- if (!block) {
- return;
- }
-
- blockMap.set(key, func(block));
- };
- /**
- * Ancestors needs to be preserved when there are non selected
- * children to make sure we do not leave any orphans behind
- */
-
-
- var getAncestorsKeys = function getAncestorsKeys(blockKey, blockMap) {
- var parents = [];
-
- if (!blockKey) {
- return parents;
- }
-
- var blockNode = blockMap.get(blockKey);
-
- while (blockNode && blockNode.getParentKey()) {
- var parentKey = blockNode.getParentKey();
-
- if (parentKey) {
- parents.push(parentKey);
- }
-
- blockNode = parentKey ? blockMap.get(parentKey) : null;
- }
-
- return parents;
- };
- /**
- * Get all next delimiter keys until we hit a root delimiter and return
- * an array of key references
- */
-
-
- var getNextDelimitersBlockKeys = function getNextDelimitersBlockKeys(block, blockMap) {
- var nextDelimiters = [];
-
- if (!block) {
- return nextDelimiters;
- }
-
- var nextDelimiter = getNextDelimiterBlockKey(block, blockMap);
-
- while (nextDelimiter && blockMap.get(nextDelimiter)) {
- var _block = blockMap.get(nextDelimiter);
-
- nextDelimiters.push(nextDelimiter); // we do not need to keep checking all root node siblings, just the first occurance
-
- nextDelimiter = _block.getParentKey() ? getNextDelimiterBlockKey(_block, blockMap) : null;
- }
-
- return nextDelimiters;
- };
-
- var getNextValidSibling = function getNextValidSibling(block, blockMap, originalBlockMap) {
- if (!block) {
- return null;
- } // note that we need to make sure we refer to the original block since this
- // function is called within a withMutations
-
-
- var nextValidSiblingKey = originalBlockMap.get(block.getKey()).getNextSiblingKey();
-
- while (nextValidSiblingKey && !blockMap.get(nextValidSiblingKey)) {
- nextValidSiblingKey = originalBlockMap.get(nextValidSiblingKey).getNextSiblingKey() || null;
- }
-
- return nextValidSiblingKey;
- };
-
- var getPrevValidSibling = function getPrevValidSibling(block, blockMap, originalBlockMap) {
- if (!block) {
- return null;
- } // note that we need to make sure we refer to the original block since this
- // function is called within a withMutations
-
-
- var prevValidSiblingKey = originalBlockMap.get(block.getKey()).getPrevSiblingKey();
-
- while (prevValidSiblingKey && !blockMap.get(prevValidSiblingKey)) {
- prevValidSiblingKey = originalBlockMap.get(prevValidSiblingKey).getPrevSiblingKey() || null;
- }
-
- return prevValidSiblingKey;
- };
-
- var updateBlockMapLinks = function updateBlockMapLinks(blockMap, startBlock, endBlock, originalBlockMap) {
- return blockMap.withMutations(function (blocks) {
- // update start block if its retained
- transformBlock(startBlock.getKey(), blocks, function (block) {
- return block.merge({
- nextSibling: getNextValidSibling(block, blocks, originalBlockMap),
- prevSibling: getPrevValidSibling(block, blocks, originalBlockMap)
- });
- }); // update endblock if its retained
-
- transformBlock(endBlock.getKey(), blocks, function (block) {
- return block.merge({
- nextSibling: getNextValidSibling(block, blocks, originalBlockMap),
- prevSibling: getPrevValidSibling(block, blocks, originalBlockMap)
- });
- }); // update start block parent ancestors
-
- getAncestorsKeys(startBlock.getKey(), originalBlockMap).forEach(function (parentKey) {
- return transformBlock(parentKey, blocks, function (block) {
- return block.merge({
- children: block.getChildKeys().filter(function (key) {
- return blocks.get(key);
- }),
- nextSibling: getNextValidSibling(block, blocks, originalBlockMap),
- prevSibling: getPrevValidSibling(block, blocks, originalBlockMap)
- });
- });
- }); // update start block next - can only happen if startBlock == endBlock
-
- transformBlock(startBlock.getNextSiblingKey(), blocks, function (block) {
- return block.merge({
- prevSibling: startBlock.getPrevSiblingKey()
- });
- }); // update start block prev
-
- transformBlock(startBlock.getPrevSiblingKey(), blocks, function (block) {
- return block.merge({
- nextSibling: getNextValidSibling(block, blocks, originalBlockMap)
- });
- }); // update end block next
-
- transformBlock(endBlock.getNextSiblingKey(), blocks, function (block) {
- return block.merge({
- prevSibling: getPrevValidSibling(block, blocks, originalBlockMap)
- });
- }); // update end block prev
-
- transformBlock(endBlock.getPrevSiblingKey(), blocks, function (block) {
- return block.merge({
- nextSibling: endBlock.getNextSiblingKey()
- });
- }); // update end block parent ancestors
-
- getAncestorsKeys(endBlock.getKey(), originalBlockMap).forEach(function (parentKey) {
- transformBlock(parentKey, blocks, function (block) {
- return block.merge({
- children: block.getChildKeys().filter(function (key) {
- return blocks.get(key);
- }),
- nextSibling: getNextValidSibling(block, blocks, originalBlockMap),
- prevSibling: getPrevValidSibling(block, blocks, originalBlockMap)
- });
- });
- }); // update next delimiters all the way to a root delimiter
-
- getNextDelimitersBlockKeys(endBlock, originalBlockMap).forEach(function (delimiterKey) {
- return transformBlock(delimiterKey, blocks, function (block) {
- return block.merge({
- nextSibling: getNextValidSibling(block, blocks, originalBlockMap),
- prevSibling: getPrevValidSibling(block, blocks, originalBlockMap)
- });
- });
- }); // if parent (startBlock) was deleted
-
- if (blockMap.get(startBlock.getKey()) == null && blockMap.get(endBlock.getKey()) != null && endBlock.getParentKey() === startBlock.getKey() && endBlock.getPrevSiblingKey() == null) {
- var prevSiblingKey = startBlock.getPrevSiblingKey(); // endBlock becomes next sibling of parent's prevSibling
-
- transformBlock(endBlock.getKey(), blocks, function (block) {
- return block.merge({
- prevSibling: prevSiblingKey
- });
- });
- transformBlock(prevSiblingKey, blocks, function (block) {
- return block.merge({
- nextSibling: endBlock.getKey()
- });
- }); // Update parent for previous parent's children, and children for that parent
-
- var prevSibling = prevSiblingKey ? blockMap.get(prevSiblingKey) : null;
- var newParentKey = prevSibling ? prevSibling.getParentKey() : null;
- startBlock.getChildKeys().forEach(function (childKey) {
- transformBlock(childKey, blocks, function (block) {
- return block.merge({
- parent: newParentKey // set to null if there is no parent
-
- });
- });
- });
-
- if (newParentKey != null) {
- var newParent = blockMap.get(newParentKey);
- transformBlock(newParentKey, blocks, function (block) {
- return block.merge({
- children: newParent.getChildKeys().concat(startBlock.getChildKeys())
- });
- });
- } // last child of deleted parent should point to next sibling
-
-
- transformBlock(startBlock.getChildKeys().find(function (key) {
- var block = blockMap.get(key);
- return block.getNextSiblingKey() === null;
- }), blocks, function (block) {
- return block.merge({
- nextSibling: startBlock.getNextSiblingKey()
- });
- });
- }
- });
- };
-
- var removeRangeFromContentState = function removeRangeFromContentState(contentState, selectionState) {
- if (selectionState.isCollapsed()) {
- return contentState;
- }
-
- var blockMap = contentState.getBlockMap();
- var startKey = selectionState.getStartKey();
- var startOffset = selectionState.getStartOffset();
- var endKey = selectionState.getEndKey();
- var endOffset = selectionState.getEndOffset();
- var startBlock = blockMap.get(startKey);
- var endBlock = blockMap.get(endKey); // we assume that ContentBlockNode and ContentBlocks are not mixed together
-
- var isExperimentalTreeBlock = startBlock instanceof ContentBlockNode; // used to retain blocks that should not be deleted to avoid orphan children
-
- var parentAncestors = [];
-
- if (isExperimentalTreeBlock) {
- var endBlockchildrenKeys = endBlock.getChildKeys();
- var endBlockAncestors = getAncestorsKeys(endKey, blockMap); // endBlock has unselected siblings so we can not remove its ancestors parents
-
- if (endBlock.getNextSiblingKey()) {
- parentAncestors = parentAncestors.concat(endBlockAncestors);
- } // endBlock has children so can not remove this block or any of its ancestors
-
-
- if (!endBlockchildrenKeys.isEmpty()) {
- parentAncestors = parentAncestors.concat(endBlockAncestors.concat([endKey]));
- } // we need to retain all ancestors of the next delimiter block
-
-
- parentAncestors = parentAncestors.concat(getAncestorsKeys(getNextDelimiterBlockKey(endBlock, blockMap), blockMap));
- }
-
- var characterList;
-
- if (startBlock === endBlock) {
- characterList = removeFromList(startBlock.getCharacterList(), startOffset, endOffset);
- } else {
- characterList = startBlock.getCharacterList().slice(0, startOffset).concat(endBlock.getCharacterList().slice(endOffset));
- }
-
- var modifiedStart = startBlock.merge({
- text: startBlock.getText().slice(0, startOffset) + endBlock.getText().slice(endOffset),
- characterList: characterList
- }); // If cursor (collapsed) is at the start of the first child, delete parent
- // instead of child
-
- var shouldDeleteParent = isExperimentalTreeBlock && startOffset === 0 && endOffset === 0 && endBlock.getParentKey() === startKey && endBlock.getPrevSiblingKey() == null;
- var newBlocks = shouldDeleteParent ? Map([[startKey, null]]) : blockMap.toSeq().skipUntil(function (_, k) {
- return k === startKey;
- }).takeUntil(function (_, k) {
- return k === endKey;
- }).filter(function (_, k) {
- return parentAncestors.indexOf(k) === -1;
- }).concat(Map([[endKey, null]])).map(function (_, k) {
- return k === startKey ? modifiedStart : null;
- });
- var updatedBlockMap = blockMap.merge(newBlocks).filter(function (block) {
- return !!block;
- }); // Only update tree block pointers if the range is across blocks
-
- if (isExperimentalTreeBlock && startBlock !== endBlock) {
- updatedBlockMap = updateBlockMapLinks(updatedBlockMap, startBlock, endBlock, blockMap);
- }
-
- return contentState.merge({
- blockMap: updatedBlockMap,
- selectionBefore: selectionState,
- selectionAfter: selectionState.merge({
- anchorKey: startKey,
- anchorOffset: startOffset,
- focusKey: startKey,
- focusOffset: startOffset,
- isBackward: false
- })
- });
- };
- /**
- * Maintain persistence for target list when removing characters on the
- * head and tail of the character list.
- */
-
-
- var removeFromList = function removeFromList(targetList, startOffset, endOffset) {
- if (startOffset === 0) {
- while (startOffset < endOffset) {
- targetList = targetList.shift();
- startOffset++;
- }
- } else if (endOffset === targetList.count()) {
- while (endOffset > startOffset) {
- targetList = targetList.pop();
- endOffset--;
- }
- } else {
- var head = targetList.slice(0, startOffset);
- var tail = targetList.slice(endOffset);
- targetList = head.concat(tail).toList();
- }
-
- return targetList;
- };
-
- module.exports = removeRangeFromContentState;
-
- /***/ }),
- /* 89 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var ContentBlockNode = __webpack_require__(7);
-
- var generateRandomKey = __webpack_require__(9);
-
- var Immutable = __webpack_require__(0);
-
- var invariant = __webpack_require__(1);
-
- var modifyBlockForContentState = __webpack_require__(44);
-
- var List = Immutable.List,
- Map = Immutable.Map;
-
- var transformBlock = function transformBlock(key, blockMap, func) {
- if (!key) {
- return;
- }
-
- var block = blockMap.get(key);
-
- if (!block) {
- return;
- }
-
- blockMap.set(key, func(block));
- };
-
- var updateBlockMapLinks = function updateBlockMapLinks(blockMap, originalBlock, belowBlock) {
- return blockMap.withMutations(function (blocks) {
- var originalBlockKey = originalBlock.getKey();
- var belowBlockKey = belowBlock.getKey(); // update block parent
-
- transformBlock(originalBlock.getParentKey(), blocks, function (block) {
- var parentChildrenList = block.getChildKeys();
- var insertionIndex = parentChildrenList.indexOf(originalBlockKey) + 1;
- var newChildrenArray = parentChildrenList.toArray();
- newChildrenArray.splice(insertionIndex, 0, belowBlockKey);
- return block.merge({
- children: List(newChildrenArray)
- });
- }); // update original next block
-
- transformBlock(originalBlock.getNextSiblingKey(), blocks, function (block) {
- return block.merge({
- prevSibling: belowBlockKey
- });
- }); // update original block
-
- transformBlock(originalBlockKey, blocks, function (block) {
- return block.merge({
- nextSibling: belowBlockKey
- });
- }); // update below block
-
- transformBlock(belowBlockKey, blocks, function (block) {
- return block.merge({
- prevSibling: originalBlockKey
- });
- });
- });
- };
-
- var splitBlockInContentState = function splitBlockInContentState(contentState, selectionState) {
- !selectionState.isCollapsed() ? true ? invariant(false, 'Selection range must be collapsed.') : invariant(false) : void 0;
- var key = selectionState.getAnchorKey();
- var blockMap = contentState.getBlockMap();
- var blockToSplit = blockMap.get(key);
- var text = blockToSplit.getText();
-
- if (!text) {
- var blockType = blockToSplit.getType();
-
- if (blockType === 'unordered-list-item' || blockType === 'ordered-list-item') {
- return modifyBlockForContentState(contentState, selectionState, function (block) {
- return block.merge({
- type: 'unstyled',
- depth: 0
- });
- });
- }
- }
-
- var offset = selectionState.getAnchorOffset();
- var chars = blockToSplit.getCharacterList();
- var keyBelow = generateRandomKey();
- var isExperimentalTreeBlock = blockToSplit instanceof ContentBlockNode;
- var blockAbove = blockToSplit.merge({
- text: text.slice(0, offset),
- characterList: chars.slice(0, offset)
- });
- var blockBelow = blockAbove.merge({
- key: keyBelow,
- text: text.slice(offset),
- characterList: chars.slice(offset),
- data: Map()
- });
- var blocksBefore = blockMap.toSeq().takeUntil(function (v) {
- return v === blockToSplit;
- });
- var blocksAfter = blockMap.toSeq().skipUntil(function (v) {
- return v === blockToSplit;
- }).rest();
- var newBlocks = blocksBefore.concat([[key, blockAbove], [keyBelow, blockBelow]], blocksAfter).toOrderedMap();
-
- if (isExperimentalTreeBlock) {
- !blockToSplit.getChildKeys().isEmpty() ? true ? invariant(false, 'ContentBlockNode must not have children') : invariant(false) : void 0;
- newBlocks = updateBlockMapLinks(newBlocks, blockAbove, blockBelow);
- }
-
- return contentState.merge({
- blockMap: newBlocks,
- selectionBefore: selectionState,
- selectionAfter: selectionState.merge({
- anchorKey: keyBelow,
- anchorOffset: 0,
- focusKey: keyBelow,
- focusOffset: 0,
- isBackward: false
- })
- });
- };
-
- module.exports = splitBlockInContentState;
-
- /***/ }),
- /* 90 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var findRangesImmutable = __webpack_require__(18);
-
- var Immutable = __webpack_require__(0);
-
- var List = Immutable.List,
- Repeat = Immutable.Repeat,
- Record = Immutable.Record;
-
- var returnTrue = function returnTrue() {
- return true;
- };
-
- var defaultLeafRange = {
- start: null,
- end: null
- };
- var LeafRange = Record(defaultLeafRange);
- var defaultDecoratorRange = {
- start: null,
- end: null,
- decoratorKey: null,
- leaves: null
- };
- var DecoratorRange = Record(defaultDecoratorRange);
- var BlockTree = {
- /**
- * Generate a block tree for a given ContentBlock/decorator pair.
- */
- generate: function generate(contentState, block, decorator) {
- var textLength = block.getLength();
-
- if (!textLength) {
- return List.of(new DecoratorRange({
- start: 0,
- end: 0,
- decoratorKey: null,
- leaves: List.of(new LeafRange({
- start: 0,
- end: 0
- }))
- }));
- }
-
- var leafSets = [];
- var decorations = decorator ? decorator.getDecorations(block, contentState) : List(Repeat(null, textLength));
- var chars = block.getCharacterList();
- findRangesImmutable(decorations, areEqual, returnTrue, function (start, end) {
- leafSets.push(new DecoratorRange({
- start: start,
- end: end,
- decoratorKey: decorations.get(start),
- leaves: generateLeaves(chars.slice(start, end).toList(), start)
- }));
- });
- return List(leafSets);
- }
- };
- /**
- * Generate LeafRange records for a given character list.
- */
-
- function generateLeaves(characters, offset) {
- var leaves = [];
- var inlineStyles = characters.map(function (c) {
- return c.getStyle();
- }).toList();
- findRangesImmutable(inlineStyles, areEqual, returnTrue, function (start, end) {
- leaves.push(new LeafRange({
- start: start + offset,
- end: end + offset
- }));
- });
- return List(leaves);
- }
-
- function areEqual(a, b) {
- return a === b;
- }
-
- module.exports = BlockTree;
-
- /***/ }),
- /* 91 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var UnicodeBidiService = __webpack_require__(92);
-
- var Immutable = __webpack_require__(0);
-
- var nullthrows = __webpack_require__(4);
-
- var OrderedMap = Immutable.OrderedMap;
- var bidiService;
- var EditorBidiService = {
- getDirectionMap: function getDirectionMap(content, prevBidiMap) {
- if (!bidiService) {
- bidiService = new UnicodeBidiService();
- } else {
- bidiService.reset();
- }
-
- var blockMap = content.getBlockMap();
- var nextBidi = blockMap.valueSeq().map(function (block) {
- return nullthrows(bidiService).getDirection(block.getText());
- });
- var bidiMap = OrderedMap(blockMap.keySeq().zip(nextBidi));
-
- if (prevBidiMap != null && Immutable.is(prevBidiMap, bidiMap)) {
- return prevBidiMap;
- }
-
- return bidiMap;
- }
- };
- module.exports = EditorBidiService;
-
- /***/ }),
- /* 92 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- *
- */
-
- /**
- * Stateful API for text direction detection
- *
- * This class can be used in applications where you need to detect the
- * direction of a sequence of text blocks, where each direction shall be used
- * as the fallback direction for the next one.
- *
- * NOTE: A default direction, if not provided, is set based on the global
- * direction, as defined by `UnicodeBidiDirection`.
- *
- * == Example ==
- * ```
- * var UnicodeBidiService = require('UnicodeBidiService');
- *
- * var bidiService = new UnicodeBidiService();
- *
- * ...
- *
- * bidiService.reset();
- * for (var para in paragraphs) {
- * var dir = bidiService.getDirection(para);
- * ...
- * }
- * ```
- *
- * Part of our implementation of Unicode Bidirectional Algorithm (UBA)
- * Unicode Standard Annex #9 (UAX9)
- * http://www.unicode.org/reports/tr9/
- */
-
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- var UnicodeBidi = __webpack_require__(33);
-
- var UnicodeBidiDirection = __webpack_require__(24);
-
- var invariant = __webpack_require__(1);
-
- var UnicodeBidiService =
- /*#__PURE__*/
- function () {
- /**
- * Stateful class for paragraph direction detection
- *
- * @param defaultDir Default direction of the service
- */
- function UnicodeBidiService(defaultDir) {
- _defineProperty(this, "_defaultDir", void 0);
-
- _defineProperty(this, "_lastDir", void 0);
-
- if (!defaultDir) {
- defaultDir = UnicodeBidiDirection.getGlobalDir();
- } else {
- !UnicodeBidiDirection.isStrong(defaultDir) ? true ? invariant(false, 'Default direction must be a strong direction (LTR or RTL)') : invariant(false) : void 0;
- }
-
- this._defaultDir = defaultDir;
- this.reset();
- }
- /**
- * Reset the internal state
- *
- * Instead of creating a new instance, you can just reset() your instance
- * everytime you start a new loop.
- */
-
-
- var _proto = UnicodeBidiService.prototype;
-
- _proto.reset = function reset() {
- this._lastDir = this._defaultDir;
- };
- /**
- * Returns the direction of a block of text, and remembers it as the
- * fall-back direction for the next paragraph.
- *
- * @param str A text block, e.g. paragraph, table cell, tag
- * @return The resolved direction
- */
-
-
- _proto.getDirection = function getDirection(str) {
- this._lastDir = UnicodeBidi.getDirection(str, this._lastDir);
- return this._lastDir;
- };
-
- return UnicodeBidiService;
- }();
-
- module.exports = UnicodeBidiService;
-
- /***/ }),
- /* 93 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var ContentBlockNode = __webpack_require__(7);
-
- var getNextDelimiterBlockKey = __webpack_require__(45);
-
- var Immutable = __webpack_require__(0);
-
- var invariant = __webpack_require__(1);
-
- var OrderedMap = Immutable.OrderedMap,
- List = Immutable.List;
-
- var transformBlock = function transformBlock(key, blockMap, func) {
- if (!key) {
- return;
- }
-
- var block = blockMap.get(key);
-
- if (!block) {
- return;
- }
-
- blockMap.set(key, func(block));
- };
-
- var updateBlockMapLinks = function updateBlockMapLinks(blockMap, originalBlockToBeMoved, originalTargetBlock, insertionMode, isExperimentalTreeBlock) {
- if (!isExperimentalTreeBlock) {
- return blockMap;
- } // possible values of 'insertionMode' are: 'after', 'before'
-
-
- var isInsertedAfterTarget = insertionMode === 'after';
- var originalBlockKey = originalBlockToBeMoved.getKey();
- var originalTargetKey = originalTargetBlock.getKey();
- var originalParentKey = originalBlockToBeMoved.getParentKey();
- var originalNextSiblingKey = originalBlockToBeMoved.getNextSiblingKey();
- var originalPrevSiblingKey = originalBlockToBeMoved.getPrevSiblingKey();
- var newParentKey = originalTargetBlock.getParentKey();
- var newNextSiblingKey = isInsertedAfterTarget ? originalTargetBlock.getNextSiblingKey() : originalTargetKey;
- var newPrevSiblingKey = isInsertedAfterTarget ? originalTargetKey : originalTargetBlock.getPrevSiblingKey();
- return blockMap.withMutations(function (blocks) {
- // update old parent
- transformBlock(originalParentKey, blocks, function (block) {
- var parentChildrenList = block.getChildKeys();
- return block.merge({
- children: parentChildrenList["delete"](parentChildrenList.indexOf(originalBlockKey))
- });
- }); // update old prev
-
- transformBlock(originalPrevSiblingKey, blocks, function (block) {
- return block.merge({
- nextSibling: originalNextSiblingKey
- });
- }); // update old next
-
- transformBlock(originalNextSiblingKey, blocks, function (block) {
- return block.merge({
- prevSibling: originalPrevSiblingKey
- });
- }); // update new next
-
- transformBlock(newNextSiblingKey, blocks, function (block) {
- return block.merge({
- prevSibling: originalBlockKey
- });
- }); // update new prev
-
- transformBlock(newPrevSiblingKey, blocks, function (block) {
- return block.merge({
- nextSibling: originalBlockKey
- });
- }); // update new parent
-
- transformBlock(newParentKey, blocks, function (block) {
- var newParentChildrenList = block.getChildKeys();
- var targetBlockIndex = newParentChildrenList.indexOf(originalTargetKey);
- var insertionIndex = isInsertedAfterTarget ? targetBlockIndex + 1 : targetBlockIndex !== 0 ? targetBlockIndex - 1 : 0;
- var newChildrenArray = newParentChildrenList.toArray();
- newChildrenArray.splice(insertionIndex, 0, originalBlockKey);
- return block.merge({
- children: List(newChildrenArray)
- });
- }); // update block
-
- transformBlock(originalBlockKey, blocks, function (block) {
- return block.merge({
- nextSibling: newNextSiblingKey,
- prevSibling: newPrevSiblingKey,
- parent: newParentKey
- });
- });
- });
- };
-
- var moveBlockInContentState = function moveBlockInContentState(contentState, blockToBeMoved, targetBlock, insertionMode) {
- !(insertionMode !== 'replace') ? true ? invariant(false, 'Replacing blocks is not supported.') : invariant(false) : void 0;
- var targetKey = targetBlock.getKey();
- var blockKey = blockToBeMoved.getKey();
- !(blockKey !== targetKey) ? true ? invariant(false, 'Block cannot be moved next to itself.') : invariant(false) : void 0;
- var blockMap = contentState.getBlockMap();
- var isExperimentalTreeBlock = blockToBeMoved instanceof ContentBlockNode;
- var blocksToBeMoved = [blockToBeMoved];
- var blockMapWithoutBlocksToBeMoved = blockMap["delete"](blockKey);
-
- if (isExperimentalTreeBlock) {
- blocksToBeMoved = [];
- blockMapWithoutBlocksToBeMoved = blockMap.withMutations(function (blocks) {
- var nextSiblingKey = blockToBeMoved.getNextSiblingKey();
- var nextDelimiterBlockKey = getNextDelimiterBlockKey(blockToBeMoved, blocks);
- blocks.toSeq().skipUntil(function (block) {
- return block.getKey() === blockKey;
- }).takeWhile(function (block) {
- var key = block.getKey();
- var isBlockToBeMoved = key === blockKey;
- var hasNextSiblingAndIsNotNextSibling = nextSiblingKey && key !== nextSiblingKey;
- var doesNotHaveNextSiblingAndIsNotDelimiter = !nextSiblingKey && block.getParentKey() && (!nextDelimiterBlockKey || key !== nextDelimiterBlockKey);
- return !!(isBlockToBeMoved || hasNextSiblingAndIsNotNextSibling || doesNotHaveNextSiblingAndIsNotDelimiter);
- }).forEach(function (block) {
- blocksToBeMoved.push(block);
- blocks["delete"](block.getKey());
- });
- });
- }
-
- var blocksBefore = blockMapWithoutBlocksToBeMoved.toSeq().takeUntil(function (v) {
- return v === targetBlock;
- });
- var blocksAfter = blockMapWithoutBlocksToBeMoved.toSeq().skipUntil(function (v) {
- return v === targetBlock;
- }).skip(1);
- var slicedBlocks = blocksToBeMoved.map(function (block) {
- return [block.getKey(), block];
- });
- var newBlocks = OrderedMap();
-
- if (insertionMode === 'before') {
- var blockBefore = contentState.getBlockBefore(targetKey);
- !(!blockBefore || blockBefore.getKey() !== blockToBeMoved.getKey()) ? true ? invariant(false, 'Block cannot be moved next to itself.') : invariant(false) : void 0;
- newBlocks = blocksBefore.concat([].concat(slicedBlocks, [[targetKey, targetBlock]]), blocksAfter).toOrderedMap();
- } else if (insertionMode === 'after') {
- var blockAfter = contentState.getBlockAfter(targetKey);
- !(!blockAfter || blockAfter.getKey() !== blockKey) ? true ? invariant(false, 'Block cannot be moved next to itself.') : invariant(false) : void 0;
- newBlocks = blocksBefore.concat([[targetKey, targetBlock]].concat(slicedBlocks), blocksAfter).toOrderedMap();
- }
-
- return contentState.merge({
- blockMap: updateBlockMapLinks(newBlocks, blockToBeMoved, targetBlock, insertionMode, isExperimentalTreeBlock),
- selectionBefore: contentState.getSelectionAfter(),
- selectionAfter: contentState.getSelectionAfter().merge({
- anchorKey: blockKey,
- focusKey: blockKey
- })
- });
- };
-
- module.exports = moveBlockInContentState;
-
- /***/ }),
- /* 94 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- var Immutable = __webpack_require__(0);
-
- var List = Immutable.List;
- var DELIMITER = '.';
- /**
- * A CompositeDraftDecorator traverses through a list of DraftDecorator
- * instances to identify sections of a ContentBlock that should be rendered
- * in a "decorated" manner. For example, hashtags, mentions, and links may
- * be intended to stand out visually, be rendered as anchors, etc.
- *
- * The list of decorators supplied to the constructor will be used in the
- * order they are provided. This allows the caller to specify a priority for
- * string matching, in case of match collisions among decorators.
- *
- * For instance, I may have a link with a `#` in its text. Though this section
- * of text may match our hashtag decorator, it should not be treated as a
- * hashtag. I should therefore list my link DraftDecorator
- * before my hashtag DraftDecorator when constructing this composite
- * decorator instance.
- *
- * Thus, when a collision like this is encountered, the earlier match is
- * preserved and the new match is discarded.
- */
-
- var CompositeDraftDecorator =
- /*#__PURE__*/
- function () {
- function CompositeDraftDecorator(decorators) {
- _defineProperty(this, "_decorators", void 0);
-
- // Copy the decorator array, since we use this array order to determine
- // precedence of decoration matching. If the array is mutated externally,
- // we don't want to be affected here.
- this._decorators = decorators.slice();
- }
-
- var _proto = CompositeDraftDecorator.prototype;
-
- _proto.getDecorations = function getDecorations(block, contentState) {
- var decorations = Array(block.getText().length).fill(null);
-
- this._decorators.forEach(function (
- /*object*/
- decorator,
- /*number*/
- ii) {
- var counter = 0;
- var strategy = decorator.strategy;
-
- var callback = function callback(
- /*number*/
- start,
- /*number*/
- end) {
- // Find out if any of our matching range is already occupied
- // by another decorator. If so, discard the match. Otherwise, store
- // the component key for rendering.
- if (canOccupySlice(decorations, start, end)) {
- occupySlice(decorations, start, end, ii + DELIMITER + counter);
- counter++;
- }
- };
-
- strategy(block, callback, contentState);
- });
-
- return List(decorations);
- };
-
- _proto.getComponentForKey = function getComponentForKey(key) {
- var componentKey = parseInt(key.split(DELIMITER)[0], 10);
- return this._decorators[componentKey].component;
- };
-
- _proto.getPropsForKey = function getPropsForKey(key) {
- var componentKey = parseInt(key.split(DELIMITER)[0], 10);
- return this._decorators[componentKey].props;
- };
-
- return CompositeDraftDecorator;
- }();
- /**
- * Determine whether we can occupy the specified slice of the decorations
- * array.
- */
-
-
- function canOccupySlice(decorations, start, end) {
- for (var ii = start; ii < end; ii++) {
- if (decorations[ii] != null) {
- return false;
- }
- }
-
- return true;
- }
- /**
- * Splice the specified component into our decoration array at the desired
- * range.
- */
-
-
- function occupySlice(targetArr, start, end, componentKey) {
- for (var ii = start; ii < end; ii++) {
- targetArr[ii] = componentKey;
- }
- }
-
- module.exports = CompositeDraftDecorator;
-
- /***/ }),
- /* 95 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /* WEBPACK VAR INJECTION */(function(global) {/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @preventMunge
- * @emails oncall+draft_js
- */
-
-
- var _assign = __webpack_require__(14);
-
- function _extends() { _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
-
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
-
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- var DefaultDraftBlockRenderMap = __webpack_require__(34);
-
- var DefaultDraftInlineStyle = __webpack_require__(48);
-
- var DraftEditorCompositionHandler = __webpack_require__(96);
-
- var DraftEditorContents = __webpack_require__(104);
-
- var DraftEditorDragHandler = __webpack_require__(121);
-
- var DraftEditorEditHandler = __webpack_require__(124);
-
- var flushControlled = __webpack_require__(160);
-
- var DraftEditorPlaceholder = __webpack_require__(162);
-
- var DraftEffects = __webpack_require__(60);
-
- var EditorState = __webpack_require__(2);
-
- var React = __webpack_require__(8);
-
- var Scroll = __webpack_require__(37);
-
- var Style = __webpack_require__(29);
-
- var UserAgent = __webpack_require__(5);
-
- var cx = __webpack_require__(13);
-
- var generateRandomKey = __webpack_require__(9);
-
- var getDefaultKeyBinding = __webpack_require__(76);
-
- var getScrollPosition = __webpack_require__(30);
-
- var gkx = __webpack_require__(11);
-
- var invariant = __webpack_require__(1);
-
- var isHTMLElement = __webpack_require__(19);
-
- var nullthrows = __webpack_require__(4);
-
- var isIE = UserAgent.isBrowser('IE'); // IE does not support the `input` event on contentEditable, so we can't
- // observe spellcheck behavior.
-
- var allowSpellCheck = !isIE; // Define a set of handler objects to correspond to each possible `mode`
- // of editor behavior.
-
- var handlerMap = {
- edit: DraftEditorEditHandler,
- composite: DraftEditorCompositionHandler,
- drag: DraftEditorDragHandler,
- cut: null,
- render: null
- };
- var didInitODS = false;
-
- var UpdateDraftEditorFlags =
- /*#__PURE__*/
- function (_React$Component) {
- _inheritsLoose(UpdateDraftEditorFlags, _React$Component);
-
- function UpdateDraftEditorFlags() {
- return _React$Component.apply(this, arguments) || this;
- }
-
- var _proto = UpdateDraftEditorFlags.prototype;
-
- _proto.render = function render() {
- return null;
- };
-
- _proto.componentDidMount = function componentDidMount() {
- this._update();
- };
-
- _proto.componentDidUpdate = function componentDidUpdate() {
- this._update();
- };
-
- _proto._update = function _update() {
- var editor = this.props.editor;
- /**
- * Sometimes a render triggers a 'focus' or other event, and that will
- * schedule a second render pass.
- * In order to make sure the second render pass gets the latest editor
- * state, we update it here.
- * Example:
- * render #1
- * +
- * |
- * | cWU -> Nothing ... latestEditorState = STALE_STATE :(
- * |
- * | render -> this.props.editorState = FRESH_STATE
- * | + *and* set latestEditorState = FRESH_STATE
- * |
- * | |
- * | +--> triggers 'focus' event, calling 'handleFocus' with latestEditorState
- * | +
- * | |
- * +>cdU -> latestEditorState = FRESH_STATE | the 'handleFocus' call schedules render #2
- * | with latestEditorState, which is FRESH_STATE
- * |
- * render #2 <--------------------------------------+
- * +
- * |
- * | cwU -> nothing updates
- * |
- * | render -> this.props.editorState = FRESH_STATE which was passed in above
- * |
- * +>cdU fires and resets latestEditorState = FRESH_STATE
- * ---
- * Note that if we don't set latestEditorState in 'render' in the above
- * diagram, then STALE_STATE gets passed to render #2.
- */
-
- editor._latestEditorState = this.props.editorState;
- /**
- * The reason we set this 'blockSelectEvents' flag is that IE will fire a
- * 'selectionChange' event when we programmatically change the selection,
- * meaning it would trigger a new select event while we are in the middle
- * of updating.
- * We found that the 'selection.addRange' was what triggered the stray
- * selectionchange event in IE.
- * To be clear - we have not been able to reproduce specific bugs related
- * to this stray selection event, but have recorded logs that some
- * conditions do cause it to get bumped into during editOnSelect.
- */
-
- editor._blockSelectEvents = true;
- };
-
- return UpdateDraftEditorFlags;
- }(React.Component);
- /**
- * `DraftEditor` is the root editor component. It composes a `contentEditable`
- * div, and provides a wide variety of useful function props for managing the
- * state of the editor. See `DraftEditorProps` for details.
- */
-
-
- var DraftEditor =
- /*#__PURE__*/
- function (_React$Component2) {
- _inheritsLoose(DraftEditor, _React$Component2);
-
- /**
- * Define proxies that can route events to the current handler.
- */
- function DraftEditor(props) {
- var _this;
-
- _this = _React$Component2.call(this, props) || this;
-
- _defineProperty(_assertThisInitialized(_this), "_blockSelectEvents", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_clipboard", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_handler", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_dragCount", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_internalDrag", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_editorKey", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_placeholderAccessibilityID", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_latestEditorState", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_latestCommittedEditorState", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_pendingStateFromBeforeInput", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onBeforeInput", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onBlur", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onCharacterData", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onCompositionEnd", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onCompositionStart", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onCopy", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onCut", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onDragEnd", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onDragOver", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onDragStart", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onDrop", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onInput", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onFocus", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onKeyDown", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onKeyPress", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onKeyUp", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onMouseDown", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onMouseUp", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onPaste", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_onSelect", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "editor", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "editorContainer", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "focus", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "blur", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "setMode", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "exitCurrentMode", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "restoreEditorDOM", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "setClipboard", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "getClipboard", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "getEditorKey", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "update", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "onDragEnter", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "onDragLeave", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_handleEditorContainerRef", function (node) {
- _this.editorContainer = node; // Instead of having a direct ref on the child, we'll grab it here.
- // This is safe as long as the rendered structure is static (which it is).
- // This lets the child support ref={props.editorRef} without merging refs.
-
- _this.editor = node !== null ? node.firstChild : null;
- });
-
- _defineProperty(_assertThisInitialized(_this), "focus", function (scrollPosition) {
- var editorState = _this.props.editorState;
- var alreadyHasFocus = editorState.getSelection().getHasFocus();
- var editorNode = _this.editor;
-
- if (!editorNode) {
- // once in a while people call 'focus' in a setTimeout, and the node has
- // been deleted, so it can be null in that case.
- return;
- }
-
- var scrollParent = Style.getScrollParent(editorNode);
-
- var _ref = scrollPosition || getScrollPosition(scrollParent),
- x = _ref.x,
- y = _ref.y;
-
- !isHTMLElement(editorNode) ? true ? invariant(false, 'editorNode is not an HTMLElement') : invariant(false) : void 0;
- editorNode.focus(); // Restore scroll position
-
- if (scrollParent === window) {
- window.scrollTo(x, y);
- } else {
- Scroll.setTop(scrollParent, y);
- } // On Chrome and Safari, calling focus on contenteditable focuses the
- // cursor at the first character. This is something you don't expect when
- // you're clicking on an input element but not directly on a character.
- // Put the cursor back where it was before the blur.
-
-
- if (!alreadyHasFocus) {
- _this.update(EditorState.forceSelection(editorState, editorState.getSelection()));
- }
- });
-
- _defineProperty(_assertThisInitialized(_this), "blur", function () {
- var editorNode = _this.editor;
-
- if (!editorNode) {
- return;
- }
-
- !isHTMLElement(editorNode) ? true ? invariant(false, 'editorNode is not an HTMLElement') : invariant(false) : void 0;
- editorNode.blur();
- });
-
- _defineProperty(_assertThisInitialized(_this), "setMode", function (mode) {
- var _this$props = _this.props,
- onPaste = _this$props.onPaste,
- onCut = _this$props.onCut,
- onCopy = _this$props.onCopy;
-
- var editHandler = _objectSpread({}, handlerMap.edit);
-
- if (onPaste) {
- /* $FlowFixMe(>=0.117.0 site=www) This comment suppresses an error found
- * when Flow v0.117 was deployed. To see the error delete this comment
- * and run Flow. */
- editHandler.onPaste = onPaste;
- }
-
- if (onCut) {
- editHandler.onCut = onCut;
- }
-
- if (onCopy) {
- editHandler.onCopy = onCopy;
- }
-
- var handler = _objectSpread({}, handlerMap, {
- edit: editHandler
- });
-
- _this._handler = handler[mode];
- });
-
- _defineProperty(_assertThisInitialized(_this), "exitCurrentMode", function () {
- _this.setMode('edit');
- });
-
- _defineProperty(_assertThisInitialized(_this), "restoreEditorDOM", function (scrollPosition) {
- _this.setState({
- contentsKey: _this.state.contentsKey + 1
- }, function () {
- _this.focus(scrollPosition);
- });
- });
-
- _defineProperty(_assertThisInitialized(_this), "setClipboard", function (clipboard) {
- _this._clipboard = clipboard;
- });
-
- _defineProperty(_assertThisInitialized(_this), "getClipboard", function () {
- return _this._clipboard;
- });
-
- _defineProperty(_assertThisInitialized(_this), "update", function (editorState) {
- _this._latestEditorState = editorState;
-
- _this.props.onChange(editorState);
- });
-
- _defineProperty(_assertThisInitialized(_this), "onDragEnter", function () {
- _this._dragCount++;
- });
-
- _defineProperty(_assertThisInitialized(_this), "onDragLeave", function () {
- _this._dragCount--;
-
- if (_this._dragCount === 0) {
- _this.exitCurrentMode();
- }
- });
-
- _this._blockSelectEvents = false;
- _this._clipboard = null;
- _this._handler = null;
- _this._dragCount = 0;
- _this._editorKey = props.editorKey || generateRandomKey();
- _this._placeholderAccessibilityID = 'placeholder-' + _this._editorKey;
- _this._latestEditorState = props.editorState;
- _this._latestCommittedEditorState = props.editorState;
- _this._onBeforeInput = _this._buildHandler('onBeforeInput');
- _this._onBlur = _this._buildHandler('onBlur');
- _this._onCharacterData = _this._buildHandler('onCharacterData');
- _this._onCompositionEnd = _this._buildHandler('onCompositionEnd');
- _this._onCompositionStart = _this._buildHandler('onCompositionStart');
- _this._onCopy = _this._buildHandler('onCopy');
- _this._onCut = _this._buildHandler('onCut');
- _this._onDragEnd = _this._buildHandler('onDragEnd');
- _this._onDragOver = _this._buildHandler('onDragOver');
- _this._onDragStart = _this._buildHandler('onDragStart');
- _this._onDrop = _this._buildHandler('onDrop');
- _this._onInput = _this._buildHandler('onInput');
- _this._onFocus = _this._buildHandler('onFocus');
- _this._onKeyDown = _this._buildHandler('onKeyDown');
- _this._onKeyPress = _this._buildHandler('onKeyPress');
- _this._onKeyUp = _this._buildHandler('onKeyUp');
- _this._onMouseDown = _this._buildHandler('onMouseDown');
- _this._onMouseUp = _this._buildHandler('onMouseUp');
- _this._onPaste = _this._buildHandler('onPaste');
- _this._onSelect = _this._buildHandler('onSelect');
-
- _this.getEditorKey = function () {
- return _this._editorKey;
- };
-
- if (true) {
- ['onDownArrow', 'onEscape', 'onLeftArrow', 'onRightArrow', 'onTab', 'onUpArrow'].forEach(function (propName) {
- if (props.hasOwnProperty(propName)) {
- // eslint-disable-next-line no-console
- console.warn("Supplying an `".concat(propName, "` prop to `DraftEditor` has ") + 'been deprecated. If your handler needs access to the keyboard ' + 'event, supply a custom `keyBindingFn` prop that falls back to ' + 'the default one (eg. https://is.gd/wHKQ3W).');
- }
- });
- } // See `restoreEditorDOM()`.
-
-
- _this.state = {
- contentsKey: 0
- };
- return _this;
- }
- /**
- * Build a method that will pass the event to the specified handler method.
- * This allows us to look up the correct handler function for the current
- * editor mode, if any has been specified.
- */
-
-
- var _proto2 = DraftEditor.prototype;
-
- _proto2._buildHandler = function _buildHandler(eventName) {
- var _this2 = this;
-
- // Wrap event handlers in `flushControlled`. In sync mode, this is
- // effectively a no-op. In async mode, this ensures all updates scheduled
- // inside the handler are flushed before React yields to the browser.
- return function (e) {
- if (!_this2.props.readOnly) {
- var method = _this2._handler && _this2._handler[eventName];
-
- if (method) {
- if (flushControlled) {
- flushControlled(function () {
- return method(_this2, e);
- });
- } else {
- method(_this2, e);
- }
- }
- }
- };
- };
-
- _proto2._showPlaceholder = function _showPlaceholder() {
- return !!this.props.placeholder && !this.props.editorState.isInCompositionMode() && !this.props.editorState.getCurrentContent().hasText();
- };
-
- _proto2._renderPlaceholder = function _renderPlaceholder() {
- if (this._showPlaceholder()) {
- var placeHolderProps = {
- text: nullthrows(this.props.placeholder),
- editorState: this.props.editorState,
- textAlignment: this.props.textAlignment,
- accessibilityID: this._placeholderAccessibilityID
- };
- /* $FlowFixMe(>=0.112.0 site=www,mobile) This comment suppresses an error
- * found when Flow v0.112 was deployed. To see the error delete this
- * comment and run Flow. */
-
- return React.createElement(DraftEditorPlaceholder, placeHolderProps);
- }
-
- return null;
- };
-
- _proto2.render = function render() {
- var _this$props2 = this.props,
- blockRenderMap = _this$props2.blockRenderMap,
- blockRendererFn = _this$props2.blockRendererFn,
- blockStyleFn = _this$props2.blockStyleFn,
- customStyleFn = _this$props2.customStyleFn,
- customStyleMap = _this$props2.customStyleMap,
- editorState = _this$props2.editorState,
- preventScroll = _this$props2.preventScroll,
- readOnly = _this$props2.readOnly,
- textAlignment = _this$props2.textAlignment,
- textDirectionality = _this$props2.textDirectionality;
- var rootClass = cx({
- 'DraftEditor/root': true,
- 'DraftEditor/alignLeft': textAlignment === 'left',
- 'DraftEditor/alignRight': textAlignment === 'right',
- 'DraftEditor/alignCenter': textAlignment === 'center'
- });
- var contentStyle = {
- outline: 'none',
- // fix parent-draggable Safari bug. #1326
- userSelect: 'text',
- WebkitUserSelect: 'text',
- whiteSpace: 'pre-wrap',
- wordWrap: 'break-word'
- }; // The aria-expanded and aria-haspopup properties should only be rendered
- // for a combobox.
-
- /* $FlowFixMe(>=0.68.0 site=www,mobile) This comment suppresses an error
- * found when Flow v0.68 was deployed. To see the error delete this comment
- * and run Flow. */
-
- var ariaRole = this.props.role || 'textbox';
- var ariaExpanded = ariaRole === 'combobox' ? !!this.props.ariaExpanded : null;
- var editorContentsProps = {
- blockRenderMap: blockRenderMap,
- blockRendererFn: blockRendererFn,
- blockStyleFn: blockStyleFn,
- customStyleMap: _objectSpread({}, DefaultDraftInlineStyle, customStyleMap),
- customStyleFn: customStyleFn,
- editorKey: this._editorKey,
- editorState: editorState,
- preventScroll: preventScroll,
- textDirectionality: textDirectionality
- };
- return React.createElement("div", {
- className: rootClass
- }, this._renderPlaceholder(), React.createElement("div", {
- className: cx('DraftEditor/editorContainer'),
- ref: this._handleEditorContainerRef
- }, React.createElement("div", {
- "aria-activedescendant": readOnly ? null : this.props.ariaActiveDescendantID,
- "aria-autocomplete": readOnly ? null : this.props.ariaAutoComplete,
- "aria-controls": readOnly ? null : this.props.ariaControls,
- "aria-describedby": this.props.ariaDescribedBy || this._placeholderAccessibilityID,
- "aria-expanded": readOnly ? null : ariaExpanded,
- "aria-label": this.props.ariaLabel,
- "aria-labelledby": this.props.ariaLabelledBy,
- "aria-multiline": this.props.ariaMultiline,
- "aria-owns": readOnly ? null : this.props.ariaOwneeID,
- autoCapitalize: this.props.autoCapitalize,
- autoComplete: this.props.autoComplete,
- autoCorrect: this.props.autoCorrect,
- className: cx({
- // Chrome's built-in translation feature mutates the DOM in ways
- // that Draft doesn't expect (ex: adding <font> tags inside
- // DraftEditorLeaf spans) and causes problems. We add notranslate
- // here which makes its autotranslation skip over this subtree.
- notranslate: !readOnly,
- 'public/DraftEditor/content': true
- }),
- contentEditable: !readOnly,
- "data-testid": this.props.webDriverTestID,
- onBeforeInput: this._onBeforeInput,
- onBlur: this._onBlur,
- onCompositionEnd: this._onCompositionEnd,
- onCompositionStart: this._onCompositionStart,
- onCopy: this._onCopy,
- onCut: this._onCut,
- onDragEnd: this._onDragEnd,
- onDragEnter: this.onDragEnter,
- onDragLeave: this.onDragLeave,
- onDragOver: this._onDragOver,
- onDragStart: this._onDragStart,
- onDrop: this._onDrop,
- onFocus: this._onFocus,
- onInput: this._onInput,
- onKeyDown: this._onKeyDown,
- onKeyPress: this._onKeyPress,
- onKeyUp: this._onKeyUp,
- onMouseUp: this._onMouseUp,
- onPaste: this._onPaste,
- onSelect: this._onSelect,
- ref: this.props.editorRef,
- role: readOnly ? null : ariaRole,
- spellCheck: allowSpellCheck && this.props.spellCheck,
- style: contentStyle,
- suppressContentEditableWarning: true,
- tabIndex: this.props.tabIndex
- }, React.createElement(UpdateDraftEditorFlags, {
- editor: this,
- editorState: editorState
- }), React.createElement(DraftEditorContents, _extends({}, editorContentsProps, {
- key: 'contents' + this.state.contentsKey
- })))));
- };
-
- _proto2.componentDidMount = function componentDidMount() {
- this._blockSelectEvents = false;
-
- if (!didInitODS && gkx('draft_ods_enabled')) {
- didInitODS = true;
- DraftEffects.initODS();
- }
-
- this.setMode('edit');
- /**
- * IE has a hardcoded "feature" that attempts to convert link text into
- * anchors in contentEditable DOM. This breaks the editor's expectations of
- * the DOM, and control is lost. Disable it to make IE behave.
- * See: http://blogs.msdn.com/b/ieinternals/archive/2010/09/15/
- * ie9-beta-minor-change-list.aspx
- */
-
- if (isIE) {
- // editor can be null after mounting
- // https://stackoverflow.com/questions/44074747/componentdidmount-called-before-ref-callback
- if (!this.editor) {
- global.execCommand('AutoUrlDetect', false, false);
- } else {
- this.editor.ownerDocument.execCommand('AutoUrlDetect', false, false);
- }
- }
- };
-
- _proto2.componentDidUpdate = function componentDidUpdate() {
- this._blockSelectEvents = false;
- this._latestEditorState = this.props.editorState;
- this._latestCommittedEditorState = this.props.editorState;
- }
- /**
- * Used via `this.focus()`.
- *
- * Force focus back onto the editor node.
- *
- * We attempt to preserve scroll position when focusing. You can also pass
- * a specified scroll position (for cases like `cut` behavior where it should
- * be restored to a known position).
- */
- ;
-
- return DraftEditor;
- }(React.Component);
-
- _defineProperty(DraftEditor, "defaultProps", {
- blockRenderMap: DefaultDraftBlockRenderMap,
- blockRendererFn: function blockRendererFn() {
- return null;
- },
- blockStyleFn: function blockStyleFn() {
- return '';
- },
- keyBindingFn: getDefaultKeyBinding,
- readOnly: false,
- spellCheck: false,
- stripPastedStyles: false
- });
-
- module.exports = DraftEditor;
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(25)))
-
- /***/ }),
- /* 96 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DOMObserver = __webpack_require__(97);
-
- var DraftModifier = __webpack_require__(3);
-
- var DraftOffsetKey = __webpack_require__(10);
-
- var EditorState = __webpack_require__(2);
-
- var Keys = __webpack_require__(28);
-
- var editOnSelect = __webpack_require__(51);
-
- var getContentEditableContainer = __webpack_require__(53);
-
- var getDraftEditorSelection = __webpack_require__(54);
-
- var getEntityKeyForSelection = __webpack_require__(35);
-
- var nullthrows = __webpack_require__(4);
- /**
- * Millisecond delay to allow `compositionstart` to fire again upon
- * `compositionend`.
- *
- * This is used for Korean input to ensure that typing can continue without
- * the editor trying to render too quickly. More specifically, Safari 7.1+
- * triggers `compositionstart` a little slower than Chrome/FF, which
- * leads to composed characters being resolved and re-render occurring
- * sooner than we want.
- */
-
-
- var RESOLVE_DELAY = 20;
- /**
- * A handful of variables used to track the current composition and its
- * resolution status. These exist at the module level because it is not
- * possible to have compositions occurring in multiple editors simultaneously,
- * and it simplifies state management with respect to the DraftEditor component.
- */
-
- var resolved = false;
- var stillComposing = false;
- var domObserver = null;
-
- function startDOMObserver(editor) {
- if (!domObserver) {
- domObserver = new DOMObserver(getContentEditableContainer(editor));
- domObserver.start();
- }
- }
-
- var DraftEditorCompositionHandler = {
- /**
- * A `compositionstart` event has fired while we're still in composition
- * mode. Continue the current composition session to prevent a re-render.
- */
- onCompositionStart: function onCompositionStart(editor) {
- stillComposing = true;
- startDOMObserver(editor);
- },
-
- /**
- * Attempt to end the current composition session.
- *
- * Defer handling because browser will still insert the chars into active
- * element after `compositionend`. If a `compositionstart` event fires
- * before `resolveComposition` executes, our composition session will
- * continue.
- *
- * The `resolved` flag is useful because certain IME interfaces fire the
- * `compositionend` event multiple times, thus queueing up multiple attempts
- * at handling the composition. Since handling the same composition event
- * twice could break the DOM, we only use the first event. Example: Arabic
- * Google Input Tools on Windows 8.1 fires `compositionend` three times.
- */
- onCompositionEnd: function onCompositionEnd(editor) {
- resolved = false;
- stillComposing = false;
- setTimeout(function () {
- if (!resolved) {
- DraftEditorCompositionHandler.resolveComposition(editor);
- }
- }, RESOLVE_DELAY);
- },
- onSelect: editOnSelect,
-
- /**
- * In Safari, keydown events may fire when committing compositions. If
- * the arrow keys are used to commit, prevent default so that the cursor
- * doesn't move, otherwise it will jump back noticeably on re-render.
- */
- onKeyDown: function onKeyDown(editor, e) {
- if (!stillComposing) {
- // If a keydown event is received after compositionend but before the
- // 20ms timer expires (ex: type option-E then backspace, or type A then
- // backspace in 2-Set Korean), we should immediately resolve the
- // composition and reinterpret the key press in edit mode.
- DraftEditorCompositionHandler.resolveComposition(editor);
-
- editor._onKeyDown(e);
-
- return;
- }
-
- if (e.which === Keys.RIGHT || e.which === Keys.LEFT) {
- e.preventDefault();
- }
- },
-
- /**
- * Keypress events may fire when committing compositions. In Firefox,
- * pressing RETURN commits the composition and inserts extra newline
- * characters that we do not want. `preventDefault` allows the composition
- * to be committed while preventing the extra characters.
- */
- onKeyPress: function onKeyPress(editor, e) {
- if (e.which === Keys.RETURN) {
- e.preventDefault();
- }
- },
-
- /**
- * Attempt to insert composed characters into the document.
- *
- * If we are still in a composition session, do nothing. Otherwise, insert
- * the characters into the document and terminate the composition session.
- *
- * If no characters were composed -- for instance, the user
- * deleted all composed characters and committed nothing new --
- * force a re-render. We also re-render when the composition occurs
- * at the beginning of a leaf, to ensure that if the browser has
- * created a new text node for the composition, we will discard it.
- *
- * Resetting innerHTML will move focus to the beginning of the editor,
- * so we update to force it back to the correct place.
- */
- resolveComposition: function resolveComposition(editor) {
- if (stillComposing) {
- return;
- }
-
- var mutations = nullthrows(domObserver).stopAndFlushMutations();
- domObserver = null;
- resolved = true;
- var editorState = EditorState.set(editor._latestEditorState, {
- inCompositionMode: false
- });
- editor.exitCurrentMode();
-
- if (!mutations.size) {
- editor.update(editorState);
- return;
- } // TODO, check if Facebook still needs this flag or if it could be removed.
- // Since there can be multiple mutations providing a `composedChars` doesn't
- // apply well on this new model.
- // if (
- // gkx('draft_handlebeforeinput_composed_text') &&
- // editor.props.handleBeforeInput &&
- // isEventHandled(
- // editor.props.handleBeforeInput(
- // composedChars,
- // editorState,
- // event.timeStamp,
- // ),
- // )
- // ) {
- // return;
- // }
-
-
- var contentState = editorState.getCurrentContent();
- mutations.forEach(function (composedChars, offsetKey) {
- var _DraftOffsetKey$decod = DraftOffsetKey.decode(offsetKey),
- blockKey = _DraftOffsetKey$decod.blockKey,
- decoratorKey = _DraftOffsetKey$decod.decoratorKey,
- leafKey = _DraftOffsetKey$decod.leafKey;
-
- var _editorState$getBlock = editorState.getBlockTree(blockKey).getIn([decoratorKey, 'leaves', leafKey]),
- start = _editorState$getBlock.start,
- end = _editorState$getBlock.end;
-
- var replacementRange = editorState.getSelection().merge({
- anchorKey: blockKey,
- focusKey: blockKey,
- anchorOffset: start,
- focusOffset: end,
- isBackward: false
- });
- var entityKey = getEntityKeyForSelection(contentState, replacementRange);
- var currentStyle = contentState.getBlockForKey(blockKey).getInlineStyleAt(start);
- contentState = DraftModifier.replaceText(contentState, replacementRange, composedChars, currentStyle, entityKey); // We need to update the editorState so the leaf node ranges are properly
- // updated and multiple mutations are correctly applied.
-
- editorState = EditorState.set(editorState, {
- currentContent: contentState
- });
- }); // When we apply the text changes to the ContentState, the selection always
- // goes to the end of the field, but it should just stay where it is
- // after compositionEnd.
-
- var documentSelection = getDraftEditorSelection(editorState, getContentEditableContainer(editor));
- var compositionEndSelectionState = documentSelection.selectionState;
- editor.restoreEditorDOM();
- var editorStateWithUpdatedSelection = EditorState.acceptSelection(editorState, compositionEndSelectionState);
- editor.update(EditorState.push(editorStateWithUpdatedSelection, contentState, 'insert-characters'));
- }
- };
- module.exports = DraftEditorCompositionHandler;
-
- /***/ }),
- /* 97 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- var UserAgent = __webpack_require__(5);
-
- var findAncestorOffsetKey = __webpack_require__(26);
-
- var getWindowForNode = __webpack_require__(50);
-
- var Immutable = __webpack_require__(0);
-
- var invariant = __webpack_require__(1);
-
- var nullthrows = __webpack_require__(4);
-
- var Map = Immutable.Map;
- // Heavily based on Prosemirror's DOMObserver https://github.com/ProseMirror/prosemirror-view/blob/master/src/domobserver.js
- var DOM_OBSERVER_OPTIONS = {
- subtree: true,
- characterData: true,
- childList: true,
- characterDataOldValue: false,
- attributes: false
- }; // IE11 has very broken mutation observers, so we also listen to DOMCharacterDataModified
-
- var USE_CHAR_DATA = UserAgent.isBrowser('IE <= 11');
-
- var DOMObserver =
- /*#__PURE__*/
- function () {
- function DOMObserver(container) {
- var _this = this;
-
- _defineProperty(this, "observer", void 0);
-
- _defineProperty(this, "container", void 0);
-
- _defineProperty(this, "mutations", void 0);
-
- _defineProperty(this, "onCharData", void 0);
-
- this.container = container;
- this.mutations = Map();
- var containerWindow = getWindowForNode(container);
-
- if (containerWindow.MutationObserver && !USE_CHAR_DATA) {
- this.observer = new containerWindow.MutationObserver(function (mutations) {
- return _this.registerMutations(mutations);
- });
- } else {
- this.onCharData = function (e) {
- !(e.target instanceof Node) ? true ? invariant(false, 'Expected target to be an instance of Node') : invariant(false) : void 0;
-
- _this.registerMutation({
- type: 'characterData',
- target: e.target
- });
- };
- }
- }
-
- var _proto = DOMObserver.prototype;
-
- _proto.start = function start() {
- if (this.observer) {
- this.observer.observe(this.container, DOM_OBSERVER_OPTIONS);
- } else {
- /* $FlowFixMe(>=0.68.0 site=www,mobile) This event type is not defined
- * by Flow's standard library */
- this.container.addEventListener('DOMCharacterDataModified', this.onCharData);
- }
- };
-
- _proto.stopAndFlushMutations = function stopAndFlushMutations() {
- var observer = this.observer;
-
- if (observer) {
- this.registerMutations(observer.takeRecords());
- observer.disconnect();
- } else {
- /* $FlowFixMe(>=0.68.0 site=www,mobile) This event type is not defined
- * by Flow's standard library */
- this.container.removeEventListener('DOMCharacterDataModified', this.onCharData);
- }
-
- var mutations = this.mutations;
- this.mutations = Map();
- return mutations;
- };
-
- _proto.registerMutations = function registerMutations(mutations) {
- for (var i = 0; i < mutations.length; i++) {
- this.registerMutation(mutations[i]);
- }
- };
-
- _proto.getMutationTextContent = function getMutationTextContent(mutation) {
- var type = mutation.type,
- target = mutation.target,
- removedNodes = mutation.removedNodes;
-
- if (type === 'characterData') {
- // When `textContent` is '', there is a race condition that makes
- // getting the offsetKey from the target not possible.
- // These events are also followed by a `childList`, which is the one
- // we are able to retrieve the offsetKey and apply the '' text.
- if (target.textContent !== '') {
- // IE 11 considers the enter keypress that concludes the composition
- // as an input char. This strips that newline character so the draft
- // state does not receive spurious newlines.
- if (USE_CHAR_DATA) {
- return target.textContent.replace('\n', '');
- }
-
- return target.textContent;
- }
- } else if (type === 'childList') {
- if (removedNodes && removedNodes.length) {
- // `characterData` events won't happen or are ignored when
- // removing the last character of a leaf node, what happens
- // instead is a `childList` event with a `removedNodes` array.
- // For this case the textContent should be '' and
- // `DraftModifier.replaceText` will make sure the content is
- // updated properly.
- return '';
- } else if (target.textContent !== '') {
- // Typing Chinese in an empty block in MS Edge results in a
- // `childList` event with non-empty textContent.
- // See https://github.com/facebook/draft-js/issues/2082
- return target.textContent;
- }
- }
-
- return null;
- };
-
- _proto.registerMutation = function registerMutation(mutation) {
- var textContent = this.getMutationTextContent(mutation);
-
- if (textContent != null) {
- var offsetKey = nullthrows(findAncestorOffsetKey(mutation.target));
- this.mutations = this.mutations.set(offsetKey, textContent);
- }
- };
-
- return DOMObserver;
- }();
-
- module.exports = DOMObserver;
-
- /***/ }),
- /* 98 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
-
- /**
- * Usage note:
- * This module makes a best effort to export the same data we would internally.
- * At Facebook we use a server-generated module that does the parsing and
- * exports the data for the client to use. We can't rely on a server-side
- * implementation in open source so instead we make use of an open source
- * library to do the heavy lifting and then make some adjustments as necessary.
- * It's likely there will be some differences. Some we can smooth over.
- * Others are going to be harder.
- */
-
-
- var UAParser = __webpack_require__(99);
-
- var UNKNOWN = 'Unknown';
- var PLATFORM_MAP = {
- 'Mac OS': 'Mac OS X'
- };
- /**
- * Convert from UAParser platform name to what we expect.
- */
-
- function convertPlatformName(name) {
- return PLATFORM_MAP[name] || name;
- }
- /**
- * Get the version number in parts. This is very naive. We actually get major
- * version as a part of UAParser already, which is generally good enough, but
- * let's get the minor just in case.
- */
-
-
- function getBrowserVersion(version) {
- if (!version) {
- return {
- major: '',
- minor: ''
- };
- }
-
- var parts = version.split('.');
- return {
- major: parts[0],
- minor: parts[1]
- };
- }
- /**
- * Get the UA data fom UAParser and then convert it to the format we're
- * expecting for our APIS.
- */
-
-
- var parser = new UAParser();
- var results = parser.getResult(); // Do some conversion first.
-
- var browserVersionData = getBrowserVersion(results.browser.version);
- var uaData = {
- browserArchitecture: results.cpu.architecture || UNKNOWN,
- browserFullVersion: results.browser.version || UNKNOWN,
- browserMinorVersion: browserVersionData.minor || UNKNOWN,
- browserName: results.browser.name || UNKNOWN,
- browserVersion: results.browser.major || UNKNOWN,
- deviceName: results.device.model || UNKNOWN,
- engineName: results.engine.name || UNKNOWN,
- engineVersion: results.engine.version || UNKNOWN,
- platformArchitecture: results.cpu.architecture || UNKNOWN,
- platformName: convertPlatformName(results.os.name) || UNKNOWN,
- platformVersion: results.os.version || UNKNOWN,
- platformFullVersion: results.os.version || UNKNOWN
- };
- module.exports = uaData;
-
- /***/ }),
- /* 99 */
- /***/ (function(module, exports, __webpack_require__) {
-
- var __WEBPACK_AMD_DEFINE_RESULT__;/*!
- * UAParser.js v0.7.19
- * Lightweight JavaScript-based User-Agent string parser
- * https://github.com/faisalman/ua-parser-js
- *
- * Copyright © 2012-2016 Faisal Salman <fyzlman@gmail.com>
- * Dual licensed under GPLv2 or MIT
- */
-
- (function (window, undefined) {
-
- 'use strict';
-
- //////////////
- // Constants
- /////////////
-
-
- var LIBVERSION = '0.7.19',
- EMPTY = '',
- UNKNOWN = '?',
- FUNC_TYPE = 'function',
- UNDEF_TYPE = 'undefined',
- OBJ_TYPE = 'object',
- STR_TYPE = 'string',
- MAJOR = 'major', // deprecated
- MODEL = 'model',
- NAME = 'name',
- TYPE = 'type',
- VENDOR = 'vendor',
- VERSION = 'version',
- ARCHITECTURE= 'architecture',
- CONSOLE = 'console',
- MOBILE = 'mobile',
- TABLET = 'tablet',
- SMARTTV = 'smarttv',
- WEARABLE = 'wearable',
- EMBEDDED = 'embedded';
-
-
- ///////////
- // Helper
- //////////
-
-
- var util = {
- extend : function (regexes, extensions) {
- var margedRegexes = {};
- for (var i in regexes) {
- if (extensions[i] && extensions[i].length % 2 === 0) {
- margedRegexes[i] = extensions[i].concat(regexes[i]);
- } else {
- margedRegexes[i] = regexes[i];
- }
- }
- return margedRegexes;
- },
- has : function (str1, str2) {
- if (typeof str1 === "string") {
- return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1;
- } else {
- return false;
- }
- },
- lowerize : function (str) {
- return str.toLowerCase();
- },
- major : function (version) {
- return typeof(version) === STR_TYPE ? version.replace(/[^\d\.]/g,'').split(".")[0] : undefined;
- },
- trim : function (str) {
- return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
- }
- };
-
-
- ///////////////
- // Map helper
- //////////////
-
-
- var mapper = {
-
- rgx : function (ua, arrays) {
-
- //var result = {},
- var i = 0, j, k, p, q, matches, match;//, args = arguments;
-
- /*// construct object barebones
- for (p = 0; p < args[1].length; p++) {
- q = args[1][p];
- result[typeof q === OBJ_TYPE ? q[0] : q] = undefined;
- }*/
-
- // loop through all regexes maps
- while (i < arrays.length && !matches) {
-
- var regex = arrays[i], // even sequence (0,2,4,..)
- props = arrays[i + 1]; // odd sequence (1,3,5,..)
- j = k = 0;
-
- // try matching uastring with regexes
- while (j < regex.length && !matches) {
-
- matches = regex[j++].exec(ua);
-
- if (!!matches) {
- for (p = 0; p < props.length; p++) {
- match = matches[++k];
- q = props[p];
- // check if given property is actually array
- if (typeof q === OBJ_TYPE && q.length > 0) {
- if (q.length == 2) {
- if (typeof q[1] == FUNC_TYPE) {
- // assign modified match
- this[q[0]] = q[1].call(this, match);
- } else {
- // assign given value, ignore regex match
- this[q[0]] = q[1];
- }
- } else if (q.length == 3) {
- // check whether function or regex
- if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) {
- // call function (usually string mapper)
- this[q[0]] = match ? q[1].call(this, match, q[2]) : undefined;
- } else {
- // sanitize match using given regex
- this[q[0]] = match ? match.replace(q[1], q[2]) : undefined;
- }
- } else if (q.length == 4) {
- this[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined;
- }
- } else {
- this[q] = match ? match : undefined;
- }
- }
- }
- }
- i += 2;
- }
- // console.log(this);
- //return this;
- },
-
- str : function (str, map) {
-
- for (var i in map) {
- // check if array
- if (typeof map[i] === OBJ_TYPE && map[i].length > 0) {
- for (var j = 0; j < map[i].length; j++) {
- if (util.has(map[i][j], str)) {
- return (i === UNKNOWN) ? undefined : i;
- }
- }
- } else if (util.has(map[i], str)) {
- return (i === UNKNOWN) ? undefined : i;
- }
- }
- return str;
- }
- };
-
-
- ///////////////
- // String map
- //////////////
-
-
- var maps = {
-
- browser : {
- oldsafari : {
- version : {
- '1.0' : '/8',
- '1.2' : '/1',
- '1.3' : '/3',
- '2.0' : '/412',
- '2.0.2' : '/416',
- '2.0.3' : '/417',
- '2.0.4' : '/419',
- '?' : '/'
- }
- }
- },
-
- device : {
- amazon : {
- model : {
- 'Fire Phone' : ['SD', 'KF']
- }
- },
- sprint : {
- model : {
- 'Evo Shift 4G' : '7373KT'
- },
- vendor : {
- 'HTC' : 'APA',
- 'Sprint' : 'Sprint'
- }
- }
- },
-
- os : {
- windows : {
- version : {
- 'ME' : '4.90',
- 'NT 3.11' : 'NT3.51',
- 'NT 4.0' : 'NT4.0',
- '2000' : 'NT 5.0',
- 'XP' : ['NT 5.1', 'NT 5.2'],
- 'Vista' : 'NT 6.0',
- '7' : 'NT 6.1',
- '8' : 'NT 6.2',
- '8.1' : 'NT 6.3',
- '10' : ['NT 6.4', 'NT 10.0'],
- 'RT' : 'ARM'
- }
- }
- }
- };
-
-
- //////////////
- // Regex map
- /////////////
-
-
- var regexes = {
-
- browser : [[
-
- // Presto based
- /(opera\smini)\/([\w\.-]+)/i, // Opera Mini
- /(opera\s[mobiletab]+).+version\/([\w\.-]+)/i, // Opera Mobi/Tablet
- /(opera).+version\/([\w\.]+)/i, // Opera > 9.80
- /(opera)[\/\s]+([\w\.]+)/i // Opera < 9.80
- ], [NAME, VERSION], [
-
- /(opios)[\/\s]+([\w\.]+)/i // Opera mini on iphone >= 8.0
- ], [[NAME, 'Opera Mini'], VERSION], [
-
- /\s(opr)\/([\w\.]+)/i // Opera Webkit
- ], [[NAME, 'Opera'], VERSION], [
-
- // Mixed
- /(kindle)\/([\w\.]+)/i, // Kindle
- /(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]*)/i,
- // Lunascape/Maxthon/Netfront/Jasmine/Blazer
-
- // Trident based
- /(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?([\w\.]*)/i,
- // Avant/IEMobile/SlimBrowser/Baidu
- /(?:ms|\()(ie)\s([\w\.]+)/i, // Internet Explorer
-
- // Webkit/KHTML based
- /(rekonq)\/([\w\.]*)/i, // Rekonq
- /(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark)\/([\w\.-]+)/i
- // Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser
- ], [NAME, VERSION], [
-
- /(trident).+rv[:\s]([\w\.]+).+like\sgecko/i // IE11
- ], [[NAME, 'IE'], VERSION], [
-
- /(edge|edgios|edga)\/((\d+)?[\w\.]+)/i // Microsoft Edge
- ], [[NAME, 'Edge'], VERSION], [
-
- /(yabrowser)\/([\w\.]+)/i // Yandex
- ], [[NAME, 'Yandex'], VERSION], [
-
- /(puffin)\/([\w\.]+)/i // Puffin
- ], [[NAME, 'Puffin'], VERSION], [
-
- /(focus)\/([\w\.]+)/i // Firefox Focus
- ], [[NAME, 'Firefox Focus'], VERSION], [
-
- /(opt)\/([\w\.]+)/i // Opera Touch
- ], [[NAME, 'Opera Touch'], VERSION], [
-
- /((?:[\s\/])uc?\s?browser|(?:juc.+)ucweb)[\/\s]?([\w\.]+)/i // UCBrowser
- ], [[NAME, 'UCBrowser'], VERSION], [
-
- /(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon
- ], [[NAME, /_/g, ' '], VERSION], [
-
- /(micromessenger)\/([\w\.]+)/i // WeChat
- ], [[NAME, 'WeChat'], VERSION], [
-
- /(brave)\/([\w\.]+)/i // Brave browser
- ], [[NAME, 'Brave'], VERSION], [
-
- /(qqbrowserlite)\/([\w\.]+)/i // QQBrowserLite
- ], [NAME, VERSION], [
-
- /(QQ)\/([\d\.]+)/i // QQ, aka ShouQ
- ], [NAME, VERSION], [
-
- /m?(qqbrowser)[\/\s]?([\w\.]+)/i // QQBrowser
- ], [NAME, VERSION], [
-
- /(BIDUBrowser)[\/\s]?([\w\.]+)/i // Baidu Browser
- ], [NAME, VERSION], [
-
- /(2345Explorer)[\/\s]?([\w\.]+)/i // 2345 Browser
- ], [NAME, VERSION], [
-
- /(MetaSr)[\/\s]?([\w\.]+)/i // SouGouBrowser
- ], [NAME], [
-
- /(LBBROWSER)/i // LieBao Browser
- ], [NAME], [
-
- /xiaomi\/miuibrowser\/([\w\.]+)/i // MIUI Browser
- ], [VERSION, [NAME, 'MIUI Browser']], [
-
- /;fbav\/([\w\.]+);/i // Facebook App for iOS & Android
- ], [VERSION, [NAME, 'Facebook']], [
-
- /safari\s(line)\/([\w\.]+)/i, // Line App for iOS
- /android.+(line)\/([\w\.]+)\/iab/i // Line App for Android
- ], [NAME, VERSION], [
-
- /headlesschrome(?:\/([\w\.]+)|\s)/i // Chrome Headless
- ], [VERSION, [NAME, 'Chrome Headless']], [
-
- /\swv\).+(chrome)\/([\w\.]+)/i // Chrome WebView
- ], [[NAME, /(.+)/, '$1 WebView'], VERSION], [
-
- /((?:oculus|samsung)browser)\/([\w\.]+)/i
- ], [[NAME, /(.+(?:g|us))(.+)/, '$1 $2'], VERSION], [ // Oculus / Samsung Browser
-
- /android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)*/i // Android Browser
- ], [VERSION, [NAME, 'Android Browser']], [
-
- /(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i
- // Chrome/OmniWeb/Arora/Tizen/Nokia
- ], [NAME, VERSION], [
-
- /(dolfin)\/([\w\.]+)/i // Dolphin
- ], [[NAME, 'Dolphin'], VERSION], [
-
- /((?:android.+)crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS
- ], [[NAME, 'Chrome'], VERSION], [
-
- /(coast)\/([\w\.]+)/i // Opera Coast
- ], [[NAME, 'Opera Coast'], VERSION], [
-
- /fxios\/([\w\.-]+)/i // Firefox for iOS
- ], [VERSION, [NAME, 'Firefox']], [
-
- /version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari
- ], [VERSION, [NAME, 'Mobile Safari']], [
-
- /version\/([\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile
- ], [VERSION, NAME], [
-
- /webkit.+?(gsa)\/([\w\.]+).+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Google Search Appliance on iOS
- ], [[NAME, 'GSA'], VERSION], [
-
- /webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Safari < 3.0
- ], [NAME, [VERSION, mapper.str, maps.browser.oldsafari.version]], [
-
- /(konqueror)\/([\w\.]+)/i, // Konqueror
- /(webkit|khtml)\/([\w\.]+)/i
- ], [NAME, VERSION], [
-
- // Gecko based
- /(navigator|netscape)\/([\w\.-]+)/i // Netscape
- ], [[NAME, 'Netscape'], VERSION], [
- /(swiftfox)/i, // Swiftfox
- /(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i,
- // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror
- /(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([\w\.-]+)$/i,
-
- // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
- /(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla
-
- // Other
- /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir)[\/\s]?([\w\.]+)/i,
- // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir
- /(links)\s\(([\w\.]+)/i, // Links
- /(gobrowser)\/?([\w\.]*)/i, // GoBrowser
- /(ice\s?browser)\/v?([\w\._]+)/i, // ICE Browser
- /(mosaic)[\/\s]([\w\.]+)/i // Mosaic
- ], [NAME, VERSION]
-
- /* /////////////////////
- // Media players BEGIN
- ////////////////////////
-
- , [
-
- /(apple(?:coremedia|))\/((\d+)[\w\._]+)/i, // Generic Apple CoreMedia
- /(coremedia) v((\d+)[\w\._]+)/i
- ], [NAME, VERSION], [
-
- /(aqualung|lyssna|bsplayer)\/((\d+)?[\w\.-]+)/i // Aqualung/Lyssna/BSPlayer
- ], [NAME, VERSION], [
-
- /(ares|ossproxy)\s((\d+)[\w\.-]+)/i // Ares/OSSProxy
- ], [NAME, VERSION], [
-
- /(audacious|audimusicstream|amarok|bass|core|dalvik|gnomemplayer|music on console|nsplayer|psp-internetradioplayer|videos)\/((\d+)[\w\.-]+)/i,
- // Audacious/AudiMusicStream/Amarok/BASS/OpenCORE/Dalvik/GnomeMplayer/MoC
- // NSPlayer/PSP-InternetRadioPlayer/Videos
- /(clementine|music player daemon)\s((\d+)[\w\.-]+)/i, // Clementine/MPD
- /(lg player|nexplayer)\s((\d+)[\d\.]+)/i,
- /player\/(nexplayer|lg player)\s((\d+)[\w\.-]+)/i // NexPlayer/LG Player
- ], [NAME, VERSION], [
- /(nexplayer)\s((\d+)[\w\.-]+)/i // Nexplayer
- ], [NAME, VERSION], [
-
- /(flrp)\/((\d+)[\w\.-]+)/i // Flip Player
- ], [[NAME, 'Flip Player'], VERSION], [
-
- /(fstream|nativehost|queryseekspider|ia-archiver|facebookexternalhit)/i
- // FStream/NativeHost/QuerySeekSpider/IA Archiver/facebookexternalhit
- ], [NAME], [
-
- /(gstreamer) souphttpsrc (?:\([^\)]+\)){0,1} libsoup\/((\d+)[\w\.-]+)/i
- // Gstreamer
- ], [NAME, VERSION], [
-
- /(htc streaming player)\s[\w_]+\s\/\s((\d+)[\d\.]+)/i, // HTC Streaming Player
- /(java|python-urllib|python-requests|wget|libcurl)\/((\d+)[\w\.-_]+)/i,
- // Java/urllib/requests/wget/cURL
- /(lavf)((\d+)[\d\.]+)/i // Lavf (FFMPEG)
- ], [NAME, VERSION], [
-
- /(htc_one_s)\/((\d+)[\d\.]+)/i // HTC One S
- ], [[NAME, /_/g, ' '], VERSION], [
-
- /(mplayer)(?:\s|\/)(?:(?:sherpya-){0,1}svn)(?:-|\s)(r\d+(?:-\d+[\w\.-]+){0,1})/i
- // MPlayer SVN
- ], [NAME, VERSION], [
-
- /(mplayer)(?:\s|\/|[unkow-]+)((\d+)[\w\.-]+)/i // MPlayer
- ], [NAME, VERSION], [
-
- /(mplayer)/i, // MPlayer (no other info)
- /(yourmuze)/i, // YourMuze
- /(media player classic|nero showtime)/i // Media Player Classic/Nero ShowTime
- ], [NAME], [
-
- /(nero (?:home|scout))\/((\d+)[\w\.-]+)/i // Nero Home/Nero Scout
- ], [NAME, VERSION], [
-
- /(nokia\d+)\/((\d+)[\w\.-]+)/i // Nokia
- ], [NAME, VERSION], [
-
- /\s(songbird)\/((\d+)[\w\.-]+)/i // Songbird/Philips-Songbird
- ], [NAME, VERSION], [
-
- /(winamp)3 version ((\d+)[\w\.-]+)/i, // Winamp
- /(winamp)\s((\d+)[\w\.-]+)/i,
- /(winamp)mpeg\/((\d+)[\w\.-]+)/i
- ], [NAME, VERSION], [
-
- /(ocms-bot|tapinradio|tunein radio|unknown|winamp|inlight radio)/i // OCMS-bot/tap in radio/tunein/unknown/winamp (no other info)
- // inlight radio
- ], [NAME], [
-
- /(quicktime|rma|radioapp|radioclientapplication|soundtap|totem|stagefright|streamium)\/((\d+)[\w\.-]+)/i
- // QuickTime/RealMedia/RadioApp/RadioClientApplication/
- // SoundTap/Totem/Stagefright/Streamium
- ], [NAME, VERSION], [
-
- /(smp)((\d+)[\d\.]+)/i // SMP
- ], [NAME, VERSION], [
-
- /(vlc) media player - version ((\d+)[\w\.]+)/i, // VLC Videolan
- /(vlc)\/((\d+)[\w\.-]+)/i,
- /(xbmc|gvfs|xine|xmms|irapp)\/((\d+)[\w\.-]+)/i, // XBMC/gvfs/Xine/XMMS/irapp
- /(foobar2000)\/((\d+)[\d\.]+)/i, // Foobar2000
- /(itunes)\/((\d+)[\d\.]+)/i // iTunes
- ], [NAME, VERSION], [
-
- /(wmplayer)\/((\d+)[\w\.-]+)/i, // Windows Media Player
- /(windows-media-player)\/((\d+)[\w\.-]+)/i
- ], [[NAME, /-/g, ' '], VERSION], [
-
- /windows\/((\d+)[\w\.-]+) upnp\/[\d\.]+ dlnadoc\/[\d\.]+ (home media server)/i
- // Windows Media Server
- ], [VERSION, [NAME, 'Windows']], [
-
- /(com\.riseupradioalarm)\/((\d+)[\d\.]*)/i // RiseUP Radio Alarm
- ], [NAME, VERSION], [
-
- /(rad.io)\s((\d+)[\d\.]+)/i, // Rad.io
- /(radio.(?:de|at|fr))\s((\d+)[\d\.]+)/i
- ], [[NAME, 'rad.io'], VERSION]
-
- //////////////////////
- // Media players END
- ////////////////////*/
-
- ],
-
- cpu : [[
-
- /(?:(amd|x(?:(?:86|64)[_-])?|wow|win)64)[;\)]/i // AMD64
- ], [[ARCHITECTURE, 'amd64']], [
-
- /(ia32(?=;))/i // IA32 (quicktime)
- ], [[ARCHITECTURE, util.lowerize]], [
-
- /((?:i[346]|x)86)[;\)]/i // IA32
- ], [[ARCHITECTURE, 'ia32']], [
-
- // PocketPC mistakenly identified as PowerPC
- /windows\s(ce|mobile);\sppc;/i
- ], [[ARCHITECTURE, 'arm']], [
-
- /((?:ppc|powerpc)(?:64)?)(?:\smac|;|\))/i // PowerPC
- ], [[ARCHITECTURE, /ower/, '', util.lowerize]], [
-
- /(sun4\w)[;\)]/i // SPARC
- ], [[ARCHITECTURE, 'sparc']], [
-
- /((?:avr32|ia64(?=;))|68k(?=\))|arm(?:64|(?=v\d+[;l]))|(?=atmel\s)avr|(?:irix|mips|sparc)(?:64)?(?=;)|pa-risc)/i
- // IA64, 68K, ARM/64, AVR/32, IRIX/64, MIPS/64, SPARC/64, PA-RISC
- ], [[ARCHITECTURE, util.lowerize]]
- ],
-
- device : [[
-
- /\((ipad|playbook);[\w\s\);-]+(rim|apple)/i // iPad/PlayBook
- ], [MODEL, VENDOR, [TYPE, TABLET]], [
-
- /applecoremedia\/[\w\.]+ \((ipad)/ // iPad
- ], [MODEL, [VENDOR, 'Apple'], [TYPE, TABLET]], [
-
- /(apple\s{0,1}tv)/i // Apple TV
- ], [[MODEL, 'Apple TV'], [VENDOR, 'Apple']], [
-
- /(archos)\s(gamepad2?)/i, // Archos
- /(hp).+(touchpad)/i, // HP TouchPad
- /(hp).+(tablet)/i, // HP Tablet
- /(kindle)\/([\w\.]+)/i, // Kindle
- /\s(nook)[\w\s]+build\/(\w+)/i, // Nook
- /(dell)\s(strea[kpr\s\d]*[\dko])/i // Dell Streak
- ], [VENDOR, MODEL, [TYPE, TABLET]], [
-
- /(kf[A-z]+)\sbuild\/.+silk\//i // Kindle Fire HD
- ], [MODEL, [VENDOR, 'Amazon'], [TYPE, TABLET]], [
- /(sd|kf)[0349hijorstuw]+\sbuild\/.+silk\//i // Fire Phone
- ], [[MODEL, mapper.str, maps.device.amazon.model], [VENDOR, 'Amazon'], [TYPE, MOBILE]], [
- /android.+aft([bms])\sbuild/i // Fire TV
- ], [MODEL, [VENDOR, 'Amazon'], [TYPE, SMARTTV]], [
-
- /\((ip[honed|\s\w*]+);.+(apple)/i // iPod/iPhone
- ], [MODEL, VENDOR, [TYPE, MOBILE]], [
- /\((ip[honed|\s\w*]+);/i // iPod/iPhone
- ], [MODEL, [VENDOR, 'Apple'], [TYPE, MOBILE]], [
-
- /(blackberry)[\s-]?(\w+)/i, // BlackBerry
- /(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[\s_-]?([\w-]*)/i,
- // BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Meizu/Motorola/Polytron
- /(hp)\s([\w\s]+\w)/i, // HP iPAQ
- /(asus)-?(\w+)/i // Asus
- ], [VENDOR, MODEL, [TYPE, MOBILE]], [
- /\(bb10;\s(\w+)/i // BlackBerry 10
- ], [MODEL, [VENDOR, 'BlackBerry'], [TYPE, MOBILE]], [
- // Asus Tablets
- /android.+(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus 7|padfone)/i
- ], [MODEL, [VENDOR, 'Asus'], [TYPE, TABLET]], [
-
- /(sony)\s(tablet\s[ps])\sbuild\//i, // Sony
- /(sony)?(?:sgp.+)\sbuild\//i
- ], [[VENDOR, 'Sony'], [MODEL, 'Xperia Tablet'], [TYPE, TABLET]], [
- /android.+\s([c-g]\d{4}|so[-l]\w+)\sbuild\//i
- ], [MODEL, [VENDOR, 'Sony'], [TYPE, MOBILE]], [
-
- /\s(ouya)\s/i, // Ouya
- /(nintendo)\s([wids3u]+)/i // Nintendo
- ], [VENDOR, MODEL, [TYPE, CONSOLE]], [
-
- /android.+;\s(shield)\sbuild/i // Nvidia
- ], [MODEL, [VENDOR, 'Nvidia'], [TYPE, CONSOLE]], [
-
- /(playstation\s[34portablevi]+)/i // Playstation
- ], [MODEL, [VENDOR, 'Sony'], [TYPE, CONSOLE]], [
-
- /(sprint\s(\w+))/i // Sprint Phones
- ], [[VENDOR, mapper.str, maps.device.sprint.vendor], [MODEL, mapper.str, maps.device.sprint.model], [TYPE, MOBILE]], [
-
- /(lenovo)\s?(S(?:5000|6000)+(?:[-][\w+]))/i // Lenovo tablets
- ], [VENDOR, MODEL, [TYPE, TABLET]], [
-
- /(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i, // HTC
- /(zte)-(\w*)/i, // ZTE
- /(alcatel|geeksphone|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]*)/i
- // Alcatel/GeeksPhone/Lenovo/Nexian/Panasonic/Sony
- ], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
-
- /(nexus\s9)/i // HTC Nexus 9
- ], [MODEL, [VENDOR, 'HTC'], [TYPE, TABLET]], [
-
- /d\/huawei([\w\s-]+)[;\)]/i,
- /(nexus\s6p)/i // Huawei
- ], [MODEL, [VENDOR, 'Huawei'], [TYPE, MOBILE]], [
-
- /(microsoft);\s(lumia[\s\w]+)/i // Microsoft Lumia
- ], [VENDOR, MODEL, [TYPE, MOBILE]], [
-
- /[\s\(;](xbox(?:\sone)?)[\s\);]/i // Microsoft Xbox
- ], [MODEL, [VENDOR, 'Microsoft'], [TYPE, CONSOLE]], [
- /(kin\.[onetw]{3})/i // Microsoft Kin
- ], [[MODEL, /\./g, ' '], [VENDOR, 'Microsoft'], [TYPE, MOBILE]], [
-
- // Motorola
- /\s(milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?:?(\s4g)?)[\w\s]+build\//i,
- /mot[\s-]?(\w*)/i,
- /(XT\d{3,4}) build\//i,
- /(nexus\s6)/i
- ], [MODEL, [VENDOR, 'Motorola'], [TYPE, MOBILE]], [
- /android.+\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i
- ], [MODEL, [VENDOR, 'Motorola'], [TYPE, TABLET]], [
-
- /hbbtv\/\d+\.\d+\.\d+\s+\([\w\s]*;\s*(\w[^;]*);([^;]*)/i // HbbTV devices
- ], [[VENDOR, util.trim], [MODEL, util.trim], [TYPE, SMARTTV]], [
-
- /hbbtv.+maple;(\d+)/i
- ], [[MODEL, /^/, 'SmartTV'], [VENDOR, 'Samsung'], [TYPE, SMARTTV]], [
-
- /\(dtv[\);].+(aquos)/i // Sharp
- ], [MODEL, [VENDOR, 'Sharp'], [TYPE, SMARTTV]], [
-
- /android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n\d+|sgh-t8[56]9|nexus 10))/i,
- /((SM-T\w+))/i
- ], [[VENDOR, 'Samsung'], MODEL, [TYPE, TABLET]], [ // Samsung
- /smart-tv.+(samsung)/i
- ], [VENDOR, [TYPE, SMARTTV], MODEL], [
- /((s[cgp]h-\w+|gt-\w+|galaxy\snexus|sm-\w[\w\d]+))/i,
- /(sam[sung]*)[\s-]*(\w+-?[\w-]*)/i,
- /sec-((sgh\w+))/i
- ], [[VENDOR, 'Samsung'], MODEL, [TYPE, MOBILE]], [
-
- /sie-(\w*)/i // Siemens
- ], [MODEL, [VENDOR, 'Siemens'], [TYPE, MOBILE]], [
-
- /(maemo|nokia).*(n900|lumia\s\d+)/i, // Nokia
- /(nokia)[\s_-]?([\w-]*)/i
- ], [[VENDOR, 'Nokia'], MODEL, [TYPE, MOBILE]], [
-
- /android\s3\.[\s\w;-]{10}(a\d{3})/i // Acer
- ], [MODEL, [VENDOR, 'Acer'], [TYPE, TABLET]], [
-
- /android.+([vl]k\-?\d{3})\s+build/i // LG Tablet
- ], [MODEL, [VENDOR, 'LG'], [TYPE, TABLET]], [
- /android\s3\.[\s\w;-]{10}(lg?)-([06cv9]{3,4})/i // LG Tablet
- ], [[VENDOR, 'LG'], MODEL, [TYPE, TABLET]], [
- /(lg) netcast\.tv/i // LG SmartTV
- ], [VENDOR, MODEL, [TYPE, SMARTTV]], [
- /(nexus\s[45])/i, // LG
- /lg[e;\s\/-]+(\w*)/i,
- /android.+lg(\-?[\d\w]+)\s+build/i
- ], [MODEL, [VENDOR, 'LG'], [TYPE, MOBILE]], [
-
- /android.+(ideatab[a-z0-9\-\s]+)/i // Lenovo
- ], [MODEL, [VENDOR, 'Lenovo'], [TYPE, TABLET]], [
-
- /linux;.+((jolla));/i // Jolla
- ], [VENDOR, MODEL, [TYPE, MOBILE]], [
-
- /((pebble))app\/[\d\.]+\s/i // Pebble
- ], [VENDOR, MODEL, [TYPE, WEARABLE]], [
-
- /android.+;\s(oppo)\s?([\w\s]+)\sbuild/i // OPPO
- ], [VENDOR, MODEL, [TYPE, MOBILE]], [
-
- /crkey/i // Google Chromecast
- ], [[MODEL, 'Chromecast'], [VENDOR, 'Google']], [
-
- /android.+;\s(glass)\s\d/i // Google Glass
- ], [MODEL, [VENDOR, 'Google'], [TYPE, WEARABLE]], [
-
- /android.+;\s(pixel c)[\s)]/i // Google Pixel C
- ], [MODEL, [VENDOR, 'Google'], [TYPE, TABLET]], [
-
- /android.+;\s(pixel( [23])?( xl)?)\s/i // Google Pixel
- ], [MODEL, [VENDOR, 'Google'], [TYPE, MOBILE]], [
-
- /android.+;\s(\w+)\s+build\/hm\1/i, // Xiaomi Hongmi 'numeric' models
- /android.+(hm[\s\-_]*note?[\s_]*(?:\d\w)?)\s+build/i, // Xiaomi Hongmi
- /android.+(mi[\s\-_]*(?:one|one[\s_]plus|note lte)?[\s_]*(?:\d?\w?)[\s_]*(?:plus)?)\s+build/i, // Xiaomi Mi
- /android.+(redmi[\s\-_]*(?:note)?(?:[\s_]*[\w\s]+))\s+build/i // Redmi Phones
- ], [[MODEL, /_/g, ' '], [VENDOR, 'Xiaomi'], [TYPE, MOBILE]], [
- /android.+(mi[\s\-_]*(?:pad)(?:[\s_]*[\w\s]+))\s+build/i // Mi Pad tablets
- ],[[MODEL, /_/g, ' '], [VENDOR, 'Xiaomi'], [TYPE, TABLET]], [
- /android.+;\s(m[1-5]\snote)\sbuild/i // Meizu Tablet
- ], [MODEL, [VENDOR, 'Meizu'], [TYPE, TABLET]], [
- /(mz)-([\w-]{2,})/i // Meizu Phone
- ], [[VENDOR, 'Meizu'], MODEL, [TYPE, MOBILE]], [
-
- /android.+a000(1)\s+build/i, // OnePlus
- /android.+oneplus\s(a\d{4})\s+build/i
- ], [MODEL, [VENDOR, 'OnePlus'], [TYPE, MOBILE]], [
-
- /android.+[;\/]\s*(RCT[\d\w]+)\s+build/i // RCA Tablets
- ], [MODEL, [VENDOR, 'RCA'], [TYPE, TABLET]], [
-
- /android.+[;\/\s]+(Venue[\d\s]{2,7})\s+build/i // Dell Venue Tablets
- ], [MODEL, [VENDOR, 'Dell'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s*(Q[T|M][\d\w]+)\s+build/i // Verizon Tablet
- ], [MODEL, [VENDOR, 'Verizon'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s+(Barnes[&\s]+Noble\s+|BN[RT])(V?.*)\s+build/i // Barnes & Noble Tablet
- ], [[VENDOR, 'Barnes & Noble'], MODEL, [TYPE, TABLET]], [
-
- /android.+[;\/]\s+(TM\d{3}.*\b)\s+build/i // Barnes & Noble Tablet
- ], [MODEL, [VENDOR, 'NuVision'], [TYPE, TABLET]], [
-
- /android.+;\s(k88)\sbuild/i // ZTE K Series Tablet
- ], [MODEL, [VENDOR, 'ZTE'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s*(gen\d{3})\s+build.*49h/i // Swiss GEN Mobile
- ], [MODEL, [VENDOR, 'Swiss'], [TYPE, MOBILE]], [
-
- /android.+[;\/]\s*(zur\d{3})\s+build/i // Swiss ZUR Tablet
- ], [MODEL, [VENDOR, 'Swiss'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s*((Zeki)?TB.*\b)\s+build/i // Zeki Tablets
- ], [MODEL, [VENDOR, 'Zeki'], [TYPE, TABLET]], [
-
- /(android).+[;\/]\s+([YR]\d{2})\s+build/i,
- /android.+[;\/]\s+(Dragon[\-\s]+Touch\s+|DT)(\w{5})\sbuild/i // Dragon Touch Tablet
- ], [[VENDOR, 'Dragon Touch'], MODEL, [TYPE, TABLET]], [
-
- /android.+[;\/]\s*(NS-?\w{0,9})\sbuild/i // Insignia Tablets
- ], [MODEL, [VENDOR, 'Insignia'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s*((NX|Next)-?\w{0,9})\s+build/i // NextBook Tablets
- ], [MODEL, [VENDOR, 'NextBook'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s*(Xtreme\_)?(V(1[045]|2[015]|30|40|60|7[05]|90))\s+build/i
- ], [[VENDOR, 'Voice'], MODEL, [TYPE, MOBILE]], [ // Voice Xtreme Phones
-
- /android.+[;\/]\s*(LVTEL\-)?(V1[12])\s+build/i // LvTel Phones
- ], [[VENDOR, 'LvTel'], MODEL, [TYPE, MOBILE]], [
-
- /android.+;\s(PH-1)\s/i
- ], [MODEL, [VENDOR, 'Essential'], [TYPE, MOBILE]], [ // Essential PH-1
-
- /android.+[;\/]\s*(V(100MD|700NA|7011|917G).*\b)\s+build/i // Envizen Tablets
- ], [MODEL, [VENDOR, 'Envizen'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s*(Le[\s\-]+Pan)[\s\-]+(\w{1,9})\s+build/i // Le Pan Tablets
- ], [VENDOR, MODEL, [TYPE, TABLET]], [
-
- /android.+[;\/]\s*(Trio[\s\-]*.*)\s+build/i // MachSpeed Tablets
- ], [MODEL, [VENDOR, 'MachSpeed'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s*(Trinity)[\-\s]*(T\d{3})\s+build/i // Trinity Tablets
- ], [VENDOR, MODEL, [TYPE, TABLET]], [
-
- /android.+[;\/]\s*TU_(1491)\s+build/i // Rotor Tablets
- ], [MODEL, [VENDOR, 'Rotor'], [TYPE, TABLET]], [
-
- /android.+(KS(.+))\s+build/i // Amazon Kindle Tablets
- ], [MODEL, [VENDOR, 'Amazon'], [TYPE, TABLET]], [
-
- /android.+(Gigaset)[\s\-]+(Q\w{1,9})\s+build/i // Gigaset Tablets
- ], [VENDOR, MODEL, [TYPE, TABLET]], [
-
- /\s(tablet|tab)[;\/]/i, // Unidentifiable Tablet
- /\s(mobile)(?:[;\/]|\ssafari)/i // Unidentifiable Mobile
- ], [[TYPE, util.lowerize], VENDOR, MODEL], [
-
- /(android[\w\.\s\-]{0,9});.+build/i // Generic Android Device
- ], [MODEL, [VENDOR, 'Generic']]
-
-
- /*//////////////////////////
- // TODO: move to string map
- ////////////////////////////
-
- /(C6603)/i // Sony Xperia Z C6603
- ], [[MODEL, 'Xperia Z C6603'], [VENDOR, 'Sony'], [TYPE, MOBILE]], [
- /(C6903)/i // Sony Xperia Z 1
- ], [[MODEL, 'Xperia Z 1'], [VENDOR, 'Sony'], [TYPE, MOBILE]], [
-
- /(SM-G900[F|H])/i // Samsung Galaxy S5
- ], [[MODEL, 'Galaxy S5'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [
- /(SM-G7102)/i // Samsung Galaxy Grand 2
- ], [[MODEL, 'Galaxy Grand 2'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [
- /(SM-G530H)/i // Samsung Galaxy Grand Prime
- ], [[MODEL, 'Galaxy Grand Prime'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [
- /(SM-G313HZ)/i // Samsung Galaxy V
- ], [[MODEL, 'Galaxy V'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [
- /(SM-T805)/i // Samsung Galaxy Tab S 10.5
- ], [[MODEL, 'Galaxy Tab S 10.5'], [VENDOR, 'Samsung'], [TYPE, TABLET]], [
- /(SM-G800F)/i // Samsung Galaxy S5 Mini
- ], [[MODEL, 'Galaxy S5 Mini'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [
- /(SM-T311)/i // Samsung Galaxy Tab 3 8.0
- ], [[MODEL, 'Galaxy Tab 3 8.0'], [VENDOR, 'Samsung'], [TYPE, TABLET]], [
-
- /(T3C)/i // Advan Vandroid T3C
- ], [MODEL, [VENDOR, 'Advan'], [TYPE, TABLET]], [
- /(ADVAN T1J\+)/i // Advan Vandroid T1J+
- ], [[MODEL, 'Vandroid T1J+'], [VENDOR, 'Advan'], [TYPE, TABLET]], [
- /(ADVAN S4A)/i // Advan Vandroid S4A
- ], [[MODEL, 'Vandroid S4A'], [VENDOR, 'Advan'], [TYPE, MOBILE]], [
-
- /(V972M)/i // ZTE V972M
- ], [MODEL, [VENDOR, 'ZTE'], [TYPE, MOBILE]], [
-
- /(i-mobile)\s(IQ\s[\d\.]+)/i // i-mobile IQ
- ], [VENDOR, MODEL, [TYPE, MOBILE]], [
- /(IQ6.3)/i // i-mobile IQ IQ 6.3
- ], [[MODEL, 'IQ 6.3'], [VENDOR, 'i-mobile'], [TYPE, MOBILE]], [
- /(i-mobile)\s(i-style\s[\d\.]+)/i // i-mobile i-STYLE
- ], [VENDOR, MODEL, [TYPE, MOBILE]], [
- /(i-STYLE2.1)/i // i-mobile i-STYLE 2.1
- ], [[MODEL, 'i-STYLE 2.1'], [VENDOR, 'i-mobile'], [TYPE, MOBILE]], [
-
- /(mobiistar touch LAI 512)/i // mobiistar touch LAI 512
- ], [[MODEL, 'Touch LAI 512'], [VENDOR, 'mobiistar'], [TYPE, MOBILE]], [
-
- /////////////
- // END TODO
- ///////////*/
-
- ],
-
- engine : [[
-
- /windows.+\sedge\/([\w\.]+)/i // EdgeHTML
- ], [VERSION, [NAME, 'EdgeHTML']], [
-
- /(presto)\/([\w\.]+)/i, // Presto
- /(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m
- /(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links
- /(icab)[\/\s]([23]\.[\d\.]+)/i // iCab
- ], [NAME, VERSION], [
-
- /rv\:([\w\.]{1,9}).+(gecko)/i // Gecko
- ], [VERSION, NAME]
- ],
-
- os : [[
-
- // Windows based
- /microsoft\s(windows)\s(vista|xp)/i // Windows (iTunes)
- ], [NAME, VERSION], [
- /(windows)\snt\s6\.2;\s(arm)/i, // Windows RT
- /(windows\sphone(?:\sos)*)[\s\/]?([\d\.\s\w]*)/i, // Windows Phone
- /(windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i
- ], [NAME, [VERSION, mapper.str, maps.os.windows.version]], [
- /(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i
- ], [[NAME, 'Windows'], [VERSION, mapper.str, maps.os.windows.version]], [
-
- // Mobile/Embedded OS
- /\((bb)(10);/i // BlackBerry 10
- ], [[NAME, 'BlackBerry'], VERSION], [
- /(blackberry)\w*\/?([\w\.]*)/i, // Blackberry
- /(tizen)[\/\s]([\w\.]+)/i, // Tizen
- /(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]*)/i,
- // Android/WebOS/Palm/QNX/Bada/RIM/MeeGo/Contiki
- /linux;.+(sailfish);/i // Sailfish OS
- ], [NAME, VERSION], [
- /(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]*)/i // Symbian
- ], [[NAME, 'Symbian'], VERSION], [
- /\((series40);/i // Series 40
- ], [NAME], [
- /mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS
- ], [[NAME, 'Firefox OS'], VERSION], [
-
- // Console
- /(nintendo|playstation)\s([wids34portablevu]+)/i, // Nintendo/Playstation
-
- // GNU/Linux based
- /(mint)[\/\s\(]?(\w*)/i, // Mint
- /(mageia|vectorlinux)[;\s]/i, // Mageia/VectorLinux
- /(joli|[kxln]?ubuntu|debian|suse|opensuse|gentoo|(?=\s)arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?(?!chrom)([\w\.-]*)/i,
- // Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware
- // Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus
- /(hurd|linux)\s?([\w\.]*)/i, // Hurd/Linux
- /(gnu)\s?([\w\.]*)/i // GNU
- ], [NAME, VERSION], [
-
- /(cros)\s[\w]+\s([\w\.]+\w)/i // Chromium OS
- ], [[NAME, 'Chromium OS'], VERSION],[
-
- // Solaris
- /(sunos)\s?([\w\.\d]*)/i // Solaris
- ], [[NAME, 'Solaris'], VERSION], [
-
- // BSD based
- /\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]*)/i // FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly
- ], [NAME, VERSION],[
-
- /(haiku)\s(\w+)/i // Haiku
- ], [NAME, VERSION],[
-
- /cfnetwork\/.+darwin/i,
- /ip[honead]{2,4}(?:.*os\s([\w]+)\slike\smac|;\sopera)/i // iOS
- ], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
-
- /(mac\sos\sx)\s?([\w\s\.]*)/i,
- /(macintosh|mac(?=_powerpc)\s)/i // Mac OS
- ], [[NAME, 'Mac OS'], [VERSION, /_/g, '.']], [
-
- // Other
- /((?:open)?solaris)[\/\s-]?([\w\.]*)/i, // Solaris
- /(aix)\s((\d)(?=\.|\)|\s)[\w\.])*/i, // AIX
- /(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms|fuchsia)/i,
- // Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS/OpenVMS/Fuchsia
- /(unix)\s?([\w\.]*)/i // UNIX
- ], [NAME, VERSION]
- ]
- };
-
-
- /////////////////
- // Constructor
- ////////////////
- /*
- var Browser = function (name, version) {
- this[NAME] = name;
- this[VERSION] = version;
- };
- var CPU = function (arch) {
- this[ARCHITECTURE] = arch;
- };
- var Device = function (vendor, model, type) {
- this[VENDOR] = vendor;
- this[MODEL] = model;
- this[TYPE] = type;
- };
- var Engine = Browser;
- var OS = Browser;
- */
- var UAParser = function (uastring, extensions) {
-
- if (typeof uastring === 'object') {
- extensions = uastring;
- uastring = undefined;
- }
-
- if (!(this instanceof UAParser)) {
- return new UAParser(uastring, extensions).getResult();
- }
-
- var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
- var rgxmap = extensions ? util.extend(regexes, extensions) : regexes;
- //var browser = new Browser();
- //var cpu = new CPU();
- //var device = new Device();
- //var engine = new Engine();
- //var os = new OS();
-
- this.getBrowser = function () {
- var browser = { name: undefined, version: undefined };
- mapper.rgx.call(browser, ua, rgxmap.browser);
- browser.major = util.major(browser.version); // deprecated
- return browser;
- };
- this.getCPU = function () {
- var cpu = { architecture: undefined };
- mapper.rgx.call(cpu, ua, rgxmap.cpu);
- return cpu;
- };
- this.getDevice = function () {
- var device = { vendor: undefined, model: undefined, type: undefined };
- mapper.rgx.call(device, ua, rgxmap.device);
- return device;
- };
- this.getEngine = function () {
- var engine = { name: undefined, version: undefined };
- mapper.rgx.call(engine, ua, rgxmap.engine);
- return engine;
- };
- this.getOS = function () {
- var os = { name: undefined, version: undefined };
- mapper.rgx.call(os, ua, rgxmap.os);
- return os;
- };
- this.getResult = function () {
- return {
- ua : this.getUA(),
- browser : this.getBrowser(),
- engine : this.getEngine(),
- os : this.getOS(),
- device : this.getDevice(),
- cpu : this.getCPU()
- };
- };
- this.getUA = function () {
- return ua;
- };
- this.setUA = function (uastring) {
- ua = uastring;
- //browser = new Browser();
- //cpu = new CPU();
- //device = new Device();
- //engine = new Engine();
- //os = new OS();
- return this;
- };
- return this;
- };
-
- UAParser.VERSION = LIBVERSION;
- UAParser.BROWSER = {
- NAME : NAME,
- MAJOR : MAJOR, // deprecated
- VERSION : VERSION
- };
- UAParser.CPU = {
- ARCHITECTURE : ARCHITECTURE
- };
- UAParser.DEVICE = {
- MODEL : MODEL,
- VENDOR : VENDOR,
- TYPE : TYPE,
- CONSOLE : CONSOLE,
- MOBILE : MOBILE,
- SMARTTV : SMARTTV,
- TABLET : TABLET,
- WEARABLE: WEARABLE,
- EMBEDDED: EMBEDDED
- };
- UAParser.ENGINE = {
- NAME : NAME,
- VERSION : VERSION
- };
- UAParser.OS = {
- NAME : NAME,
- VERSION : VERSION
- };
- //UAParser.Utils = util;
-
- ///////////
- // Export
- //////////
-
-
- // check js environment
- if (typeof(exports) !== UNDEF_TYPE) {
- // nodejs env
- if (typeof module !== UNDEF_TYPE && module.exports) {
- exports = module.exports = UAParser;
- }
- // TODO: test!!!!!!!!
- /*
- if (require && require.main === module && process) {
- // cli
- var jsonize = function (arr) {
- var res = [];
- for (var i in arr) {
- res.push(new UAParser(arr[i]).getResult());
- }
- process.stdout.write(JSON.stringify(res, null, 2) + '\n');
- };
- if (process.stdin.isTTY) {
- // via args
- jsonize(process.argv.slice(2));
- } else {
- // via pipe
- var str = '';
- process.stdin.on('readable', function() {
- var read = process.stdin.read();
- if (read !== null) {
- str += read;
- }
- });
- process.stdin.on('end', function () {
- jsonize(str.replace(/\n$/, '').split('\n'));
- });
- }
- }
- */
- exports.UAParser = UAParser;
- } else {
- // requirejs env (optional)
- if ("function" === FUNC_TYPE && __webpack_require__(100)) {
- !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
- return UAParser;
- }).call(exports, __webpack_require__, exports, module),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- } else if (window) {
- // browser env
- window.UAParser = UAParser;
- }
- }
-
- // jQuery/Zepto specific (optional)
- // Note:
- // In AMD env the global scope should be kept clean, but jQuery is an exception.
- // jQuery always exports to global scope, unless jQuery.noConflict(true) is used,
- // and we should catch that.
- var $ = window && (window.jQuery || window.Zepto);
- if (typeof $ !== UNDEF_TYPE && !$.ua) {
- var parser = new UAParser();
- $.ua = parser.getResult();
- $.ua.get = function () {
- return parser.getUA();
- };
- $.ua.set = function (uastring) {
- parser.setUA(uastring);
- var result = parser.getResult();
- for (var prop in result) {
- $.ua[prop] = result[prop];
- }
- };
- }
-
- })(typeof window === 'object' ? window : this);
-
-
- /***/ }),
- /* 100 */
- /***/ (function(module, exports) {
-
- /* WEBPACK VAR INJECTION */(function(__webpack_amd_options__) {/* globals __webpack_amd_options__ */
- module.exports = __webpack_amd_options__;
-
- /* WEBPACK VAR INJECTION */}.call(exports, {}))
-
- /***/ }),
- /* 101 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
-
-
- var invariant = __webpack_require__(1);
-
- var componentRegex = /\./;
- var orRegex = /\|\|/;
- var rangeRegex = /\s+\-\s+/;
- var modifierRegex = /^(<=|<|=|>=|~>|~|>|)?\s*(.+)/;
- var numericRegex = /^(\d*)(.*)/;
- /**
- * Splits input `range` on "||" and returns true if any subrange matches
- * `version`.
- *
- * @param {string} range
- * @param {string} version
- * @returns {boolean}
- */
-
- function checkOrExpression(range, version) {
- var expressions = range.split(orRegex);
-
- if (expressions.length > 1) {
- return expressions.some(function (range) {
- return VersionRange.contains(range, version);
- });
- } else {
- range = expressions[0].trim();
- return checkRangeExpression(range, version);
- }
- }
- /**
- * Splits input `range` on " - " (the surrounding whitespace is required) and
- * returns true if version falls between the two operands.
- *
- * @param {string} range
- * @param {string} version
- * @returns {boolean}
- */
-
-
- function checkRangeExpression(range, version) {
- var expressions = range.split(rangeRegex);
- !(expressions.length > 0 && expressions.length <= 2) ? true ? invariant(false, 'the "-" operator expects exactly 2 operands') : invariant(false) : void 0;
-
- if (expressions.length === 1) {
- return checkSimpleExpression(expressions[0], version);
- } else {
- var startVersion = expressions[0],
- endVersion = expressions[1];
- !(isSimpleVersion(startVersion) && isSimpleVersion(endVersion)) ? true ? invariant(false, 'operands to the "-" operator must be simple (no modifiers)') : invariant(false) : void 0;
- return checkSimpleExpression('>=' + startVersion, version) && checkSimpleExpression('<=' + endVersion, version);
- }
- }
- /**
- * Checks if `range` matches `version`. `range` should be a "simple" range (ie.
- * not a compound range using the " - " or "||" operators).
- *
- * @param {string} range
- * @param {string} version
- * @returns {boolean}
- */
-
-
- function checkSimpleExpression(range, version) {
- range = range.trim();
-
- if (range === '') {
- return true;
- }
-
- var versionComponents = version.split(componentRegex);
-
- var _getModifierAndCompon = getModifierAndComponents(range),
- modifier = _getModifierAndCompon.modifier,
- rangeComponents = _getModifierAndCompon.rangeComponents;
-
- switch (modifier) {
- case '<':
- return checkLessThan(versionComponents, rangeComponents);
-
- case '<=':
- return checkLessThanOrEqual(versionComponents, rangeComponents);
-
- case '>=':
- return checkGreaterThanOrEqual(versionComponents, rangeComponents);
-
- case '>':
- return checkGreaterThan(versionComponents, rangeComponents);
-
- case '~':
- case '~>':
- return checkApproximateVersion(versionComponents, rangeComponents);
-
- default:
- return checkEqual(versionComponents, rangeComponents);
- }
- }
- /**
- * Checks whether `a` is less than `b`.
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {boolean}
- */
-
-
- function checkLessThan(a, b) {
- return compareComponents(a, b) === -1;
- }
- /**
- * Checks whether `a` is less than or equal to `b`.
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {boolean}
- */
-
-
- function checkLessThanOrEqual(a, b) {
- var result = compareComponents(a, b);
- return result === -1 || result === 0;
- }
- /**
- * Checks whether `a` is equal to `b`.
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {boolean}
- */
-
-
- function checkEqual(a, b) {
- return compareComponents(a, b) === 0;
- }
- /**
- * Checks whether `a` is greater than or equal to `b`.
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {boolean}
- */
-
-
- function checkGreaterThanOrEqual(a, b) {
- var result = compareComponents(a, b);
- return result === 1 || result === 0;
- }
- /**
- * Checks whether `a` is greater than `b`.
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {boolean}
- */
-
-
- function checkGreaterThan(a, b) {
- return compareComponents(a, b) === 1;
- }
- /**
- * Checks whether `a` is "reasonably close" to `b` (as described in
- * https://www.npmjs.org/doc/misc/semver.html). For example, if `b` is "1.3.1"
- * then "reasonably close" is defined as ">= 1.3.1 and < 1.4".
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {boolean}
- */
-
-
- function checkApproximateVersion(a, b) {
- var lowerBound = b.slice();
- var upperBound = b.slice();
-
- if (upperBound.length > 1) {
- upperBound.pop();
- }
-
- var lastIndex = upperBound.length - 1;
- var numeric = parseInt(upperBound[lastIndex], 10);
-
- if (isNumber(numeric)) {
- upperBound[lastIndex] = numeric + 1 + '';
- }
-
- return checkGreaterThanOrEqual(a, lowerBound) && checkLessThan(a, upperBound);
- }
- /**
- * Extracts the optional modifier (<, <=, =, >=, >, ~, ~>) and version
- * components from `range`.
- *
- * For example, given `range` ">= 1.2.3" returns an object with a `modifier` of
- * `">="` and `components` of `[1, 2, 3]`.
- *
- * @param {string} range
- * @returns {object}
- */
-
-
- function getModifierAndComponents(range) {
- var rangeComponents = range.split(componentRegex);
- var matches = rangeComponents[0].match(modifierRegex);
- !matches ? true ? invariant(false, 'expected regex to match but it did not') : invariant(false) : void 0;
- return {
- modifier: matches[1],
- rangeComponents: [matches[2]].concat(rangeComponents.slice(1))
- };
- }
- /**
- * Determines if `number` is a number.
- *
- * @param {mixed} number
- * @returns {boolean}
- */
-
-
- function isNumber(number) {
- return !isNaN(number) && isFinite(number);
- }
- /**
- * Tests whether `range` is a "simple" version number without any modifiers
- * (">", "~" etc).
- *
- * @param {string} range
- * @returns {boolean}
- */
-
-
- function isSimpleVersion(range) {
- return !getModifierAndComponents(range).modifier;
- }
- /**
- * Zero-pads array `array` until it is at least `length` long.
- *
- * @param {array} array
- * @param {number} length
- */
-
-
- function zeroPad(array, length) {
- for (var i = array.length; i < length; i++) {
- array[i] = '0';
- }
- }
- /**
- * Normalizes `a` and `b` in preparation for comparison by doing the following:
- *
- * - zero-pads `a` and `b`
- * - marks any "x", "X" or "*" component in `b` as equivalent by zero-ing it out
- * in both `a` and `b`
- * - marks any final "*" component in `b` as a greedy wildcard by zero-ing it
- * and all of its successors in `a`
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {array<array<string>>}
- */
-
-
- function normalizeVersions(a, b) {
- a = a.slice();
- b = b.slice();
- zeroPad(a, b.length); // mark "x" and "*" components as equal
-
- for (var i = 0; i < b.length; i++) {
- var matches = b[i].match(/^[x*]$/i);
-
- if (matches) {
- b[i] = a[i] = '0'; // final "*" greedily zeros all remaining components
-
- if (matches[0] === '*' && i === b.length - 1) {
- for (var j = i; j < a.length; j++) {
- a[j] = '0';
- }
- }
- }
- }
-
- zeroPad(b, a.length);
- return [a, b];
- }
- /**
- * Returns the numerical -- not the lexicographical -- ordering of `a` and `b`.
- *
- * For example, `10-alpha` is greater than `2-beta`.
- *
- * @param {string} a
- * @param {string} b
- * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to,
- * or greater than `b`, respectively
- */
-
-
- function compareNumeric(a, b) {
- var aPrefix = a.match(numericRegex)[1];
- var bPrefix = b.match(numericRegex)[1];
- var aNumeric = parseInt(aPrefix, 10);
- var bNumeric = parseInt(bPrefix, 10);
-
- if (isNumber(aNumeric) && isNumber(bNumeric) && aNumeric !== bNumeric) {
- return compare(aNumeric, bNumeric);
- } else {
- return compare(a, b);
- }
- }
- /**
- * Returns the ordering of `a` and `b`.
- *
- * @param {string|number} a
- * @param {string|number} b
- * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to,
- * or greater than `b`, respectively
- */
-
-
- function compare(a, b) {
- !(typeof a === typeof b) ? true ? invariant(false, '"a" and "b" must be of the same type') : invariant(false) : void 0;
-
- if (a > b) {
- return 1;
- } else if (a < b) {
- return -1;
- } else {
- return 0;
- }
- }
- /**
- * Compares arrays of version components.
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to,
- * or greater than `b`, respectively
- */
-
-
- function compareComponents(a, b) {
- var _normalizeVersions = normalizeVersions(a, b),
- aNormalized = _normalizeVersions[0],
- bNormalized = _normalizeVersions[1];
-
- for (var i = 0; i < bNormalized.length; i++) {
- var result = compareNumeric(aNormalized[i], bNormalized[i]);
-
- if (result) {
- return result;
- }
- }
-
- return 0;
- }
-
- var VersionRange = {
- /**
- * Checks whether `version` satisfies the `range` specification.
- *
- * We support a subset of the expressions defined in
- * https://www.npmjs.org/doc/misc/semver.html:
- *
- * version Must match version exactly
- * =version Same as just version
- * >version Must be greater than version
- * >=version Must be greater than or equal to version
- * <version Must be less than version
- * <=version Must be less than or equal to version
- * ~version Must be at least version, but less than the next significant
- * revision above version:
- * "~1.2.3" is equivalent to ">= 1.2.3 and < 1.3"
- * ~>version Equivalent to ~version
- * 1.2.x Must match "1.2.x", where "x" is a wildcard that matches
- * anything
- * 1.2.* Similar to "1.2.x", but "*" in the trailing position is a
- * "greedy" wildcard, so will match any number of additional
- * components:
- * "1.2.*" will match "1.2.1", "1.2.1.1", "1.2.1.1.1" etc
- * * Any version
- * "" (Empty string) Same as *
- * v1 - v2 Equivalent to ">= v1 and <= v2"
- * r1 || r2 Passes if either r1 or r2 are satisfied
- *
- * @param {string} range
- * @param {string} version
- * @returns {boolean}
- */
- contains: function contains(range, version) {
- return checkOrExpression(range.trim(), version.trim());
- }
- };
- module.exports = VersionRange;
-
- /***/ }),
- /* 102 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
-
-
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- /**
- * Executes the provided `callback` once for each enumerable own property in the
- * object and constructs a new object from the results. The `callback` is
- * invoked with three arguments:
- *
- * - the property value
- * - the property name
- * - the object being traversed
- *
- * Properties that are added after the call to `mapObject` will not be visited
- * by `callback`. If the values of existing properties are changed, the value
- * passed to `callback` will be the value at the time `mapObject` visits them.
- * Properties that are deleted before being visited are not visited.
- *
- * @grep function objectMap()
- * @grep function objMap()
- *
- * @param {?object} object
- * @param {function} callback
- * @param {*} context
- * @return {?object}
- */
-
- function mapObject(object, callback, context) {
- if (!object) {
- return null;
- }
-
- var result = {};
-
- for (var name in object) {
- if (hasOwnProperty.call(object, name)) {
- result[name] = callback.call(context, object[name], name, object);
- }
- }
-
- return result;
- }
-
- module.exports = mapObject;
-
- /***/ }),
- /* 103 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- * @typechecks static-only
- */
-
- /**
- * Memoizes the return value of a function that accepts one string argument.
- */
-
- function memoizeStringOnly(callback) {
- var cache = {};
- return function (string) {
- if (!cache.hasOwnProperty(string)) {
- cache[string] = callback.call(this, string);
- }
-
- return cache[string];
- };
- }
-
- module.exports = memoizeStringOnly;
-
- /***/ }),
- /* 104 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- */
-
-
- var gkx = __webpack_require__(11);
-
- var experimentalTreeDataSupport = gkx('draft_tree_data_support');
- module.exports = experimentalTreeDataSupport ? __webpack_require__(105) : __webpack_require__(119);
-
- /***/ }),
- /* 105 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- *
- * This file is a fork of DraftEditorContents.react.js for tree nodes
- *
- * This is unstable and not part of the public API and should not be used by
- * production systems. This file may be update/removed without notice.
- */
-
-
- var _assign = __webpack_require__(14);
-
- function _extends() { _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- var DraftEditorBlockNode = __webpack_require__(106);
-
- var DraftOffsetKey = __webpack_require__(10);
-
- var React = __webpack_require__(8);
-
- var nullthrows = __webpack_require__(4);
-
- /**
- * `DraftEditorContents` is the container component for all block components
- * rendered for a `DraftEditor`. It is optimized to aggressively avoid
- * re-rendering blocks whenever possible.
- *
- * This component is separate from `DraftEditor` because certain props
- * (for instance, ARIA props) must be allowed to update without affecting
- * the contents of the editor.
- */
- var DraftEditorContentsExperimental =
- /*#__PURE__*/
- function (_React$Component) {
- _inheritsLoose(DraftEditorContentsExperimental, _React$Component);
-
- function DraftEditorContentsExperimental() {
- return _React$Component.apply(this, arguments) || this;
- }
-
- var _proto = DraftEditorContentsExperimental.prototype;
-
- _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
- var prevEditorState = this.props.editorState;
- var nextEditorState = nextProps.editorState;
- var prevDirectionMap = prevEditorState.getDirectionMap();
- var nextDirectionMap = nextEditorState.getDirectionMap(); // Text direction has changed for one or more blocks. We must re-render.
-
- if (prevDirectionMap !== nextDirectionMap) {
- return true;
- }
-
- var didHaveFocus = prevEditorState.getSelection().getHasFocus();
- var nowHasFocus = nextEditorState.getSelection().getHasFocus();
-
- if (didHaveFocus !== nowHasFocus) {
- return true;
- }
-
- var nextNativeContent = nextEditorState.getNativelyRenderedContent();
- var wasComposing = prevEditorState.isInCompositionMode();
- var nowComposing = nextEditorState.isInCompositionMode(); // If the state is unchanged or we're currently rendering a natively
- // rendered state, there's nothing new to be done.
-
- if (prevEditorState === nextEditorState || nextNativeContent !== null && nextEditorState.getCurrentContent() === nextNativeContent || wasComposing && nowComposing) {
- return false;
- }
-
- var prevContent = prevEditorState.getCurrentContent();
- var nextContent = nextEditorState.getCurrentContent();
- var prevDecorator = prevEditorState.getDecorator();
- var nextDecorator = nextEditorState.getDecorator();
- return wasComposing !== nowComposing || prevContent !== nextContent || prevDecorator !== nextDecorator || nextEditorState.mustForceSelection();
- };
-
- _proto.render = function render() {
- var _this$props = this.props,
- blockRenderMap = _this$props.blockRenderMap,
- blockRendererFn = _this$props.blockRendererFn,
- blockStyleFn = _this$props.blockStyleFn,
- customStyleMap = _this$props.customStyleMap,
- customStyleFn = _this$props.customStyleFn,
- editorState = _this$props.editorState,
- editorKey = _this$props.editorKey,
- textDirectionality = _this$props.textDirectionality;
- var content = editorState.getCurrentContent();
- var selection = editorState.getSelection();
- var forceSelection = editorState.mustForceSelection();
- var decorator = editorState.getDecorator();
- var directionMap = nullthrows(editorState.getDirectionMap());
- var blocksAsArray = content.getBlocksAsArray();
- var rootBlock = blocksAsArray[0];
- var processedBlocks = [];
- var nodeBlock = rootBlock;
-
- while (nodeBlock) {
- var blockKey = nodeBlock.getKey();
- var blockProps = {
- blockRenderMap: blockRenderMap,
- blockRendererFn: blockRendererFn,
- blockStyleFn: blockStyleFn,
- contentState: content,
- customStyleFn: customStyleFn,
- customStyleMap: customStyleMap,
- decorator: decorator,
- editorKey: editorKey,
- editorState: editorState,
- forceSelection: forceSelection,
- selection: selection,
- block: nodeBlock,
- direction: textDirectionality ? textDirectionality : directionMap.get(blockKey),
- tree: editorState.getBlockTree(blockKey)
- };
- var configForType = blockRenderMap.get(nodeBlock.getType()) || blockRenderMap.get('unstyled');
- var wrapperTemplate = configForType.wrapper;
- processedBlocks.push({
- /* $FlowFixMe(>=0.112.0 site=www,mobile) This comment suppresses an
- * error found when Flow v0.112 was deployed. To see the error delete
- * this comment and run Flow. */
- block: React.createElement(DraftEditorBlockNode, _extends({
- key: blockKey
- }, blockProps)),
- wrapperTemplate: wrapperTemplate,
- key: blockKey,
- offsetKey: DraftOffsetKey.encode(blockKey, 0, 0)
- });
- var nextBlockKey = nodeBlock.getNextSiblingKey();
- nodeBlock = nextBlockKey ? content.getBlockForKey(nextBlockKey) : null;
- } // Group contiguous runs of blocks that have the same wrapperTemplate
-
-
- var outputBlocks = [];
-
- for (var ii = 0; ii < processedBlocks.length;) {
- var info = processedBlocks[ii];
-
- if (info.wrapperTemplate) {
- var blocks = [];
-
- do {
- blocks.push(processedBlocks[ii].block);
- ii++;
- } while (ii < processedBlocks.length && processedBlocks[ii].wrapperTemplate === info.wrapperTemplate);
-
- var wrapperElement = React.cloneElement(info.wrapperTemplate, {
- key: info.key + '-wrap',
- 'data-offset-key': info.offsetKey
- }, blocks);
- outputBlocks.push(wrapperElement);
- } else {
- outputBlocks.push(info.block);
- ii++;
- }
- }
-
- return React.createElement("div", {
- "data-contents": "true"
- }, outputBlocks);
- };
-
- return DraftEditorContentsExperimental;
- }(React.Component);
-
- module.exports = DraftEditorContentsExperimental;
-
- /***/ }),
- /* 106 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- *
- * This file is a fork of DraftEditorBlock.react.js and DraftEditorContents.react.js
- *
- * This is unstable and not part of the public API and should not be used by
- * production systems. This file may be update/removed without notice.
- */
-
-
- var _assign = __webpack_require__(14);
-
- function _extends() { _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
-
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- var DraftEditorNode = __webpack_require__(107);
-
- var DraftOffsetKey = __webpack_require__(10);
-
- var React = __webpack_require__(8);
-
- var Scroll = __webpack_require__(37);
-
- var Style = __webpack_require__(29);
-
- var getElementPosition = __webpack_require__(62);
-
- var getScrollPosition = __webpack_require__(30);
-
- var getViewportDimensions = __webpack_require__(63);
-
- var Immutable = __webpack_require__(0);
-
- var invariant = __webpack_require__(1);
-
- var isHTMLElement = __webpack_require__(19);
-
- var SCROLL_BUFFER = 10;
- var List = Immutable.List; // we should harden up the bellow flow types to make them more strict
-
- /**
- * Return whether a block overlaps with either edge of the `SelectionState`.
- */
- var isBlockOnSelectionEdge = function isBlockOnSelectionEdge(selection, key) {
- return selection.getAnchorKey() === key || selection.getFocusKey() === key;
- };
- /**
- * We will use this helper to identify blocks that need to be wrapped but have siblings that
- * also share the same wrapper element, this way we can do the wrapping once the last sibling
- * is added.
- */
-
-
- var shouldNotAddWrapperElement = function shouldNotAddWrapperElement(block, contentState) {
- var nextSiblingKey = block.getNextSiblingKey();
- return nextSiblingKey ? contentState.getBlockForKey(nextSiblingKey).getType() === block.getType() : false;
- };
-
- var applyWrapperElementToSiblings = function applyWrapperElementToSiblings(wrapperTemplate, Element, nodes) {
- var wrappedSiblings = []; // we check back until we find a sibbling that does not have same wrapper
-
- var _iteratorNormalCompletion = true;
- var _didIteratorError = false;
- var _iteratorError = undefined;
-
- try {
- for (var _iterator = nodes.reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
- var sibling = _step.value;
-
- if (sibling.type !== Element) {
- break;
- }
-
- wrappedSiblings.push(sibling);
- } // we now should remove from acc the wrappedSiblings and add them back under same wrap
-
- } catch (err) {
- _didIteratorError = true;
- _iteratorError = err;
- } finally {
- try {
- if (!_iteratorNormalCompletion && _iterator["return"] != null) {
- _iterator["return"]();
- }
- } finally {
- if (_didIteratorError) {
- throw _iteratorError;
- }
- }
- }
-
- nodes.splice(nodes.indexOf(wrappedSiblings[0]), wrappedSiblings.length + 1);
- var childrenIs = wrappedSiblings.reverse();
- var key = childrenIs[0].key;
- nodes.push(React.cloneElement(wrapperTemplate, {
- key: "".concat(key, "-wrap"),
- 'data-offset-key': DraftOffsetKey.encode(key, 0, 0)
- }, childrenIs));
- return nodes;
- };
-
- var getDraftRenderConfig = function getDraftRenderConfig(block, blockRenderMap) {
- var configForType = blockRenderMap.get(block.getType()) || blockRenderMap.get('unstyled');
- var wrapperTemplate = configForType.wrapper;
- var Element = configForType.element || blockRenderMap.get('unstyled').element;
- return {
- Element: Element,
- wrapperTemplate: wrapperTemplate
- };
- };
-
- var getCustomRenderConfig = function getCustomRenderConfig(block, blockRendererFn) {
- var customRenderer = blockRendererFn(block);
-
- if (!customRenderer) {
- return {};
- }
-
- var CustomComponent = customRenderer.component,
- customProps = customRenderer.props,
- customEditable = customRenderer.editable;
- return {
- CustomComponent: CustomComponent,
- customProps: customProps,
- customEditable: customEditable
- };
- };
-
- var getElementPropsConfig = function getElementPropsConfig(block, editorKey, offsetKey, blockStyleFn, customConfig, ref) {
- var elementProps = {
- 'data-block': true,
- 'data-editor': editorKey,
- 'data-offset-key': offsetKey,
- key: block.getKey(),
- ref: ref
- };
- var customClass = blockStyleFn(block);
-
- if (customClass) {
- elementProps.className = customClass;
- }
-
- if (customConfig.customEditable !== undefined) {
- elementProps = _objectSpread({}, elementProps, {
- contentEditable: customConfig.customEditable,
- suppressContentEditableWarning: true
- });
- }
-
- return elementProps;
- };
-
- var DraftEditorBlockNode =
- /*#__PURE__*/
- function (_React$Component) {
- _inheritsLoose(DraftEditorBlockNode, _React$Component);
-
- function DraftEditorBlockNode() {
- var _this;
-
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
-
- _defineProperty(_assertThisInitialized(_this), "wrapperRef", React.createRef());
-
- return _this;
- }
-
- var _proto = DraftEditorBlockNode.prototype;
-
- _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
- var _this$props = this.props,
- block = _this$props.block,
- direction = _this$props.direction,
- tree = _this$props.tree;
- var isContainerNode = !block.getChildKeys().isEmpty();
- var blockHasChanged = block !== nextProps.block || tree !== nextProps.tree || direction !== nextProps.direction || isBlockOnSelectionEdge(nextProps.selection, nextProps.block.getKey()) && nextProps.forceSelection; // if we have children at this stage we always re-render container nodes
- // else if its a root node we avoid re-rendering by checking for block updates
-
- return isContainerNode || blockHasChanged;
- }
- /**
- * When a block is mounted and overlaps the selection state, we need to make
- * sure that the cursor is visible to match native behavior. This may not
- * be the case if the user has pressed `RETURN` or pasted some content, since
- * programatically creating these new blocks and setting the DOM selection
- * will miss out on the browser natively scrolling to that position.
- *
- * To replicate native behavior, if the block overlaps the selection state
- * on mount, force the scroll position. Check the scroll state of the scroll
- * parent, and adjust it to align the entire block to the bottom of the
- * scroll parent.
- */
- ;
-
- _proto.componentDidMount = function componentDidMount() {
- var selection = this.props.selection;
- var endKey = selection.getEndKey();
-
- if (!selection.getHasFocus() || endKey !== this.props.block.getKey()) {
- return;
- }
-
- var blockNode = this.wrapperRef.current;
-
- if (!blockNode) {
- // This Block Node was rendered without a wrapper element.
- return;
- }
-
- var scrollParent = Style.getScrollParent(blockNode);
- var scrollPosition = getScrollPosition(scrollParent);
- var scrollDelta;
-
- if (scrollParent === window) {
- var nodePosition = getElementPosition(blockNode);
- var nodeBottom = nodePosition.y + nodePosition.height;
- var viewportHeight = getViewportDimensions().height;
- scrollDelta = nodeBottom - viewportHeight;
-
- if (scrollDelta > 0) {
- window.scrollTo(scrollPosition.x, scrollPosition.y + scrollDelta + SCROLL_BUFFER);
- }
- } else {
- !isHTMLElement(blockNode) ? true ? invariant(false, 'blockNode is not an HTMLElement') : invariant(false) : void 0;
- var htmlBlockNode = blockNode;
- var blockBottom = htmlBlockNode.offsetHeight + htmlBlockNode.offsetTop;
- var scrollBottom = scrollParent.offsetHeight + scrollPosition.y;
- scrollDelta = blockBottom - scrollBottom;
-
- if (scrollDelta > 0) {
- Scroll.setTop(scrollParent, Scroll.getTop(scrollParent) + scrollDelta + SCROLL_BUFFER);
- }
- }
- };
-
- _proto.render = function render() {
- var _this2 = this;
-
- var _this$props2 = this.props,
- block = _this$props2.block,
- blockRenderMap = _this$props2.blockRenderMap,
- blockRendererFn = _this$props2.blockRendererFn,
- blockStyleFn = _this$props2.blockStyleFn,
- contentState = _this$props2.contentState,
- decorator = _this$props2.decorator,
- editorKey = _this$props2.editorKey,
- editorState = _this$props2.editorState,
- customStyleFn = _this$props2.customStyleFn,
- customStyleMap = _this$props2.customStyleMap,
- direction = _this$props2.direction,
- forceSelection = _this$props2.forceSelection,
- selection = _this$props2.selection,
- tree = _this$props2.tree;
- var children = null;
-
- if (block.children.size) {
- children = block.children.reduce(function (acc, key) {
- var offsetKey = DraftOffsetKey.encode(key, 0, 0);
- var child = contentState.getBlockForKey(key);
- var customConfig = getCustomRenderConfig(child, blockRendererFn);
- var Component = customConfig.CustomComponent || DraftEditorBlockNode;
-
- var _getDraftRenderConfig = getDraftRenderConfig(child, blockRenderMap),
- Element = _getDraftRenderConfig.Element,
- wrapperTemplate = _getDraftRenderConfig.wrapperTemplate;
-
- var elementProps = getElementPropsConfig(child, editorKey, offsetKey, blockStyleFn, customConfig, null);
-
- var childProps = _objectSpread({}, _this2.props, {
- tree: editorState.getBlockTree(key),
- blockProps: customConfig.customProps,
- offsetKey: offsetKey,
- block: child
- });
-
- acc.push(React.createElement(Element, elementProps, React.createElement(Component, childProps)));
-
- if (!wrapperTemplate || shouldNotAddWrapperElement(child, contentState)) {
- return acc;
- } // if we are here it means we are the last block
- // that has a wrapperTemplate so we should wrap itself
- // and all other previous siblings that share the same wrapper
-
-
- applyWrapperElementToSiblings(wrapperTemplate, Element, acc);
- return acc;
- }, []);
- }
-
- var blockKey = block.getKey();
- var offsetKey = DraftOffsetKey.encode(blockKey, 0, 0);
- var customConfig = getCustomRenderConfig(block, blockRendererFn);
- var Component = customConfig.CustomComponent;
- var blockNode = Component != null ? React.createElement(Component, _extends({}, this.props, {
- tree: editorState.getBlockTree(blockKey),
- blockProps: customConfig.customProps,
- offsetKey: offsetKey,
- block: block
- })) : React.createElement(DraftEditorNode, {
- block: block,
- children: children,
- contentState: contentState,
- customStyleFn: customStyleFn,
- customStyleMap: customStyleMap,
- decorator: decorator,
- direction: direction,
- forceSelection: forceSelection,
- hasSelection: isBlockOnSelectionEdge(selection, blockKey),
- selection: selection,
- tree: tree
- });
-
- if (block.getParentKey()) {
- return blockNode;
- }
-
- var _getDraftRenderConfig2 = getDraftRenderConfig(block, blockRenderMap),
- Element = _getDraftRenderConfig2.Element;
-
- var elementProps = getElementPropsConfig(block, editorKey, offsetKey, blockStyleFn, customConfig, this.wrapperRef); // root block nodes needs to be wrapped
-
- return React.createElement(Element, elementProps, blockNode);
- };
-
- return DraftEditorBlockNode;
- }(React.Component);
-
- module.exports = DraftEditorBlockNode;
-
- /***/ }),
- /* 107 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- *
- * This is unstable and not part of the public API and should not be used by
- * production systems. This file may be update/removed without notice.
- */
-
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- var DraftEditorDecoratedLeaves = __webpack_require__(108);
-
- var DraftEditorLeaf = __webpack_require__(58);
-
- var DraftOffsetKey = __webpack_require__(10);
-
- var Immutable = __webpack_require__(0);
-
- var React = __webpack_require__(8);
-
- var cx = __webpack_require__(13);
-
- var List = Immutable.List;
-
- var DraftEditorNode =
- /*#__PURE__*/
- function (_React$Component) {
- _inheritsLoose(DraftEditorNode, _React$Component);
-
- function DraftEditorNode() {
- return _React$Component.apply(this, arguments) || this;
- }
-
- var _proto = DraftEditorNode.prototype;
-
- _proto.render = function render() {
- var _this$props = this.props,
- block = _this$props.block,
- contentState = _this$props.contentState,
- customStyleFn = _this$props.customStyleFn,
- customStyleMap = _this$props.customStyleMap,
- decorator = _this$props.decorator,
- direction = _this$props.direction,
- forceSelection = _this$props.forceSelection,
- hasSelection = _this$props.hasSelection,
- selection = _this$props.selection,
- tree = _this$props.tree;
- var blockKey = block.getKey();
- var text = block.getText();
- var lastLeafSet = tree.size - 1;
- var children = this.props.children || tree.map(function (leafSet, ii) {
- var decoratorKey = leafSet.get('decoratorKey');
- var leavesForLeafSet = leafSet.get('leaves');
- var lastLeaf = leavesForLeafSet.size - 1;
- var Leaves = leavesForLeafSet.map(function (leaf, jj) {
- var offsetKey = DraftOffsetKey.encode(blockKey, ii, jj);
- var start = leaf.get('start');
- var end = leaf.get('end');
- return React.createElement(DraftEditorLeaf, {
- key: offsetKey,
- offsetKey: offsetKey,
- block: block,
- start: start,
- selection: hasSelection ? selection : null,
- forceSelection: forceSelection,
- text: text.slice(start, end),
- styleSet: block.getInlineStyleAt(start),
- customStyleMap: customStyleMap,
- customStyleFn: customStyleFn,
- isLast: decoratorKey === lastLeafSet && jj === lastLeaf
- });
- }).toArray();
-
- if (!decoratorKey || !decorator) {
- return Leaves;
- }
-
- return React.createElement(DraftEditorDecoratedLeaves, {
- block: block,
- children: Leaves,
- contentState: contentState,
- decorator: decorator,
- decoratorKey: decoratorKey,
- direction: direction,
- leafSet: leafSet,
- text: text,
- key: ii
- });
- }).toArray();
- return React.createElement("div", {
- "data-offset-key": DraftOffsetKey.encode(blockKey, 0, 0),
- className: cx({
- 'public/DraftStyleDefault/block': true,
- 'public/DraftStyleDefault/ltr': direction === 'LTR',
- 'public/DraftStyleDefault/rtl': direction === 'RTL'
- })
- }, children);
- };
-
- return DraftEditorNode;
- }(React.Component);
-
- module.exports = DraftEditorNode;
-
- /***/ }),
- /* 108 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- *
- * This is unstable and not part of the public API and should not be used by
- * production systems. This file may be update/removed without notice.
- */
-
-
- var _assign = __webpack_require__(14);
-
- function _extends() { _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- var DraftOffsetKey = __webpack_require__(10);
-
- var React = __webpack_require__(8);
-
- var UnicodeBidi = __webpack_require__(33);
-
- var UnicodeBidiDirection = __webpack_require__(24);
-
- var DraftEditorDecoratedLeaves =
- /*#__PURE__*/
- function (_React$Component) {
- _inheritsLoose(DraftEditorDecoratedLeaves, _React$Component);
-
- function DraftEditorDecoratedLeaves() {
- return _React$Component.apply(this, arguments) || this;
- }
-
- var _proto = DraftEditorDecoratedLeaves.prototype;
-
- _proto.render = function render() {
- var _this$props = this.props,
- block = _this$props.block,
- children = _this$props.children,
- contentState = _this$props.contentState,
- decorator = _this$props.decorator,
- decoratorKey = _this$props.decoratorKey,
- direction = _this$props.direction,
- leafSet = _this$props.leafSet,
- text = _this$props.text;
- var blockKey = block.getKey();
- var leavesForLeafSet = leafSet.get('leaves');
- var DecoratorComponent = decorator.getComponentForKey(decoratorKey);
- var decoratorProps = decorator.getPropsForKey(decoratorKey);
- var decoratorOffsetKey = DraftOffsetKey.encode(blockKey, parseInt(decoratorKey, 10), 0);
- var decoratedText = text.slice(leavesForLeafSet.first().get('start'), leavesForLeafSet.last().get('end')); // Resetting dir to the same value on a child node makes Chrome/Firefox
- // confused on cursor movement. See http://jsfiddle.net/d157kLck/3/
-
- var dir = UnicodeBidiDirection.getHTMLDirIfDifferent(UnicodeBidi.getDirection(decoratedText), direction);
- return React.createElement(DecoratorComponent, _extends({}, decoratorProps, {
- contentState: contentState,
- decoratedText: decoratedText,
- dir: dir,
- key: decoratorOffsetKey,
- entityKey: block.getEntityAt(leafSet.get('start')),
- offsetKey: decoratorOffsetKey
- }), children);
- };
-
- return DraftEditorDecoratedLeaves;
- }(React.Component);
-
- module.exports = DraftEditorDecoratedLeaves;
-
- /***/ }),
- /* 109 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- var React = __webpack_require__(8);
-
- var UserAgent = __webpack_require__(5);
-
- var invariant = __webpack_require__(1);
-
- var isElement = __webpack_require__(15); // In IE, spans with <br> tags render as two newlines. By rendering a span
- // with only a newline character, we can be sure to render a single line.
-
-
- var useNewlineChar = UserAgent.isBrowser('IE <= 11');
- /**
- * Check whether the node should be considered a newline.
- */
-
- function isNewline(node) {
- return useNewlineChar ? node.textContent === '\n' : node.tagName === 'BR';
- }
- /**
- * Placeholder elements for empty text content.
- *
- * What is this `data-text` attribute, anyway? It turns out that we need to
- * put an attribute on the lowest-level text node in order to preserve correct
- * spellcheck handling. If the <span> is naked, Chrome and Safari may do
- * bizarre things to do the DOM -- split text nodes, create extra spans, etc.
- * If the <span> has an attribute, this appears not to happen.
- * See http://jsfiddle.net/9khdavod/ for the failure case, and
- * http://jsfiddle.net/7pg143f7/ for the fixed case.
- */
-
-
- var NEWLINE_A = function NEWLINE_A(ref) {
- return useNewlineChar ? React.createElement("span", {
- key: "A",
- "data-text": "true",
- ref: ref
- }, '\n') : React.createElement("br", {
- key: "A",
- "data-text": "true",
- ref: ref
- });
- };
-
- var NEWLINE_B = function NEWLINE_B(ref) {
- return useNewlineChar ? React.createElement("span", {
- key: "B",
- "data-text": "true",
- ref: ref
- }, '\n') : React.createElement("br", {
- key: "B",
- "data-text": "true",
- ref: ref
- });
- };
-
- /**
- * The lowest-level component in a `DraftEditor`, the text node component
- * replaces the default React text node implementation. This allows us to
- * perform custom handling of newline behavior and avoid re-rendering text
- * nodes with DOM state that already matches the expectations of our immutable
- * editor state.
- */
- var DraftEditorTextNode =
- /*#__PURE__*/
- function (_React$Component) {
- _inheritsLoose(DraftEditorTextNode, _React$Component);
-
- function DraftEditorTextNode(props) {
- var _this;
-
- _this = _React$Component.call(this, props) || this; // By flipping this flag, we also keep flipping keys which forces
- // React to remount this node every time it rerenders.
-
- _defineProperty(_assertThisInitialized(_this), "_forceFlag", void 0);
-
- _defineProperty(_assertThisInitialized(_this), "_node", void 0);
-
- _this._forceFlag = false;
- return _this;
- }
-
- var _proto = DraftEditorTextNode.prototype;
-
- _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
- var node = this._node;
- var shouldBeNewline = nextProps.children === '';
- !isElement(node) ? true ? invariant(false, 'node is not an Element') : invariant(false) : void 0;
- var elementNode = node;
-
- if (shouldBeNewline) {
- return !isNewline(elementNode);
- }
-
- return elementNode.textContent !== nextProps.children;
- };
-
- _proto.componentDidMount = function componentDidMount() {
- this._forceFlag = !this._forceFlag;
- };
-
- _proto.componentDidUpdate = function componentDidUpdate() {
- this._forceFlag = !this._forceFlag;
- };
-
- _proto.render = function render() {
- var _this2 = this;
-
- if (this.props.children === '') {
- return this._forceFlag ? NEWLINE_A(function (ref) {
- return _this2._node = ref;
- }) : NEWLINE_B(function (ref) {
- return _this2._node = ref;
- });
- }
-
- return React.createElement("span", {
- key: this._forceFlag ? 'A' : 'B',
- "data-text": "true",
- ref: function ref(_ref) {
- return _this2._node = _ref;
- }
- }, this.props.children);
- };
-
- return DraftEditorTextNode;
- }(React.Component);
-
- module.exports = DraftEditorTextNode;
-
- /***/ }),
- /* 110 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftEffects = __webpack_require__(60);
-
- var DraftJsDebugLogging = __webpack_require__(52);
-
- var UserAgent = __webpack_require__(5);
-
- var containsNode = __webpack_require__(36);
-
- var getActiveElement = __webpack_require__(61);
-
- var getCorrectDocumentFromNode = __webpack_require__(27);
-
- var invariant = __webpack_require__(1);
-
- var isElement = __webpack_require__(15);
-
- var isIE = UserAgent.isBrowser('IE');
-
- function getAnonymizedDOM(node, getNodeLabels) {
- if (!node) {
- return '[empty]';
- }
-
- var anonymized = anonymizeTextWithin(node, getNodeLabels);
-
- if (anonymized.nodeType === Node.TEXT_NODE) {
- return anonymized.textContent;
- }
-
- !isElement(anonymized) ? true ? invariant(false, 'Node must be an Element if it is not a text node.') : invariant(false) : void 0;
- var castedElement = anonymized;
- return castedElement.outerHTML;
- }
-
- function anonymizeTextWithin(node, getNodeLabels) {
- var labels = getNodeLabels !== undefined ? getNodeLabels(node) : [];
-
- if (node.nodeType === Node.TEXT_NODE) {
- var length = node.textContent.length;
- return getCorrectDocumentFromNode(node).createTextNode('[text ' + length + (labels.length ? ' | ' + labels.join(', ') : '') + ']');
- }
-
- var clone = node.cloneNode();
-
- if (clone.nodeType === 1 && labels.length) {
- clone.setAttribute('data-labels', labels.join(', '));
- }
-
- var childNodes = node.childNodes;
-
- for (var ii = 0; ii < childNodes.length; ii++) {
- clone.appendChild(anonymizeTextWithin(childNodes[ii], getNodeLabels));
- }
-
- return clone;
- }
-
- function getAnonymizedEditorDOM(node, getNodeLabels) {
- // grabbing the DOM content of the Draft editor
- var currentNode = node; // this should only be used after checking with isElement
-
- var castedNode = currentNode;
-
- while (currentNode) {
- if (isElement(currentNode) && castedNode.hasAttribute('contenteditable')) {
- // found the Draft editor container
- return getAnonymizedDOM(currentNode, getNodeLabels);
- } else {
- currentNode = currentNode.parentNode;
- castedNode = currentNode;
- }
- }
-
- return 'Could not find contentEditable parent of node';
- }
-
- function getNodeLength(node) {
- return node.nodeValue === null ? node.childNodes.length : node.nodeValue.length;
- }
- /**
- * In modern non-IE browsers, we can support both forward and backward
- * selections.
- *
- * Note: IE10+ supports the Selection object, but it does not support
- * the `extend` method, which means that even in modern IE, it's not possible
- * to programatically create a backward selection. Thus, for all IE
- * versions, we use the old IE API to create our selections.
- */
-
-
- function setDraftEditorSelection(selectionState, node, blockKey, nodeStart, nodeEnd) {
- // It's possible that the editor has been removed from the DOM but
- // our selection code doesn't know it yet. Forcing selection in
- // this case may lead to errors, so just bail now.
- var documentObject = getCorrectDocumentFromNode(node);
-
- if (!containsNode(documentObject.documentElement, node)) {
- return;
- }
-
- var selection = documentObject.defaultView.getSelection();
- var anchorKey = selectionState.getAnchorKey();
- var anchorOffset = selectionState.getAnchorOffset();
- var focusKey = selectionState.getFocusKey();
- var focusOffset = selectionState.getFocusOffset();
- var isBackward = selectionState.getIsBackward(); // IE doesn't support backward selection. Swap key/offset pairs.
-
- if (!selection.extend && isBackward) {
- var tempKey = anchorKey;
- var tempOffset = anchorOffset;
- anchorKey = focusKey;
- anchorOffset = focusOffset;
- focusKey = tempKey;
- focusOffset = tempOffset;
- isBackward = false;
- }
-
- var hasAnchor = anchorKey === blockKey && nodeStart <= anchorOffset && nodeEnd >= anchorOffset;
- var hasFocus = focusKey === blockKey && nodeStart <= focusOffset && nodeEnd >= focusOffset; // If the selection is entirely bound within this node, set the selection
- // and be done.
-
- if (hasAnchor && hasFocus) {
- selection.removeAllRanges();
- addPointToSelection(selection, node, anchorOffset - nodeStart, selectionState);
- addFocusToSelection(selection, node, focusOffset - nodeStart, selectionState);
- return;
- }
-
- if (!isBackward) {
- // If the anchor is within this node, set the range start.
- if (hasAnchor) {
- selection.removeAllRanges();
- addPointToSelection(selection, node, anchorOffset - nodeStart, selectionState);
- } // If the focus is within this node, we can assume that we have
- // already set the appropriate start range on the selection, and
- // can simply extend the selection.
-
-
- if (hasFocus) {
- addFocusToSelection(selection, node, focusOffset - nodeStart, selectionState);
- }
- } else {
- // If this node has the focus, set the selection range to be a
- // collapsed range beginning here. Later, when we encounter the anchor,
- // we'll use this information to extend the selection.
- if (hasFocus) {
- selection.removeAllRanges();
- addPointToSelection(selection, node, focusOffset - nodeStart, selectionState);
- } // If this node has the anchor, we may assume that the correct
- // focus information is already stored on the selection object.
- // We keep track of it, reset the selection range, and extend it
- // back to the focus point.
-
-
- if (hasAnchor) {
- var storedFocusNode = selection.focusNode;
- var storedFocusOffset = selection.focusOffset;
- selection.removeAllRanges();
- addPointToSelection(selection, node, anchorOffset - nodeStart, selectionState);
- addFocusToSelection(selection, storedFocusNode, storedFocusOffset, selectionState);
- }
- }
- }
- /**
- * Extend selection towards focus point.
- */
-
-
- function addFocusToSelection(selection, node, offset, selectionState) {
- var activeElement = getActiveElement();
-
- if (selection.extend && containsNode(activeElement, node)) {
- // If `extend` is called while another element has focus, an error is
- // thrown. We therefore disable `extend` if the active element is somewhere
- // other than the node we are selecting. This should only occur in Firefox,
- // since it is the only browser to support multiple selections.
- // See https://bugzilla.mozilla.org/show_bug.cgi?id=921444.
- // logging to catch bug that is being reported in t16250795
- if (offset > getNodeLength(node)) {
- // the call to 'selection.extend' is about to throw
- DraftJsDebugLogging.logSelectionStateFailure({
- anonymizedDom: getAnonymizedEditorDOM(node),
- extraParams: JSON.stringify({
- offset: offset
- }),
- selectionState: JSON.stringify(selectionState.toJS())
- });
- } // logging to catch bug that is being reported in t18110632
-
-
- var nodeWasFocus = node === selection.focusNode;
-
- try {
- selection.extend(node, offset);
- } catch (e) {
- DraftJsDebugLogging.logSelectionStateFailure({
- anonymizedDom: getAnonymizedEditorDOM(node, function (n) {
- var labels = [];
-
- if (n === activeElement) {
- labels.push('active element');
- }
-
- if (n === selection.anchorNode) {
- labels.push('selection anchor node');
- }
-
- if (n === selection.focusNode) {
- labels.push('selection focus node');
- }
-
- return labels;
- }),
- extraParams: JSON.stringify({
- activeElementName: activeElement ? activeElement.nodeName : null,
- nodeIsFocus: node === selection.focusNode,
- nodeWasFocus: nodeWasFocus,
- selectionRangeCount: selection.rangeCount,
- selectionAnchorNodeName: selection.anchorNode ? selection.anchorNode.nodeName : null,
- selectionAnchorOffset: selection.anchorOffset,
- selectionFocusNodeName: selection.focusNode ? selection.focusNode.nodeName : null,
- selectionFocusOffset: selection.focusOffset,
- message: e ? '' + e : null,
- offset: offset
- }, null, 2),
- selectionState: JSON.stringify(selectionState.toJS(), null, 2)
- }); // allow the error to be thrown -
- // better than continuing in a broken state
-
- throw e;
- }
- } else {
- // IE doesn't support extend. This will mean no backward selection.
- // Extract the existing selection range and add focus to it.
- // Additionally, clone the selection range. IE11 throws an
- // InvalidStateError when attempting to access selection properties
- // after the range is detached.
- if (selection.rangeCount > 0) {
- var range = selection.getRangeAt(0);
- range.setEnd(node, offset);
- selection.addRange(range.cloneRange());
- }
- }
- }
-
- function addPointToSelection(selection, node, offset, selectionState) {
- var range = getCorrectDocumentFromNode(node).createRange(); // logging to catch bug that is being reported in t16250795
-
- if (offset > getNodeLength(node)) {
- // in this case we know that the call to 'range.setStart' is about to throw
- DraftJsDebugLogging.logSelectionStateFailure({
- anonymizedDom: getAnonymizedEditorDOM(node),
- extraParams: JSON.stringify({
- offset: offset
- }),
- selectionState: JSON.stringify(selectionState.toJS())
- });
- DraftEffects.handleExtensionCausedError();
- }
-
- range.setStart(node, offset); // IE sometimes throws Unspecified Error when trying to addRange
-
- if (isIE) {
- try {
- selection.addRange(range);
- } catch (e) {
- if (true) {
- /* eslint-disable-next-line no-console */
- console.warn('Call to selection.addRange() threw exception: ', e);
- }
- }
- } else {
- selection.addRange(range);
- }
- }
-
- module.exports = {
- setDraftEditorSelection: setDraftEditorSelection,
- addFocusToSelection: addFocusToSelection
- };
-
- /***/ }),
- /* 111 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
- var isNode = __webpack_require__(112);
- /**
- * @param {*} object The object to check.
- * @return {boolean} Whether or not the object is a DOM text node.
- */
-
-
- function isTextNode(object) {
- return isNode(object) && object.nodeType == 3;
- }
-
- module.exports = isTextNode;
-
- /***/ }),
- /* 112 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
- /**
- * @param {*} object The object to check.
- * @return {boolean} Whether or not the object is a DOM node.
- */
- function isNode(object) {
- var doc = object ? object.ownerDocument || object : document;
- var defaultView = doc.defaultView || window;
- return !!(object && (typeof defaultView.Node === 'function' ? object instanceof defaultView.Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'));
- }
-
- module.exports = isNode;
-
- /***/ }),
- /* 113 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
- var camelize = __webpack_require__(114);
-
- var hyphenate = __webpack_require__(115);
-
- function asString(value)
- /*?string*/
- {
- return value == null ? value : String(value);
- }
-
- function getStyleProperty(
- /*DOMNode*/
- node,
- /*string*/
- name)
- /*?string*/
- {
- var computedStyle; // W3C Standard
-
- if (window.getComputedStyle) {
- // In certain cases such as within an iframe in FF3, this returns null.
- computedStyle = window.getComputedStyle(node, null);
-
- if (computedStyle) {
- return asString(computedStyle.getPropertyValue(hyphenate(name)));
- }
- } // Safari
-
-
- if (document.defaultView && document.defaultView.getComputedStyle) {
- computedStyle = document.defaultView.getComputedStyle(node, null); // A Safari bug causes this to return null for `display: none` elements.
-
- if (computedStyle) {
- return asString(computedStyle.getPropertyValue(hyphenate(name)));
- }
-
- if (name === 'display') {
- return 'none';
- }
- } // Internet Explorer
-
-
- if (node.currentStyle) {
- if (name === 'float') {
- return asString(node.currentStyle.cssFloat || node.currentStyle.styleFloat);
- }
-
- return asString(node.currentStyle[camelize(name)]);
- }
-
- return asString(node.style && node.style[camelize(name)]);
- }
-
- module.exports = getStyleProperty;
-
- /***/ }),
- /* 114 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
- var _hyphenPattern = /-(.)/g;
- /**
- * Camelcases a hyphenated string, for example:
- *
- * > camelize('background-color')
- * < "backgroundColor"
- *
- * @param {string} string
- * @return {string}
- */
-
- function camelize(string) {
- return string.replace(_hyphenPattern, function (_, character) {
- return character.toUpperCase();
- });
- }
-
- module.exports = camelize;
-
- /***/ }),
- /* 115 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
- var _uppercasePattern = /([A-Z])/g;
- /**
- * Hyphenates a camelcased string, for example:
- *
- * > hyphenate('backgroundColor')
- * < "background-color"
- *
- * For CSS style names, use `hyphenateStyleName` instead which works properly
- * with all vendor prefixes, including `ms`.
- *
- * @param {string} string
- * @return {string}
- */
-
- function hyphenate(string) {
- return string.replace(_uppercasePattern, '-$1').toLowerCase();
- }
-
- module.exports = hyphenate;
-
- /***/ }),
- /* 116 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
- var containsNode = __webpack_require__(36);
- /**
- * Gets an element's bounding rect in pixels relative to the viewport.
- *
- * @param {DOMElement} elem
- * @return {object}
- */
-
-
- function getElementRect(elem) {
- var docElem = elem.ownerDocument.documentElement; // FF 2, Safari 3 and Opera 9.5- do not support getBoundingClientRect().
- // IE9- will throw if the element is not in the document.
-
- if (!('getBoundingClientRect' in elem) || !containsNode(docElem, elem)) {
- return {
- left: 0,
- right: 0,
- top: 0,
- bottom: 0
- };
- } // Subtracts clientTop/Left because IE8- added a 2px border to the
- // <html> element (see http://fburl.com/1493213). IE 7 in
- // Quicksmode does not report clientLeft/clientTop so there
- // will be an unaccounted offset of 2px when in quirksmode
-
-
- var rect = elem.getBoundingClientRect();
- return {
- left: Math.round(rect.left) - docElem.clientLeft,
- right: Math.round(rect.right) - docElem.clientLeft,
- top: Math.round(rect.top) - docElem.clientTop,
- bottom: Math.round(rect.bottom) - docElem.clientTop
- };
- }
-
- module.exports = getElementRect;
-
- /***/ }),
- /* 117 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
-
- var isWebkit = typeof navigator !== 'undefined' && navigator.userAgent.indexOf('AppleWebKit') > -1;
- /**
- * Gets the element with the document scroll properties such as `scrollLeft` and
- * `scrollHeight`. This may differ across different browsers.
- *
- * NOTE: The return value can be null if the DOM is not yet ready.
- *
- * @param {?DOMDocument} doc Defaults to current document.
- * @return {?DOMElement}
- */
-
- function getDocumentScrollElement(doc) {
- doc = doc || document;
-
- if (doc.scrollingElement) {
- return doc.scrollingElement;
- }
-
- return !isWebkit && doc.compatMode === 'CSS1Compat' ? doc.documentElement : doc.body;
- }
-
- module.exports = getDocumentScrollElement;
-
- /***/ }),
- /* 118 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
- /**
- * Gets the scroll position of the supplied element or window.
- *
- * The return values are unbounded, unlike `getScrollPosition`. This means they
- * may be negative or exceed the element boundaries (which is possible using
- * inertial scrolling).
- *
- * @param {DOMWindow|DOMElement} scrollable
- * @return {object} Map with `x` and `y` keys.
- */
-
- function getUnboundedScrollPosition(scrollable) {
- if (scrollable.Window && scrollable instanceof scrollable.Window) {
- return {
- x: scrollable.pageXOffset || scrollable.document.documentElement.scrollLeft,
- y: scrollable.pageYOffset || scrollable.document.documentElement.scrollTop
- };
- }
-
- return {
- x: scrollable.scrollLeft,
- y: scrollable.scrollTop
- };
- }
-
- module.exports = getUnboundedScrollPosition;
-
- /***/ }),
- /* 119 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var _assign = __webpack_require__(14);
-
- function _extends() { _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
-
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- var DraftEditorBlock = __webpack_require__(64);
-
- var DraftOffsetKey = __webpack_require__(10);
-
- var React = __webpack_require__(8);
-
- var cx = __webpack_require__(13);
-
- var joinClasses = __webpack_require__(120);
-
- var nullthrows = __webpack_require__(4);
-
- /**
- * Provide default styling for list items. This way, lists will be styled with
- * proper counters and indentation even if the caller does not specify
- * their own styling at all. If more than five levels of nesting are needed,
- * the necessary CSS classes can be provided via `blockStyleFn` configuration.
- */
- var getListItemClasses = function getListItemClasses(type, depth, shouldResetCount, direction) {
- return cx({
- 'public/DraftStyleDefault/unorderedListItem': type === 'unordered-list-item',
- 'public/DraftStyleDefault/orderedListItem': type === 'ordered-list-item',
- 'public/DraftStyleDefault/reset': shouldResetCount,
- 'public/DraftStyleDefault/depth0': depth === 0,
- 'public/DraftStyleDefault/depth1': depth === 1,
- 'public/DraftStyleDefault/depth2': depth === 2,
- 'public/DraftStyleDefault/depth3': depth === 3,
- 'public/DraftStyleDefault/depth4': depth >= 4,
- 'public/DraftStyleDefault/listLTR': direction === 'LTR',
- 'public/DraftStyleDefault/listRTL': direction === 'RTL'
- });
- };
- /**
- * `DraftEditorContents` is the container component for all block components
- * rendered for a `DraftEditor`. It is optimized to aggressively avoid
- * re-rendering blocks whenever possible.
- *
- * This component is separate from `DraftEditor` because certain props
- * (for instance, ARIA props) must be allowed to update without affecting
- * the contents of the editor.
- */
-
-
- var DraftEditorContents =
- /*#__PURE__*/
- function (_React$Component) {
- _inheritsLoose(DraftEditorContents, _React$Component);
-
- function DraftEditorContents() {
- return _React$Component.apply(this, arguments) || this;
- }
-
- var _proto = DraftEditorContents.prototype;
-
- _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
- var prevEditorState = this.props.editorState;
- var nextEditorState = nextProps.editorState;
- var prevDirectionMap = prevEditorState.getDirectionMap();
- var nextDirectionMap = nextEditorState.getDirectionMap(); // Text direction has changed for one or more blocks. We must re-render.
-
- if (prevDirectionMap !== nextDirectionMap) {
- return true;
- }
-
- var didHaveFocus = prevEditorState.getSelection().getHasFocus();
- var nowHasFocus = nextEditorState.getSelection().getHasFocus();
-
- if (didHaveFocus !== nowHasFocus) {
- return true;
- }
-
- var nextNativeContent = nextEditorState.getNativelyRenderedContent();
- var wasComposing = prevEditorState.isInCompositionMode();
- var nowComposing = nextEditorState.isInCompositionMode(); // If the state is unchanged or we're currently rendering a natively
- // rendered state, there's nothing new to be done.
-
- if (prevEditorState === nextEditorState || nextNativeContent !== null && nextEditorState.getCurrentContent() === nextNativeContent || wasComposing && nowComposing) {
- return false;
- }
-
- var prevContent = prevEditorState.getCurrentContent();
- var nextContent = nextEditorState.getCurrentContent();
- var prevDecorator = prevEditorState.getDecorator();
- var nextDecorator = nextEditorState.getDecorator();
- return wasComposing !== nowComposing || prevContent !== nextContent || prevDecorator !== nextDecorator || nextEditorState.mustForceSelection();
- };
-
- _proto.render = function render() {
- var _this$props = this.props,
- blockRenderMap = _this$props.blockRenderMap,
- blockRendererFn = _this$props.blockRendererFn,
- blockStyleFn = _this$props.blockStyleFn,
- customStyleMap = _this$props.customStyleMap,
- customStyleFn = _this$props.customStyleFn,
- editorState = _this$props.editorState,
- editorKey = _this$props.editorKey,
- preventScroll = _this$props.preventScroll,
- textDirectionality = _this$props.textDirectionality;
- var content = editorState.getCurrentContent();
- var selection = editorState.getSelection();
- var forceSelection = editorState.mustForceSelection();
- var decorator = editorState.getDecorator();
- var directionMap = nullthrows(editorState.getDirectionMap());
- var blocksAsArray = content.getBlocksAsArray();
- var processedBlocks = [];
- var currentDepth = null;
- var lastWrapperTemplate = null;
-
- for (var ii = 0; ii < blocksAsArray.length; ii++) {
- var _block = blocksAsArray[ii];
-
- var key = _block.getKey();
-
- var blockType = _block.getType();
-
- var customRenderer = blockRendererFn(_block);
- var CustomComponent = void 0,
- customProps = void 0,
- customEditable = void 0;
-
- if (customRenderer) {
- CustomComponent = customRenderer.component;
- customProps = customRenderer.props;
- customEditable = customRenderer.editable;
- }
-
- var direction = textDirectionality ? textDirectionality : directionMap.get(key);
- var offsetKey = DraftOffsetKey.encode(key, 0, 0);
- var componentProps = {
- contentState: content,
- block: _block,
- blockProps: customProps,
- blockStyleFn: blockStyleFn,
- customStyleMap: customStyleMap,
- customStyleFn: customStyleFn,
- decorator: decorator,
- direction: direction,
- forceSelection: forceSelection,
- offsetKey: offsetKey,
- preventScroll: preventScroll,
- selection: selection,
- tree: editorState.getBlockTree(key)
- };
- var configForType = blockRenderMap.get(blockType) || blockRenderMap.get('unstyled');
- var wrapperTemplate = configForType.wrapper;
- var Element = configForType.element || blockRenderMap.get('unstyled').element;
-
- var depth = _block.getDepth();
-
- var _className = '';
-
- if (blockStyleFn) {
- _className = blockStyleFn(_block);
- } // List items are special snowflakes, since we handle nesting and
- // counters manually.
-
-
- if (Element === 'li') {
- var shouldResetCount = lastWrapperTemplate !== wrapperTemplate || currentDepth === null || depth > currentDepth;
- _className = joinClasses(_className, getListItemClasses(blockType, depth, shouldResetCount, direction));
- }
-
- var Component = CustomComponent || DraftEditorBlock;
- var childProps = {
- className: _className,
- 'data-block': true,
- 'data-editor': editorKey,
- 'data-offset-key': offsetKey,
- key: key
- };
-
- if (customEditable !== undefined) {
- childProps = _objectSpread({}, childProps, {
- contentEditable: customEditable,
- suppressContentEditableWarning: true
- });
- }
-
- var child = React.createElement(Element, childProps,
- /* $FlowFixMe(>=0.112.0 site=www,mobile) This comment suppresses an
- * error found when Flow v0.112 was deployed. To see the error delete
- * this comment and run Flow. */
- React.createElement(Component, _extends({}, componentProps, {
- key: key
- })));
- processedBlocks.push({
- block: child,
- wrapperTemplate: wrapperTemplate,
- key: key,
- offsetKey: offsetKey
- });
-
- if (wrapperTemplate) {
- currentDepth = _block.getDepth();
- } else {
- currentDepth = null;
- }
-
- lastWrapperTemplate = wrapperTemplate;
- } // Group contiguous runs of blocks that have the same wrapperTemplate
-
-
- var outputBlocks = [];
-
- for (var _ii = 0; _ii < processedBlocks.length;) {
- var info = processedBlocks[_ii];
-
- if (info.wrapperTemplate) {
- var blocks = [];
-
- do {
- blocks.push(processedBlocks[_ii].block);
- _ii++;
- } while (_ii < processedBlocks.length && processedBlocks[_ii].wrapperTemplate === info.wrapperTemplate);
-
- var wrapperElement = React.cloneElement(info.wrapperTemplate, {
- key: info.key + '-wrap',
- 'data-offset-key': info.offsetKey
- }, blocks);
- outputBlocks.push(wrapperElement);
- } else {
- outputBlocks.push(info.block);
- _ii++;
- }
- }
-
- return React.createElement("div", {
- "data-contents": "true"
- }, outputBlocks);
- };
-
- return DraftEditorContents;
- }(React.Component);
-
- module.exports = DraftEditorContents;
-
- /***/ }),
- /* 120 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- * @typechecks static-only
- */
-
- /**
- * Combines multiple className strings into one.
- */
-
- function joinClasses(className) {
- var newClassName = className || '';
- var argLength = arguments.length;
-
- if (argLength > 1) {
- for (var index = 1; index < argLength; index++) {
- var nextClass = arguments[index];
-
- if (nextClass) {
- newClassName = (newClassName ? newClassName + ' ' : '') + nextClass;
- }
- }
- }
-
- return newClassName;
- }
-
- module.exports = joinClasses;
-
- /***/ }),
- /* 121 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DataTransfer = __webpack_require__(65);
-
- var DraftModifier = __webpack_require__(3);
-
- var EditorState = __webpack_require__(2);
-
- var findAncestorOffsetKey = __webpack_require__(26);
-
- var getCorrectDocumentFromNode = __webpack_require__(27);
-
- var getTextContentFromFiles = __webpack_require__(67);
-
- var getUpdatedSelectionState = __webpack_require__(56);
-
- var getWindowForNode = __webpack_require__(50);
-
- var isEventHandled = __webpack_require__(31);
-
- var nullthrows = __webpack_require__(4);
- /**
- * Get a SelectionState for the supplied mouse event.
- */
-
-
- function getSelectionForEvent(event, editorState) {
- var node = null;
- var offset = null;
- var eventTargetDocument = getCorrectDocumentFromNode(event.currentTarget);
- /* $FlowFixMe(>=0.68.0 site=www,mobile) This comment suppresses an error
- * found when Flow v0.68 was deployed. To see the error delete this comment
- * and run Flow. */
-
- if (typeof eventTargetDocument.caretRangeFromPoint === 'function') {
- /* $FlowFixMe(>=0.68.0 site=www,mobile) This comment suppresses an error
- * found when Flow v0.68 was deployed. To see the error delete this comment
- * and run Flow. */
- var dropRange = eventTargetDocument.caretRangeFromPoint(event.x, event.y);
- node = dropRange.startContainer;
- offset = dropRange.startOffset;
- } else if (event.rangeParent) {
- node = event.rangeParent;
- offset = event.rangeOffset;
- } else {
- return null;
- }
-
- node = nullthrows(node);
- offset = nullthrows(offset);
- var offsetKey = nullthrows(findAncestorOffsetKey(node));
- return getUpdatedSelectionState(editorState, offsetKey, offset, offsetKey, offset);
- }
-
- var DraftEditorDragHandler = {
- /**
- * Drag originating from input terminated.
- */
- onDragEnd: function onDragEnd(editor) {
- editor.exitCurrentMode();
- endDrag(editor);
- },
-
- /**
- * Handle data being dropped.
- */
- onDrop: function onDrop(editor, e) {
- var data = new DataTransfer(e.nativeEvent.dataTransfer);
- var editorState = editor._latestEditorState;
- var dropSelection = getSelectionForEvent(e.nativeEvent, editorState);
- e.preventDefault();
- editor._dragCount = 0;
- editor.exitCurrentMode();
-
- if (dropSelection == null) {
- return;
- }
-
- var files = data.getFiles();
-
- if (files.length > 0) {
- if (editor.props.handleDroppedFiles && isEventHandled(editor.props.handleDroppedFiles(dropSelection, files))) {
- return;
- }
- /* $FlowFixMe This comment suppresses an error found DataTransfer was
- * typed. getFiles() returns an array of <Files extends Blob>, not Blob
- */
-
-
- getTextContentFromFiles(files, function (fileText) {
- fileText && editor.update(insertTextAtSelection(editorState, dropSelection, fileText));
- });
- return;
- }
-
- var dragType = editor._internalDrag ? 'internal' : 'external';
-
- if (editor.props.handleDrop && isEventHandled(editor.props.handleDrop(dropSelection, data, dragType))) {// handled
- } else if (editor._internalDrag) {
- editor.update(moveText(editorState, dropSelection));
- } else {
- editor.update(insertTextAtSelection(editorState, dropSelection, data.getText()));
- }
-
- endDrag(editor);
- }
- };
-
- function endDrag(editor) {
- editor._internalDrag = false; // Fix issue #1383
- // Prior to React v16.5.0 onDrop breaks onSelect event:
- // https://github.com/facebook/react/issues/11379.
- // Dispatching a mouseup event on DOM node will make it go back to normal.
-
- var editorNode = editor.editorContainer;
-
- if (editorNode) {
- var mouseUpEvent = new MouseEvent('mouseup', {
- view: getWindowForNode(editorNode),
- bubbles: true,
- cancelable: true
- });
- editorNode.dispatchEvent(mouseUpEvent);
- }
- }
-
- function moveText(editorState, targetSelection) {
- var newContentState = DraftModifier.moveText(editorState.getCurrentContent(), editorState.getSelection(), targetSelection);
- return EditorState.push(editorState, newContentState, 'insert-fragment');
- }
- /**
- * Insert text at a specified selection.
- */
-
-
- function insertTextAtSelection(editorState, selection, text) {
- var newContentState = DraftModifier.insertText(editorState.getCurrentContent(), selection, text, editorState.getCurrentInlineStyle());
- return EditorState.push(editorState, newContentState, 'insert-fragment');
- }
-
- module.exports = DraftEditorDragHandler;
-
- /***/ }),
- /* 122 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
- var PhotosMimeType = {
- isImage: function isImage(mimeString) {
- return getParts(mimeString)[0] === 'image';
- },
- isJpeg: function isJpeg(mimeString) {
- var parts = getParts(mimeString);
- return PhotosMimeType.isImage(mimeString) && ( // see http://fburl.com/10972194
- parts[1] === 'jpeg' || parts[1] === 'pjpeg');
- }
- };
-
- function getParts(mimeString) {
- return mimeString.split('/');
- }
-
- module.exports = PhotosMimeType;
-
- /***/ }),
- /* 123 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
- var invariant = __webpack_require__(1);
- /**
- * Convert array-like objects to arrays.
- *
- * This API assumes the caller knows the contents of the data type. For less
- * well defined inputs use createArrayFromMixed.
- *
- * @param {object|function|filelist} obj
- * @return {array}
- */
-
-
- function toArray(obj) {
- var length = obj.length; // Some browsers builtin objects can report typeof 'function' (e.g. NodeList
- // in old versions of Safari).
-
- !(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? true ? invariant(false, 'toArray: Array-like object expected') : invariant(false) : void 0;
- !(typeof length === 'number') ? true ? invariant(false, 'toArray: Object needs a length property') : invariant(false) : void 0;
- !(length === 0 || length - 1 in obj) ? true ? invariant(false, 'toArray: Object should have keys for indices') : invariant(false) : void 0;
- !(typeof obj.callee !== 'function') ? true ? invariant(false, 'toArray: Object can\'t be `arguments`. Use rest params ' + '(function(...args) {}) or Array.from() instead.') : invariant(false) : void 0; // Old IE doesn't give collections access to hasOwnProperty. Assume inputs
- // without method will throw during the slice call and skip straight to the
- // fallback.
-
- if (obj.hasOwnProperty) {
- try {
- return Array.prototype.slice.call(obj);
- } catch (e) {// IE < 9 does not support Array#slice on collections objects
- }
- } // Fall back to copying key by key. This assumes all keys have a value,
- // so will not preserve sparsely populated inputs.
-
-
- var ret = Array(length);
-
- for (var ii = 0; ii < length; ii++) {
- ret[ii] = obj[ii];
- }
-
- return ret;
- }
- /**
- * Perform a heuristic test to determine if an object is "array-like".
- *
- * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
- * Joshu replied: "Mu."
- *
- * This function determines if its argument has "array nature": it returns
- * true if the argument is an actual array, an `arguments' object, or an
- * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
- *
- * It will return false for other array-like objects like Filelist.
- *
- * @param {*} obj
- * @return {boolean}
- */
-
-
- function hasArrayNature(obj) {
- return (// not null/false
- !!obj && ( // arrays are objects, NodeLists are functions in Safari
- typeof obj == 'object' || typeof obj == 'function') && // quacks like an array
- 'length' in obj && // not window
- !('setInterval' in obj) && // no DOM node should be considered an array-like
- // a 'select' element has 'length' and 'item' properties on IE8
- typeof obj.nodeType != 'number' && ( // a real array
- Array.isArray(obj) || // arguments
- 'callee' in obj || // HTMLCollection/NodeList
- 'item' in obj)
- );
- }
- /**
- * Ensure that the argument is an array by wrapping it in an array if it is not.
- * Creates a copy of the argument if it is already an array.
- *
- * This is mostly useful idiomatically:
- *
- * var createArrayFromMixed = require('createArrayFromMixed');
- *
- * function takesOneOrMoreThings(things) {
- * things = createArrayFromMixed(things);
- * ...
- * }
- *
- * This allows you to treat `things' as an array, but accept scalars in the API.
- *
- * If you need to convert an array-like object, like `arguments`, into an array
- * use toArray instead.
- *
- * @param {*} obj
- * @return {array}
- */
-
-
- function createArrayFromMixed(obj) {
- if (!hasArrayNature(obj)) {
- return [obj];
- } else if (Array.isArray(obj)) {
- return obj.slice();
- } else {
- return toArray(obj);
- }
- }
-
- module.exports = createArrayFromMixed;
-
- /***/ }),
- /* 124 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var UserAgent = __webpack_require__(5);
-
- var onBeforeInput = __webpack_require__(125);
-
- var onBlur = __webpack_require__(130);
-
- var onCompositionStart = __webpack_require__(131);
-
- var onCopy = __webpack_require__(132);
-
- var onCut = __webpack_require__(133);
-
- var onDragOver = __webpack_require__(135);
-
- var onDragStart = __webpack_require__(136);
-
- var onFocus = __webpack_require__(137);
-
- var onInput = __webpack_require__(138);
-
- var onKeyDown = __webpack_require__(139);
-
- var onPaste = __webpack_require__(153);
-
- var onSelect = __webpack_require__(51);
-
- var isChrome = UserAgent.isBrowser('Chrome');
- var selectionHandler = isChrome ? onSelect : function (e) {};
- var DraftEditorEditHandler = {
- onBeforeInput: onBeforeInput,
- onBlur: onBlur,
- onCompositionStart: onCompositionStart,
- onCopy: onCopy,
- onCut: onCut,
- onDragOver: onDragOver,
- onDragStart: onDragStart,
- onFocus: onFocus,
- onInput: onInput,
- onKeyDown: onKeyDown,
- onPaste: onPaste,
- onSelect: onSelect,
- // In certain cases, contenteditable on chrome does not fire the onSelect
- // event, causing problems with cursor positioning. Therefore, the selection
- // state update handler is added to more events to ensure that the selection
- // state is always synced with the actual cursor positions.
- onMouseUp: selectionHandler,
- onKeyUp: selectionHandler
- };
- module.exports = DraftEditorEditHandler;
-
- /***/ }),
- /* 125 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftModifier = __webpack_require__(3);
-
- var EditorState = __webpack_require__(2);
-
- var UserAgent = __webpack_require__(5);
-
- var getEntityKeyForSelection = __webpack_require__(35);
-
- var isEventHandled = __webpack_require__(31);
-
- var isSelectionAtLeafStart = __webpack_require__(126);
-
- var nullthrows = __webpack_require__(4);
-
- var setImmediate = __webpack_require__(127); // When nothing is focused, Firefox regards two characters, `'` and `/`, as
- // commands that should open and focus the "quickfind" search bar. This should
- // *never* happen while a contenteditable is focused, but as of v28, it
- // sometimes does, even when the keypress event target is the contenteditable.
- // This breaks the input. Special case these characters to ensure that when
- // they are typed, we prevent default on the event to make sure not to
- // trigger quickfind.
-
-
- var FF_QUICKFIND_CHAR = "'";
- var FF_QUICKFIND_LINK_CHAR = '/';
- var isFirefox = UserAgent.isBrowser('Firefox');
-
- function mustPreventDefaultForCharacter(character) {
- return isFirefox && (character == FF_QUICKFIND_CHAR || character == FF_QUICKFIND_LINK_CHAR);
- }
- /**
- * Replace the current selection with the specified text string, with the
- * inline style and entity key applied to the newly inserted text.
- */
-
-
- function replaceText(editorState, text, inlineStyle, entityKey, forceSelection) {
- var contentState = DraftModifier.replaceText(editorState.getCurrentContent(), editorState.getSelection(), text, inlineStyle, entityKey);
- return EditorState.push(editorState, contentState, 'insert-characters', forceSelection);
- }
- /**
- * When `onBeforeInput` executes, the browser is attempting to insert a
- * character into the editor. Apply this character data to the document,
- * allowing native insertion if possible.
- *
- * Native insertion is encouraged in order to limit re-rendering and to
- * preserve spellcheck highlighting, which disappears or flashes if re-render
- * occurs on the relevant text nodes.
- */
-
-
- function editOnBeforeInput(editor, e) {
- if (editor._pendingStateFromBeforeInput !== undefined) {
- editor.update(editor._pendingStateFromBeforeInput);
- editor._pendingStateFromBeforeInput = undefined;
- }
-
- var editorState = editor._latestEditorState;
- var chars = e.data; // In some cases (ex: IE ideographic space insertion) no character data
- // is provided. There's nothing to do when this happens.
-
- if (!chars) {
- return;
- } // Allow the top-level component to handle the insertion manually. This is
- // useful when triggering interesting behaviors for a character insertion,
- // Simple examples: replacing a raw text ':)' with a smile emoji or image
- // decorator, or setting a block to be a list item after typing '- ' at the
- // start of the block.
-
-
- if (editor.props.handleBeforeInput && isEventHandled(editor.props.handleBeforeInput(chars, editorState, e.timeStamp))) {
- e.preventDefault();
- return;
- } // If selection is collapsed, conditionally allow native behavior. This
- // reduces re-renders and preserves spellcheck highlighting. If the selection
- // is not collapsed, we will re-render.
-
-
- var selection = editorState.getSelection();
- var selectionStart = selection.getStartOffset();
- var anchorKey = selection.getAnchorKey();
-
- if (!selection.isCollapsed()) {
- e.preventDefault();
- editor.update(replaceText(editorState, chars, editorState.getCurrentInlineStyle(), getEntityKeyForSelection(editorState.getCurrentContent(), editorState.getSelection()), true));
- return;
- }
-
- var newEditorState = replaceText(editorState, chars, editorState.getCurrentInlineStyle(), getEntityKeyForSelection(editorState.getCurrentContent(), editorState.getSelection()), false); // Bunch of different cases follow where we need to prevent native insertion.
-
- var mustPreventNative = false;
-
- if (!mustPreventNative) {
- // Browsers tend to insert text in weird places in the DOM when typing at
- // the start of a leaf, so we'll handle it ourselves.
- mustPreventNative = isSelectionAtLeafStart(editor._latestCommittedEditorState);
- }
-
- if (!mustPreventNative) {
- // Let's say we have a decorator that highlights hashtags. In many cases
- // we need to prevent native behavior and rerender ourselves --
- // particularly, any case *except* where the inserted characters end up
- // anywhere except exactly where you put them.
- //
- // Using [] to denote a decorated leaf, some examples:
- //
- // 1. 'hi #' and append 'f'
- // desired rendering: 'hi [#f]'
- // native rendering would be: 'hi #f' (incorrect)
- //
- // 2. 'x [#foo]' and insert '#' before 'f'
- // desired rendering: 'x #[#foo]'
- // native rendering would be: 'x [##foo]' (incorrect)
- //
- // 3. '[#foobar]' and insert ' ' between 'foo' and 'bar'
- // desired rendering: '[#foo] bar'
- // native rendering would be: '[#foo bar]' (incorrect)
- //
- // 4. '[#foo]' and delete '#' [won't use this beforeinput codepath though]
- // desired rendering: 'foo'
- // native rendering would be: '[foo]' (incorrect)
- //
- // 5. '[#foo]' and append 'b'
- // desired rendering: '[#foob]'
- // native rendering would be: '[#foob]'
- // (native insertion here would be ok for decorators like simple spans,
- // but not more complex decorators. To be safe, we need to prevent it.)
- //
- // It is safe to allow native insertion if and only if the full list of
- // decorator ranges matches what we expect native insertion to give, and
- // the range lengths have not changed. We don't need to compare the content
- // because the only possible mutation to consider here is inserting plain
- // text and decorators can't affect text content.
- var oldBlockTree = editorState.getBlockTree(anchorKey);
- var newBlockTree = newEditorState.getBlockTree(anchorKey);
- mustPreventNative = oldBlockTree.size !== newBlockTree.size || oldBlockTree.zip(newBlockTree).some(function (_ref) {
- var oldLeafSet = _ref[0],
- newLeafSet = _ref[1];
- // selectionStart is guaranteed to be selectionEnd here
- var oldStart = oldLeafSet.get('start');
- var adjustedStart = oldStart + (oldStart >= selectionStart ? chars.length : 0);
- var oldEnd = oldLeafSet.get('end');
- var adjustedEnd = oldEnd + (oldEnd >= selectionStart ? chars.length : 0);
- var newStart = newLeafSet.get('start');
- var newEnd = newLeafSet.get('end');
- var newDecoratorKey = newLeafSet.get('decoratorKey');
- return (// Different decorators
- oldLeafSet.get('decoratorKey') !== newDecoratorKey || // Different number of inline styles
- oldLeafSet.get('leaves').size !== newLeafSet.get('leaves').size || // Different effective decorator position
- adjustedStart !== newStart || adjustedEnd !== newEnd || // Decorator already existed and its length changed
- newDecoratorKey != null && newEnd - newStart !== oldEnd - oldStart
- );
- });
- }
-
- if (!mustPreventNative) {
- mustPreventNative = mustPreventDefaultForCharacter(chars);
- }
-
- if (!mustPreventNative) {
- mustPreventNative = nullthrows(newEditorState.getDirectionMap()).get(anchorKey) !== nullthrows(editorState.getDirectionMap()).get(anchorKey);
- }
-
- if (mustPreventNative) {
- e.preventDefault();
- newEditorState = EditorState.set(newEditorState, {
- forceSelection: true
- });
- editor.update(newEditorState);
- return;
- } // We made it all the way! Let the browser do its thing and insert the char.
-
-
- newEditorState = EditorState.set(newEditorState, {
- nativelyRenderedContent: newEditorState.getCurrentContent()
- }); // The native event is allowed to occur. To allow user onChange handlers to
- // change the inserted text, we wait until the text is actually inserted
- // before we actually update our state. That way when we rerender, the text
- // we see in the DOM will already have been inserted properly.
-
- editor._pendingStateFromBeforeInput = newEditorState;
- setImmediate(function () {
- if (editor._pendingStateFromBeforeInput !== undefined) {
- editor.update(editor._pendingStateFromBeforeInput);
- editor._pendingStateFromBeforeInput = undefined;
- }
- });
- }
-
- module.exports = editOnBeforeInput;
-
- /***/ }),
- /* 126 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function isSelectionAtLeafStart(editorState) {
- var selection = editorState.getSelection();
- var anchorKey = selection.getAnchorKey();
- var blockTree = editorState.getBlockTree(anchorKey);
- var offset = selection.getStartOffset();
- var isAtStart = false;
- blockTree.some(function (leafSet) {
- if (offset === leafSet.get('start')) {
- isAtStart = true;
- return true;
- }
-
- if (offset < leafSet.get('end')) {
- return leafSet.get('leaves').some(function (leaf) {
- var leafStart = leaf.get('start');
-
- if (offset === leafStart) {
- isAtStart = true;
- return true;
- }
-
- return false;
- });
- }
-
- return false;
- });
- return isAtStart;
- }
-
- module.exports = isSelectionAtLeafStart;
-
- /***/ }),
- /* 127 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /* WEBPACK VAR INJECTION */(function(global) {/**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
- // setimmediate adds setImmediate to the global. We want to make sure we export
- // the actual function.
-
- __webpack_require__(128);
-
- module.exports = global.setImmediate;
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(25)))
-
- /***/ }),
- /* 128 */
- /***/ (function(module, exports, __webpack_require__) {
-
- /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
- "use strict";
-
- if (global.setImmediate) {
- return;
- }
-
- var nextHandle = 1; // Spec says greater than zero
- var tasksByHandle = {};
- var currentlyRunningATask = false;
- var doc = global.document;
- var registerImmediate;
-
- function setImmediate(callback) {
- // Callback can either be a function or a string
- if (typeof callback !== "function") {
- callback = new Function("" + callback);
- }
- // Copy function arguments
- var args = new Array(arguments.length - 1);
- for (var i = 0; i < args.length; i++) {
- args[i] = arguments[i + 1];
- }
- // Store and register the task
- var task = { callback: callback, args: args };
- tasksByHandle[nextHandle] = task;
- registerImmediate(nextHandle);
- return nextHandle++;
- }
-
- function clearImmediate(handle) {
- delete tasksByHandle[handle];
- }
-
- function run(task) {
- var callback = task.callback;
- var args = task.args;
- switch (args.length) {
- case 0:
- callback();
- break;
- case 1:
- callback(args[0]);
- break;
- case 2:
- callback(args[0], args[1]);
- break;
- case 3:
- callback(args[0], args[1], args[2]);
- break;
- default:
- callback.apply(undefined, args);
- break;
- }
- }
-
- function runIfPresent(handle) {
- // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
- // So if we're currently running a task, we'll need to delay this invocation.
- if (currentlyRunningATask) {
- // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
- // "too much recursion" error.
- setTimeout(runIfPresent, 0, handle);
- } else {
- var task = tasksByHandle[handle];
- if (task) {
- currentlyRunningATask = true;
- try {
- run(task);
- } finally {
- clearImmediate(handle);
- currentlyRunningATask = false;
- }
- }
- }
- }
-
- function installNextTickImplementation() {
- registerImmediate = function(handle) {
- process.nextTick(function () { runIfPresent(handle); });
- };
- }
-
- function canUsePostMessage() {
- // The test against `importScripts` prevents this implementation from being installed inside a web worker,
- // where `global.postMessage` means something completely different and can't be used for this purpose.
- if (global.postMessage && !global.importScripts) {
- var postMessageIsAsynchronous = true;
- var oldOnMessage = global.onmessage;
- global.onmessage = function() {
- postMessageIsAsynchronous = false;
- };
- global.postMessage("", "*");
- global.onmessage = oldOnMessage;
- return postMessageIsAsynchronous;
- }
- }
-
- function installPostMessageImplementation() {
- // Installs an event handler on `global` for the `message` event: see
- // * https://developer.mozilla.org/en/DOM/window.postMessage
- // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
-
- var messagePrefix = "setImmediate$" + Math.random() + "$";
- var onGlobalMessage = function(event) {
- if (event.source === global &&
- typeof event.data === "string" &&
- event.data.indexOf(messagePrefix) === 0) {
- runIfPresent(+event.data.slice(messagePrefix.length));
- }
- };
-
- if (global.addEventListener) {
- global.addEventListener("message", onGlobalMessage, false);
- } else {
- global.attachEvent("onmessage", onGlobalMessage);
- }
-
- registerImmediate = function(handle) {
- global.postMessage(messagePrefix + handle, "*");
- };
- }
-
- function installMessageChannelImplementation() {
- var channel = new MessageChannel();
- channel.port1.onmessage = function(event) {
- var handle = event.data;
- runIfPresent(handle);
- };
-
- registerImmediate = function(handle) {
- channel.port2.postMessage(handle);
- };
- }
-
- function installReadyStateChangeImplementation() {
- var html = doc.documentElement;
- registerImmediate = function(handle) {
- // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
- // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
- var script = doc.createElement("script");
- script.onreadystatechange = function () {
- runIfPresent(handle);
- script.onreadystatechange = null;
- html.removeChild(script);
- script = null;
- };
- html.appendChild(script);
- };
- }
-
- function installSetTimeoutImplementation() {
- registerImmediate = function(handle) {
- setTimeout(runIfPresent, 0, handle);
- };
- }
-
- // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
- var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
- attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
-
- // Don't get fooled by e.g. browserify environments.
- if ({}.toString.call(global.process) === "[object process]") {
- // For Node.js before 0.9
- installNextTickImplementation();
-
- } else if (canUsePostMessage()) {
- // For non-IE10 modern browsers
- installPostMessageImplementation();
-
- } else if (global.MessageChannel) {
- // For web workers, where supported
- installMessageChannelImplementation();
-
- } else if (doc && "onreadystatechange" in doc.createElement("script")) {
- // For IE 6–8
- installReadyStateChangeImplementation();
-
- } else {
- // For older browsers
- installSetTimeoutImplementation();
- }
-
- attachTo.setImmediate = setImmediate;
- attachTo.clearImmediate = clearImmediate;
- }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
-
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(25), __webpack_require__(129)))
-
- /***/ }),
- /* 129 */
- /***/ (function(module, exports) {
-
- // shim for using process in browser
- var process = module.exports = {};
-
- // cached from whatever global is present so that test runners that stub it
- // don't break things. But we need to wrap it in a try catch in case it is
- // wrapped in strict mode code which doesn't define any globals. It's inside a
- // function because try/catches deoptimize in certain engines.
-
- var cachedSetTimeout;
- var cachedClearTimeout;
-
- function defaultSetTimout() {
- throw new Error('setTimeout has not been defined');
- }
- function defaultClearTimeout () {
- throw new Error('clearTimeout has not been defined');
- }
- (function () {
- try {
- if (typeof setTimeout === 'function') {
- cachedSetTimeout = setTimeout;
- } else {
- cachedSetTimeout = defaultSetTimout;
- }
- } catch (e) {
- cachedSetTimeout = defaultSetTimout;
- }
- try {
- if (typeof clearTimeout === 'function') {
- cachedClearTimeout = clearTimeout;
- } else {
- cachedClearTimeout = defaultClearTimeout;
- }
- } catch (e) {
- cachedClearTimeout = defaultClearTimeout;
- }
- } ())
- function runTimeout(fun) {
- if (cachedSetTimeout === setTimeout) {
- //normal enviroments in sane situations
- return setTimeout(fun, 0);
- }
- // if setTimeout wasn't available but was latter defined
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
- cachedSetTimeout = setTimeout;
- return setTimeout(fun, 0);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedSetTimeout(fun, 0);
- } catch(e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedSetTimeout.call(null, fun, 0);
- } catch(e){
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
- return cachedSetTimeout.call(this, fun, 0);
- }
- }
-
-
- }
- function runClearTimeout(marker) {
- if (cachedClearTimeout === clearTimeout) {
- //normal enviroments in sane situations
- return clearTimeout(marker);
- }
- // if clearTimeout wasn't available but was latter defined
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
- cachedClearTimeout = clearTimeout;
- return clearTimeout(marker);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedClearTimeout(marker);
- } catch (e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedClearTimeout.call(null, marker);
- } catch (e){
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
- // Some versions of I.E. have different rules for clearTimeout vs setTimeout
- return cachedClearTimeout.call(this, marker);
- }
- }
-
-
-
- }
- var queue = [];
- var draining = false;
- var currentQueue;
- var queueIndex = -1;
-
- function cleanUpNextTick() {
- if (!draining || !currentQueue) {
- return;
- }
- draining = false;
- if (currentQueue.length) {
- queue = currentQueue.concat(queue);
- } else {
- queueIndex = -1;
- }
- if (queue.length) {
- drainQueue();
- }
- }
-
- function drainQueue() {
- if (draining) {
- return;
- }
- var timeout = runTimeout(cleanUpNextTick);
- draining = true;
-
- var len = queue.length;
- while(len) {
- currentQueue = queue;
- queue = [];
- while (++queueIndex < len) {
- if (currentQueue) {
- currentQueue[queueIndex].run();
- }
- }
- queueIndex = -1;
- len = queue.length;
- }
- currentQueue = null;
- draining = false;
- runClearTimeout(timeout);
- }
-
- process.nextTick = function (fun) {
- var args = new Array(arguments.length - 1);
- if (arguments.length > 1) {
- for (var i = 1; i < arguments.length; i++) {
- args[i - 1] = arguments[i];
- }
- }
- queue.push(new Item(fun, args));
- if (queue.length === 1 && !draining) {
- runTimeout(drainQueue);
- }
- };
-
- // v8 likes predictible objects
- function Item(fun, array) {
- this.fun = fun;
- this.array = array;
- }
- Item.prototype.run = function () {
- this.fun.apply(null, this.array);
- };
- process.title = 'browser';
- process.browser = true;
- process.env = {};
- process.argv = [];
- process.version = ''; // empty string to avoid regexp issues
- process.versions = {};
-
- function noop() {}
-
- process.on = noop;
- process.addListener = noop;
- process.once = noop;
- process.off = noop;
- process.removeListener = noop;
- process.removeAllListeners = noop;
- process.emit = noop;
- process.prependListener = noop;
- process.prependOnceListener = noop;
-
- process.listeners = function (name) { return [] }
-
- process.binding = function (name) {
- throw new Error('process.binding is not supported');
- };
-
- process.cwd = function () { return '/' };
- process.chdir = function (dir) {
- throw new Error('process.chdir is not supported');
- };
- process.umask = function() { return 0; };
-
-
- /***/ }),
- /* 130 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var EditorState = __webpack_require__(2);
-
- var containsNode = __webpack_require__(36);
-
- var getActiveElement = __webpack_require__(61);
-
- function editOnBlur(editor, e) {
- // In a contentEditable element, when you select a range and then click
- // another active element, this does trigger a `blur` event but will not
- // remove the DOM selection from the contenteditable.
- // This is consistent across all browsers, but we prefer that the editor
- // behave like a textarea, where a `blur` event clears the DOM selection.
- // We therefore force the issue to be certain, checking whether the active
- // element is `body` to force it when blurring occurs within the window (as
- // opposed to clicking to another tab or window).
- var ownerDocument = e.currentTarget.ownerDocument;
-
- if ( // This ESLint rule conflicts with `sketchy-null-bool` flow check
- // eslint-disable-next-line no-extra-boolean-cast
- !Boolean(editor.props.preserveSelectionOnBlur) && getActiveElement(ownerDocument) === ownerDocument.body) {
- var _selection = ownerDocument.defaultView.getSelection();
-
- var editorNode = editor.editor;
-
- if (_selection.rangeCount === 1 && containsNode(editorNode, _selection.anchorNode) && containsNode(editorNode, _selection.focusNode)) {
- _selection.removeAllRanges();
- }
- }
-
- var editorState = editor._latestEditorState;
- var currentSelection = editorState.getSelection();
-
- if (!currentSelection.getHasFocus()) {
- return;
- }
-
- var selection = currentSelection.set('hasFocus', false);
- editor.props.onBlur && editor.props.onBlur(e);
- editor.update(EditorState.acceptSelection(editorState, selection));
- }
-
- module.exports = editOnBlur;
-
- /***/ }),
- /* 131 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var EditorState = __webpack_require__(2);
- /**
- * The user has begun using an IME input system. Switching to `composite` mode
- * allows handling composition input and disables other edit behavior.
- */
-
-
- function editOnCompositionStart(editor, e) {
- editor.setMode('composite');
- editor.update(EditorState.set(editor._latestEditorState, {
- inCompositionMode: true
- })); // Allow composition handler to interpret the compositionstart event
-
- editor._onCompositionStart(e);
- }
-
- module.exports = editOnCompositionStart;
-
- /***/ }),
- /* 132 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var getFragmentFromSelection = __webpack_require__(68);
- /**
- * If we have a selection, create a ContentState fragment and store
- * it in our internal clipboard. Subsequent paste events will use this
- * fragment if no external clipboard data is supplied.
- */
-
-
- function editOnCopy(editor, e) {
- var editorState = editor._latestEditorState;
- var selection = editorState.getSelection(); // No selection, so there's nothing to copy.
-
- if (selection.isCollapsed()) {
- e.preventDefault();
- return;
- }
-
- editor.setClipboard(getFragmentFromSelection(editor._latestEditorState));
- }
-
- module.exports = editOnCopy;
-
- /***/ }),
- /* 133 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftModifier = __webpack_require__(3);
-
- var EditorState = __webpack_require__(2);
-
- var Style = __webpack_require__(29);
-
- var getFragmentFromSelection = __webpack_require__(68);
-
- var getScrollPosition = __webpack_require__(30);
-
- var isNode = __webpack_require__(134);
- /**
- * On `cut` events, native behavior is allowed to occur so that the system
- * clipboard is set properly. This means that we need to take steps to recover
- * the editor DOM state after the `cut` has occurred in order to maintain
- * control of the component.
- *
- * In addition, we can keep a copy of the removed fragment, including all
- * styles and entities, for use as an internal paste.
- */
-
-
- function editOnCut(editor, e) {
- var editorState = editor._latestEditorState;
- var selection = editorState.getSelection();
- var element = e.target;
- var scrollPosition; // No selection, so there's nothing to cut.
-
- if (selection.isCollapsed()) {
- e.preventDefault();
- return;
- } // Track the current scroll position so that it can be forced back in place
- // after the editor regains control of the DOM.
-
-
- if (isNode(element)) {
- var node = element;
- scrollPosition = getScrollPosition(Style.getScrollParent(node));
- }
-
- var fragment = getFragmentFromSelection(editorState);
- editor.setClipboard(fragment); // Set `cut` mode to disable all event handling temporarily.
-
- editor.setMode('cut'); // Let native `cut` behavior occur, then recover control.
-
- setTimeout(function () {
- editor.restoreEditorDOM(scrollPosition);
- editor.exitCurrentMode();
- editor.update(removeFragment(editorState));
- }, 0);
- }
-
- function removeFragment(editorState) {
- var newContent = DraftModifier.removeRange(editorState.getCurrentContent(), editorState.getSelection(), 'forward');
- return EditorState.push(editorState, newContent, 'remove-range');
- }
-
- module.exports = editOnCut;
-
- /***/ }),
- /* 134 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
- function isInstanceOfNode(target) {
- // we changed the name because of having duplicate module provider (fbjs)
- if (!target || !('ownerDocument' in target)) {
- return false;
- }
-
- if ('ownerDocument' in target) {
- var node = target;
-
- if (!node.ownerDocument.defaultView) {
- return node instanceof Node;
- }
-
- if (node instanceof node.ownerDocument.defaultView.Node) {
- return true;
- }
- }
-
- return false;
- }
-
- module.exports = isInstanceOfNode;
-
- /***/ }),
- /* 135 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- /**
- * Drag behavior has begun from outside the editor element.
- */
- function editOnDragOver(editor, e) {
- editor.setMode('drag');
- e.preventDefault();
- }
-
- module.exports = editOnDragOver;
-
- /***/ }),
- /* 136 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- /**
- * A `dragstart` event has begun within the text editor component.
- */
- function editOnDragStart(editor) {
- editor._internalDrag = true;
- editor.setMode('drag');
- }
-
- module.exports = editOnDragStart;
-
- /***/ }),
- /* 137 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var EditorState = __webpack_require__(2);
-
- var UserAgent = __webpack_require__(5);
-
- function editOnFocus(editor, e) {
- var editorState = editor._latestEditorState;
- var currentSelection = editorState.getSelection();
-
- if (currentSelection.getHasFocus()) {
- return;
- }
-
- var selection = currentSelection.set('hasFocus', true);
- editor.props.onFocus && editor.props.onFocus(e); // When the tab containing this text editor is hidden and the user does a
- // find-in-page in a _different_ tab, Chrome on Mac likes to forget what the
- // selection was right after sending this focus event and (if you let it)
- // moves the cursor back to the beginning of the editor, so we force the
- // selection here instead of simply accepting it in order to preserve the
- // old cursor position. See https://crbug.com/540004.
- // But it looks like this is fixed in Chrome 60.0.3081.0.
- // Other browsers also don't have this bug, so we prefer to acceptSelection
- // when possible, to ensure that unfocusing and refocusing a Draft editor
- // doesn't preserve the selection, matching how textareas work.
-
- if (UserAgent.isBrowser('Chrome < 60.0.3081.0')) {
- editor.update(EditorState.forceSelection(editorState, selection));
- } else {
- editor.update(EditorState.acceptSelection(editorState, selection));
- }
- }
-
- module.exports = editOnFocus;
-
- /***/ }),
- /* 138 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftModifier = __webpack_require__(3);
-
- var DraftOffsetKey = __webpack_require__(10);
-
- var EditorState = __webpack_require__(2);
-
- var UserAgent = __webpack_require__(5);
-
- var _require = __webpack_require__(57),
- notEmptyKey = _require.notEmptyKey;
-
- var findAncestorOffsetKey = __webpack_require__(26);
-
- var keyCommandPlainBackspace = __webpack_require__(69);
-
- var nullthrows = __webpack_require__(4);
-
- var isGecko = UserAgent.isEngine('Gecko');
- var DOUBLE_NEWLINE = '\n\n';
-
- function onInputType(inputType, editorState) {
- switch (inputType) {
- case 'deleteContentBackward':
- return keyCommandPlainBackspace(editorState);
- }
-
- return editorState;
- }
- /**
- * This function serves two purposes
- *
- * 1. To update the editorState and call onChange method with the new
- * editorState. This editorState is calculated in editOnBeforeInput but the
- * onChange method is not called with the new state until this method does it.
- * It is done to handle a specific case where certain character inputs might
- * be replaced with something else. E.g. snippets ('rc' might be replaced
- * with boilerplate code for react component). More information on the
- * exact problem can be found here -
- * https://github.com/facebook/draft-js/commit/07892ba479bd4dfc6afd1e0ed179aaf51cd138b1
- *
- * 2. intended to handle spellcheck and autocorrect changes,
- * which occur in the DOM natively without any opportunity to observe or
- * interpret the changes before they occur.
- *
- * The `input` event fires in contentEditable elements reliably for non-IE
- * browsers, immediately after changes occur to the editor DOM. Since our other
- * handlers override or otherwise handle cover other varieties of text input,
- * the DOM state should match the model in all controlled input cases. Thus,
- * when an `input` change leads to a DOM/model mismatch, the change should be
- * due to a spellcheck change, and we can incorporate it into our model.
- */
-
-
- function editOnInput(editor, e) {
- if (editor._pendingStateFromBeforeInput !== undefined) {
- editor.update(editor._pendingStateFromBeforeInput);
- editor._pendingStateFromBeforeInput = undefined;
- } // at this point editor is not null for sure (after input)
-
-
- var castedEditorElement = editor.editor;
- var domSelection = castedEditorElement.ownerDocument.defaultView.getSelection();
- var anchorNode = domSelection.anchorNode,
- isCollapsed = domSelection.isCollapsed;
- var isNotTextOrElementNode = (anchorNode === null || anchorNode === void 0 ? void 0 : anchorNode.nodeType) !== Node.TEXT_NODE && (anchorNode === null || anchorNode === void 0 ? void 0 : anchorNode.nodeType) !== Node.ELEMENT_NODE;
-
- if (isNotTextOrElementNode) {
- // TODO: (t16149272) figure out context for this change
- return;
- }
-
- if (anchorNode.nodeType === Node.TEXT_NODE && (anchorNode.previousSibling !== null || anchorNode.nextSibling !== null)) {
- // When typing at the beginning of a visual line, Chrome splits the text
- // nodes into two. Why? No one knows. This commit is suspicious:
- // https://chromium.googlesource.com/chromium/src/+/a3b600981286b135632371477f902214c55a1724
- // To work around, we'll merge the sibling text nodes back into this one.
- var span = anchorNode.parentNode;
- anchorNode.nodeValue = span.textContent;
-
- for (var child = span.firstChild; child !== null; child = child.nextSibling) {
- if (child !== anchorNode) {
- span.removeChild(child);
- }
- }
- }
-
- var domText = anchorNode.textContent;
- var editorState = editor._latestEditorState;
- var offsetKey = nullthrows(findAncestorOffsetKey(anchorNode));
-
- var _DraftOffsetKey$decod = DraftOffsetKey.decode(offsetKey),
- blockKey = _DraftOffsetKey$decod.blockKey,
- decoratorKey = _DraftOffsetKey$decod.decoratorKey,
- leafKey = _DraftOffsetKey$decod.leafKey;
-
- var _editorState$getBlock = editorState.getBlockTree(blockKey).getIn([decoratorKey, 'leaves', leafKey]),
- start = _editorState$getBlock.start,
- end = _editorState$getBlock.end;
-
- var content = editorState.getCurrentContent();
- var block = content.getBlockForKey(blockKey);
- var modelText = block.getText().slice(start, end); // Special-case soft newlines here. If the DOM text ends in a soft newline,
- // we will have manually inserted an extra soft newline in DraftEditorLeaf.
- // We want to remove this extra newline for the purpose of our comparison
- // of DOM and model text.
-
- if (domText.endsWith(DOUBLE_NEWLINE)) {
- domText = domText.slice(0, -1);
- } // No change -- the DOM is up to date. Nothing to do here.
-
-
- if (domText === modelText) {
- // This can be buggy for some Android keyboards because they don't fire
- // standard onkeydown/pressed events and only fired editOnInput
- // so domText is already changed by the browser and ends up being equal
- // to modelText unexpectedly.
- // Newest versions of Android support the dom-inputevent-inputtype
- // and we can use the `inputType` to properly apply the state changes.
-
- /* $FlowFixMe inputType is only defined on a draft of a standard.
- * https://w3c.github.io/input-events/#dom-inputevent-inputtype */
- var inputType = e.nativeEvent.inputType;
-
- if (inputType) {
- var newEditorState = onInputType(inputType, editorState);
-
- if (newEditorState !== editorState) {
- editor.restoreEditorDOM();
- editor.update(newEditorState);
- return;
- }
- }
-
- return;
- }
-
- var selection = editorState.getSelection(); // We'll replace the entire leaf with the text content of the target.
-
- var targetRange = selection.merge({
- anchorOffset: start,
- focusOffset: end,
- isBackward: false
- });
- var entityKey = block.getEntityAt(start);
- var entity = notEmptyKey(entityKey) ? content.getEntity(entityKey) : null;
- var entityType = entity != null ? entity.getMutability() : null;
- var preserveEntity = entityType === 'MUTABLE'; // Immutable or segmented entities cannot properly be handled by the
- // default browser undo, so we have to use a different change type to
- // force using our internal undo method instead of falling through to the
- // native browser undo.
-
- var changeType = preserveEntity ? 'spellcheck-change' : 'apply-entity';
- var newContent = DraftModifier.replaceText(content, targetRange, domText, block.getInlineStyleAt(start), preserveEntity ? block.getEntityAt(start) : null);
- var anchorOffset, focusOffset, startOffset, endOffset;
-
- if (isGecko) {
- // Firefox selection does not change while the context menu is open, so
- // we preserve the anchor and focus values of the DOM selection.
- anchorOffset = domSelection.anchorOffset;
- focusOffset = domSelection.focusOffset;
- startOffset = start + Math.min(anchorOffset, focusOffset);
- endOffset = startOffset + Math.abs(anchorOffset - focusOffset);
- anchorOffset = startOffset;
- focusOffset = endOffset;
- } else {
- // Browsers other than Firefox may adjust DOM selection while the context
- // menu is open, and Safari autocorrect is prone to providing an inaccurate
- // DOM selection. Don't trust it. Instead, use our existing SelectionState
- // and adjust it based on the number of characters changed during the
- // mutation.
- var charDelta = domText.length - modelText.length;
- startOffset = selection.getStartOffset();
- endOffset = selection.getEndOffset();
- anchorOffset = isCollapsed ? endOffset + charDelta : startOffset;
- focusOffset = endOffset + charDelta;
- } // Segmented entities are completely or partially removed when their
- // text content changes. For this case we do not want any text to be selected
- // after the change, so we are not merging the selection.
-
-
- var contentWithAdjustedDOMSelection = newContent.merge({
- selectionBefore: content.getSelectionAfter(),
- selectionAfter: selection.merge({
- anchorOffset: anchorOffset,
- focusOffset: focusOffset
- })
- });
- editor.update(EditorState.push(editorState, contentWithAdjustedDOMSelection, changeType));
- }
-
- module.exports = editOnInput;
-
- /***/ }),
- /* 139 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftModifier = __webpack_require__(3);
-
- var EditorState = __webpack_require__(2);
-
- var KeyBindingUtil = __webpack_require__(40);
-
- var Keys = __webpack_require__(28);
-
- var SecondaryClipboard = __webpack_require__(141);
-
- var UserAgent = __webpack_require__(5);
-
- var isEventHandled = __webpack_require__(31);
-
- var keyCommandBackspaceToStartOfLine = __webpack_require__(142);
-
- var keyCommandBackspaceWord = __webpack_require__(144);
-
- var keyCommandDeleteWord = __webpack_require__(146);
-
- var keyCommandInsertNewline = __webpack_require__(147);
-
- var keyCommandMoveSelectionToEndOfBlock = __webpack_require__(148);
-
- var keyCommandMoveSelectionToStartOfBlock = __webpack_require__(149);
-
- var keyCommandPlainBackspace = __webpack_require__(69);
-
- var keyCommandPlainDelete = __webpack_require__(150);
-
- var keyCommandTransposeCharacters = __webpack_require__(151);
-
- var keyCommandUndo = __webpack_require__(152);
-
- var isOptionKeyCommand = KeyBindingUtil.isOptionKeyCommand;
- var isChrome = UserAgent.isBrowser('Chrome');
- /**
- * Map a `DraftEditorCommand` command value to a corresponding function.
- */
-
- function onKeyCommand(command, editorState, e) {
- switch (command) {
- case 'redo':
- return EditorState.redo(editorState);
-
- case 'delete':
- return keyCommandPlainDelete(editorState);
-
- case 'delete-word':
- return keyCommandDeleteWord(editorState);
-
- case 'backspace':
- return keyCommandPlainBackspace(editorState);
-
- case 'backspace-word':
- return keyCommandBackspaceWord(editorState);
-
- case 'backspace-to-start-of-line':
- return keyCommandBackspaceToStartOfLine(editorState, e);
-
- case 'split-block':
- return keyCommandInsertNewline(editorState);
-
- case 'transpose-characters':
- return keyCommandTransposeCharacters(editorState);
-
- case 'move-selection-to-start-of-block':
- return keyCommandMoveSelectionToStartOfBlock(editorState);
-
- case 'move-selection-to-end-of-block':
- return keyCommandMoveSelectionToEndOfBlock(editorState);
-
- case 'secondary-cut':
- return SecondaryClipboard.cut(editorState);
-
- case 'secondary-paste':
- return SecondaryClipboard.paste(editorState);
-
- default:
- return editorState;
- }
- }
- /**
- * Intercept keydown behavior to handle keys and commands manually, if desired.
- *
- * Keydown combinations may be mapped to `DraftCommand` values, which may
- * correspond to command functions that modify the editor or its contents.
- *
- * See `getDefaultKeyBinding` for defaults. Alternatively, the top-level
- * component may provide a custom mapping via the `keyBindingFn` prop.
- */
-
-
- function editOnKeyDown(editor, e) {
- var keyCode = e.which;
- var editorState = editor._latestEditorState;
-
- function callDeprecatedHandler(handlerName) {
- var deprecatedHandler = editor.props[handlerName];
-
- if (deprecatedHandler) {
- deprecatedHandler(e);
- return true;
- } else {
- return false;
- }
- }
-
- switch (keyCode) {
- case Keys.RETURN:
- e.preventDefault(); // The top-level component may manually handle newline insertion. If
- // no special handling is performed, fall through to command handling.
-
- if (editor.props.handleReturn && isEventHandled(editor.props.handleReturn(e, editorState))) {
- return;
- }
-
- break;
-
- case Keys.ESC:
- e.preventDefault();
-
- if (callDeprecatedHandler('onEscape')) {
- return;
- }
-
- break;
-
- case Keys.TAB:
- if (callDeprecatedHandler('onTab')) {
- return;
- }
-
- break;
-
- case Keys.UP:
- if (callDeprecatedHandler('onUpArrow')) {
- return;
- }
-
- break;
-
- case Keys.RIGHT:
- if (callDeprecatedHandler('onRightArrow')) {
- return;
- }
-
- break;
-
- case Keys.DOWN:
- if (callDeprecatedHandler('onDownArrow')) {
- return;
- }
-
- break;
-
- case Keys.LEFT:
- if (callDeprecatedHandler('onLeftArrow')) {
- return;
- }
-
- break;
-
- case Keys.SPACE:
- // Prevent Chrome on OSX behavior where option + space scrolls.
- if (isChrome && isOptionKeyCommand(e)) {
- e.preventDefault();
- }
-
- }
-
- var command = editor.props.keyBindingFn(e); // If no command is specified, allow keydown event to continue.
-
- if (command == null || command === '') {
- if (keyCode === Keys.SPACE && isChrome && isOptionKeyCommand(e)) {
- // The default keydown event has already been prevented in order to stop
- // Chrome from scrolling. Insert a nbsp into the editor as OSX would for
- // other browsers.
- var contentState = DraftModifier.replaceText(editorState.getCurrentContent(), editorState.getSelection(), "\xA0");
- editor.update(EditorState.push(editorState, contentState, 'insert-characters'));
- }
-
- return;
- }
-
- if (command === 'undo') {
- // Since undo requires some special updating behavior to keep the editor
- // in sync, handle it separately.
- keyCommandUndo(e, editorState, editor.update);
- return;
- } // At this point, we know that we're handling a command of some kind, so
- // we don't want to insert a character following the keydown.
-
-
- e.preventDefault(); // Allow components higher up the tree to handle the command first.
-
- if (editor.props.handleKeyCommand && isEventHandled(editor.props.handleKeyCommand(command, editorState, e.timeStamp))) {
- return;
- }
-
- var newState = onKeyCommand(command, editorState, e);
-
- if (newState !== editorState) {
- editor.update(newState);
- }
- }
-
- module.exports = editOnKeyDown;
-
- /***/ }),
- /* 140 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var Keys = __webpack_require__(28);
-
- function isSoftNewlineEvent(e) {
- return e.which === Keys.RETURN && (e.getModifierState('Shift') || e.getModifierState('Alt') || e.getModifierState('Control'));
- }
-
- module.exports = isSoftNewlineEvent;
-
- /***/ }),
- /* 141 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftModifier = __webpack_require__(3);
-
- var EditorState = __webpack_require__(2);
-
- var getContentStateFragment = __webpack_require__(21);
-
- var nullthrows = __webpack_require__(4);
-
- var clipboard = null;
- /**
- * Some systems offer a "secondary" clipboard to allow quick internal cut
- * and paste behavior. For instance, Ctrl+K (cut) and Ctrl+Y (paste).
- */
-
- var SecondaryClipboard = {
- cut: function cut(editorState) {
- var content = editorState.getCurrentContent();
- var selection = editorState.getSelection();
- var targetRange = null;
-
- if (selection.isCollapsed()) {
- var anchorKey = selection.getAnchorKey();
- var blockEnd = content.getBlockForKey(anchorKey).getLength();
-
- if (blockEnd === selection.getAnchorOffset()) {
- var keyAfter = content.getKeyAfter(anchorKey);
-
- if (keyAfter == null) {
- return editorState;
- }
-
- targetRange = selection.set('focusKey', keyAfter).set('focusOffset', 0);
- } else {
- targetRange = selection.set('focusOffset', blockEnd);
- }
- } else {
- targetRange = selection;
- }
-
- targetRange = nullthrows(targetRange); // TODO: This should actually append to the current state when doing
- // successive ^K commands without any other cursor movement
-
- clipboard = getContentStateFragment(content, targetRange);
- var afterRemoval = DraftModifier.removeRange(content, targetRange, 'forward');
-
- if (afterRemoval === content) {
- return editorState;
- }
-
- return EditorState.push(editorState, afterRemoval, 'remove-range');
- },
- paste: function paste(editorState) {
- if (!clipboard) {
- return editorState;
- }
-
- var newContent = DraftModifier.replaceWithFragment(editorState.getCurrentContent(), editorState.getSelection(), clipboard);
- return EditorState.push(editorState, newContent, 'insert-fragment');
- }
- };
- module.exports = SecondaryClipboard;
-
- /***/ }),
- /* 142 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var EditorState = __webpack_require__(2);
-
- var expandRangeToStartOfLine = __webpack_require__(143);
-
- var getDraftEditorSelectionWithNodes = __webpack_require__(55);
-
- var moveSelectionBackward = __webpack_require__(38);
-
- var removeTextWithStrategy = __webpack_require__(20);
-
- function keyCommandBackspaceToStartOfLine(editorState, e) {
- var afterRemoval = removeTextWithStrategy(editorState, function (strategyState) {
- var selection = strategyState.getSelection();
-
- if (selection.isCollapsed() && selection.getAnchorOffset() === 0) {
- return moveSelectionBackward(strategyState, 1);
- }
-
- var ownerDocument = e.currentTarget.ownerDocument;
- var domSelection = ownerDocument.defaultView.getSelection();
- var range = domSelection.getRangeAt(0);
- range = expandRangeToStartOfLine(range);
- return getDraftEditorSelectionWithNodes(strategyState, null, range.endContainer, range.endOffset, range.startContainer, range.startOffset).selectionState;
- }, 'backward');
-
- if (afterRemoval === editorState.getCurrentContent()) {
- return editorState;
- }
-
- return EditorState.push(editorState, afterRemoval, 'remove-range');
- }
-
- module.exports = keyCommandBackspaceToStartOfLine;
-
- /***/ }),
- /* 143 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
- var UnicodeUtils = __webpack_require__(16);
-
- var getCorrectDocumentFromNode = __webpack_require__(27);
-
- var getRangeClientRects = __webpack_require__(70);
-
- var invariant = __webpack_require__(1);
- /**
- * Return the computed line height, in pixels, for the provided element.
- */
-
-
- function getLineHeightPx(element) {
- var computed = getComputedStyle(element);
- var correctDocument = getCorrectDocumentFromNode(element);
- var div = correctDocument.createElement('div');
- div.style.fontFamily = computed.fontFamily;
- div.style.fontSize = computed.fontSize;
- div.style.fontStyle = computed.fontStyle;
- div.style.fontWeight = computed.fontWeight;
- div.style.lineHeight = computed.lineHeight;
- div.style.position = 'absolute';
- div.textContent = 'M';
- var documentBody = correctDocument.body;
- !documentBody ? true ? invariant(false, 'Missing document.body') : invariant(false) : void 0; // forced layout here
-
- documentBody.appendChild(div);
- var rect = div.getBoundingClientRect();
- documentBody.removeChild(div);
- return rect.height;
- }
- /**
- * Return whether every ClientRect in the provided list lies on the same line.
- *
- * We assume that the rects on the same line all contain the baseline, so the
- * lowest top line needs to be above the highest bottom line (i.e., if you were
- * to project the rects onto the y-axis, their intersection would be nonempty).
- *
- * In addition, we require that no two boxes are lineHeight (or more) apart at
- * either top or bottom, which helps protect against false positives for fonts
- * with extremely large glyph heights (e.g., with a font size of 17px, Zapfino
- * produces rects of height 58px!).
- */
-
-
- function areRectsOnOneLine(rects, lineHeight) {
- var minTop = Infinity;
- var minBottom = Infinity;
- var maxTop = -Infinity;
- var maxBottom = -Infinity;
-
- for (var ii = 0; ii < rects.length; ii++) {
- var rect = rects[ii];
-
- if (rect.width === 0 || rect.width === 1) {
- // When a range starts or ends a soft wrap, many browsers (Chrome, IE,
- // Safari) include an empty rect on the previous or next line. When the
- // text lies in a container whose position is not integral (e.g., from
- // margin: auto), Safari makes these empty rects have width 1 (instead of
- // 0). Having one-pixel-wide characters seems unlikely (and most browsers
- // report widths in subpixel precision anyway) so it's relatively safe to
- // skip over them.
- continue;
- }
-
- minTop = Math.min(minTop, rect.top);
- minBottom = Math.min(minBottom, rect.bottom);
- maxTop = Math.max(maxTop, rect.top);
- maxBottom = Math.max(maxBottom, rect.bottom);
- }
-
- return maxTop <= minBottom && maxTop - minTop < lineHeight && maxBottom - minBottom < lineHeight;
- }
- /**
- * Return the length of a node, as used by Range offsets.
- */
-
-
- function getNodeLength(node) {
- // http://www.w3.org/TR/dom/#concept-node-length
- switch (node.nodeType) {
- case Node.DOCUMENT_TYPE_NODE:
- return 0;
-
- case Node.TEXT_NODE:
- case Node.PROCESSING_INSTRUCTION_NODE:
- case Node.COMMENT_NODE:
- return node.length;
-
- default:
- return node.childNodes.length;
- }
- }
- /**
- * Given a collapsed range, move the start position backwards as far as
- * possible while the range still spans only a single line.
- */
-
-
- function expandRangeToStartOfLine(range) {
- !range.collapsed ? true ? invariant(false, 'expandRangeToStartOfLine: Provided range is not collapsed.') : invariant(false) : void 0;
- range = range.cloneRange();
- var containingElement = range.startContainer;
-
- if (containingElement.nodeType !== 1) {
- containingElement = containingElement.parentNode;
- }
-
- var lineHeight = getLineHeightPx(containingElement); // Imagine our text looks like:
- // <div><span>once upon a time, there was a <em>boy
- // who lived</em> </span><q><strong>under^ the
- // stairs</strong> in a small closet.</q></div>
- // where the caret represents the cursor. First, we crawl up the tree until
- // the range spans multiple lines (setting the start point to before
- // "<strong>", then before "<div>"), then at each level we do a search to
- // find the latest point which is still on a previous line. We'll find that
- // the break point is inside the span, then inside the <em>, then in its text
- // node child, the actual break point before "who".
-
- var bestContainer = range.endContainer;
- var bestOffset = range.endOffset;
- range.setStart(range.startContainer, 0);
-
- while (areRectsOnOneLine(getRangeClientRects(range), lineHeight)) {
- bestContainer = range.startContainer;
- bestOffset = range.startOffset;
- !bestContainer.parentNode ? true ? invariant(false, 'Found unexpected detached subtree when traversing.') : invariant(false) : void 0;
- range.setStartBefore(bestContainer);
-
- if (bestContainer.nodeType === 1 && getComputedStyle(bestContainer).display !== 'inline') {
- // The start of the line is never in a different block-level container.
- break;
- }
- } // In the above example, range now spans from "<div>" to "under",
- // bestContainer is <div>, and bestOffset is 1 (index of <q> inside <div>)].
- // Picking out which child to recurse into here is a special case since we
- // don't want to check past <q> -- once we find that the final range starts
- // in <span>, we can look at all of its children (and all of their children)
- // to find the break point.
- // At all times, (bestContainer, bestOffset) is the latest single-line start
- // point that we know of.
-
-
- var currentContainer = bestContainer;
- var maxIndexToConsider = bestOffset - 1;
-
- do {
- var nodeValue = currentContainer.nodeValue;
- var ii = maxIndexToConsider;
-
- for (; ii >= 0; ii--) {
- if (nodeValue != null && ii > 0 && UnicodeUtils.isSurrogatePair(nodeValue, ii - 1)) {
- // We're in the middle of a surrogate pair -- skip over so we never
- // return a range with an endpoint in the middle of a code point.
- continue;
- }
-
- range.setStart(currentContainer, ii);
-
- if (areRectsOnOneLine(getRangeClientRects(range), lineHeight)) {
- bestContainer = currentContainer;
- bestOffset = ii;
- } else {
- break;
- }
- }
-
- if (ii === -1 || currentContainer.childNodes.length === 0) {
- // If ii === -1, then (bestContainer, bestOffset), which is equal to
- // (currentContainer, 0), was a single-line start point but a start
- // point before currentContainer wasn't, so the line break seems to
- // have occurred immediately after currentContainer's start tag
- //
- // If currentContainer.childNodes.length === 0, we're already at a
- // terminal node (e.g., text node) and should return our current best.
- break;
- }
-
- currentContainer = currentContainer.childNodes[ii];
- maxIndexToConsider = getNodeLength(currentContainer);
- } while (true);
-
- range.setStart(bestContainer, bestOffset);
- return range;
- }
-
- module.exports = expandRangeToStartOfLine;
-
- /***/ }),
- /* 144 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftRemovableWord = __webpack_require__(71);
-
- var EditorState = __webpack_require__(2);
-
- var moveSelectionBackward = __webpack_require__(38);
-
- var removeTextWithStrategy = __webpack_require__(20);
- /**
- * Delete the word that is left of the cursor, as well as any spaces or
- * punctuation after the word.
- */
-
-
- function keyCommandBackspaceWord(editorState) {
- var afterRemoval = removeTextWithStrategy(editorState, function (strategyState) {
- var selection = strategyState.getSelection();
- var offset = selection.getStartOffset(); // If there are no words before the cursor, remove the preceding newline.
-
- if (offset === 0) {
- return moveSelectionBackward(strategyState, 1);
- }
-
- var key = selection.getStartKey();
- var content = strategyState.getCurrentContent();
- var text = content.getBlockForKey(key).getText().slice(0, offset);
- var toRemove = DraftRemovableWord.getBackward(text);
- return moveSelectionBackward(strategyState, toRemove.length || 1);
- }, 'backward');
-
- if (afterRemoval === editorState.getCurrentContent()) {
- return editorState;
- }
-
- return EditorState.push(editorState, afterRemoval, 'remove-range');
- }
-
- module.exports = keyCommandBackspaceWord;
-
- /***/ }),
- /* 145 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- * @stub
- *
- */
- // \u00a1-\u00b1\u00b4-\u00b8\u00ba\u00bb\u00bf
- // is latin supplement punctuation except fractions and superscript
- // numbers
- // \u2010-\u2027\u2030-\u205e
- // is punctuation from the general punctuation block:
- // weird quotes, commas, bullets, dashes, etc.
- // \u30fb\u3001\u3002\u3008-\u3011\u3014-\u301f
- // is CJK punctuation
- // \uff1a-\uff1f\uff01-\uff0f\uff3b-\uff40\uff5b-\uff65
- // is some full-width/half-width punctuation
- // \u2E2E\u061f\u066a-\u066c\u061b\u060c\u060d\uFD3e\uFD3F
- // is some Arabic punctuation marks
- // \u1801\u0964\u104a\u104b
- // is misc. other language punctuation marks
-
- var PUNCTUATION = '[.,+*?$|#{}()\'\\^\\-\\[\\]\\\\\\/!@%"~=<>_:;' + "\u30FB\u3001\u3002\u3008-\u3011\u3014-\u301F\uFF1A-\uFF1F\uFF01-\uFF0F" + "\uFF3B-\uFF40\uFF5B-\uFF65\u2E2E\u061F\u066A-\u066C\u061B\u060C\u060D" + "\uFD3E\uFD3F\u1801\u0964\u104A\u104B\u2010-\u2027\u2030-\u205E" + "\xA1-\xB1\xB4-\xB8\xBA\xBB\xBF]";
- module.exports = {
- getPunctuation: function getPunctuation() {
- return PUNCTUATION;
- }
- };
-
- /***/ }),
- /* 146 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftRemovableWord = __webpack_require__(71);
-
- var EditorState = __webpack_require__(2);
-
- var moveSelectionForward = __webpack_require__(72);
-
- var removeTextWithStrategy = __webpack_require__(20);
- /**
- * Delete the word that is right of the cursor, as well as any spaces or
- * punctuation before the word.
- */
-
-
- function keyCommandDeleteWord(editorState) {
- var afterRemoval = removeTextWithStrategy(editorState, function (strategyState) {
- var selection = strategyState.getSelection();
- var offset = selection.getStartOffset();
- var key = selection.getStartKey();
- var content = strategyState.getCurrentContent();
- var text = content.getBlockForKey(key).getText().slice(offset);
- var toRemove = DraftRemovableWord.getForward(text); // If there are no words in front of the cursor, remove the newline.
-
- return moveSelectionForward(strategyState, toRemove.length || 1);
- }, 'forward');
-
- if (afterRemoval === editorState.getCurrentContent()) {
- return editorState;
- }
-
- return EditorState.push(editorState, afterRemoval, 'remove-range');
- }
-
- module.exports = keyCommandDeleteWord;
-
- /***/ }),
- /* 147 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftModifier = __webpack_require__(3);
-
- var EditorState = __webpack_require__(2);
-
- function keyCommandInsertNewline(editorState) {
- var contentState = DraftModifier.splitBlock(editorState.getCurrentContent(), editorState.getSelection());
- return EditorState.push(editorState, contentState, 'split-block');
- }
-
- module.exports = keyCommandInsertNewline;
-
- /***/ }),
- /* 148 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var EditorState = __webpack_require__(2);
- /**
- * See comment for `moveSelectionToStartOfBlock`.
- */
-
-
- function keyCommandMoveSelectionToEndOfBlock(editorState) {
- var selection = editorState.getSelection();
- var endKey = selection.getEndKey();
- var content = editorState.getCurrentContent();
- var textLength = content.getBlockForKey(endKey).getLength();
- return EditorState.set(editorState, {
- selection: selection.merge({
- anchorKey: endKey,
- anchorOffset: textLength,
- focusKey: endKey,
- focusOffset: textLength,
- isBackward: false
- }),
- forceSelection: true
- });
- }
-
- module.exports = keyCommandMoveSelectionToEndOfBlock;
-
- /***/ }),
- /* 149 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var EditorState = __webpack_require__(2);
- /**
- * Collapse selection at the start of the first selected block. This is used
- * for Firefox versions that attempt to navigate forward/backward instead of
- * moving the cursor. Other browsers are able to move the cursor natively.
- */
-
-
- function keyCommandMoveSelectionToStartOfBlock(editorState) {
- var selection = editorState.getSelection();
- var startKey = selection.getStartKey();
- return EditorState.set(editorState, {
- selection: selection.merge({
- anchorKey: startKey,
- anchorOffset: 0,
- focusKey: startKey,
- focusOffset: 0,
- isBackward: false
- }),
- forceSelection: true
- });
- }
-
- module.exports = keyCommandMoveSelectionToStartOfBlock;
-
- /***/ }),
- /* 150 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var EditorState = __webpack_require__(2);
-
- var UnicodeUtils = __webpack_require__(16);
-
- var moveSelectionForward = __webpack_require__(72);
-
- var removeTextWithStrategy = __webpack_require__(20);
- /**
- * Remove the selected range. If the cursor is collapsed, remove the following
- * character. This operation is Unicode-aware, so removing a single character
- * will remove a surrogate pair properly as well.
- */
-
-
- function keyCommandPlainDelete(editorState) {
- var afterRemoval = removeTextWithStrategy(editorState, function (strategyState) {
- var selection = strategyState.getSelection();
- var content = strategyState.getCurrentContent();
- var key = selection.getAnchorKey();
- var offset = selection.getAnchorOffset();
- var charAhead = content.getBlockForKey(key).getText()[offset];
- return moveSelectionForward(strategyState, charAhead ? UnicodeUtils.getUTF16Length(charAhead, 0) : 1);
- }, 'forward');
-
- if (afterRemoval === editorState.getCurrentContent()) {
- return editorState;
- }
-
- var selection = editorState.getSelection();
- return EditorState.push(editorState, afterRemoval.set('selectionBefore', selection), selection.isCollapsed() ? 'delete-character' : 'remove-range');
- }
-
- module.exports = keyCommandPlainDelete;
-
- /***/ }),
- /* 151 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftModifier = __webpack_require__(3);
-
- var EditorState = __webpack_require__(2);
-
- var getContentStateFragment = __webpack_require__(21);
- /**
- * Transpose the characters on either side of a collapsed cursor, or
- * if the cursor is at the end of the block, transpose the last two
- * characters.
- */
-
-
- function keyCommandTransposeCharacters(editorState) {
- var selection = editorState.getSelection();
-
- if (!selection.isCollapsed()) {
- return editorState;
- }
-
- var offset = selection.getAnchorOffset();
-
- if (offset === 0) {
- return editorState;
- }
-
- var blockKey = selection.getAnchorKey();
- var content = editorState.getCurrentContent();
- var block = content.getBlockForKey(blockKey);
- var length = block.getLength(); // Nothing to transpose if there aren't two characters.
-
- if (length <= 1) {
- return editorState;
- }
-
- var removalRange;
- var finalSelection;
-
- if (offset === length) {
- // The cursor is at the end of the block. Swap the last two characters.
- removalRange = selection.set('anchorOffset', offset - 1);
- finalSelection = selection;
- } else {
- removalRange = selection.set('focusOffset', offset + 1);
- finalSelection = removalRange.set('anchorOffset', offset + 1);
- } // Extract the character to move as a fragment. This preserves its
- // styling and entity, if any.
-
-
- var movedFragment = getContentStateFragment(content, removalRange);
- var afterRemoval = DraftModifier.removeRange(content, removalRange, 'backward'); // After the removal, the insertion target is one character back.
-
- var selectionAfter = afterRemoval.getSelectionAfter();
- var targetOffset = selectionAfter.getAnchorOffset() - 1;
- var targetRange = selectionAfter.merge({
- anchorOffset: targetOffset,
- focusOffset: targetOffset
- });
- var afterInsert = DraftModifier.replaceWithFragment(afterRemoval, targetRange, movedFragment);
- var newEditorState = EditorState.push(editorState, afterInsert, 'insert-fragment');
- return EditorState.acceptSelection(newEditorState, finalSelection);
- }
-
- module.exports = keyCommandTransposeCharacters;
-
- /***/ }),
- /* 152 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var EditorState = __webpack_require__(2);
-
- function keyCommandUndo(e, editorState, updateFn) {
- var undoneState = EditorState.undo(editorState); // If the last change to occur was a spellcheck change, allow the undo
- // event to fall through to the browser. This allows the browser to record
- // the unwanted change, which should soon lead it to learn not to suggest
- // the correction again.
-
- if (editorState.getLastChangeType() === 'spellcheck-change') {
- var nativelyRenderedContent = undoneState.getCurrentContent();
- updateFn(EditorState.set(undoneState, {
- nativelyRenderedContent: nativelyRenderedContent
- }));
- return;
- } // Otheriwse, manage the undo behavior manually.
-
-
- e.preventDefault();
-
- if (!editorState.getNativelyRenderedContent()) {
- updateFn(undoneState);
- return;
- } // Trigger a re-render with the current content state to ensure that the
- // component tree has up-to-date props for comparison.
-
-
- updateFn(EditorState.set(editorState, {
- nativelyRenderedContent: null
- })); // Wait to ensure that the re-render has occurred before performing
- // the undo action.
-
- setTimeout(function () {
- updateFn(undoneState);
- }, 0);
- }
-
- module.exports = keyCommandUndo;
-
- /***/ }),
- /* 153 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var BlockMapBuilder = __webpack_require__(17);
-
- var CharacterMetadata = __webpack_require__(6);
-
- var DataTransfer = __webpack_require__(65);
-
- var DraftModifier = __webpack_require__(3);
-
- var DraftPasteProcessor = __webpack_require__(154);
-
- var EditorState = __webpack_require__(2);
-
- var RichTextEditorUtil = __webpack_require__(75);
-
- var getEntityKeyForSelection = __webpack_require__(35);
-
- var getTextContentFromFiles = __webpack_require__(67);
-
- var isEventHandled = __webpack_require__(31);
-
- var splitTextIntoTextBlocks = __webpack_require__(159);
- /**
- * Paste content.
- */
-
-
- function editOnPaste(editor, e) {
- e.preventDefault();
- var data = new DataTransfer(e.clipboardData); // Get files, unless this is likely to be a string the user wants inline.
-
- if (!data.isRichText()) {
- var files = data.getFiles();
- var defaultFileText = data.getText();
-
- if (files.length > 0) {
- // Allow customized paste handling for images, etc. Otherwise, fall
- // through to insert text contents into the editor.
- if (editor.props.handlePastedFiles && isEventHandled(editor.props.handlePastedFiles(files))) {
- return;
- }
- /* $FlowFixMe This comment suppresses an error found DataTransfer was
- * typed. getFiles() returns an array of <Files extends Blob>, not Blob
- */
-
-
- getTextContentFromFiles(files, function (
- /*string*/
- fileText) {
- fileText = fileText || defaultFileText;
-
- if (!fileText) {
- return;
- }
-
- var editorState = editor._latestEditorState;
- var blocks = splitTextIntoTextBlocks(fileText);
- var character = CharacterMetadata.create({
- style: editorState.getCurrentInlineStyle(),
- entity: getEntityKeyForSelection(editorState.getCurrentContent(), editorState.getSelection())
- });
- var currentBlockType = RichTextEditorUtil.getCurrentBlockType(editorState);
- var text = DraftPasteProcessor.processText(blocks, character, currentBlockType);
- var fragment = BlockMapBuilder.createFromArray(text);
- var withInsertedText = DraftModifier.replaceWithFragment(editorState.getCurrentContent(), editorState.getSelection(), fragment);
- editor.update(EditorState.push(editorState, withInsertedText, 'insert-fragment'));
- });
- return;
- }
- }
-
- var textBlocks = [];
- var text = data.getText();
- var html = data.getHTML();
- var editorState = editor._latestEditorState;
-
- if (editor.props.handlePastedText && isEventHandled(editor.props.handlePastedText(text, html, editorState))) {
- return;
- }
-
- if (text) {
- textBlocks = splitTextIntoTextBlocks(text);
- }
-
- if (!editor.props.stripPastedStyles) {
- // If the text from the paste event is rich content that matches what we
- // already have on the internal clipboard, assume that we should just use
- // the clipboard fragment for the paste. This will allow us to preserve
- // styling and entities, if any are present. Note that newlines are
- // stripped during comparison -- this is because copy/paste within the
- // editor in Firefox and IE will not include empty lines. The resulting
- // paste will preserve the newlines correctly.
- var internalClipboard = editor.getClipboard();
-
- if (data.isRichText() && internalClipboard) {
- if ( // If the editorKey is present in the pasted HTML, it should be safe to
- // assume this is an internal paste.
- html.indexOf(editor.getEditorKey()) !== -1 || // The copy may have been made within a single block, in which case the
- // editor key won't be part of the paste. In this case, just check
- // whether the pasted text matches the internal clipboard.
- textBlocks.length === 1 && internalClipboard.size === 1 && internalClipboard.first().getText() === text) {
- editor.update(insertFragment(editor._latestEditorState, internalClipboard));
- return;
- }
- } else if (internalClipboard && data.types.includes('com.apple.webarchive') && !data.types.includes('text/html') && areTextBlocksAndClipboardEqual(textBlocks, internalClipboard)) {
- // Safari does not properly store text/html in some cases.
- // Use the internalClipboard if present and equal to what is on
- // the clipboard. See https://bugs.webkit.org/show_bug.cgi?id=19893.
- editor.update(insertFragment(editor._latestEditorState, internalClipboard));
- return;
- } // If there is html paste data, try to parse that.
-
-
- if (html) {
- var htmlFragment = DraftPasteProcessor.processHTML(html, editor.props.blockRenderMap);
-
- if (htmlFragment) {
- var contentBlocks = htmlFragment.contentBlocks,
- entityMap = htmlFragment.entityMap;
-
- if (contentBlocks) {
- var htmlMap = BlockMapBuilder.createFromArray(contentBlocks);
- editor.update(insertFragment(editor._latestEditorState, htmlMap, entityMap));
- return;
- }
- }
- } // Otherwise, create a new fragment from our pasted text. Also
- // empty the internal clipboard, since it's no longer valid.
-
-
- editor.setClipboard(null);
- }
-
- if (textBlocks.length) {
- var character = CharacterMetadata.create({
- style: editorState.getCurrentInlineStyle(),
- entity: getEntityKeyForSelection(editorState.getCurrentContent(), editorState.getSelection())
- });
- var currentBlockType = RichTextEditorUtil.getCurrentBlockType(editorState);
- var textFragment = DraftPasteProcessor.processText(textBlocks, character, currentBlockType);
- var textMap = BlockMapBuilder.createFromArray(textFragment);
- editor.update(insertFragment(editor._latestEditorState, textMap));
- }
- }
-
- function insertFragment(editorState, fragment, entityMap) {
- var newContent = DraftModifier.replaceWithFragment(editorState.getCurrentContent(), editorState.getSelection(), fragment); // TODO: merge the entity map once we stop using DraftEntity
- // like this:
- // const mergedEntityMap = newContent.getEntityMap().merge(entityMap);
-
- return EditorState.push(editorState, newContent.set('entityMap', entityMap), 'insert-fragment');
- }
-
- function areTextBlocksAndClipboardEqual(textBlocks, blockMap) {
- return textBlocks.length === blockMap.size && blockMap.valueSeq().every(function (block, ii) {
- return block.getText() === textBlocks[ii];
- });
- }
-
- module.exports = editOnPaste;
-
- /***/ }),
- /* 154 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- var ContentBlock = __webpack_require__(12);
-
- var ContentBlockNode = __webpack_require__(7);
-
- var convertFromHTMLToContentBlocks = __webpack_require__(73);
-
- var generateRandomKey = __webpack_require__(9);
-
- var getSafeBodyFromHTML = __webpack_require__(74);
-
- var gkx = __webpack_require__(11);
-
- var Immutable = __webpack_require__(0);
-
- var sanitizeDraftText = __webpack_require__(47);
-
- var List = Immutable.List,
- Repeat = Immutable.Repeat;
- var experimentalTreeDataSupport = gkx('draft_tree_data_support');
- var ContentBlockRecord = experimentalTreeDataSupport ? ContentBlockNode : ContentBlock;
- var DraftPasteProcessor = {
- processHTML: function processHTML(html, blockRenderMap) {
- return convertFromHTMLToContentBlocks(html, getSafeBodyFromHTML, blockRenderMap);
- },
- processText: function processText(textBlocks, character, type) {
- return textBlocks.reduce(function (acc, textLine, index) {
- textLine = sanitizeDraftText(textLine);
- var key = generateRandomKey();
- var blockNodeConfig = {
- key: key,
- type: type,
- text: textLine,
- characterList: List(Repeat(character, textLine.length))
- }; // next block updates previous block
-
- if (experimentalTreeDataSupport && index !== 0) {
- var prevSiblingIndex = index - 1; // update previous block
-
- var previousBlock = acc[prevSiblingIndex] = acc[prevSiblingIndex].merge({
- nextSibling: key
- });
- blockNodeConfig = _objectSpread({}, blockNodeConfig, {
- prevSibling: previousBlock.getKey()
- });
- }
-
- acc.push(new ContentBlockRecord(blockNodeConfig));
- return acc;
- }, []);
- }
- };
- module.exports = DraftPasteProcessor;
-
- /***/ }),
- /* 155 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- */
-
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- var URI =
- /*#__PURE__*/
- function () {
- function URI(uri) {
- _defineProperty(this, "_uri", void 0);
-
- this._uri = uri;
- }
-
- var _proto = URI.prototype;
-
- _proto.toString = function toString() {
- return this._uri;
- };
-
- return URI;
- }();
-
- module.exports = URI;
-
- /***/ }),
- /* 156 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
- var isElement = __webpack_require__(15);
-
- function isHTMLAnchorElement(node) {
- if (!node || !node.ownerDocument) {
- return false;
- }
-
- return isElement(node) && node.nodeName === 'A';
- }
-
- module.exports = isHTMLAnchorElement;
-
- /***/ }),
- /* 157 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
- var isElement = __webpack_require__(15);
-
- function isHTMLImageElement(node) {
- if (!node || !node.ownerDocument) {
- return false;
- }
-
- return isElement(node) && node.nodeName === 'IMG';
- }
-
- module.exports = isHTMLImageElement;
-
- /***/ }),
- /* 158 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function adjustBlockDepthForContentState(contentState, selectionState, adjustment, maxDepth) {
- var startKey = selectionState.getStartKey();
- var endKey = selectionState.getEndKey();
- var blockMap = contentState.getBlockMap();
- var blocks = blockMap.toSeq().skipUntil(function (_, k) {
- return k === startKey;
- }).takeUntil(function (_, k) {
- return k === endKey;
- }).concat([[endKey, blockMap.get(endKey)]]).map(function (block) {
- var depth = block.getDepth() + adjustment;
- depth = Math.max(0, Math.min(depth, maxDepth));
- return block.set('depth', depth);
- });
- blockMap = blockMap.merge(blocks);
- return contentState.merge({
- blockMap: blockMap,
- selectionBefore: selectionState,
- selectionAfter: selectionState
- });
- }
-
- module.exports = adjustBlockDepthForContentState;
-
- /***/ }),
- /* 159 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var NEWLINE_REGEX = /\r\n?|\n/g;
-
- function splitTextIntoTextBlocks(text) {
- return text.split(NEWLINE_REGEX);
- }
-
- module.exports = splitTextIntoTextBlocks;
-
- /***/ }),
- /* 160 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
- var ReactDOMComet = __webpack_require__(161);
-
- var flushControlled = ReactDOMComet.unstable_flushControlled;
- module.exports = flushControlled;
-
- /***/ }),
- /* 161 */
- /***/ (function(module, exports) {
-
- module.exports = __WEBPACK_EXTERNAL_MODULE_161__;
-
- /***/ }),
- /* 162 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
-
- var React = __webpack_require__(8);
-
- var cx = __webpack_require__(13);
-
- /**
- * This component is responsible for rendering placeholder text for the
- * `DraftEditor` component.
- *
- * Override placeholder style via CSS.
- */
- var DraftEditorPlaceholder =
- /*#__PURE__*/
- function (_React$Component) {
- _inheritsLoose(DraftEditorPlaceholder, _React$Component);
-
- function DraftEditorPlaceholder() {
- return _React$Component.apply(this, arguments) || this;
- }
-
- var _proto = DraftEditorPlaceholder.prototype;
-
- _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
- return this.props.text !== nextProps.text || this.props.editorState.getSelection().getHasFocus() !== nextProps.editorState.getSelection().getHasFocus();
- };
-
- _proto.render = function render() {
- var hasFocus = this.props.editorState.getSelection().getHasFocus();
- var className = cx({
- 'public/DraftEditorPlaceholder/root': true,
- 'public/DraftEditorPlaceholder/hasFocus': hasFocus
- });
- var contentStyle = {
- whiteSpace: 'pre-wrap'
- };
- return React.createElement("div", {
- className: className
- }, React.createElement("div", {
- className: cx('public/DraftEditorPlaceholder/inner'),
- id: this.props.accessibilityID,
- style: contentStyle
- }, this.props.text));
- };
-
- return DraftEditorPlaceholder;
- }(React.Component);
-
- module.exports = DraftEditorPlaceholder;
-
- /***/ }),
- /* 163 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- /***/ }),
- /* 164 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- var ContentBlock = __webpack_require__(12);
-
- var ContentBlockNode = __webpack_require__(7);
-
- var DraftStringKey = __webpack_require__(77);
-
- var encodeEntityRanges = __webpack_require__(165);
-
- var encodeInlineStyleRanges = __webpack_require__(166);
-
- var invariant = __webpack_require__(1);
-
- var createRawBlock = function createRawBlock(block, entityStorageMap) {
- return {
- key: block.getKey(),
- text: block.getText(),
- type: block.getType(),
- depth: block.getDepth(),
- inlineStyleRanges: encodeInlineStyleRanges(block),
- entityRanges: encodeEntityRanges(block, entityStorageMap),
- data: block.getData().toObject()
- };
- };
-
- var insertRawBlock = function insertRawBlock(block, entityMap, rawBlocks, blockCacheRef) {
- if (block instanceof ContentBlock) {
- rawBlocks.push(createRawBlock(block, entityMap));
- return;
- }
-
- !(block instanceof ContentBlockNode) ? true ? invariant(false, 'block is not a BlockNode') : invariant(false) : void 0;
- var parentKey = block.getParentKey();
-
- var rawBlock = blockCacheRef[block.getKey()] = _objectSpread({}, createRawBlock(block, entityMap), {
- children: []
- });
-
- if (parentKey) {
- blockCacheRef[parentKey].children.push(rawBlock);
- return;
- }
-
- rawBlocks.push(rawBlock);
- };
-
- var encodeRawBlocks = function encodeRawBlocks(contentState, rawState) {
- var entityMap = rawState.entityMap;
- var rawBlocks = [];
- var blockCacheRef = {};
- var entityCacheRef = {};
- var entityStorageKey = 0;
- contentState.getBlockMap().forEach(function (block) {
- block.findEntityRanges(function (character) {
- return character.getEntity() !== null;
- }, function (start) {
- var entityKey = block.getEntityAt(start); // Stringify to maintain order of otherwise numeric keys.
-
- var stringifiedEntityKey = DraftStringKey.stringify(entityKey); // This makes this function resilient to two entities
- // erroneously having the same key
-
- if (entityCacheRef[stringifiedEntityKey]) {
- return;
- }
-
- entityCacheRef[stringifiedEntityKey] = entityKey; // we need the `any` casting here since this is a temporary state
- // where we will later on flip the entity map and populate it with
- // real entity, at this stage we just need to map back the entity
- // key used by the BlockNode
-
- entityMap[stringifiedEntityKey] = "".concat(entityStorageKey);
- entityStorageKey++;
- });
- insertRawBlock(block, entityMap, rawBlocks, blockCacheRef);
- });
- return {
- blocks: rawBlocks,
- entityMap: entityMap
- };
- }; // Flip storage map so that our storage keys map to global
- // DraftEntity keys.
-
-
- var encodeRawEntityMap = function encodeRawEntityMap(contentState, rawState) {
- var blocks = rawState.blocks,
- entityMap = rawState.entityMap;
- var rawEntityMap = {};
- Object.keys(entityMap).forEach(function (key, index) {
- var entity = contentState.getEntity(DraftStringKey.unstringify(key));
- rawEntityMap[index] = {
- type: entity.getType(),
- mutability: entity.getMutability(),
- data: entity.getData()
- };
- });
- return {
- blocks: blocks,
- entityMap: rawEntityMap
- };
- };
-
- var convertFromDraftStateToRaw = function convertFromDraftStateToRaw(contentState) {
- var rawDraftContentState = {
- entityMap: {},
- blocks: []
- }; // add blocks
-
- rawDraftContentState = encodeRawBlocks(contentState, rawDraftContentState); // add entities
-
- rawDraftContentState = encodeRawEntityMap(contentState, rawDraftContentState);
- return rawDraftContentState;
- };
-
- module.exports = convertFromDraftStateToRaw;
-
- /***/ }),
- /* 165 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var DraftStringKey = __webpack_require__(77);
-
- var UnicodeUtils = __webpack_require__(16);
-
- var strlen = UnicodeUtils.strlen;
- /**
- * Convert to UTF-8 character counts for storage.
- */
-
- function encodeEntityRanges(block, storageMap) {
- var encoded = [];
- block.findEntityRanges(function (character) {
- return !!character.getEntity();
- }, function (
- /*number*/
- start,
- /*number*/
- end) {
- var text = block.getText();
- var key = block.getEntityAt(start);
- encoded.push({
- offset: strlen(text.slice(0, start)),
- length: strlen(text.slice(start, end)),
- // Encode the key as a number for range storage.
- key: Number(storageMap[DraftStringKey.stringify(key)])
- });
- });
- return encoded;
- }
-
- module.exports = encodeEntityRanges;
-
- /***/ }),
- /* 166 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var UnicodeUtils = __webpack_require__(16);
-
- var findRangesImmutable = __webpack_require__(18);
-
- var areEqual = function areEqual(a, b) {
- return a === b;
- };
-
- var isTruthy = function isTruthy(a) {
- return !!a;
- };
-
- var EMPTY_ARRAY = [];
- /**
- * Helper function for getting encoded styles for each inline style. Convert
- * to UTF-8 character counts for storage.
- */
-
- function getEncodedInlinesForType(block, styleList, styleToEncode) {
- var ranges = []; // Obtain an array with ranges for only the specified style.
-
- var filteredInlines = styleList.map(function (style) {
- return style.has(styleToEncode);
- }).toList();
- findRangesImmutable(filteredInlines, areEqual, // We only want to keep ranges with nonzero style values.
- isTruthy, function (start, end) {
- var text = block.getText();
- ranges.push({
- offset: UnicodeUtils.strlen(text.slice(0, start)),
- length: UnicodeUtils.strlen(text.slice(start, end)),
- style: styleToEncode
- });
- });
- return ranges;
- }
- /*
- * Retrieve the encoded arrays of inline styles, with each individual style
- * treated separately.
- */
-
-
- function encodeInlineStyleRanges(block) {
- var styleList = block.getCharacterList().map(function (c) {
- return c.getStyle();
- }).toList();
- var ranges = styleList.flatten().toSet().map(function (style) {
- return getEncodedInlinesForType(block, styleList, style);
- });
- return Array.prototype.concat.apply(EMPTY_ARRAY, ranges.toJS());
- }
-
- module.exports = encodeInlineStyleRanges;
-
- /***/ }),
- /* 167 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- var ContentBlock = __webpack_require__(12);
-
- var ContentBlockNode = __webpack_require__(7);
-
- var ContentState = __webpack_require__(32);
-
- var DraftEntity = __webpack_require__(22);
-
- var DraftTreeAdapter = __webpack_require__(168);
-
- var DraftTreeInvariants = __webpack_require__(169);
-
- var SelectionState = __webpack_require__(23);
-
- var createCharacterList = __webpack_require__(170);
-
- var decodeEntityRanges = __webpack_require__(171);
-
- var decodeInlineStyleRanges = __webpack_require__(172);
-
- var generateRandomKey = __webpack_require__(9);
-
- var gkx = __webpack_require__(11);
-
- var Immutable = __webpack_require__(0);
-
- var invariant = __webpack_require__(1);
-
- var experimentalTreeDataSupport = gkx('draft_tree_data_support');
- var List = Immutable.List,
- Map = Immutable.Map,
- OrderedMap = Immutable.OrderedMap;
-
- var decodeBlockNodeConfig = function decodeBlockNodeConfig(block, entityMap) {
- var key = block.key,
- type = block.type,
- data = block.data,
- text = block.text,
- depth = block.depth;
- var blockNodeConfig = {
- text: text,
- depth: depth || 0,
- type: type || 'unstyled',
- key: key || generateRandomKey(),
- data: Map(data),
- characterList: decodeCharacterList(block, entityMap)
- };
- return blockNodeConfig;
- };
-
- var decodeCharacterList = function decodeCharacterList(block, entityMap) {
- var text = block.text,
- rawEntityRanges = block.entityRanges,
- rawInlineStyleRanges = block.inlineStyleRanges;
- var entityRanges = rawEntityRanges || [];
- var inlineStyleRanges = rawInlineStyleRanges || []; // Translate entity range keys to the DraftEntity map.
-
- return createCharacterList(decodeInlineStyleRanges(text, inlineStyleRanges), decodeEntityRanges(text, entityRanges.filter(function (range) {
- return entityMap.hasOwnProperty(range.key);
- }).map(function (range) {
- return _objectSpread({}, range, {
- key: entityMap[range.key]
- });
- })));
- };
-
- var addKeyIfMissing = function addKeyIfMissing(block) {
- return _objectSpread({}, block, {
- key: block.key || generateRandomKey()
- });
- };
- /**
- * Node stack is responsible to ensure we traverse the tree only once
- * in depth order, while also providing parent refs to inner nodes to
- * construct their links.
- */
-
-
- var updateNodeStack = function updateNodeStack(stack, nodes, parentRef) {
- var nodesWithParentRef = nodes.map(function (block) {
- return _objectSpread({}, block, {
- parentRef: parentRef
- });
- }); // since we pop nodes from the stack we need to insert them in reverse
-
- return stack.concat(nodesWithParentRef.reverse());
- };
- /**
- * This will build a tree draft content state by creating the node
- * reference links into a single tree walk. Each node has a link
- * reference to "parent", "children", "nextSibling" and "prevSibling"
- * blockMap will be created using depth ordering.
- */
-
-
- var decodeContentBlockNodes = function decodeContentBlockNodes(blocks, entityMap) {
- return blocks // ensure children have valid keys to enable sibling links
- .map(addKeyIfMissing).reduce(function (blockMap, block, index) {
- !Array.isArray(block.children) ? true ? invariant(false, 'invalid RawDraftContentBlock can not be converted to ContentBlockNode') : invariant(false) : void 0; // ensure children have valid keys to enable sibling links
-
- var children = block.children.map(addKeyIfMissing); // root level nodes
-
- var contentBlockNode = new ContentBlockNode(_objectSpread({}, decodeBlockNodeConfig(block, entityMap), {
- prevSibling: index === 0 ? null : blocks[index - 1].key,
- nextSibling: index === blocks.length - 1 ? null : blocks[index + 1].key,
- children: List(children.map(function (child) {
- return child.key;
- }))
- })); // push root node to blockMap
-
- blockMap = blockMap.set(contentBlockNode.getKey(), contentBlockNode); // this stack is used to ensure we visit all nodes respecting depth ordering
-
- var stack = updateNodeStack([], children, contentBlockNode); // start computing children nodes
-
- while (stack.length > 0) {
- // we pop from the stack and start processing this node
- var node = stack.pop(); // parentRef already points to a converted ContentBlockNode
-
- var parentRef = node.parentRef;
- var siblings = parentRef.getChildKeys();
-
- var _index = siblings.indexOf(node.key);
-
- var isValidBlock = Array.isArray(node.children);
-
- if (!isValidBlock) {
- !isValidBlock ? true ? invariant(false, 'invalid RawDraftContentBlock can not be converted to ContentBlockNode') : invariant(false) : void 0;
- break;
- } // ensure children have valid keys to enable sibling links
-
-
- var _children = node.children.map(addKeyIfMissing);
-
- var _contentBlockNode = new ContentBlockNode(_objectSpread({}, decodeBlockNodeConfig(node, entityMap), {
- parent: parentRef.getKey(),
- children: List(_children.map(function (child) {
- return child.key;
- })),
- prevSibling: _index === 0 ? null : siblings.get(_index - 1),
- nextSibling: _index === siblings.size - 1 ? null : siblings.get(_index + 1)
- })); // push node to blockMap
-
-
- blockMap = blockMap.set(_contentBlockNode.getKey(), _contentBlockNode); // this stack is used to ensure we visit all nodes respecting depth ordering
-
- stack = updateNodeStack(stack, _children, _contentBlockNode);
- }
-
- return blockMap;
- }, OrderedMap());
- };
-
- var decodeContentBlocks = function decodeContentBlocks(blocks, entityMap) {
- return OrderedMap(blocks.map(function (block) {
- var contentBlock = new ContentBlock(decodeBlockNodeConfig(block, entityMap));
- return [contentBlock.getKey(), contentBlock];
- }));
- };
-
- var decodeRawBlocks = function decodeRawBlocks(rawState, entityMap) {
- var isTreeRawBlock = rawState.blocks.find(function (block) {
- return Array.isArray(block.children) && block.children.length > 0;
- });
- var rawBlocks = experimentalTreeDataSupport && !isTreeRawBlock ? DraftTreeAdapter.fromRawStateToRawTreeState(rawState).blocks : rawState.blocks;
-
- if (!experimentalTreeDataSupport) {
- return decodeContentBlocks(isTreeRawBlock ? DraftTreeAdapter.fromRawTreeStateToRawState(rawState).blocks : rawBlocks, entityMap);
- }
-
- var blockMap = decodeContentBlockNodes(rawBlocks, entityMap); // in dev mode, check that the tree invariants are met
-
- if (true) {
- !DraftTreeInvariants.isValidTree(blockMap) ? true ? invariant(false, 'Should be a valid tree') : invariant(false) : void 0;
- }
-
- return blockMap;
- };
-
- var decodeRawEntityMap = function decodeRawEntityMap(rawState) {
- var rawEntityMap = rawState.entityMap;
- var entityMap = {}; // TODO: Update this once we completely remove DraftEntity
-
- Object.keys(rawEntityMap).forEach(function (rawEntityKey) {
- var _rawEntityMap$rawEnti = rawEntityMap[rawEntityKey],
- type = _rawEntityMap$rawEnti.type,
- mutability = _rawEntityMap$rawEnti.mutability,
- data = _rawEntityMap$rawEnti.data; // get the key reference to created entity
-
- entityMap[rawEntityKey] = DraftEntity.__create(type, mutability, data || {});
- });
- return entityMap;
- };
-
- var convertFromRawToDraftState = function convertFromRawToDraftState(rawState) {
- !Array.isArray(rawState.blocks) ? true ? invariant(false, 'invalid RawDraftContentState') : invariant(false) : void 0; // decode entities
-
- var entityMap = decodeRawEntityMap(rawState); // decode blockMap
-
- var blockMap = decodeRawBlocks(rawState, entityMap); // create initial selection
-
- var selectionState = blockMap.isEmpty() ? new SelectionState() : SelectionState.createEmpty(blockMap.first().getKey());
- return new ContentState({
- blockMap: blockMap,
- entityMap: entityMap,
- selectionBefore: selectionState,
- selectionAfter: selectionState
- });
- };
-
- module.exports = convertFromRawToDraftState;
-
- /***/ }),
- /* 168 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- *
- * This is unstable and not part of the public API and should not be used by
- * production systems. This file may be update/removed without notice.
- */
- var generateRandomKey = __webpack_require__(9);
-
- var invariant = __webpack_require__(1);
-
- var traverseInDepthOrder = function traverseInDepthOrder(blocks, fn) {
- var stack = [].concat(blocks).reverse();
-
- while (stack.length) {
- var _block = stack.pop();
-
- fn(_block);
- var children = _block.children;
- !Array.isArray(children) ? true ? invariant(false, 'Invalid tree raw block') : invariant(false) : void 0;
- stack = stack.concat([].concat(children.reverse()));
- }
- };
-
- var isListBlock = function isListBlock(block) {
- if (!(block && block.type)) {
- return false;
- }
-
- var type = block.type;
- return type === 'unordered-list-item' || type === 'ordered-list-item';
- };
-
- var addDepthToChildren = function addDepthToChildren(block) {
- if (Array.isArray(block.children)) {
- block.children = block.children.map(function (child) {
- return child.type === block.type ? _objectSpread({}, child, {
- depth: (block.depth || 0) + 1
- }) : child;
- });
- }
- };
- /**
- * This adapter is intended to be be used as an adapter to draft tree data
- *
- * draft state <=====> draft tree state
- */
-
-
- var DraftTreeAdapter = {
- /**
- * Converts from a tree raw state back to draft raw state
- */
- fromRawTreeStateToRawState: function fromRawTreeStateToRawState(draftTreeState) {
- var blocks = draftTreeState.blocks;
- var transformedBlocks = [];
- !Array.isArray(blocks) ? true ? invariant(false, 'Invalid raw state') : invariant(false) : void 0;
-
- if (!Array.isArray(blocks) || !blocks.length) {
- return draftTreeState;
- }
-
- traverseInDepthOrder(blocks, function (block) {
- var newBlock = _objectSpread({}, block);
-
- if (isListBlock(block)) {
- newBlock.depth = newBlock.depth || 0;
- addDepthToChildren(block); // if it's a non-leaf node, we don't do anything else
-
- if (block.children != null && block.children.length > 0) {
- return;
- }
- }
-
- delete newBlock.children;
- transformedBlocks.push(newBlock);
- });
- draftTreeState.blocks = transformedBlocks;
- return _objectSpread({}, draftTreeState, {
- blocks: transformedBlocks
- });
- },
-
- /**
- * Converts from draft raw state to tree draft state
- */
- fromRawStateToRawTreeState: function fromRawStateToRawTreeState(draftState) {
- var transformedBlocks = [];
- var parentStack = [];
- draftState.blocks.forEach(function (block) {
- var isList = isListBlock(block);
- var depth = block.depth || 0;
-
- var treeBlock = _objectSpread({}, block, {
- children: []
- });
-
- if (!isList) {
- transformedBlocks.push(treeBlock);
- return;
- }
-
- var lastParent = parentStack[0]; // block is non-nested & there are no nested blocks, directly push block
-
- if (lastParent == null && depth === 0) {
- transformedBlocks.push(treeBlock); // block is first nested block or previous nested block is at a lower level
- } else if (lastParent == null || lastParent.depth < depth - 1) {
- // create new parent block
- var newParent = {
- key: generateRandomKey(),
- text: '',
- depth: depth - 1,
- type: block.type,
- children: [],
- entityRanges: [],
- inlineStyleRanges: []
- };
- parentStack.unshift(newParent);
-
- if (depth === 1) {
- // add as a root-level block
- transformedBlocks.push(newParent);
- } else if (lastParent != null) {
- // depth > 1 => also add as previous parent's child
- lastParent.children.push(newParent);
- }
-
- newParent.children.push(treeBlock);
- } else if (lastParent.depth === depth - 1) {
- // add as child of last parent
- lastParent.children.push(treeBlock);
- } else {
- // pop out parents at levels above this one from the parent stack
- while (lastParent != null && lastParent.depth >= depth) {
- parentStack.shift();
- lastParent = parentStack[0];
- }
-
- if (depth > 0) {
- lastParent.children.push(treeBlock);
- } else {
- transformedBlocks.push(treeBlock);
- }
- }
- });
- return _objectSpread({}, draftState, {
- blocks: transformedBlocks
- });
- }
- };
- module.exports = DraftTreeAdapter;
-
- /***/ }),
- /* 169 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
-
-
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- *
- * This is unstable and not part of the public API and should not be used by
- * production systems. This file may be update/removed without notice.
- */
- var warning = __webpack_require__(39);
-
- var DraftTreeInvariants = {
- /**
- * Check if the block is valid
- */
- isValidBlock: function isValidBlock(block, blockMap) {
- var key = block.getKey(); // is its parent's child
-
- var parentKey = block.getParentKey();
-
- if (parentKey != null) {
- var parent = blockMap.get(parentKey);
-
- if (!parent.getChildKeys().includes(key)) {
- true ? warning(true, 'Tree is missing parent -> child pointer on %s', key) : void 0;
- return false;
- }
- } // is its children's parent
-
-
- var children = block.getChildKeys().map(function (k) {
- return blockMap.get(k);
- });
-
- if (!children.every(function (c) {
- return c.getParentKey() === key;
- })) {
- true ? warning(true, 'Tree is missing child -> parent pointer on %s', key) : void 0;
- return false;
- } // is its previous sibling's next sibling
-
-
- var prevSiblingKey = block.getPrevSiblingKey();
-
- if (prevSiblingKey != null) {
- var prevSibling = blockMap.get(prevSiblingKey);
-
- if (prevSibling.getNextSiblingKey() !== key) {
- true ? warning(true, "Tree is missing nextSibling pointer on %s's prevSibling", key) : void 0;
- return false;
- }
- } // is its next sibling's previous sibling
-
-
- var nextSiblingKey = block.getNextSiblingKey();
-
- if (nextSiblingKey != null) {
- var nextSibling = blockMap.get(nextSiblingKey);
-
- if (nextSibling.getPrevSiblingKey() !== key) {
- true ? warning(true, "Tree is missing prevSibling pointer on %s's nextSibling", key) : void 0;
- return false;
- }
- } // no 2-node cycles
-
-
- if (nextSiblingKey !== null && prevSiblingKey !== null) {
- if (prevSiblingKey === nextSiblingKey) {
- true ? warning(true, 'Tree has a two-node cycle at %s', key) : void 0;
- return false;
- }
- } // if it's a leaf node, it has text but no children
-
-
- if (block.text != '') {
- if (block.getChildKeys().size > 0) {
- true ? warning(true, 'Leaf node %s has children', key) : void 0;
- return false;
- }
- }
-
- return true;
- },
-
- /**
- * Checks that this is a connected tree on all the blocks
- * starting from the first block, traversing nextSibling and child pointers
- * should be a tree (preorder traversal - parent, then children)
- * num of connected node === number of blocks
- */
- isConnectedTree: function isConnectedTree(blockMap) {
- // exactly one node has no previous sibling + no parent
- var eligibleFirstNodes = blockMap.toArray().filter(function (block) {
- return block.getParentKey() == null && block.getPrevSiblingKey() == null;
- });
-
- if (eligibleFirstNodes.length !== 1) {
- true ? warning(true, 'Tree is not connected. More or less than one first node') : void 0;
- return false;
- }
-
- var firstNode = eligibleFirstNodes.shift();
- var nodesSeen = 0;
- var currentKey = firstNode.getKey();
- var visitedStack = [];
-
- while (currentKey != null) {
- var currentNode = blockMap.get(currentKey);
- var childKeys = currentNode.getChildKeys();
- var nextSiblingKey = currentNode.getNextSiblingKey(); // if the node has children, add parent's next sibling to stack and go to children
-
- if (childKeys.size > 0) {
- if (nextSiblingKey != null) {
- visitedStack.unshift(nextSiblingKey);
- }
-
- var children = childKeys.map(function (k) {
- return blockMap.get(k);
- });
-
- var _firstNode = children.find(function (block) {
- return block.getPrevSiblingKey() == null;
- });
-
- if (_firstNode == null) {
- true ? warning(true, '%s has no first child', currentKey) : void 0;
- return false;
- }
-
- currentKey = _firstNode.getKey(); // TODO(T32490138): Deal with multi-node cycles here
- } else {
- if (currentNode.getNextSiblingKey() != null) {
- currentKey = currentNode.getNextSiblingKey();
- } else {
- currentKey = visitedStack.shift();
- }
- }
-
- nodesSeen++;
- }
-
- if (nodesSeen !== blockMap.size) {
- true ? warning(true, 'Tree is not connected. %s nodes were seen instead of %s', nodesSeen, blockMap.size) : void 0;
- return false;
- }
-
- return true;
- },
-
- /**
- * Checks that the block map is a connected tree with valid blocks
- */
- isValidTree: function isValidTree(blockMap) {
- var _this = this;
-
- var blocks = blockMap.toArray();
-
- if (!blocks.every(function (block) {
- return _this.isValidBlock(block, blockMap);
- })) {
- return false;
- }
-
- return this.isConnectedTree(blockMap);
- }
- };
- module.exports = DraftTreeInvariants;
-
- /***/ }),
- /* 170 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var CharacterMetadata = __webpack_require__(6);
-
- var Immutable = __webpack_require__(0);
-
- var List = Immutable.List;
-
- function createCharacterList(inlineStyles, entities) {
- var characterArray = inlineStyles.map(function (style, ii) {
- var entity = entities[ii];
- return CharacterMetadata.create({
- style: style,
- entity: entity
- });
- });
- return List(characterArray);
- }
-
- module.exports = createCharacterList;
-
- /***/ }),
- /* 171 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var UnicodeUtils = __webpack_require__(16);
-
- var substr = UnicodeUtils.substr;
- /**
- * Convert to native JavaScript string lengths to determine ranges.
- */
-
- function decodeEntityRanges(text, ranges) {
- var entities = Array(text.length).fill(null);
-
- if (ranges) {
- ranges.forEach(function (range) {
- // Using Unicode-enabled substrings converted to JavaScript lengths,
- // fill the output array with entity keys.
- var start = substr(text, 0, range.offset).length;
- var end = start + substr(text, range.offset, range.length).length;
-
- for (var ii = start; ii < end; ii++) {
- entities[ii] = range.key;
- }
- });
- }
-
- return entities;
- }
-
- module.exports = decodeEntityRanges;
-
- /***/ }),
- /* 172 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var UnicodeUtils = __webpack_require__(16);
-
- var _require = __webpack_require__(0),
- OrderedSet = _require.OrderedSet;
-
- var substr = UnicodeUtils.substr;
- var EMPTY_SET = OrderedSet();
- /**
- * Convert to native JavaScript string lengths to determine ranges.
- */
-
- function decodeInlineStyleRanges(text, ranges) {
- var styles = Array(text.length).fill(EMPTY_SET);
-
- if (ranges) {
- ranges.forEach(function (range) {
- var cursor = substr(text, 0, range.offset).length;
- var end = cursor + substr(text, range.offset, range.length).length;
-
- while (cursor < end) {
- styles[cursor] = styles[cursor].add(range.style);
- cursor++;
- }
- });
- }
-
- return styles;
- }
-
- module.exports = decodeInlineStyleRanges;
-
- /***/ }),
- /* 173 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var getRangeBoundingClientRect = __webpack_require__(174);
- /**
- * Return the bounding ClientRect for the visible DOM selection, if any.
- * In cases where there are no selected ranges or the bounding rect is
- * temporarily invalid, return null.
- *
- * When using from an iframe, you should pass the iframe window object
- */
-
-
- function getVisibleSelectionRect(global) {
- var selection = global.getSelection();
-
- if (!selection.rangeCount) {
- return null;
- }
-
- var range = selection.getRangeAt(0);
- var boundingRect = getRangeBoundingClientRect(range);
- var top = boundingRect.top,
- right = boundingRect.right,
- bottom = boundingRect.bottom,
- left = boundingRect.left; // When a re-render leads to a node being removed, the DOM selection will
- // temporarily be placed on an ancestor node, which leads to an invalid
- // bounding rect. Discard this state.
-
- if (top === 0 && right === 0 && bottom === 0 && left === 0) {
- return null;
- }
-
- return boundingRect;
- }
-
- module.exports = getVisibleSelectionRect;
-
- /***/ }),
- /* 174 */
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @format
- *
- * @emails oncall+draft_js
- */
-
-
- var getRangeClientRects = __webpack_require__(70);
-
- /**
- * Like range.getBoundingClientRect() but normalizes for browser bugs.
- */
- function getRangeBoundingClientRect(range) {
- // "Return a DOMRect object describing the smallest rectangle that includes
- // the first rectangle in list and all of the remaining rectangles of which
- // the height or width is not zero."
- // http://www.w3.org/TR/cssom-view/#dom-range-getboundingclientrect
- var rects = getRangeClientRects(range);
- var top = 0;
- var right = 0;
- var bottom = 0;
- var left = 0;
-
- if (rects.length) {
- // If the first rectangle has 0 width, we use the second, this is needed
- // because Chrome renders a 0 width rectangle when the selection contains
- // a line break.
- if (rects.length > 1 && rects[0].width === 0) {
- var _rects$ = rects[1];
- top = _rects$.top;
- right = _rects$.right;
- bottom = _rects$.bottom;
- left = _rects$.left;
- } else {
- var _rects$2 = rects[0];
- top = _rects$2.top;
- right = _rects$2.right;
- bottom = _rects$2.bottom;
- left = _rects$2.left;
- }
-
- for (var ii = 1; ii < rects.length; ii++) {
- var rect = rects[ii];
-
- if (rect.height !== 0 && rect.width !== 0) {
- top = Math.min(top, rect.top);
- right = Math.max(right, rect.right);
- bottom = Math.max(bottom, rect.bottom);
- left = Math.min(left, rect.left);
- }
- }
- }
-
- return {
- top: top,
- right: right,
- bottom: bottom,
- left: left,
- width: right - left,
- height: bottom - top
- };
- }
-
- module.exports = getRangeBoundingClientRect;
-
- /***/ })
- /******/ ]);
- });
|