13.js 819 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576
  1. webpackJsonp([13],{
  2. /***/ 320:
  3. /***/ (function(module, exports) {
  4. module.exports = "/fonts/pages/main/components/MDEditor/assets/font/iconfont.eot?5cb756e5";
  5. /***/ }),
  6. /***/ 321:
  7. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8. "use strict";
  9. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  10. // Kludges for bugs and behavior differences that can't be feature
  11. // detected are enabled based on userAgent etc sniffing.
  12. var userAgent = navigator.userAgent;
  13. var platform = navigator.platform;
  14. var gecko = /gecko\/\d/i.test(userAgent);
  15. var ie_upto10 = /MSIE \d/.test(userAgent);
  16. var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
  17. var edge = /Edge\/(\d+)/.exec(userAgent);
  18. var ie = ie_upto10 || ie_11up || edge;
  19. var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]);
  20. var webkit = !edge && /WebKit\//.test(userAgent);
  21. var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
  22. var chrome = !edge && /Chrome\//.test(userAgent);
  23. var presto = /Opera\//.test(userAgent);
  24. var safari = /Apple Computer/.test(navigator.vendor);
  25. var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
  26. var phantom = /PhantomJS/.test(userAgent);
  27. var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
  28. var android = /Android/.test(userAgent);
  29. // This is woefully incomplete. Suggestions for alternative methods welcome.
  30. var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
  31. var mac = ios || /Mac/.test(platform);
  32. var chromeOS = /\bCrOS\b/.test(userAgent);
  33. var windows = /win/i.test(platform);
  34. var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
  35. if (presto_version) {
  36. presto_version = Number(presto_version[1]);
  37. }
  38. if (presto_version && presto_version >= 15) {
  39. presto = false;
  40. webkit = true;
  41. }
  42. // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
  43. var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
  44. var captureRightClick = gecko || ie && ie_version >= 9;
  45. function classTest(cls) {
  46. return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*");
  47. }
  48. var rmClass = function rmClass(node, cls) {
  49. var current = node.className;
  50. var match = classTest(cls).exec(current);
  51. if (match) {
  52. var after = current.slice(match.index + match[0].length);
  53. node.className = current.slice(0, match.index) + (after ? match[1] + after : "");
  54. }
  55. };
  56. function removeChildren(e) {
  57. for (var count = e.childNodes.length; count > 0; --count) {
  58. e.removeChild(e.firstChild);
  59. }
  60. return e;
  61. }
  62. function removeChildrenAndAdd(parent, e) {
  63. return removeChildren(parent).appendChild(e);
  64. }
  65. function elt(tag, content, className, style) {
  66. var e = document.createElement(tag);
  67. if (className) {
  68. e.className = className;
  69. }
  70. if (style) {
  71. e.style.cssText = style;
  72. }
  73. if (typeof content == "string") {
  74. e.appendChild(document.createTextNode(content));
  75. } else if (content) {
  76. for (var i = 0; i < content.length; ++i) {
  77. e.appendChild(content[i]);
  78. }
  79. }
  80. return e;
  81. }
  82. // wrapper for elt, which removes the elt from the accessibility tree
  83. function eltP(tag, content, className, style) {
  84. var e = elt(tag, content, className, style);
  85. e.setAttribute("role", "presentation");
  86. return e;
  87. }
  88. var range;
  89. if (document.createRange) {
  90. range = function range(node, start, end, endNode) {
  91. var r = document.createRange();
  92. r.setEnd(endNode || node, end);
  93. r.setStart(node, start);
  94. return r;
  95. };
  96. } else {
  97. range = function range(node, start, end) {
  98. var r = document.body.createTextRange();
  99. try {
  100. r.moveToElementText(node.parentNode);
  101. } catch (e) {
  102. return r;
  103. }
  104. r.collapse(true);
  105. r.moveEnd("character", end);
  106. r.moveStart("character", start);
  107. return r;
  108. };
  109. }
  110. function contains(parent, child) {
  111. if (child.nodeType == 3) // Android browser always returns false when child is a textnode
  112. {
  113. child = child.parentNode;
  114. }
  115. if (parent.contains) {
  116. return parent.contains(child);
  117. }
  118. do {
  119. if (child.nodeType == 11) {
  120. child = child.host;
  121. }
  122. if (child == parent) {
  123. return true;
  124. }
  125. } while (child = child.parentNode);
  126. }
  127. function activeElt() {
  128. // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
  129. // IE < 10 will throw when accessed while the page is loading or in an iframe.
  130. // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
  131. var activeElement;
  132. try {
  133. activeElement = document.activeElement;
  134. } catch (e) {
  135. activeElement = document.body || null;
  136. }
  137. while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement) {
  138. activeElement = activeElement.shadowRoot.activeElement;
  139. }
  140. return activeElement;
  141. }
  142. function addClass(node, cls) {
  143. var current = node.className;
  144. if (!classTest(cls).test(current)) {
  145. node.className += (current ? " " : "") + cls;
  146. }
  147. }
  148. function joinClasses(a, b) {
  149. var as = a.split(" ");
  150. for (var i = 0; i < as.length; i++) {
  151. if (as[i] && !classTest(as[i]).test(b)) {
  152. b += " " + as[i];
  153. }
  154. }
  155. return b;
  156. }
  157. var selectInput = function selectInput(node) {
  158. node.select();
  159. };
  160. if (ios) // Mobile Safari apparently has a bug where select() is broken.
  161. {
  162. selectInput = function selectInput(node) {
  163. node.selectionStart = 0;
  164. node.selectionEnd = node.value.length;
  165. };
  166. } else if (ie) // Suppress mysterious IE10 errors
  167. {
  168. selectInput = function selectInput(node) {
  169. try {
  170. node.select();
  171. } catch (_e) {}
  172. };
  173. }
  174. function bind(f) {
  175. var args = Array.prototype.slice.call(arguments, 1);
  176. return function () {
  177. return f.apply(null, args);
  178. };
  179. }
  180. function copyObj(obj, target, overwrite) {
  181. if (!target) {
  182. target = {};
  183. }
  184. for (var prop in obj) {
  185. if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop))) {
  186. target[prop] = obj[prop];
  187. }
  188. }
  189. return target;
  190. }
  191. // Counts the column offset in a string, taking tabs into account.
  192. // Used mostly to find indentation.
  193. function countColumn(string, end, tabSize, startIndex, startValue) {
  194. if (end == null) {
  195. end = string.search(/[^\s\u00a0]/);
  196. if (end == -1) {
  197. end = string.length;
  198. }
  199. }
  200. for (var i = startIndex || 0, n = startValue || 0;;) {
  201. var nextTab = string.indexOf("\t", i);
  202. if (nextTab < 0 || nextTab >= end) {
  203. return n + (end - i);
  204. }
  205. n += nextTab - i;
  206. n += tabSize - n % tabSize;
  207. i = nextTab + 1;
  208. }
  209. }
  210. var Delayed = function Delayed() {
  211. this.id = null;
  212. this.f = null;
  213. this.time = 0;
  214. this.handler = bind(this.onTimeout, this);
  215. };
  216. Delayed.prototype.onTimeout = function (self) {
  217. self.id = 0;
  218. if (self.time <= +new Date()) {
  219. self.f();
  220. } else {
  221. setTimeout(self.handler, self.time - +new Date());
  222. }
  223. };
  224. Delayed.prototype.set = function (ms, f) {
  225. this.f = f;
  226. var time = +new Date() + ms;
  227. if (!this.id || time < this.time) {
  228. clearTimeout(this.id);
  229. this.id = setTimeout(this.handler, ms);
  230. this.time = time;
  231. }
  232. };
  233. function indexOf(array, elt) {
  234. for (var i = 0; i < array.length; ++i) {
  235. if (array[i] == elt) {
  236. return i;
  237. }
  238. }
  239. return -1;
  240. }
  241. // Number of pixels added to scroller and sizer to hide scrollbar
  242. var scrollerGap = 30;
  243. // Returned or thrown by various protocols to signal 'I'm not
  244. // handling this'.
  245. var Pass = {
  246. toString: function toString() {
  247. return "CodeMirror.Pass";
  248. }
  249. };
  250. // Reused option objects for setSelection & friends
  251. var sel_dontScroll = { scroll: false },
  252. sel_mouse = { origin: "*mouse" },
  253. sel_move = { origin: "+move" };
  254. // The inverse of countColumn -- find the offset that corresponds to
  255. // a particular column.
  256. function findColumn(string, goal, tabSize) {
  257. for (var pos = 0, col = 0;;) {
  258. var nextTab = string.indexOf("\t", pos);
  259. if (nextTab == -1) {
  260. nextTab = string.length;
  261. }
  262. var skipped = nextTab - pos;
  263. if (nextTab == string.length || col + skipped >= goal) {
  264. return pos + Math.min(skipped, goal - col);
  265. }
  266. col += nextTab - pos;
  267. col += tabSize - col % tabSize;
  268. pos = nextTab + 1;
  269. if (col >= goal) {
  270. return pos;
  271. }
  272. }
  273. }
  274. var spaceStrs = [""];
  275. function spaceStr(n) {
  276. while (spaceStrs.length <= n) {
  277. spaceStrs.push(lst(spaceStrs) + " ");
  278. }
  279. return spaceStrs[n];
  280. }
  281. function lst(arr) {
  282. return arr[arr.length - 1];
  283. }
  284. function map(array, f) {
  285. var out = [];
  286. for (var i = 0; i < array.length; i++) {
  287. out[i] = f(array[i], i);
  288. }
  289. return out;
  290. }
  291. function insertSorted(array, value, score) {
  292. var pos = 0,
  293. priority = score(value);
  294. while (pos < array.length && score(array[pos]) <= priority) {
  295. pos++;
  296. }
  297. array.splice(pos, 0, value);
  298. }
  299. function nothing() {}
  300. function createObj(base, props) {
  301. var inst;
  302. if (Object.create) {
  303. inst = Object.create(base);
  304. } else {
  305. nothing.prototype = base;
  306. inst = new nothing();
  307. }
  308. if (props) {
  309. copyObj(props, inst);
  310. }
  311. return inst;
  312. }
  313. var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
  314. function isWordCharBasic(ch) {
  315. return (/\w/.test(ch) || ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch))
  316. );
  317. }
  318. function isWordChar(ch, helper) {
  319. if (!helper) {
  320. return isWordCharBasic(ch);
  321. }
  322. if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) {
  323. return true;
  324. }
  325. return helper.test(ch);
  326. }
  327. function isEmpty(obj) {
  328. for (var n in obj) {
  329. if (obj.hasOwnProperty(n) && obj[n]) {
  330. return false;
  331. }
  332. }
  333. return true;
  334. }
  335. // Extending unicode characters. A series of a non-extending char +
  336. // any number of extending chars is treated as a single unit as far
  337. // as editing and measuring is concerned. This is not fully correct,
  338. // since some scripts/fonts/browsers also treat other configurations
  339. // of code points as a group.
  340. var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;
  341. function isExtendingChar(ch) {
  342. return ch.charCodeAt(0) >= 768 && extendingChars.test(ch);
  343. }
  344. // Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range.
  345. function skipExtendingChars(str, pos, dir) {
  346. while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) {
  347. pos += dir;
  348. }
  349. return pos;
  350. }
  351. // Returns the value from the range [`from`; `to`] that satisfies
  352. // `pred` and is closest to `from`. Assumes that at least `to`
  353. // satisfies `pred`. Supports `from` being greater than `to`.
  354. function findFirst(pred, from, to) {
  355. // At any point we are certain `to` satisfies `pred`, don't know
  356. // whether `from` does.
  357. var dir = from > to ? -1 : 1;
  358. for (;;) {
  359. if (from == to) {
  360. return from;
  361. }
  362. var midF = (from + to) / 2,
  363. mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF);
  364. if (mid == from) {
  365. return pred(mid) ? from : to;
  366. }
  367. if (pred(mid)) {
  368. to = mid;
  369. } else {
  370. from = mid + dir;
  371. }
  372. }
  373. }
  374. // BIDI HELPERS
  375. function iterateBidiSections(order, from, to, f) {
  376. if (!order) {
  377. return f(from, to, "ltr", 0);
  378. }
  379. var found = false;
  380. for (var i = 0; i < order.length; ++i) {
  381. var part = order[i];
  382. if (part.from < to && part.to > from || from == to && part.to == from) {
  383. f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr", i);
  384. found = true;
  385. }
  386. }
  387. if (!found) {
  388. f(from, to, "ltr");
  389. }
  390. }
  391. var bidiOther = null;
  392. function getBidiPartAt(order, ch, sticky) {
  393. var found;
  394. bidiOther = null;
  395. for (var i = 0; i < order.length; ++i) {
  396. var cur = order[i];
  397. if (cur.from < ch && cur.to > ch) {
  398. return i;
  399. }
  400. if (cur.to == ch) {
  401. if (cur.from != cur.to && sticky == "before") {
  402. found = i;
  403. } else {
  404. bidiOther = i;
  405. }
  406. }
  407. if (cur.from == ch) {
  408. if (cur.from != cur.to && sticky != "before") {
  409. found = i;
  410. } else {
  411. bidiOther = i;
  412. }
  413. }
  414. }
  415. return found != null ? found : bidiOther;
  416. }
  417. // Bidirectional ordering algorithm
  418. // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
  419. // that this (partially) implements.
  420. // One-char codes used for character types:
  421. // L (L): Left-to-Right
  422. // R (R): Right-to-Left
  423. // r (AL): Right-to-Left Arabic
  424. // 1 (EN): European Number
  425. // + (ES): European Number Separator
  426. // % (ET): European Number Terminator
  427. // n (AN): Arabic Number
  428. // , (CS): Common Number Separator
  429. // m (NSM): Non-Spacing Mark
  430. // b (BN): Boundary Neutral
  431. // s (B): Paragraph Separator
  432. // t (S): Segment Separator
  433. // w (WS): Whitespace
  434. // N (ON): Other Neutrals
  435. // Returns null if characters are ordered as they appear
  436. // (left-to-right), or an array of sections ({from, to, level}
  437. // objects) in the order in which they occur visually.
  438. var bidiOrdering = function () {
  439. // Character types for codepoints 0 to 0xff
  440. var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
  441. // Character types for codepoints 0x600 to 0x6f9
  442. var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";
  443. function charType(code) {
  444. if (code <= 0xf7) {
  445. return lowTypes.charAt(code);
  446. } else if (0x590 <= code && code <= 0x5f4) {
  447. return "R";
  448. } else if (0x600 <= code && code <= 0x6f9) {
  449. return arabicTypes.charAt(code - 0x600);
  450. } else if (0x6ee <= code && code <= 0x8ac) {
  451. return "r";
  452. } else if (0x2000 <= code && code <= 0x200b) {
  453. return "w";
  454. } else if (code == 0x200c) {
  455. return "b";
  456. } else {
  457. return "L";
  458. }
  459. }
  460. var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
  461. var isNeutral = /[stwN]/,
  462. isStrong = /[LRr]/,
  463. countsAsLeft = /[Lb1n]/,
  464. countsAsNum = /[1n]/;
  465. function BidiSpan(level, from, to) {
  466. this.level = level;
  467. this.from = from;
  468. this.to = to;
  469. }
  470. return function (str, direction) {
  471. var outerType = direction == "ltr" ? "L" : "R";
  472. if (str.length == 0 || direction == "ltr" && !bidiRE.test(str)) {
  473. return false;
  474. }
  475. var len = str.length,
  476. types = [];
  477. for (var i = 0; i < len; ++i) {
  478. types.push(charType(str.charCodeAt(i)));
  479. }
  480. // W1. Examine each non-spacing mark (NSM) in the level run, and
  481. // change the type of the NSM to the type of the previous
  482. // character. If the NSM is at the start of the level run, it will
  483. // get the type of sor.
  484. for (var i$1 = 0, prev = outerType; i$1 < len; ++i$1) {
  485. var type = types[i$1];
  486. if (type == "m") {
  487. types[i$1] = prev;
  488. } else {
  489. prev = type;
  490. }
  491. }
  492. // W2. Search backwards from each instance of a European number
  493. // until the first strong type (R, L, AL, or sor) is found. If an
  494. // AL is found, change the type of the European number to Arabic
  495. // number.
  496. // W3. Change all ALs to R.
  497. for (var i$2 = 0, cur = outerType; i$2 < len; ++i$2) {
  498. var type$1 = types[i$2];
  499. if (type$1 == "1" && cur == "r") {
  500. types[i$2] = "n";
  501. } else if (isStrong.test(type$1)) {
  502. cur = type$1;
  503. if (type$1 == "r") {
  504. types[i$2] = "R";
  505. }
  506. }
  507. }
  508. // W4. A single European separator between two European numbers
  509. // changes to a European number. A single common separator between
  510. // two numbers of the same type changes to that type.
  511. for (var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3) {
  512. var type$2 = types[i$3];
  513. if (type$2 == "+" && prev$1 == "1" && types[i$3 + 1] == "1") {
  514. types[i$3] = "1";
  515. } else if (type$2 == "," && prev$1 == types[i$3 + 1] && (prev$1 == "1" || prev$1 == "n")) {
  516. types[i$3] = prev$1;
  517. }
  518. prev$1 = type$2;
  519. }
  520. // W5. A sequence of European terminators adjacent to European
  521. // numbers changes to all European numbers.
  522. // W6. Otherwise, separators and terminators change to Other
  523. // Neutral.
  524. for (var i$4 = 0; i$4 < len; ++i$4) {
  525. var type$3 = types[i$4];
  526. if (type$3 == ",") {
  527. types[i$4] = "N";
  528. } else if (type$3 == "%") {
  529. var end = void 0;
  530. for (end = i$4 + 1; end < len && types[end] == "%"; ++end) {}
  531. var replace = i$4 && types[i$4 - 1] == "!" || end < len && types[end] == "1" ? "1" : "N";
  532. for (var j = i$4; j < end; ++j) {
  533. types[j] = replace;
  534. }
  535. i$4 = end - 1;
  536. }
  537. }
  538. // W7. Search backwards from each instance of a European number
  539. // until the first strong type (R, L, or sor) is found. If an L is
  540. // found, then change the type of the European number to L.
  541. for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) {
  542. var type$4 = types[i$5];
  543. if (cur$1 == "L" && type$4 == "1") {
  544. types[i$5] = "L";
  545. } else if (isStrong.test(type$4)) {
  546. cur$1 = type$4;
  547. }
  548. }
  549. // N1. A sequence of neutrals takes the direction of the
  550. // surrounding strong text if the text on both sides has the same
  551. // direction. European and Arabic numbers act as if they were R in
  552. // terms of their influence on neutrals. Start-of-level-run (sor)
  553. // and end-of-level-run (eor) are used at level run boundaries.
  554. // N2. Any remaining neutrals take the embedding direction.
  555. for (var i$6 = 0; i$6 < len; ++i$6) {
  556. if (isNeutral.test(types[i$6])) {
  557. var end$1 = void 0;
  558. for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {}
  559. var before = (i$6 ? types[i$6 - 1] : outerType) == "L";
  560. var after = (end$1 < len ? types[end$1] : outerType) == "L";
  561. var replace$1 = before == after ? before ? "L" : "R" : outerType;
  562. for (var j$1 = i$6; j$1 < end$1; ++j$1) {
  563. types[j$1] = replace$1;
  564. }
  565. i$6 = end$1 - 1;
  566. }
  567. }
  568. // Here we depart from the documented algorithm, in order to avoid
  569. // building up an actual levels array. Since there are only three
  570. // levels (0, 1, 2) in an implementation that doesn't take
  571. // explicit embedding into account, we can build up the order on
  572. // the fly, without following the level-based algorithm.
  573. var order = [],
  574. m;
  575. for (var i$7 = 0; i$7 < len;) {
  576. if (countsAsLeft.test(types[i$7])) {
  577. var start = i$7;
  578. for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {}
  579. order.push(new BidiSpan(0, start, i$7));
  580. } else {
  581. var pos = i$7,
  582. at = order.length;
  583. for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {}
  584. for (var j$2 = pos; j$2 < i$7;) {
  585. if (countsAsNum.test(types[j$2])) {
  586. if (pos < j$2) {
  587. order.splice(at, 0, new BidiSpan(1, pos, j$2));
  588. }
  589. var nstart = j$2;
  590. for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {}
  591. order.splice(at, 0, new BidiSpan(2, nstart, j$2));
  592. pos = j$2;
  593. } else {
  594. ++j$2;
  595. }
  596. }
  597. if (pos < i$7) {
  598. order.splice(at, 0, new BidiSpan(1, pos, i$7));
  599. }
  600. }
  601. }
  602. if (direction == "ltr") {
  603. if (order[0].level == 1 && (m = str.match(/^\s+/))) {
  604. order[0].from = m[0].length;
  605. order.unshift(new BidiSpan(0, 0, m[0].length));
  606. }
  607. if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
  608. lst(order).to -= m[0].length;
  609. order.push(new BidiSpan(0, len - m[0].length, len));
  610. }
  611. }
  612. return direction == "rtl" ? order.reverse() : order;
  613. };
  614. }();
  615. // Get the bidi ordering for the given line (and cache it). Returns
  616. // false for lines that are fully left-to-right, and an array of
  617. // BidiSpan objects otherwise.
  618. function getOrder(line, direction) {
  619. var order = line.order;
  620. if (order == null) {
  621. order = line.order = bidiOrdering(line.text, direction);
  622. }
  623. return order;
  624. }
  625. var noHandlers = [];
  626. var on = function on(emitter, type, f) {
  627. if (emitter.addEventListener) {
  628. emitter.addEventListener(type, f, false);
  629. } else if (emitter.attachEvent) {
  630. emitter.attachEvent("on" + type, f);
  631. } else {
  632. var map$$1 = emitter._handlers || (emitter._handlers = {});
  633. map$$1[type] = (map$$1[type] || noHandlers).concat(f);
  634. }
  635. };
  636. function getHandlers(emitter, type) {
  637. return emitter._handlers && emitter._handlers[type] || noHandlers;
  638. }
  639. function off(emitter, type, f) {
  640. if (emitter.removeEventListener) {
  641. emitter.removeEventListener(type, f, false);
  642. } else if (emitter.detachEvent) {
  643. emitter.detachEvent("on" + type, f);
  644. } else {
  645. var map$$1 = emitter._handlers,
  646. arr = map$$1 && map$$1[type];
  647. if (arr) {
  648. var index = indexOf(arr, f);
  649. if (index > -1) {
  650. map$$1[type] = arr.slice(0, index).concat(arr.slice(index + 1));
  651. }
  652. }
  653. }
  654. }
  655. function signal(emitter, type /*, values...*/) {
  656. var handlers = getHandlers(emitter, type);
  657. if (!handlers.length) {
  658. return;
  659. }
  660. var args = Array.prototype.slice.call(arguments, 2);
  661. for (var i = 0; i < handlers.length; ++i) {
  662. handlers[i].apply(null, args);
  663. }
  664. }
  665. // The DOM events that CodeMirror handles can be overridden by
  666. // registering a (non-DOM) handler on the src for the event name,
  667. // and preventDefault-ing the event in that handler.
  668. function signalDOMEvent(cm, e, override) {
  669. if (typeof e == "string") {
  670. e = {
  671. type: e, preventDefault: function preventDefault() {
  672. this.defaultPrevented = true;
  673. }
  674. };
  675. }
  676. signal(cm, override || e.type, cm, e);
  677. return e_defaultPrevented(e) || e.codemirrorIgnore;
  678. }
  679. function signalCursorActivity(cm) {
  680. var arr = cm._handlers && cm._handlers.cursorActivity;
  681. if (!arr) {
  682. return;
  683. }
  684. var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
  685. for (var i = 0; i < arr.length; ++i) {
  686. if (indexOf(set, arr[i]) == -1) {
  687. set.push(arr[i]);
  688. }
  689. }
  690. }
  691. function hasHandler(emitter, type) {
  692. return getHandlers(emitter, type).length > 0;
  693. }
  694. // Add on and off methods to a constructor's prototype, to make
  695. // registering events on such objects more convenient.
  696. function eventMixin(ctor) {
  697. ctor.prototype.on = function (type, f) {
  698. on(this, type, f);
  699. };
  700. ctor.prototype.off = function (type, f) {
  701. off(this, type, f);
  702. };
  703. }
  704. // Due to the fact that we still support jurassic IE versions, some
  705. // compatibility wrappers are needed.
  706. function e_preventDefault(e) {
  707. if (e.preventDefault) {
  708. e.preventDefault();
  709. } else {
  710. e.returnValue = false;
  711. }
  712. }
  713. function e_stopPropagation(e) {
  714. if (e.stopPropagation) {
  715. e.stopPropagation();
  716. } else {
  717. e.cancelBubble = true;
  718. }
  719. }
  720. function e_defaultPrevented(e) {
  721. return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false;
  722. }
  723. function e_stop(e) {
  724. e_preventDefault(e);
  725. e_stopPropagation(e);
  726. }
  727. function e_target(e) {
  728. return e.target || e.srcElement;
  729. }
  730. function e_button(e) {
  731. var b = e.which;
  732. if (b == null) {
  733. if (e.button & 1) {
  734. b = 1;
  735. } else if (e.button & 2) {
  736. b = 3;
  737. } else if (e.button & 4) {
  738. b = 2;
  739. }
  740. }
  741. if (mac && e.ctrlKey && b == 1) {
  742. b = 3;
  743. }
  744. return b;
  745. }
  746. // Detect drag-and-drop
  747. var dragAndDrop = function () {
  748. // There is *some* kind of drag-and-drop support in IE6-8, but I
  749. // couldn't get it to work yet.
  750. if (ie && ie_version < 9) {
  751. return false;
  752. }
  753. var div = elt('div');
  754. return "draggable" in div || "dragDrop" in div;
  755. }();
  756. var zwspSupported;
  757. function zeroWidthElement(measure) {
  758. if (zwspSupported == null) {
  759. var test = elt("span", "\u200B");
  760. removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
  761. if (measure.firstChild.offsetHeight != 0) {
  762. zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8);
  763. }
  764. }
  765. var node = zwspSupported ? elt("span", "\u200B") : elt("span", "\xA0", null, "display: inline-block; width: 1px; margin-right: -1px");
  766. node.setAttribute("cm-text", "");
  767. return node;
  768. }
  769. // Feature-detect IE's crummy client rect reporting for bidi text
  770. var badBidiRects;
  771. function hasBadBidiRects(measure) {
  772. if (badBidiRects != null) {
  773. return badBidiRects;
  774. }
  775. var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062EA"));
  776. var r0 = range(txt, 0, 1).getBoundingClientRect();
  777. var r1 = range(txt, 1, 2).getBoundingClientRect();
  778. removeChildren(measure);
  779. if (!r0 || r0.left == r0.right) {
  780. return false;
  781. } // Safari returns null in some cases (#2780)
  782. return badBidiRects = r1.right - r0.right < 3;
  783. }
  784. // See if "".split is the broken IE version, if so, provide an
  785. // alternative way to split lines.
  786. var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? function (string) {
  787. var pos = 0,
  788. result = [],
  789. l = string.length;
  790. while (pos <= l) {
  791. var nl = string.indexOf("\n", pos);
  792. if (nl == -1) {
  793. nl = string.length;
  794. }
  795. var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
  796. var rt = line.indexOf("\r");
  797. if (rt != -1) {
  798. result.push(line.slice(0, rt));
  799. pos += rt + 1;
  800. } else {
  801. result.push(line);
  802. pos = nl + 1;
  803. }
  804. }
  805. return result;
  806. } : function (string) {
  807. return string.split(/\r\n?|\n/);
  808. };
  809. var hasSelection = window.getSelection ? function (te) {
  810. try {
  811. return te.selectionStart != te.selectionEnd;
  812. } catch (e) {
  813. return false;
  814. }
  815. } : function (te) {
  816. var range$$1;
  817. try {
  818. range$$1 = te.ownerDocument.selection.createRange();
  819. } catch (e) {}
  820. if (!range$$1 || range$$1.parentElement() != te) {
  821. return false;
  822. }
  823. return range$$1.compareEndPoints("StartToEnd", range$$1) != 0;
  824. };
  825. var hasCopyEvent = function () {
  826. var e = elt("div");
  827. if ("oncopy" in e) {
  828. return true;
  829. }
  830. e.setAttribute("oncopy", "return;");
  831. return typeof e.oncopy == "function";
  832. }();
  833. var badZoomedRects = null;
  834. function hasBadZoomedRects(measure) {
  835. if (badZoomedRects != null) {
  836. return badZoomedRects;
  837. }
  838. var node = removeChildrenAndAdd(measure, elt("span", "x"));
  839. var normal = node.getBoundingClientRect();
  840. var fromRange = range(node, 0, 1).getBoundingClientRect();
  841. return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1;
  842. }
  843. // Known modes, by name and by MIME
  844. var modes = {},
  845. mimeModes = {};
  846. // Extra arguments are stored as the mode's dependencies, which is
  847. // used by (legacy) mechanisms like loadmode.js to automatically
  848. // load a mode. (Preferred mechanism is the require/define calls.)
  849. function defineMode(name, mode) {
  850. if (arguments.length > 2) {
  851. mode.dependencies = Array.prototype.slice.call(arguments, 2);
  852. }
  853. modes[name] = mode;
  854. }
  855. function defineMIME(mime, spec) {
  856. mimeModes[mime] = spec;
  857. }
  858. // Given a MIME type, a {name, ...options} config object, or a name
  859. // string, return a mode config object.
  860. function resolveMode(spec) {
  861. if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
  862. spec = mimeModes[spec];
  863. } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
  864. var found = mimeModes[spec.name];
  865. if (typeof found == "string") {
  866. found = { name: found };
  867. }
  868. spec = createObj(found, spec);
  869. spec.name = found.name;
  870. } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
  871. return resolveMode("application/xml");
  872. } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
  873. return resolveMode("application/json");
  874. }
  875. if (typeof spec == "string") {
  876. return { name: spec };
  877. } else {
  878. return spec || { name: "null" };
  879. }
  880. }
  881. // Given a mode spec (anything that resolveMode accepts), find and
  882. // initialize an actual mode object.
  883. function getMode(options, spec) {
  884. spec = resolveMode(spec);
  885. var mfactory = modes[spec.name];
  886. if (!mfactory) {
  887. return getMode(options, "text/plain");
  888. }
  889. var modeObj = mfactory(options, spec);
  890. if (modeExtensions.hasOwnProperty(spec.name)) {
  891. var exts = modeExtensions[spec.name];
  892. for (var prop in exts) {
  893. if (!exts.hasOwnProperty(prop)) {
  894. continue;
  895. }
  896. if (modeObj.hasOwnProperty(prop)) {
  897. modeObj["_" + prop] = modeObj[prop];
  898. }
  899. modeObj[prop] = exts[prop];
  900. }
  901. }
  902. modeObj.name = spec.name;
  903. if (spec.helperType) {
  904. modeObj.helperType = spec.helperType;
  905. }
  906. if (spec.modeProps) {
  907. for (var prop$1 in spec.modeProps) {
  908. modeObj[prop$1] = spec.modeProps[prop$1];
  909. }
  910. }
  911. return modeObj;
  912. }
  913. // This can be used to attach properties to mode objects from
  914. // outside the actual mode definition.
  915. var modeExtensions = {};
  916. function extendMode(mode, properties) {
  917. var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : modeExtensions[mode] = {};
  918. copyObj(properties, exts);
  919. }
  920. function copyState(mode, state) {
  921. if (state === true) {
  922. return state;
  923. }
  924. if (mode.copyState) {
  925. return mode.copyState(state);
  926. }
  927. var nstate = {};
  928. for (var n in state) {
  929. var val = state[n];
  930. if (val instanceof Array) {
  931. val = val.concat([]);
  932. }
  933. nstate[n] = val;
  934. }
  935. return nstate;
  936. }
  937. // Given a mode and a state (for that mode), find the inner mode and
  938. // state at the position that the state refers to.
  939. function innerMode(mode, state) {
  940. var info;
  941. while (mode.innerMode) {
  942. info = mode.innerMode(state);
  943. if (!info || info.mode == mode) {
  944. break;
  945. }
  946. state = info.state;
  947. mode = info.mode;
  948. }
  949. return info || { mode: mode, state: state };
  950. }
  951. function startState(mode, a1, a2) {
  952. return mode.startState ? mode.startState(a1, a2) : true;
  953. }
  954. // STRING STREAM
  955. // Fed to the mode parsers, provides helper functions to make
  956. // parsers more succinct.
  957. var StringStream = function StringStream(string, tabSize, lineOracle) {
  958. this.pos = this.start = 0;
  959. this.string = string;
  960. this.tabSize = tabSize || 8;
  961. this.lastColumnPos = this.lastColumnValue = 0;
  962. this.lineStart = 0;
  963. this.lineOracle = lineOracle;
  964. };
  965. StringStream.prototype.eol = function () {
  966. return this.pos >= this.string.length;
  967. };
  968. StringStream.prototype.sol = function () {
  969. return this.pos == this.lineStart;
  970. };
  971. StringStream.prototype.peek = function () {
  972. return this.string.charAt(this.pos) || undefined;
  973. };
  974. StringStream.prototype.next = function () {
  975. if (this.pos < this.string.length) {
  976. return this.string.charAt(this.pos++);
  977. }
  978. };
  979. StringStream.prototype.eat = function (match) {
  980. var ch = this.string.charAt(this.pos);
  981. var ok;
  982. if (typeof match == "string") {
  983. ok = ch == match;
  984. } else {
  985. ok = ch && (match.test ? match.test(ch) : match(ch));
  986. }
  987. if (ok) {
  988. ++this.pos;
  989. return ch;
  990. }
  991. };
  992. StringStream.prototype.eatWhile = function (match) {
  993. var start = this.pos;
  994. while (this.eat(match)) {}
  995. return this.pos > start;
  996. };
  997. StringStream.prototype.eatSpace = function () {
  998. var this$1 = this;
  999. var start = this.pos;
  1000. while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) {
  1001. ++this$1.pos;
  1002. }
  1003. return this.pos > start;
  1004. };
  1005. StringStream.prototype.skipToEnd = function () {
  1006. this.pos = this.string.length;
  1007. };
  1008. StringStream.prototype.skipTo = function (ch) {
  1009. var found = this.string.indexOf(ch, this.pos);
  1010. if (found > -1) {
  1011. this.pos = found;
  1012. return true;
  1013. }
  1014. };
  1015. StringStream.prototype.backUp = function (n) {
  1016. this.pos -= n;
  1017. };
  1018. StringStream.prototype.column = function () {
  1019. if (this.lastColumnPos < this.start) {
  1020. this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
  1021. this.lastColumnPos = this.start;
  1022. }
  1023. return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
  1024. };
  1025. StringStream.prototype.indentation = function () {
  1026. return countColumn(this.string, null, this.tabSize) - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
  1027. };
  1028. StringStream.prototype.match = function (pattern, consume, caseInsensitive) {
  1029. if (typeof pattern == "string") {
  1030. var cased = function cased(str) {
  1031. return caseInsensitive ? str.toLowerCase() : str;
  1032. };
  1033. var substr = this.string.substr(this.pos, pattern.length);
  1034. if (cased(substr) == cased(pattern)) {
  1035. if (consume !== false) {
  1036. this.pos += pattern.length;
  1037. }
  1038. return true;
  1039. }
  1040. } else {
  1041. var match = this.string.slice(this.pos).match(pattern);
  1042. if (match && match.index > 0) {
  1043. return null;
  1044. }
  1045. if (match && consume !== false) {
  1046. this.pos += match[0].length;
  1047. }
  1048. return match;
  1049. }
  1050. };
  1051. StringStream.prototype.current = function () {
  1052. return this.string.slice(this.start, this.pos);
  1053. };
  1054. StringStream.prototype.hideFirstChars = function (n, inner) {
  1055. this.lineStart += n;
  1056. try {
  1057. return inner();
  1058. } finally {
  1059. this.lineStart -= n;
  1060. }
  1061. };
  1062. StringStream.prototype.lookAhead = function (n) {
  1063. var oracle = this.lineOracle;
  1064. return oracle && oracle.lookAhead(n);
  1065. };
  1066. StringStream.prototype.baseToken = function () {
  1067. var oracle = this.lineOracle;
  1068. return oracle && oracle.baseToken(this.pos);
  1069. };
  1070. // Find the line object corresponding to the given line number.
  1071. function getLine(doc, n) {
  1072. n -= doc.first;
  1073. if (n < 0 || n >= doc.size) {
  1074. throw new Error("There is no line " + (n + doc.first) + " in the document.");
  1075. }
  1076. var chunk = doc;
  1077. while (!chunk.lines) {
  1078. for (var i = 0;; ++i) {
  1079. var child = chunk.children[i],
  1080. sz = child.chunkSize();
  1081. if (n < sz) {
  1082. chunk = child;
  1083. break;
  1084. }
  1085. n -= sz;
  1086. }
  1087. }
  1088. return chunk.lines[n];
  1089. }
  1090. // Get the part of a document between two positions, as an array of
  1091. // strings.
  1092. function getBetween(doc, start, end) {
  1093. var out = [],
  1094. n = start.line;
  1095. doc.iter(start.line, end.line + 1, function (line) {
  1096. var text = line.text;
  1097. if (n == end.line) {
  1098. text = text.slice(0, end.ch);
  1099. }
  1100. if (n == start.line) {
  1101. text = text.slice(start.ch);
  1102. }
  1103. out.push(text);
  1104. ++n;
  1105. });
  1106. return out;
  1107. }
  1108. // Get the lines between from and to, as array of strings.
  1109. function getLines(doc, from, to) {
  1110. var out = [];
  1111. doc.iter(from, to, function (line) {
  1112. out.push(line.text);
  1113. }); // iter aborts when callback returns truthy value
  1114. return out;
  1115. }
  1116. // Update the height of a line, propagating the height change
  1117. // upwards to parent nodes.
  1118. function updateLineHeight(line, height) {
  1119. var diff = height - line.height;
  1120. if (diff) {
  1121. for (var n = line; n; n = n.parent) {
  1122. n.height += diff;
  1123. }
  1124. }
  1125. }
  1126. // Given a line object, find its line number by walking up through
  1127. // its parent links.
  1128. function lineNo(line) {
  1129. if (line.parent == null) {
  1130. return null;
  1131. }
  1132. var cur = line.parent,
  1133. no = indexOf(cur.lines, line);
  1134. for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
  1135. for (var i = 0;; ++i) {
  1136. if (chunk.children[i] == cur) {
  1137. break;
  1138. }
  1139. no += chunk.children[i].chunkSize();
  1140. }
  1141. }
  1142. return no + cur.first;
  1143. }
  1144. // Find the line at the given vertical position, using the height
  1145. // information in the document tree.
  1146. function _lineAtHeight(chunk, h) {
  1147. var n = chunk.first;
  1148. outer: do {
  1149. for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) {
  1150. var child = chunk.children[i$1],
  1151. ch = child.height;
  1152. if (h < ch) {
  1153. chunk = child;
  1154. continue outer;
  1155. }
  1156. h -= ch;
  1157. n += child.chunkSize();
  1158. }
  1159. return n;
  1160. } while (!chunk.lines);
  1161. var i = 0;
  1162. for (; i < chunk.lines.length; ++i) {
  1163. var line = chunk.lines[i],
  1164. lh = line.height;
  1165. if (h < lh) {
  1166. break;
  1167. }
  1168. h -= lh;
  1169. }
  1170. return n + i;
  1171. }
  1172. function isLine(doc, l) {
  1173. return l >= doc.first && l < doc.first + doc.size;
  1174. }
  1175. function lineNumberFor(options, i) {
  1176. return String(options.lineNumberFormatter(i + options.firstLineNumber));
  1177. }
  1178. // A Pos instance represents a position within the text.
  1179. function Pos(line, ch, sticky) {
  1180. if (sticky === void 0) sticky = null;
  1181. if (!(this instanceof Pos)) {
  1182. return new Pos(line, ch, sticky);
  1183. }
  1184. this.line = line;
  1185. this.ch = ch;
  1186. this.sticky = sticky;
  1187. }
  1188. // Compare two positions, return 0 if they are the same, a negative
  1189. // number when a is less, and a positive number otherwise.
  1190. function cmp(a, b) {
  1191. return a.line - b.line || a.ch - b.ch;
  1192. }
  1193. function equalCursorPos(a, b) {
  1194. return a.sticky == b.sticky && cmp(a, b) == 0;
  1195. }
  1196. function copyPos(x) {
  1197. return Pos(x.line, x.ch);
  1198. }
  1199. function maxPos(a, b) {
  1200. return cmp(a, b) < 0 ? b : a;
  1201. }
  1202. function minPos(a, b) {
  1203. return cmp(a, b) < 0 ? a : b;
  1204. }
  1205. // Most of the external API clips given positions to make sure they
  1206. // actually exist within the document.
  1207. function clipLine(doc, n) {
  1208. return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));
  1209. }
  1210. function _clipPos(doc, pos) {
  1211. if (pos.line < doc.first) {
  1212. return Pos(doc.first, 0);
  1213. }
  1214. var last = doc.first + doc.size - 1;
  1215. if (pos.line > last) {
  1216. return Pos(last, getLine(doc, last).text.length);
  1217. }
  1218. return clipToLen(pos, getLine(doc, pos.line).text.length);
  1219. }
  1220. function clipToLen(pos, linelen) {
  1221. var ch = pos.ch;
  1222. if (ch == null || ch > linelen) {
  1223. return Pos(pos.line, linelen);
  1224. } else if (ch < 0) {
  1225. return Pos(pos.line, 0);
  1226. } else {
  1227. return pos;
  1228. }
  1229. }
  1230. function clipPosArray(doc, array) {
  1231. var out = [];
  1232. for (var i = 0; i < array.length; i++) {
  1233. out[i] = _clipPos(doc, array[i]);
  1234. }
  1235. return out;
  1236. }
  1237. var SavedContext = function SavedContext(state, lookAhead) {
  1238. this.state = state;
  1239. this.lookAhead = lookAhead;
  1240. };
  1241. var Context = function Context(doc, state, line, lookAhead) {
  1242. this.state = state;
  1243. this.doc = doc;
  1244. this.line = line;
  1245. this.maxLookAhead = lookAhead || 0;
  1246. this.baseTokens = null;
  1247. this.baseTokenPos = 1;
  1248. };
  1249. Context.prototype.lookAhead = function (n) {
  1250. var line = this.doc.getLine(this.line + n);
  1251. if (line != null && n > this.maxLookAhead) {
  1252. this.maxLookAhead = n;
  1253. }
  1254. return line;
  1255. };
  1256. Context.prototype.baseToken = function (n) {
  1257. var this$1 = this;
  1258. if (!this.baseTokens) {
  1259. return null;
  1260. }
  1261. while (this.baseTokens[this.baseTokenPos] <= n) {
  1262. this$1.baseTokenPos += 2;
  1263. }
  1264. var type = this.baseTokens[this.baseTokenPos + 1];
  1265. return {
  1266. type: type && type.replace(/( |^)overlay .*/, ""),
  1267. size: this.baseTokens[this.baseTokenPos] - n
  1268. };
  1269. };
  1270. Context.prototype.nextLine = function () {
  1271. this.line++;
  1272. if (this.maxLookAhead > 0) {
  1273. this.maxLookAhead--;
  1274. }
  1275. };
  1276. Context.fromSaved = function (doc, saved, line) {
  1277. if (saved instanceof SavedContext) {
  1278. return new Context(doc, copyState(doc.mode, saved.state), line, saved.lookAhead);
  1279. } else {
  1280. return new Context(doc, copyState(doc.mode, saved), line);
  1281. }
  1282. };
  1283. Context.prototype.save = function (copy) {
  1284. var state = copy !== false ? copyState(this.doc.mode, this.state) : this.state;
  1285. return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state;
  1286. };
  1287. // Compute a style array (an array starting with a mode generation
  1288. // -- for invalidation -- followed by pairs of end positions and
  1289. // style strings), which is used to highlight the tokens on the
  1290. // line.
  1291. function highlightLine(cm, line, context, forceToEnd) {
  1292. // A styles array always starts with a number identifying the
  1293. // mode/overlays that it is based on (for easy invalidation).
  1294. var st = [cm.state.modeGen],
  1295. lineClasses = {};
  1296. // Compute the base array of styles
  1297. runMode(cm, line.text, cm.doc.mode, context, function (end, style) {
  1298. return st.push(end, style);
  1299. }, lineClasses, forceToEnd);
  1300. var state = context.state;
  1301. // Run overlays, adjust style array.
  1302. var loop = function loop(o) {
  1303. context.baseTokens = st;
  1304. var overlay = cm.state.overlays[o],
  1305. i = 1,
  1306. at = 0;
  1307. context.state = true;
  1308. runMode(cm, line.text, overlay.mode, context, function (end, style) {
  1309. var start = i;
  1310. // Ensure there's a token end at the current position, and that i points at it
  1311. while (at < end) {
  1312. var i_end = st[i];
  1313. if (i_end > end) {
  1314. st.splice(i, 1, end, st[i + 1], i_end);
  1315. }
  1316. i += 2;
  1317. at = Math.min(end, i_end);
  1318. }
  1319. if (!style) {
  1320. return;
  1321. }
  1322. if (overlay.opaque) {
  1323. st.splice(start, i - start, end, "overlay " + style);
  1324. i = start + 2;
  1325. } else {
  1326. for (; start < i; start += 2) {
  1327. var cur = st[start + 1];
  1328. st[start + 1] = (cur ? cur + " " : "") + "overlay " + style;
  1329. }
  1330. }
  1331. }, lineClasses);
  1332. context.state = state;
  1333. context.baseTokens = null;
  1334. context.baseTokenPos = 1;
  1335. };
  1336. for (var o = 0; o < cm.state.overlays.length; ++o) {
  1337. loop(o);
  1338. }return { styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null };
  1339. }
  1340. function getLineStyles(cm, line, updateFrontier) {
  1341. if (!line.styles || line.styles[0] != cm.state.modeGen) {
  1342. var context = getContextBefore(cm, lineNo(line));
  1343. var resetState = line.text.length > cm.options.maxHighlightLength && copyState(cm.doc.mode, context.state);
  1344. var result = highlightLine(cm, line, context);
  1345. if (resetState) {
  1346. context.state = resetState;
  1347. }
  1348. line.stateAfter = context.save(!resetState);
  1349. line.styles = result.styles;
  1350. if (result.classes) {
  1351. line.styleClasses = result.classes;
  1352. } else if (line.styleClasses) {
  1353. line.styleClasses = null;
  1354. }
  1355. if (updateFrontier === cm.doc.highlightFrontier) {
  1356. cm.doc.modeFrontier = Math.max(cm.doc.modeFrontier, ++cm.doc.highlightFrontier);
  1357. }
  1358. }
  1359. return line.styles;
  1360. }
  1361. function getContextBefore(cm, n, precise) {
  1362. var doc = cm.doc,
  1363. display = cm.display;
  1364. if (!doc.mode.startState) {
  1365. return new Context(doc, true, n);
  1366. }
  1367. var start = findStartLine(cm, n, precise);
  1368. var saved = start > doc.first && getLine(doc, start - 1).stateAfter;
  1369. var context = saved ? Context.fromSaved(doc, saved, start) : new Context(doc, startState(doc.mode), start);
  1370. doc.iter(start, n, function (line) {
  1371. processLine(cm, line.text, context);
  1372. var pos = context.line;
  1373. line.stateAfter = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo ? context.save() : null;
  1374. context.nextLine();
  1375. });
  1376. if (precise) {
  1377. doc.modeFrontier = context.line;
  1378. }
  1379. return context;
  1380. }
  1381. // Lightweight form of highlight -- proceed over this line and
  1382. // update state, but don't save a style array. Used for lines that
  1383. // aren't currently visible.
  1384. function processLine(cm, text, context, startAt) {
  1385. var mode = cm.doc.mode;
  1386. var stream = new StringStream(text, cm.options.tabSize, context);
  1387. stream.start = stream.pos = startAt || 0;
  1388. if (text == "") {
  1389. callBlankLine(mode, context.state);
  1390. }
  1391. while (!stream.eol()) {
  1392. readToken(mode, stream, context.state);
  1393. stream.start = stream.pos;
  1394. }
  1395. }
  1396. function callBlankLine(mode, state) {
  1397. if (mode.blankLine) {
  1398. return mode.blankLine(state);
  1399. }
  1400. if (!mode.innerMode) {
  1401. return;
  1402. }
  1403. var inner = innerMode(mode, state);
  1404. if (inner.mode.blankLine) {
  1405. return inner.mode.blankLine(inner.state);
  1406. }
  1407. }
  1408. function readToken(mode, stream, state, inner) {
  1409. for (var i = 0; i < 10; i++) {
  1410. if (inner) {
  1411. inner[0] = innerMode(mode, state).mode;
  1412. }
  1413. var style = mode.token(stream, state);
  1414. if (stream.pos > stream.start) {
  1415. return style;
  1416. }
  1417. }
  1418. throw new Error("Mode " + mode.name + " failed to advance stream.");
  1419. }
  1420. var Token = function Token(stream, type, state) {
  1421. this.start = stream.start;
  1422. this.end = stream.pos;
  1423. this.string = stream.current();
  1424. this.type = type || null;
  1425. this.state = state;
  1426. };
  1427. // Utility for getTokenAt and getLineTokens
  1428. function takeToken(cm, pos, precise, asArray) {
  1429. var doc = cm.doc,
  1430. mode = doc.mode,
  1431. style;
  1432. pos = _clipPos(doc, pos);
  1433. var line = getLine(doc, pos.line),
  1434. context = getContextBefore(cm, pos.line, precise);
  1435. var stream = new StringStream(line.text, cm.options.tabSize, context),
  1436. tokens;
  1437. if (asArray) {
  1438. tokens = [];
  1439. }
  1440. while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
  1441. stream.start = stream.pos;
  1442. style = readToken(mode, stream, context.state);
  1443. if (asArray) {
  1444. tokens.push(new Token(stream, style, copyState(doc.mode, context.state)));
  1445. }
  1446. }
  1447. return asArray ? tokens : new Token(stream, style, context.state);
  1448. }
  1449. function extractLineClasses(type, output) {
  1450. if (type) {
  1451. for (;;) {
  1452. var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
  1453. if (!lineClass) {
  1454. break;
  1455. }
  1456. type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
  1457. var prop = lineClass[1] ? "bgClass" : "textClass";
  1458. if (output[prop] == null) {
  1459. output[prop] = lineClass[2];
  1460. } else if (!new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)").test(output[prop])) {
  1461. output[prop] += " " + lineClass[2];
  1462. }
  1463. }
  1464. }
  1465. return type;
  1466. }
  1467. // Run the given mode's parser over a line, calling f for each token.
  1468. function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) {
  1469. var flattenSpans = mode.flattenSpans;
  1470. if (flattenSpans == null) {
  1471. flattenSpans = cm.options.flattenSpans;
  1472. }
  1473. var curStart = 0,
  1474. curStyle = null;
  1475. var stream = new StringStream(text, cm.options.tabSize, context),
  1476. style;
  1477. var inner = cm.options.addModeClass && [null];
  1478. if (text == "") {
  1479. extractLineClasses(callBlankLine(mode, context.state), lineClasses);
  1480. }
  1481. while (!stream.eol()) {
  1482. if (stream.pos > cm.options.maxHighlightLength) {
  1483. flattenSpans = false;
  1484. if (forceToEnd) {
  1485. processLine(cm, text, context, stream.pos);
  1486. }
  1487. stream.pos = text.length;
  1488. style = null;
  1489. } else {
  1490. style = extractLineClasses(readToken(mode, stream, context.state, inner), lineClasses);
  1491. }
  1492. if (inner) {
  1493. var mName = inner[0].name;
  1494. if (mName) {
  1495. style = "m-" + (style ? mName + " " + style : mName);
  1496. }
  1497. }
  1498. if (!flattenSpans || curStyle != style) {
  1499. while (curStart < stream.start) {
  1500. curStart = Math.min(stream.start, curStart + 5000);
  1501. f(curStart, curStyle);
  1502. }
  1503. curStyle = style;
  1504. }
  1505. stream.start = stream.pos;
  1506. }
  1507. while (curStart < stream.pos) {
  1508. // Webkit seems to refuse to render text nodes longer than 57444
  1509. // characters, and returns inaccurate measurements in nodes
  1510. // starting around 5000 chars.
  1511. var pos = Math.min(stream.pos, curStart + 5000);
  1512. f(pos, curStyle);
  1513. curStart = pos;
  1514. }
  1515. }
  1516. // Finds the line to start with when starting a parse. Tries to
  1517. // find a line with a stateAfter, so that it can start with a
  1518. // valid state. If that fails, it returns the line with the
  1519. // smallest indentation, which tends to need the least context to
  1520. // parse correctly.
  1521. function findStartLine(cm, n, precise) {
  1522. var minindent,
  1523. minline,
  1524. doc = cm.doc;
  1525. var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
  1526. for (var search = n; search > lim; --search) {
  1527. if (search <= doc.first) {
  1528. return doc.first;
  1529. }
  1530. var line = getLine(doc, search - 1),
  1531. after = line.stateAfter;
  1532. if (after && (!precise || search + (after instanceof SavedContext ? after.lookAhead : 0) <= doc.modeFrontier)) {
  1533. return search;
  1534. }
  1535. var indented = countColumn(line.text, null, cm.options.tabSize);
  1536. if (minline == null || minindent > indented) {
  1537. minline = search - 1;
  1538. minindent = indented;
  1539. }
  1540. }
  1541. return minline;
  1542. }
  1543. function retreatFrontier(doc, n) {
  1544. doc.modeFrontier = Math.min(doc.modeFrontier, n);
  1545. if (doc.highlightFrontier < n - 10) {
  1546. return;
  1547. }
  1548. var start = doc.first;
  1549. for (var line = n - 1; line > start; line--) {
  1550. var saved = getLine(doc, line).stateAfter;
  1551. // change is on 3
  1552. // state on line 1 looked ahead 2 -- so saw 3
  1553. // test 1 + 2 < 3 should cover this
  1554. if (saved && (!(saved instanceof SavedContext) || line + saved.lookAhead < n)) {
  1555. start = line + 1;
  1556. break;
  1557. }
  1558. }
  1559. doc.highlightFrontier = Math.min(doc.highlightFrontier, start);
  1560. }
  1561. // Optimize some code when these features are not used.
  1562. var sawReadOnlySpans = false,
  1563. sawCollapsedSpans = false;
  1564. function seeReadOnlySpans() {
  1565. sawReadOnlySpans = true;
  1566. }
  1567. function seeCollapsedSpans() {
  1568. sawCollapsedSpans = true;
  1569. }
  1570. // TEXTMARKER SPANS
  1571. function MarkedSpan(marker, from, to) {
  1572. this.marker = marker;
  1573. this.from = from;
  1574. this.to = to;
  1575. }
  1576. // Search an array of spans for a span matching the given marker.
  1577. function getMarkedSpanFor(spans, marker) {
  1578. if (spans) {
  1579. for (var i = 0; i < spans.length; ++i) {
  1580. var span = spans[i];
  1581. if (span.marker == marker) {
  1582. return span;
  1583. }
  1584. }
  1585. }
  1586. }
  1587. // Remove a span from an array, returning undefined if no spans are
  1588. // left (we don't store arrays for lines without spans).
  1589. function removeMarkedSpan(spans, span) {
  1590. var r;
  1591. for (var i = 0; i < spans.length; ++i) {
  1592. if (spans[i] != span) {
  1593. (r || (r = [])).push(spans[i]);
  1594. }
  1595. }
  1596. return r;
  1597. }
  1598. // Add a span to a line.
  1599. function addMarkedSpan(line, span) {
  1600. line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
  1601. span.marker.attachLine(line);
  1602. }
  1603. // Used for the algorithm that adjusts markers for a change in the
  1604. // document. These functions cut an array of spans at a given
  1605. // character position, returning an array of remaining chunks (or
  1606. // undefined if nothing remains).
  1607. function markedSpansBefore(old, startCh, isInsert) {
  1608. var nw;
  1609. if (old) {
  1610. for (var i = 0; i < old.length; ++i) {
  1611. var span = old[i],
  1612. marker = span.marker;
  1613. var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
  1614. if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
  1615. var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
  1616. }
  1617. }
  1618. }
  1619. return nw;
  1620. }
  1621. function markedSpansAfter(old, endCh, isInsert) {
  1622. var nw;
  1623. if (old) {
  1624. for (var i = 0; i < old.length; ++i) {
  1625. var span = old[i],
  1626. marker = span.marker;
  1627. var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
  1628. if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
  1629. var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh, span.to == null ? null : span.to - endCh));
  1630. }
  1631. }
  1632. }
  1633. return nw;
  1634. }
  1635. // Given a change object, compute the new set of marker spans that
  1636. // cover the line in which the change took place. Removes spans
  1637. // entirely within the change, reconnects spans belonging to the
  1638. // same marker that appear on both sides of the change, and cuts off
  1639. // spans partially within the change. Returns an array of span
  1640. // arrays with one element for each line in (after) the change.
  1641. function stretchSpansOverChange(doc, change) {
  1642. if (change.full) {
  1643. return null;
  1644. }
  1645. var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
  1646. var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
  1647. if (!oldFirst && !oldLast) {
  1648. return null;
  1649. }
  1650. var startCh = change.from.ch,
  1651. endCh = change.to.ch,
  1652. isInsert = cmp(change.from, change.to) == 0;
  1653. // Get the spans that 'stick out' on both sides
  1654. var first = markedSpansBefore(oldFirst, startCh, isInsert);
  1655. var last = markedSpansAfter(oldLast, endCh, isInsert);
  1656. // Next, merge those two ends
  1657. var sameLine = change.text.length == 1,
  1658. offset = lst(change.text).length + (sameLine ? startCh : 0);
  1659. if (first) {
  1660. // Fix up .to properties of first
  1661. for (var i = 0; i < first.length; ++i) {
  1662. var span = first[i];
  1663. if (span.to == null) {
  1664. var found = getMarkedSpanFor(last, span.marker);
  1665. if (!found) {
  1666. span.to = startCh;
  1667. } else if (sameLine) {
  1668. span.to = found.to == null ? null : found.to + offset;
  1669. }
  1670. }
  1671. }
  1672. }
  1673. if (last) {
  1674. // Fix up .from in last (or move them into first in case of sameLine)
  1675. for (var i$1 = 0; i$1 < last.length; ++i$1) {
  1676. var span$1 = last[i$1];
  1677. if (span$1.to != null) {
  1678. span$1.to += offset;
  1679. }
  1680. if (span$1.from == null) {
  1681. var found$1 = getMarkedSpanFor(first, span$1.marker);
  1682. if (!found$1) {
  1683. span$1.from = offset;
  1684. if (sameLine) {
  1685. (first || (first = [])).push(span$1);
  1686. }
  1687. }
  1688. } else {
  1689. span$1.from += offset;
  1690. if (sameLine) {
  1691. (first || (first = [])).push(span$1);
  1692. }
  1693. }
  1694. }
  1695. }
  1696. // Make sure we didn't create any zero-length spans
  1697. if (first) {
  1698. first = clearEmptySpans(first);
  1699. }
  1700. if (last && last != first) {
  1701. last = clearEmptySpans(last);
  1702. }
  1703. var newMarkers = [first];
  1704. if (!sameLine) {
  1705. // Fill gap with whole-line-spans
  1706. var gap = change.text.length - 2,
  1707. gapMarkers;
  1708. if (gap > 0 && first) {
  1709. for (var i$2 = 0; i$2 < first.length; ++i$2) {
  1710. if (first[i$2].to == null) {
  1711. (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2].marker, null, null));
  1712. }
  1713. }
  1714. }
  1715. for (var i$3 = 0; i$3 < gap; ++i$3) {
  1716. newMarkers.push(gapMarkers);
  1717. }
  1718. newMarkers.push(last);
  1719. }
  1720. return newMarkers;
  1721. }
  1722. // Remove spans that are empty and don't have a clearWhenEmpty
  1723. // option of false.
  1724. function clearEmptySpans(spans) {
  1725. for (var i = 0; i < spans.length; ++i) {
  1726. var span = spans[i];
  1727. if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false) {
  1728. spans.splice(i--, 1);
  1729. }
  1730. }
  1731. if (!spans.length) {
  1732. return null;
  1733. }
  1734. return spans;
  1735. }
  1736. // Used to 'clip' out readOnly ranges when making a change.
  1737. function removeReadOnlyRanges(doc, from, to) {
  1738. var markers = null;
  1739. doc.iter(from.line, to.line + 1, function (line) {
  1740. if (line.markedSpans) {
  1741. for (var i = 0; i < line.markedSpans.length; ++i) {
  1742. var mark = line.markedSpans[i].marker;
  1743. if (mark.readOnly && (!markers || indexOf(markers, mark) == -1)) {
  1744. (markers || (markers = [])).push(mark);
  1745. }
  1746. }
  1747. }
  1748. });
  1749. if (!markers) {
  1750. return null;
  1751. }
  1752. var parts = [{ from: from, to: to }];
  1753. for (var i = 0; i < markers.length; ++i) {
  1754. var mk = markers[i],
  1755. m = mk.find(0);
  1756. for (var j = 0; j < parts.length; ++j) {
  1757. var p = parts[j];
  1758. if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) {
  1759. continue;
  1760. }
  1761. var newParts = [j, 1],
  1762. dfrom = cmp(p.from, m.from),
  1763. dto = cmp(p.to, m.to);
  1764. if (dfrom < 0 || !mk.inclusiveLeft && !dfrom) {
  1765. newParts.push({ from: p.from, to: m.from });
  1766. }
  1767. if (dto > 0 || !mk.inclusiveRight && !dto) {
  1768. newParts.push({ from: m.to, to: p.to });
  1769. }
  1770. parts.splice.apply(parts, newParts);
  1771. j += newParts.length - 3;
  1772. }
  1773. }
  1774. return parts;
  1775. }
  1776. // Connect or disconnect spans from a line.
  1777. function detachMarkedSpans(line) {
  1778. var spans = line.markedSpans;
  1779. if (!spans) {
  1780. return;
  1781. }
  1782. for (var i = 0; i < spans.length; ++i) {
  1783. spans[i].marker.detachLine(line);
  1784. }
  1785. line.markedSpans = null;
  1786. }
  1787. function attachMarkedSpans(line, spans) {
  1788. if (!spans) {
  1789. return;
  1790. }
  1791. for (var i = 0; i < spans.length; ++i) {
  1792. spans[i].marker.attachLine(line);
  1793. }
  1794. line.markedSpans = spans;
  1795. }
  1796. // Helpers used when computing which overlapping collapsed span
  1797. // counts as the larger one.
  1798. function extraLeft(marker) {
  1799. return marker.inclusiveLeft ? -1 : 0;
  1800. }
  1801. function extraRight(marker) {
  1802. return marker.inclusiveRight ? 1 : 0;
  1803. }
  1804. // Returns a number indicating which of two overlapping collapsed
  1805. // spans is larger (and thus includes the other). Falls back to
  1806. // comparing ids when the spans cover exactly the same range.
  1807. function compareCollapsedMarkers(a, b) {
  1808. var lenDiff = a.lines.length - b.lines.length;
  1809. if (lenDiff != 0) {
  1810. return lenDiff;
  1811. }
  1812. var aPos = a.find(),
  1813. bPos = b.find();
  1814. var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
  1815. if (fromCmp) {
  1816. return -fromCmp;
  1817. }
  1818. var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
  1819. if (toCmp) {
  1820. return toCmp;
  1821. }
  1822. return b.id - a.id;
  1823. }
  1824. // Find out whether a line ends or starts in a collapsed span. If
  1825. // so, return the marker for that span.
  1826. function collapsedSpanAtSide(line, start) {
  1827. var sps = sawCollapsedSpans && line.markedSpans,
  1828. found;
  1829. if (sps) {
  1830. for (var sp = void 0, i = 0; i < sps.length; ++i) {
  1831. sp = sps[i];
  1832. if (sp.marker.collapsed && (start ? sp.from : sp.to) == null && (!found || compareCollapsedMarkers(found, sp.marker) < 0)) {
  1833. found = sp.marker;
  1834. }
  1835. }
  1836. }
  1837. return found;
  1838. }
  1839. function collapsedSpanAtStart(line) {
  1840. return collapsedSpanAtSide(line, true);
  1841. }
  1842. function collapsedSpanAtEnd(line) {
  1843. return collapsedSpanAtSide(line, false);
  1844. }
  1845. function collapsedSpanAround(line, ch) {
  1846. var sps = sawCollapsedSpans && line.markedSpans,
  1847. found;
  1848. if (sps) {
  1849. for (var i = 0; i < sps.length; ++i) {
  1850. var sp = sps[i];
  1851. if (sp.marker.collapsed && (sp.from == null || sp.from < ch) && (sp.to == null || sp.to > ch) && (!found || compareCollapsedMarkers(found, sp.marker) < 0)) {
  1852. found = sp.marker;
  1853. }
  1854. }
  1855. }
  1856. return found;
  1857. }
  1858. // Test whether there exists a collapsed span that partially
  1859. // overlaps (covers the start or end, but not both) of a new span.
  1860. // Such overlap is not allowed.
  1861. function conflictingCollapsedRange(doc, lineNo$$1, from, to, marker) {
  1862. var line = getLine(doc, lineNo$$1);
  1863. var sps = sawCollapsedSpans && line.markedSpans;
  1864. if (sps) {
  1865. for (var i = 0; i < sps.length; ++i) {
  1866. var sp = sps[i];
  1867. if (!sp.marker.collapsed) {
  1868. continue;
  1869. }
  1870. var found = sp.marker.find(0);
  1871. var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
  1872. var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
  1873. if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) {
  1874. continue;
  1875. }
  1876. if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) || fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0)) {
  1877. return true;
  1878. }
  1879. }
  1880. }
  1881. }
  1882. // A visual line is a line as drawn on the screen. Folding, for
  1883. // example, can cause multiple logical lines to appear on the same
  1884. // visual line. This finds the start of the visual line that the
  1885. // given line is part of (usually that is the line itself).
  1886. function visualLine(line) {
  1887. var merged;
  1888. while (merged = collapsedSpanAtStart(line)) {
  1889. line = merged.find(-1, true).line;
  1890. }
  1891. return line;
  1892. }
  1893. function visualLineEnd(line) {
  1894. var merged;
  1895. while (merged = collapsedSpanAtEnd(line)) {
  1896. line = merged.find(1, true).line;
  1897. }
  1898. return line;
  1899. }
  1900. // Returns an array of logical lines that continue the visual line
  1901. // started by the argument, or undefined if there are no such lines.
  1902. function visualLineContinued(line) {
  1903. var merged, lines;
  1904. while (merged = collapsedSpanAtEnd(line)) {
  1905. line = merged.find(1, true).line;(lines || (lines = [])).push(line);
  1906. }
  1907. return lines;
  1908. }
  1909. // Get the line number of the start of the visual line that the
  1910. // given line number is part of.
  1911. function visualLineNo(doc, lineN) {
  1912. var line = getLine(doc, lineN),
  1913. vis = visualLine(line);
  1914. if (line == vis) {
  1915. return lineN;
  1916. }
  1917. return lineNo(vis);
  1918. }
  1919. // Get the line number of the start of the next visual line after
  1920. // the given line.
  1921. function visualLineEndNo(doc, lineN) {
  1922. if (lineN > doc.lastLine()) {
  1923. return lineN;
  1924. }
  1925. var line = getLine(doc, lineN),
  1926. merged;
  1927. if (!lineIsHidden(doc, line)) {
  1928. return lineN;
  1929. }
  1930. while (merged = collapsedSpanAtEnd(line)) {
  1931. line = merged.find(1, true).line;
  1932. }
  1933. return lineNo(line) + 1;
  1934. }
  1935. // Compute whether a line is hidden. Lines count as hidden when they
  1936. // are part of a visual line that starts with another line, or when
  1937. // they are entirely covered by collapsed, non-widget span.
  1938. function lineIsHidden(doc, line) {
  1939. var sps = sawCollapsedSpans && line.markedSpans;
  1940. if (sps) {
  1941. for (var sp = void 0, i = 0; i < sps.length; ++i) {
  1942. sp = sps[i];
  1943. if (!sp.marker.collapsed) {
  1944. continue;
  1945. }
  1946. if (sp.from == null) {
  1947. return true;
  1948. }
  1949. if (sp.marker.widgetNode) {
  1950. continue;
  1951. }
  1952. if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp)) {
  1953. return true;
  1954. }
  1955. }
  1956. }
  1957. }
  1958. function lineIsHiddenInner(doc, line, span) {
  1959. if (span.to == null) {
  1960. var end = span.marker.find(1, true);
  1961. return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker));
  1962. }
  1963. if (span.marker.inclusiveRight && span.to == line.text.length) {
  1964. return true;
  1965. }
  1966. for (var sp = void 0, i = 0; i < line.markedSpans.length; ++i) {
  1967. sp = line.markedSpans[i];
  1968. if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to && (sp.to == null || sp.to != span.from) && (sp.marker.inclusiveLeft || span.marker.inclusiveRight) && lineIsHiddenInner(doc, line, sp)) {
  1969. return true;
  1970. }
  1971. }
  1972. }
  1973. // Find the height above the given line.
  1974. function _heightAtLine(lineObj) {
  1975. lineObj = visualLine(lineObj);
  1976. var h = 0,
  1977. chunk = lineObj.parent;
  1978. for (var i = 0; i < chunk.lines.length; ++i) {
  1979. var line = chunk.lines[i];
  1980. if (line == lineObj) {
  1981. break;
  1982. } else {
  1983. h += line.height;
  1984. }
  1985. }
  1986. for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
  1987. for (var i$1 = 0; i$1 < p.children.length; ++i$1) {
  1988. var cur = p.children[i$1];
  1989. if (cur == chunk) {
  1990. break;
  1991. } else {
  1992. h += cur.height;
  1993. }
  1994. }
  1995. }
  1996. return h;
  1997. }
  1998. // Compute the character length of a line, taking into account
  1999. // collapsed ranges (see markText) that might hide parts, and join
  2000. // other lines onto it.
  2001. function lineLength(line) {
  2002. if (line.height == 0) {
  2003. return 0;
  2004. }
  2005. var len = line.text.length,
  2006. merged,
  2007. cur = line;
  2008. while (merged = collapsedSpanAtStart(cur)) {
  2009. var found = merged.find(0, true);
  2010. cur = found.from.line;
  2011. len += found.from.ch - found.to.ch;
  2012. }
  2013. cur = line;
  2014. while (merged = collapsedSpanAtEnd(cur)) {
  2015. var found$1 = merged.find(0, true);
  2016. len -= cur.text.length - found$1.from.ch;
  2017. cur = found$1.to.line;
  2018. len += cur.text.length - found$1.to.ch;
  2019. }
  2020. return len;
  2021. }
  2022. // Find the longest line in the document.
  2023. function findMaxLine(cm) {
  2024. var d = cm.display,
  2025. doc = cm.doc;
  2026. d.maxLine = getLine(doc, doc.first);
  2027. d.maxLineLength = lineLength(d.maxLine);
  2028. d.maxLineChanged = true;
  2029. doc.iter(function (line) {
  2030. var len = lineLength(line);
  2031. if (len > d.maxLineLength) {
  2032. d.maxLineLength = len;
  2033. d.maxLine = line;
  2034. }
  2035. });
  2036. }
  2037. // LINE DATA STRUCTURE
  2038. // Line objects. These hold state related to a line, including
  2039. // highlighting info (the styles array).
  2040. var Line = function Line(text, markedSpans, estimateHeight) {
  2041. this.text = text;
  2042. attachMarkedSpans(this, markedSpans);
  2043. this.height = estimateHeight ? estimateHeight(this) : 1;
  2044. };
  2045. Line.prototype.lineNo = function () {
  2046. return lineNo(this);
  2047. };
  2048. eventMixin(Line);
  2049. // Change the content (text, markers) of a line. Automatically
  2050. // invalidates cached information and tries to re-estimate the
  2051. // line's height.
  2052. function updateLine(line, text, markedSpans, estimateHeight) {
  2053. line.text = text;
  2054. if (line.stateAfter) {
  2055. line.stateAfter = null;
  2056. }
  2057. if (line.styles) {
  2058. line.styles = null;
  2059. }
  2060. if (line.order != null) {
  2061. line.order = null;
  2062. }
  2063. detachMarkedSpans(line);
  2064. attachMarkedSpans(line, markedSpans);
  2065. var estHeight = estimateHeight ? estimateHeight(line) : 1;
  2066. if (estHeight != line.height) {
  2067. updateLineHeight(line, estHeight);
  2068. }
  2069. }
  2070. // Detach a line from the document tree and its markers.
  2071. function cleanUpLine(line) {
  2072. line.parent = null;
  2073. detachMarkedSpans(line);
  2074. }
  2075. // Convert a style as returned by a mode (either null, or a string
  2076. // containing one or more styles) to a CSS style. This is cached,
  2077. // and also looks for line-wide styles.
  2078. var styleToClassCache = {},
  2079. styleToClassCacheWithMode = {};
  2080. function interpretTokenStyle(style, options) {
  2081. if (!style || /^\s*$/.test(style)) {
  2082. return null;
  2083. }
  2084. var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
  2085. return cache[style] || (cache[style] = style.replace(/\S+/g, "cm-$&"));
  2086. }
  2087. // Render the DOM representation of the text of a line. Also builds
  2088. // up a 'line map', which points at the DOM nodes that represent
  2089. // specific stretches of text, and is used by the measuring code.
  2090. // The returned object contains the DOM node, this map, and
  2091. // information about line-wide styles that were set by the mode.
  2092. function buildLineContent(cm, lineView) {
  2093. // The padding-right forces the element to have a 'border', which
  2094. // is needed on Webkit to be able to get line-level bounding
  2095. // rectangles for it (in measureChar).
  2096. var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null);
  2097. var builder = {
  2098. pre: eltP("pre", [content], "CodeMirror-line"), content: content,
  2099. col: 0, pos: 0, cm: cm,
  2100. trailingSpace: false,
  2101. splitSpaces: cm.getOption("lineWrapping")
  2102. };
  2103. lineView.measure = {};
  2104. // Iterate over the logical lines that make up this visual line.
  2105. for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
  2106. var line = i ? lineView.rest[i - 1] : lineView.line,
  2107. order = void 0;
  2108. builder.pos = 0;
  2109. builder.addToken = buildToken;
  2110. // Optionally wire in some hacks into the token-rendering
  2111. // algorithm, to deal with browser quirks.
  2112. if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction))) {
  2113. builder.addToken = buildTokenBadBidi(builder.addToken, order);
  2114. }
  2115. builder.map = [];
  2116. var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
  2117. insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
  2118. if (line.styleClasses) {
  2119. if (line.styleClasses.bgClass) {
  2120. builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "");
  2121. }
  2122. if (line.styleClasses.textClass) {
  2123. builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "");
  2124. }
  2125. }
  2126. // Ensure at least a single node is present, for measuring.
  2127. if (builder.map.length == 0) {
  2128. builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)));
  2129. }
  2130. // Store the map and a cache object for the current logical line
  2131. if (i == 0) {
  2132. lineView.measure.map = builder.map;
  2133. lineView.measure.cache = {};
  2134. } else {
  2135. (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map);(lineView.measure.caches || (lineView.measure.caches = [])).push({});
  2136. }
  2137. }
  2138. // See issue #2901
  2139. if (webkit) {
  2140. var last = builder.content.lastChild;
  2141. if (/\bcm-tab\b/.test(last.className) || last.querySelector && last.querySelector(".cm-tab")) {
  2142. builder.content.className = "cm-tab-wrap-hack";
  2143. }
  2144. }
  2145. signal(cm, "renderLine", cm, lineView.line, builder.pre);
  2146. if (builder.pre.className) {
  2147. builder.textClass = joinClasses(builder.pre.className, builder.textClass || "");
  2148. }
  2149. return builder;
  2150. }
  2151. function defaultSpecialCharPlaceholder(ch) {
  2152. var token = elt("span", "\u2022", "cm-invalidchar");
  2153. token.title = "\\u" + ch.charCodeAt(0).toString(16);
  2154. token.setAttribute("aria-label", token.title);
  2155. return token;
  2156. }
  2157. // Build up the DOM representation for a single token, and add it to
  2158. // the line map. Takes care to render special characters separately.
  2159. function buildToken(builder, text, style, startStyle, endStyle, css, attributes) {
  2160. if (!text) {
  2161. return;
  2162. }
  2163. var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text;
  2164. var special = builder.cm.state.specialChars,
  2165. mustWrap = false;
  2166. var content;
  2167. if (!special.test(text)) {
  2168. builder.col += text.length;
  2169. content = document.createTextNode(displayText);
  2170. builder.map.push(builder.pos, builder.pos + text.length, content);
  2171. if (ie && ie_version < 9) {
  2172. mustWrap = true;
  2173. }
  2174. builder.pos += text.length;
  2175. } else {
  2176. content = document.createDocumentFragment();
  2177. var pos = 0;
  2178. while (true) {
  2179. special.lastIndex = pos;
  2180. var m = special.exec(text);
  2181. var skipped = m ? m.index - pos : text.length - pos;
  2182. if (skipped) {
  2183. var txt = document.createTextNode(displayText.slice(pos, pos + skipped));
  2184. if (ie && ie_version < 9) {
  2185. content.appendChild(elt("span", [txt]));
  2186. } else {
  2187. content.appendChild(txt);
  2188. }
  2189. builder.map.push(builder.pos, builder.pos + skipped, txt);
  2190. builder.col += skipped;
  2191. builder.pos += skipped;
  2192. }
  2193. if (!m) {
  2194. break;
  2195. }
  2196. pos += skipped + 1;
  2197. var txt$1 = void 0;
  2198. if (m[0] == "\t") {
  2199. var tabSize = builder.cm.options.tabSize,
  2200. tabWidth = tabSize - builder.col % tabSize;
  2201. txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
  2202. txt$1.setAttribute("role", "presentation");
  2203. txt$1.setAttribute("cm-text", "\t");
  2204. builder.col += tabWidth;
  2205. } else if (m[0] == "\r" || m[0] == "\n") {
  2206. txt$1 = content.appendChild(elt("span", m[0] == "\r" ? "\u240D" : "\u2424", "cm-invalidchar"));
  2207. txt$1.setAttribute("cm-text", m[0]);
  2208. builder.col += 1;
  2209. } else {
  2210. txt$1 = builder.cm.options.specialCharPlaceholder(m[0]);
  2211. txt$1.setAttribute("cm-text", m[0]);
  2212. if (ie && ie_version < 9) {
  2213. content.appendChild(elt("span", [txt$1]));
  2214. } else {
  2215. content.appendChild(txt$1);
  2216. }
  2217. builder.col += 1;
  2218. }
  2219. builder.map.push(builder.pos, builder.pos + 1, txt$1);
  2220. builder.pos++;
  2221. }
  2222. }
  2223. builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32;
  2224. if (style || startStyle || endStyle || mustWrap || css) {
  2225. var fullStyle = style || "";
  2226. if (startStyle) {
  2227. fullStyle += startStyle;
  2228. }
  2229. if (endStyle) {
  2230. fullStyle += endStyle;
  2231. }
  2232. var token = elt("span", [content], fullStyle, css);
  2233. if (attributes) {
  2234. for (var attr in attributes) {
  2235. if (attributes.hasOwnProperty(attr) && attr != "style" && attr != "class") {
  2236. token.setAttribute(attr, attributes[attr]);
  2237. }
  2238. }
  2239. }
  2240. return builder.content.appendChild(token);
  2241. }
  2242. builder.content.appendChild(content);
  2243. }
  2244. // Change some spaces to NBSP to prevent the browser from collapsing
  2245. // trailing spaces at the end of a line when rendering text (issue #1362).
  2246. function splitSpaces(text, trailingBefore) {
  2247. if (text.length > 1 && !/ /.test(text)) {
  2248. return text;
  2249. }
  2250. var spaceBefore = trailingBefore,
  2251. result = "";
  2252. for (var i = 0; i < text.length; i++) {
  2253. var ch = text.charAt(i);
  2254. if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32)) {
  2255. ch = "\xA0";
  2256. }
  2257. result += ch;
  2258. spaceBefore = ch == " ";
  2259. }
  2260. return result;
  2261. }
  2262. // Work around nonsense dimensions being reported for stretches of
  2263. // right-to-left text.
  2264. function buildTokenBadBidi(inner, order) {
  2265. return function (builder, text, style, startStyle, endStyle, css, attributes) {
  2266. style = style ? style + " cm-force-border" : "cm-force-border";
  2267. var start = builder.pos,
  2268. end = start + text.length;
  2269. for (;;) {
  2270. // Find the part that overlaps with the start of this text
  2271. var part = void 0;
  2272. for (var i = 0; i < order.length; i++) {
  2273. part = order[i];
  2274. if (part.to > start && part.from <= start) {
  2275. break;
  2276. }
  2277. }
  2278. if (part.to >= end) {
  2279. return inner(builder, text, style, startStyle, endStyle, css, attributes);
  2280. }
  2281. inner(builder, text.slice(0, part.to - start), style, startStyle, null, css, attributes);
  2282. startStyle = null;
  2283. text = text.slice(part.to - start);
  2284. start = part.to;
  2285. }
  2286. };
  2287. }
  2288. function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
  2289. var widget = !ignoreWidget && marker.widgetNode;
  2290. if (widget) {
  2291. builder.map.push(builder.pos, builder.pos + size, widget);
  2292. }
  2293. if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
  2294. if (!widget) {
  2295. widget = builder.content.appendChild(document.createElement("span"));
  2296. }
  2297. widget.setAttribute("cm-marker", marker.id);
  2298. }
  2299. if (widget) {
  2300. builder.cm.display.input.setUneditable(widget);
  2301. builder.content.appendChild(widget);
  2302. }
  2303. builder.pos += size;
  2304. builder.trailingSpace = false;
  2305. }
  2306. // Outputs a number of spans to make up a line, taking highlighting
  2307. // and index text into account.
  2308. function insertLineContent(line, builder, styles) {
  2309. var spans = line.markedSpans,
  2310. allText = line.text,
  2311. at = 0;
  2312. if (!spans) {
  2313. for (var i$1 = 1; i$1 < styles.length; i$1 += 2) {
  2314. builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1 + 1], builder.cm.options));
  2315. }
  2316. return;
  2317. }
  2318. var len = allText.length,
  2319. pos = 0,
  2320. i = 1,
  2321. text = "",
  2322. style,
  2323. css;
  2324. var nextChange = 0,
  2325. spanStyle,
  2326. spanEndStyle,
  2327. spanStartStyle,
  2328. collapsed,
  2329. attributes;
  2330. for (;;) {
  2331. if (nextChange == pos) {
  2332. // Update current marker set
  2333. spanStyle = spanEndStyle = spanStartStyle = css = "";
  2334. attributes = null;
  2335. collapsed = null;
  2336. nextChange = Infinity;
  2337. var foundBookmarks = [],
  2338. endStyles = void 0;
  2339. for (var j = 0; j < spans.length; ++j) {
  2340. var sp = spans[j],
  2341. m = sp.marker;
  2342. if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
  2343. foundBookmarks.push(m);
  2344. } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {
  2345. if (sp.to != null && sp.to != pos && nextChange > sp.to) {
  2346. nextChange = sp.to;
  2347. spanEndStyle = "";
  2348. }
  2349. if (m.className) {
  2350. spanStyle += " " + m.className;
  2351. }
  2352. if (m.css) {
  2353. css = (css ? css + ";" : "") + m.css;
  2354. }
  2355. if (m.startStyle && sp.from == pos) {
  2356. spanStartStyle += " " + m.startStyle;
  2357. }
  2358. if (m.endStyle && sp.to == nextChange) {
  2359. (endStyles || (endStyles = [])).push(m.endStyle, sp.to);
  2360. }
  2361. // support for the old title property
  2362. // https://github.com/codemirror/CodeMirror/pull/5673
  2363. if (m.title) {
  2364. (attributes || (attributes = {})).title = m.title;
  2365. }
  2366. if (m.attributes) {
  2367. for (var attr in m.attributes) {
  2368. (attributes || (attributes = {}))[attr] = m.attributes[attr];
  2369. }
  2370. }
  2371. if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0)) {
  2372. collapsed = sp;
  2373. }
  2374. } else if (sp.from > pos && nextChange > sp.from) {
  2375. nextChange = sp.from;
  2376. }
  2377. }
  2378. if (endStyles) {
  2379. for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2) {
  2380. if (endStyles[j$1 + 1] == nextChange) {
  2381. spanEndStyle += " " + endStyles[j$1];
  2382. }
  2383. }
  2384. }
  2385. if (!collapsed || collapsed.from == pos) {
  2386. for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2) {
  2387. buildCollapsedSpan(builder, 0, foundBookmarks[j$2]);
  2388. }
  2389. }
  2390. if (collapsed && (collapsed.from || 0) == pos) {
  2391. buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos, collapsed.marker, collapsed.from == null);
  2392. if (collapsed.to == null) {
  2393. return;
  2394. }
  2395. if (collapsed.to == pos) {
  2396. collapsed = false;
  2397. }
  2398. }
  2399. }
  2400. if (pos >= len) {
  2401. break;
  2402. }
  2403. var upto = Math.min(len, nextChange);
  2404. while (true) {
  2405. if (text) {
  2406. var end = pos + text.length;
  2407. if (!collapsed) {
  2408. var tokenText = end > upto ? text.slice(0, upto - pos) : text;
  2409. builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle, spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", css, attributes);
  2410. }
  2411. if (end >= upto) {
  2412. text = text.slice(upto - pos);
  2413. pos = upto;
  2414. break;
  2415. }
  2416. pos = end;
  2417. spanStartStyle = "";
  2418. }
  2419. text = allText.slice(at, at = styles[i++]);
  2420. style = interpretTokenStyle(styles[i++], builder.cm.options);
  2421. }
  2422. }
  2423. }
  2424. // These objects are used to represent the visible (currently drawn)
  2425. // part of the document. A LineView may correspond to multiple
  2426. // logical lines, if those are connected by collapsed ranges.
  2427. function LineView(doc, line, lineN) {
  2428. // The starting line
  2429. this.line = line;
  2430. // Continuing lines, if any
  2431. this.rest = visualLineContinued(line);
  2432. // Number of logical lines in this visual line
  2433. this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;
  2434. this.node = this.text = null;
  2435. this.hidden = lineIsHidden(doc, line);
  2436. }
  2437. // Create a range of LineView objects for the given lines.
  2438. function buildViewArray(cm, from, to) {
  2439. var array = [],
  2440. nextPos;
  2441. for (var pos = from; pos < to; pos = nextPos) {
  2442. var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);
  2443. nextPos = pos + view.size;
  2444. array.push(view);
  2445. }
  2446. return array;
  2447. }
  2448. var operationGroup = null;
  2449. function pushOperation(op) {
  2450. if (operationGroup) {
  2451. operationGroup.ops.push(op);
  2452. } else {
  2453. op.ownsGroup = operationGroup = {
  2454. ops: [op],
  2455. delayedCallbacks: []
  2456. };
  2457. }
  2458. }
  2459. function fireCallbacksForOps(group) {
  2460. // Calls delayed callbacks and cursorActivity handlers until no
  2461. // new ones appear
  2462. var callbacks = group.delayedCallbacks,
  2463. i = 0;
  2464. do {
  2465. for (; i < callbacks.length; i++) {
  2466. callbacks[i].call(null);
  2467. }
  2468. for (var j = 0; j < group.ops.length; j++) {
  2469. var op = group.ops[j];
  2470. if (op.cursorActivityHandlers) {
  2471. while (op.cursorActivityCalled < op.cursorActivityHandlers.length) {
  2472. op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm);
  2473. }
  2474. }
  2475. }
  2476. } while (i < callbacks.length);
  2477. }
  2478. function finishOperation(op, endCb) {
  2479. var group = op.ownsGroup;
  2480. if (!group) {
  2481. return;
  2482. }
  2483. try {
  2484. fireCallbacksForOps(group);
  2485. } finally {
  2486. operationGroup = null;
  2487. endCb(group);
  2488. }
  2489. }
  2490. var orphanDelayedCallbacks = null;
  2491. // Often, we want to signal events at a point where we are in the
  2492. // middle of some work, but don't want the handler to start calling
  2493. // other methods on the src, which might be in an inconsistent
  2494. // state or simply not expect any other events to happen.
  2495. // signalLater looks whether there are any handlers, and schedules
  2496. // them to be executed when the last operation ends, or, if no
  2497. // operation is active, when a timeout fires.
  2498. function signalLater(emitter, type /*, values...*/) {
  2499. var arr = getHandlers(emitter, type);
  2500. if (!arr.length) {
  2501. return;
  2502. }
  2503. var args = Array.prototype.slice.call(arguments, 2),
  2504. list;
  2505. if (operationGroup) {
  2506. list = operationGroup.delayedCallbacks;
  2507. } else if (orphanDelayedCallbacks) {
  2508. list = orphanDelayedCallbacks;
  2509. } else {
  2510. list = orphanDelayedCallbacks = [];
  2511. setTimeout(fireOrphanDelayed, 0);
  2512. }
  2513. var loop = function loop(i) {
  2514. list.push(function () {
  2515. return arr[i].apply(null, args);
  2516. });
  2517. };
  2518. for (var i = 0; i < arr.length; ++i) {
  2519. loop(i);
  2520. }
  2521. }
  2522. function fireOrphanDelayed() {
  2523. var delayed = orphanDelayedCallbacks;
  2524. orphanDelayedCallbacks = null;
  2525. for (var i = 0; i < delayed.length; ++i) {
  2526. delayed[i]();
  2527. }
  2528. }
  2529. // When an aspect of a line changes, a string is added to
  2530. // lineView.changes. This updates the relevant part of the line's
  2531. // DOM structure.
  2532. function updateLineForChanges(cm, lineView, lineN, dims) {
  2533. for (var j = 0; j < lineView.changes.length; j++) {
  2534. var type = lineView.changes[j];
  2535. if (type == "text") {
  2536. updateLineText(cm, lineView);
  2537. } else if (type == "gutter") {
  2538. updateLineGutter(cm, lineView, lineN, dims);
  2539. } else if (type == "class") {
  2540. updateLineClasses(cm, lineView);
  2541. } else if (type == "widget") {
  2542. updateLineWidgets(cm, lineView, dims);
  2543. }
  2544. }
  2545. lineView.changes = null;
  2546. }
  2547. // Lines with gutter elements, widgets or a background class need to
  2548. // be wrapped, and have the extra elements added to the wrapper div
  2549. function ensureLineWrapped(lineView) {
  2550. if (lineView.node == lineView.text) {
  2551. lineView.node = elt("div", null, null, "position: relative");
  2552. if (lineView.text.parentNode) {
  2553. lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
  2554. }
  2555. lineView.node.appendChild(lineView.text);
  2556. if (ie && ie_version < 8) {
  2557. lineView.node.style.zIndex = 2;
  2558. }
  2559. }
  2560. return lineView.node;
  2561. }
  2562. function updateLineBackground(cm, lineView) {
  2563. var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
  2564. if (cls) {
  2565. cls += " CodeMirror-linebackground";
  2566. }
  2567. if (lineView.background) {
  2568. if (cls) {
  2569. lineView.background.className = cls;
  2570. } else {
  2571. lineView.background.parentNode.removeChild(lineView.background);
  2572. lineView.background = null;
  2573. }
  2574. } else if (cls) {
  2575. var wrap = ensureLineWrapped(lineView);
  2576. lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
  2577. cm.display.input.setUneditable(lineView.background);
  2578. }
  2579. }
  2580. // Wrapper around buildLineContent which will reuse the structure
  2581. // in display.externalMeasured when possible.
  2582. function getLineContent(cm, lineView) {
  2583. var ext = cm.display.externalMeasured;
  2584. if (ext && ext.line == lineView.line) {
  2585. cm.display.externalMeasured = null;
  2586. lineView.measure = ext.measure;
  2587. return ext.built;
  2588. }
  2589. return buildLineContent(cm, lineView);
  2590. }
  2591. // Redraw the line's text. Interacts with the background and text
  2592. // classes because the mode may output tokens that influence these
  2593. // classes.
  2594. function updateLineText(cm, lineView) {
  2595. var cls = lineView.text.className;
  2596. var built = getLineContent(cm, lineView);
  2597. if (lineView.text == lineView.node) {
  2598. lineView.node = built.pre;
  2599. }
  2600. lineView.text.parentNode.replaceChild(built.pre, lineView.text);
  2601. lineView.text = built.pre;
  2602. if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
  2603. lineView.bgClass = built.bgClass;
  2604. lineView.textClass = built.textClass;
  2605. updateLineClasses(cm, lineView);
  2606. } else if (cls) {
  2607. lineView.text.className = cls;
  2608. }
  2609. }
  2610. function updateLineClasses(cm, lineView) {
  2611. updateLineBackground(cm, lineView);
  2612. if (lineView.line.wrapClass) {
  2613. ensureLineWrapped(lineView).className = lineView.line.wrapClass;
  2614. } else if (lineView.node != lineView.text) {
  2615. lineView.node.className = "";
  2616. }
  2617. var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
  2618. lineView.text.className = textClass || "";
  2619. }
  2620. function updateLineGutter(cm, lineView, lineN, dims) {
  2621. if (lineView.gutter) {
  2622. lineView.node.removeChild(lineView.gutter);
  2623. lineView.gutter = null;
  2624. }
  2625. if (lineView.gutterBackground) {
  2626. lineView.node.removeChild(lineView.gutterBackground);
  2627. lineView.gutterBackground = null;
  2628. }
  2629. if (lineView.line.gutterClass) {
  2630. var wrap = ensureLineWrapped(lineView);
  2631. lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass, "left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + dims.gutterTotalWidth + "px");
  2632. cm.display.input.setUneditable(lineView.gutterBackground);
  2633. wrap.insertBefore(lineView.gutterBackground, lineView.text);
  2634. }
  2635. var markers = lineView.line.gutterMarkers;
  2636. if (cm.options.lineNumbers || markers) {
  2637. var wrap$1 = ensureLineWrapped(lineView);
  2638. var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px");
  2639. cm.display.input.setUneditable(gutterWrap);
  2640. wrap$1.insertBefore(gutterWrap, lineView.text);
  2641. if (lineView.line.gutterClass) {
  2642. gutterWrap.className += " " + lineView.line.gutterClass;
  2643. }
  2644. if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"])) {
  2645. lineView.lineNumber = gutterWrap.appendChild(elt("div", lineNumberFor(cm.options, lineN), "CodeMirror-linenumber CodeMirror-gutter-elt", "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: " + cm.display.lineNumInnerWidth + "px"));
  2646. }
  2647. if (markers) {
  2648. for (var k = 0; k < cm.display.gutterSpecs.length; ++k) {
  2649. var id = cm.display.gutterSpecs[k].className,
  2650. found = markers.hasOwnProperty(id) && markers[id];
  2651. if (found) {
  2652. gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " + dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
  2653. }
  2654. }
  2655. }
  2656. }
  2657. }
  2658. function updateLineWidgets(cm, lineView, dims) {
  2659. if (lineView.alignable) {
  2660. lineView.alignable = null;
  2661. }
  2662. for (var node = lineView.node.firstChild, next = void 0; node; node = next) {
  2663. next = node.nextSibling;
  2664. if (node.className == "CodeMirror-linewidget") {
  2665. lineView.node.removeChild(node);
  2666. }
  2667. }
  2668. insertLineWidgets(cm, lineView, dims);
  2669. }
  2670. // Build a line's DOM representation from scratch
  2671. function buildLineElement(cm, lineView, lineN, dims) {
  2672. var built = getLineContent(cm, lineView);
  2673. lineView.text = lineView.node = built.pre;
  2674. if (built.bgClass) {
  2675. lineView.bgClass = built.bgClass;
  2676. }
  2677. if (built.textClass) {
  2678. lineView.textClass = built.textClass;
  2679. }
  2680. updateLineClasses(cm, lineView);
  2681. updateLineGutter(cm, lineView, lineN, dims);
  2682. insertLineWidgets(cm, lineView, dims);
  2683. return lineView.node;
  2684. }
  2685. // A lineView may contain multiple logical lines (when merged by
  2686. // collapsed spans). The widgets for all of them need to be drawn.
  2687. function insertLineWidgets(cm, lineView, dims) {
  2688. insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
  2689. if (lineView.rest) {
  2690. for (var i = 0; i < lineView.rest.length; i++) {
  2691. insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false);
  2692. }
  2693. }
  2694. }
  2695. function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
  2696. if (!line.widgets) {
  2697. return;
  2698. }
  2699. var wrap = ensureLineWrapped(lineView);
  2700. for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
  2701. var widget = ws[i],
  2702. node = elt("div", [widget.node], "CodeMirror-linewidget");
  2703. if (!widget.handleMouseEvents) {
  2704. node.setAttribute("cm-ignore-events", "true");
  2705. }
  2706. positionLineWidget(widget, node, lineView, dims);
  2707. cm.display.input.setUneditable(node);
  2708. if (allowAbove && widget.above) {
  2709. wrap.insertBefore(node, lineView.gutter || lineView.text);
  2710. } else {
  2711. wrap.appendChild(node);
  2712. }
  2713. signalLater(widget, "redraw");
  2714. }
  2715. }
  2716. function positionLineWidget(widget, node, lineView, dims) {
  2717. if (widget.noHScroll) {
  2718. (lineView.alignable || (lineView.alignable = [])).push(node);
  2719. var width = dims.wrapperWidth;
  2720. node.style.left = dims.fixedPos + "px";
  2721. if (!widget.coverGutter) {
  2722. width -= dims.gutterTotalWidth;
  2723. node.style.paddingLeft = dims.gutterTotalWidth + "px";
  2724. }
  2725. node.style.width = width + "px";
  2726. }
  2727. if (widget.coverGutter) {
  2728. node.style.zIndex = 5;
  2729. node.style.position = "relative";
  2730. if (!widget.noHScroll) {
  2731. node.style.marginLeft = -dims.gutterTotalWidth + "px";
  2732. }
  2733. }
  2734. }
  2735. function widgetHeight(widget) {
  2736. if (widget.height != null) {
  2737. return widget.height;
  2738. }
  2739. var cm = widget.doc.cm;
  2740. if (!cm) {
  2741. return 0;
  2742. }
  2743. if (!contains(document.body, widget.node)) {
  2744. var parentStyle = "position: relative;";
  2745. if (widget.coverGutter) {
  2746. parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;";
  2747. }
  2748. if (widget.noHScroll) {
  2749. parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;";
  2750. }
  2751. removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
  2752. }
  2753. return widget.height = widget.node.parentNode.offsetHeight;
  2754. }
  2755. // Return true when the given mouse event happened in a widget
  2756. function eventInWidget(display, e) {
  2757. for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
  2758. if (!n || n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true" || n.parentNode == display.sizer && n != display.mover) {
  2759. return true;
  2760. }
  2761. }
  2762. }
  2763. // POSITION MEASUREMENT
  2764. function paddingTop(display) {
  2765. return display.lineSpace.offsetTop;
  2766. }
  2767. function paddingVert(display) {
  2768. return display.mover.offsetHeight - display.lineSpace.offsetHeight;
  2769. }
  2770. function paddingH(display) {
  2771. if (display.cachedPaddingH) {
  2772. return display.cachedPaddingH;
  2773. }
  2774. var e = removeChildrenAndAdd(display.measure, elt("pre", "x", "CodeMirror-line-like"));
  2775. var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
  2776. var data = { left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight) };
  2777. if (!isNaN(data.left) && !isNaN(data.right)) {
  2778. display.cachedPaddingH = data;
  2779. }
  2780. return data;
  2781. }
  2782. function scrollGap(cm) {
  2783. return scrollerGap - cm.display.nativeBarWidth;
  2784. }
  2785. function displayWidth(cm) {
  2786. return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth;
  2787. }
  2788. function displayHeight(cm) {
  2789. return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight;
  2790. }
  2791. // Ensure the lineView.wrapping.heights array is populated. This is
  2792. // an array of bottom offsets for the lines that make up a drawn
  2793. // line. When lineWrapping is on, there might be more than one
  2794. // height.
  2795. function ensureLineHeights(cm, lineView, rect) {
  2796. var wrapping = cm.options.lineWrapping;
  2797. var curWidth = wrapping && displayWidth(cm);
  2798. if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
  2799. var heights = lineView.measure.heights = [];
  2800. if (wrapping) {
  2801. lineView.measure.width = curWidth;
  2802. var rects = lineView.text.firstChild.getClientRects();
  2803. for (var i = 0; i < rects.length - 1; i++) {
  2804. var cur = rects[i],
  2805. next = rects[i + 1];
  2806. if (Math.abs(cur.bottom - next.bottom) > 2) {
  2807. heights.push((cur.bottom + next.top) / 2 - rect.top);
  2808. }
  2809. }
  2810. }
  2811. heights.push(rect.bottom - rect.top);
  2812. }
  2813. }
  2814. // Find a line map (mapping character offsets to text nodes) and a
  2815. // measurement cache for the given line number. (A line view might
  2816. // contain multiple lines when collapsed ranges are present.)
  2817. function mapFromLineView(lineView, line, lineN) {
  2818. if (lineView.line == line) {
  2819. return { map: lineView.measure.map, cache: lineView.measure.cache };
  2820. }
  2821. for (var i = 0; i < lineView.rest.length; i++) {
  2822. if (lineView.rest[i] == line) {
  2823. return { map: lineView.measure.maps[i], cache: lineView.measure.caches[i] };
  2824. }
  2825. }
  2826. for (var i$1 = 0; i$1 < lineView.rest.length; i$1++) {
  2827. if (lineNo(lineView.rest[i$1]) > lineN) {
  2828. return { map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true };
  2829. }
  2830. }
  2831. }
  2832. // Render a line into the hidden node display.externalMeasured. Used
  2833. // when measurement is needed for a line that's not in the viewport.
  2834. function updateExternalMeasurement(cm, line) {
  2835. line = visualLine(line);
  2836. var lineN = lineNo(line);
  2837. var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
  2838. view.lineN = lineN;
  2839. var built = view.built = buildLineContent(cm, view);
  2840. view.text = built.pre;
  2841. removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
  2842. return view;
  2843. }
  2844. // Get a {top, bottom, left, right} box (in line-local coordinates)
  2845. // for a given character.
  2846. function measureChar(cm, line, ch, bias) {
  2847. return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias);
  2848. }
  2849. // Find a line view that corresponds to the given line number.
  2850. function findViewForLine(cm, lineN) {
  2851. if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo) {
  2852. return cm.display.view[findViewIndex(cm, lineN)];
  2853. }
  2854. var ext = cm.display.externalMeasured;
  2855. if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size) {
  2856. return ext;
  2857. }
  2858. }
  2859. // Measurement can be split in two steps, the set-up work that
  2860. // applies to the whole line, and the measurement of the actual
  2861. // character. Functions like coordsChar, that need to do a lot of
  2862. // measurements in a row, can thus ensure that the set-up work is
  2863. // only done once.
  2864. function prepareMeasureForLine(cm, line) {
  2865. var lineN = lineNo(line);
  2866. var view = findViewForLine(cm, lineN);
  2867. if (view && !view.text) {
  2868. view = null;
  2869. } else if (view && view.changes) {
  2870. updateLineForChanges(cm, view, lineN, getDimensions(cm));
  2871. cm.curOp.forceUpdate = true;
  2872. }
  2873. if (!view) {
  2874. view = updateExternalMeasurement(cm, line);
  2875. }
  2876. var info = mapFromLineView(view, line, lineN);
  2877. return {
  2878. line: line, view: view, rect: null,
  2879. map: info.map, cache: info.cache, before: info.before,
  2880. hasHeights: false
  2881. };
  2882. }
  2883. // Given a prepared measurement object, measures the position of an
  2884. // actual character (or fetches it from the cache).
  2885. function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
  2886. if (prepared.before) {
  2887. ch = -1;
  2888. }
  2889. var key = ch + (bias || ""),
  2890. found;
  2891. if (prepared.cache.hasOwnProperty(key)) {
  2892. found = prepared.cache[key];
  2893. } else {
  2894. if (!prepared.rect) {
  2895. prepared.rect = prepared.view.text.getBoundingClientRect();
  2896. }
  2897. if (!prepared.hasHeights) {
  2898. ensureLineHeights(cm, prepared.view, prepared.rect);
  2899. prepared.hasHeights = true;
  2900. }
  2901. found = measureCharInner(cm, prepared, ch, bias);
  2902. if (!found.bogus) {
  2903. prepared.cache[key] = found;
  2904. }
  2905. }
  2906. return {
  2907. left: found.left, right: found.right,
  2908. top: varHeight ? found.rtop : found.top,
  2909. bottom: varHeight ? found.rbottom : found.bottom
  2910. };
  2911. }
  2912. var nullRect = { left: 0, right: 0, top: 0, bottom: 0 };
  2913. function nodeAndOffsetInLineMap(map$$1, ch, bias) {
  2914. var node, start, end, collapse, mStart, mEnd;
  2915. // First, search the line map for the text node corresponding to,
  2916. // or closest to, the target character.
  2917. for (var i = 0; i < map$$1.length; i += 3) {
  2918. mStart = map$$1[i];
  2919. mEnd = map$$1[i + 1];
  2920. if (ch < mStart) {
  2921. start = 0;
  2922. end = 1;
  2923. collapse = "left";
  2924. } else if (ch < mEnd) {
  2925. start = ch - mStart;
  2926. end = start + 1;
  2927. } else if (i == map$$1.length - 3 || ch == mEnd && map$$1[i + 3] > ch) {
  2928. end = mEnd - mStart;
  2929. start = end - 1;
  2930. if (ch >= mEnd) {
  2931. collapse = "right";
  2932. }
  2933. }
  2934. if (start != null) {
  2935. node = map$$1[i + 2];
  2936. if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right")) {
  2937. collapse = bias;
  2938. }
  2939. if (bias == "left" && start == 0) {
  2940. while (i && map$$1[i - 2] == map$$1[i - 3] && map$$1[i - 1].insertLeft) {
  2941. node = map$$1[(i -= 3) + 2];
  2942. collapse = "left";
  2943. }
  2944. }
  2945. if (bias == "right" && start == mEnd - mStart) {
  2946. while (i < map$$1.length - 3 && map$$1[i + 3] == map$$1[i + 4] && !map$$1[i + 5].insertLeft) {
  2947. node = map$$1[(i += 3) + 2];
  2948. collapse = "right";
  2949. }
  2950. }
  2951. break;
  2952. }
  2953. }
  2954. return { node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd };
  2955. }
  2956. function getUsefulRect(rects, bias) {
  2957. var rect = nullRect;
  2958. if (bias == "left") {
  2959. for (var i = 0; i < rects.length; i++) {
  2960. if ((rect = rects[i]).left != rect.right) {
  2961. break;
  2962. }
  2963. }
  2964. } else {
  2965. for (var i$1 = rects.length - 1; i$1 >= 0; i$1--) {
  2966. if ((rect = rects[i$1]).left != rect.right) {
  2967. break;
  2968. }
  2969. }
  2970. }
  2971. return rect;
  2972. }
  2973. function measureCharInner(cm, prepared, ch, bias) {
  2974. var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
  2975. var node = place.node,
  2976. start = place.start,
  2977. end = place.end,
  2978. collapse = place.collapse;
  2979. var rect;
  2980. if (node.nodeType == 3) {
  2981. // If it is a text node, use a range to retrieve the coordinates.
  2982. for (var i$1 = 0; i$1 < 4; i$1++) {
  2983. // Retry a maximum of 4 times when nonsense rectangles are returned
  2984. while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) {
  2985. --start;
  2986. }
  2987. while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) {
  2988. ++end;
  2989. }
  2990. if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) {
  2991. rect = node.parentNode.getBoundingClientRect();
  2992. } else {
  2993. rect = getUsefulRect(range(node, start, end).getClientRects(), bias);
  2994. }
  2995. if (rect.left || rect.right || start == 0) {
  2996. break;
  2997. }
  2998. end = start;
  2999. start = start - 1;
  3000. collapse = "right";
  3001. }
  3002. if (ie && ie_version < 11) {
  3003. rect = maybeUpdateRectForZooming(cm.display.measure, rect);
  3004. }
  3005. } else {
  3006. // If it is a widget, simply get the box for the whole widget.
  3007. if (start > 0) {
  3008. collapse = bias = "right";
  3009. }
  3010. var rects;
  3011. if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1) {
  3012. rect = rects[bias == "right" ? rects.length - 1 : 0];
  3013. } else {
  3014. rect = node.getBoundingClientRect();
  3015. }
  3016. }
  3017. if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
  3018. var rSpan = node.parentNode.getClientRects()[0];
  3019. if (rSpan) {
  3020. rect = { left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom };
  3021. } else {
  3022. rect = nullRect;
  3023. }
  3024. }
  3025. var rtop = rect.top - prepared.rect.top,
  3026. rbot = rect.bottom - prepared.rect.top;
  3027. var mid = (rtop + rbot) / 2;
  3028. var heights = prepared.view.measure.heights;
  3029. var i = 0;
  3030. for (; i < heights.length - 1; i++) {
  3031. if (mid < heights[i]) {
  3032. break;
  3033. }
  3034. }
  3035. var top = i ? heights[i - 1] : 0,
  3036. bot = heights[i];
  3037. var result = {
  3038. left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
  3039. right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
  3040. top: top, bottom: bot
  3041. };
  3042. if (!rect.left && !rect.right) {
  3043. result.bogus = true;
  3044. }
  3045. if (!cm.options.singleCursorHeightPerLine) {
  3046. result.rtop = rtop;
  3047. result.rbottom = rbot;
  3048. }
  3049. return result;
  3050. }
  3051. // Work around problem with bounding client rects on ranges being
  3052. // returned incorrectly when zoomed on IE10 and below.
  3053. function maybeUpdateRectForZooming(measure, rect) {
  3054. if (!window.screen || screen.logicalXDPI == null || screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure)) {
  3055. return rect;
  3056. }
  3057. var scaleX = screen.logicalXDPI / screen.deviceXDPI;
  3058. var scaleY = screen.logicalYDPI / screen.deviceYDPI;
  3059. return {
  3060. left: rect.left * scaleX, right: rect.right * scaleX,
  3061. top: rect.top * scaleY, bottom: rect.bottom * scaleY
  3062. };
  3063. }
  3064. function clearLineMeasurementCacheFor(lineView) {
  3065. if (lineView.measure) {
  3066. lineView.measure.cache = {};
  3067. lineView.measure.heights = null;
  3068. if (lineView.rest) {
  3069. for (var i = 0; i < lineView.rest.length; i++) {
  3070. lineView.measure.caches[i] = {};
  3071. }
  3072. }
  3073. }
  3074. }
  3075. function clearLineMeasurementCache(cm) {
  3076. cm.display.externalMeasure = null;
  3077. removeChildren(cm.display.lineMeasure);
  3078. for (var i = 0; i < cm.display.view.length; i++) {
  3079. clearLineMeasurementCacheFor(cm.display.view[i]);
  3080. }
  3081. }
  3082. function clearCaches(cm) {
  3083. clearLineMeasurementCache(cm);
  3084. cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
  3085. if (!cm.options.lineWrapping) {
  3086. cm.display.maxLineChanged = true;
  3087. }
  3088. cm.display.lineNumChars = null;
  3089. }
  3090. function pageScrollX() {
  3091. // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206
  3092. // which causes page_Offset and bounding client rects to use
  3093. // different reference viewports and invalidate our calculations.
  3094. if (chrome && android) {
  3095. return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft));
  3096. }
  3097. return window.pageXOffset || (document.documentElement || document.body).scrollLeft;
  3098. }
  3099. function pageScrollY() {
  3100. if (chrome && android) {
  3101. return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop));
  3102. }
  3103. return window.pageYOffset || (document.documentElement || document.body).scrollTop;
  3104. }
  3105. function widgetTopHeight(lineObj) {
  3106. var height = 0;
  3107. if (lineObj.widgets) {
  3108. for (var i = 0; i < lineObj.widgets.length; ++i) {
  3109. if (lineObj.widgets[i].above) {
  3110. height += widgetHeight(lineObj.widgets[i]);
  3111. }
  3112. }
  3113. }
  3114. return height;
  3115. }
  3116. // Converts a {top, bottom, left, right} box from line-local
  3117. // coordinates into another coordinate system. Context may be one of
  3118. // "line", "div" (display.lineDiv), "local"./null (src), "window",
  3119. // or "page".
  3120. function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) {
  3121. if (!includeWidgets) {
  3122. var height = widgetTopHeight(lineObj);
  3123. rect.top += height;
  3124. rect.bottom += height;
  3125. }
  3126. if (context == "line") {
  3127. return rect;
  3128. }
  3129. if (!context) {
  3130. context = "local";
  3131. }
  3132. var yOff = _heightAtLine(lineObj);
  3133. if (context == "local") {
  3134. yOff += paddingTop(cm.display);
  3135. } else {
  3136. yOff -= cm.display.viewOffset;
  3137. }
  3138. if (context == "page" || context == "window") {
  3139. var lOff = cm.display.lineSpace.getBoundingClientRect();
  3140. yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
  3141. var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
  3142. rect.left += xOff;
  3143. rect.right += xOff;
  3144. }
  3145. rect.top += yOff;
  3146. rect.bottom += yOff;
  3147. return rect;
  3148. }
  3149. // Coverts a box from "div" coords to another coordinate system.
  3150. // Context may be "window", "page", "div", or "local"./null.
  3151. function fromCoordSystem(cm, coords, context) {
  3152. if (context == "div") {
  3153. return coords;
  3154. }
  3155. var left = coords.left,
  3156. top = coords.top;
  3157. // First move into "page" coordinate system
  3158. if (context == "page") {
  3159. left -= pageScrollX();
  3160. top -= pageScrollY();
  3161. } else if (context == "local" || !context) {
  3162. var localBox = cm.display.sizer.getBoundingClientRect();
  3163. left += localBox.left;
  3164. top += localBox.top;
  3165. }
  3166. var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
  3167. return { left: left - lineSpaceBox.left, top: top - lineSpaceBox.top };
  3168. }
  3169. function _charCoords(cm, pos, context, lineObj, bias) {
  3170. if (!lineObj) {
  3171. lineObj = getLine(cm.doc, pos.line);
  3172. }
  3173. return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context);
  3174. }
  3175. // Returns a box for a given cursor position, which may have an
  3176. // 'other' property containing the position of the secondary cursor
  3177. // on a bidi boundary.
  3178. // A cursor Pos(line, char, "before") is on the same visual line as `char - 1`
  3179. // and after `char - 1` in writing order of `char - 1`
  3180. // A cursor Pos(line, char, "after") is on the same visual line as `char`
  3181. // and before `char` in writing order of `char`
  3182. // Examples (upper-case letters are RTL, lower-case are LTR):
  3183. // Pos(0, 1, ...)
  3184. // before after
  3185. // ab a|b a|b
  3186. // aB a|B aB|
  3187. // Ab |Ab A|b
  3188. // AB B|A B|A
  3189. // Every position after the last character on a line is considered to stick
  3190. // to the last character on the line.
  3191. function _cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
  3192. lineObj = lineObj || getLine(cm.doc, pos.line);
  3193. if (!preparedMeasure) {
  3194. preparedMeasure = prepareMeasureForLine(cm, lineObj);
  3195. }
  3196. function get(ch, right) {
  3197. var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
  3198. if (right) {
  3199. m.left = m.right;
  3200. } else {
  3201. m.right = m.left;
  3202. }
  3203. return intoCoordSystem(cm, lineObj, m, context);
  3204. }
  3205. var order = getOrder(lineObj, cm.doc.direction),
  3206. ch = pos.ch,
  3207. sticky = pos.sticky;
  3208. if (ch >= lineObj.text.length) {
  3209. ch = lineObj.text.length;
  3210. sticky = "before";
  3211. } else if (ch <= 0) {
  3212. ch = 0;
  3213. sticky = "after";
  3214. }
  3215. if (!order) {
  3216. return get(sticky == "before" ? ch - 1 : ch, sticky == "before");
  3217. }
  3218. function getBidi(ch, partPos, invert) {
  3219. var part = order[partPos],
  3220. right = part.level == 1;
  3221. return get(invert ? ch - 1 : ch, right != invert);
  3222. }
  3223. var partPos = getBidiPartAt(order, ch, sticky);
  3224. var other = bidiOther;
  3225. var val = getBidi(ch, partPos, sticky == "before");
  3226. if (other != null) {
  3227. val.other = getBidi(ch, other, sticky != "before");
  3228. }
  3229. return val;
  3230. }
  3231. // Used to cheaply estimate the coordinates for a position. Used for
  3232. // intermediate scroll updates.
  3233. function estimateCoords(cm, pos) {
  3234. var left = 0;
  3235. pos = _clipPos(cm.doc, pos);
  3236. if (!cm.options.lineWrapping) {
  3237. left = charWidth(cm.display) * pos.ch;
  3238. }
  3239. var lineObj = getLine(cm.doc, pos.line);
  3240. var top = _heightAtLine(lineObj) + paddingTop(cm.display);
  3241. return { left: left, right: left, top: top, bottom: top + lineObj.height };
  3242. }
  3243. // Positions returned by coordsChar contain some extra information.
  3244. // xRel is the relative x position of the input coordinates compared
  3245. // to the found position (so xRel > 0 means the coordinates are to
  3246. // the right of the character position, for example). When outside
  3247. // is true, that means the coordinates lie outside the line's
  3248. // vertical range.
  3249. function PosWithInfo(line, ch, sticky, outside, xRel) {
  3250. var pos = Pos(line, ch, sticky);
  3251. pos.xRel = xRel;
  3252. if (outside) {
  3253. pos.outside = outside;
  3254. }
  3255. return pos;
  3256. }
  3257. // Compute the character position closest to the given coordinates.
  3258. // Input must be lineSpace-local ("div" coordinate system).
  3259. function _coordsChar(cm, x, y) {
  3260. var doc = cm.doc;
  3261. y += cm.display.viewOffset;
  3262. if (y < 0) {
  3263. return PosWithInfo(doc.first, 0, null, -1, -1);
  3264. }
  3265. var lineN = _lineAtHeight(doc, y),
  3266. last = doc.first + doc.size - 1;
  3267. if (lineN > last) {
  3268. return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, 1, 1);
  3269. }
  3270. if (x < 0) {
  3271. x = 0;
  3272. }
  3273. var lineObj = getLine(doc, lineN);
  3274. for (;;) {
  3275. var found = coordsCharInner(cm, lineObj, lineN, x, y);
  3276. var collapsed = collapsedSpanAround(lineObj, found.ch + (found.xRel > 0 || found.outside > 0 ? 1 : 0));
  3277. if (!collapsed) {
  3278. return found;
  3279. }
  3280. var rangeEnd = collapsed.find(1);
  3281. if (rangeEnd.line == lineN) {
  3282. return rangeEnd;
  3283. }
  3284. lineObj = getLine(doc, lineN = rangeEnd.line);
  3285. }
  3286. }
  3287. function wrappedLineExtent(cm, lineObj, preparedMeasure, y) {
  3288. y -= widgetTopHeight(lineObj);
  3289. var end = lineObj.text.length;
  3290. var begin = findFirst(function (ch) {
  3291. return measureCharPrepared(cm, preparedMeasure, ch - 1).bottom <= y;
  3292. }, end, 0);
  3293. end = findFirst(function (ch) {
  3294. return measureCharPrepared(cm, preparedMeasure, ch).top > y;
  3295. }, begin, end);
  3296. return { begin: begin, end: end };
  3297. }
  3298. function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) {
  3299. if (!preparedMeasure) {
  3300. preparedMeasure = prepareMeasureForLine(cm, lineObj);
  3301. }
  3302. var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line").top;
  3303. return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop);
  3304. }
  3305. // Returns true if the given side of a box is after the given
  3306. // coordinates, in top-to-bottom, left-to-right order.
  3307. function boxIsAfter(box, x, y, left) {
  3308. return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x;
  3309. }
  3310. function coordsCharInner(cm, lineObj, lineNo$$1, x, y) {
  3311. // Move y into line-local coordinate space
  3312. y -= _heightAtLine(lineObj);
  3313. var preparedMeasure = prepareMeasureForLine(cm, lineObj);
  3314. // When directly calling `measureCharPrepared`, we have to adjust
  3315. // for the widgets at this line.
  3316. var widgetHeight$$1 = widgetTopHeight(lineObj);
  3317. var begin = 0,
  3318. end = lineObj.text.length,
  3319. ltr = true;
  3320. var order = getOrder(lineObj, cm.doc.direction);
  3321. // If the line isn't plain left-to-right text, first figure out
  3322. // which bidi section the coordinates fall into.
  3323. if (order) {
  3324. var part = (cm.options.lineWrapping ? coordsBidiPartWrapped : coordsBidiPart)(cm, lineObj, lineNo$$1, preparedMeasure, order, x, y);
  3325. ltr = part.level != 1;
  3326. // The awkward -1 offsets are needed because findFirst (called
  3327. // on these below) will treat its first bound as inclusive,
  3328. // second as exclusive, but we want to actually address the
  3329. // characters in the part's range
  3330. begin = ltr ? part.from : part.to - 1;
  3331. end = ltr ? part.to : part.from - 1;
  3332. }
  3333. // A binary search to find the first character whose bounding box
  3334. // starts after the coordinates. If we run across any whose box wrap
  3335. // the coordinates, store that.
  3336. var chAround = null,
  3337. boxAround = null;
  3338. var ch = findFirst(function (ch) {
  3339. var box = measureCharPrepared(cm, preparedMeasure, ch);
  3340. box.top += widgetHeight$$1;
  3341. box.bottom += widgetHeight$$1;
  3342. if (!boxIsAfter(box, x, y, false)) {
  3343. return false;
  3344. }
  3345. if (box.top <= y && box.left <= x) {
  3346. chAround = ch;
  3347. boxAround = box;
  3348. }
  3349. return true;
  3350. }, begin, end);
  3351. var baseX,
  3352. sticky,
  3353. outside = false;
  3354. // If a box around the coordinates was found, use that
  3355. if (boxAround) {
  3356. // Distinguish coordinates nearer to the left or right side of the box
  3357. var atLeft = x - boxAround.left < boxAround.right - x,
  3358. atStart = atLeft == ltr;
  3359. ch = chAround + (atStart ? 0 : 1);
  3360. sticky = atStart ? "after" : "before";
  3361. baseX = atLeft ? boxAround.left : boxAround.right;
  3362. } else {
  3363. // (Adjust for extended bound, if necessary.)
  3364. if (!ltr && (ch == end || ch == begin)) {
  3365. ch++;
  3366. }
  3367. // To determine which side to associate with, get the box to the
  3368. // left of the character and compare it's vertical position to the
  3369. // coordinates
  3370. sticky = ch == 0 ? "after" : ch == lineObj.text.length ? "before" : measureCharPrepared(cm, preparedMeasure, ch - (ltr ? 1 : 0)).bottom + widgetHeight$$1 <= y == ltr ? "after" : "before";
  3371. // Now get accurate coordinates for this place, in order to get a
  3372. // base X position
  3373. var coords = _cursorCoords(cm, Pos(lineNo$$1, ch, sticky), "line", lineObj, preparedMeasure);
  3374. baseX = coords.left;
  3375. outside = y < coords.top ? -1 : y >= coords.bottom ? 1 : 0;
  3376. }
  3377. ch = skipExtendingChars(lineObj.text, ch, 1);
  3378. return PosWithInfo(lineNo$$1, ch, sticky, outside, x - baseX);
  3379. }
  3380. function coordsBidiPart(cm, lineObj, lineNo$$1, preparedMeasure, order, x, y) {
  3381. // Bidi parts are sorted left-to-right, and in a non-line-wrapping
  3382. // situation, we can take this ordering to correspond to the visual
  3383. // ordering. This finds the first part whose end is after the given
  3384. // coordinates.
  3385. var index = findFirst(function (i) {
  3386. var part = order[i],
  3387. ltr = part.level != 1;
  3388. return boxIsAfter(_cursorCoords(cm, Pos(lineNo$$1, ltr ? part.to : part.from, ltr ? "before" : "after"), "line", lineObj, preparedMeasure), x, y, true);
  3389. }, 0, order.length - 1);
  3390. var part = order[index];
  3391. // If this isn't the first part, the part's start is also after
  3392. // the coordinates, and the coordinates aren't on the same line as
  3393. // that start, move one part back.
  3394. if (index > 0) {
  3395. var ltr = part.level != 1;
  3396. var start = _cursorCoords(cm, Pos(lineNo$$1, ltr ? part.from : part.to, ltr ? "after" : "before"), "line", lineObj, preparedMeasure);
  3397. if (boxIsAfter(start, x, y, true) && start.top > y) {
  3398. part = order[index - 1];
  3399. }
  3400. }
  3401. return part;
  3402. }
  3403. function coordsBidiPartWrapped(cm, lineObj, _lineNo, preparedMeasure, order, x, y) {
  3404. // In a wrapped line, rtl text on wrapping boundaries can do things
  3405. // that don't correspond to the ordering in our `order` array at
  3406. // all, so a binary search doesn't work, and we want to return a
  3407. // part that only spans one line so that the binary search in
  3408. // coordsCharInner is safe. As such, we first find the extent of the
  3409. // wrapped line, and then do a flat search in which we discard any
  3410. // spans that aren't on the line.
  3411. var ref = wrappedLineExtent(cm, lineObj, preparedMeasure, y);
  3412. var begin = ref.begin;
  3413. var end = ref.end;
  3414. if (/\s/.test(lineObj.text.charAt(end - 1))) {
  3415. end--;
  3416. }
  3417. var part = null,
  3418. closestDist = null;
  3419. for (var i = 0; i < order.length; i++) {
  3420. var p = order[i];
  3421. if (p.from >= end || p.to <= begin) {
  3422. continue;
  3423. }
  3424. var ltr = p.level != 1;
  3425. var endX = measureCharPrepared(cm, preparedMeasure, ltr ? Math.min(end, p.to) - 1 : Math.max(begin, p.from)).right;
  3426. // Weigh against spans ending before this, so that they are only
  3427. // picked if nothing ends after
  3428. var dist = endX < x ? x - endX + 1e9 : endX - x;
  3429. if (!part || closestDist > dist) {
  3430. part = p;
  3431. closestDist = dist;
  3432. }
  3433. }
  3434. if (!part) {
  3435. part = order[order.length - 1];
  3436. }
  3437. // Clip the part to the wrapped line.
  3438. if (part.from < begin) {
  3439. part = { from: begin, to: part.to, level: part.level };
  3440. }
  3441. if (part.to > end) {
  3442. part = { from: part.from, to: end, level: part.level };
  3443. }
  3444. return part;
  3445. }
  3446. var measureText;
  3447. // Compute the default text height.
  3448. function textHeight(display) {
  3449. if (display.cachedTextHeight != null) {
  3450. return display.cachedTextHeight;
  3451. }
  3452. if (measureText == null) {
  3453. measureText = elt("pre", null, "CodeMirror-line-like");
  3454. // Measure a bunch of lines, for browsers that compute
  3455. // fractional heights.
  3456. for (var i = 0; i < 49; ++i) {
  3457. measureText.appendChild(document.createTextNode("x"));
  3458. measureText.appendChild(elt("br"));
  3459. }
  3460. measureText.appendChild(document.createTextNode("x"));
  3461. }
  3462. removeChildrenAndAdd(display.measure, measureText);
  3463. var height = measureText.offsetHeight / 50;
  3464. if (height > 3) {
  3465. display.cachedTextHeight = height;
  3466. }
  3467. removeChildren(display.measure);
  3468. return height || 1;
  3469. }
  3470. // Compute the default character width.
  3471. function charWidth(display) {
  3472. if (display.cachedCharWidth != null) {
  3473. return display.cachedCharWidth;
  3474. }
  3475. var anchor = elt("span", "xxxxxxxxxx");
  3476. var pre = elt("pre", [anchor], "CodeMirror-line-like");
  3477. removeChildrenAndAdd(display.measure, pre);
  3478. var rect = anchor.getBoundingClientRect(),
  3479. width = (rect.right - rect.left) / 10;
  3480. if (width > 2) {
  3481. display.cachedCharWidth = width;
  3482. }
  3483. return width || 10;
  3484. }
  3485. // Do a bulk-read of the DOM positions and sizes needed to draw the
  3486. // view, so that we don't interleave reading and writing to the DOM.
  3487. function getDimensions(cm) {
  3488. var d = cm.display,
  3489. left = {},
  3490. width = {};
  3491. var gutterLeft = d.gutters.clientLeft;
  3492. for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
  3493. var id = cm.display.gutterSpecs[i].className;
  3494. left[id] = n.offsetLeft + n.clientLeft + gutterLeft;
  3495. width[id] = n.clientWidth;
  3496. }
  3497. return {
  3498. fixedPos: compensateForHScroll(d),
  3499. gutterTotalWidth: d.gutters.offsetWidth,
  3500. gutterLeft: left,
  3501. gutterWidth: width,
  3502. wrapperWidth: d.wrapper.clientWidth
  3503. };
  3504. }
  3505. // Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
  3506. // but using getBoundingClientRect to get a sub-pixel-accurate
  3507. // result.
  3508. function compensateForHScroll(display) {
  3509. return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
  3510. }
  3511. // Returns a function that estimates the height of a line, to use as
  3512. // first approximation until the line becomes visible (and is thus
  3513. // properly measurable).
  3514. function estimateHeight(cm) {
  3515. var th = textHeight(cm.display),
  3516. wrapping = cm.options.lineWrapping;
  3517. var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
  3518. return function (line) {
  3519. if (lineIsHidden(cm.doc, line)) {
  3520. return 0;
  3521. }
  3522. var widgetsHeight = 0;
  3523. if (line.widgets) {
  3524. for (var i = 0; i < line.widgets.length; i++) {
  3525. if (line.widgets[i].height) {
  3526. widgetsHeight += line.widgets[i].height;
  3527. }
  3528. }
  3529. }
  3530. if (wrapping) {
  3531. return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;
  3532. } else {
  3533. return widgetsHeight + th;
  3534. }
  3535. };
  3536. }
  3537. function estimateLineHeights(cm) {
  3538. var doc = cm.doc,
  3539. est = estimateHeight(cm);
  3540. doc.iter(function (line) {
  3541. var estHeight = est(line);
  3542. if (estHeight != line.height) {
  3543. updateLineHeight(line, estHeight);
  3544. }
  3545. });
  3546. }
  3547. // Given a mouse event, find the corresponding position. If liberal
  3548. // is false, it checks whether a gutter or scrollbar was clicked,
  3549. // and returns null if it was. forRect is used by rectangular
  3550. // selections, and tries to estimate a character position even for
  3551. // coordinates beyond the right of the text.
  3552. function posFromMouse(cm, e, liberal, forRect) {
  3553. var display = cm.display;
  3554. if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") {
  3555. return null;
  3556. }
  3557. var x,
  3558. y,
  3559. space = display.lineSpace.getBoundingClientRect();
  3560. // Fails unpredictably on IE[67] when mouse is dragged around quickly.
  3561. try {
  3562. x = e.clientX - space.left;
  3563. y = e.clientY - space.top;
  3564. } catch (e) {
  3565. return null;
  3566. }
  3567. var coords = _coordsChar(cm, x, y),
  3568. line;
  3569. if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
  3570. var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
  3571. coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
  3572. }
  3573. return coords;
  3574. }
  3575. // Find the view element corresponding to a given line. Return null
  3576. // when the line isn't visible.
  3577. function findViewIndex(cm, n) {
  3578. if (n >= cm.display.viewTo) {
  3579. return null;
  3580. }
  3581. n -= cm.display.viewFrom;
  3582. if (n < 0) {
  3583. return null;
  3584. }
  3585. var view = cm.display.view;
  3586. for (var i = 0; i < view.length; i++) {
  3587. n -= view[i].size;
  3588. if (n < 0) {
  3589. return i;
  3590. }
  3591. }
  3592. }
  3593. // Updates the display.view data structure for a given change to the
  3594. // document. From and to are in pre-change coordinates. Lendiff is
  3595. // the amount of lines added or subtracted by the change. This is
  3596. // used for changes that span multiple lines, or change the way
  3597. // lines are divided into visual lines. regLineChange (below)
  3598. // registers single-line changes.
  3599. function regChange(cm, from, to, lendiff) {
  3600. if (from == null) {
  3601. from = cm.doc.first;
  3602. }
  3603. if (to == null) {
  3604. to = cm.doc.first + cm.doc.size;
  3605. }
  3606. if (!lendiff) {
  3607. lendiff = 0;
  3608. }
  3609. var display = cm.display;
  3610. if (lendiff && to < display.viewTo && (display.updateLineNumbers == null || display.updateLineNumbers > from)) {
  3611. display.updateLineNumbers = from;
  3612. }
  3613. cm.curOp.viewChanged = true;
  3614. if (from >= display.viewTo) {
  3615. // Change after
  3616. if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo) {
  3617. resetView(cm);
  3618. }
  3619. } else if (to <= display.viewFrom) {
  3620. // Change before
  3621. if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
  3622. resetView(cm);
  3623. } else {
  3624. display.viewFrom += lendiff;
  3625. display.viewTo += lendiff;
  3626. }
  3627. } else if (from <= display.viewFrom && to >= display.viewTo) {
  3628. // Full overlap
  3629. resetView(cm);
  3630. } else if (from <= display.viewFrom) {
  3631. // Top overlap
  3632. var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
  3633. if (cut) {
  3634. display.view = display.view.slice(cut.index);
  3635. display.viewFrom = cut.lineN;
  3636. display.viewTo += lendiff;
  3637. } else {
  3638. resetView(cm);
  3639. }
  3640. } else if (to >= display.viewTo) {
  3641. // Bottom overlap
  3642. var cut$1 = viewCuttingPoint(cm, from, from, -1);
  3643. if (cut$1) {
  3644. display.view = display.view.slice(0, cut$1.index);
  3645. display.viewTo = cut$1.lineN;
  3646. } else {
  3647. resetView(cm);
  3648. }
  3649. } else {
  3650. // Gap in the middle
  3651. var cutTop = viewCuttingPoint(cm, from, from, -1);
  3652. var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
  3653. if (cutTop && cutBot) {
  3654. display.view = display.view.slice(0, cutTop.index).concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN)).concat(display.view.slice(cutBot.index));
  3655. display.viewTo += lendiff;
  3656. } else {
  3657. resetView(cm);
  3658. }
  3659. }
  3660. var ext = display.externalMeasured;
  3661. if (ext) {
  3662. if (to < ext.lineN) {
  3663. ext.lineN += lendiff;
  3664. } else if (from < ext.lineN + ext.size) {
  3665. display.externalMeasured = null;
  3666. }
  3667. }
  3668. }
  3669. // Register a change to a single line. Type must be one of "text",
  3670. // "gutter", "class", "widget"
  3671. function regLineChange(cm, line, type) {
  3672. cm.curOp.viewChanged = true;
  3673. var display = cm.display,
  3674. ext = cm.display.externalMeasured;
  3675. if (ext && line >= ext.lineN && line < ext.lineN + ext.size) {
  3676. display.externalMeasured = null;
  3677. }
  3678. if (line < display.viewFrom || line >= display.viewTo) {
  3679. return;
  3680. }
  3681. var lineView = display.view[findViewIndex(cm, line)];
  3682. if (lineView.node == null) {
  3683. return;
  3684. }
  3685. var arr = lineView.changes || (lineView.changes = []);
  3686. if (indexOf(arr, type) == -1) {
  3687. arr.push(type);
  3688. }
  3689. }
  3690. // Clear the view.
  3691. function resetView(cm) {
  3692. cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
  3693. cm.display.view = [];
  3694. cm.display.viewOffset = 0;
  3695. }
  3696. function viewCuttingPoint(cm, oldN, newN, dir) {
  3697. var index = findViewIndex(cm, oldN),
  3698. diff,
  3699. view = cm.display.view;
  3700. if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size) {
  3701. return { index: index, lineN: newN };
  3702. }
  3703. var n = cm.display.viewFrom;
  3704. for (var i = 0; i < index; i++) {
  3705. n += view[i].size;
  3706. }
  3707. if (n != oldN) {
  3708. if (dir > 0) {
  3709. if (index == view.length - 1) {
  3710. return null;
  3711. }
  3712. diff = n + view[index].size - oldN;
  3713. index++;
  3714. } else {
  3715. diff = n - oldN;
  3716. }
  3717. oldN += diff;
  3718. newN += diff;
  3719. }
  3720. while (visualLineNo(cm.doc, newN) != newN) {
  3721. if (index == (dir < 0 ? 0 : view.length - 1)) {
  3722. return null;
  3723. }
  3724. newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
  3725. index += dir;
  3726. }
  3727. return { index: index, lineN: newN };
  3728. }
  3729. // Force the view to cover a given range, adding empty view element
  3730. // or clipping off existing ones as needed.
  3731. function adjustView(cm, from, to) {
  3732. var display = cm.display,
  3733. view = display.view;
  3734. if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
  3735. display.view = buildViewArray(cm, from, to);
  3736. display.viewFrom = from;
  3737. } else {
  3738. if (display.viewFrom > from) {
  3739. display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view);
  3740. } else if (display.viewFrom < from) {
  3741. display.view = display.view.slice(findViewIndex(cm, from));
  3742. }
  3743. display.viewFrom = from;
  3744. if (display.viewTo < to) {
  3745. display.view = display.view.concat(buildViewArray(cm, display.viewTo, to));
  3746. } else if (display.viewTo > to) {
  3747. display.view = display.view.slice(0, findViewIndex(cm, to));
  3748. }
  3749. }
  3750. display.viewTo = to;
  3751. }
  3752. // Count the number of lines in the view whose DOM representation is
  3753. // out of date (or nonexistent).
  3754. function countDirtyView(cm) {
  3755. var view = cm.display.view,
  3756. dirty = 0;
  3757. for (var i = 0; i < view.length; i++) {
  3758. var lineView = view[i];
  3759. if (!lineView.hidden && (!lineView.node || lineView.changes)) {
  3760. ++dirty;
  3761. }
  3762. }
  3763. return dirty;
  3764. }
  3765. function updateSelection(cm) {
  3766. cm.display.input.showSelection(cm.display.input.prepareSelection());
  3767. }
  3768. function prepareSelection(cm, primary) {
  3769. if (primary === void 0) primary = true;
  3770. var doc = cm.doc,
  3771. result = {};
  3772. var curFragment = result.cursors = document.createDocumentFragment();
  3773. var selFragment = result.selection = document.createDocumentFragment();
  3774. for (var i = 0; i < doc.sel.ranges.length; i++) {
  3775. if (!primary && i == doc.sel.primIndex) {
  3776. continue;
  3777. }
  3778. var range$$1 = doc.sel.ranges[i];
  3779. if (range$$1.from().line >= cm.display.viewTo || range$$1.to().line < cm.display.viewFrom) {
  3780. continue;
  3781. }
  3782. var collapsed = range$$1.empty();
  3783. if (collapsed || cm.options.showCursorWhenSelecting) {
  3784. drawSelectionCursor(cm, range$$1.head, curFragment);
  3785. }
  3786. if (!collapsed) {
  3787. drawSelectionRange(cm, range$$1, selFragment);
  3788. }
  3789. }
  3790. return result;
  3791. }
  3792. // Draws a cursor for the given range
  3793. function drawSelectionCursor(cm, head, output) {
  3794. var pos = _cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
  3795. var cursor = output.appendChild(elt("div", "\xA0", "CodeMirror-cursor"));
  3796. cursor.style.left = pos.left + "px";
  3797. cursor.style.top = pos.top + "px";
  3798. cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
  3799. if (pos.other) {
  3800. // Secondary cursor, shown when on a 'jump' in bi-directional text
  3801. var otherCursor = output.appendChild(elt("div", "\xA0", "CodeMirror-cursor CodeMirror-secondarycursor"));
  3802. otherCursor.style.display = "";
  3803. otherCursor.style.left = pos.other.left + "px";
  3804. otherCursor.style.top = pos.other.top + "px";
  3805. otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
  3806. }
  3807. }
  3808. function cmpCoords(a, b) {
  3809. return a.top - b.top || a.left - b.left;
  3810. }
  3811. // Draws the given range as a highlighted selection
  3812. function drawSelectionRange(cm, range$$1, output) {
  3813. var display = cm.display,
  3814. doc = cm.doc;
  3815. var fragment = document.createDocumentFragment();
  3816. var padding = paddingH(cm.display),
  3817. leftSide = padding.left;
  3818. var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
  3819. var docLTR = doc.direction == "ltr";
  3820. function add(left, top, width, bottom) {
  3821. if (top < 0) {
  3822. top = 0;
  3823. }
  3824. top = Math.round(top);
  3825. bottom = Math.round(bottom);
  3826. fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left + "px;\n top: " + top + "px; width: " + (width == null ? rightSide - left : width) + "px;\n height: " + (bottom - top) + "px"));
  3827. }
  3828. function drawForLine(line, fromArg, toArg) {
  3829. var lineObj = getLine(doc, line);
  3830. var lineLen = lineObj.text.length;
  3831. var start, end;
  3832. function coords(ch, bias) {
  3833. return _charCoords(cm, Pos(line, ch), "div", lineObj, bias);
  3834. }
  3835. function wrapX(pos, dir, side) {
  3836. var extent = wrappedLineExtentChar(cm, lineObj, null, pos);
  3837. var prop = dir == "ltr" == (side == "after") ? "left" : "right";
  3838. var ch = side == "after" ? extent.begin : extent.end - (/\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1);
  3839. return coords(ch, prop)[prop];
  3840. }
  3841. var order = getOrder(lineObj, doc.direction);
  3842. iterateBidiSections(order, fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir, i) {
  3843. var ltr = dir == "ltr";
  3844. var fromPos = coords(from, ltr ? "left" : "right");
  3845. var toPos = coords(to - 1, ltr ? "right" : "left");
  3846. var openStart = fromArg == null && from == 0,
  3847. openEnd = toArg == null && to == lineLen;
  3848. var first = i == 0,
  3849. last = !order || i == order.length - 1;
  3850. if (toPos.top - fromPos.top <= 3) {
  3851. // Single line
  3852. var openLeft = (docLTR ? openStart : openEnd) && first;
  3853. var openRight = (docLTR ? openEnd : openStart) && last;
  3854. var left = openLeft ? leftSide : (ltr ? fromPos : toPos).left;
  3855. var right = openRight ? rightSide : (ltr ? toPos : fromPos).right;
  3856. add(left, fromPos.top, right - left, fromPos.bottom);
  3857. } else {
  3858. // Multiple lines
  3859. var topLeft, topRight, botLeft, botRight;
  3860. if (ltr) {
  3861. topLeft = docLTR && openStart && first ? leftSide : fromPos.left;
  3862. topRight = docLTR ? rightSide : wrapX(from, dir, "before");
  3863. botLeft = docLTR ? leftSide : wrapX(to, dir, "after");
  3864. botRight = docLTR && openEnd && last ? rightSide : toPos.right;
  3865. } else {
  3866. topLeft = !docLTR ? leftSide : wrapX(from, dir, "before");
  3867. topRight = !docLTR && openStart && first ? rightSide : fromPos.right;
  3868. botLeft = !docLTR && openEnd && last ? leftSide : toPos.left;
  3869. botRight = !docLTR ? rightSide : wrapX(to, dir, "after");
  3870. }
  3871. add(topLeft, fromPos.top, topRight - topLeft, fromPos.bottom);
  3872. if (fromPos.bottom < toPos.top) {
  3873. add(leftSide, fromPos.bottom, null, toPos.top);
  3874. }
  3875. add(botLeft, toPos.top, botRight - botLeft, toPos.bottom);
  3876. }
  3877. if (!start || cmpCoords(fromPos, start) < 0) {
  3878. start = fromPos;
  3879. }
  3880. if (cmpCoords(toPos, start) < 0) {
  3881. start = toPos;
  3882. }
  3883. if (!end || cmpCoords(fromPos, end) < 0) {
  3884. end = fromPos;
  3885. }
  3886. if (cmpCoords(toPos, end) < 0) {
  3887. end = toPos;
  3888. }
  3889. });
  3890. return { start: start, end: end };
  3891. }
  3892. var sFrom = range$$1.from(),
  3893. sTo = range$$1.to();
  3894. if (sFrom.line == sTo.line) {
  3895. drawForLine(sFrom.line, sFrom.ch, sTo.ch);
  3896. } else {
  3897. var fromLine = getLine(doc, sFrom.line),
  3898. toLine = getLine(doc, sTo.line);
  3899. var singleVLine = visualLine(fromLine) == visualLine(toLine);
  3900. var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
  3901. var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
  3902. if (singleVLine) {
  3903. if (leftEnd.top < rightStart.top - 2) {
  3904. add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
  3905. add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
  3906. } else {
  3907. add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
  3908. }
  3909. }
  3910. if (leftEnd.bottom < rightStart.top) {
  3911. add(leftSide, leftEnd.bottom, null, rightStart.top);
  3912. }
  3913. }
  3914. output.appendChild(fragment);
  3915. }
  3916. // Cursor-blinking
  3917. function restartBlink(cm) {
  3918. if (!cm.state.focused) {
  3919. return;
  3920. }
  3921. var display = cm.display;
  3922. clearInterval(display.blinker);
  3923. var on = true;
  3924. display.cursorDiv.style.visibility = "";
  3925. if (cm.options.cursorBlinkRate > 0) {
  3926. display.blinker = setInterval(function () {
  3927. return display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
  3928. }, cm.options.cursorBlinkRate);
  3929. } else if (cm.options.cursorBlinkRate < 0) {
  3930. display.cursorDiv.style.visibility = "hidden";
  3931. }
  3932. }
  3933. function ensureFocus(cm) {
  3934. if (!cm.state.focused) {
  3935. cm.display.input.focus();
  3936. onFocus(cm);
  3937. }
  3938. }
  3939. function delayBlurEvent(cm) {
  3940. cm.state.delayingBlurEvent = true;
  3941. setTimeout(function () {
  3942. if (cm.state.delayingBlurEvent) {
  3943. cm.state.delayingBlurEvent = false;
  3944. onBlur(cm);
  3945. }
  3946. }, 100);
  3947. }
  3948. function onFocus(cm, e) {
  3949. if (cm.state.delayingBlurEvent) {
  3950. cm.state.delayingBlurEvent = false;
  3951. }
  3952. if (cm.options.readOnly == "nocursor") {
  3953. return;
  3954. }
  3955. if (!cm.state.focused) {
  3956. signal(cm, "focus", cm, e);
  3957. cm.state.focused = true;
  3958. addClass(cm.display.wrapper, "CodeMirror-focused");
  3959. // This test prevents this from firing when a context
  3960. // menu is closed (since the input reset would kill the
  3961. // select-all detection hack)
  3962. if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
  3963. cm.display.input.reset();
  3964. if (webkit) {
  3965. setTimeout(function () {
  3966. return cm.display.input.reset(true);
  3967. }, 20);
  3968. } // Issue #1730
  3969. }
  3970. cm.display.input.receivedFocus();
  3971. }
  3972. restartBlink(cm);
  3973. }
  3974. function onBlur(cm, e) {
  3975. if (cm.state.delayingBlurEvent) {
  3976. return;
  3977. }
  3978. if (cm.state.focused) {
  3979. signal(cm, "blur", cm, e);
  3980. cm.state.focused = false;
  3981. rmClass(cm.display.wrapper, "CodeMirror-focused");
  3982. }
  3983. clearInterval(cm.display.blinker);
  3984. setTimeout(function () {
  3985. if (!cm.state.focused) {
  3986. cm.display.shift = false;
  3987. }
  3988. }, 150);
  3989. }
  3990. // Read the actual heights of the rendered lines, and update their
  3991. // stored heights to match.
  3992. function updateHeightsInViewport(cm) {
  3993. var display = cm.display;
  3994. var prevBottom = display.lineDiv.offsetTop;
  3995. for (var i = 0; i < display.view.length; i++) {
  3996. var cur = display.view[i],
  3997. wrapping = cm.options.lineWrapping;
  3998. var height = void 0,
  3999. width = 0;
  4000. if (cur.hidden) {
  4001. continue;
  4002. }
  4003. if (ie && ie_version < 8) {
  4004. var bot = cur.node.offsetTop + cur.node.offsetHeight;
  4005. height = bot - prevBottom;
  4006. prevBottom = bot;
  4007. } else {
  4008. var box = cur.node.getBoundingClientRect();
  4009. height = box.bottom - box.top;
  4010. // Check that lines don't extend past the right of the current
  4011. // src width
  4012. if (!wrapping && cur.text.firstChild) {
  4013. width = cur.text.firstChild.getBoundingClientRect().right - box.left - 1;
  4014. }
  4015. }
  4016. var diff = cur.line.height - height;
  4017. if (diff > .005 || diff < -.005) {
  4018. updateLineHeight(cur.line, height);
  4019. updateWidgetHeight(cur.line);
  4020. if (cur.rest) {
  4021. for (var j = 0; j < cur.rest.length; j++) {
  4022. updateWidgetHeight(cur.rest[j]);
  4023. }
  4024. }
  4025. }
  4026. if (width > cm.display.sizerWidth) {
  4027. var chWidth = Math.ceil(width / charWidth(cm.display));
  4028. if (chWidth > cm.display.maxLineLength) {
  4029. cm.display.maxLineLength = chWidth;
  4030. cm.display.maxLine = cur.line;
  4031. cm.display.maxLineChanged = true;
  4032. }
  4033. }
  4034. }
  4035. }
  4036. // Read and store the height of line widgets associated with the
  4037. // given line.
  4038. function updateWidgetHeight(line) {
  4039. if (line.widgets) {
  4040. for (var i = 0; i < line.widgets.length; ++i) {
  4041. var w = line.widgets[i],
  4042. parent = w.node.parentNode;
  4043. if (parent) {
  4044. w.height = parent.offsetHeight;
  4045. }
  4046. }
  4047. }
  4048. }
  4049. // Compute the lines that are visible in a given viewport (defaults
  4050. // the the current scroll position). viewport may contain top,
  4051. // height, and ensure (see op.scrollToPos) properties.
  4052. function visibleLines(display, doc, viewport) {
  4053. var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
  4054. top = Math.floor(top - paddingTop(display));
  4055. var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
  4056. var from = _lineAtHeight(doc, top),
  4057. to = _lineAtHeight(doc, bottom);
  4058. // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
  4059. // forces those lines into the viewport (if possible).
  4060. if (viewport && viewport.ensure) {
  4061. var ensureFrom = viewport.ensure.from.line,
  4062. ensureTo = viewport.ensure.to.line;
  4063. if (ensureFrom < from) {
  4064. from = ensureFrom;
  4065. to = _lineAtHeight(doc, _heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
  4066. } else if (Math.min(ensureTo, doc.lastLine()) >= to) {
  4067. from = _lineAtHeight(doc, _heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
  4068. to = ensureTo;
  4069. }
  4070. }
  4071. return { from: from, to: Math.max(to, from + 1) };
  4072. }
  4073. // SCROLLING THINGS INTO VIEW
  4074. // If an src sits on the top or bottom of the window, partially
  4075. // scrolled out of view, this ensures that the cursor is visible.
  4076. function maybeScrollWindow(cm, rect) {
  4077. if (signalDOMEvent(cm, "scrollCursorIntoView")) {
  4078. return;
  4079. }
  4080. var display = cm.display,
  4081. box = display.sizer.getBoundingClientRect(),
  4082. doScroll = null;
  4083. if (rect.top + box.top < 0) {
  4084. doScroll = true;
  4085. } else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) {
  4086. doScroll = false;
  4087. }
  4088. if (doScroll != null && !phantom) {
  4089. var scrollNode = elt("div", "\u200B", null, "position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + rect.left + "px; width: " + Math.max(2, rect.right - rect.left) + "px;");
  4090. cm.display.lineSpace.appendChild(scrollNode);
  4091. scrollNode.scrollIntoView(doScroll);
  4092. cm.display.lineSpace.removeChild(scrollNode);
  4093. }
  4094. }
  4095. // Scroll a given position into view (immediately), verifying that
  4096. // it actually became visible (as line heights are accurately
  4097. // measured, the position of something may 'drift' during drawing).
  4098. function scrollPosIntoView(cm, pos, end, margin) {
  4099. if (margin == null) {
  4100. margin = 0;
  4101. }
  4102. var rect;
  4103. if (!cm.options.lineWrapping && pos == end) {
  4104. // Set pos and end to the cursor positions around the character pos sticks to
  4105. // If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch
  4106. // If pos == Pos(_, 0, "before"), pos and end are unchanged
  4107. pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos;
  4108. end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos;
  4109. }
  4110. for (var limit = 0; limit < 5; limit++) {
  4111. var changed = false;
  4112. var coords = _cursorCoords(cm, pos);
  4113. var endCoords = !end || end == pos ? coords : _cursorCoords(cm, end);
  4114. rect = {
  4115. left: Math.min(coords.left, endCoords.left),
  4116. top: Math.min(coords.top, endCoords.top) - margin,
  4117. right: Math.max(coords.left, endCoords.left),
  4118. bottom: Math.max(coords.bottom, endCoords.bottom) + margin
  4119. };
  4120. var scrollPos = calculateScrollPos(cm, rect);
  4121. var startTop = cm.doc.scrollTop,
  4122. startLeft = cm.doc.scrollLeft;
  4123. if (scrollPos.scrollTop != null) {
  4124. updateScrollTop(cm, scrollPos.scrollTop);
  4125. if (Math.abs(cm.doc.scrollTop - startTop) > 1) {
  4126. changed = true;
  4127. }
  4128. }
  4129. if (scrollPos.scrollLeft != null) {
  4130. setScrollLeft(cm, scrollPos.scrollLeft);
  4131. if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) {
  4132. changed = true;
  4133. }
  4134. }
  4135. if (!changed) {
  4136. break;
  4137. }
  4138. }
  4139. return rect;
  4140. }
  4141. // Scroll a given set of coordinates into view (immediately).
  4142. function scrollIntoView(cm, rect) {
  4143. var scrollPos = calculateScrollPos(cm, rect);
  4144. if (scrollPos.scrollTop != null) {
  4145. updateScrollTop(cm, scrollPos.scrollTop);
  4146. }
  4147. if (scrollPos.scrollLeft != null) {
  4148. setScrollLeft(cm, scrollPos.scrollLeft);
  4149. }
  4150. }
  4151. // Calculate a new scroll position needed to scroll the given
  4152. // rectangle into view. Returns an object with scrollTop and
  4153. // scrollLeft properties. When these are undefined, the
  4154. // vertical/horizontal position does not need to be adjusted.
  4155. function calculateScrollPos(cm, rect) {
  4156. var display = cm.display,
  4157. snapMargin = textHeight(cm.display);
  4158. if (rect.top < 0) {
  4159. rect.top = 0;
  4160. }
  4161. var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
  4162. var screen = displayHeight(cm),
  4163. result = {};
  4164. if (rect.bottom - rect.top > screen) {
  4165. rect.bottom = rect.top + screen;
  4166. }
  4167. var docBottom = cm.doc.height + paddingVert(display);
  4168. var atTop = rect.top < snapMargin,
  4169. atBottom = rect.bottom > docBottom - snapMargin;
  4170. if (rect.top < screentop) {
  4171. result.scrollTop = atTop ? 0 : rect.top;
  4172. } else if (rect.bottom > screentop + screen) {
  4173. var newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen);
  4174. if (newTop != screentop) {
  4175. result.scrollTop = newTop;
  4176. }
  4177. }
  4178. var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
  4179. var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);
  4180. var tooWide = rect.right - rect.left > screenw;
  4181. if (tooWide) {
  4182. rect.right = rect.left + screenw;
  4183. }
  4184. if (rect.left < 10) {
  4185. result.scrollLeft = 0;
  4186. } else if (rect.left < screenleft) {
  4187. result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10));
  4188. } else if (rect.right > screenw + screenleft - 3) {
  4189. result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw;
  4190. }
  4191. return result;
  4192. }
  4193. // Store a relative adjustment to the scroll position in the current
  4194. // operation (to be applied when the operation finishes).
  4195. function addToScrollTop(cm, top) {
  4196. if (top == null) {
  4197. return;
  4198. }
  4199. resolveScrollToPos(cm);
  4200. cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
  4201. }
  4202. // Make sure that at the end of the operation the current cursor is
  4203. // shown.
  4204. function ensureCursorVisible(cm) {
  4205. resolveScrollToPos(cm);
  4206. var cur = cm.getCursor();
  4207. cm.curOp.scrollToPos = { from: cur, to: cur, margin: cm.options.cursorScrollMargin };
  4208. }
  4209. function scrollToCoords(cm, x, y) {
  4210. if (x != null || y != null) {
  4211. resolveScrollToPos(cm);
  4212. }
  4213. if (x != null) {
  4214. cm.curOp.scrollLeft = x;
  4215. }
  4216. if (y != null) {
  4217. cm.curOp.scrollTop = y;
  4218. }
  4219. }
  4220. function scrollToRange(cm, range$$1) {
  4221. resolveScrollToPos(cm);
  4222. cm.curOp.scrollToPos = range$$1;
  4223. }
  4224. // When an operation has its scrollToPos property set, and another
  4225. // scroll action is applied before the end of the operation, this
  4226. // 'simulates' scrolling that position into view in a cheap way, so
  4227. // that the effect of intermediate scroll commands is not ignored.
  4228. function resolveScrollToPos(cm) {
  4229. var range$$1 = cm.curOp.scrollToPos;
  4230. if (range$$1) {
  4231. cm.curOp.scrollToPos = null;
  4232. var from = estimateCoords(cm, range$$1.from),
  4233. to = estimateCoords(cm, range$$1.to);
  4234. scrollToCoordsRange(cm, from, to, range$$1.margin);
  4235. }
  4236. }
  4237. function scrollToCoordsRange(cm, from, to, margin) {
  4238. var sPos = calculateScrollPos(cm, {
  4239. left: Math.min(from.left, to.left),
  4240. top: Math.min(from.top, to.top) - margin,
  4241. right: Math.max(from.right, to.right),
  4242. bottom: Math.max(from.bottom, to.bottom) + margin
  4243. });
  4244. scrollToCoords(cm, sPos.scrollLeft, sPos.scrollTop);
  4245. }
  4246. // Sync the scrollable area and scrollbars, ensure the viewport
  4247. // covers the visible area.
  4248. function updateScrollTop(cm, val) {
  4249. if (Math.abs(cm.doc.scrollTop - val) < 2) {
  4250. return;
  4251. }
  4252. if (!gecko) {
  4253. updateDisplaySimple(cm, { top: val });
  4254. }
  4255. setScrollTop(cm, val, true);
  4256. if (gecko) {
  4257. updateDisplaySimple(cm);
  4258. }
  4259. startWorker(cm, 100);
  4260. }
  4261. function setScrollTop(cm, val, forceScroll) {
  4262. val = Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val);
  4263. if (cm.display.scroller.scrollTop == val && !forceScroll) {
  4264. return;
  4265. }
  4266. cm.doc.scrollTop = val;
  4267. cm.display.scrollbars.setScrollTop(val);
  4268. if (cm.display.scroller.scrollTop != val) {
  4269. cm.display.scroller.scrollTop = val;
  4270. }
  4271. }
  4272. // Sync scroller and scrollbar, ensure the gutter elements are
  4273. // aligned.
  4274. function setScrollLeft(cm, val, isScroller, forceScroll) {
  4275. val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
  4276. if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) {
  4277. return;
  4278. }
  4279. cm.doc.scrollLeft = val;
  4280. alignHorizontally(cm);
  4281. if (cm.display.scroller.scrollLeft != val) {
  4282. cm.display.scroller.scrollLeft = val;
  4283. }
  4284. cm.display.scrollbars.setScrollLeft(val);
  4285. }
  4286. // SCROLLBARS
  4287. // Prepare DOM reads needed to update the scrollbars. Done in one
  4288. // shot to minimize update/measure roundtrips.
  4289. function measureForScrollbars(cm) {
  4290. var d = cm.display,
  4291. gutterW = d.gutters.offsetWidth;
  4292. var docH = Math.round(cm.doc.height + paddingVert(cm.display));
  4293. return {
  4294. clientHeight: d.scroller.clientHeight,
  4295. viewHeight: d.wrapper.clientHeight,
  4296. scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
  4297. viewWidth: d.wrapper.clientWidth,
  4298. barLeft: cm.options.fixedGutter ? gutterW : 0,
  4299. docHeight: docH,
  4300. scrollHeight: docH + scrollGap(cm) + d.barHeight,
  4301. nativeBarWidth: d.nativeBarWidth,
  4302. gutterWidth: gutterW
  4303. };
  4304. }
  4305. var NativeScrollbars = function NativeScrollbars(place, scroll, cm) {
  4306. this.cm = cm;
  4307. var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
  4308. var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
  4309. vert.tabIndex = horiz.tabIndex = -1;
  4310. place(vert);
  4311. place(horiz);
  4312. on(vert, "scroll", function () {
  4313. if (vert.clientHeight) {
  4314. scroll(vert.scrollTop, "vertical");
  4315. }
  4316. });
  4317. on(horiz, "scroll", function () {
  4318. if (horiz.clientWidth) {
  4319. scroll(horiz.scrollLeft, "horizontal");
  4320. }
  4321. });
  4322. this.checkedZeroWidth = false;
  4323. // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
  4324. if (ie && ie_version < 8) {
  4325. this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
  4326. }
  4327. };
  4328. NativeScrollbars.prototype.update = function (measure) {
  4329. var needsH = measure.scrollWidth > measure.clientWidth + 1;
  4330. var needsV = measure.scrollHeight > measure.clientHeight + 1;
  4331. var sWidth = measure.nativeBarWidth;
  4332. if (needsV) {
  4333. this.vert.style.display = "block";
  4334. this.vert.style.bottom = needsH ? sWidth + "px" : "0";
  4335. var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
  4336. // A bug in IE8 can cause this value to be negative, so guard it.
  4337. this.vert.firstChild.style.height = Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
  4338. } else {
  4339. this.vert.style.display = "";
  4340. this.vert.firstChild.style.height = "0";
  4341. }
  4342. if (needsH) {
  4343. this.horiz.style.display = "block";
  4344. this.horiz.style.right = needsV ? sWidth + "px" : "0";
  4345. this.horiz.style.left = measure.barLeft + "px";
  4346. var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
  4347. this.horiz.firstChild.style.width = Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
  4348. } else {
  4349. this.horiz.style.display = "";
  4350. this.horiz.firstChild.style.width = "0";
  4351. }
  4352. if (!this.checkedZeroWidth && measure.clientHeight > 0) {
  4353. if (sWidth == 0) {
  4354. this.zeroWidthHack();
  4355. }
  4356. this.checkedZeroWidth = true;
  4357. }
  4358. return { right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0 };
  4359. };
  4360. NativeScrollbars.prototype.setScrollLeft = function (pos) {
  4361. if (this.horiz.scrollLeft != pos) {
  4362. this.horiz.scrollLeft = pos;
  4363. }
  4364. if (this.disableHoriz) {
  4365. this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz");
  4366. }
  4367. };
  4368. NativeScrollbars.prototype.setScrollTop = function (pos) {
  4369. if (this.vert.scrollTop != pos) {
  4370. this.vert.scrollTop = pos;
  4371. }
  4372. if (this.disableVert) {
  4373. this.enableZeroWidthBar(this.vert, this.disableVert, "vert");
  4374. }
  4375. };
  4376. NativeScrollbars.prototype.zeroWidthHack = function () {
  4377. var w = mac && !mac_geMountainLion ? "12px" : "18px";
  4378. this.horiz.style.height = this.vert.style.width = w;
  4379. this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none";
  4380. this.disableHoriz = new Delayed();
  4381. this.disableVert = new Delayed();
  4382. };
  4383. NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay, type) {
  4384. bar.style.pointerEvents = "auto";
  4385. function maybeDisable() {
  4386. // To find out whether the scrollbar is still visible, we
  4387. // check whether the element under the pixel in the bottom
  4388. // right corner of the scrollbar box is the scrollbar box
  4389. // itself (when the bar is still visible) or its filler child
  4390. // (when the bar is hidden). If it is still visible, we keep
  4391. // it enabled, if it's hidden, we disable pointer events.
  4392. var box = bar.getBoundingClientRect();
  4393. var elt$$1 = type == "vert" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2) : document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1);
  4394. if (elt$$1 != bar) {
  4395. bar.style.pointerEvents = "none";
  4396. } else {
  4397. delay.set(1000, maybeDisable);
  4398. }
  4399. }
  4400. delay.set(1000, maybeDisable);
  4401. };
  4402. NativeScrollbars.prototype.clear = function () {
  4403. var parent = this.horiz.parentNode;
  4404. parent.removeChild(this.horiz);
  4405. parent.removeChild(this.vert);
  4406. };
  4407. var NullScrollbars = function NullScrollbars() {};
  4408. NullScrollbars.prototype.update = function () {
  4409. return { bottom: 0, right: 0 };
  4410. };
  4411. NullScrollbars.prototype.setScrollLeft = function () {};
  4412. NullScrollbars.prototype.setScrollTop = function () {};
  4413. NullScrollbars.prototype.clear = function () {};
  4414. function updateScrollbars(cm, measure) {
  4415. if (!measure) {
  4416. measure = measureForScrollbars(cm);
  4417. }
  4418. var startWidth = cm.display.barWidth,
  4419. startHeight = cm.display.barHeight;
  4420. updateScrollbarsInner(cm, measure);
  4421. for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
  4422. if (startWidth != cm.display.barWidth && cm.options.lineWrapping) {
  4423. updateHeightsInViewport(cm);
  4424. }
  4425. updateScrollbarsInner(cm, measureForScrollbars(cm));
  4426. startWidth = cm.display.barWidth;
  4427. startHeight = cm.display.barHeight;
  4428. }
  4429. }
  4430. // Re-synchronize the fake scrollbars with the actual size of the
  4431. // content.
  4432. function updateScrollbarsInner(cm, measure) {
  4433. var d = cm.display;
  4434. var sizes = d.scrollbars.update(measure);
  4435. d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
  4436. d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
  4437. d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent";
  4438. if (sizes.right && sizes.bottom) {
  4439. d.scrollbarFiller.style.display = "block";
  4440. d.scrollbarFiller.style.height = sizes.bottom + "px";
  4441. d.scrollbarFiller.style.width = sizes.right + "px";
  4442. } else {
  4443. d.scrollbarFiller.style.display = "";
  4444. }
  4445. if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
  4446. d.gutterFiller.style.display = "block";
  4447. d.gutterFiller.style.height = sizes.bottom + "px";
  4448. d.gutterFiller.style.width = measure.gutterWidth + "px";
  4449. } else {
  4450. d.gutterFiller.style.display = "";
  4451. }
  4452. }
  4453. var scrollbarModel = { "native": NativeScrollbars, "null": NullScrollbars };
  4454. function initScrollbars(cm) {
  4455. if (cm.display.scrollbars) {
  4456. cm.display.scrollbars.clear();
  4457. if (cm.display.scrollbars.addClass) {
  4458. rmClass(cm.display.wrapper, cm.display.scrollbars.addClass);
  4459. }
  4460. }
  4461. cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function (node) {
  4462. cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
  4463. // Prevent clicks in the scrollbars from killing focus
  4464. on(node, "mousedown", function () {
  4465. if (cm.state.focused) {
  4466. setTimeout(function () {
  4467. return cm.display.input.focus();
  4468. }, 0);
  4469. }
  4470. });
  4471. node.setAttribute("cm-not-content", "true");
  4472. }, function (pos, axis) {
  4473. if (axis == "horizontal") {
  4474. setScrollLeft(cm, pos);
  4475. } else {
  4476. updateScrollTop(cm, pos);
  4477. }
  4478. }, cm);
  4479. if (cm.display.scrollbars.addClass) {
  4480. addClass(cm.display.wrapper, cm.display.scrollbars.addClass);
  4481. }
  4482. }
  4483. // Operations are used to wrap a series of changes to the src
  4484. // state in such a way that each change won't have to update the
  4485. // cursor and display (which would be awkward, slow, and
  4486. // error-prone). Instead, display updates are batched and then all
  4487. // combined and executed at once.
  4488. var nextOpId = 0;
  4489. // Start a new operation.
  4490. function _startOperation(cm) {
  4491. cm.curOp = {
  4492. cm: cm,
  4493. viewChanged: false, // Flag that indicates that lines might need to be redrawn
  4494. startHeight: cm.doc.height, // Used to detect need to update scrollbar
  4495. forceUpdate: false, // Used to force a redraw
  4496. updateInput: 0, // Whether to reset the input textarea
  4497. typing: false, // Whether this reset should be careful to leave existing text (for compositing)
  4498. changeObjs: null, // Accumulated changes, for firing change events
  4499. cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
  4500. cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
  4501. selectionChanged: false, // Whether the selection needs to be redrawn
  4502. updateMaxLine: false, // Set when the widest line needs to be determined anew
  4503. scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
  4504. scrollToPos: null, // Used to scroll to a specific position
  4505. focus: false,
  4506. id: ++nextOpId // Unique ID
  4507. };
  4508. pushOperation(cm.curOp);
  4509. }
  4510. // Finish an operation, updating the display and signalling delayed events
  4511. function _endOperation(cm) {
  4512. var op = cm.curOp;
  4513. if (op) {
  4514. finishOperation(op, function (group) {
  4515. for (var i = 0; i < group.ops.length; i++) {
  4516. group.ops[i].cm.curOp = null;
  4517. }
  4518. endOperations(group);
  4519. });
  4520. }
  4521. }
  4522. // The DOM updates done when an operation finishes are batched so
  4523. // that the minimum number of relayouts are required.
  4524. function endOperations(group) {
  4525. var ops = group.ops;
  4526. for (var i = 0; i < ops.length; i++) // Read DOM
  4527. {
  4528. endOperation_R1(ops[i]);
  4529. }
  4530. for (var i$1 = 0; i$1 < ops.length; i$1++) // Write DOM (maybe)
  4531. {
  4532. endOperation_W1(ops[i$1]);
  4533. }
  4534. for (var i$2 = 0; i$2 < ops.length; i$2++) // Read DOM
  4535. {
  4536. endOperation_R2(ops[i$2]);
  4537. }
  4538. for (var i$3 = 0; i$3 < ops.length; i$3++) // Write DOM (maybe)
  4539. {
  4540. endOperation_W2(ops[i$3]);
  4541. }
  4542. for (var i$4 = 0; i$4 < ops.length; i$4++) // Read DOM
  4543. {
  4544. endOperation_finish(ops[i$4]);
  4545. }
  4546. }
  4547. function endOperation_R1(op) {
  4548. var cm = op.cm,
  4549. display = cm.display;
  4550. maybeClipScrollbars(cm);
  4551. if (op.updateMaxLine) {
  4552. findMaxLine(cm);
  4553. }
  4554. op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null || op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom || op.scrollToPos.to.line >= display.viewTo) || display.maxLineChanged && cm.options.lineWrapping;
  4555. op.update = op.mustUpdate && new DisplayUpdate(cm, op.mustUpdate && { top: op.scrollTop, ensure: op.scrollToPos }, op.forceUpdate);
  4556. }
  4557. function endOperation_W1(op) {
  4558. op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);
  4559. }
  4560. function endOperation_R2(op) {
  4561. var cm = op.cm,
  4562. display = cm.display;
  4563. if (op.updatedDisplay) {
  4564. updateHeightsInViewport(cm);
  4565. }
  4566. op.barMeasure = measureForScrollbars(cm);
  4567. // If the max line changed since it was last measured, measure it,
  4568. // and ensure the document's width matches it.
  4569. // updateDisplay_W2 will use these properties to do the actual resizing
  4570. if (display.maxLineChanged && !cm.options.lineWrapping) {
  4571. op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;
  4572. cm.display.sizerWidth = op.adjustWidthTo;
  4573. op.barMeasure.scrollWidth = Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth);
  4574. op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm));
  4575. }
  4576. if (op.updatedDisplay || op.selectionChanged) {
  4577. op.preparedSelection = display.input.prepareSelection();
  4578. }
  4579. }
  4580. function endOperation_W2(op) {
  4581. var cm = op.cm;
  4582. if (op.adjustWidthTo != null) {
  4583. cm.display.sizer.style.minWidth = op.adjustWidthTo + "px";
  4584. if (op.maxScrollLeft < cm.doc.scrollLeft) {
  4585. setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true);
  4586. }
  4587. cm.display.maxLineChanged = false;
  4588. }
  4589. var takeFocus = op.focus && op.focus == activeElt();
  4590. if (op.preparedSelection) {
  4591. cm.display.input.showSelection(op.preparedSelection, takeFocus);
  4592. }
  4593. if (op.updatedDisplay || op.startHeight != cm.doc.height) {
  4594. updateScrollbars(cm, op.barMeasure);
  4595. }
  4596. if (op.updatedDisplay) {
  4597. setDocumentHeight(cm, op.barMeasure);
  4598. }
  4599. if (op.selectionChanged) {
  4600. restartBlink(cm);
  4601. }
  4602. if (cm.state.focused && op.updateInput) {
  4603. cm.display.input.reset(op.typing);
  4604. }
  4605. if (takeFocus) {
  4606. ensureFocus(op.cm);
  4607. }
  4608. }
  4609. function endOperation_finish(op) {
  4610. var cm = op.cm,
  4611. display = cm.display,
  4612. doc = cm.doc;
  4613. if (op.updatedDisplay) {
  4614. postUpdateDisplay(cm, op.update);
  4615. }
  4616. // Abort mouse wheel delta measurement, when scrolling explicitly
  4617. if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos)) {
  4618. display.wheelStartX = display.wheelStartY = null;
  4619. }
  4620. // Propagate the scroll position to the actual DOM scroller
  4621. if (op.scrollTop != null) {
  4622. setScrollTop(cm, op.scrollTop, op.forceScroll);
  4623. }
  4624. if (op.scrollLeft != null) {
  4625. setScrollLeft(cm, op.scrollLeft, true, true);
  4626. }
  4627. // If we need to scroll a specific position into view, do so.
  4628. if (op.scrollToPos) {
  4629. var rect = scrollPosIntoView(cm, _clipPos(doc, op.scrollToPos.from), _clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin);
  4630. maybeScrollWindow(cm, rect);
  4631. }
  4632. // Fire events for markers that are hidden/unidden by editing or
  4633. // undoing
  4634. var hidden = op.maybeHiddenMarkers,
  4635. unhidden = op.maybeUnhiddenMarkers;
  4636. if (hidden) {
  4637. for (var i = 0; i < hidden.length; ++i) {
  4638. if (!hidden[i].lines.length) {
  4639. signal(hidden[i], "hide");
  4640. }
  4641. }
  4642. }
  4643. if (unhidden) {
  4644. for (var i$1 = 0; i$1 < unhidden.length; ++i$1) {
  4645. if (unhidden[i$1].lines.length) {
  4646. signal(unhidden[i$1], "unhide");
  4647. }
  4648. }
  4649. }
  4650. if (display.wrapper.offsetHeight) {
  4651. doc.scrollTop = cm.display.scroller.scrollTop;
  4652. }
  4653. // Fire change events, and delayed event handlers
  4654. if (op.changeObjs) {
  4655. signal(cm, "changes", cm, op.changeObjs);
  4656. }
  4657. if (op.update) {
  4658. op.update.finish();
  4659. }
  4660. }
  4661. // Run the given function in an operation
  4662. function runInOp(cm, f) {
  4663. if (cm.curOp) {
  4664. return f();
  4665. }
  4666. _startOperation(cm);
  4667. try {
  4668. return f();
  4669. } finally {
  4670. _endOperation(cm);
  4671. }
  4672. }
  4673. // Wraps a function in an operation. Returns the wrapped function.
  4674. function operation(cm, f) {
  4675. return function () {
  4676. if (cm.curOp) {
  4677. return f.apply(cm, arguments);
  4678. }
  4679. _startOperation(cm);
  4680. try {
  4681. return f.apply(cm, arguments);
  4682. } finally {
  4683. _endOperation(cm);
  4684. }
  4685. };
  4686. }
  4687. // Used to add methods to src and docs instances, wrapping them in
  4688. // operations.
  4689. function methodOp(f) {
  4690. return function () {
  4691. if (this.curOp) {
  4692. return f.apply(this, arguments);
  4693. }
  4694. _startOperation(this);
  4695. try {
  4696. return f.apply(this, arguments);
  4697. } finally {
  4698. _endOperation(this);
  4699. }
  4700. };
  4701. }
  4702. function docMethodOp(f) {
  4703. return function () {
  4704. var cm = this.cm;
  4705. if (!cm || cm.curOp) {
  4706. return f.apply(this, arguments);
  4707. }
  4708. _startOperation(cm);
  4709. try {
  4710. return f.apply(this, arguments);
  4711. } finally {
  4712. _endOperation(cm);
  4713. }
  4714. };
  4715. }
  4716. // HIGHLIGHT WORKER
  4717. function startWorker(cm, time) {
  4718. if (cm.doc.highlightFrontier < cm.display.viewTo) {
  4719. cm.state.highlight.set(time, bind(highlightWorker, cm));
  4720. }
  4721. }
  4722. function highlightWorker(cm) {
  4723. var doc = cm.doc;
  4724. if (doc.highlightFrontier >= cm.display.viewTo) {
  4725. return;
  4726. }
  4727. var end = +new Date() + cm.options.workTime;
  4728. var context = getContextBefore(cm, doc.highlightFrontier);
  4729. var changedLines = [];
  4730. doc.iter(context.line, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) {
  4731. if (context.line >= cm.display.viewFrom) {
  4732. // Visible
  4733. var oldStyles = line.styles;
  4734. var resetState = line.text.length > cm.options.maxHighlightLength ? copyState(doc.mode, context.state) : null;
  4735. var highlighted = highlightLine(cm, line, context, true);
  4736. if (resetState) {
  4737. context.state = resetState;
  4738. }
  4739. line.styles = highlighted.styles;
  4740. var oldCls = line.styleClasses,
  4741. newCls = highlighted.classes;
  4742. if (newCls) {
  4743. line.styleClasses = newCls;
  4744. } else if (oldCls) {
  4745. line.styleClasses = null;
  4746. }
  4747. var ischange = !oldStyles || oldStyles.length != line.styles.length || oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
  4748. for (var i = 0; !ischange && i < oldStyles.length; ++i) {
  4749. ischange = oldStyles[i] != line.styles[i];
  4750. }
  4751. if (ischange) {
  4752. changedLines.push(context.line);
  4753. }
  4754. line.stateAfter = context.save();
  4755. context.nextLine();
  4756. } else {
  4757. if (line.text.length <= cm.options.maxHighlightLength) {
  4758. processLine(cm, line.text, context);
  4759. }
  4760. line.stateAfter = context.line % 5 == 0 ? context.save() : null;
  4761. context.nextLine();
  4762. }
  4763. if (+new Date() > end) {
  4764. startWorker(cm, cm.options.workDelay);
  4765. return true;
  4766. }
  4767. });
  4768. doc.highlightFrontier = context.line;
  4769. doc.modeFrontier = Math.max(doc.modeFrontier, context.line);
  4770. if (changedLines.length) {
  4771. runInOp(cm, function () {
  4772. for (var i = 0; i < changedLines.length; i++) {
  4773. regLineChange(cm, changedLines[i], "text");
  4774. }
  4775. });
  4776. }
  4777. }
  4778. // DISPLAY DRAWING
  4779. var DisplayUpdate = function DisplayUpdate(cm, viewport, force) {
  4780. var display = cm.display;
  4781. this.viewport = viewport;
  4782. // Store some values that we'll need later (but don't want to force a relayout for)
  4783. this.visible = visibleLines(display, cm.doc, viewport);
  4784. this.editorIsHidden = !display.wrapper.offsetWidth;
  4785. this.wrapperHeight = display.wrapper.clientHeight;
  4786. this.wrapperWidth = display.wrapper.clientWidth;
  4787. this.oldDisplayWidth = displayWidth(cm);
  4788. this.force = force;
  4789. this.dims = getDimensions(cm);
  4790. this.events = [];
  4791. };
  4792. DisplayUpdate.prototype.signal = function (emitter, type) {
  4793. if (hasHandler(emitter, type)) {
  4794. this.events.push(arguments);
  4795. }
  4796. };
  4797. DisplayUpdate.prototype.finish = function () {
  4798. var this$1 = this;
  4799. for (var i = 0; i < this.events.length; i++) {
  4800. signal.apply(null, this$1.events[i]);
  4801. }
  4802. };
  4803. function maybeClipScrollbars(cm) {
  4804. var display = cm.display;
  4805. if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
  4806. display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
  4807. display.heightForcer.style.height = scrollGap(cm) + "px";
  4808. display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
  4809. display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
  4810. display.scrollbarsClipped = true;
  4811. }
  4812. }
  4813. function selectionSnapshot(cm) {
  4814. if (cm.hasFocus()) {
  4815. return null;
  4816. }
  4817. var active = activeElt();
  4818. if (!active || !contains(cm.display.lineDiv, active)) {
  4819. return null;
  4820. }
  4821. var result = { activeElt: active };
  4822. if (window.getSelection) {
  4823. var sel = window.getSelection();
  4824. if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) {
  4825. result.anchorNode = sel.anchorNode;
  4826. result.anchorOffset = sel.anchorOffset;
  4827. result.focusNode = sel.focusNode;
  4828. result.focusOffset = sel.focusOffset;
  4829. }
  4830. }
  4831. return result;
  4832. }
  4833. function restoreSelection(snapshot) {
  4834. if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) {
  4835. return;
  4836. }
  4837. snapshot.activeElt.focus();
  4838. if (snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
  4839. var sel = window.getSelection(),
  4840. range$$1 = document.createRange();
  4841. range$$1.setEnd(snapshot.anchorNode, snapshot.anchorOffset);
  4842. range$$1.collapse(false);
  4843. sel.removeAllRanges();
  4844. sel.addRange(range$$1);
  4845. sel.extend(snapshot.focusNode, snapshot.focusOffset);
  4846. }
  4847. }
  4848. // Does the actual updating of the line display. Bails out
  4849. // (returning false) when there is nothing to be done and forced is
  4850. // false.
  4851. function updateDisplayIfNeeded(cm, update) {
  4852. var display = cm.display,
  4853. doc = cm.doc;
  4854. if (update.editorIsHidden) {
  4855. resetView(cm);
  4856. return false;
  4857. }
  4858. // Bail out if the visible area is already rendered and nothing changed.
  4859. if (!update.force && update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo && (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) && display.renderedView == display.view && countDirtyView(cm) == 0) {
  4860. return false;
  4861. }
  4862. if (maybeUpdateLineNumberWidth(cm)) {
  4863. resetView(cm);
  4864. update.dims = getDimensions(cm);
  4865. }
  4866. // Compute a suitable new viewport (from & to)
  4867. var end = doc.first + doc.size;
  4868. var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
  4869. var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
  4870. if (display.viewFrom < from && from - display.viewFrom < 20) {
  4871. from = Math.max(doc.first, display.viewFrom);
  4872. }
  4873. if (display.viewTo > to && display.viewTo - to < 20) {
  4874. to = Math.min(end, display.viewTo);
  4875. }
  4876. if (sawCollapsedSpans) {
  4877. from = visualLineNo(cm.doc, from);
  4878. to = visualLineEndNo(cm.doc, to);
  4879. }
  4880. var different = from != display.viewFrom || to != display.viewTo || display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
  4881. adjustView(cm, from, to);
  4882. display.viewOffset = _heightAtLine(getLine(cm.doc, display.viewFrom));
  4883. // Position the mover div to align with the current scroll position
  4884. cm.display.mover.style.top = display.viewOffset + "px";
  4885. var toUpdate = countDirtyView(cm);
  4886. if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view && (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo)) {
  4887. return false;
  4888. }
  4889. // For big changes, we hide the enclosing element during the
  4890. // update, since that speeds up the operations on most browsers.
  4891. var selSnapshot = selectionSnapshot(cm);
  4892. if (toUpdate > 4) {
  4893. display.lineDiv.style.display = "none";
  4894. }
  4895. patchDisplay(cm, display.updateLineNumbers, update.dims);
  4896. if (toUpdate > 4) {
  4897. display.lineDiv.style.display = "";
  4898. }
  4899. display.renderedView = display.view;
  4900. // There might have been a widget with a focused element that got
  4901. // hidden or updated, if so re-focus it.
  4902. restoreSelection(selSnapshot);
  4903. // Prevent selection and cursors from interfering with the scroll
  4904. // width and height.
  4905. removeChildren(display.cursorDiv);
  4906. removeChildren(display.selectionDiv);
  4907. display.gutters.style.height = display.sizer.style.minHeight = 0;
  4908. if (different) {
  4909. display.lastWrapHeight = update.wrapperHeight;
  4910. display.lastWrapWidth = update.wrapperWidth;
  4911. startWorker(cm, 400);
  4912. }
  4913. display.updateLineNumbers = null;
  4914. return true;
  4915. }
  4916. function postUpdateDisplay(cm, update) {
  4917. var viewport = update.viewport;
  4918. for (var first = true;; first = false) {
  4919. if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
  4920. // Clip forced viewport to actual scrollable area.
  4921. if (viewport && viewport.top != null) {
  4922. viewport = { top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top) };
  4923. }
  4924. // Updated line heights might result in the drawn area not
  4925. // actually covering the viewport. Keep looping until it does.
  4926. update.visible = visibleLines(cm.display, cm.doc, viewport);
  4927. if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo) {
  4928. break;
  4929. }
  4930. }
  4931. if (!updateDisplayIfNeeded(cm, update)) {
  4932. break;
  4933. }
  4934. updateHeightsInViewport(cm);
  4935. var barMeasure = measureForScrollbars(cm);
  4936. updateSelection(cm);
  4937. updateScrollbars(cm, barMeasure);
  4938. setDocumentHeight(cm, barMeasure);
  4939. update.force = false;
  4940. }
  4941. update.signal(cm, "update", cm);
  4942. if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
  4943. update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
  4944. cm.display.reportedViewFrom = cm.display.viewFrom;
  4945. cm.display.reportedViewTo = cm.display.viewTo;
  4946. }
  4947. }
  4948. function updateDisplaySimple(cm, viewport) {
  4949. var update = new DisplayUpdate(cm, viewport);
  4950. if (updateDisplayIfNeeded(cm, update)) {
  4951. updateHeightsInViewport(cm);
  4952. postUpdateDisplay(cm, update);
  4953. var barMeasure = measureForScrollbars(cm);
  4954. updateSelection(cm);
  4955. updateScrollbars(cm, barMeasure);
  4956. setDocumentHeight(cm, barMeasure);
  4957. update.finish();
  4958. }
  4959. }
  4960. // Sync the actual display DOM structure with display.view, removing
  4961. // nodes for lines that are no longer in view, and creating the ones
  4962. // that are not there yet, and updating the ones that are out of
  4963. // date.
  4964. function patchDisplay(cm, updateNumbersFrom, dims) {
  4965. var display = cm.display,
  4966. lineNumbers = cm.options.lineNumbers;
  4967. var container = display.lineDiv,
  4968. cur = container.firstChild;
  4969. function rm(node) {
  4970. var next = node.nextSibling;
  4971. // Works around a throw-scroll bug in OS X Webkit
  4972. if (webkit && mac && cm.display.currentWheelTarget == node) {
  4973. node.style.display = "none";
  4974. } else {
  4975. node.parentNode.removeChild(node);
  4976. }
  4977. return next;
  4978. }
  4979. var view = display.view,
  4980. lineN = display.viewFrom;
  4981. // Loop over the elements in the view, syncing cur (the DOM nodes
  4982. // in display.lineDiv) with the view as we go.
  4983. for (var i = 0; i < view.length; i++) {
  4984. var lineView = view[i];
  4985. if (lineView.hidden) ;else if (!lineView.node || lineView.node.parentNode != container) {
  4986. // Not drawn yet
  4987. var node = buildLineElement(cm, lineView, lineN, dims);
  4988. container.insertBefore(node, cur);
  4989. } else {
  4990. // Already drawn
  4991. while (cur != lineView.node) {
  4992. cur = rm(cur);
  4993. }
  4994. var updateNumber = lineNumbers && updateNumbersFrom != null && updateNumbersFrom <= lineN && lineView.lineNumber;
  4995. if (lineView.changes) {
  4996. if (indexOf(lineView.changes, "gutter") > -1) {
  4997. updateNumber = false;
  4998. }
  4999. updateLineForChanges(cm, lineView, lineN, dims);
  5000. }
  5001. if (updateNumber) {
  5002. removeChildren(lineView.lineNumber);
  5003. lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
  5004. }
  5005. cur = lineView.node.nextSibling;
  5006. }
  5007. lineN += lineView.size;
  5008. }
  5009. while (cur) {
  5010. cur = rm(cur);
  5011. }
  5012. }
  5013. function updateGutterSpace(display) {
  5014. var width = display.gutters.offsetWidth;
  5015. display.sizer.style.marginLeft = width + "px";
  5016. }
  5017. function setDocumentHeight(cm, measure) {
  5018. cm.display.sizer.style.minHeight = measure.docHeight + "px";
  5019. cm.display.heightForcer.style.top = measure.docHeight + "px";
  5020. cm.display.gutters.style.height = measure.docHeight + cm.display.barHeight + scrollGap(cm) + "px";
  5021. }
  5022. // Re-align line numbers and gutter marks to compensate for
  5023. // horizontal scrolling.
  5024. function alignHorizontally(cm) {
  5025. var display = cm.display,
  5026. view = display.view;
  5027. if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) {
  5028. return;
  5029. }
  5030. var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
  5031. var gutterW = display.gutters.offsetWidth,
  5032. left = comp + "px";
  5033. for (var i = 0; i < view.length; i++) {
  5034. if (!view[i].hidden) {
  5035. if (cm.options.fixedGutter) {
  5036. if (view[i].gutter) {
  5037. view[i].gutter.style.left = left;
  5038. }
  5039. if (view[i].gutterBackground) {
  5040. view[i].gutterBackground.style.left = left;
  5041. }
  5042. }
  5043. var align = view[i].alignable;
  5044. if (align) {
  5045. for (var j = 0; j < align.length; j++) {
  5046. align[j].style.left = left;
  5047. }
  5048. }
  5049. }
  5050. }
  5051. if (cm.options.fixedGutter) {
  5052. display.gutters.style.left = comp + gutterW + "px";
  5053. }
  5054. }
  5055. // Used to ensure that the line number gutter is still the right
  5056. // size for the current document size. Returns true when an update
  5057. // is needed.
  5058. function maybeUpdateLineNumberWidth(cm) {
  5059. if (!cm.options.lineNumbers) {
  5060. return false;
  5061. }
  5062. var doc = cm.doc,
  5063. last = lineNumberFor(cm.options, doc.first + doc.size - 1),
  5064. display = cm.display;
  5065. if (last.length != display.lineNumChars) {
  5066. var test = display.measure.appendChild(elt("div", [elt("div", last)], "CodeMirror-linenumber CodeMirror-gutter-elt"));
  5067. var innerW = test.firstChild.offsetWidth,
  5068. padding = test.offsetWidth - innerW;
  5069. display.lineGutter.style.width = "";
  5070. display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
  5071. display.lineNumWidth = display.lineNumInnerWidth + padding;
  5072. display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
  5073. display.lineGutter.style.width = display.lineNumWidth + "px";
  5074. updateGutterSpace(cm.display);
  5075. return true;
  5076. }
  5077. return false;
  5078. }
  5079. function getGutters(gutters, lineNumbers) {
  5080. var result = [],
  5081. sawLineNumbers = false;
  5082. for (var i = 0; i < gutters.length; i++) {
  5083. var name = gutters[i],
  5084. style = null;
  5085. if (typeof name != "string") {
  5086. style = name.style;
  5087. name = name.className;
  5088. }
  5089. if (name == "CodeMirror-linenumbers") {
  5090. if (!lineNumbers) {
  5091. continue;
  5092. } else {
  5093. sawLineNumbers = true;
  5094. }
  5095. }
  5096. result.push({ className: name, style: style });
  5097. }
  5098. if (lineNumbers && !sawLineNumbers) {
  5099. result.push({ className: "CodeMirror-linenumbers", style: null });
  5100. }
  5101. return result;
  5102. }
  5103. // Rebuild the gutter elements, ensure the margin to the left of the
  5104. // code matches their width.
  5105. function renderGutters(display) {
  5106. var gutters = display.gutters,
  5107. specs = display.gutterSpecs;
  5108. removeChildren(gutters);
  5109. display.lineGutter = null;
  5110. for (var i = 0; i < specs.length; ++i) {
  5111. var ref = specs[i];
  5112. var className = ref.className;
  5113. var style = ref.style;
  5114. var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + className));
  5115. if (style) {
  5116. gElt.style.cssText = style;
  5117. }
  5118. if (className == "CodeMirror-linenumbers") {
  5119. display.lineGutter = gElt;
  5120. gElt.style.width = (display.lineNumWidth || 1) + "px";
  5121. }
  5122. }
  5123. gutters.style.display = specs.length ? "" : "none";
  5124. updateGutterSpace(display);
  5125. }
  5126. function updateGutters(cm) {
  5127. renderGutters(cm.display);
  5128. regChange(cm);
  5129. alignHorizontally(cm);
  5130. }
  5131. // The display handles the DOM integration, both for input reading
  5132. // and content drawing. It holds references to DOM nodes and
  5133. // display-related state.
  5134. function Display(place, doc, input, options) {
  5135. var d = this;
  5136. this.input = input;
  5137. // Covers bottom-right square when both scrollbars are present.
  5138. d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
  5139. d.scrollbarFiller.setAttribute("cm-not-content", "true");
  5140. // Covers bottom of gutter when coverGutterNextToScrollbar is on
  5141. // and h scrollbar is present.
  5142. d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
  5143. d.gutterFiller.setAttribute("cm-not-content", "true");
  5144. // Will contain the actual code, positioned to cover the viewport.
  5145. d.lineDiv = eltP("div", null, "CodeMirror-code");
  5146. // Elements are added to these to represent selection and cursors.
  5147. d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
  5148. d.cursorDiv = elt("div", null, "CodeMirror-cursors");
  5149. // A visibility: hidden element used to find the size of things.
  5150. d.measure = elt("div", null, "CodeMirror-measure");
  5151. // When lines outside of the viewport are measured, they are drawn in this.
  5152. d.lineMeasure = elt("div", null, "CodeMirror-measure");
  5153. // Wraps everything that needs to exist inside the vertically-padded coordinate system
  5154. d.lineSpace = eltP("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv], null, "position: relative; outline: none");
  5155. var lines = eltP("div", [d.lineSpace], "CodeMirror-lines");
  5156. // Moved around its parent to cover visible view.
  5157. d.mover = elt("div", [lines], null, "position: relative");
  5158. // Set to the height of the document, allowing scrolling.
  5159. d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
  5160. d.sizerWidth = null;
  5161. // Behavior of elts with overflow: auto and padding is
  5162. // inconsistent across browsers. This is used to ensure the
  5163. // scrollable area is big enough.
  5164. d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
  5165. // Will contain the gutters, if any.
  5166. d.gutters = elt("div", null, "CodeMirror-gutters");
  5167. d.lineGutter = null;
  5168. // Actual scrollable element.
  5169. d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
  5170. d.scroller.setAttribute("tabIndex", "-1");
  5171. // The element in which the src lives.
  5172. d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
  5173. // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
  5174. if (ie && ie_version < 8) {
  5175. d.gutters.style.zIndex = -1;
  5176. d.scroller.style.paddingRight = 0;
  5177. }
  5178. if (!webkit && !(gecko && mobile)) {
  5179. d.scroller.draggable = true;
  5180. }
  5181. if (place) {
  5182. if (place.appendChild) {
  5183. place.appendChild(d.wrapper);
  5184. } else {
  5185. place(d.wrapper);
  5186. }
  5187. }
  5188. // Current rendered range (may be bigger than the view window).
  5189. d.viewFrom = d.viewTo = doc.first;
  5190. d.reportedViewFrom = d.reportedViewTo = doc.first;
  5191. // Information about the rendered lines.
  5192. d.view = [];
  5193. d.renderedView = null;
  5194. // Holds info about a single rendered line when it was rendered
  5195. // for measurement, while not in view.
  5196. d.externalMeasured = null;
  5197. // Empty space (in pixels) above the view
  5198. d.viewOffset = 0;
  5199. d.lastWrapHeight = d.lastWrapWidth = 0;
  5200. d.updateLineNumbers = null;
  5201. d.nativeBarWidth = d.barHeight = d.barWidth = 0;
  5202. d.scrollbarsClipped = false;
  5203. // Used to only resize the line number gutter when necessary (when
  5204. // the amount of lines crosses a boundary that makes its width change)
  5205. d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
  5206. // Set to true when a non-horizontal-scrolling line widget is
  5207. // added. As an optimization, line widget aligning is skipped when
  5208. // this is false.
  5209. d.alignWidgets = false;
  5210. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
  5211. // Tracks the maximum line length so that the horizontal scrollbar
  5212. // can be kept static when scrolling.
  5213. d.maxLine = null;
  5214. d.maxLineLength = 0;
  5215. d.maxLineChanged = false;
  5216. // Used for measuring wheel scrolling granularity
  5217. d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
  5218. // True when shift is held down.
  5219. d.shift = false;
  5220. // Used to track whether anything happened since the context menu
  5221. // was opened.
  5222. d.selForContextMenu = null;
  5223. d.activeTouch = null;
  5224. d.gutterSpecs = getGutters(options.gutters, options.lineNumbers);
  5225. renderGutters(d);
  5226. input.init(d);
  5227. }
  5228. // Since the delta values reported on mouse wheel events are
  5229. // unstandardized between browsers and even browser versions, and
  5230. // generally horribly unpredictable, this code starts by measuring
  5231. // the scroll effect that the first few mouse wheel events have,
  5232. // and, from that, detects the way it can convert deltas to pixel
  5233. // offsets afterwards.
  5234. //
  5235. // The reason we want to know the amount a wheel event will scroll
  5236. // is that it gives us a chance to update the display before the
  5237. // actual scrolling happens, reducing flickering.
  5238. var wheelSamples = 0,
  5239. wheelPixelsPerUnit = null;
  5240. // Fill in a browser-detected starting value on browsers where we
  5241. // know one. These don't have to be accurate -- the result of them
  5242. // being wrong would just be a slight flicker on the first wheel
  5243. // scroll (if it is large enough).
  5244. if (ie) {
  5245. wheelPixelsPerUnit = -.53;
  5246. } else if (gecko) {
  5247. wheelPixelsPerUnit = 15;
  5248. } else if (chrome) {
  5249. wheelPixelsPerUnit = -.7;
  5250. } else if (safari) {
  5251. wheelPixelsPerUnit = -1 / 3;
  5252. }
  5253. function wheelEventDelta(e) {
  5254. var dx = e.wheelDeltaX,
  5255. dy = e.wheelDeltaY;
  5256. if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) {
  5257. dx = e.detail;
  5258. }
  5259. if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) {
  5260. dy = e.detail;
  5261. } else if (dy == null) {
  5262. dy = e.wheelDelta;
  5263. }
  5264. return { x: dx, y: dy };
  5265. }
  5266. function wheelEventPixels(e) {
  5267. var delta = wheelEventDelta(e);
  5268. delta.x *= wheelPixelsPerUnit;
  5269. delta.y *= wheelPixelsPerUnit;
  5270. return delta;
  5271. }
  5272. function onScrollWheel(cm, e) {
  5273. var delta = wheelEventDelta(e),
  5274. dx = delta.x,
  5275. dy = delta.y;
  5276. var display = cm.display,
  5277. scroll = display.scroller;
  5278. // Quit if there's nothing to scroll here
  5279. var canScrollX = scroll.scrollWidth > scroll.clientWidth;
  5280. var canScrollY = scroll.scrollHeight > scroll.clientHeight;
  5281. if (!(dx && canScrollX || dy && canScrollY)) {
  5282. return;
  5283. }
  5284. // Webkit browsers on OS X abort momentum scrolls when the target
  5285. // of the scroll event is removed from the scrollable element.
  5286. // This hack (see related code in patchDisplay) makes sure the
  5287. // element is kept around.
  5288. if (dy && mac && webkit) {
  5289. outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
  5290. for (var i = 0; i < view.length; i++) {
  5291. if (view[i].node == cur) {
  5292. cm.display.currentWheelTarget = cur;
  5293. break outer;
  5294. }
  5295. }
  5296. }
  5297. }
  5298. // On some browsers, horizontal scrolling will cause redraws to
  5299. // happen before the gutter has been realigned, causing it to
  5300. // wriggle around in a most unseemly way. When we have an
  5301. // estimated pixels/delta value, we just handle horizontal
  5302. // scrolling entirely here. It'll be slightly off from native, but
  5303. // better than glitching out.
  5304. if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
  5305. if (dy && canScrollY) {
  5306. updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * wheelPixelsPerUnit));
  5307. }
  5308. setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * wheelPixelsPerUnit));
  5309. // Only prevent default scrolling if vertical scrolling is
  5310. // actually possible. Otherwise, it causes vertical scroll
  5311. // jitter on OSX trackpads when deltaX is small and deltaY
  5312. // is large (issue #3579)
  5313. if (!dy || dy && canScrollY) {
  5314. e_preventDefault(e);
  5315. }
  5316. display.wheelStartX = null; // Abort measurement, if in progress
  5317. return;
  5318. }
  5319. // 'Project' the visible viewport to cover the area that is being
  5320. // scrolled into view (if we know enough to estimate it).
  5321. if (dy && wheelPixelsPerUnit != null) {
  5322. var pixels = dy * wheelPixelsPerUnit;
  5323. var top = cm.doc.scrollTop,
  5324. bot = top + display.wrapper.clientHeight;
  5325. if (pixels < 0) {
  5326. top = Math.max(0, top + pixels - 50);
  5327. } else {
  5328. bot = Math.min(cm.doc.height, bot + pixels + 50);
  5329. }
  5330. updateDisplaySimple(cm, { top: top, bottom: bot });
  5331. }
  5332. if (wheelSamples < 20) {
  5333. if (display.wheelStartX == null) {
  5334. display.wheelStartX = scroll.scrollLeft;
  5335. display.wheelStartY = scroll.scrollTop;
  5336. display.wheelDX = dx;
  5337. display.wheelDY = dy;
  5338. setTimeout(function () {
  5339. if (display.wheelStartX == null) {
  5340. return;
  5341. }
  5342. var movedX = scroll.scrollLeft - display.wheelStartX;
  5343. var movedY = scroll.scrollTop - display.wheelStartY;
  5344. var sample = movedY && display.wheelDY && movedY / display.wheelDY || movedX && display.wheelDX && movedX / display.wheelDX;
  5345. display.wheelStartX = display.wheelStartY = null;
  5346. if (!sample) {
  5347. return;
  5348. }
  5349. wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
  5350. ++wheelSamples;
  5351. }, 200);
  5352. } else {
  5353. display.wheelDX += dx;
  5354. display.wheelDY += dy;
  5355. }
  5356. }
  5357. }
  5358. // Selection objects are immutable. A new one is created every time
  5359. // the selection changes. A selection is one or more non-overlapping
  5360. // (and non-touching) ranges, sorted, and an integer that indicates
  5361. // which one is the primary selection (the one that's scrolled into
  5362. // view, that getCursor returns, etc).
  5363. var Selection = function Selection(ranges, primIndex) {
  5364. this.ranges = ranges;
  5365. this.primIndex = primIndex;
  5366. };
  5367. Selection.prototype.primary = function () {
  5368. return this.ranges[this.primIndex];
  5369. };
  5370. Selection.prototype.equals = function (other) {
  5371. var this$1 = this;
  5372. if (other == this) {
  5373. return true;
  5374. }
  5375. if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) {
  5376. return false;
  5377. }
  5378. for (var i = 0; i < this.ranges.length; i++) {
  5379. var here = this$1.ranges[i],
  5380. there = other.ranges[i];
  5381. if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) {
  5382. return false;
  5383. }
  5384. }
  5385. return true;
  5386. };
  5387. Selection.prototype.deepCopy = function () {
  5388. var this$1 = this;
  5389. var out = [];
  5390. for (var i = 0; i < this.ranges.length; i++) {
  5391. out[i] = new Range(copyPos(this$1.ranges[i].anchor), copyPos(this$1.ranges[i].head));
  5392. }
  5393. return new Selection(out, this.primIndex);
  5394. };
  5395. Selection.prototype.somethingSelected = function () {
  5396. var this$1 = this;
  5397. for (var i = 0; i < this.ranges.length; i++) {
  5398. if (!this$1.ranges[i].empty()) {
  5399. return true;
  5400. }
  5401. }
  5402. return false;
  5403. };
  5404. Selection.prototype.contains = function (pos, end) {
  5405. var this$1 = this;
  5406. if (!end) {
  5407. end = pos;
  5408. }
  5409. for (var i = 0; i < this.ranges.length; i++) {
  5410. var range = this$1.ranges[i];
  5411. if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0) {
  5412. return i;
  5413. }
  5414. }
  5415. return -1;
  5416. };
  5417. var Range = function Range(anchor, head) {
  5418. this.anchor = anchor;
  5419. this.head = head;
  5420. };
  5421. Range.prototype.from = function () {
  5422. return minPos(this.anchor, this.head);
  5423. };
  5424. Range.prototype.to = function () {
  5425. return maxPos(this.anchor, this.head);
  5426. };
  5427. Range.prototype.empty = function () {
  5428. return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch;
  5429. };
  5430. // Take an unsorted, potentially overlapping set of ranges, and
  5431. // build a selection out of it. 'Consumes' ranges array (modifying
  5432. // it).
  5433. function normalizeSelection(cm, ranges, primIndex) {
  5434. var mayTouch = cm && cm.options.selectionsMayTouch;
  5435. var prim = ranges[primIndex];
  5436. ranges.sort(function (a, b) {
  5437. return cmp(a.from(), b.from());
  5438. });
  5439. primIndex = indexOf(ranges, prim);
  5440. for (var i = 1; i < ranges.length; i++) {
  5441. var cur = ranges[i],
  5442. prev = ranges[i - 1];
  5443. var diff = cmp(prev.to(), cur.from());
  5444. if (mayTouch && !cur.empty() ? diff > 0 : diff >= 0) {
  5445. var from = minPos(prev.from(), cur.from()),
  5446. to = maxPos(prev.to(), cur.to());
  5447. var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
  5448. if (i <= primIndex) {
  5449. --primIndex;
  5450. }
  5451. ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
  5452. }
  5453. }
  5454. return new Selection(ranges, primIndex);
  5455. }
  5456. function simpleSelection(anchor, head) {
  5457. return new Selection([new Range(anchor, head || anchor)], 0);
  5458. }
  5459. // Compute the position of the end of a change (its 'to' property
  5460. // refers to the pre-change end).
  5461. function changeEnd(change) {
  5462. if (!change.text) {
  5463. return change.to;
  5464. }
  5465. return Pos(change.from.line + change.text.length - 1, lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0));
  5466. }
  5467. // Adjust a position to refer to the post-change position of the
  5468. // same text, or the end of the change if the change covers it.
  5469. function adjustForChange(pos, change) {
  5470. if (cmp(pos, change.from) < 0) {
  5471. return pos;
  5472. }
  5473. if (cmp(pos, change.to) <= 0) {
  5474. return changeEnd(change);
  5475. }
  5476. var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1,
  5477. ch = pos.ch;
  5478. if (pos.line == change.to.line) {
  5479. ch += changeEnd(change).ch - change.to.ch;
  5480. }
  5481. return Pos(line, ch);
  5482. }
  5483. function computeSelAfterChange(doc, change) {
  5484. var out = [];
  5485. for (var i = 0; i < doc.sel.ranges.length; i++) {
  5486. var range = doc.sel.ranges[i];
  5487. out.push(new Range(adjustForChange(range.anchor, change), adjustForChange(range.head, change)));
  5488. }
  5489. return normalizeSelection(doc.cm, out, doc.sel.primIndex);
  5490. }
  5491. function offsetPos(pos, old, nw) {
  5492. if (pos.line == old.line) {
  5493. return Pos(nw.line, pos.ch - old.ch + nw.ch);
  5494. } else {
  5495. return Pos(nw.line + (pos.line - old.line), pos.ch);
  5496. }
  5497. }
  5498. // Used by replaceSelections to allow moving the selection to the
  5499. // start or around the replaced test. Hint may be "start" or "around".
  5500. function computeReplacedSel(doc, changes, hint) {
  5501. var out = [];
  5502. var oldPrev = Pos(doc.first, 0),
  5503. newPrev = oldPrev;
  5504. for (var i = 0; i < changes.length; i++) {
  5505. var change = changes[i];
  5506. var from = offsetPos(change.from, oldPrev, newPrev);
  5507. var to = offsetPos(changeEnd(change), oldPrev, newPrev);
  5508. oldPrev = change.to;
  5509. newPrev = to;
  5510. if (hint == "around") {
  5511. var range = doc.sel.ranges[i],
  5512. inv = cmp(range.head, range.anchor) < 0;
  5513. out[i] = new Range(inv ? to : from, inv ? from : to);
  5514. } else {
  5515. out[i] = new Range(from, from);
  5516. }
  5517. }
  5518. return new Selection(out, doc.sel.primIndex);
  5519. }
  5520. // Used to get the src into a consistent state again when options change.
  5521. function loadMode(cm) {
  5522. cm.doc.mode = getMode(cm.options, cm.doc.modeOption);
  5523. resetModeState(cm);
  5524. }
  5525. function resetModeState(cm) {
  5526. cm.doc.iter(function (line) {
  5527. if (line.stateAfter) {
  5528. line.stateAfter = null;
  5529. }
  5530. if (line.styles) {
  5531. line.styles = null;
  5532. }
  5533. });
  5534. cm.doc.modeFrontier = cm.doc.highlightFrontier = cm.doc.first;
  5535. startWorker(cm, 100);
  5536. cm.state.modeGen++;
  5537. if (cm.curOp) {
  5538. regChange(cm);
  5539. }
  5540. }
  5541. // DOCUMENT DATA STRUCTURE
  5542. // By default, updates that start and end at the beginning of a line
  5543. // are treated specially, in order to make the association of line
  5544. // widgets and marker elements with the text behave more intuitive.
  5545. function isWholeLineUpdate(doc, change) {
  5546. return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" && (!doc.cm || doc.cm.options.wholeLineUpdateBefore);
  5547. }
  5548. // Perform a change on the document data structure.
  5549. function updateDoc(doc, change, markedSpans, estimateHeight$$1) {
  5550. function spansFor(n) {
  5551. return markedSpans ? markedSpans[n] : null;
  5552. }
  5553. function update(line, text, spans) {
  5554. updateLine(line, text, spans, estimateHeight$$1);
  5555. signalLater(line, "change", line, change);
  5556. }
  5557. function linesFor(start, end) {
  5558. var result = [];
  5559. for (var i = start; i < end; ++i) {
  5560. result.push(new Line(text[i], spansFor(i), estimateHeight$$1));
  5561. }
  5562. return result;
  5563. }
  5564. var from = change.from,
  5565. to = change.to,
  5566. text = change.text;
  5567. var firstLine = getLine(doc, from.line),
  5568. lastLine = getLine(doc, to.line);
  5569. var lastText = lst(text),
  5570. lastSpans = spansFor(text.length - 1),
  5571. nlines = to.line - from.line;
  5572. // Adjust the line structure
  5573. if (change.full) {
  5574. doc.insert(0, linesFor(0, text.length));
  5575. doc.remove(text.length, doc.size - text.length);
  5576. } else if (isWholeLineUpdate(doc, change)) {
  5577. // This is a whole-line replace. Treated specially to make
  5578. // sure line objects move the way they are supposed to.
  5579. var added = linesFor(0, text.length - 1);
  5580. update(lastLine, lastLine.text, lastSpans);
  5581. if (nlines) {
  5582. doc.remove(from.line, nlines);
  5583. }
  5584. if (added.length) {
  5585. doc.insert(from.line, added);
  5586. }
  5587. } else if (firstLine == lastLine) {
  5588. if (text.length == 1) {
  5589. update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
  5590. } else {
  5591. var added$1 = linesFor(1, text.length - 1);
  5592. added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight$$1));
  5593. update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
  5594. doc.insert(from.line + 1, added$1);
  5595. }
  5596. } else if (text.length == 1) {
  5597. update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
  5598. doc.remove(from.line + 1, nlines);
  5599. } else {
  5600. update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
  5601. update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
  5602. var added$2 = linesFor(1, text.length - 1);
  5603. if (nlines > 1) {
  5604. doc.remove(from.line + 1, nlines - 1);
  5605. }
  5606. doc.insert(from.line + 1, added$2);
  5607. }
  5608. signalLater(doc, "change", doc, change);
  5609. }
  5610. // Call f for all linked documents.
  5611. function linkedDocs(doc, f, sharedHistOnly) {
  5612. function propagate(doc, skip, sharedHist) {
  5613. if (doc.linked) {
  5614. for (var i = 0; i < doc.linked.length; ++i) {
  5615. var rel = doc.linked[i];
  5616. if (rel.doc == skip) {
  5617. continue;
  5618. }
  5619. var shared = sharedHist && rel.sharedHist;
  5620. if (sharedHistOnly && !shared) {
  5621. continue;
  5622. }
  5623. f(rel.doc, shared);
  5624. propagate(rel.doc, doc, shared);
  5625. }
  5626. }
  5627. }
  5628. propagate(doc, null, true);
  5629. }
  5630. // Attach a document to an src.
  5631. function attachDoc(cm, doc) {
  5632. if (doc.cm) {
  5633. throw new Error("This document is already in use.");
  5634. }
  5635. cm.doc = doc;
  5636. doc.cm = cm;
  5637. estimateLineHeights(cm);
  5638. loadMode(cm);
  5639. setDirectionClass(cm);
  5640. if (!cm.options.lineWrapping) {
  5641. findMaxLine(cm);
  5642. }
  5643. cm.options.mode = doc.modeOption;
  5644. regChange(cm);
  5645. }
  5646. function setDirectionClass(cm) {
  5647. (cm.doc.direction == "rtl" ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl");
  5648. }
  5649. function directionChanged(cm) {
  5650. runInOp(cm, function () {
  5651. setDirectionClass(cm);
  5652. regChange(cm);
  5653. });
  5654. }
  5655. function History(startGen) {
  5656. // Arrays of change events and selections. Doing something adds an
  5657. // event to done and clears undo. Undoing moves events from done
  5658. // to undone, redoing moves them in the other direction.
  5659. this.done = [];
  5660. this.undone = [];
  5661. this.undoDepth = Infinity;
  5662. // Used to track when changes can be merged into a single undo
  5663. // event
  5664. this.lastModTime = this.lastSelTime = 0;
  5665. this.lastOp = this.lastSelOp = null;
  5666. this.lastOrigin = this.lastSelOrigin = null;
  5667. // Used by the isClean() method
  5668. this.generation = this.maxGeneration = startGen || 1;
  5669. }
  5670. // Create a history change event from an updateDoc-style change
  5671. // object.
  5672. function historyChangeFromChange(doc, change) {
  5673. var histChange = { from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to) };
  5674. attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
  5675. linkedDocs(doc, function (doc) {
  5676. return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
  5677. }, true);
  5678. return histChange;
  5679. }
  5680. // Pop all selection events off the end of a history array. Stop at
  5681. // a change event.
  5682. function clearSelectionEvents(array) {
  5683. while (array.length) {
  5684. var last = lst(array);
  5685. if (last.ranges) {
  5686. array.pop();
  5687. } else {
  5688. break;
  5689. }
  5690. }
  5691. }
  5692. // Find the top change event in the history. Pop off selection
  5693. // events that are in the way.
  5694. function lastChangeEvent(hist, force) {
  5695. if (force) {
  5696. clearSelectionEvents(hist.done);
  5697. return lst(hist.done);
  5698. } else if (hist.done.length && !lst(hist.done).ranges) {
  5699. return lst(hist.done);
  5700. } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
  5701. hist.done.pop();
  5702. return lst(hist.done);
  5703. }
  5704. }
  5705. // Register a change in the history. Merges changes that are within
  5706. // a single operation, or are close together with an origin that
  5707. // allows merging (starting with "+") into a single event.
  5708. function addChangeToHistory(doc, change, selAfter, opId) {
  5709. var hist = doc.history;
  5710. hist.undone.length = 0;
  5711. var time = +new Date(),
  5712. cur;
  5713. var last;
  5714. if ((hist.lastOp == opId || hist.lastOrigin == change.origin && change.origin && (change.origin.charAt(0) == "+" && hist.lastModTime > time - (doc.cm ? doc.cm.options.historyEventDelay : 500) || change.origin.charAt(0) == "*")) && (cur = lastChangeEvent(hist, hist.lastOp == opId))) {
  5715. // Merge this change into the last event
  5716. last = lst(cur.changes);
  5717. if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
  5718. // Optimized case for simple insertion -- don't want to add
  5719. // new changesets for every character typed
  5720. last.to = changeEnd(change);
  5721. } else {
  5722. // Add new sub-event
  5723. cur.changes.push(historyChangeFromChange(doc, change));
  5724. }
  5725. } else {
  5726. // Can not be merged, start a new event.
  5727. var before = lst(hist.done);
  5728. if (!before || !before.ranges) {
  5729. pushSelectionToHistory(doc.sel, hist.done);
  5730. }
  5731. cur = {
  5732. changes: [historyChangeFromChange(doc, change)],
  5733. generation: hist.generation
  5734. };
  5735. hist.done.push(cur);
  5736. while (hist.done.length > hist.undoDepth) {
  5737. hist.done.shift();
  5738. if (!hist.done[0].ranges) {
  5739. hist.done.shift();
  5740. }
  5741. }
  5742. }
  5743. hist.done.push(selAfter);
  5744. hist.generation = ++hist.maxGeneration;
  5745. hist.lastModTime = hist.lastSelTime = time;
  5746. hist.lastOp = hist.lastSelOp = opId;
  5747. hist.lastOrigin = hist.lastSelOrigin = change.origin;
  5748. if (!last) {
  5749. signal(doc, "historyAdded");
  5750. }
  5751. }
  5752. function selectionEventCanBeMerged(doc, origin, prev, sel) {
  5753. var ch = origin.charAt(0);
  5754. return ch == "*" || ch == "+" && prev.ranges.length == sel.ranges.length && prev.somethingSelected() == sel.somethingSelected() && new Date() - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500);
  5755. }
  5756. // Called whenever the selection changes, sets the new selection as
  5757. // the pending selection in the history, and pushes the old pending
  5758. // selection into the 'done' array when it was significantly
  5759. // different (in number of selected ranges, emptiness, or time).
  5760. function addSelectionToHistory(doc, sel, opId, options) {
  5761. var hist = doc.history,
  5762. origin = options && options.origin;
  5763. // A new event is started when the previous origin does not match
  5764. // the current, or the origins don't allow matching. Origins
  5765. // starting with * are always merged, those starting with + are
  5766. // merged when similar and close together in time.
  5767. if (opId == hist.lastSelOp || origin && hist.lastSelOrigin == origin && (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))) {
  5768. hist.done[hist.done.length - 1] = sel;
  5769. } else {
  5770. pushSelectionToHistory(sel, hist.done);
  5771. }
  5772. hist.lastSelTime = +new Date();
  5773. hist.lastSelOrigin = origin;
  5774. hist.lastSelOp = opId;
  5775. if (options && options.clearRedo !== false) {
  5776. clearSelectionEvents(hist.undone);
  5777. }
  5778. }
  5779. function pushSelectionToHistory(sel, dest) {
  5780. var top = lst(dest);
  5781. if (!(top && top.ranges && top.equals(sel))) {
  5782. dest.push(sel);
  5783. }
  5784. }
  5785. // Used to store index span information in the history.
  5786. function attachLocalSpans(doc, change, from, to) {
  5787. var existing = change["spans_" + doc.id],
  5788. n = 0;
  5789. doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) {
  5790. if (line.markedSpans) {
  5791. (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans;
  5792. }
  5793. ++n;
  5794. });
  5795. }
  5796. // When un/re-doing restores text containing index spans, those
  5797. // that have been explicitly cleared should not be restored.
  5798. function removeClearedSpans(spans) {
  5799. if (!spans) {
  5800. return null;
  5801. }
  5802. var out;
  5803. for (var i = 0; i < spans.length; ++i) {
  5804. if (spans[i].marker.explicitlyCleared) {
  5805. if (!out) {
  5806. out = spans.slice(0, i);
  5807. }
  5808. } else if (out) {
  5809. out.push(spans[i]);
  5810. }
  5811. }
  5812. return !out ? spans : out.length ? out : null;
  5813. }
  5814. // Retrieve and filter the old index spans stored in a change event.
  5815. function getOldSpans(doc, change) {
  5816. var found = change["spans_" + doc.id];
  5817. if (!found) {
  5818. return null;
  5819. }
  5820. var nw = [];
  5821. for (var i = 0; i < change.text.length; ++i) {
  5822. nw.push(removeClearedSpans(found[i]));
  5823. }
  5824. return nw;
  5825. }
  5826. // Used for un/re-doing changes from the history. Combines the
  5827. // result of computing the existing spans with the set of spans that
  5828. // existed in the history (so that deleting around a span and then
  5829. // undoing brings back the span).
  5830. function mergeOldSpans(doc, change) {
  5831. var old = getOldSpans(doc, change);
  5832. var stretched = stretchSpansOverChange(doc, change);
  5833. if (!old) {
  5834. return stretched;
  5835. }
  5836. if (!stretched) {
  5837. return old;
  5838. }
  5839. for (var i = 0; i < old.length; ++i) {
  5840. var oldCur = old[i],
  5841. stretchCur = stretched[i];
  5842. if (oldCur && stretchCur) {
  5843. spans: for (var j = 0; j < stretchCur.length; ++j) {
  5844. var span = stretchCur[j];
  5845. for (var k = 0; k < oldCur.length; ++k) {
  5846. if (oldCur[k].marker == span.marker) {
  5847. continue spans;
  5848. }
  5849. }
  5850. oldCur.push(span);
  5851. }
  5852. } else if (stretchCur) {
  5853. old[i] = stretchCur;
  5854. }
  5855. }
  5856. return old;
  5857. }
  5858. // Used both to provide a JSON-safe object in .getHistory, and, when
  5859. // detaching a document, to split the history in two
  5860. function copyHistoryArray(events, newGroup, instantiateSel) {
  5861. var copy = [];
  5862. for (var i = 0; i < events.length; ++i) {
  5863. var event = events[i];
  5864. if (event.ranges) {
  5865. copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
  5866. continue;
  5867. }
  5868. var changes = event.changes,
  5869. newChanges = [];
  5870. copy.push({ changes: newChanges });
  5871. for (var j = 0; j < changes.length; ++j) {
  5872. var change = changes[j],
  5873. m = void 0;
  5874. newChanges.push({ from: change.from, to: change.to, text: change.text });
  5875. if (newGroup) {
  5876. for (var prop in change) {
  5877. if (m = prop.match(/^spans_(\d+)$/)) {
  5878. if (indexOf(newGroup, Number(m[1])) > -1) {
  5879. lst(newChanges)[prop] = change[prop];
  5880. delete change[prop];
  5881. }
  5882. }
  5883. }
  5884. }
  5885. }
  5886. }
  5887. return copy;
  5888. }
  5889. // The 'scroll' parameter given to many of these indicated whether
  5890. // the new cursor position should be scrolled into view after
  5891. // modifying the selection.
  5892. // If shift is held or the extend flag is set, extends a range to
  5893. // include a given position (and optionally a second position).
  5894. // Otherwise, simply returns the range between the given positions.
  5895. // Used for cursor motion and such.
  5896. function extendRange(range, head, other, extend) {
  5897. if (extend) {
  5898. var anchor = range.anchor;
  5899. if (other) {
  5900. var posBefore = cmp(head, anchor) < 0;
  5901. if (posBefore != cmp(other, anchor) < 0) {
  5902. anchor = head;
  5903. head = other;
  5904. } else if (posBefore != cmp(head, other) < 0) {
  5905. head = other;
  5906. }
  5907. }
  5908. return new Range(anchor, head);
  5909. } else {
  5910. return new Range(other || head, head);
  5911. }
  5912. }
  5913. // Extend the primary selection range, discard the rest.
  5914. function extendSelection(doc, head, other, options, extend) {
  5915. if (extend == null) {
  5916. extend = doc.cm && (doc.cm.display.shift || doc.extend);
  5917. }
  5918. setSelection(doc, new Selection([extendRange(doc.sel.primary(), head, other, extend)], 0), options);
  5919. }
  5920. // Extend all selections (pos is an array of selections with length
  5921. // equal the number of selections)
  5922. function extendSelections(doc, heads, options) {
  5923. var out = [];
  5924. var extend = doc.cm && (doc.cm.display.shift || doc.extend);
  5925. for (var i = 0; i < doc.sel.ranges.length; i++) {
  5926. out[i] = extendRange(doc.sel.ranges[i], heads[i], null, extend);
  5927. }
  5928. var newSel = normalizeSelection(doc.cm, out, doc.sel.primIndex);
  5929. setSelection(doc, newSel, options);
  5930. }
  5931. // Updates a single range in the selection.
  5932. function replaceOneSelection(doc, i, range, options) {
  5933. var ranges = doc.sel.ranges.slice(0);
  5934. ranges[i] = range;
  5935. setSelection(doc, normalizeSelection(doc.cm, ranges, doc.sel.primIndex), options);
  5936. }
  5937. // Reset the selection to a single range.
  5938. function setSimpleSelection(doc, anchor, head, options) {
  5939. setSelection(doc, simpleSelection(anchor, head), options);
  5940. }
  5941. // Give beforeSelectionChange handlers a change to influence a
  5942. // selection update.
  5943. function filterSelectionChange(doc, sel, options) {
  5944. var obj = {
  5945. ranges: sel.ranges,
  5946. update: function update(ranges) {
  5947. var this$1 = this;
  5948. this.ranges = [];
  5949. for (var i = 0; i < ranges.length; i++) {
  5950. this$1.ranges[i] = new Range(_clipPos(doc, ranges[i].anchor), _clipPos(doc, ranges[i].head));
  5951. }
  5952. },
  5953. origin: options && options.origin
  5954. };
  5955. signal(doc, "beforeSelectionChange", doc, obj);
  5956. if (doc.cm) {
  5957. signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
  5958. }
  5959. if (obj.ranges != sel.ranges) {
  5960. return normalizeSelection(doc.cm, obj.ranges, obj.ranges.length - 1);
  5961. } else {
  5962. return sel;
  5963. }
  5964. }
  5965. function setSelectionReplaceHistory(doc, sel, options) {
  5966. var done = doc.history.done,
  5967. last = lst(done);
  5968. if (last && last.ranges) {
  5969. done[done.length - 1] = sel;
  5970. setSelectionNoUndo(doc, sel, options);
  5971. } else {
  5972. setSelection(doc, sel, options);
  5973. }
  5974. }
  5975. // Set a new selection.
  5976. function setSelection(doc, sel, options) {
  5977. setSelectionNoUndo(doc, sel, options);
  5978. addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
  5979. }
  5980. function setSelectionNoUndo(doc, sel, options) {
  5981. if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) {
  5982. sel = filterSelectionChange(doc, sel, options);
  5983. }
  5984. var bias = options && options.bias || (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
  5985. setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
  5986. if (!(options && options.scroll === false) && doc.cm) {
  5987. ensureCursorVisible(doc.cm);
  5988. }
  5989. }
  5990. function setSelectionInner(doc, sel) {
  5991. if (sel.equals(doc.sel)) {
  5992. return;
  5993. }
  5994. doc.sel = sel;
  5995. if (doc.cm) {
  5996. doc.cm.curOp.updateInput = 1;
  5997. doc.cm.curOp.selectionChanged = true;
  5998. signalCursorActivity(doc.cm);
  5999. }
  6000. signalLater(doc, "cursorActivity", doc);
  6001. }
  6002. // Verify that the selection does not partially select any atomic
  6003. // index ranges.
  6004. function reCheckSelection(doc) {
  6005. setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false));
  6006. }
  6007. // Return a selection that does not partially select any atomic
  6008. // ranges.
  6009. function skipAtomicInSelection(doc, sel, bias, mayClear) {
  6010. var out;
  6011. for (var i = 0; i < sel.ranges.length; i++) {
  6012. var range = sel.ranges[i];
  6013. var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i];
  6014. var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear);
  6015. var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear);
  6016. if (out || newAnchor != range.anchor || newHead != range.head) {
  6017. if (!out) {
  6018. out = sel.ranges.slice(0, i);
  6019. }
  6020. out[i] = new Range(newAnchor, newHead);
  6021. }
  6022. }
  6023. return out ? normalizeSelection(doc.cm, out, sel.primIndex) : sel;
  6024. }
  6025. function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
  6026. var line = getLine(doc, pos.line);
  6027. if (line.markedSpans) {
  6028. for (var i = 0; i < line.markedSpans.length; ++i) {
  6029. var sp = line.markedSpans[i],
  6030. m = sp.marker;
  6031. // Determine if we should prevent the cursor being placed to the left/right of an atomic marker
  6032. // Historically this was determined using the inclusiveLeft/Right option, but the new way to control it
  6033. // is with selectLeft/Right
  6034. var preventCursorLeft = "selectLeft" in m ? !m.selectLeft : m.inclusiveLeft;
  6035. var preventCursorRight = "selectRight" in m ? !m.selectRight : m.inclusiveRight;
  6036. if ((sp.from == null || (preventCursorLeft ? sp.from <= pos.ch : sp.from < pos.ch)) && (sp.to == null || (preventCursorRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
  6037. if (mayClear) {
  6038. signal(m, "beforeCursorEnter");
  6039. if (m.explicitlyCleared) {
  6040. if (!line.markedSpans) {
  6041. break;
  6042. } else {
  6043. --i;
  6044. continue;
  6045. }
  6046. }
  6047. }
  6048. if (!m.atomic) {
  6049. continue;
  6050. }
  6051. if (oldPos) {
  6052. var near = m.find(dir < 0 ? 1 : -1),
  6053. diff = void 0;
  6054. if (dir < 0 ? preventCursorRight : preventCursorLeft) {
  6055. near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null);
  6056. }
  6057. if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0)) {
  6058. return skipAtomicInner(doc, near, pos, dir, mayClear);
  6059. }
  6060. }
  6061. var far = m.find(dir < 0 ? -1 : 1);
  6062. if (dir < 0 ? preventCursorLeft : preventCursorRight) {
  6063. far = movePos(doc, far, dir, far.line == pos.line ? line : null);
  6064. }
  6065. return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null;
  6066. }
  6067. }
  6068. }
  6069. return pos;
  6070. }
  6071. // Ensure a given position is not inside an atomic range.
  6072. function skipAtomic(doc, pos, oldPos, bias, mayClear) {
  6073. var dir = bias || 1;
  6074. var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) || !mayClear && skipAtomicInner(doc, pos, oldPos, dir, true) || skipAtomicInner(doc, pos, oldPos, -dir, mayClear) || !mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true);
  6075. if (!found) {
  6076. doc.cantEdit = true;
  6077. return Pos(doc.first, 0);
  6078. }
  6079. return found;
  6080. }
  6081. function movePos(doc, pos, dir, line) {
  6082. if (dir < 0 && pos.ch == 0) {
  6083. if (pos.line > doc.first) {
  6084. return _clipPos(doc, Pos(pos.line - 1));
  6085. } else {
  6086. return null;
  6087. }
  6088. } else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
  6089. if (pos.line < doc.first + doc.size - 1) {
  6090. return Pos(pos.line + 1, 0);
  6091. } else {
  6092. return null;
  6093. }
  6094. } else {
  6095. return new Pos(pos.line, pos.ch + dir);
  6096. }
  6097. }
  6098. function selectAll(cm) {
  6099. cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);
  6100. }
  6101. // UPDATING
  6102. // Allow "beforeChange" event handlers to influence a change
  6103. function filterChange(doc, change, update) {
  6104. var obj = {
  6105. canceled: false,
  6106. from: change.from,
  6107. to: change.to,
  6108. text: change.text,
  6109. origin: change.origin,
  6110. cancel: function cancel() {
  6111. return obj.canceled = true;
  6112. }
  6113. };
  6114. if (update) {
  6115. obj.update = function (from, to, text, origin) {
  6116. if (from) {
  6117. obj.from = _clipPos(doc, from);
  6118. }
  6119. if (to) {
  6120. obj.to = _clipPos(doc, to);
  6121. }
  6122. if (text) {
  6123. obj.text = text;
  6124. }
  6125. if (origin !== undefined) {
  6126. obj.origin = origin;
  6127. }
  6128. };
  6129. }
  6130. signal(doc, "beforeChange", doc, obj);
  6131. if (doc.cm) {
  6132. signal(doc.cm, "beforeChange", doc.cm, obj);
  6133. }
  6134. if (obj.canceled) {
  6135. if (doc.cm) {
  6136. doc.cm.curOp.updateInput = 2;
  6137. }
  6138. return null;
  6139. }
  6140. return { from: obj.from, to: obj.to, text: obj.text, origin: obj.origin };
  6141. }
  6142. // Apply a change to a document, and add it to the document's
  6143. // history, and propagating it to all linked documents.
  6144. function makeChange(doc, change, ignoreReadOnly) {
  6145. if (doc.cm) {
  6146. if (!doc.cm.curOp) {
  6147. return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly);
  6148. }
  6149. if (doc.cm.state.suppressEdits) {
  6150. return;
  6151. }
  6152. }
  6153. if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
  6154. change = filterChange(doc, change, true);
  6155. if (!change) {
  6156. return;
  6157. }
  6158. }
  6159. // Possibly split or suppress the update based on the presence
  6160. // of read-only spans in its range.
  6161. var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
  6162. if (split) {
  6163. for (var i = split.length - 1; i >= 0; --i) {
  6164. makeChangeInner(doc, {
  6165. from: split[i].from,
  6166. to: split[i].to,
  6167. text: i ? [""] : change.text,
  6168. origin: change.origin
  6169. });
  6170. }
  6171. } else {
  6172. makeChangeInner(doc, change);
  6173. }
  6174. }
  6175. function makeChangeInner(doc, change) {
  6176. if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) {
  6177. return;
  6178. }
  6179. var selAfter = computeSelAfterChange(doc, change);
  6180. addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
  6181. makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
  6182. var rebased = [];
  6183. linkedDocs(doc, function (doc, sharedHist) {
  6184. if (!sharedHist && indexOf(rebased, doc.history) == -1) {
  6185. rebaseHist(doc.history, change);
  6186. rebased.push(doc.history);
  6187. }
  6188. makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));
  6189. });
  6190. }
  6191. // Revert a change stored in a document's history.
  6192. function makeChangeFromHistory(doc, type, allowSelectionOnly) {
  6193. var suppress = doc.cm && doc.cm.state.suppressEdits;
  6194. if (suppress && !allowSelectionOnly) {
  6195. return;
  6196. }
  6197. var hist = doc.history,
  6198. event,
  6199. selAfter = doc.sel;
  6200. var source = type == "undo" ? hist.done : hist.undone,
  6201. dest = type == "undo" ? hist.undone : hist.done;
  6202. // Verify that there is a useable event (so that ctrl-z won't
  6203. // needlessly clear selection events)
  6204. var i = 0;
  6205. for (; i < source.length; i++) {
  6206. event = source[i];
  6207. if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges) {
  6208. break;
  6209. }
  6210. }
  6211. if (i == source.length) {
  6212. return;
  6213. }
  6214. hist.lastOrigin = hist.lastSelOrigin = null;
  6215. for (;;) {
  6216. event = source.pop();
  6217. if (event.ranges) {
  6218. pushSelectionToHistory(event, dest);
  6219. if (allowSelectionOnly && !event.equals(doc.sel)) {
  6220. setSelection(doc, event, { clearRedo: false });
  6221. return;
  6222. }
  6223. selAfter = event;
  6224. } else if (suppress) {
  6225. source.push(event);
  6226. return;
  6227. } else {
  6228. break;
  6229. }
  6230. }
  6231. // Build up a reverse change object to add to the opposite history
  6232. // stack (redo when undoing, and vice versa).
  6233. var antiChanges = [];
  6234. pushSelectionToHistory(selAfter, dest);
  6235. dest.push({ changes: antiChanges, generation: hist.generation });
  6236. hist.generation = event.generation || ++hist.maxGeneration;
  6237. var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
  6238. var loop = function loop(i) {
  6239. var change = event.changes[i];
  6240. change.origin = type;
  6241. if (filter && !filterChange(doc, change, false)) {
  6242. source.length = 0;
  6243. return {};
  6244. }
  6245. antiChanges.push(historyChangeFromChange(doc, change));
  6246. var after = i ? computeSelAfterChange(doc, change) : lst(source);
  6247. makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
  6248. if (!i && doc.cm) {
  6249. doc.cm.scrollIntoView({ from: change.from, to: changeEnd(change) });
  6250. }
  6251. var rebased = [];
  6252. // Propagate to the linked documents
  6253. linkedDocs(doc, function (doc, sharedHist) {
  6254. if (!sharedHist && indexOf(rebased, doc.history) == -1) {
  6255. rebaseHist(doc.history, change);
  6256. rebased.push(doc.history);
  6257. }
  6258. makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
  6259. });
  6260. };
  6261. for (var i$1 = event.changes.length - 1; i$1 >= 0; --i$1) {
  6262. var returned = loop(i$1);
  6263. if (returned) return returned.v;
  6264. }
  6265. }
  6266. // Sub-views need their line numbers shifted when text is added
  6267. // above or below them in the parent document.
  6268. function shiftDoc(doc, distance) {
  6269. if (distance == 0) {
  6270. return;
  6271. }
  6272. doc.first += distance;
  6273. doc.sel = new Selection(map(doc.sel.ranges, function (range) {
  6274. return new Range(Pos(range.anchor.line + distance, range.anchor.ch), Pos(range.head.line + distance, range.head.ch));
  6275. }), doc.sel.primIndex);
  6276. if (doc.cm) {
  6277. regChange(doc.cm, doc.first, doc.first - distance, distance);
  6278. for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++) {
  6279. regLineChange(doc.cm, l, "gutter");
  6280. }
  6281. }
  6282. }
  6283. // More lower-level change function, handling only a single document
  6284. // (not linked ones).
  6285. function makeChangeSingleDoc(doc, change, selAfter, spans) {
  6286. if (doc.cm && !doc.cm.curOp) {
  6287. return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);
  6288. }
  6289. if (change.to.line < doc.first) {
  6290. shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
  6291. return;
  6292. }
  6293. if (change.from.line > doc.lastLine()) {
  6294. return;
  6295. }
  6296. // Clip the change to the size of this docs
  6297. if (change.from.line < doc.first) {
  6298. var shift = change.text.length - 1 - (doc.first - change.from.line);
  6299. shiftDoc(doc, shift);
  6300. change = {
  6301. from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
  6302. text: [lst(change.text)], origin: change.origin
  6303. };
  6304. }
  6305. var last = doc.lastLine();
  6306. if (change.to.line > last) {
  6307. change = {
  6308. from: change.from, to: Pos(last, getLine(doc, last).text.length),
  6309. text: [change.text[0]], origin: change.origin
  6310. };
  6311. }
  6312. change.removed = getBetween(doc, change.from, change.to);
  6313. if (!selAfter) {
  6314. selAfter = computeSelAfterChange(doc, change);
  6315. }
  6316. if (doc.cm) {
  6317. makeChangeSingleDocInEditor(doc.cm, change, spans);
  6318. } else {
  6319. updateDoc(doc, change, spans);
  6320. }
  6321. setSelectionNoUndo(doc, selAfter, sel_dontScroll);
  6322. if (doc.cantEdit && skipAtomic(doc, Pos(doc.firstLine(), 0))) {
  6323. doc.cantEdit = false;
  6324. }
  6325. }
  6326. // Handle the interaction of a change to a document with the src
  6327. // that this document is part of.
  6328. function makeChangeSingleDocInEditor(cm, change, spans) {
  6329. var doc = cm.doc,
  6330. display = cm.display,
  6331. from = change.from,
  6332. to = change.to;
  6333. var recomputeMaxLength = false,
  6334. checkWidthStart = from.line;
  6335. if (!cm.options.lineWrapping) {
  6336. checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
  6337. doc.iter(checkWidthStart, to.line + 1, function (line) {
  6338. if (line == display.maxLine) {
  6339. recomputeMaxLength = true;
  6340. return true;
  6341. }
  6342. });
  6343. }
  6344. if (doc.sel.contains(change.from, change.to) > -1) {
  6345. signalCursorActivity(cm);
  6346. }
  6347. updateDoc(doc, change, spans, estimateHeight(cm));
  6348. if (!cm.options.lineWrapping) {
  6349. doc.iter(checkWidthStart, from.line + change.text.length, function (line) {
  6350. var len = lineLength(line);
  6351. if (len > display.maxLineLength) {
  6352. display.maxLine = line;
  6353. display.maxLineLength = len;
  6354. display.maxLineChanged = true;
  6355. recomputeMaxLength = false;
  6356. }
  6357. });
  6358. if (recomputeMaxLength) {
  6359. cm.curOp.updateMaxLine = true;
  6360. }
  6361. }
  6362. retreatFrontier(doc, from.line);
  6363. startWorker(cm, 400);
  6364. var lendiff = change.text.length - (to.line - from.line) - 1;
  6365. // Remember that these lines changed, for updating the display
  6366. if (change.full) {
  6367. regChange(cm);
  6368. } else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change)) {
  6369. regLineChange(cm, from.line, "text");
  6370. } else {
  6371. regChange(cm, from.line, to.line + 1, lendiff);
  6372. }
  6373. var changesHandler = hasHandler(cm, "changes"),
  6374. changeHandler = hasHandler(cm, "change");
  6375. if (changeHandler || changesHandler) {
  6376. var obj = {
  6377. from: from, to: to,
  6378. text: change.text,
  6379. removed: change.removed,
  6380. origin: change.origin
  6381. };
  6382. if (changeHandler) {
  6383. signalLater(cm, "change", cm, obj);
  6384. }
  6385. if (changesHandler) {
  6386. (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj);
  6387. }
  6388. }
  6389. cm.display.selForContextMenu = null;
  6390. }
  6391. function _replaceRange(doc, code, from, to, origin) {
  6392. var assign;
  6393. if (!to) {
  6394. to = from;
  6395. }
  6396. if (cmp(to, from) < 0) {
  6397. assign = [to, from], from = assign[0], to = assign[1];
  6398. }
  6399. if (typeof code == "string") {
  6400. code = doc.splitLines(code);
  6401. }
  6402. makeChange(doc, { from: from, to: to, text: code, origin: origin });
  6403. }
  6404. // Rebasing/resetting history to deal with externally-sourced changes
  6405. function rebaseHistSelSingle(pos, from, to, diff) {
  6406. if (to < pos.line) {
  6407. pos.line += diff;
  6408. } else if (from < pos.line) {
  6409. pos.line = from;
  6410. pos.ch = 0;
  6411. }
  6412. }
  6413. // Tries to rebase an array of history events given a change in the
  6414. // document. If the change touches the same lines as the event, the
  6415. // event, and everything 'behind' it, is discarded. If the change is
  6416. // before the event, the event's positions are updated. Uses a
  6417. // copy-on-write scheme for the positions, to avoid having to
  6418. // reallocate them all on every rebase, but also avoid problems with
  6419. // shared position objects being unsafely updated.
  6420. function rebaseHistArray(array, from, to, diff) {
  6421. for (var i = 0; i < array.length; ++i) {
  6422. var sub = array[i],
  6423. ok = true;
  6424. if (sub.ranges) {
  6425. if (!sub.copied) {
  6426. sub = array[i] = sub.deepCopy();
  6427. sub.copied = true;
  6428. }
  6429. for (var j = 0; j < sub.ranges.length; j++) {
  6430. rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
  6431. rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
  6432. }
  6433. continue;
  6434. }
  6435. for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) {
  6436. var cur = sub.changes[j$1];
  6437. if (to < cur.from.line) {
  6438. cur.from = Pos(cur.from.line + diff, cur.from.ch);
  6439. cur.to = Pos(cur.to.line + diff, cur.to.ch);
  6440. } else if (from <= cur.to.line) {
  6441. ok = false;
  6442. break;
  6443. }
  6444. }
  6445. if (!ok) {
  6446. array.splice(0, i + 1);
  6447. i = 0;
  6448. }
  6449. }
  6450. }
  6451. function rebaseHist(hist, change) {
  6452. var from = change.from.line,
  6453. to = change.to.line,
  6454. diff = change.text.length - (to - from) - 1;
  6455. rebaseHistArray(hist.done, from, to, diff);
  6456. rebaseHistArray(hist.undone, from, to, diff);
  6457. }
  6458. // Utility for applying a change to a line by handle or number,
  6459. // returning the number and optionally registering the line as
  6460. // changed.
  6461. function changeLine(doc, handle, changeType, op) {
  6462. var no = handle,
  6463. line = handle;
  6464. if (typeof handle == "number") {
  6465. line = getLine(doc, clipLine(doc, handle));
  6466. } else {
  6467. no = lineNo(handle);
  6468. }
  6469. if (no == null) {
  6470. return null;
  6471. }
  6472. if (op(line, no) && doc.cm) {
  6473. regLineChange(doc.cm, no, changeType);
  6474. }
  6475. return line;
  6476. }
  6477. // The document is represented as a BTree consisting of leaves, with
  6478. // chunk of lines in them, and branches, with up to ten leaves or
  6479. // other branch nodes below them. The top node is always a branch
  6480. // node, and is the document object itself (meaning it has
  6481. // additional methods and properties).
  6482. //
  6483. // All nodes have parent links. The tree is used both to go from
  6484. // line numbers to line objects, and to go from objects to numbers.
  6485. // It also indexes by height, and is used to convert between height
  6486. // and line object, and to find the total height of the document.
  6487. //
  6488. // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
  6489. function LeafChunk(lines) {
  6490. var this$1 = this;
  6491. this.lines = lines;
  6492. this.parent = null;
  6493. var height = 0;
  6494. for (var i = 0; i < lines.length; ++i) {
  6495. lines[i].parent = this$1;
  6496. height += lines[i].height;
  6497. }
  6498. this.height = height;
  6499. }
  6500. LeafChunk.prototype = {
  6501. chunkSize: function chunkSize() {
  6502. return this.lines.length;
  6503. },
  6504. // Remove the n lines at offset 'at'.
  6505. removeInner: function removeInner(at, n) {
  6506. var this$1 = this;
  6507. for (var i = at, e = at + n; i < e; ++i) {
  6508. var line = this$1.lines[i];
  6509. this$1.height -= line.height;
  6510. cleanUpLine(line);
  6511. signalLater(line, "delete");
  6512. }
  6513. this.lines.splice(at, n);
  6514. },
  6515. // Helper used to collapse a small branch into a single leaf.
  6516. collapse: function collapse(lines) {
  6517. lines.push.apply(lines, this.lines);
  6518. },
  6519. // Insert the given array of lines at offset 'at', count them as
  6520. // having the given height.
  6521. insertInner: function insertInner(at, lines, height) {
  6522. var this$1 = this;
  6523. this.height += height;
  6524. this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
  6525. for (var i = 0; i < lines.length; ++i) {
  6526. lines[i].parent = this$1;
  6527. }
  6528. },
  6529. // Used to iterate over a part of the tree.
  6530. iterN: function iterN(at, n, op) {
  6531. var this$1 = this;
  6532. for (var e = at + n; at < e; ++at) {
  6533. if (op(this$1.lines[at])) {
  6534. return true;
  6535. }
  6536. }
  6537. }
  6538. };
  6539. function BranchChunk(children) {
  6540. var this$1 = this;
  6541. this.children = children;
  6542. var size = 0,
  6543. height = 0;
  6544. for (var i = 0; i < children.length; ++i) {
  6545. var ch = children[i];
  6546. size += ch.chunkSize();
  6547. height += ch.height;
  6548. ch.parent = this$1;
  6549. }
  6550. this.size = size;
  6551. this.height = height;
  6552. this.parent = null;
  6553. }
  6554. BranchChunk.prototype = {
  6555. chunkSize: function chunkSize() {
  6556. return this.size;
  6557. },
  6558. removeInner: function removeInner(at, n) {
  6559. var this$1 = this;
  6560. this.size -= n;
  6561. for (var i = 0; i < this.children.length; ++i) {
  6562. var child = this$1.children[i],
  6563. sz = child.chunkSize();
  6564. if (at < sz) {
  6565. var rm = Math.min(n, sz - at),
  6566. oldHeight = child.height;
  6567. child.removeInner(at, rm);
  6568. this$1.height -= oldHeight - child.height;
  6569. if (sz == rm) {
  6570. this$1.children.splice(i--, 1);
  6571. child.parent = null;
  6572. }
  6573. if ((n -= rm) == 0) {
  6574. break;
  6575. }
  6576. at = 0;
  6577. } else {
  6578. at -= sz;
  6579. }
  6580. }
  6581. // If the result is smaller than 25 lines, ensure that it is a
  6582. // single leaf node.
  6583. if (this.size - n < 25 && (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
  6584. var lines = [];
  6585. this.collapse(lines);
  6586. this.children = [new LeafChunk(lines)];
  6587. this.children[0].parent = this;
  6588. }
  6589. },
  6590. collapse: function collapse(lines) {
  6591. var this$1 = this;
  6592. for (var i = 0; i < this.children.length; ++i) {
  6593. this$1.children[i].collapse(lines);
  6594. }
  6595. },
  6596. insertInner: function insertInner(at, lines, height) {
  6597. var this$1 = this;
  6598. this.size += lines.length;
  6599. this.height += height;
  6600. for (var i = 0; i < this.children.length; ++i) {
  6601. var child = this$1.children[i],
  6602. sz = child.chunkSize();
  6603. if (at <= sz) {
  6604. child.insertInner(at, lines, height);
  6605. if (child.lines && child.lines.length > 50) {
  6606. // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.
  6607. // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.
  6608. var remaining = child.lines.length % 25 + 25;
  6609. for (var pos = remaining; pos < child.lines.length;) {
  6610. var leaf = new LeafChunk(child.lines.slice(pos, pos += 25));
  6611. child.height -= leaf.height;
  6612. this$1.children.splice(++i, 0, leaf);
  6613. leaf.parent = this$1;
  6614. }
  6615. child.lines = child.lines.slice(0, remaining);
  6616. this$1.maybeSpill();
  6617. }
  6618. break;
  6619. }
  6620. at -= sz;
  6621. }
  6622. },
  6623. // When a node has grown, check whether it should be split.
  6624. maybeSpill: function maybeSpill() {
  6625. if (this.children.length <= 10) {
  6626. return;
  6627. }
  6628. var me = this;
  6629. do {
  6630. var spilled = me.children.splice(me.children.length - 5, 5);
  6631. var sibling = new BranchChunk(spilled);
  6632. if (!me.parent) {
  6633. // Become the parent node
  6634. var copy = new BranchChunk(me.children);
  6635. copy.parent = me;
  6636. me.children = [copy, sibling];
  6637. me = copy;
  6638. } else {
  6639. me.size -= sibling.size;
  6640. me.height -= sibling.height;
  6641. var myIndex = indexOf(me.parent.children, me);
  6642. me.parent.children.splice(myIndex + 1, 0, sibling);
  6643. }
  6644. sibling.parent = me.parent;
  6645. } while (me.children.length > 10);
  6646. me.parent.maybeSpill();
  6647. },
  6648. iterN: function iterN(at, n, op) {
  6649. var this$1 = this;
  6650. for (var i = 0; i < this.children.length; ++i) {
  6651. var child = this$1.children[i],
  6652. sz = child.chunkSize();
  6653. if (at < sz) {
  6654. var used = Math.min(n, sz - at);
  6655. if (child.iterN(at, used, op)) {
  6656. return true;
  6657. }
  6658. if ((n -= used) == 0) {
  6659. break;
  6660. }
  6661. at = 0;
  6662. } else {
  6663. at -= sz;
  6664. }
  6665. }
  6666. }
  6667. };
  6668. // Line widgets are block elements displayed above or below a line.
  6669. var LineWidget = function LineWidget(doc, node, options) {
  6670. var this$1 = this;
  6671. if (options) {
  6672. for (var opt in options) {
  6673. if (options.hasOwnProperty(opt)) {
  6674. this$1[opt] = options[opt];
  6675. }
  6676. }
  6677. }
  6678. this.doc = doc;
  6679. this.node = node;
  6680. };
  6681. LineWidget.prototype.clear = function () {
  6682. var this$1 = this;
  6683. var cm = this.doc.cm,
  6684. ws = this.line.widgets,
  6685. line = this.line,
  6686. no = lineNo(line);
  6687. if (no == null || !ws) {
  6688. return;
  6689. }
  6690. for (var i = 0; i < ws.length; ++i) {
  6691. if (ws[i] == this$1) {
  6692. ws.splice(i--, 1);
  6693. }
  6694. }
  6695. if (!ws.length) {
  6696. line.widgets = null;
  6697. }
  6698. var height = widgetHeight(this);
  6699. updateLineHeight(line, Math.max(0, line.height - height));
  6700. if (cm) {
  6701. runInOp(cm, function () {
  6702. adjustScrollWhenAboveVisible(cm, line, -height);
  6703. regLineChange(cm, no, "widget");
  6704. });
  6705. signalLater(cm, "lineWidgetCleared", cm, this, no);
  6706. }
  6707. };
  6708. LineWidget.prototype.changed = function () {
  6709. var this$1 = this;
  6710. var oldH = this.height,
  6711. cm = this.doc.cm,
  6712. line = this.line;
  6713. this.height = null;
  6714. var diff = widgetHeight(this) - oldH;
  6715. if (!diff) {
  6716. return;
  6717. }
  6718. if (!lineIsHidden(this.doc, line)) {
  6719. updateLineHeight(line, line.height + diff);
  6720. }
  6721. if (cm) {
  6722. runInOp(cm, function () {
  6723. cm.curOp.forceUpdate = true;
  6724. adjustScrollWhenAboveVisible(cm, line, diff);
  6725. signalLater(cm, "lineWidgetChanged", cm, this$1, lineNo(line));
  6726. });
  6727. }
  6728. };
  6729. eventMixin(LineWidget);
  6730. function adjustScrollWhenAboveVisible(cm, line, diff) {
  6731. if (_heightAtLine(line) < (cm.curOp && cm.curOp.scrollTop || cm.doc.scrollTop)) {
  6732. addToScrollTop(cm, diff);
  6733. }
  6734. }
  6735. function addLineWidget(doc, handle, node, options) {
  6736. var widget = new LineWidget(doc, node, options);
  6737. var cm = doc.cm;
  6738. if (cm && widget.noHScroll) {
  6739. cm.display.alignWidgets = true;
  6740. }
  6741. changeLine(doc, handle, "widget", function (line) {
  6742. var widgets = line.widgets || (line.widgets = []);
  6743. if (widget.insertAt == null) {
  6744. widgets.push(widget);
  6745. } else {
  6746. widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget);
  6747. }
  6748. widget.line = line;
  6749. if (cm && !lineIsHidden(doc, line)) {
  6750. var aboveVisible = _heightAtLine(line) < doc.scrollTop;
  6751. updateLineHeight(line, line.height + widgetHeight(widget));
  6752. if (aboveVisible) {
  6753. addToScrollTop(cm, widget.height);
  6754. }
  6755. cm.curOp.forceUpdate = true;
  6756. }
  6757. return true;
  6758. });
  6759. if (cm) {
  6760. signalLater(cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle));
  6761. }
  6762. return widget;
  6763. }
  6764. var nextMarkerId = 0;
  6765. var TextMarker = function TextMarker(doc, type) {
  6766. this.lines = [];
  6767. this.type = type;
  6768. this.doc = doc;
  6769. this.id = ++nextMarkerId;
  6770. };
  6771. // Clear the marker.
  6772. TextMarker.prototype.clear = function () {
  6773. var this$1 = this;
  6774. if (this.explicitlyCleared) {
  6775. return;
  6776. }
  6777. var cm = this.doc.cm,
  6778. withOp = cm && !cm.curOp;
  6779. if (withOp) {
  6780. _startOperation(cm);
  6781. }
  6782. if (hasHandler(this, "clear")) {
  6783. var found = this.find();
  6784. if (found) {
  6785. signalLater(this, "clear", found.from, found.to);
  6786. }
  6787. }
  6788. var min = null,
  6789. max = null;
  6790. for (var i = 0; i < this.lines.length; ++i) {
  6791. var line = this$1.lines[i];
  6792. var span = getMarkedSpanFor(line.markedSpans, this$1);
  6793. if (cm && !this$1.collapsed) {
  6794. regLineChange(cm, lineNo(line), "text");
  6795. } else if (cm) {
  6796. if (span.to != null) {
  6797. max = lineNo(line);
  6798. }
  6799. if (span.from != null) {
  6800. min = lineNo(line);
  6801. }
  6802. }
  6803. line.markedSpans = removeMarkedSpan(line.markedSpans, span);
  6804. if (span.from == null && this$1.collapsed && !lineIsHidden(this$1.doc, line) && cm) {
  6805. updateLineHeight(line, textHeight(cm.display));
  6806. }
  6807. }
  6808. if (cm && this.collapsed && !cm.options.lineWrapping) {
  6809. for (var i$1 = 0; i$1 < this.lines.length; ++i$1) {
  6810. var visual = visualLine(this$1.lines[i$1]),
  6811. len = lineLength(visual);
  6812. if (len > cm.display.maxLineLength) {
  6813. cm.display.maxLine = visual;
  6814. cm.display.maxLineLength = len;
  6815. cm.display.maxLineChanged = true;
  6816. }
  6817. }
  6818. }
  6819. if (min != null && cm && this.collapsed) {
  6820. regChange(cm, min, max + 1);
  6821. }
  6822. this.lines.length = 0;
  6823. this.explicitlyCleared = true;
  6824. if (this.atomic && this.doc.cantEdit) {
  6825. this.doc.cantEdit = false;
  6826. if (cm) {
  6827. reCheckSelection(cm.doc);
  6828. }
  6829. }
  6830. if (cm) {
  6831. signalLater(cm, "markerCleared", cm, this, min, max);
  6832. }
  6833. if (withOp) {
  6834. _endOperation(cm);
  6835. }
  6836. if (this.parent) {
  6837. this.parent.clear();
  6838. }
  6839. };
  6840. // Find the position of the marker in the document. Returns a {from,
  6841. // to} object by default. Side can be passed to get a specific side
  6842. // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
  6843. // Pos objects returned contain a line object, rather than a line
  6844. // number (used to prevent looking up the same line twice).
  6845. TextMarker.prototype.find = function (side, lineObj) {
  6846. var this$1 = this;
  6847. if (side == null && this.type == "bookmark") {
  6848. side = 1;
  6849. }
  6850. var from, to;
  6851. for (var i = 0; i < this.lines.length; ++i) {
  6852. var line = this$1.lines[i];
  6853. var span = getMarkedSpanFor(line.markedSpans, this$1);
  6854. if (span.from != null) {
  6855. from = Pos(lineObj ? line : lineNo(line), span.from);
  6856. if (side == -1) {
  6857. return from;
  6858. }
  6859. }
  6860. if (span.to != null) {
  6861. to = Pos(lineObj ? line : lineNo(line), span.to);
  6862. if (side == 1) {
  6863. return to;
  6864. }
  6865. }
  6866. }
  6867. return from && { from: from, to: to };
  6868. };
  6869. // Signals that the marker's widget changed, and surrounding layout
  6870. // should be recomputed.
  6871. TextMarker.prototype.changed = function () {
  6872. var this$1 = this;
  6873. var pos = this.find(-1, true),
  6874. widget = this,
  6875. cm = this.doc.cm;
  6876. if (!pos || !cm) {
  6877. return;
  6878. }
  6879. runInOp(cm, function () {
  6880. var line = pos.line,
  6881. lineN = lineNo(pos.line);
  6882. var view = findViewForLine(cm, lineN);
  6883. if (view) {
  6884. clearLineMeasurementCacheFor(view);
  6885. cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;
  6886. }
  6887. cm.curOp.updateMaxLine = true;
  6888. if (!lineIsHidden(widget.doc, line) && widget.height != null) {
  6889. var oldHeight = widget.height;
  6890. widget.height = null;
  6891. var dHeight = widgetHeight(widget) - oldHeight;
  6892. if (dHeight) {
  6893. updateLineHeight(line, line.height + dHeight);
  6894. }
  6895. }
  6896. signalLater(cm, "markerChanged", cm, this$1);
  6897. });
  6898. };
  6899. TextMarker.prototype.attachLine = function (line) {
  6900. if (!this.lines.length && this.doc.cm) {
  6901. var op = this.doc.cm.curOp;
  6902. if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1) {
  6903. (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this);
  6904. }
  6905. }
  6906. this.lines.push(line);
  6907. };
  6908. TextMarker.prototype.detachLine = function (line) {
  6909. this.lines.splice(indexOf(this.lines, line), 1);
  6910. if (!this.lines.length && this.doc.cm) {
  6911. var op = this.doc.cm.curOp;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);
  6912. }
  6913. };
  6914. eventMixin(TextMarker);
  6915. // Create a marker, wire it up to the right lines, and
  6916. function _markText(doc, from, to, options, type) {
  6917. // Shared markers (across linked documents) are handled separately
  6918. // (markTextShared will call out to this again, once per
  6919. // document).
  6920. if (options && options.shared) {
  6921. return markTextShared(doc, from, to, options, type);
  6922. }
  6923. // Ensure we are in an operation.
  6924. if (doc.cm && !doc.cm.curOp) {
  6925. return operation(doc.cm, _markText)(doc, from, to, options, type);
  6926. }
  6927. var marker = new TextMarker(doc, type),
  6928. diff = cmp(from, to);
  6929. if (options) {
  6930. copyObj(options, marker, false);
  6931. }
  6932. // Don't connect empty markers unless clearWhenEmpty is false
  6933. if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false) {
  6934. return marker;
  6935. }
  6936. if (marker.replacedWith) {
  6937. // Showing up as a widget implies collapsed (widget replaces text)
  6938. marker.collapsed = true;
  6939. marker.widgetNode = eltP("span", [marker.replacedWith], "CodeMirror-widget");
  6940. if (!options.handleMouseEvents) {
  6941. marker.widgetNode.setAttribute("cm-ignore-events", "true");
  6942. }
  6943. if (options.insertLeft) {
  6944. marker.widgetNode.insertLeft = true;
  6945. }
  6946. }
  6947. if (marker.collapsed) {
  6948. if (conflictingCollapsedRange(doc, from.line, from, to, marker) || from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker)) {
  6949. throw new Error("Inserting collapsed marker partially overlapping an existing one");
  6950. }
  6951. seeCollapsedSpans();
  6952. }
  6953. if (marker.addToHistory) {
  6954. addChangeToHistory(doc, { from: from, to: to, origin: "markText" }, doc.sel, NaN);
  6955. }
  6956. var curLine = from.line,
  6957. cm = doc.cm,
  6958. updateMaxLine;
  6959. doc.iter(curLine, to.line + 1, function (line) {
  6960. if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine) {
  6961. updateMaxLine = true;
  6962. }
  6963. if (marker.collapsed && curLine != from.line) {
  6964. updateLineHeight(line, 0);
  6965. }
  6966. addMarkedSpan(line, new MarkedSpan(marker, curLine == from.line ? from.ch : null, curLine == to.line ? to.ch : null));
  6967. ++curLine;
  6968. });
  6969. // lineIsHidden depends on the presence of the spans, so needs a second pass
  6970. if (marker.collapsed) {
  6971. doc.iter(from.line, to.line + 1, function (line) {
  6972. if (lineIsHidden(doc, line)) {
  6973. updateLineHeight(line, 0);
  6974. }
  6975. });
  6976. }
  6977. if (marker.clearOnEnter) {
  6978. on(marker, "beforeCursorEnter", function () {
  6979. return marker.clear();
  6980. });
  6981. }
  6982. if (marker.readOnly) {
  6983. seeReadOnlySpans();
  6984. if (doc.history.done.length || doc.history.undone.length) {
  6985. doc.clearHistory();
  6986. }
  6987. }
  6988. if (marker.collapsed) {
  6989. marker.id = ++nextMarkerId;
  6990. marker.atomic = true;
  6991. }
  6992. if (cm) {
  6993. // Sync src state
  6994. if (updateMaxLine) {
  6995. cm.curOp.updateMaxLine = true;
  6996. }
  6997. if (marker.collapsed) {
  6998. regChange(cm, from.line, to.line + 1);
  6999. } else if (marker.className || marker.startStyle || marker.endStyle || marker.css || marker.attributes || marker.title) {
  7000. for (var i = from.line; i <= to.line; i++) {
  7001. regLineChange(cm, i, "text");
  7002. }
  7003. }
  7004. if (marker.atomic) {
  7005. reCheckSelection(cm.doc);
  7006. }
  7007. signalLater(cm, "markerAdded", cm, marker);
  7008. }
  7009. return marker;
  7010. }
  7011. // SHARED TEXTMARKERS
  7012. // A shared marker spans multiple linked documents. It is
  7013. // implemented as a meta-marker-object controlling multiple normal
  7014. // markers.
  7015. var SharedTextMarker = function SharedTextMarker(markers, primary) {
  7016. var this$1 = this;
  7017. this.markers = markers;
  7018. this.primary = primary;
  7019. for (var i = 0; i < markers.length; ++i) {
  7020. markers[i].parent = this$1;
  7021. }
  7022. };
  7023. SharedTextMarker.prototype.clear = function () {
  7024. var this$1 = this;
  7025. if (this.explicitlyCleared) {
  7026. return;
  7027. }
  7028. this.explicitlyCleared = true;
  7029. for (var i = 0; i < this.markers.length; ++i) {
  7030. this$1.markers[i].clear();
  7031. }
  7032. signalLater(this, "clear");
  7033. };
  7034. SharedTextMarker.prototype.find = function (side, lineObj) {
  7035. return this.primary.find(side, lineObj);
  7036. };
  7037. eventMixin(SharedTextMarker);
  7038. function markTextShared(doc, from, to, options, type) {
  7039. options = copyObj(options);
  7040. options.shared = false;
  7041. var markers = [_markText(doc, from, to, options, type)],
  7042. primary = markers[0];
  7043. var widget = options.widgetNode;
  7044. linkedDocs(doc, function (doc) {
  7045. if (widget) {
  7046. options.widgetNode = widget.cloneNode(true);
  7047. }
  7048. markers.push(_markText(doc, _clipPos(doc, from), _clipPos(doc, to), options, type));
  7049. for (var i = 0; i < doc.linked.length; ++i) {
  7050. if (doc.linked[i].isParent) {
  7051. return;
  7052. }
  7053. }
  7054. primary = lst(markers);
  7055. });
  7056. return new SharedTextMarker(markers, primary);
  7057. }
  7058. function findSharedMarkers(doc) {
  7059. return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function (m) {
  7060. return m.parent;
  7061. });
  7062. }
  7063. function copySharedMarkers(doc, markers) {
  7064. for (var i = 0; i < markers.length; i++) {
  7065. var marker = markers[i],
  7066. pos = marker.find();
  7067. var mFrom = doc.clipPos(pos.from),
  7068. mTo = doc.clipPos(pos.to);
  7069. if (cmp(mFrom, mTo)) {
  7070. var subMark = _markText(doc, mFrom, mTo, marker.primary, marker.primary.type);
  7071. marker.markers.push(subMark);
  7072. subMark.parent = marker;
  7073. }
  7074. }
  7075. }
  7076. function detachSharedMarkers(markers) {
  7077. var loop = function loop(i) {
  7078. var marker = markers[i],
  7079. linked = [marker.primary.doc];
  7080. linkedDocs(marker.primary.doc, function (d) {
  7081. return linked.push(d);
  7082. });
  7083. for (var j = 0; j < marker.markers.length; j++) {
  7084. var subMarker = marker.markers[j];
  7085. if (indexOf(linked, subMarker.doc) == -1) {
  7086. subMarker.parent = null;
  7087. marker.markers.splice(j--, 1);
  7088. }
  7089. }
  7090. };
  7091. for (var i = 0; i < markers.length; i++) {
  7092. loop(i);
  7093. }
  7094. }
  7095. var nextDocId = 0;
  7096. var Doc = function Doc(text, mode, firstLine, lineSep, direction) {
  7097. if (!(this instanceof Doc)) {
  7098. return new Doc(text, mode, firstLine, lineSep, direction);
  7099. }
  7100. if (firstLine == null) {
  7101. firstLine = 0;
  7102. }
  7103. BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
  7104. this.first = firstLine;
  7105. this.scrollTop = this.scrollLeft = 0;
  7106. this.cantEdit = false;
  7107. this.cleanGeneration = 1;
  7108. this.modeFrontier = this.highlightFrontier = firstLine;
  7109. var start = Pos(firstLine, 0);
  7110. this.sel = simpleSelection(start);
  7111. this.history = new History(null);
  7112. this.id = ++nextDocId;
  7113. this.modeOption = mode;
  7114. this.lineSep = lineSep;
  7115. this.direction = direction == "rtl" ? "rtl" : "ltr";
  7116. this.extend = false;
  7117. if (typeof text == "string") {
  7118. text = this.splitLines(text);
  7119. }
  7120. updateDoc(this, { from: start, to: start, text: text });
  7121. setSelection(this, simpleSelection(start), sel_dontScroll);
  7122. };
  7123. Doc.prototype = createObj(BranchChunk.prototype, {
  7124. constructor: Doc,
  7125. // Iterate over the document. Supports two forms -- with only one
  7126. // argument, it calls that for each line in the document. With
  7127. // three, it iterates over the range given by the first two (with
  7128. // the second being non-inclusive).
  7129. iter: function iter(from, to, op) {
  7130. if (op) {
  7131. this.iterN(from - this.first, to - from, op);
  7132. } else {
  7133. this.iterN(this.first, this.first + this.size, from);
  7134. }
  7135. },
  7136. // Non-public interface for adding and removing lines.
  7137. insert: function insert(at, lines) {
  7138. var height = 0;
  7139. for (var i = 0; i < lines.length; ++i) {
  7140. height += lines[i].height;
  7141. }
  7142. this.insertInner(at - this.first, lines, height);
  7143. },
  7144. remove: function remove(at, n) {
  7145. this.removeInner(at - this.first, n);
  7146. },
  7147. getValue: function getValue(lineSep) {
  7148. var lines = getLines(this, this.first, this.first + this.size);
  7149. if (lineSep === false) {
  7150. return lines;
  7151. }
  7152. return lines.join(lineSep || this.lineSeparator());
  7153. },
  7154. setValue: docMethodOp(function (code) {
  7155. var top = Pos(this.first, 0),
  7156. last = this.first + this.size - 1;
  7157. makeChange(this, {
  7158. from: top, to: Pos(last, getLine(this, last).text.length),
  7159. text: this.splitLines(code), origin: "setValue", full: true
  7160. }, true);
  7161. if (this.cm) {
  7162. scrollToCoords(this.cm, 0, 0);
  7163. }
  7164. setSelection(this, simpleSelection(top), sel_dontScroll);
  7165. }),
  7166. replaceRange: function replaceRange(code, from, to, origin) {
  7167. from = _clipPos(this, from);
  7168. to = to ? _clipPos(this, to) : from;
  7169. _replaceRange(this, code, from, to, origin);
  7170. },
  7171. getRange: function getRange(from, to, lineSep) {
  7172. var lines = getBetween(this, _clipPos(this, from), _clipPos(this, to));
  7173. if (lineSep === false) {
  7174. return lines;
  7175. }
  7176. return lines.join(lineSep || this.lineSeparator());
  7177. },
  7178. getLine: function getLine(line) {
  7179. var l = this.getLineHandle(line);
  7180. return l && l.text;
  7181. },
  7182. getLineHandle: function getLineHandle(line) {
  7183. if (isLine(this, line)) {
  7184. return getLine(this, line);
  7185. }
  7186. },
  7187. getLineNumber: function getLineNumber(line) {
  7188. return lineNo(line);
  7189. },
  7190. getLineHandleVisualStart: function getLineHandleVisualStart(line) {
  7191. if (typeof line == "number") {
  7192. line = getLine(this, line);
  7193. }
  7194. return visualLine(line);
  7195. },
  7196. lineCount: function lineCount() {
  7197. return this.size;
  7198. },
  7199. firstLine: function firstLine() {
  7200. return this.first;
  7201. },
  7202. lastLine: function lastLine() {
  7203. return this.first + this.size - 1;
  7204. },
  7205. clipPos: function clipPos(pos) {
  7206. return _clipPos(this, pos);
  7207. },
  7208. getCursor: function getCursor(start) {
  7209. var range$$1 = this.sel.primary(),
  7210. pos;
  7211. if (start == null || start == "head") {
  7212. pos = range$$1.head;
  7213. } else if (start == "anchor") {
  7214. pos = range$$1.anchor;
  7215. } else if (start == "end" || start == "to" || start === false) {
  7216. pos = range$$1.to();
  7217. } else {
  7218. pos = range$$1.from();
  7219. }
  7220. return pos;
  7221. },
  7222. listSelections: function listSelections() {
  7223. return this.sel.ranges;
  7224. },
  7225. somethingSelected: function somethingSelected() {
  7226. return this.sel.somethingSelected();
  7227. },
  7228. setCursor: docMethodOp(function (line, ch, options) {
  7229. setSimpleSelection(this, _clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
  7230. }),
  7231. setSelection: docMethodOp(function (anchor, head, options) {
  7232. setSimpleSelection(this, _clipPos(this, anchor), _clipPos(this, head || anchor), options);
  7233. }),
  7234. extendSelection: docMethodOp(function (head, other, options) {
  7235. extendSelection(this, _clipPos(this, head), other && _clipPos(this, other), options);
  7236. }),
  7237. extendSelections: docMethodOp(function (heads, options) {
  7238. extendSelections(this, clipPosArray(this, heads), options);
  7239. }),
  7240. extendSelectionsBy: docMethodOp(function (f, options) {
  7241. var heads = map(this.sel.ranges, f);
  7242. extendSelections(this, clipPosArray(this, heads), options);
  7243. }),
  7244. setSelections: docMethodOp(function (ranges, primary, options) {
  7245. var this$1 = this;
  7246. if (!ranges.length) {
  7247. return;
  7248. }
  7249. var out = [];
  7250. for (var i = 0; i < ranges.length; i++) {
  7251. out[i] = new Range(_clipPos(this$1, ranges[i].anchor), _clipPos(this$1, ranges[i].head));
  7252. }
  7253. if (primary == null) {
  7254. primary = Math.min(ranges.length - 1, this.sel.primIndex);
  7255. }
  7256. setSelection(this, normalizeSelection(this.cm, out, primary), options);
  7257. }),
  7258. addSelection: docMethodOp(function (anchor, head, options) {
  7259. var ranges = this.sel.ranges.slice(0);
  7260. ranges.push(new Range(_clipPos(this, anchor), _clipPos(this, head || anchor)));
  7261. setSelection(this, normalizeSelection(this.cm, ranges, ranges.length - 1), options);
  7262. }),
  7263. getSelection: function getSelection(lineSep) {
  7264. var this$1 = this;
  7265. var ranges = this.sel.ranges,
  7266. lines;
  7267. for (var i = 0; i < ranges.length; i++) {
  7268. var sel = getBetween(this$1, ranges[i].from(), ranges[i].to());
  7269. lines = lines ? lines.concat(sel) : sel;
  7270. }
  7271. if (lineSep === false) {
  7272. return lines;
  7273. } else {
  7274. return lines.join(lineSep || this.lineSeparator());
  7275. }
  7276. },
  7277. getSelections: function getSelections(lineSep) {
  7278. var this$1 = this;
  7279. var parts = [],
  7280. ranges = this.sel.ranges;
  7281. for (var i = 0; i < ranges.length; i++) {
  7282. var sel = getBetween(this$1, ranges[i].from(), ranges[i].to());
  7283. if (lineSep !== false) {
  7284. sel = sel.join(lineSep || this$1.lineSeparator());
  7285. }
  7286. parts[i] = sel;
  7287. }
  7288. return parts;
  7289. },
  7290. replaceSelection: function replaceSelection(code, collapse, origin) {
  7291. var dup = [];
  7292. for (var i = 0; i < this.sel.ranges.length; i++) {
  7293. dup[i] = code;
  7294. }
  7295. this.replaceSelections(dup, collapse, origin || "+input");
  7296. },
  7297. replaceSelections: docMethodOp(function (code, collapse, origin) {
  7298. var this$1 = this;
  7299. var changes = [],
  7300. sel = this.sel;
  7301. for (var i = 0; i < sel.ranges.length; i++) {
  7302. var range$$1 = sel.ranges[i];
  7303. changes[i] = { from: range$$1.from(), to: range$$1.to(), text: this$1.splitLines(code[i]), origin: origin };
  7304. }
  7305. var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
  7306. for (var i$1 = changes.length - 1; i$1 >= 0; i$1--) {
  7307. makeChange(this$1, changes[i$1]);
  7308. }
  7309. if (newSel) {
  7310. setSelectionReplaceHistory(this, newSel);
  7311. } else if (this.cm) {
  7312. ensureCursorVisible(this.cm);
  7313. }
  7314. }),
  7315. undo: docMethodOp(function () {
  7316. makeChangeFromHistory(this, "undo");
  7317. }),
  7318. redo: docMethodOp(function () {
  7319. makeChangeFromHistory(this, "redo");
  7320. }),
  7321. undoSelection: docMethodOp(function () {
  7322. makeChangeFromHistory(this, "undo", true);
  7323. }),
  7324. redoSelection: docMethodOp(function () {
  7325. makeChangeFromHistory(this, "redo", true);
  7326. }),
  7327. setExtending: function setExtending(val) {
  7328. this.extend = val;
  7329. },
  7330. getExtending: function getExtending() {
  7331. return this.extend;
  7332. },
  7333. historySize: function historySize() {
  7334. var hist = this.history,
  7335. done = 0,
  7336. undone = 0;
  7337. for (var i = 0; i < hist.done.length; i++) {
  7338. if (!hist.done[i].ranges) {
  7339. ++done;
  7340. }
  7341. }
  7342. for (var i$1 = 0; i$1 < hist.undone.length; i$1++) {
  7343. if (!hist.undone[i$1].ranges) {
  7344. ++undone;
  7345. }
  7346. }
  7347. return { undo: done, redo: undone };
  7348. },
  7349. clearHistory: function clearHistory() {
  7350. this.history = new History(this.history.maxGeneration);
  7351. },
  7352. markClean: function markClean() {
  7353. this.cleanGeneration = this.changeGeneration(true);
  7354. },
  7355. changeGeneration: function changeGeneration(forceSplit) {
  7356. if (forceSplit) {
  7357. this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null;
  7358. }
  7359. return this.history.generation;
  7360. },
  7361. isClean: function isClean(gen) {
  7362. return this.history.generation == (gen || this.cleanGeneration);
  7363. },
  7364. getHistory: function getHistory() {
  7365. return {
  7366. done: copyHistoryArray(this.history.done),
  7367. undone: copyHistoryArray(this.history.undone)
  7368. };
  7369. },
  7370. setHistory: function setHistory(histData) {
  7371. var hist = this.history = new History(this.history.maxGeneration);
  7372. hist.done = copyHistoryArray(histData.done.slice(0), null, true);
  7373. hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
  7374. },
  7375. setGutterMarker: docMethodOp(function (line, gutterID, value) {
  7376. return changeLine(this, line, "gutter", function (line) {
  7377. var markers = line.gutterMarkers || (line.gutterMarkers = {});
  7378. markers[gutterID] = value;
  7379. if (!value && isEmpty(markers)) {
  7380. line.gutterMarkers = null;
  7381. }
  7382. return true;
  7383. });
  7384. }),
  7385. clearGutter: docMethodOp(function (gutterID) {
  7386. var this$1 = this;
  7387. this.iter(function (line) {
  7388. if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
  7389. changeLine(this$1, line, "gutter", function () {
  7390. line.gutterMarkers[gutterID] = null;
  7391. if (isEmpty(line.gutterMarkers)) {
  7392. line.gutterMarkers = null;
  7393. }
  7394. return true;
  7395. });
  7396. }
  7397. });
  7398. }),
  7399. lineInfo: function lineInfo(line) {
  7400. var n;
  7401. if (typeof line == "number") {
  7402. if (!isLine(this, line)) {
  7403. return null;
  7404. }
  7405. n = line;
  7406. line = getLine(this, line);
  7407. if (!line) {
  7408. return null;
  7409. }
  7410. } else {
  7411. n = lineNo(line);
  7412. if (n == null) {
  7413. return null;
  7414. }
  7415. }
  7416. return {
  7417. line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
  7418. textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
  7419. widgets: line.widgets
  7420. };
  7421. },
  7422. addLineClass: docMethodOp(function (handle, where, cls) {
  7423. return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
  7424. var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : where == "gutter" ? "gutterClass" : "wrapClass";
  7425. if (!line[prop]) {
  7426. line[prop] = cls;
  7427. } else if (classTest(cls).test(line[prop])) {
  7428. return false;
  7429. } else {
  7430. line[prop] += " " + cls;
  7431. }
  7432. return true;
  7433. });
  7434. }),
  7435. removeLineClass: docMethodOp(function (handle, where, cls) {
  7436. return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
  7437. var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : where == "gutter" ? "gutterClass" : "wrapClass";
  7438. var cur = line[prop];
  7439. if (!cur) {
  7440. return false;
  7441. } else if (cls == null) {
  7442. line[prop] = null;
  7443. } else {
  7444. var found = cur.match(classTest(cls));
  7445. if (!found) {
  7446. return false;
  7447. }
  7448. var end = found.index + found[0].length;
  7449. line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
  7450. }
  7451. return true;
  7452. });
  7453. }),
  7454. addLineWidget: docMethodOp(function (handle, node, options) {
  7455. return addLineWidget(this, handle, node, options);
  7456. }),
  7457. removeLineWidget: function removeLineWidget(widget) {
  7458. widget.clear();
  7459. },
  7460. markText: function markText(from, to, options) {
  7461. return _markText(this, _clipPos(this, from), _clipPos(this, to), options, options && options.type || "range");
  7462. },
  7463. setBookmark: function setBookmark(pos, options) {
  7464. var realOpts = {
  7465. replacedWith: options && (options.nodeType == null ? options.widget : options),
  7466. insertLeft: options && options.insertLeft,
  7467. clearWhenEmpty: false, shared: options && options.shared,
  7468. handleMouseEvents: options && options.handleMouseEvents
  7469. };
  7470. pos = _clipPos(this, pos);
  7471. return _markText(this, pos, pos, realOpts, "bookmark");
  7472. },
  7473. findMarksAt: function findMarksAt(pos) {
  7474. pos = _clipPos(this, pos);
  7475. var markers = [],
  7476. spans = getLine(this, pos.line).markedSpans;
  7477. if (spans) {
  7478. for (var i = 0; i < spans.length; ++i) {
  7479. var span = spans[i];
  7480. if ((span.from == null || span.from <= pos.ch) && (span.to == null || span.to >= pos.ch)) {
  7481. markers.push(span.marker.parent || span.marker);
  7482. }
  7483. }
  7484. }
  7485. return markers;
  7486. },
  7487. findMarks: function findMarks(from, to, filter) {
  7488. from = _clipPos(this, from);
  7489. to = _clipPos(this, to);
  7490. var found = [],
  7491. lineNo$$1 = from.line;
  7492. this.iter(from.line, to.line + 1, function (line) {
  7493. var spans = line.markedSpans;
  7494. if (spans) {
  7495. for (var i = 0; i < spans.length; i++) {
  7496. var span = spans[i];
  7497. if (!(span.to != null && lineNo$$1 == from.line && from.ch >= span.to || span.from == null && lineNo$$1 != from.line || span.from != null && lineNo$$1 == to.line && span.from >= to.ch) && (!filter || filter(span.marker))) {
  7498. found.push(span.marker.parent || span.marker);
  7499. }
  7500. }
  7501. }
  7502. ++lineNo$$1;
  7503. });
  7504. return found;
  7505. },
  7506. getAllMarks: function getAllMarks() {
  7507. var markers = [];
  7508. this.iter(function (line) {
  7509. var sps = line.markedSpans;
  7510. if (sps) {
  7511. for (var i = 0; i < sps.length; ++i) {
  7512. if (sps[i].from != null) {
  7513. markers.push(sps[i].marker);
  7514. }
  7515. }
  7516. }
  7517. });
  7518. return markers;
  7519. },
  7520. posFromIndex: function posFromIndex(off) {
  7521. var ch,
  7522. lineNo$$1 = this.first,
  7523. sepSize = this.lineSeparator().length;
  7524. this.iter(function (line) {
  7525. var sz = line.text.length + sepSize;
  7526. if (sz > off) {
  7527. ch = off;
  7528. return true;
  7529. }
  7530. off -= sz;
  7531. ++lineNo$$1;
  7532. });
  7533. return _clipPos(this, Pos(lineNo$$1, ch));
  7534. },
  7535. indexFromPos: function indexFromPos(coords) {
  7536. coords = _clipPos(this, coords);
  7537. var index = coords.ch;
  7538. if (coords.line < this.first || coords.ch < 0) {
  7539. return 0;
  7540. }
  7541. var sepSize = this.lineSeparator().length;
  7542. this.iter(this.first, coords.line, function (line) {
  7543. // iter aborts when callback returns a truthy value
  7544. index += line.text.length + sepSize;
  7545. });
  7546. return index;
  7547. },
  7548. copy: function copy(copyHistory) {
  7549. var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first, this.lineSep, this.direction);
  7550. doc.scrollTop = this.scrollTop;
  7551. doc.scrollLeft = this.scrollLeft;
  7552. doc.sel = this.sel;
  7553. doc.extend = false;
  7554. if (copyHistory) {
  7555. doc.history.undoDepth = this.history.undoDepth;
  7556. doc.setHistory(this.getHistory());
  7557. }
  7558. return doc;
  7559. },
  7560. linkedDoc: function linkedDoc(options) {
  7561. if (!options) {
  7562. options = {};
  7563. }
  7564. var from = this.first,
  7565. to = this.first + this.size;
  7566. if (options.from != null && options.from > from) {
  7567. from = options.from;
  7568. }
  7569. if (options.to != null && options.to < to) {
  7570. to = options.to;
  7571. }
  7572. var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep, this.direction);
  7573. if (options.sharedHist) {
  7574. copy.history = this.history;
  7575. }
  7576. (this.linked || (this.linked = [])).push({ doc: copy, sharedHist: options.sharedHist });
  7577. copy.linked = [{ doc: this, isParent: true, sharedHist: options.sharedHist }];
  7578. copySharedMarkers(copy, findSharedMarkers(this));
  7579. return copy;
  7580. },
  7581. unlinkDoc: function unlinkDoc(other) {
  7582. var this$1 = this;
  7583. if (other instanceof CodeMirror) {
  7584. other = other.doc;
  7585. }
  7586. if (this.linked) {
  7587. for (var i = 0; i < this.linked.length; ++i) {
  7588. var link = this$1.linked[i];
  7589. if (link.doc != other) {
  7590. continue;
  7591. }
  7592. this$1.linked.splice(i, 1);
  7593. other.unlinkDoc(this$1);
  7594. detachSharedMarkers(findSharedMarkers(this$1));
  7595. break;
  7596. }
  7597. }
  7598. // If the histories were shared, split them again
  7599. if (other.history == this.history) {
  7600. var splitIds = [other.id];
  7601. linkedDocs(other, function (doc) {
  7602. return splitIds.push(doc.id);
  7603. }, true);
  7604. other.history = new History(null);
  7605. other.history.done = copyHistoryArray(this.history.done, splitIds);
  7606. other.history.undone = copyHistoryArray(this.history.undone, splitIds);
  7607. }
  7608. },
  7609. iterLinkedDocs: function iterLinkedDocs(f) {
  7610. linkedDocs(this, f);
  7611. },
  7612. getMode: function getMode() {
  7613. return this.mode;
  7614. },
  7615. getEditor: function getEditor() {
  7616. return this.cm;
  7617. },
  7618. splitLines: function splitLines(str) {
  7619. if (this.lineSep) {
  7620. return str.split(this.lineSep);
  7621. }
  7622. return splitLinesAuto(str);
  7623. },
  7624. lineSeparator: function lineSeparator() {
  7625. return this.lineSep || "\n";
  7626. },
  7627. setDirection: docMethodOp(function (dir) {
  7628. if (dir != "rtl") {
  7629. dir = "ltr";
  7630. }
  7631. if (dir == this.direction) {
  7632. return;
  7633. }
  7634. this.direction = dir;
  7635. this.iter(function (line) {
  7636. return line.order = null;
  7637. });
  7638. if (this.cm) {
  7639. directionChanged(this.cm);
  7640. }
  7641. })
  7642. });
  7643. // Public alias.
  7644. Doc.prototype.eachLine = Doc.prototype.iter;
  7645. // Kludge to work around strange IE behavior where it'll sometimes
  7646. // re-fire a series of drag-related events right after the drop (#1551)
  7647. var lastDrop = 0;
  7648. function onDrop(e) {
  7649. var cm = this;
  7650. clearDragCursor(cm);
  7651. if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) {
  7652. return;
  7653. }
  7654. e_preventDefault(e);
  7655. if (ie) {
  7656. lastDrop = +new Date();
  7657. }
  7658. var pos = posFromMouse(cm, e, true),
  7659. files = e.dataTransfer.files;
  7660. if (!pos || cm.isReadOnly()) {
  7661. return;
  7662. }
  7663. // Might be a file drop, in which case we simply extract the text
  7664. // and insert it.
  7665. if (files && files.length && window.FileReader && window.File) {
  7666. var n = files.length,
  7667. text = Array(n),
  7668. read = 0;
  7669. var loadFile = function loadFile(file, i) {
  7670. if (cm.options.allowDropFileTypes && indexOf(cm.options.allowDropFileTypes, file.type) == -1) {
  7671. return;
  7672. }
  7673. var reader = new FileReader();
  7674. reader.onload = operation(cm, function () {
  7675. var content = reader.result;
  7676. if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) {
  7677. content = "";
  7678. }
  7679. text[i] = content;
  7680. if (++read == n) {
  7681. pos = _clipPos(cm.doc, pos);
  7682. var change = {
  7683. from: pos, to: pos,
  7684. text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
  7685. origin: "paste"
  7686. };
  7687. makeChange(cm.doc, change);
  7688. setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
  7689. }
  7690. });
  7691. reader.readAsText(file);
  7692. };
  7693. for (var i = 0; i < n; ++i) {
  7694. loadFile(files[i], i);
  7695. }
  7696. } else {
  7697. // Normal drop
  7698. // Don't do a replace if the drop happened inside of the selected text.
  7699. if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
  7700. cm.state.draggingText(e);
  7701. // Ensure the src is re-focused
  7702. setTimeout(function () {
  7703. return cm.display.input.focus();
  7704. }, 20);
  7705. return;
  7706. }
  7707. try {
  7708. var text$1 = e.dataTransfer.getData("Text");
  7709. if (text$1) {
  7710. var selected;
  7711. if (cm.state.draggingText && !cm.state.draggingText.copy) {
  7712. selected = cm.listSelections();
  7713. }
  7714. setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
  7715. if (selected) {
  7716. for (var i$1 = 0; i$1 < selected.length; ++i$1) {
  7717. _replaceRange(cm.doc, "", selected[i$1].anchor, selected[i$1].head, "drag");
  7718. }
  7719. }
  7720. cm.replaceSelection(text$1, "around", "paste");
  7721. cm.display.input.focus();
  7722. }
  7723. } catch (e) {}
  7724. }
  7725. }
  7726. function onDragStart(cm, e) {
  7727. if (ie && (!cm.state.draggingText || +new Date() - lastDrop < 100)) {
  7728. e_stop(e);
  7729. return;
  7730. }
  7731. if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) {
  7732. return;
  7733. }
  7734. e.dataTransfer.setData("Text", cm.getSelection());
  7735. e.dataTransfer.effectAllowed = "copyMove";
  7736. // Use dummy image instead of default browsers image.
  7737. // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
  7738. if (e.dataTransfer.setDragImage && !safari) {
  7739. var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
  7740. img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  7741. if (presto) {
  7742. img.width = img.height = 1;
  7743. cm.display.wrapper.appendChild(img);
  7744. // Force a relayout, or Opera won't use our image for some obscure reason
  7745. img._top = img.offsetTop;
  7746. }
  7747. e.dataTransfer.setDragImage(img, 0, 0);
  7748. if (presto) {
  7749. img.parentNode.removeChild(img);
  7750. }
  7751. }
  7752. }
  7753. function onDragOver(cm, e) {
  7754. var pos = posFromMouse(cm, e);
  7755. if (!pos) {
  7756. return;
  7757. }
  7758. var frag = document.createDocumentFragment();
  7759. drawSelectionCursor(cm, pos, frag);
  7760. if (!cm.display.dragCursor) {
  7761. cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors");
  7762. cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv);
  7763. }
  7764. removeChildrenAndAdd(cm.display.dragCursor, frag);
  7765. }
  7766. function clearDragCursor(cm) {
  7767. if (cm.display.dragCursor) {
  7768. cm.display.lineSpace.removeChild(cm.display.dragCursor);
  7769. cm.display.dragCursor = null;
  7770. }
  7771. }
  7772. // These must be handled carefully, because naively registering a
  7773. // handler for each src will cause the editors to never be
  7774. // garbage collected.
  7775. function forEachCodeMirror(f) {
  7776. if (!document.getElementsByClassName) {
  7777. return;
  7778. }
  7779. var byClass = document.getElementsByClassName("CodeMirror"),
  7780. editors = [];
  7781. for (var i = 0; i < byClass.length; i++) {
  7782. var cm = byClass[i].CodeMirror;
  7783. if (cm) {
  7784. editors.push(cm);
  7785. }
  7786. }
  7787. if (editors.length) {
  7788. editors[0].operation(function () {
  7789. for (var i = 0; i < editors.length; i++) {
  7790. f(editors[i]);
  7791. }
  7792. });
  7793. }
  7794. }
  7795. var globalsRegistered = false;
  7796. function ensureGlobalHandlers() {
  7797. if (globalsRegistered) {
  7798. return;
  7799. }
  7800. registerGlobalHandlers();
  7801. globalsRegistered = true;
  7802. }
  7803. function registerGlobalHandlers() {
  7804. // When the window resizes, we need to refresh active editors.
  7805. var resizeTimer;
  7806. on(window, "resize", function () {
  7807. if (resizeTimer == null) {
  7808. resizeTimer = setTimeout(function () {
  7809. resizeTimer = null;
  7810. forEachCodeMirror(onResize);
  7811. }, 100);
  7812. }
  7813. });
  7814. // When the window loses focus, we want to show the src as blurred
  7815. on(window, "blur", function () {
  7816. return forEachCodeMirror(onBlur);
  7817. });
  7818. }
  7819. // Called when the window resizes
  7820. function onResize(cm) {
  7821. var d = cm.display;
  7822. // Might be a text scaling operation, clear size caches.
  7823. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
  7824. d.scrollbarsClipped = false;
  7825. cm.setSize();
  7826. }
  7827. var keyNames = {
  7828. 3: "Pause", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
  7829. 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
  7830. 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
  7831. 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
  7832. 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 145: "ScrollLock",
  7833. 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
  7834. 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
  7835. 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
  7836. };
  7837. // Number keys
  7838. for (var i = 0; i < 10; i++) {
  7839. keyNames[i + 48] = keyNames[i + 96] = String(i);
  7840. }
  7841. // Alphabetic keys
  7842. for (var i$1 = 65; i$1 <= 90; i$1++) {
  7843. keyNames[i$1] = String.fromCharCode(i$1);
  7844. }
  7845. // Function keys
  7846. for (var i$2 = 1; i$2 <= 12; i$2++) {
  7847. keyNames[i$2 + 111] = keyNames[i$2 + 63235] = "F" + i$2;
  7848. }
  7849. var keyMap = {};
  7850. keyMap.basic = {
  7851. "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
  7852. "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
  7853. "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
  7854. "Tab": "defaultTab", "Shift-Tab": "indentAuto",
  7855. "Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
  7856. "Esc": "singleSelection"
  7857. };
  7858. // Note that the save and find-related commands aren't defined by
  7859. // default. User code or addons can define them. Unknown commands
  7860. // are simply ignored.
  7861. keyMap.pcDefault = {
  7862. "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
  7863. "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
  7864. "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
  7865. "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
  7866. "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
  7867. "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
  7868. "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
  7869. "fallthrough": "basic"
  7870. };
  7871. // Very basic readline/emacs-style bindings, which are standard on Mac.
  7872. keyMap.emacsy = {
  7873. "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
  7874. "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
  7875. "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
  7876. "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars",
  7877. "Ctrl-O": "openLine"
  7878. };
  7879. keyMap.macDefault = {
  7880. "Cmd-A": "selectAll",
  7881. "Cmd-D": "deleteLine",
  7882. "Cmd-Z": "undo",
  7883. "Shift-Cmd-Z": "redo",
  7884. "Cmd-Y": "redo",
  7885. "Cmd-Home": "goDocStart",
  7886. "Cmd-Up": "goDocStart",
  7887. "Cmd-End": "goDocEnd",
  7888. "Cmd-Down": "goDocEnd",
  7889. "Alt-Left": "goGroupLeft",
  7890. "Alt-Right": "goGroupRight",
  7891. "Cmd-Left": "goLineLeft",
  7892. "Cmd-Right": "goLineRight",
  7893. "Alt-Backspace": "delGroupBefore",
  7894. "Ctrl-Alt-Backspace": "delGroupAfter",
  7895. "Alt-Delete": "delGroupAfter",
  7896. "Cmd-S": "save",
  7897. "Cmd-F": "find",
  7898. "Cmd-G": "findNext",
  7899. "Shift-Cmd-G": "findPrev",
  7900. "Cmd-Alt-F": "replace",
  7901. "Shift-Cmd-Alt-F": "replaceAll",
  7902. "Cmd-[": "indentLess",
  7903. "Cmd-]": "indentMore",
  7904. "Cmd-Backspace": "delWrappedLineLeft",
  7905. "Cmd-Delete": "delWrappedLineRight",
  7906. "Cmd-U": "undoSelection",
  7907. "Shift-Cmd-U": "redoSelection",
  7908. "Ctrl-Up": "goDocStart",
  7909. "Ctrl-Down": "goDocEnd",
  7910. "fallthrough": ["basic", "emacsy"]
  7911. };
  7912. keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
  7913. // KEYMAP DISPATCH
  7914. function normalizeKeyName(name) {
  7915. var parts = name.split(/-(?!$)/);
  7916. name = parts[parts.length - 1];
  7917. var alt, ctrl, shift, cmd;
  7918. for (var i = 0; i < parts.length - 1; i++) {
  7919. var mod = parts[i];
  7920. if (/^(cmd|meta|m)$/i.test(mod)) {
  7921. cmd = true;
  7922. } else if (/^a(lt)?$/i.test(mod)) {
  7923. alt = true;
  7924. } else if (/^(c|ctrl|control)$/i.test(mod)) {
  7925. ctrl = true;
  7926. } else if (/^s(hift)?$/i.test(mod)) {
  7927. shift = true;
  7928. } else {
  7929. throw new Error("Unrecognized modifier name: " + mod);
  7930. }
  7931. }
  7932. if (alt) {
  7933. name = "Alt-" + name;
  7934. }
  7935. if (ctrl) {
  7936. name = "Ctrl-" + name;
  7937. }
  7938. if (cmd) {
  7939. name = "Cmd-" + name;
  7940. }
  7941. if (shift) {
  7942. name = "Shift-" + name;
  7943. }
  7944. return name;
  7945. }
  7946. // This is a kludge to keep keymaps mostly working as raw objects
  7947. // (backwards compatibility) while at the same time support features
  7948. // like normalization and multi-stroke key bindings. It compiles a
  7949. // new normalized keymap, and then updates the old object to reflect
  7950. // this.
  7951. function normalizeKeyMap(keymap) {
  7952. var copy = {};
  7953. for (var keyname in keymap) {
  7954. if (keymap.hasOwnProperty(keyname)) {
  7955. var value = keymap[keyname];
  7956. if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) {
  7957. continue;
  7958. }
  7959. if (value == "...") {
  7960. delete keymap[keyname];
  7961. continue;
  7962. }
  7963. var keys = map(keyname.split(" "), normalizeKeyName);
  7964. for (var i = 0; i < keys.length; i++) {
  7965. var val = void 0,
  7966. name = void 0;
  7967. if (i == keys.length - 1) {
  7968. name = keys.join(" ");
  7969. val = value;
  7970. } else {
  7971. name = keys.slice(0, i + 1).join(" ");
  7972. val = "...";
  7973. }
  7974. var prev = copy[name];
  7975. if (!prev) {
  7976. copy[name] = val;
  7977. } else if (prev != val) {
  7978. throw new Error("Inconsistent bindings for " + name);
  7979. }
  7980. }
  7981. delete keymap[keyname];
  7982. }
  7983. }
  7984. for (var prop in copy) {
  7985. keymap[prop] = copy[prop];
  7986. }
  7987. return keymap;
  7988. }
  7989. function lookupKey(key, map$$1, handle, context) {
  7990. map$$1 = getKeyMap(map$$1);
  7991. var found = map$$1.call ? map$$1.call(key, context) : map$$1[key];
  7992. if (found === false) {
  7993. return "nothing";
  7994. }
  7995. if (found === "...") {
  7996. return "multi";
  7997. }
  7998. if (found != null && handle(found)) {
  7999. return "handled";
  8000. }
  8001. if (map$$1.fallthrough) {
  8002. if (Object.prototype.toString.call(map$$1.fallthrough) != "[object Array]") {
  8003. return lookupKey(key, map$$1.fallthrough, handle, context);
  8004. }
  8005. for (var i = 0; i < map$$1.fallthrough.length; i++) {
  8006. var result = lookupKey(key, map$$1.fallthrough[i], handle, context);
  8007. if (result) {
  8008. return result;
  8009. }
  8010. }
  8011. }
  8012. }
  8013. // Modifier key presses don't count as 'real' key presses for the
  8014. // purpose of keymap fallthrough.
  8015. function isModifierKey(value) {
  8016. var name = typeof value == "string" ? value : keyNames[value.keyCode];
  8017. return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
  8018. }
  8019. function addModifierNames(name, event, noShift) {
  8020. var base = name;
  8021. if (event.altKey && base != "Alt") {
  8022. name = "Alt-" + name;
  8023. }
  8024. if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") {
  8025. name = "Ctrl-" + name;
  8026. }
  8027. if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") {
  8028. name = "Cmd-" + name;
  8029. }
  8030. if (!noShift && event.shiftKey && base != "Shift") {
  8031. name = "Shift-" + name;
  8032. }
  8033. return name;
  8034. }
  8035. // Look up the name of a key as indicated by an event object.
  8036. function keyName(event, noShift) {
  8037. if (presto && event.keyCode == 34 && event["char"]) {
  8038. return false;
  8039. }
  8040. var name = keyNames[event.keyCode];
  8041. if (name == null || event.altGraphKey) {
  8042. return false;
  8043. }
  8044. // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,
  8045. // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)
  8046. if (event.keyCode == 3 && event.code) {
  8047. name = event.code;
  8048. }
  8049. return addModifierNames(name, event, noShift);
  8050. }
  8051. function getKeyMap(val) {
  8052. return typeof val == "string" ? keyMap[val] : val;
  8053. }
  8054. // Helper for deleting text near the selection(s), used to implement
  8055. // backspace, delete, and similar functionality.
  8056. function deleteNearSelection(cm, compute) {
  8057. var ranges = cm.doc.sel.ranges,
  8058. kill = [];
  8059. // Build up a set of ranges to kill first, merging overlapping
  8060. // ranges.
  8061. for (var i = 0; i < ranges.length; i++) {
  8062. var toKill = compute(ranges[i]);
  8063. while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
  8064. var replaced = kill.pop();
  8065. if (cmp(replaced.from, toKill.from) < 0) {
  8066. toKill.from = replaced.from;
  8067. break;
  8068. }
  8069. }
  8070. kill.push(toKill);
  8071. }
  8072. // Next, remove those actual ranges.
  8073. runInOp(cm, function () {
  8074. for (var i = kill.length - 1; i >= 0; i--) {
  8075. _replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete");
  8076. }
  8077. ensureCursorVisible(cm);
  8078. });
  8079. }
  8080. function moveCharLogically(line, ch, dir) {
  8081. var target = skipExtendingChars(line.text, ch + dir, dir);
  8082. return target < 0 || target > line.text.length ? null : target;
  8083. }
  8084. function moveLogically(line, start, dir) {
  8085. var ch = moveCharLogically(line, start.ch, dir);
  8086. return ch == null ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before");
  8087. }
  8088. function endOfLine(visually, cm, lineObj, lineNo, dir) {
  8089. if (visually) {
  8090. var order = getOrder(lineObj, cm.doc.direction);
  8091. if (order) {
  8092. var part = dir < 0 ? lst(order) : order[0];
  8093. var moveInStorageOrder = dir < 0 == (part.level == 1);
  8094. var sticky = moveInStorageOrder ? "after" : "before";
  8095. var ch;
  8096. if (part.level > 0 || cm.doc.direction == "rtl") {
  8097. var prep = prepareMeasureForLine(cm, lineObj);
  8098. ch = dir < 0 ? lineObj.text.length - 1 : 0;
  8099. var targetTop = measureCharPrepared(cm, prep, ch).top;
  8100. ch = findFirst(function (ch) {
  8101. return measureCharPrepared(cm, prep, ch).top == targetTop;
  8102. }, dir < 0 == (part.level == 1) ? part.from : part.to - 1, ch);
  8103. if (sticky == "before") {
  8104. ch = moveCharLogically(lineObj, ch, 1);
  8105. }
  8106. } else {
  8107. ch = dir < 0 ? part.to : part.from;
  8108. }
  8109. return new Pos(lineNo, ch, sticky);
  8110. }
  8111. }
  8112. return new Pos(lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after");
  8113. }
  8114. function moveVisually(cm, line, start, dir) {
  8115. var bidi = getOrder(line, cm.doc.direction);
  8116. if (!bidi) {
  8117. return moveLogically(line, start, dir);
  8118. }
  8119. if (start.ch >= line.text.length) {
  8120. start.ch = line.text.length;
  8121. start.sticky = "before";
  8122. } else if (start.ch <= 0) {
  8123. start.ch = 0;
  8124. start.sticky = "after";
  8125. }
  8126. var partPos = getBidiPartAt(bidi, start.ch, start.sticky),
  8127. part = bidi[partPos];
  8128. if (cm.doc.direction == "ltr" && part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) {
  8129. // Case 1: We move within an ltr part in an ltr src. Even with wrapped lines,
  8130. // nothing interesting happens.
  8131. return moveLogically(line, start, dir);
  8132. }
  8133. var mv = function mv(pos, dir) {
  8134. return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir);
  8135. };
  8136. var prep;
  8137. var getWrappedLineExtent = function getWrappedLineExtent(ch) {
  8138. if (!cm.options.lineWrapping) {
  8139. return { begin: 0, end: line.text.length };
  8140. }
  8141. prep = prep || prepareMeasureForLine(cm, line);
  8142. return wrappedLineExtentChar(cm, line, prep, ch);
  8143. };
  8144. var wrappedLineExtent = getWrappedLineExtent(start.sticky == "before" ? mv(start, -1) : start.ch);
  8145. if (cm.doc.direction == "rtl" || part.level == 1) {
  8146. var moveInStorageOrder = part.level == 1 == dir < 0;
  8147. var ch = mv(start, moveInStorageOrder ? 1 : -1);
  8148. if (ch != null && (!moveInStorageOrder ? ch >= part.from && ch >= wrappedLineExtent.begin : ch <= part.to && ch <= wrappedLineExtent.end)) {
  8149. // Case 2: We move within an rtl part or in an rtl src on the same visual line
  8150. var sticky = moveInStorageOrder ? "before" : "after";
  8151. return new Pos(start.line, ch, sticky);
  8152. }
  8153. }
  8154. // Case 3: Could not move within this bidi part in this visual line, so leave
  8155. // the current bidi part
  8156. var searchInVisualLine = function searchInVisualLine(partPos, dir, wrappedLineExtent) {
  8157. var getRes = function getRes(ch, moveInStorageOrder) {
  8158. return moveInStorageOrder ? new Pos(start.line, mv(ch, 1), "before") : new Pos(start.line, ch, "after");
  8159. };
  8160. for (; partPos >= 0 && partPos < bidi.length; partPos += dir) {
  8161. var part = bidi[partPos];
  8162. var moveInStorageOrder = dir > 0 == (part.level != 1);
  8163. var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1);
  8164. if (part.from <= ch && ch < part.to) {
  8165. return getRes(ch, moveInStorageOrder);
  8166. }
  8167. ch = moveInStorageOrder ? part.from : mv(part.to, -1);
  8168. if (wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end) {
  8169. return getRes(ch, moveInStorageOrder);
  8170. }
  8171. }
  8172. };
  8173. // Case 3a: Look for other bidi parts on the same visual line
  8174. var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent);
  8175. if (res) {
  8176. return res;
  8177. }
  8178. // Case 3b: Look for other bidi parts on the next visual line
  8179. var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1);
  8180. if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) {
  8181. res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh));
  8182. if (res) {
  8183. return res;
  8184. }
  8185. }
  8186. // Case 4: Nowhere to move
  8187. return null;
  8188. }
  8189. // Commands are parameter-less actions that can be performed on an
  8190. // src, mostly used for keybindings.
  8191. var commands = {
  8192. selectAll: selectAll,
  8193. singleSelection: function singleSelection(cm) {
  8194. return cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll);
  8195. },
  8196. killLine: function killLine(cm) {
  8197. return deleteNearSelection(cm, function (range) {
  8198. if (range.empty()) {
  8199. var len = getLine(cm.doc, range.head.line).text.length;
  8200. if (range.head.ch == len && range.head.line < cm.lastLine()) {
  8201. return { from: range.head, to: Pos(range.head.line + 1, 0) };
  8202. } else {
  8203. return { from: range.head, to: Pos(range.head.line, len) };
  8204. }
  8205. } else {
  8206. return { from: range.from(), to: range.to() };
  8207. }
  8208. });
  8209. },
  8210. deleteLine: function deleteLine(cm) {
  8211. return deleteNearSelection(cm, function (range) {
  8212. return {
  8213. from: Pos(range.from().line, 0),
  8214. to: _clipPos(cm.doc, Pos(range.to().line + 1, 0))
  8215. };
  8216. });
  8217. },
  8218. delLineLeft: function delLineLeft(cm) {
  8219. return deleteNearSelection(cm, function (range) {
  8220. return {
  8221. from: Pos(range.from().line, 0), to: range.from()
  8222. };
  8223. });
  8224. },
  8225. delWrappedLineLeft: function delWrappedLineLeft(cm) {
  8226. return deleteNearSelection(cm, function (range) {
  8227. var top = cm.charCoords(range.head, "div").top + 5;
  8228. var leftPos = cm.coordsChar({ left: 0, top: top }, "div");
  8229. return { from: leftPos, to: range.from() };
  8230. });
  8231. },
  8232. delWrappedLineRight: function delWrappedLineRight(cm) {
  8233. return deleteNearSelection(cm, function (range) {
  8234. var top = cm.charCoords(range.head, "div").top + 5;
  8235. var rightPos = cm.coordsChar({ left: cm.display.lineDiv.offsetWidth + 100, top: top }, "div");
  8236. return { from: range.from(), to: rightPos };
  8237. });
  8238. },
  8239. undo: function undo(cm) {
  8240. return cm.undo();
  8241. },
  8242. redo: function redo(cm) {
  8243. return cm.redo();
  8244. },
  8245. undoSelection: function undoSelection(cm) {
  8246. return cm.undoSelection();
  8247. },
  8248. redoSelection: function redoSelection(cm) {
  8249. return cm.redoSelection();
  8250. },
  8251. goDocStart: function goDocStart(cm) {
  8252. return cm.extendSelection(Pos(cm.firstLine(), 0));
  8253. },
  8254. goDocEnd: function goDocEnd(cm) {
  8255. return cm.extendSelection(Pos(cm.lastLine()));
  8256. },
  8257. goLineStart: function goLineStart(cm) {
  8258. return cm.extendSelectionsBy(function (range) {
  8259. return lineStart(cm, range.head.line);
  8260. }, { origin: "+move", bias: 1 });
  8261. },
  8262. goLineStartSmart: function goLineStartSmart(cm) {
  8263. return cm.extendSelectionsBy(function (range) {
  8264. return lineStartSmart(cm, range.head);
  8265. }, { origin: "+move", bias: 1 });
  8266. },
  8267. goLineEnd: function goLineEnd(cm) {
  8268. return cm.extendSelectionsBy(function (range) {
  8269. return lineEnd(cm, range.head.line);
  8270. }, { origin: "+move", bias: -1 });
  8271. },
  8272. goLineRight: function goLineRight(cm) {
  8273. return cm.extendSelectionsBy(function (range) {
  8274. var top = cm.cursorCoords(range.head, "div").top + 5;
  8275. return cm.coordsChar({ left: cm.display.lineDiv.offsetWidth + 100, top: top }, "div");
  8276. }, sel_move);
  8277. },
  8278. goLineLeft: function goLineLeft(cm) {
  8279. return cm.extendSelectionsBy(function (range) {
  8280. var top = cm.cursorCoords(range.head, "div").top + 5;
  8281. return cm.coordsChar({ left: 0, top: top }, "div");
  8282. }, sel_move);
  8283. },
  8284. goLineLeftSmart: function goLineLeftSmart(cm) {
  8285. return cm.extendSelectionsBy(function (range) {
  8286. var top = cm.cursorCoords(range.head, "div").top + 5;
  8287. var pos = cm.coordsChar({ left: 0, top: top }, "div");
  8288. if (pos.ch < cm.getLine(pos.line).search(/\S/)) {
  8289. return lineStartSmart(cm, range.head);
  8290. }
  8291. return pos;
  8292. }, sel_move);
  8293. },
  8294. goLineUp: function goLineUp(cm) {
  8295. return cm.moveV(-1, "line");
  8296. },
  8297. goLineDown: function goLineDown(cm) {
  8298. return cm.moveV(1, "line");
  8299. },
  8300. goPageUp: function goPageUp(cm) {
  8301. return cm.moveV(-1, "page");
  8302. },
  8303. goPageDown: function goPageDown(cm) {
  8304. return cm.moveV(1, "page");
  8305. },
  8306. goCharLeft: function goCharLeft(cm) {
  8307. return cm.moveH(-1, "char");
  8308. },
  8309. goCharRight: function goCharRight(cm) {
  8310. return cm.moveH(1, "char");
  8311. },
  8312. goColumnLeft: function goColumnLeft(cm) {
  8313. return cm.moveH(-1, "column");
  8314. },
  8315. goColumnRight: function goColumnRight(cm) {
  8316. return cm.moveH(1, "column");
  8317. },
  8318. goWordLeft: function goWordLeft(cm) {
  8319. return cm.moveH(-1, "word");
  8320. },
  8321. goGroupRight: function goGroupRight(cm) {
  8322. return cm.moveH(1, "group");
  8323. },
  8324. goGroupLeft: function goGroupLeft(cm) {
  8325. return cm.moveH(-1, "group");
  8326. },
  8327. goWordRight: function goWordRight(cm) {
  8328. return cm.moveH(1, "word");
  8329. },
  8330. delCharBefore: function delCharBefore(cm) {
  8331. return cm.deleteH(-1, "char");
  8332. },
  8333. delCharAfter: function delCharAfter(cm) {
  8334. return cm.deleteH(1, "char");
  8335. },
  8336. delWordBefore: function delWordBefore(cm) {
  8337. return cm.deleteH(-1, "word");
  8338. },
  8339. delWordAfter: function delWordAfter(cm) {
  8340. return cm.deleteH(1, "word");
  8341. },
  8342. delGroupBefore: function delGroupBefore(cm) {
  8343. return cm.deleteH(-1, "group");
  8344. },
  8345. delGroupAfter: function delGroupAfter(cm) {
  8346. return cm.deleteH(1, "group");
  8347. },
  8348. indentAuto: function indentAuto(cm) {
  8349. return cm.indentSelection("smart");
  8350. },
  8351. indentMore: function indentMore(cm) {
  8352. return cm.indentSelection("add");
  8353. },
  8354. indentLess: function indentLess(cm) {
  8355. return cm.indentSelection("subtract");
  8356. },
  8357. insertTab: function insertTab(cm) {
  8358. return cm.replaceSelection("\t");
  8359. },
  8360. insertSoftTab: function insertSoftTab(cm) {
  8361. var spaces = [],
  8362. ranges = cm.listSelections(),
  8363. tabSize = cm.options.tabSize;
  8364. for (var i = 0; i < ranges.length; i++) {
  8365. var pos = ranges[i].from();
  8366. var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
  8367. spaces.push(spaceStr(tabSize - col % tabSize));
  8368. }
  8369. cm.replaceSelections(spaces);
  8370. },
  8371. defaultTab: function defaultTab(cm) {
  8372. if (cm.somethingSelected()) {
  8373. cm.indentSelection("add");
  8374. } else {
  8375. cm.execCommand("insertTab");
  8376. }
  8377. },
  8378. // Swap the two chars left and right of each selection's head.
  8379. // Move cursor behind the two swapped characters afterwards.
  8380. //
  8381. // Doesn't consider line feeds a character.
  8382. // Doesn't scan more than one line above to find a character.
  8383. // Doesn't do anything on an empty line.
  8384. // Doesn't do anything with non-empty selections.
  8385. transposeChars: function transposeChars(cm) {
  8386. return runInOp(cm, function () {
  8387. var ranges = cm.listSelections(),
  8388. newSel = [];
  8389. for (var i = 0; i < ranges.length; i++) {
  8390. if (!ranges[i].empty()) {
  8391. continue;
  8392. }
  8393. var cur = ranges[i].head,
  8394. line = getLine(cm.doc, cur.line).text;
  8395. if (line) {
  8396. if (cur.ch == line.length) {
  8397. cur = new Pos(cur.line, cur.ch - 1);
  8398. }
  8399. if (cur.ch > 0) {
  8400. cur = new Pos(cur.line, cur.ch + 1);
  8401. cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2), Pos(cur.line, cur.ch - 2), cur, "+transpose");
  8402. } else if (cur.line > cm.doc.first) {
  8403. var prev = getLine(cm.doc, cur.line - 1).text;
  8404. if (prev) {
  8405. cur = new Pos(cur.line, 1);
  8406. cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() + prev.charAt(prev.length - 1), Pos(cur.line - 1, prev.length - 1), cur, "+transpose");
  8407. }
  8408. }
  8409. }
  8410. newSel.push(new Range(cur, cur));
  8411. }
  8412. cm.setSelections(newSel);
  8413. });
  8414. },
  8415. newlineAndIndent: function newlineAndIndent(cm) {
  8416. return runInOp(cm, function () {
  8417. var sels = cm.listSelections();
  8418. for (var i = sels.length - 1; i >= 0; i--) {
  8419. cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input");
  8420. }
  8421. sels = cm.listSelections();
  8422. for (var i$1 = 0; i$1 < sels.length; i$1++) {
  8423. cm.indentLine(sels[i$1].from().line, null, true);
  8424. }
  8425. ensureCursorVisible(cm);
  8426. });
  8427. },
  8428. openLine: function openLine(cm) {
  8429. return cm.replaceSelection("\n", "start");
  8430. },
  8431. toggleOverwrite: function toggleOverwrite(cm) {
  8432. return cm.toggleOverwrite();
  8433. }
  8434. };
  8435. function lineStart(cm, lineN) {
  8436. var line = getLine(cm.doc, lineN);
  8437. var visual = visualLine(line);
  8438. if (visual != line) {
  8439. lineN = lineNo(visual);
  8440. }
  8441. return endOfLine(true, cm, visual, lineN, 1);
  8442. }
  8443. function lineEnd(cm, lineN) {
  8444. var line = getLine(cm.doc, lineN);
  8445. var visual = visualLineEnd(line);
  8446. if (visual != line) {
  8447. lineN = lineNo(visual);
  8448. }
  8449. return endOfLine(true, cm, line, lineN, -1);
  8450. }
  8451. function lineStartSmart(cm, pos) {
  8452. var start = lineStart(cm, pos.line);
  8453. var line = getLine(cm.doc, start.line);
  8454. var order = getOrder(line, cm.doc.direction);
  8455. if (!order || order[0].level == 0) {
  8456. var firstNonWS = Math.max(0, line.text.search(/\S/));
  8457. var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;
  8458. return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky);
  8459. }
  8460. return start;
  8461. }
  8462. // Run a handler that was bound to a key.
  8463. function doHandleBinding(cm, bound, dropShift) {
  8464. if (typeof bound == "string") {
  8465. bound = commands[bound];
  8466. if (!bound) {
  8467. return false;
  8468. }
  8469. }
  8470. // Ensure previous input has been read, so that the handler sees a
  8471. // consistent view of the document
  8472. cm.display.input.ensurePolled();
  8473. var prevShift = cm.display.shift,
  8474. done = false;
  8475. try {
  8476. if (cm.isReadOnly()) {
  8477. cm.state.suppressEdits = true;
  8478. }
  8479. if (dropShift) {
  8480. cm.display.shift = false;
  8481. }
  8482. done = bound(cm) != Pass;
  8483. } finally {
  8484. cm.display.shift = prevShift;
  8485. cm.state.suppressEdits = false;
  8486. }
  8487. return done;
  8488. }
  8489. function lookupKeyForEditor(cm, name, handle) {
  8490. for (var i = 0; i < cm.state.keyMaps.length; i++) {
  8491. var result = lookupKey(name, cm.state.keyMaps[i], handle, cm);
  8492. if (result) {
  8493. return result;
  8494. }
  8495. }
  8496. return cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm) || lookupKey(name, cm.options.keyMap, handle, cm);
  8497. }
  8498. // Note that, despite the name, this function is also used to check
  8499. // for bound mouse clicks.
  8500. var stopSeq = new Delayed();
  8501. function dispatchKey(cm, name, e, handle) {
  8502. var seq = cm.state.keySeq;
  8503. if (seq) {
  8504. if (isModifierKey(name)) {
  8505. return "handled";
  8506. }
  8507. if (/\'$/.test(name)) {
  8508. cm.state.keySeq = null;
  8509. } else {
  8510. stopSeq.set(50, function () {
  8511. if (cm.state.keySeq == seq) {
  8512. cm.state.keySeq = null;
  8513. cm.display.input.reset();
  8514. }
  8515. });
  8516. }
  8517. if (dispatchKeyInner(cm, seq + " " + name, e, handle)) {
  8518. return true;
  8519. }
  8520. }
  8521. return dispatchKeyInner(cm, name, e, handle);
  8522. }
  8523. function dispatchKeyInner(cm, name, e, handle) {
  8524. var result = lookupKeyForEditor(cm, name, handle);
  8525. if (result == "multi") {
  8526. cm.state.keySeq = name;
  8527. }
  8528. if (result == "handled") {
  8529. signalLater(cm, "keyHandled", cm, name, e);
  8530. }
  8531. if (result == "handled" || result == "multi") {
  8532. e_preventDefault(e);
  8533. restartBlink(cm);
  8534. }
  8535. return !!result;
  8536. }
  8537. // Handle a key from the keydown event.
  8538. function handleKeyBinding(cm, e) {
  8539. var name = keyName(e, true);
  8540. if (!name) {
  8541. return false;
  8542. }
  8543. if (e.shiftKey && !cm.state.keySeq) {
  8544. // First try to resolve full name (including 'Shift-'). Failing
  8545. // that, see if there is a cursor-motion command (starting with
  8546. // 'go') bound to the keyname without 'Shift-'.
  8547. return dispatchKey(cm, "Shift-" + name, e, function (b) {
  8548. return doHandleBinding(cm, b, true);
  8549. }) || dispatchKey(cm, name, e, function (b) {
  8550. if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion) {
  8551. return doHandleBinding(cm, b);
  8552. }
  8553. });
  8554. } else {
  8555. return dispatchKey(cm, name, e, function (b) {
  8556. return doHandleBinding(cm, b);
  8557. });
  8558. }
  8559. }
  8560. // Handle a key from the keypress event
  8561. function handleCharBinding(cm, e, ch) {
  8562. return dispatchKey(cm, "'" + ch + "'", e, function (b) {
  8563. return doHandleBinding(cm, b, true);
  8564. });
  8565. }
  8566. var lastStoppedKey = null;
  8567. function onKeyDown(e) {
  8568. var cm = this;
  8569. cm.curOp.focus = activeElt();
  8570. if (signalDOMEvent(cm, e)) {
  8571. return;
  8572. }
  8573. // IE does strange things with escape.
  8574. if (ie && ie_version < 11 && e.keyCode == 27) {
  8575. e.returnValue = false;
  8576. }
  8577. var code = e.keyCode;
  8578. cm.display.shift = code == 16 || e.shiftKey;
  8579. var handled = handleKeyBinding(cm, e);
  8580. if (presto) {
  8581. lastStoppedKey = handled ? code : null;
  8582. // Opera has no cut event... we try to at least catch the key combo
  8583. if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey)) {
  8584. cm.replaceSelection("", null, "cut");
  8585. }
  8586. }
  8587. // Turn mouse into crosshair when Alt is held on Mac.
  8588. if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className)) {
  8589. showCrossHair(cm);
  8590. }
  8591. }
  8592. function showCrossHair(cm) {
  8593. var lineDiv = cm.display.lineDiv;
  8594. addClass(lineDiv, "CodeMirror-crosshair");
  8595. function up(e) {
  8596. if (e.keyCode == 18 || !e.altKey) {
  8597. rmClass(lineDiv, "CodeMirror-crosshair");
  8598. off(document, "keyup", up);
  8599. off(document, "mouseover", up);
  8600. }
  8601. }
  8602. on(document, "keyup", up);
  8603. on(document, "mouseover", up);
  8604. }
  8605. function onKeyUp(e) {
  8606. if (e.keyCode == 16) {
  8607. this.doc.sel.shift = false;
  8608. }
  8609. signalDOMEvent(this, e);
  8610. }
  8611. function onKeyPress(e) {
  8612. var cm = this;
  8613. if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) {
  8614. return;
  8615. }
  8616. var keyCode = e.keyCode,
  8617. charCode = e.charCode;
  8618. if (presto && keyCode == lastStoppedKey) {
  8619. lastStoppedKey = null;
  8620. e_preventDefault(e);
  8621. return;
  8622. }
  8623. if (presto && (!e.which || e.which < 10) && handleKeyBinding(cm, e)) {
  8624. return;
  8625. }
  8626. var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
  8627. // Some browsers fire keypress events for backspace
  8628. if (ch == "\x08") {
  8629. return;
  8630. }
  8631. if (handleCharBinding(cm, e, ch)) {
  8632. return;
  8633. }
  8634. cm.display.input.onKeyPress(e);
  8635. }
  8636. var DOUBLECLICK_DELAY = 400;
  8637. var PastClick = function PastClick(time, pos, button) {
  8638. this.time = time;
  8639. this.pos = pos;
  8640. this.button = button;
  8641. };
  8642. PastClick.prototype.compare = function (time, pos, button) {
  8643. return this.time + DOUBLECLICK_DELAY > time && cmp(pos, this.pos) == 0 && button == this.button;
  8644. };
  8645. var lastClick, lastDoubleClick;
  8646. function clickRepeat(pos, button) {
  8647. var now = +new Date();
  8648. if (lastDoubleClick && lastDoubleClick.compare(now, pos, button)) {
  8649. lastClick = lastDoubleClick = null;
  8650. return "triple";
  8651. } else if (lastClick && lastClick.compare(now, pos, button)) {
  8652. lastDoubleClick = new PastClick(now, pos, button);
  8653. lastClick = null;
  8654. return "double";
  8655. } else {
  8656. lastClick = new PastClick(now, pos, button);
  8657. lastDoubleClick = null;
  8658. return "single";
  8659. }
  8660. }
  8661. // A mouse down can be a single click, double click, triple click,
  8662. // start of selection drag, start of text drag, new cursor
  8663. // (ctrl-click), rectangle drag (alt-drag), or xwin
  8664. // middle-click-paste. Or it might be a click on something we should
  8665. // not interfere with, such as a scrollbar or widget.
  8666. function onMouseDown(e) {
  8667. var cm = this,
  8668. display = cm.display;
  8669. if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) {
  8670. return;
  8671. }
  8672. display.input.ensurePolled();
  8673. display.shift = e.shiftKey;
  8674. if (eventInWidget(display, e)) {
  8675. if (!webkit) {
  8676. // Briefly turn off draggability, to allow widgets to do
  8677. // normal dragging things.
  8678. display.scroller.draggable = false;
  8679. setTimeout(function () {
  8680. return display.scroller.draggable = true;
  8681. }, 100);
  8682. }
  8683. return;
  8684. }
  8685. if (clickInGutter(cm, e)) {
  8686. return;
  8687. }
  8688. var pos = posFromMouse(cm, e),
  8689. button = e_button(e),
  8690. repeat = pos ? clickRepeat(pos, button) : "single";
  8691. window.focus();
  8692. // #3261: make sure, that we're not starting a second selection
  8693. if (button == 1 && cm.state.selectingText) {
  8694. cm.state.selectingText(e);
  8695. }
  8696. if (pos && handleMappedButton(cm, button, pos, repeat, e)) {
  8697. return;
  8698. }
  8699. if (button == 1) {
  8700. if (pos) {
  8701. leftButtonDown(cm, pos, repeat, e);
  8702. } else if (e_target(e) == display.scroller) {
  8703. e_preventDefault(e);
  8704. }
  8705. } else if (button == 2) {
  8706. if (pos) {
  8707. extendSelection(cm.doc, pos);
  8708. }
  8709. setTimeout(function () {
  8710. return display.input.focus();
  8711. }, 20);
  8712. } else if (button == 3) {
  8713. if (captureRightClick) {
  8714. cm.display.input.onContextMenu(e);
  8715. } else {
  8716. delayBlurEvent(cm);
  8717. }
  8718. }
  8719. }
  8720. function handleMappedButton(cm, button, pos, repeat, event) {
  8721. var name = "Click";
  8722. if (repeat == "double") {
  8723. name = "Double" + name;
  8724. } else if (repeat == "triple") {
  8725. name = "Triple" + name;
  8726. }
  8727. name = (button == 1 ? "Left" : button == 2 ? "Middle" : "Right") + name;
  8728. return dispatchKey(cm, addModifierNames(name, event), event, function (bound) {
  8729. if (typeof bound == "string") {
  8730. bound = commands[bound];
  8731. }
  8732. if (!bound) {
  8733. return false;
  8734. }
  8735. var done = false;
  8736. try {
  8737. if (cm.isReadOnly()) {
  8738. cm.state.suppressEdits = true;
  8739. }
  8740. done = bound(cm, pos) != Pass;
  8741. } finally {
  8742. cm.state.suppressEdits = false;
  8743. }
  8744. return done;
  8745. });
  8746. }
  8747. function configureMouse(cm, repeat, event) {
  8748. var option = cm.getOption("configureMouse");
  8749. var value = option ? option(cm, repeat, event) : {};
  8750. if (value.unit == null) {
  8751. var rect = chromeOS ? event.shiftKey && event.metaKey : event.altKey;
  8752. value.unit = rect ? "rectangle" : repeat == "single" ? "char" : repeat == "double" ? "word" : "line";
  8753. }
  8754. if (value.extend == null || cm.doc.extend) {
  8755. value.extend = cm.doc.extend || event.shiftKey;
  8756. }
  8757. if (value.addNew == null) {
  8758. value.addNew = mac ? event.metaKey : event.ctrlKey;
  8759. }
  8760. if (value.moveOnDrag == null) {
  8761. value.moveOnDrag = !(mac ? event.altKey : event.ctrlKey);
  8762. }
  8763. return value;
  8764. }
  8765. function leftButtonDown(cm, pos, repeat, event) {
  8766. if (ie) {
  8767. setTimeout(bind(ensureFocus, cm), 0);
  8768. } else {
  8769. cm.curOp.focus = activeElt();
  8770. }
  8771. var behavior = configureMouse(cm, repeat, event);
  8772. var sel = cm.doc.sel,
  8773. contained;
  8774. if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() && repeat == "single" && (contained = sel.contains(pos)) > -1 && (cmp((contained = sel.ranges[contained]).from(), pos) < 0 || pos.xRel > 0) && (cmp(contained.to(), pos) > 0 || pos.xRel < 0)) {
  8775. leftButtonStartDrag(cm, event, pos, behavior);
  8776. } else {
  8777. leftButtonSelect(cm, event, pos, behavior);
  8778. }
  8779. }
  8780. // Start a text drag. When it ends, see if any dragging actually
  8781. // happen, and treat as a click if it didn't.
  8782. function leftButtonStartDrag(cm, event, pos, behavior) {
  8783. var display = cm.display,
  8784. moved = false;
  8785. var dragEnd = operation(cm, function (e) {
  8786. if (webkit) {
  8787. display.scroller.draggable = false;
  8788. }
  8789. cm.state.draggingText = false;
  8790. off(display.wrapper.ownerDocument, "mouseup", dragEnd);
  8791. off(display.wrapper.ownerDocument, "mousemove", mouseMove);
  8792. off(display.scroller, "dragstart", dragStart);
  8793. off(display.scroller, "drop", dragEnd);
  8794. if (!moved) {
  8795. e_preventDefault(e);
  8796. if (!behavior.addNew) {
  8797. extendSelection(cm.doc, pos, null, null, behavior.extend);
  8798. }
  8799. // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
  8800. if (webkit || ie && ie_version == 9) {
  8801. setTimeout(function () {
  8802. display.wrapper.ownerDocument.body.focus();
  8803. display.input.focus();
  8804. }, 20);
  8805. } else {
  8806. display.input.focus();
  8807. }
  8808. }
  8809. });
  8810. var mouseMove = function mouseMove(e2) {
  8811. moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clientY - e2.clientY) >= 10;
  8812. };
  8813. var dragStart = function dragStart() {
  8814. return moved = true;
  8815. };
  8816. // Let the drag handler handle this.
  8817. if (webkit) {
  8818. display.scroller.draggable = true;
  8819. }
  8820. cm.state.draggingText = dragEnd;
  8821. dragEnd.copy = !behavior.moveOnDrag;
  8822. // IE's approach to draggable
  8823. if (display.scroller.dragDrop) {
  8824. display.scroller.dragDrop();
  8825. }
  8826. on(display.wrapper.ownerDocument, "mouseup", dragEnd);
  8827. on(display.wrapper.ownerDocument, "mousemove", mouseMove);
  8828. on(display.scroller, "dragstart", dragStart);
  8829. on(display.scroller, "drop", dragEnd);
  8830. delayBlurEvent(cm);
  8831. setTimeout(function () {
  8832. return display.input.focus();
  8833. }, 20);
  8834. }
  8835. function rangeForUnit(cm, pos, unit) {
  8836. if (unit == "char") {
  8837. return new Range(pos, pos);
  8838. }
  8839. if (unit == "word") {
  8840. return cm.findWordAt(pos);
  8841. }
  8842. if (unit == "line") {
  8843. return new Range(Pos(pos.line, 0), _clipPos(cm.doc, Pos(pos.line + 1, 0)));
  8844. }
  8845. var result = unit(cm, pos);
  8846. return new Range(result.from, result.to);
  8847. }
  8848. // Normal selection, as opposed to text dragging.
  8849. function leftButtonSelect(cm, event, start, behavior) {
  8850. var display = cm.display,
  8851. doc = cm.doc;
  8852. e_preventDefault(event);
  8853. var ourRange,
  8854. ourIndex,
  8855. startSel = doc.sel,
  8856. ranges = startSel.ranges;
  8857. if (behavior.addNew && !behavior.extend) {
  8858. ourIndex = doc.sel.contains(start);
  8859. if (ourIndex > -1) {
  8860. ourRange = ranges[ourIndex];
  8861. } else {
  8862. ourRange = new Range(start, start);
  8863. }
  8864. } else {
  8865. ourRange = doc.sel.primary();
  8866. ourIndex = doc.sel.primIndex;
  8867. }
  8868. if (behavior.unit == "rectangle") {
  8869. if (!behavior.addNew) {
  8870. ourRange = new Range(start, start);
  8871. }
  8872. start = posFromMouse(cm, event, true, true);
  8873. ourIndex = -1;
  8874. } else {
  8875. var range$$1 = rangeForUnit(cm, start, behavior.unit);
  8876. if (behavior.extend) {
  8877. ourRange = extendRange(ourRange, range$$1.anchor, range$$1.head, behavior.extend);
  8878. } else {
  8879. ourRange = range$$1;
  8880. }
  8881. }
  8882. if (!behavior.addNew) {
  8883. ourIndex = 0;
  8884. setSelection(doc, new Selection([ourRange], 0), sel_mouse);
  8885. startSel = doc.sel;
  8886. } else if (ourIndex == -1) {
  8887. ourIndex = ranges.length;
  8888. setSelection(doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex), { scroll: false, origin: "*mouse" });
  8889. } else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) {
  8890. setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0), { scroll: false, origin: "*mouse" });
  8891. startSel = doc.sel;
  8892. } else {
  8893. replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
  8894. }
  8895. var lastPos = start;
  8896. function extendTo(pos) {
  8897. if (cmp(lastPos, pos) == 0) {
  8898. return;
  8899. }
  8900. lastPos = pos;
  8901. if (behavior.unit == "rectangle") {
  8902. var ranges = [],
  8903. tabSize = cm.options.tabSize;
  8904. var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
  8905. var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
  8906. var left = Math.min(startCol, posCol),
  8907. right = Math.max(startCol, posCol);
  8908. for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line)); line <= end; line++) {
  8909. var text = getLine(doc, line).text,
  8910. leftPos = findColumn(text, left, tabSize);
  8911. if (left == right) {
  8912. ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos)));
  8913. } else if (text.length > leftPos) {
  8914. ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize))));
  8915. }
  8916. }
  8917. if (!ranges.length) {
  8918. ranges.push(new Range(start, start));
  8919. }
  8920. setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), { origin: "*mouse", scroll: false });
  8921. cm.scrollIntoView(pos);
  8922. } else {
  8923. var oldRange = ourRange;
  8924. var range$$1 = rangeForUnit(cm, pos, behavior.unit);
  8925. var anchor = oldRange.anchor,
  8926. head;
  8927. if (cmp(range$$1.anchor, anchor) > 0) {
  8928. head = range$$1.head;
  8929. anchor = minPos(oldRange.from(), range$$1.anchor);
  8930. } else {
  8931. head = range$$1.anchor;
  8932. anchor = maxPos(oldRange.to(), range$$1.head);
  8933. }
  8934. var ranges$1 = startSel.ranges.slice(0);
  8935. ranges$1[ourIndex] = bidiSimplify(cm, new Range(_clipPos(doc, anchor), head));
  8936. setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
  8937. }
  8938. }
  8939. var editorSize = display.wrapper.getBoundingClientRect();
  8940. // Used to ensure timeout re-tries don't fire when another extend
  8941. // happened in the meantime (clearTimeout isn't reliable -- at
  8942. // least on Chrome, the timeouts still happen even when cleared,
  8943. // if the clear happens after their scheduled firing time).
  8944. var counter = 0;
  8945. function extend(e) {
  8946. var curCount = ++counter;
  8947. var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle");
  8948. if (!cur) {
  8949. return;
  8950. }
  8951. if (cmp(cur, lastPos) != 0) {
  8952. cm.curOp.focus = activeElt();
  8953. extendTo(cur);
  8954. var visible = visibleLines(display, doc);
  8955. if (cur.line >= visible.to || cur.line < visible.from) {
  8956. setTimeout(operation(cm, function () {
  8957. if (counter == curCount) {
  8958. extend(e);
  8959. }
  8960. }), 150);
  8961. }
  8962. } else {
  8963. var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
  8964. if (outside) {
  8965. setTimeout(operation(cm, function () {
  8966. if (counter != curCount) {
  8967. return;
  8968. }
  8969. display.scroller.scrollTop += outside;
  8970. extend(e);
  8971. }), 50);
  8972. }
  8973. }
  8974. }
  8975. function done(e) {
  8976. cm.state.selectingText = false;
  8977. counter = Infinity;
  8978. // If e is null or undefined we interpret this as someone trying
  8979. // to explicitly cancel the selection rather than the user
  8980. // letting go of the mouse button.
  8981. if (e) {
  8982. e_preventDefault(e);
  8983. display.input.focus();
  8984. }
  8985. off(display.wrapper.ownerDocument, "mousemove", move);
  8986. off(display.wrapper.ownerDocument, "mouseup", up);
  8987. doc.history.lastSelOrigin = null;
  8988. }
  8989. var move = operation(cm, function (e) {
  8990. if (e.buttons === 0 || !e_button(e)) {
  8991. done(e);
  8992. } else {
  8993. extend(e);
  8994. }
  8995. });
  8996. var up = operation(cm, done);
  8997. cm.state.selectingText = up;
  8998. on(display.wrapper.ownerDocument, "mousemove", move);
  8999. on(display.wrapper.ownerDocument, "mouseup", up);
  9000. }
  9001. // Used when mouse-selecting to adjust the anchor to the proper side
  9002. // of a bidi jump depending on the visual position of the head.
  9003. function bidiSimplify(cm, range$$1) {
  9004. var anchor = range$$1.anchor;
  9005. var head = range$$1.head;
  9006. var anchorLine = getLine(cm.doc, anchor.line);
  9007. if (cmp(anchor, head) == 0 && anchor.sticky == head.sticky) {
  9008. return range$$1;
  9009. }
  9010. var order = getOrder(anchorLine);
  9011. if (!order) {
  9012. return range$$1;
  9013. }
  9014. var index = getBidiPartAt(order, anchor.ch, anchor.sticky),
  9015. part = order[index];
  9016. if (part.from != anchor.ch && part.to != anchor.ch) {
  9017. return range$$1;
  9018. }
  9019. var boundary = index + (part.from == anchor.ch == (part.level != 1) ? 0 : 1);
  9020. if (boundary == 0 || boundary == order.length) {
  9021. return range$$1;
  9022. }
  9023. // Compute the relative visual position of the head compared to the
  9024. // anchor (<0 is to the left, >0 to the right)
  9025. var leftSide;
  9026. if (head.line != anchor.line) {
  9027. leftSide = (head.line - anchor.line) * (cm.doc.direction == "ltr" ? 1 : -1) > 0;
  9028. } else {
  9029. var headIndex = getBidiPartAt(order, head.ch, head.sticky);
  9030. var dir = headIndex - index || (head.ch - anchor.ch) * (part.level == 1 ? -1 : 1);
  9031. if (headIndex == boundary - 1 || headIndex == boundary) {
  9032. leftSide = dir < 0;
  9033. } else {
  9034. leftSide = dir > 0;
  9035. }
  9036. }
  9037. var usePart = order[boundary + (leftSide ? -1 : 0)];
  9038. var from = leftSide == (usePart.level == 1);
  9039. var ch = from ? usePart.from : usePart.to,
  9040. sticky = from ? "after" : "before";
  9041. return anchor.ch == ch && anchor.sticky == sticky ? range$$1 : new Range(new Pos(anchor.line, ch, sticky), head);
  9042. }
  9043. // Determines whether an event happened in the gutter, and fires the
  9044. // handlers for the corresponding event.
  9045. function gutterEvent(cm, e, type, prevent) {
  9046. var mX, mY;
  9047. if (e.touches) {
  9048. mX = e.touches[0].clientX;
  9049. mY = e.touches[0].clientY;
  9050. } else {
  9051. try {
  9052. mX = e.clientX;
  9053. mY = e.clientY;
  9054. } catch (e) {
  9055. return false;
  9056. }
  9057. }
  9058. if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) {
  9059. return false;
  9060. }
  9061. if (prevent) {
  9062. e_preventDefault(e);
  9063. }
  9064. var display = cm.display;
  9065. var lineBox = display.lineDiv.getBoundingClientRect();
  9066. if (mY > lineBox.bottom || !hasHandler(cm, type)) {
  9067. return e_defaultPrevented(e);
  9068. }
  9069. mY -= lineBox.top - display.viewOffset;
  9070. for (var i = 0; i < cm.display.gutterSpecs.length; ++i) {
  9071. var g = display.gutters.childNodes[i];
  9072. if (g && g.getBoundingClientRect().right >= mX) {
  9073. var line = _lineAtHeight(cm.doc, mY);
  9074. var gutter = cm.display.gutterSpecs[i];
  9075. signal(cm, type, cm, line, gutter.className, e);
  9076. return e_defaultPrevented(e);
  9077. }
  9078. }
  9079. }
  9080. function clickInGutter(cm, e) {
  9081. return gutterEvent(cm, e, "gutterClick", true);
  9082. }
  9083. // CONTEXT MENU HANDLING
  9084. // To make the context menu work, we need to briefly unhide the
  9085. // textarea (making it as unobtrusive as possible) to let the
  9086. // right-click take effect on it.
  9087. function onContextMenu(cm, e) {
  9088. if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) {
  9089. return;
  9090. }
  9091. if (signalDOMEvent(cm, e, "contextmenu")) {
  9092. return;
  9093. }
  9094. if (!captureRightClick) {
  9095. cm.display.input.onContextMenu(e);
  9096. }
  9097. }
  9098. function contextMenuInGutter(cm, e) {
  9099. if (!hasHandler(cm, "gutterContextMenu")) {
  9100. return false;
  9101. }
  9102. return gutterEvent(cm, e, "gutterContextMenu", false);
  9103. }
  9104. function themeChanged(cm) {
  9105. cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
  9106. clearCaches(cm);
  9107. }
  9108. var Init = {
  9109. toString: function toString() {
  9110. return "CodeMirror.Init";
  9111. }
  9112. };
  9113. var defaults = {};
  9114. var optionHandlers = {};
  9115. function defineOptions(CodeMirror) {
  9116. var optionHandlers = CodeMirror.optionHandlers;
  9117. function option(name, deflt, handle, notOnInit) {
  9118. CodeMirror.defaults[name] = deflt;
  9119. if (handle) {
  9120. optionHandlers[name] = notOnInit ? function (cm, val, old) {
  9121. if (old != Init) {
  9122. handle(cm, val, old);
  9123. }
  9124. } : handle;
  9125. }
  9126. }
  9127. CodeMirror.defineOption = option;
  9128. // Passed to option handlers when there is no old value.
  9129. CodeMirror.Init = Init;
  9130. // These two are, on init, called from the constructor because they
  9131. // have to be initialized before the src can start at all.
  9132. option("value", "", function (cm, val) {
  9133. return cm.setValue(val);
  9134. }, true);
  9135. option("mode", null, function (cm, val) {
  9136. cm.doc.modeOption = val;
  9137. loadMode(cm);
  9138. }, true);
  9139. option("indentUnit", 2, loadMode, true);
  9140. option("indentWithTabs", false);
  9141. option("smartIndent", true);
  9142. option("tabSize", 4, function (cm) {
  9143. resetModeState(cm);
  9144. clearCaches(cm);
  9145. regChange(cm);
  9146. }, true);
  9147. option("lineSeparator", null, function (cm, val) {
  9148. cm.doc.lineSep = val;
  9149. if (!val) {
  9150. return;
  9151. }
  9152. var newBreaks = [],
  9153. lineNo = cm.doc.first;
  9154. cm.doc.iter(function (line) {
  9155. for (var pos = 0;;) {
  9156. var found = line.text.indexOf(val, pos);
  9157. if (found == -1) {
  9158. break;
  9159. }
  9160. pos = found + val.length;
  9161. newBreaks.push(Pos(lineNo, found));
  9162. }
  9163. lineNo++;
  9164. });
  9165. for (var i = newBreaks.length - 1; i >= 0; i--) {
  9166. _replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length));
  9167. }
  9168. });
  9169. option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) {
  9170. cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
  9171. if (old != Init) {
  9172. cm.refresh();
  9173. }
  9174. });
  9175. option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) {
  9176. return cm.refresh();
  9177. }, true);
  9178. option("electricChars", true);
  9179. option("inputStyle", mobile ? "contenteditable" : "textarea", function () {
  9180. throw new Error("inputStyle can not (yet) be changed in a running src"); // FIXME
  9181. }, true);
  9182. option("spellcheck", false, function (cm, val) {
  9183. return cm.getInputField().spellcheck = val;
  9184. }, true);
  9185. option("autocorrect", false, function (cm, val) {
  9186. return cm.getInputField().autocorrect = val;
  9187. }, true);
  9188. option("autocapitalize", false, function (cm, val) {
  9189. return cm.getInputField().autocapitalize = val;
  9190. }, true);
  9191. option("rtlMoveVisually", !windows);
  9192. option("wholeLineUpdateBefore", true);
  9193. option("theme", "default", function (cm) {
  9194. themeChanged(cm);
  9195. updateGutters(cm);
  9196. }, true);
  9197. option("keyMap", "default", function (cm, val, old) {
  9198. var next = getKeyMap(val);
  9199. var prev = old != Init && getKeyMap(old);
  9200. if (prev && prev.detach) {
  9201. prev.detach(cm, next);
  9202. }
  9203. if (next.attach) {
  9204. next.attach(cm, prev || null);
  9205. }
  9206. });
  9207. option("extraKeys", null);
  9208. option("configureMouse", null);
  9209. option("lineWrapping", false, wrappingChanged, true);
  9210. option("gutters", [], function (cm, val) {
  9211. cm.display.gutterSpecs = getGutters(val, cm.options.lineNumbers);
  9212. updateGutters(cm);
  9213. }, true);
  9214. option("fixedGutter", true, function (cm, val) {
  9215. cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
  9216. cm.refresh();
  9217. }, true);
  9218. option("coverGutterNextToScrollbar", false, function (cm) {
  9219. return updateScrollbars(cm);
  9220. }, true);
  9221. option("scrollbarStyle", "native", function (cm) {
  9222. initScrollbars(cm);
  9223. updateScrollbars(cm);
  9224. cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);
  9225. cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft);
  9226. }, true);
  9227. option("lineNumbers", false, function (cm, val) {
  9228. cm.display.gutterSpecs = getGutters(cm.options.gutters, val);
  9229. updateGutters(cm);
  9230. }, true);
  9231. option("firstLineNumber", 1, updateGutters, true);
  9232. option("lineNumberFormatter", function (integer) {
  9233. return integer;
  9234. }, updateGutters, true);
  9235. option("showCursorWhenSelecting", false, updateSelection, true);
  9236. option("resetSelectionOnContextMenu", true);
  9237. option("lineWiseCopyCut", true);
  9238. option("pasteLinesPerSelection", true);
  9239. option("selectionsMayTouch", false);
  9240. option("readOnly", false, function (cm, val) {
  9241. if (val == "nocursor") {
  9242. onBlur(cm);
  9243. cm.display.input.blur();
  9244. }
  9245. cm.display.input.readOnlyChanged(val);
  9246. });
  9247. option("disableInput", false, function (cm, val) {
  9248. if (!val) {
  9249. cm.display.input.reset();
  9250. }
  9251. }, true);
  9252. option("dragDrop", true, dragDropChanged);
  9253. option("allowDropFileTypes", null);
  9254. option("cursorBlinkRate", 530);
  9255. option("cursorScrollMargin", 0);
  9256. option("cursorHeight", 1, updateSelection, true);
  9257. option("singleCursorHeightPerLine", true, updateSelection, true);
  9258. option("workTime", 100);
  9259. option("workDelay", 100);
  9260. option("flattenSpans", true, resetModeState, true);
  9261. option("addModeClass", false, resetModeState, true);
  9262. option("pollInterval", 100);
  9263. option("undoDepth", 200, function (cm, val) {
  9264. return cm.doc.history.undoDepth = val;
  9265. });
  9266. option("historyEventDelay", 1250);
  9267. option("viewportMargin", 10, function (cm) {
  9268. return cm.refresh();
  9269. }, true);
  9270. option("maxHighlightLength", 10000, resetModeState, true);
  9271. option("moveInputWithCursor", true, function (cm, val) {
  9272. if (!val) {
  9273. cm.display.input.resetPosition();
  9274. }
  9275. });
  9276. option("tabindex", null, function (cm, val) {
  9277. return cm.display.input.getField().tabIndex = val || "";
  9278. });
  9279. option("autofocus", null);
  9280. option("direction", "ltr", function (cm, val) {
  9281. return cm.doc.setDirection(val);
  9282. }, true);
  9283. option("phrases", null);
  9284. }
  9285. function dragDropChanged(cm, value, old) {
  9286. var wasOn = old && old != Init;
  9287. if (!value != !wasOn) {
  9288. var funcs = cm.display.dragFunctions;
  9289. var toggle = value ? on : off;
  9290. toggle(cm.display.scroller, "dragstart", funcs.start);
  9291. toggle(cm.display.scroller, "dragenter", funcs.enter);
  9292. toggle(cm.display.scroller, "dragover", funcs.over);
  9293. toggle(cm.display.scroller, "dragleave", funcs.leave);
  9294. toggle(cm.display.scroller, "drop", funcs.drop);
  9295. }
  9296. }
  9297. function wrappingChanged(cm) {
  9298. if (cm.options.lineWrapping) {
  9299. addClass(cm.display.wrapper, "CodeMirror-wrap");
  9300. cm.display.sizer.style.minWidth = "";
  9301. cm.display.sizerWidth = null;
  9302. } else {
  9303. rmClass(cm.display.wrapper, "CodeMirror-wrap");
  9304. findMaxLine(cm);
  9305. }
  9306. estimateLineHeights(cm);
  9307. regChange(cm);
  9308. clearCaches(cm);
  9309. setTimeout(function () {
  9310. return updateScrollbars(cm);
  9311. }, 100);
  9312. }
  9313. // A CodeMirror instance represents an src. This is the object
  9314. // that user code is usually dealing with.
  9315. function CodeMirror(place, options) {
  9316. var this$1 = this;
  9317. if (!(this instanceof CodeMirror)) {
  9318. return new CodeMirror(place, options);
  9319. }
  9320. this.options = options = options ? copyObj(options) : {};
  9321. // Determine effective options based on given values and defaults.
  9322. copyObj(defaults, options, false);
  9323. var doc = options.value;
  9324. if (typeof doc == "string") {
  9325. doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction);
  9326. } else if (options.mode) {
  9327. doc.modeOption = options.mode;
  9328. }
  9329. this.doc = doc;
  9330. var input = new CodeMirror.inputStyles[options.inputStyle](this);
  9331. var display = this.display = new Display(place, doc, input, options);
  9332. display.wrapper.CodeMirror = this;
  9333. themeChanged(this);
  9334. if (options.lineWrapping) {
  9335. this.display.wrapper.className += " CodeMirror-wrap";
  9336. }
  9337. initScrollbars(this);
  9338. this.state = {
  9339. keyMaps: [], // stores maps added by addKeyMap
  9340. overlays: [], // highlighting overlays, as added by addOverlay
  9341. modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
  9342. overwrite: false,
  9343. delayingBlurEvent: false,
  9344. focused: false,
  9345. suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
  9346. pasteIncoming: -1, cutIncoming: -1, // help recognize paste/cut edits in input.poll
  9347. selectingText: false,
  9348. draggingText: false,
  9349. highlight: new Delayed(), // stores highlight worker timeout
  9350. keySeq: null, // Unfinished key sequence
  9351. specialChars: null
  9352. };
  9353. if (options.autofocus && !mobile) {
  9354. display.input.focus();
  9355. }
  9356. // Override magic textarea content restore that IE sometimes does
  9357. // on our hidden textarea on reload
  9358. if (ie && ie_version < 11) {
  9359. setTimeout(function () {
  9360. return this$1.display.input.reset(true);
  9361. }, 20);
  9362. }
  9363. registerEventHandlers(this);
  9364. ensureGlobalHandlers();
  9365. _startOperation(this);
  9366. this.curOp.forceUpdate = true;
  9367. attachDoc(this, doc);
  9368. if (options.autofocus && !mobile || this.hasFocus()) {
  9369. setTimeout(bind(onFocus, this), 20);
  9370. } else {
  9371. onBlur(this);
  9372. }
  9373. for (var opt in optionHandlers) {
  9374. if (optionHandlers.hasOwnProperty(opt)) {
  9375. optionHandlers[opt](this$1, options[opt], Init);
  9376. }
  9377. }
  9378. maybeUpdateLineNumberWidth(this);
  9379. if (options.finishInit) {
  9380. options.finishInit(this);
  9381. }
  9382. for (var i = 0; i < initHooks.length; ++i) {
  9383. initHooks[i](this$1);
  9384. }
  9385. _endOperation(this);
  9386. // Suppress optimizelegibility in Webkit, since it breaks text
  9387. // measuring on line wrapping boundaries.
  9388. if (webkit && options.lineWrapping && getComputedStyle(display.lineDiv).textRendering == "optimizelegibility") {
  9389. display.lineDiv.style.textRendering = "auto";
  9390. }
  9391. if (options.onload) {
  9392. options.onload(this);
  9393. }
  9394. }
  9395. // The default configuration options.
  9396. CodeMirror.defaults = defaults;
  9397. // Functions to run when options are changed.
  9398. CodeMirror.optionHandlers = optionHandlers;
  9399. // Attach the necessary event handlers when initializing the src
  9400. function registerEventHandlers(cm) {
  9401. var d = cm.display;
  9402. on(d.scroller, "mousedown", operation(cm, onMouseDown));
  9403. // Older IE's will not fire a second mousedown for a double click
  9404. if (ie && ie_version < 11) {
  9405. on(d.scroller, "dblclick", operation(cm, function (e) {
  9406. if (signalDOMEvent(cm, e)) {
  9407. return;
  9408. }
  9409. var pos = posFromMouse(cm, e);
  9410. if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) {
  9411. return;
  9412. }
  9413. e_preventDefault(e);
  9414. var word = cm.findWordAt(pos);
  9415. extendSelection(cm.doc, word.anchor, word.head);
  9416. }));
  9417. } else {
  9418. on(d.scroller, "dblclick", function (e) {
  9419. return signalDOMEvent(cm, e) || e_preventDefault(e);
  9420. });
  9421. }
  9422. // Some browsers fire contextmenu *after* opening the menu, at
  9423. // which point we can't mess with it anymore. Context menu is
  9424. // handled in onMouseDown for these browsers.
  9425. on(d.scroller, "contextmenu", function (e) {
  9426. return onContextMenu(cm, e);
  9427. });
  9428. // Used to suppress mouse event handling when a touch happens
  9429. var touchFinished,
  9430. prevTouch = { end: 0 };
  9431. function finishTouch() {
  9432. if (d.activeTouch) {
  9433. touchFinished = setTimeout(function () {
  9434. return d.activeTouch = null;
  9435. }, 1000);
  9436. prevTouch = d.activeTouch;
  9437. prevTouch.end = +new Date();
  9438. }
  9439. }
  9440. function isMouseLikeTouchEvent(e) {
  9441. if (e.touches.length != 1) {
  9442. return false;
  9443. }
  9444. var touch = e.touches[0];
  9445. return touch.radiusX <= 1 && touch.radiusY <= 1;
  9446. }
  9447. function farAway(touch, other) {
  9448. if (other.left == null) {
  9449. return true;
  9450. }
  9451. var dx = other.left - touch.left,
  9452. dy = other.top - touch.top;
  9453. return dx * dx + dy * dy > 20 * 20;
  9454. }
  9455. on(d.scroller, "touchstart", function (e) {
  9456. if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e) && !clickInGutter(cm, e)) {
  9457. d.input.ensurePolled();
  9458. clearTimeout(touchFinished);
  9459. var now = +new Date();
  9460. d.activeTouch = {
  9461. start: now, moved: false,
  9462. prev: now - prevTouch.end <= 300 ? prevTouch : null
  9463. };
  9464. if (e.touches.length == 1) {
  9465. d.activeTouch.left = e.touches[0].pageX;
  9466. d.activeTouch.top = e.touches[0].pageY;
  9467. }
  9468. }
  9469. });
  9470. on(d.scroller, "touchmove", function () {
  9471. if (d.activeTouch) {
  9472. d.activeTouch.moved = true;
  9473. }
  9474. });
  9475. on(d.scroller, "touchend", function (e) {
  9476. var touch = d.activeTouch;
  9477. if (touch && !eventInWidget(d, e) && touch.left != null && !touch.moved && new Date() - touch.start < 300) {
  9478. var pos = cm.coordsChar(d.activeTouch, "page"),
  9479. range;
  9480. if (!touch.prev || farAway(touch, touch.prev)) // Single tap
  9481. {
  9482. range = new Range(pos, pos);
  9483. } else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
  9484. {
  9485. range = cm.findWordAt(pos);
  9486. } else // Triple tap
  9487. {
  9488. range = new Range(Pos(pos.line, 0), _clipPos(cm.doc, Pos(pos.line + 1, 0)));
  9489. }
  9490. cm.setSelection(range.anchor, range.head);
  9491. cm.focus();
  9492. e_preventDefault(e);
  9493. }
  9494. finishTouch();
  9495. });
  9496. on(d.scroller, "touchcancel", finishTouch);
  9497. // Sync scrolling between fake scrollbars and real scrollable
  9498. // area, ensure viewport is updated when scrolling.
  9499. on(d.scroller, "scroll", function () {
  9500. if (d.scroller.clientHeight) {
  9501. updateScrollTop(cm, d.scroller.scrollTop);
  9502. setScrollLeft(cm, d.scroller.scrollLeft, true);
  9503. signal(cm, "scroll", cm);
  9504. }
  9505. });
  9506. // Listen to wheel events in order to try and update the viewport on time.
  9507. on(d.scroller, "mousewheel", function (e) {
  9508. return onScrollWheel(cm, e);
  9509. });
  9510. on(d.scroller, "DOMMouseScroll", function (e) {
  9511. return onScrollWheel(cm, e);
  9512. });
  9513. // Prevent wrapper from ever scrolling
  9514. on(d.wrapper, "scroll", function () {
  9515. return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0;
  9516. });
  9517. d.dragFunctions = {
  9518. enter: function enter(e) {
  9519. if (!signalDOMEvent(cm, e)) {
  9520. e_stop(e);
  9521. }
  9522. },
  9523. over: function over(e) {
  9524. if (!signalDOMEvent(cm, e)) {
  9525. onDragOver(cm, e);
  9526. e_stop(e);
  9527. }
  9528. },
  9529. start: function start(e) {
  9530. return onDragStart(cm, e);
  9531. },
  9532. drop: operation(cm, onDrop),
  9533. leave: function leave(e) {
  9534. if (!signalDOMEvent(cm, e)) {
  9535. clearDragCursor(cm);
  9536. }
  9537. }
  9538. };
  9539. var inp = d.input.getField();
  9540. on(inp, "keyup", function (e) {
  9541. return onKeyUp.call(cm, e);
  9542. });
  9543. on(inp, "keydown", operation(cm, onKeyDown));
  9544. on(inp, "keypress", operation(cm, onKeyPress));
  9545. on(inp, "focus", function (e) {
  9546. return onFocus(cm, e);
  9547. });
  9548. on(inp, "blur", function (e) {
  9549. return onBlur(cm, e);
  9550. });
  9551. }
  9552. var initHooks = [];
  9553. CodeMirror.defineInitHook = function (f) {
  9554. return initHooks.push(f);
  9555. };
  9556. // Indent the given line. The how parameter can be "smart",
  9557. // "add"/null, "subtract", or "prev". When aggressive is false
  9558. // (typically set to true for forced single-line indents), empty
  9559. // lines are not indented, and places where the mode returns Pass
  9560. // are left alone.
  9561. function indentLine(cm, n, how, aggressive) {
  9562. var doc = cm.doc,
  9563. state;
  9564. if (how == null) {
  9565. how = "add";
  9566. }
  9567. if (how == "smart") {
  9568. // Fall back to "prev" when the mode doesn't have an indentation
  9569. // method.
  9570. if (!doc.mode.indent) {
  9571. how = "prev";
  9572. } else {
  9573. state = getContextBefore(cm, n).state;
  9574. }
  9575. }
  9576. var tabSize = cm.options.tabSize;
  9577. var line = getLine(doc, n),
  9578. curSpace = countColumn(line.text, null, tabSize);
  9579. if (line.stateAfter) {
  9580. line.stateAfter = null;
  9581. }
  9582. var curSpaceString = line.text.match(/^\s*/)[0],
  9583. indentation;
  9584. if (!aggressive && !/\S/.test(line.text)) {
  9585. indentation = 0;
  9586. how = "not";
  9587. } else if (how == "smart") {
  9588. indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
  9589. if (indentation == Pass || indentation > 150) {
  9590. if (!aggressive) {
  9591. return;
  9592. }
  9593. how = "prev";
  9594. }
  9595. }
  9596. if (how == "prev") {
  9597. if (n > doc.first) {
  9598. indentation = countColumn(getLine(doc, n - 1).text, null, tabSize);
  9599. } else {
  9600. indentation = 0;
  9601. }
  9602. } else if (how == "add") {
  9603. indentation = curSpace + cm.options.indentUnit;
  9604. } else if (how == "subtract") {
  9605. indentation = curSpace - cm.options.indentUnit;
  9606. } else if (typeof how == "number") {
  9607. indentation = curSpace + how;
  9608. }
  9609. indentation = Math.max(0, indentation);
  9610. var indentString = "",
  9611. pos = 0;
  9612. if (cm.options.indentWithTabs) {
  9613. for (var i = Math.floor(indentation / tabSize); i; --i) {
  9614. pos += tabSize;
  9615. indentString += "\t";
  9616. }
  9617. }
  9618. if (pos < indentation) {
  9619. indentString += spaceStr(indentation - pos);
  9620. }
  9621. if (indentString != curSpaceString) {
  9622. _replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
  9623. line.stateAfter = null;
  9624. return true;
  9625. } else {
  9626. // Ensure that, if the cursor was in the whitespace at the start
  9627. // of the line, it is moved to the end of that space.
  9628. for (var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++) {
  9629. var range = doc.sel.ranges[i$1];
  9630. if (range.head.line == n && range.head.ch < curSpaceString.length) {
  9631. var pos$1 = Pos(n, curSpaceString.length);
  9632. replaceOneSelection(doc, i$1, new Range(pos$1, pos$1));
  9633. break;
  9634. }
  9635. }
  9636. }
  9637. }
  9638. // This will be set to a {lineWise: bool, text: [string]} object, so
  9639. // that, when pasting, we know what kind of selections the copied
  9640. // text was made out of.
  9641. var lastCopied = null;
  9642. function setLastCopied(newLastCopied) {
  9643. lastCopied = newLastCopied;
  9644. }
  9645. function applyTextInput(cm, inserted, deleted, sel, origin) {
  9646. var doc = cm.doc;
  9647. cm.display.shift = false;
  9648. if (!sel) {
  9649. sel = doc.sel;
  9650. }
  9651. var recent = +new Date() - 200;
  9652. var paste = origin == "paste" || cm.state.pasteIncoming > recent;
  9653. var textLines = splitLinesAuto(inserted),
  9654. multiPaste = null;
  9655. // When pasting N lines into N selections, insert one line per selection
  9656. if (paste && sel.ranges.length > 1) {
  9657. if (lastCopied && lastCopied.text.join("\n") == inserted) {
  9658. if (sel.ranges.length % lastCopied.text.length == 0) {
  9659. multiPaste = [];
  9660. for (var i = 0; i < lastCopied.text.length; i++) {
  9661. multiPaste.push(doc.splitLines(lastCopied.text[i]));
  9662. }
  9663. }
  9664. } else if (textLines.length == sel.ranges.length && cm.options.pasteLinesPerSelection) {
  9665. multiPaste = map(textLines, function (l) {
  9666. return [l];
  9667. });
  9668. }
  9669. }
  9670. var updateInput = cm.curOp.updateInput;
  9671. // Normal behavior is to insert the new text into every selection
  9672. for (var i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--) {
  9673. var range$$1 = sel.ranges[i$1];
  9674. var from = range$$1.from(),
  9675. to = range$$1.to();
  9676. if (range$$1.empty()) {
  9677. if (deleted && deleted > 0) // Handle deletion
  9678. {
  9679. from = Pos(from.line, from.ch - deleted);
  9680. } else if (cm.state.overwrite && !paste) // Handle overwrite
  9681. {
  9682. to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
  9683. } else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted) {
  9684. from = to = Pos(from.line, 0);
  9685. }
  9686. }
  9687. var changeEvent = {
  9688. from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines,
  9689. origin: origin || (paste ? "paste" : cm.state.cutIncoming > recent ? "cut" : "+input")
  9690. };
  9691. makeChange(cm.doc, changeEvent);
  9692. signalLater(cm, "inputRead", cm, changeEvent);
  9693. }
  9694. if (inserted && !paste) {
  9695. triggerElectric(cm, inserted);
  9696. }
  9697. ensureCursorVisible(cm);
  9698. if (cm.curOp.updateInput < 2) {
  9699. cm.curOp.updateInput = updateInput;
  9700. }
  9701. cm.curOp.typing = true;
  9702. cm.state.pasteIncoming = cm.state.cutIncoming = -1;
  9703. }
  9704. function handlePaste(e, cm) {
  9705. var pasted = e.clipboardData && e.clipboardData.getData("Text");
  9706. if (pasted) {
  9707. e.preventDefault();
  9708. if (!cm.isReadOnly() && !cm.options.disableInput) {
  9709. runInOp(cm, function () {
  9710. return applyTextInput(cm, pasted, 0, null, "paste");
  9711. });
  9712. }
  9713. return true;
  9714. }
  9715. }
  9716. function triggerElectric(cm, inserted) {
  9717. // When an 'electric' character is inserted, immediately trigger a reindent
  9718. if (!cm.options.electricChars || !cm.options.smartIndent) {
  9719. return;
  9720. }
  9721. var sel = cm.doc.sel;
  9722. for (var i = sel.ranges.length - 1; i >= 0; i--) {
  9723. var range$$1 = sel.ranges[i];
  9724. if (range$$1.head.ch > 100 || i && sel.ranges[i - 1].head.line == range$$1.head.line) {
  9725. continue;
  9726. }
  9727. var mode = cm.getModeAt(range$$1.head);
  9728. var indented = false;
  9729. if (mode.electricChars) {
  9730. for (var j = 0; j < mode.electricChars.length; j++) {
  9731. if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
  9732. indented = indentLine(cm, range$$1.head.line, "smart");
  9733. break;
  9734. }
  9735. }
  9736. } else if (mode.electricInput) {
  9737. if (mode.electricInput.test(getLine(cm.doc, range$$1.head.line).text.slice(0, range$$1.head.ch))) {
  9738. indented = indentLine(cm, range$$1.head.line, "smart");
  9739. }
  9740. }
  9741. if (indented) {
  9742. signalLater(cm, "electricInput", cm, range$$1.head.line);
  9743. }
  9744. }
  9745. }
  9746. function copyableRanges(cm) {
  9747. var text = [],
  9748. ranges = [];
  9749. for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
  9750. var line = cm.doc.sel.ranges[i].head.line;
  9751. var lineRange = { anchor: Pos(line, 0), head: Pos(line + 1, 0) };
  9752. ranges.push(lineRange);
  9753. text.push(cm.getRange(lineRange.anchor, lineRange.head));
  9754. }
  9755. return { text: text, ranges: ranges };
  9756. }
  9757. function disableBrowserMagic(field, spellcheck, autocorrect, autocapitalize) {
  9758. field.setAttribute("autocorrect", autocorrect ? "" : "off");
  9759. field.setAttribute("autocapitalize", autocapitalize ? "" : "off");
  9760. field.setAttribute("spellcheck", !!spellcheck);
  9761. }
  9762. function hiddenTextarea() {
  9763. var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none");
  9764. var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
  9765. // The textarea is kept positioned near the cursor to prevent the
  9766. // fact that it'll be scrolled into view on input from scrolling
  9767. // our fake cursor out of view. On webkit, when wrap=off, paste is
  9768. // very slow. So make the area wide instead.
  9769. if (webkit) {
  9770. te.style.width = "1000px";
  9771. } else {
  9772. te.setAttribute("wrap", "off");
  9773. }
  9774. // If border: 0; -- iOS fails to open keyboard (issue #1287)
  9775. if (ios) {
  9776. te.style.border = "1px solid black";
  9777. }
  9778. disableBrowserMagic(te);
  9779. return div;
  9780. }
  9781. // The publicly visible API. Note that methodOp(f) means
  9782. // 'wrap f in an operation, performed on its `this` parameter'.
  9783. // This is not the complete set of src methods. Most of the
  9784. // methods defined on the Doc type are also injected into
  9785. // CodeMirror.prototype, for backwards compatibility and
  9786. // convenience.
  9787. function addEditorMethods(CodeMirror) {
  9788. var optionHandlers = CodeMirror.optionHandlers;
  9789. var helpers = CodeMirror.helpers = {};
  9790. CodeMirror.prototype = {
  9791. constructor: CodeMirror,
  9792. focus: function focus() {
  9793. window.focus();
  9794. this.display.input.focus();
  9795. },
  9796. setOption: function setOption(option, value) {
  9797. var options = this.options,
  9798. old = options[option];
  9799. if (options[option] == value && option != "mode") {
  9800. return;
  9801. }
  9802. options[option] = value;
  9803. if (optionHandlers.hasOwnProperty(option)) {
  9804. operation(this, optionHandlers[option])(this, value, old);
  9805. }
  9806. signal(this, "optionChange", this, option);
  9807. },
  9808. getOption: function getOption(option) {
  9809. return this.options[option];
  9810. },
  9811. getDoc: function getDoc() {
  9812. return this.doc;
  9813. },
  9814. addKeyMap: function addKeyMap(map$$1, bottom) {
  9815. this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map$$1));
  9816. },
  9817. removeKeyMap: function removeKeyMap(map$$1) {
  9818. var maps = this.state.keyMaps;
  9819. for (var i = 0; i < maps.length; ++i) {
  9820. if (maps[i] == map$$1 || maps[i].name == map$$1) {
  9821. maps.splice(i, 1);
  9822. return true;
  9823. }
  9824. }
  9825. },
  9826. addOverlay: methodOp(function (spec, options) {
  9827. var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
  9828. if (mode.startState) {
  9829. throw new Error("Overlays may not be stateful.");
  9830. }
  9831. insertSorted(this.state.overlays, {
  9832. mode: mode, modeSpec: spec, opaque: options && options.opaque,
  9833. priority: options && options.priority || 0
  9834. }, function (overlay) {
  9835. return overlay.priority;
  9836. });
  9837. this.state.modeGen++;
  9838. regChange(this);
  9839. }),
  9840. removeOverlay: methodOp(function (spec) {
  9841. var this$1 = this;
  9842. var overlays = this.state.overlays;
  9843. for (var i = 0; i < overlays.length; ++i) {
  9844. var cur = overlays[i].modeSpec;
  9845. if (cur == spec || typeof spec == "string" && cur.name == spec) {
  9846. overlays.splice(i, 1);
  9847. this$1.state.modeGen++;
  9848. regChange(this$1);
  9849. return;
  9850. }
  9851. }
  9852. }),
  9853. indentLine: methodOp(function (n, dir, aggressive) {
  9854. if (typeof dir != "string" && typeof dir != "number") {
  9855. if (dir == null) {
  9856. dir = this.options.smartIndent ? "smart" : "prev";
  9857. } else {
  9858. dir = dir ? "add" : "subtract";
  9859. }
  9860. }
  9861. if (isLine(this.doc, n)) {
  9862. indentLine(this, n, dir, aggressive);
  9863. }
  9864. }),
  9865. indentSelection: methodOp(function (how) {
  9866. var this$1 = this;
  9867. var ranges = this.doc.sel.ranges,
  9868. end = -1;
  9869. for (var i = 0; i < ranges.length; i++) {
  9870. var range$$1 = ranges[i];
  9871. if (!range$$1.empty()) {
  9872. var from = range$$1.from(),
  9873. to = range$$1.to();
  9874. var start = Math.max(end, from.line);
  9875. end = Math.min(this$1.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;
  9876. for (var j = start; j < end; ++j) {
  9877. indentLine(this$1, j, how);
  9878. }
  9879. var newRanges = this$1.doc.sel.ranges;
  9880. if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0) {
  9881. replaceOneSelection(this$1.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll);
  9882. }
  9883. } else if (range$$1.head.line > end) {
  9884. indentLine(this$1, range$$1.head.line, how, true);
  9885. end = range$$1.head.line;
  9886. if (i == this$1.doc.sel.primIndex) {
  9887. ensureCursorVisible(this$1);
  9888. }
  9889. }
  9890. }
  9891. }),
  9892. // Fetch the parser token for a given character. Useful for hacks
  9893. // that want to inspect the mode state (say, for completion).
  9894. getTokenAt: function getTokenAt(pos, precise) {
  9895. return takeToken(this, pos, precise);
  9896. },
  9897. getLineTokens: function getLineTokens(line, precise) {
  9898. return takeToken(this, Pos(line), precise, true);
  9899. },
  9900. getTokenTypeAt: function getTokenTypeAt(pos) {
  9901. pos = _clipPos(this.doc, pos);
  9902. var styles = getLineStyles(this, getLine(this.doc, pos.line));
  9903. var before = 0,
  9904. after = (styles.length - 1) / 2,
  9905. ch = pos.ch;
  9906. var type;
  9907. if (ch == 0) {
  9908. type = styles[2];
  9909. } else {
  9910. for (;;) {
  9911. var mid = before + after >> 1;
  9912. if ((mid ? styles[mid * 2 - 1] : 0) >= ch) {
  9913. after = mid;
  9914. } else if (styles[mid * 2 + 1] < ch) {
  9915. before = mid + 1;
  9916. } else {
  9917. type = styles[mid * 2 + 2];
  9918. break;
  9919. }
  9920. }
  9921. }
  9922. var cut = type ? type.indexOf("overlay ") : -1;
  9923. return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1);
  9924. },
  9925. getModeAt: function getModeAt(pos) {
  9926. var mode = this.doc.mode;
  9927. if (!mode.innerMode) {
  9928. return mode;
  9929. }
  9930. return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode;
  9931. },
  9932. getHelper: function getHelper(pos, type) {
  9933. return this.getHelpers(pos, type)[0];
  9934. },
  9935. getHelpers: function getHelpers(pos, type) {
  9936. var this$1 = this;
  9937. var found = [];
  9938. if (!helpers.hasOwnProperty(type)) {
  9939. return found;
  9940. }
  9941. var help = helpers[type],
  9942. mode = this.getModeAt(pos);
  9943. if (typeof mode[type] == "string") {
  9944. if (help[mode[type]]) {
  9945. found.push(help[mode[type]]);
  9946. }
  9947. } else if (mode[type]) {
  9948. for (var i = 0; i < mode[type].length; i++) {
  9949. var val = help[mode[type][i]];
  9950. if (val) {
  9951. found.push(val);
  9952. }
  9953. }
  9954. } else if (mode.helperType && help[mode.helperType]) {
  9955. found.push(help[mode.helperType]);
  9956. } else if (help[mode.name]) {
  9957. found.push(help[mode.name]);
  9958. }
  9959. for (var i$1 = 0; i$1 < help._global.length; i$1++) {
  9960. var cur = help._global[i$1];
  9961. if (cur.pred(mode, this$1) && indexOf(found, cur.val) == -1) {
  9962. found.push(cur.val);
  9963. }
  9964. }
  9965. return found;
  9966. },
  9967. getStateAfter: function getStateAfter(line, precise) {
  9968. var doc = this.doc;
  9969. line = clipLine(doc, line == null ? doc.first + doc.size - 1 : line);
  9970. return getContextBefore(this, line + 1, precise).state;
  9971. },
  9972. cursorCoords: function cursorCoords(start, mode) {
  9973. var pos,
  9974. range$$1 = this.doc.sel.primary();
  9975. if (start == null) {
  9976. pos = range$$1.head;
  9977. } else if ((typeof start === "undefined" ? "undefined" : _typeof(start)) == "object") {
  9978. pos = _clipPos(this.doc, start);
  9979. } else {
  9980. pos = start ? range$$1.from() : range$$1.to();
  9981. }
  9982. return _cursorCoords(this, pos, mode || "page");
  9983. },
  9984. charCoords: function charCoords(pos, mode) {
  9985. return _charCoords(this, _clipPos(this.doc, pos), mode || "page");
  9986. },
  9987. coordsChar: function coordsChar(coords, mode) {
  9988. coords = fromCoordSystem(this, coords, mode || "page");
  9989. return _coordsChar(this, coords.left, coords.top);
  9990. },
  9991. lineAtHeight: function lineAtHeight(height, mode) {
  9992. height = fromCoordSystem(this, { top: height, left: 0 }, mode || "page").top;
  9993. return _lineAtHeight(this.doc, height + this.display.viewOffset);
  9994. },
  9995. heightAtLine: function heightAtLine(line, mode, includeWidgets) {
  9996. var end = false,
  9997. lineObj;
  9998. if (typeof line == "number") {
  9999. var last = this.doc.first + this.doc.size - 1;
  10000. if (line < this.doc.first) {
  10001. line = this.doc.first;
  10002. } else if (line > last) {
  10003. line = last;
  10004. end = true;
  10005. }
  10006. lineObj = getLine(this.doc, line);
  10007. } else {
  10008. lineObj = line;
  10009. }
  10010. return intoCoordSystem(this, lineObj, { top: 0, left: 0 }, mode || "page", includeWidgets || end).top + (end ? this.doc.height - _heightAtLine(lineObj) : 0);
  10011. },
  10012. defaultTextHeight: function defaultTextHeight() {
  10013. return textHeight(this.display);
  10014. },
  10015. defaultCharWidth: function defaultCharWidth() {
  10016. return charWidth(this.display);
  10017. },
  10018. getViewport: function getViewport() {
  10019. return { from: this.display.viewFrom, to: this.display.viewTo };
  10020. },
  10021. addWidget: function addWidget(pos, node, scroll, vert, horiz) {
  10022. var display = this.display;
  10023. pos = _cursorCoords(this, _clipPos(this.doc, pos));
  10024. var top = pos.bottom,
  10025. left = pos.left;
  10026. node.style.position = "absolute";
  10027. node.setAttribute("cm-ignore-events", "true");
  10028. this.display.input.setUneditable(node);
  10029. display.sizer.appendChild(node);
  10030. if (vert == "over") {
  10031. top = pos.top;
  10032. } else if (vert == "above" || vert == "near") {
  10033. var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
  10034. hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
  10035. // Default to positioning above (if specified and possible); otherwise default to positioning below
  10036. if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight) {
  10037. top = pos.top - node.offsetHeight;
  10038. } else if (pos.bottom + node.offsetHeight <= vspace) {
  10039. top = pos.bottom;
  10040. }
  10041. if (left + node.offsetWidth > hspace) {
  10042. left = hspace - node.offsetWidth;
  10043. }
  10044. }
  10045. node.style.top = top + "px";
  10046. node.style.left = node.style.right = "";
  10047. if (horiz == "right") {
  10048. left = display.sizer.clientWidth - node.offsetWidth;
  10049. node.style.right = "0px";
  10050. } else {
  10051. if (horiz == "left") {
  10052. left = 0;
  10053. } else if (horiz == "middle") {
  10054. left = (display.sizer.clientWidth - node.offsetWidth) / 2;
  10055. }
  10056. node.style.left = left + "px";
  10057. }
  10058. if (scroll) {
  10059. scrollIntoView(this, {
  10060. left: left,
  10061. top: top,
  10062. right: left + node.offsetWidth,
  10063. bottom: top + node.offsetHeight
  10064. });
  10065. }
  10066. },
  10067. triggerOnKeyDown: methodOp(onKeyDown),
  10068. triggerOnKeyPress: methodOp(onKeyPress),
  10069. triggerOnKeyUp: onKeyUp,
  10070. triggerOnMouseDown: methodOp(onMouseDown),
  10071. execCommand: function execCommand(cmd) {
  10072. if (commands.hasOwnProperty(cmd)) {
  10073. return commands[cmd].call(null, this);
  10074. }
  10075. },
  10076. triggerElectric: methodOp(function (text) {
  10077. triggerElectric(this, text);
  10078. }),
  10079. findPosH: function findPosH(from, amount, unit, visually) {
  10080. var this$1 = this;
  10081. var dir = 1;
  10082. if (amount < 0) {
  10083. dir = -1;
  10084. amount = -amount;
  10085. }
  10086. var cur = _clipPos(this.doc, from);
  10087. for (var i = 0; i < amount; ++i) {
  10088. cur = _findPosH(this$1.doc, cur, dir, unit, visually);
  10089. if (cur.hitSide) {
  10090. break;
  10091. }
  10092. }
  10093. return cur;
  10094. },
  10095. moveH: methodOp(function (dir, unit) {
  10096. var this$1 = this;
  10097. this.extendSelectionsBy(function (range$$1) {
  10098. if (this$1.display.shift || this$1.doc.extend || range$$1.empty()) {
  10099. return _findPosH(this$1.doc, range$$1.head, dir, unit, this$1.options.rtlMoveVisually);
  10100. } else {
  10101. return dir < 0 ? range$$1.from() : range$$1.to();
  10102. }
  10103. }, sel_move);
  10104. }),
  10105. deleteH: methodOp(function (dir, unit) {
  10106. var sel = this.doc.sel,
  10107. doc = this.doc;
  10108. if (sel.somethingSelected()) {
  10109. doc.replaceSelection("", null, "+delete");
  10110. } else {
  10111. deleteNearSelection(this, function (range$$1) {
  10112. var other = _findPosH(doc, range$$1.head, dir, unit, false);
  10113. return dir < 0 ? { from: other, to: range$$1.head } : { from: range$$1.head, to: other };
  10114. });
  10115. }
  10116. }),
  10117. findPosV: function findPosV(from, amount, unit, goalColumn) {
  10118. var this$1 = this;
  10119. var dir = 1,
  10120. x = goalColumn;
  10121. if (amount < 0) {
  10122. dir = -1;
  10123. amount = -amount;
  10124. }
  10125. var cur = _clipPos(this.doc, from);
  10126. for (var i = 0; i < amount; ++i) {
  10127. var coords = _cursorCoords(this$1, cur, "div");
  10128. if (x == null) {
  10129. x = coords.left;
  10130. } else {
  10131. coords.left = x;
  10132. }
  10133. cur = _findPosV(this$1, coords, dir, unit);
  10134. if (cur.hitSide) {
  10135. break;
  10136. }
  10137. }
  10138. return cur;
  10139. },
  10140. moveV: methodOp(function (dir, unit) {
  10141. var this$1 = this;
  10142. var doc = this.doc,
  10143. goals = [];
  10144. var collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected();
  10145. doc.extendSelectionsBy(function (range$$1) {
  10146. if (collapse) {
  10147. return dir < 0 ? range$$1.from() : range$$1.to();
  10148. }
  10149. var headPos = _cursorCoords(this$1, range$$1.head, "div");
  10150. if (range$$1.goalColumn != null) {
  10151. headPos.left = range$$1.goalColumn;
  10152. }
  10153. goals.push(headPos.left);
  10154. var pos = _findPosV(this$1, headPos, dir, unit);
  10155. if (unit == "page" && range$$1 == doc.sel.primary()) {
  10156. addToScrollTop(this$1, _charCoords(this$1, pos, "div").top - headPos.top);
  10157. }
  10158. return pos;
  10159. }, sel_move);
  10160. if (goals.length) {
  10161. for (var i = 0; i < doc.sel.ranges.length; i++) {
  10162. doc.sel.ranges[i].goalColumn = goals[i];
  10163. }
  10164. }
  10165. }),
  10166. // Find the word at the given position (as returned by coordsChar).
  10167. findWordAt: function findWordAt(pos) {
  10168. var doc = this.doc,
  10169. line = getLine(doc, pos.line).text;
  10170. var start = pos.ch,
  10171. end = pos.ch;
  10172. if (line) {
  10173. var helper = this.getHelper(pos, "wordChars");
  10174. if ((pos.sticky == "before" || end == line.length) && start) {
  10175. --start;
  10176. } else {
  10177. ++end;
  10178. }
  10179. var startChar = line.charAt(start);
  10180. var check = isWordChar(startChar, helper) ? function (ch) {
  10181. return isWordChar(ch, helper);
  10182. } : /\s/.test(startChar) ? function (ch) {
  10183. return (/\s/.test(ch)
  10184. );
  10185. } : function (ch) {
  10186. return !/\s/.test(ch) && !isWordChar(ch);
  10187. };
  10188. while (start > 0 && check(line.charAt(start - 1))) {
  10189. --start;
  10190. }
  10191. while (end < line.length && check(line.charAt(end))) {
  10192. ++end;
  10193. }
  10194. }
  10195. return new Range(Pos(pos.line, start), Pos(pos.line, end));
  10196. },
  10197. toggleOverwrite: function toggleOverwrite(value) {
  10198. if (value != null && value == this.state.overwrite) {
  10199. return;
  10200. }
  10201. if (this.state.overwrite = !this.state.overwrite) {
  10202. addClass(this.display.cursorDiv, "CodeMirror-overwrite");
  10203. } else {
  10204. rmClass(this.display.cursorDiv, "CodeMirror-overwrite");
  10205. }
  10206. signal(this, "overwriteToggle", this, this.state.overwrite);
  10207. },
  10208. hasFocus: function hasFocus() {
  10209. return this.display.input.getField() == activeElt();
  10210. },
  10211. isReadOnly: function isReadOnly() {
  10212. return !!(this.options.readOnly || this.doc.cantEdit);
  10213. },
  10214. scrollTo: methodOp(function (x, y) {
  10215. scrollToCoords(this, x, y);
  10216. }),
  10217. getScrollInfo: function getScrollInfo() {
  10218. var scroller = this.display.scroller;
  10219. return {
  10220. left: scroller.scrollLeft, top: scroller.scrollTop,
  10221. height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,
  10222. width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,
  10223. clientHeight: displayHeight(this), clientWidth: displayWidth(this)
  10224. };
  10225. },
  10226. scrollIntoView: methodOp(function (range$$1, margin) {
  10227. if (range$$1 == null) {
  10228. range$$1 = { from: this.doc.sel.primary().head, to: null };
  10229. if (margin == null) {
  10230. margin = this.options.cursorScrollMargin;
  10231. }
  10232. } else if (typeof range$$1 == "number") {
  10233. range$$1 = { from: Pos(range$$1, 0), to: null };
  10234. } else if (range$$1.from == null) {
  10235. range$$1 = { from: range$$1, to: null };
  10236. }
  10237. if (!range$$1.to) {
  10238. range$$1.to = range$$1.from;
  10239. }
  10240. range$$1.margin = margin || 0;
  10241. if (range$$1.from.line != null) {
  10242. scrollToRange(this, range$$1);
  10243. } else {
  10244. scrollToCoordsRange(this, range$$1.from, range$$1.to, range$$1.margin);
  10245. }
  10246. }),
  10247. setSize: methodOp(function (width, height) {
  10248. var this$1 = this;
  10249. var interpret = function interpret(val) {
  10250. return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val;
  10251. };
  10252. if (width != null) {
  10253. this.display.wrapper.style.width = interpret(width);
  10254. }
  10255. if (height != null) {
  10256. this.display.wrapper.style.height = interpret(height);
  10257. }
  10258. if (this.options.lineWrapping) {
  10259. clearLineMeasurementCache(this);
  10260. }
  10261. var lineNo$$1 = this.display.viewFrom;
  10262. this.doc.iter(lineNo$$1, this.display.viewTo, function (line) {
  10263. if (line.widgets) {
  10264. for (var i = 0; i < line.widgets.length; i++) {
  10265. if (line.widgets[i].noHScroll) {
  10266. regLineChange(this$1, lineNo$$1, "widget");
  10267. break;
  10268. }
  10269. }
  10270. }
  10271. ++lineNo$$1;
  10272. });
  10273. this.curOp.forceUpdate = true;
  10274. signal(this, "refresh", this);
  10275. }),
  10276. operation: function operation(f) {
  10277. return runInOp(this, f);
  10278. },
  10279. startOperation: function startOperation() {
  10280. return _startOperation(this);
  10281. },
  10282. endOperation: function endOperation() {
  10283. return _endOperation(this);
  10284. },
  10285. refresh: methodOp(function () {
  10286. var oldHeight = this.display.cachedTextHeight;
  10287. regChange(this);
  10288. this.curOp.forceUpdate = true;
  10289. clearCaches(this);
  10290. scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop);
  10291. updateGutterSpace(this.display);
  10292. if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5) {
  10293. estimateLineHeights(this);
  10294. }
  10295. signal(this, "refresh", this);
  10296. }),
  10297. swapDoc: methodOp(function (doc) {
  10298. var old = this.doc;
  10299. old.cm = null;
  10300. // Cancel the current text selection if any (#5821)
  10301. if (this.state.selectingText) {
  10302. this.state.selectingText();
  10303. }
  10304. attachDoc(this, doc);
  10305. clearCaches(this);
  10306. this.display.input.reset();
  10307. scrollToCoords(this, doc.scrollLeft, doc.scrollTop);
  10308. this.curOp.forceScroll = true;
  10309. signalLater(this, "swapDoc", this, old);
  10310. return old;
  10311. }),
  10312. phrase: function phrase(phraseText) {
  10313. var phrases = this.options.phrases;
  10314. return phrases && Object.prototype.hasOwnProperty.call(phrases, phraseText) ? phrases[phraseText] : phraseText;
  10315. },
  10316. getInputField: function getInputField() {
  10317. return this.display.input.getField();
  10318. },
  10319. getWrapperElement: function getWrapperElement() {
  10320. return this.display.wrapper;
  10321. },
  10322. getScrollerElement: function getScrollerElement() {
  10323. return this.display.scroller;
  10324. },
  10325. getGutterElement: function getGutterElement() {
  10326. return this.display.gutters;
  10327. }
  10328. };
  10329. eventMixin(CodeMirror);
  10330. CodeMirror.registerHelper = function (type, name, value) {
  10331. if (!helpers.hasOwnProperty(type)) {
  10332. helpers[type] = CodeMirror[type] = { _global: [] };
  10333. }
  10334. helpers[type][name] = value;
  10335. };
  10336. CodeMirror.registerGlobalHelper = function (type, name, predicate, value) {
  10337. CodeMirror.registerHelper(type, name, value);
  10338. helpers[type]._global.push({ pred: predicate, val: value });
  10339. };
  10340. }
  10341. // Used for horizontal relative motion. Dir is -1 or 1 (left or
  10342. // right), unit can be "char", "column" (like char, but doesn't
  10343. // cross line boundaries), "word" (across next word), or "group" (to
  10344. // the start of next group of word or non-word-non-whitespace
  10345. // chars). The visually param controls whether, in right-to-left
  10346. // text, direction 1 means to move towards the next index in the
  10347. // string, or towards the character to the right of the current
  10348. // position. The resulting position will have a hitSide=true
  10349. // property if it reached the end of the document.
  10350. function _findPosH(doc, pos, dir, unit, visually) {
  10351. var oldPos = pos;
  10352. var origDir = dir;
  10353. var lineObj = getLine(doc, pos.line);
  10354. function findNextLine() {
  10355. var l = pos.line + dir;
  10356. if (l < doc.first || l >= doc.first + doc.size) {
  10357. return false;
  10358. }
  10359. pos = new Pos(l, pos.ch, pos.sticky);
  10360. return lineObj = getLine(doc, l);
  10361. }
  10362. function moveOnce(boundToLine) {
  10363. var next;
  10364. if (visually) {
  10365. next = moveVisually(doc.cm, lineObj, pos, dir);
  10366. } else {
  10367. next = moveLogically(lineObj, pos, dir);
  10368. }
  10369. if (next == null) {
  10370. if (!boundToLine && findNextLine()) {
  10371. pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir);
  10372. } else {
  10373. return false;
  10374. }
  10375. } else {
  10376. pos = next;
  10377. }
  10378. return true;
  10379. }
  10380. if (unit == "char") {
  10381. moveOnce();
  10382. } else if (unit == "column") {
  10383. moveOnce(true);
  10384. } else if (unit == "word" || unit == "group") {
  10385. var sawType = null,
  10386. group = unit == "group";
  10387. var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
  10388. for (var first = true;; first = false) {
  10389. if (dir < 0 && !moveOnce(!first)) {
  10390. break;
  10391. }
  10392. var cur = lineObj.text.charAt(pos.ch) || "\n";
  10393. var type = isWordChar(cur, helper) ? "w" : group && cur == "\n" ? "n" : !group || /\s/.test(cur) ? null : "p";
  10394. if (group && !first && !type) {
  10395. type = "s";
  10396. }
  10397. if (sawType && sawType != type) {
  10398. if (dir < 0) {
  10399. dir = 1;
  10400. moveOnce();
  10401. pos.sticky = "after";
  10402. }
  10403. break;
  10404. }
  10405. if (type) {
  10406. sawType = type;
  10407. }
  10408. if (dir > 0 && !moveOnce(!first)) {
  10409. break;
  10410. }
  10411. }
  10412. }
  10413. var result = skipAtomic(doc, pos, oldPos, origDir, true);
  10414. if (equalCursorPos(oldPos, result)) {
  10415. result.hitSide = true;
  10416. }
  10417. return result;
  10418. }
  10419. // For relative vertical movement. Dir may be -1 or 1. Unit can be
  10420. // "page" or "line". The resulting position will have a hitSide=true
  10421. // property if it reached the end of the document.
  10422. function _findPosV(cm, pos, dir, unit) {
  10423. var doc = cm.doc,
  10424. x = pos.left,
  10425. y;
  10426. if (unit == "page") {
  10427. var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
  10428. var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);
  10429. y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;
  10430. } else if (unit == "line") {
  10431. y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
  10432. }
  10433. var target;
  10434. for (;;) {
  10435. target = _coordsChar(cm, x, y);
  10436. if (!target.outside) {
  10437. break;
  10438. }
  10439. if (dir < 0 ? y <= 0 : y >= doc.height) {
  10440. target.hitSide = true;
  10441. break;
  10442. }
  10443. y += dir * 5;
  10444. }
  10445. return target;
  10446. }
  10447. // CONTENTEDITABLE INPUT STYLE
  10448. var ContentEditableInput = function ContentEditableInput(cm) {
  10449. this.cm = cm;
  10450. this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
  10451. this.polling = new Delayed();
  10452. this.composing = null;
  10453. this.gracePeriod = false;
  10454. this.readDOMTimeout = null;
  10455. };
  10456. ContentEditableInput.prototype.init = function (display) {
  10457. var this$1 = this;
  10458. var input = this,
  10459. cm = input.cm;
  10460. var div = input.div = display.lineDiv;
  10461. disableBrowserMagic(div, cm.options.spellcheck, cm.options.autocorrect, cm.options.autocapitalize);
  10462. on(div, "paste", function (e) {
  10463. if (signalDOMEvent(cm, e) || handlePaste(e, cm)) {
  10464. return;
  10465. }
  10466. // IE doesn't fire input events, so we schedule a read for the pasted content in this way
  10467. if (ie_version <= 11) {
  10468. setTimeout(operation(cm, function () {
  10469. return this$1.updateFromDOM();
  10470. }), 20);
  10471. }
  10472. });
  10473. on(div, "compositionstart", function (e) {
  10474. this$1.composing = { data: e.data, done: false };
  10475. });
  10476. on(div, "compositionupdate", function (e) {
  10477. if (!this$1.composing) {
  10478. this$1.composing = { data: e.data, done: false };
  10479. }
  10480. });
  10481. on(div, "compositionend", function (e) {
  10482. if (this$1.composing) {
  10483. if (e.data != this$1.composing.data) {
  10484. this$1.readFromDOMSoon();
  10485. }
  10486. this$1.composing.done = true;
  10487. }
  10488. });
  10489. on(div, "touchstart", function () {
  10490. return input.forceCompositionEnd();
  10491. });
  10492. on(div, "input", function () {
  10493. if (!this$1.composing) {
  10494. this$1.readFromDOMSoon();
  10495. }
  10496. });
  10497. function onCopyCut(e) {
  10498. if (signalDOMEvent(cm, e)) {
  10499. return;
  10500. }
  10501. if (cm.somethingSelected()) {
  10502. setLastCopied({ lineWise: false, text: cm.getSelections() });
  10503. if (e.type == "cut") {
  10504. cm.replaceSelection("", null, "cut");
  10505. }
  10506. } else if (!cm.options.lineWiseCopyCut) {
  10507. return;
  10508. } else {
  10509. var ranges = copyableRanges(cm);
  10510. setLastCopied({ lineWise: true, text: ranges.text });
  10511. if (e.type == "cut") {
  10512. cm.operation(function () {
  10513. cm.setSelections(ranges.ranges, 0, sel_dontScroll);
  10514. cm.replaceSelection("", null, "cut");
  10515. });
  10516. }
  10517. }
  10518. if (e.clipboardData) {
  10519. e.clipboardData.clearData();
  10520. var content = lastCopied.text.join("\n");
  10521. // iOS exposes the clipboard API, but seems to discard content inserted into it
  10522. e.clipboardData.setData("Text", content);
  10523. if (e.clipboardData.getData("Text") == content) {
  10524. e.preventDefault();
  10525. return;
  10526. }
  10527. }
  10528. // Old-fashioned briefly-focus-a-textarea hack
  10529. var kludge = hiddenTextarea(),
  10530. te = kludge.firstChild;
  10531. cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
  10532. te.value = lastCopied.text.join("\n");
  10533. var hadFocus = document.activeElement;
  10534. selectInput(te);
  10535. setTimeout(function () {
  10536. cm.display.lineSpace.removeChild(kludge);
  10537. hadFocus.focus();
  10538. if (hadFocus == div) {
  10539. input.showPrimarySelection();
  10540. }
  10541. }, 50);
  10542. }
  10543. on(div, "copy", onCopyCut);
  10544. on(div, "cut", onCopyCut);
  10545. };
  10546. ContentEditableInput.prototype.prepareSelection = function () {
  10547. var result = prepareSelection(this.cm, false);
  10548. result.focus = this.cm.state.focused;
  10549. return result;
  10550. };
  10551. ContentEditableInput.prototype.showSelection = function (info, takeFocus) {
  10552. if (!info || !this.cm.display.view.length) {
  10553. return;
  10554. }
  10555. if (info.focus || takeFocus) {
  10556. this.showPrimarySelection();
  10557. }
  10558. this.showMultipleSelections(info);
  10559. };
  10560. ContentEditableInput.prototype.getSelection = function () {
  10561. return this.cm.display.wrapper.ownerDocument.getSelection();
  10562. };
  10563. ContentEditableInput.prototype.showPrimarySelection = function () {
  10564. var sel = this.getSelection(),
  10565. cm = this.cm,
  10566. prim = cm.doc.sel.primary();
  10567. var from = prim.from(),
  10568. to = prim.to();
  10569. if (cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom) {
  10570. sel.removeAllRanges();
  10571. return;
  10572. }
  10573. var curAnchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
  10574. var curFocus = domToPos(cm, sel.focusNode, sel.focusOffset);
  10575. if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad && cmp(minPos(curAnchor, curFocus), from) == 0 && cmp(maxPos(curAnchor, curFocus), to) == 0) {
  10576. return;
  10577. }
  10578. var view = cm.display.view;
  10579. var start = from.line >= cm.display.viewFrom && posToDOM(cm, from) || { node: view[0].measure.map[2], offset: 0 };
  10580. var end = to.line < cm.display.viewTo && posToDOM(cm, to);
  10581. if (!end) {
  10582. var measure = view[view.length - 1].measure;
  10583. var map$$1 = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;
  10584. end = { node: map$$1[map$$1.length - 1], offset: map$$1[map$$1.length - 2] - map$$1[map$$1.length - 3] };
  10585. }
  10586. if (!start || !end) {
  10587. sel.removeAllRanges();
  10588. return;
  10589. }
  10590. var old = sel.rangeCount && sel.getRangeAt(0),
  10591. rng;
  10592. try {
  10593. rng = range(start.node, start.offset, end.offset, end.node);
  10594. } catch (e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
  10595. if (rng) {
  10596. if (!gecko && cm.state.focused) {
  10597. sel.collapse(start.node, start.offset);
  10598. if (!rng.collapsed) {
  10599. sel.removeAllRanges();
  10600. sel.addRange(rng);
  10601. }
  10602. } else {
  10603. sel.removeAllRanges();
  10604. sel.addRange(rng);
  10605. }
  10606. if (old && sel.anchorNode == null) {
  10607. sel.addRange(old);
  10608. } else if (gecko) {
  10609. this.startGracePeriod();
  10610. }
  10611. }
  10612. this.rememberSelection();
  10613. };
  10614. ContentEditableInput.prototype.startGracePeriod = function () {
  10615. var this$1 = this;
  10616. clearTimeout(this.gracePeriod);
  10617. this.gracePeriod = setTimeout(function () {
  10618. this$1.gracePeriod = false;
  10619. if (this$1.selectionChanged()) {
  10620. this$1.cm.operation(function () {
  10621. return this$1.cm.curOp.selectionChanged = true;
  10622. });
  10623. }
  10624. }, 20);
  10625. };
  10626. ContentEditableInput.prototype.showMultipleSelections = function (info) {
  10627. removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors);
  10628. removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection);
  10629. };
  10630. ContentEditableInput.prototype.rememberSelection = function () {
  10631. var sel = this.getSelection();
  10632. this.lastAnchorNode = sel.anchorNode;
  10633. this.lastAnchorOffset = sel.anchorOffset;
  10634. this.lastFocusNode = sel.focusNode;
  10635. this.lastFocusOffset = sel.focusOffset;
  10636. };
  10637. ContentEditableInput.prototype.selectionInEditor = function () {
  10638. var sel = this.getSelection();
  10639. if (!sel.rangeCount) {
  10640. return false;
  10641. }
  10642. var node = sel.getRangeAt(0).commonAncestorContainer;
  10643. return contains(this.div, node);
  10644. };
  10645. ContentEditableInput.prototype.focus = function () {
  10646. if (this.cm.options.readOnly != "nocursor") {
  10647. if (!this.selectionInEditor()) {
  10648. this.showSelection(this.prepareSelection(), true);
  10649. }
  10650. this.div.focus();
  10651. }
  10652. };
  10653. ContentEditableInput.prototype.blur = function () {
  10654. this.div.blur();
  10655. };
  10656. ContentEditableInput.prototype.getField = function () {
  10657. return this.div;
  10658. };
  10659. ContentEditableInput.prototype.supportsTouch = function () {
  10660. return true;
  10661. };
  10662. ContentEditableInput.prototype.receivedFocus = function () {
  10663. var input = this;
  10664. if (this.selectionInEditor()) {
  10665. this.pollSelection();
  10666. } else {
  10667. runInOp(this.cm, function () {
  10668. return input.cm.curOp.selectionChanged = true;
  10669. });
  10670. }
  10671. function poll() {
  10672. if (input.cm.state.focused) {
  10673. input.pollSelection();
  10674. input.polling.set(input.cm.options.pollInterval, poll);
  10675. }
  10676. }
  10677. this.polling.set(this.cm.options.pollInterval, poll);
  10678. };
  10679. ContentEditableInput.prototype.selectionChanged = function () {
  10680. var sel = this.getSelection();
  10681. return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset || sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset;
  10682. };
  10683. ContentEditableInput.prototype.pollSelection = function () {
  10684. if (this.readDOMTimeout != null || this.gracePeriod || !this.selectionChanged()) {
  10685. return;
  10686. }
  10687. var sel = this.getSelection(),
  10688. cm = this.cm;
  10689. // On Android Chrome (version 56, at least), backspacing into an
  10690. // uneditable block element will put the cursor in that element,
  10691. // and then, because it's not editable, hide the virtual keyboard.
  10692. // Because Android doesn't allow us to actually detect backspace
  10693. // presses in a sane way, this code checks for when that happens
  10694. // and simulates a backspace press in this case.
  10695. if (android && chrome && this.cm.display.gutterSpecs.length && isInGutter(sel.anchorNode)) {
  10696. this.cm.triggerOnKeyDown({ type: "keydown", keyCode: 8, preventDefault: Math.abs });
  10697. this.blur();
  10698. this.focus();
  10699. return;
  10700. }
  10701. if (this.composing) {
  10702. return;
  10703. }
  10704. this.rememberSelection();
  10705. var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
  10706. var head = domToPos(cm, sel.focusNode, sel.focusOffset);
  10707. if (anchor && head) {
  10708. runInOp(cm, function () {
  10709. setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);
  10710. if (anchor.bad || head.bad) {
  10711. cm.curOp.selectionChanged = true;
  10712. }
  10713. });
  10714. }
  10715. };
  10716. ContentEditableInput.prototype.pollContent = function () {
  10717. if (this.readDOMTimeout != null) {
  10718. clearTimeout(this.readDOMTimeout);
  10719. this.readDOMTimeout = null;
  10720. }
  10721. var cm = this.cm,
  10722. display = cm.display,
  10723. sel = cm.doc.sel.primary();
  10724. var from = sel.from(),
  10725. to = sel.to();
  10726. if (from.ch == 0 && from.line > cm.firstLine()) {
  10727. from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length);
  10728. }
  10729. if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine()) {
  10730. to = Pos(to.line + 1, 0);
  10731. }
  10732. if (from.line < display.viewFrom || to.line > display.viewTo - 1) {
  10733. return false;
  10734. }
  10735. var fromIndex, fromLine, fromNode;
  10736. if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
  10737. fromLine = lineNo(display.view[0].line);
  10738. fromNode = display.view[0].node;
  10739. } else {
  10740. fromLine = lineNo(display.view[fromIndex].line);
  10741. fromNode = display.view[fromIndex - 1].node.nextSibling;
  10742. }
  10743. var toIndex = findViewIndex(cm, to.line);
  10744. var toLine, toNode;
  10745. if (toIndex == display.view.length - 1) {
  10746. toLine = display.viewTo - 1;
  10747. toNode = display.lineDiv.lastChild;
  10748. } else {
  10749. toLine = lineNo(display.view[toIndex + 1].line) - 1;
  10750. toNode = display.view[toIndex + 1].node.previousSibling;
  10751. }
  10752. if (!fromNode) {
  10753. return false;
  10754. }
  10755. var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
  10756. var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
  10757. while (newText.length > 1 && oldText.length > 1) {
  10758. if (lst(newText) == lst(oldText)) {
  10759. newText.pop();
  10760. oldText.pop();
  10761. toLine--;
  10762. } else if (newText[0] == oldText[0]) {
  10763. newText.shift();
  10764. oldText.shift();
  10765. fromLine++;
  10766. } else {
  10767. break;
  10768. }
  10769. }
  10770. var cutFront = 0,
  10771. cutEnd = 0;
  10772. var newTop = newText[0],
  10773. oldTop = oldText[0],
  10774. maxCutFront = Math.min(newTop.length, oldTop.length);
  10775. while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront)) {
  10776. ++cutFront;
  10777. }
  10778. var newBot = lst(newText),
  10779. oldBot = lst(oldText);
  10780. var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0), oldBot.length - (oldText.length == 1 ? cutFront : 0));
  10781. while (cutEnd < maxCutEnd && newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) {
  10782. ++cutEnd;
  10783. }
  10784. // Try to move start of change to start of selection if ambiguous
  10785. if (newText.length == 1 && oldText.length == 1 && fromLine == from.line) {
  10786. while (cutFront && cutFront > from.ch && newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) {
  10787. cutFront--;
  10788. cutEnd++;
  10789. }
  10790. }
  10791. newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, "");
  10792. newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, "");
  10793. var chFrom = Pos(fromLine, cutFront);
  10794. var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
  10795. if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
  10796. _replaceRange(cm.doc, newText, chFrom, chTo, "+input");
  10797. return true;
  10798. }
  10799. };
  10800. ContentEditableInput.prototype.ensurePolled = function () {
  10801. this.forceCompositionEnd();
  10802. };
  10803. ContentEditableInput.prototype.reset = function () {
  10804. this.forceCompositionEnd();
  10805. };
  10806. ContentEditableInput.prototype.forceCompositionEnd = function () {
  10807. if (!this.composing) {
  10808. return;
  10809. }
  10810. clearTimeout(this.readDOMTimeout);
  10811. this.composing = null;
  10812. this.updateFromDOM();
  10813. this.div.blur();
  10814. this.div.focus();
  10815. };
  10816. ContentEditableInput.prototype.readFromDOMSoon = function () {
  10817. var this$1 = this;
  10818. if (this.readDOMTimeout != null) {
  10819. return;
  10820. }
  10821. this.readDOMTimeout = setTimeout(function () {
  10822. this$1.readDOMTimeout = null;
  10823. if (this$1.composing) {
  10824. if (this$1.composing.done) {
  10825. this$1.composing = null;
  10826. } else {
  10827. return;
  10828. }
  10829. }
  10830. this$1.updateFromDOM();
  10831. }, 80);
  10832. };
  10833. ContentEditableInput.prototype.updateFromDOM = function () {
  10834. var this$1 = this;
  10835. if (this.cm.isReadOnly() || !this.pollContent()) {
  10836. runInOp(this.cm, function () {
  10837. return regChange(this$1.cm);
  10838. });
  10839. }
  10840. };
  10841. ContentEditableInput.prototype.setUneditable = function (node) {
  10842. node.contentEditable = "false";
  10843. };
  10844. ContentEditableInput.prototype.onKeyPress = function (e) {
  10845. if (e.charCode == 0 || this.composing) {
  10846. return;
  10847. }
  10848. e.preventDefault();
  10849. if (!this.cm.isReadOnly()) {
  10850. operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
  10851. }
  10852. };
  10853. ContentEditableInput.prototype.readOnlyChanged = function (val) {
  10854. this.div.contentEditable = String(val != "nocursor");
  10855. };
  10856. ContentEditableInput.prototype.onContextMenu = function () {};
  10857. ContentEditableInput.prototype.resetPosition = function () {};
  10858. ContentEditableInput.prototype.needsContentAttribute = true;
  10859. function posToDOM(cm, pos) {
  10860. var view = findViewForLine(cm, pos.line);
  10861. if (!view || view.hidden) {
  10862. return null;
  10863. }
  10864. var line = getLine(cm.doc, pos.line);
  10865. var info = mapFromLineView(view, line, pos.line);
  10866. var order = getOrder(line, cm.doc.direction),
  10867. side = "left";
  10868. if (order) {
  10869. var partPos = getBidiPartAt(order, pos.ch);
  10870. side = partPos % 2 ? "right" : "left";
  10871. }
  10872. var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);
  10873. result.offset = result.collapse == "right" ? result.end : result.start;
  10874. return result;
  10875. }
  10876. function isInGutter(node) {
  10877. for (var scan = node; scan; scan = scan.parentNode) {
  10878. if (/CodeMirror-gutter-wrapper/.test(scan.className)) {
  10879. return true;
  10880. }
  10881. }
  10882. return false;
  10883. }
  10884. function badPos(pos, bad) {
  10885. if (bad) {
  10886. pos.bad = true;
  10887. }
  10888. return pos;
  10889. }
  10890. function domTextBetween(cm, from, to, fromLine, toLine) {
  10891. var text = "",
  10892. closing = false,
  10893. lineSep = cm.doc.lineSeparator(),
  10894. extraLinebreak = false;
  10895. function recognizeMarker(id) {
  10896. return function (marker) {
  10897. return marker.id == id;
  10898. };
  10899. }
  10900. function close() {
  10901. if (closing) {
  10902. text += lineSep;
  10903. if (extraLinebreak) {
  10904. text += lineSep;
  10905. }
  10906. closing = extraLinebreak = false;
  10907. }
  10908. }
  10909. function addText(str) {
  10910. if (str) {
  10911. close();
  10912. text += str;
  10913. }
  10914. }
  10915. function walk(node) {
  10916. if (node.nodeType == 1) {
  10917. var cmText = node.getAttribute("cm-text");
  10918. if (cmText) {
  10919. addText(cmText);
  10920. return;
  10921. }
  10922. var markerID = node.getAttribute("cm-marker"),
  10923. range$$1;
  10924. if (markerID) {
  10925. var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
  10926. if (found.length && (range$$1 = found[0].find(0))) {
  10927. addText(getBetween(cm.doc, range$$1.from, range$$1.to).join(lineSep));
  10928. }
  10929. return;
  10930. }
  10931. if (node.getAttribute("contenteditable") == "false") {
  10932. return;
  10933. }
  10934. var isBlock = /^(pre|div|p|li|table|br)$/i.test(node.nodeName);
  10935. if (!/^br$/i.test(node.nodeName) && node.textContent.length == 0) {
  10936. return;
  10937. }
  10938. if (isBlock) {
  10939. close();
  10940. }
  10941. for (var i = 0; i < node.childNodes.length; i++) {
  10942. walk(node.childNodes[i]);
  10943. }
  10944. if (/^(pre|p)$/i.test(node.nodeName)) {
  10945. extraLinebreak = true;
  10946. }
  10947. if (isBlock) {
  10948. closing = true;
  10949. }
  10950. } else if (node.nodeType == 3) {
  10951. addText(node.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " "));
  10952. }
  10953. }
  10954. for (;;) {
  10955. walk(from);
  10956. if (from == to) {
  10957. break;
  10958. }
  10959. from = from.nextSibling;
  10960. extraLinebreak = false;
  10961. }
  10962. return text;
  10963. }
  10964. function domToPos(cm, node, offset) {
  10965. var lineNode;
  10966. if (node == cm.display.lineDiv) {
  10967. lineNode = cm.display.lineDiv.childNodes[offset];
  10968. if (!lineNode) {
  10969. return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true);
  10970. }
  10971. node = null;
  10972. offset = 0;
  10973. } else {
  10974. for (lineNode = node;; lineNode = lineNode.parentNode) {
  10975. if (!lineNode || lineNode == cm.display.lineDiv) {
  10976. return null;
  10977. }
  10978. if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) {
  10979. break;
  10980. }
  10981. }
  10982. }
  10983. for (var i = 0; i < cm.display.view.length; i++) {
  10984. var lineView = cm.display.view[i];
  10985. if (lineView.node == lineNode) {
  10986. return locateNodeInLineView(lineView, node, offset);
  10987. }
  10988. }
  10989. }
  10990. function locateNodeInLineView(lineView, node, offset) {
  10991. var wrapper = lineView.text.firstChild,
  10992. bad = false;
  10993. if (!node || !contains(wrapper, node)) {
  10994. return badPos(Pos(lineNo(lineView.line), 0), true);
  10995. }
  10996. if (node == wrapper) {
  10997. bad = true;
  10998. node = wrapper.childNodes[offset];
  10999. offset = 0;
  11000. if (!node) {
  11001. var line = lineView.rest ? lst(lineView.rest) : lineView.line;
  11002. return badPos(Pos(lineNo(line), line.text.length), bad);
  11003. }
  11004. }
  11005. var textNode = node.nodeType == 3 ? node : null,
  11006. topNode = node;
  11007. if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
  11008. textNode = node.firstChild;
  11009. if (offset) {
  11010. offset = textNode.nodeValue.length;
  11011. }
  11012. }
  11013. while (topNode.parentNode != wrapper) {
  11014. topNode = topNode.parentNode;
  11015. }
  11016. var measure = lineView.measure,
  11017. maps = measure.maps;
  11018. function find(textNode, topNode, offset) {
  11019. for (var i = -1; i < (maps ? maps.length : 0); i++) {
  11020. var map$$1 = i < 0 ? measure.map : maps[i];
  11021. for (var j = 0; j < map$$1.length; j += 3) {
  11022. var curNode = map$$1[j + 2];
  11023. if (curNode == textNode || curNode == topNode) {
  11024. var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
  11025. var ch = map$$1[j] + offset;
  11026. if (offset < 0 || curNode != textNode) {
  11027. ch = map$$1[j + (offset ? 1 : 0)];
  11028. }
  11029. return Pos(line, ch);
  11030. }
  11031. }
  11032. }
  11033. }
  11034. var found = find(textNode, topNode, offset);
  11035. if (found) {
  11036. return badPos(found, bad);
  11037. }
  11038. // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
  11039. for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
  11040. found = find(after, after.firstChild, 0);
  11041. if (found) {
  11042. return badPos(Pos(found.line, found.ch - dist), bad);
  11043. } else {
  11044. dist += after.textContent.length;
  11045. }
  11046. }
  11047. for (var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling) {
  11048. found = find(before, before.firstChild, -1);
  11049. if (found) {
  11050. return badPos(Pos(found.line, found.ch + dist$1), bad);
  11051. } else {
  11052. dist$1 += before.textContent.length;
  11053. }
  11054. }
  11055. }
  11056. // TEXTAREA INPUT STYLE
  11057. var TextareaInput = function TextareaInput(cm) {
  11058. this.cm = cm;
  11059. // See input.poll and input.reset
  11060. this.prevInput = "";
  11061. // Flag that indicates whether we expect input to appear real soon
  11062. // now (after some event like 'keypress' or 'input') and are
  11063. // polling intensively.
  11064. this.pollingFast = false;
  11065. // Self-resetting timeout for the poller
  11066. this.polling = new Delayed();
  11067. // Used to work around IE issue with selection being forgotten when focus moves away from textarea
  11068. this.hasSelection = false;
  11069. this.composing = null;
  11070. };
  11071. TextareaInput.prototype.init = function (display) {
  11072. var this$1 = this;
  11073. var input = this,
  11074. cm = this.cm;
  11075. this.createField(display);
  11076. var te = this.textarea;
  11077. display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild);
  11078. // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
  11079. if (ios) {
  11080. te.style.width = "0px";
  11081. }
  11082. on(te, "input", function () {
  11083. if (ie && ie_version >= 9 && this$1.hasSelection) {
  11084. this$1.hasSelection = null;
  11085. }
  11086. input.poll();
  11087. });
  11088. on(te, "paste", function (e) {
  11089. if (signalDOMEvent(cm, e) || handlePaste(e, cm)) {
  11090. return;
  11091. }
  11092. cm.state.pasteIncoming = +new Date();
  11093. input.fastPoll();
  11094. });
  11095. function prepareCopyCut(e) {
  11096. if (signalDOMEvent(cm, e)) {
  11097. return;
  11098. }
  11099. if (cm.somethingSelected()) {
  11100. setLastCopied({ lineWise: false, text: cm.getSelections() });
  11101. } else if (!cm.options.lineWiseCopyCut) {
  11102. return;
  11103. } else {
  11104. var ranges = copyableRanges(cm);
  11105. setLastCopied({ lineWise: true, text: ranges.text });
  11106. if (e.type == "cut") {
  11107. cm.setSelections(ranges.ranges, null, sel_dontScroll);
  11108. } else {
  11109. input.prevInput = "";
  11110. te.value = ranges.text.join("\n");
  11111. selectInput(te);
  11112. }
  11113. }
  11114. if (e.type == "cut") {
  11115. cm.state.cutIncoming = +new Date();
  11116. }
  11117. }
  11118. on(te, "cut", prepareCopyCut);
  11119. on(te, "copy", prepareCopyCut);
  11120. on(display.scroller, "paste", function (e) {
  11121. if (eventInWidget(display, e) || signalDOMEvent(cm, e)) {
  11122. return;
  11123. }
  11124. if (!te.dispatchEvent) {
  11125. cm.state.pasteIncoming = +new Date();
  11126. input.focus();
  11127. return;
  11128. }
  11129. // Pass the `paste` event to the textarea so it's handled by its event listener.
  11130. var event = new Event("paste");
  11131. event.clipboardData = e.clipboardData;
  11132. te.dispatchEvent(event);
  11133. });
  11134. // Prevent normal selection in the src (we handle our own)
  11135. on(display.lineSpace, "selectstart", function (e) {
  11136. if (!eventInWidget(display, e)) {
  11137. e_preventDefault(e);
  11138. }
  11139. });
  11140. on(te, "compositionstart", function () {
  11141. var start = cm.getCursor("from");
  11142. if (input.composing) {
  11143. input.composing.range.clear();
  11144. }
  11145. input.composing = {
  11146. start: start,
  11147. range: cm.markText(start, cm.getCursor("to"), { className: "CodeMirror-composing" })
  11148. };
  11149. });
  11150. on(te, "compositionend", function () {
  11151. if (input.composing) {
  11152. input.poll();
  11153. input.composing.range.clear();
  11154. input.composing = null;
  11155. }
  11156. });
  11157. };
  11158. TextareaInput.prototype.createField = function (_display) {
  11159. // Wraps and hides input textarea
  11160. this.wrapper = hiddenTextarea();
  11161. // The semihidden textarea that is focused when the src is
  11162. // focused, and receives input.
  11163. this.textarea = this.wrapper.firstChild;
  11164. };
  11165. TextareaInput.prototype.prepareSelection = function () {
  11166. // Redraw the selection and/or cursor
  11167. var cm = this.cm,
  11168. display = cm.display,
  11169. doc = cm.doc;
  11170. var result = prepareSelection(cm);
  11171. // Move the hidden textarea near the cursor to prevent scrolling artifacts
  11172. if (cm.options.moveInputWithCursor) {
  11173. var headPos = _cursorCoords(cm, doc.sel.primary().head, "div");
  11174. var wrapOff = display.wrapper.getBoundingClientRect(),
  11175. lineOff = display.lineDiv.getBoundingClientRect();
  11176. result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10, headPos.top + lineOff.top - wrapOff.top));
  11177. result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10, headPos.left + lineOff.left - wrapOff.left));
  11178. }
  11179. return result;
  11180. };
  11181. TextareaInput.prototype.showSelection = function (drawn) {
  11182. var cm = this.cm,
  11183. display = cm.display;
  11184. removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
  11185. removeChildrenAndAdd(display.selectionDiv, drawn.selection);
  11186. if (drawn.teTop != null) {
  11187. this.wrapper.style.top = drawn.teTop + "px";
  11188. this.wrapper.style.left = drawn.teLeft + "px";
  11189. }
  11190. };
  11191. // Reset the input to correspond to the selection (or to be empty,
  11192. // when not typing and nothing is selected)
  11193. TextareaInput.prototype.reset = function (typing) {
  11194. if (this.contextMenuPending || this.composing) {
  11195. return;
  11196. }
  11197. var cm = this.cm;
  11198. if (cm.somethingSelected()) {
  11199. this.prevInput = "";
  11200. var content = cm.getSelection();
  11201. this.textarea.value = content;
  11202. if (cm.state.focused) {
  11203. selectInput(this.textarea);
  11204. }
  11205. if (ie && ie_version >= 9) {
  11206. this.hasSelection = content;
  11207. }
  11208. } else if (!typing) {
  11209. this.prevInput = this.textarea.value = "";
  11210. if (ie && ie_version >= 9) {
  11211. this.hasSelection = null;
  11212. }
  11213. }
  11214. };
  11215. TextareaInput.prototype.getField = function () {
  11216. return this.textarea;
  11217. };
  11218. TextareaInput.prototype.supportsTouch = function () {
  11219. return false;
  11220. };
  11221. TextareaInput.prototype.focus = function () {
  11222. if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
  11223. try {
  11224. this.textarea.focus();
  11225. } catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
  11226. }
  11227. };
  11228. TextareaInput.prototype.blur = function () {
  11229. this.textarea.blur();
  11230. };
  11231. TextareaInput.prototype.resetPosition = function () {
  11232. this.wrapper.style.top = this.wrapper.style.left = 0;
  11233. };
  11234. TextareaInput.prototype.receivedFocus = function () {
  11235. this.slowPoll();
  11236. };
  11237. // Poll for input changes, using the normal rate of polling. This
  11238. // runs as long as the src is focused.
  11239. TextareaInput.prototype.slowPoll = function () {
  11240. var this$1 = this;
  11241. if (this.pollingFast) {
  11242. return;
  11243. }
  11244. this.polling.set(this.cm.options.pollInterval, function () {
  11245. this$1.poll();
  11246. if (this$1.cm.state.focused) {
  11247. this$1.slowPoll();
  11248. }
  11249. });
  11250. };
  11251. // When an event has just come in that is likely to add or change
  11252. // something in the input textarea, we poll faster, to ensure that
  11253. // the change appears on the screen quickly.
  11254. TextareaInput.prototype.fastPoll = function () {
  11255. var missed = false,
  11256. input = this;
  11257. input.pollingFast = true;
  11258. function p() {
  11259. var changed = input.poll();
  11260. if (!changed && !missed) {
  11261. missed = true;
  11262. input.polling.set(60, p);
  11263. } else {
  11264. input.pollingFast = false;
  11265. input.slowPoll();
  11266. }
  11267. }
  11268. input.polling.set(20, p);
  11269. };
  11270. // Read input from the textarea, and update the document to match.
  11271. // When something is selected, it is present in the textarea, and
  11272. // selected (unless it is huge, in which case a placeholder is
  11273. // used). When nothing is selected, the cursor sits after previously
  11274. // seen text (can be empty), which is stored in prevInput (we must
  11275. // not reset the textarea when typing, because that breaks IME).
  11276. TextareaInput.prototype.poll = function () {
  11277. var this$1 = this;
  11278. var cm = this.cm,
  11279. input = this.textarea,
  11280. prevInput = this.prevInput;
  11281. // Since this is called a *lot*, try to bail out as cheaply as
  11282. // possible when it is clear that nothing happened. hasSelection
  11283. // will be the case when there is a lot of text in the textarea,
  11284. // in which case reading its value would be expensive.
  11285. if (this.contextMenuPending || !cm.state.focused || hasSelection(input) && !prevInput && !this.composing || cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq) {
  11286. return false;
  11287. }
  11288. var text = input.value;
  11289. // If nothing changed, bail.
  11290. if (text == prevInput && !cm.somethingSelected()) {
  11291. return false;
  11292. }
  11293. // Work around nonsensical selection resetting in IE9/10, and
  11294. // inexplicable appearance of private area unicode characters on
  11295. // some key combos in Mac (#2689).
  11296. if (ie && ie_version >= 9 && this.hasSelection === text || mac && /[\uf700-\uf7ff]/.test(text)) {
  11297. cm.display.input.reset();
  11298. return false;
  11299. }
  11300. if (cm.doc.sel == cm.display.selForContextMenu) {
  11301. var first = text.charCodeAt(0);
  11302. if (first == 0x200b && !prevInput) {
  11303. prevInput = "\u200B";
  11304. }
  11305. if (first == 0x21da) {
  11306. this.reset();
  11307. return this.cm.execCommand("undo");
  11308. }
  11309. }
  11310. // Find the part of the input that is actually new
  11311. var same = 0,
  11312. l = Math.min(prevInput.length, text.length);
  11313. while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) {
  11314. ++same;
  11315. }
  11316. runInOp(cm, function () {
  11317. applyTextInput(cm, text.slice(same), prevInput.length - same, null, this$1.composing ? "*compose" : null);
  11318. // Don't leave long text in the textarea, since it makes further polling slow
  11319. if (text.length > 1000 || text.indexOf("\n") > -1) {
  11320. input.value = this$1.prevInput = "";
  11321. } else {
  11322. this$1.prevInput = text;
  11323. }
  11324. if (this$1.composing) {
  11325. this$1.composing.range.clear();
  11326. this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"), { className: "CodeMirror-composing" });
  11327. }
  11328. });
  11329. return true;
  11330. };
  11331. TextareaInput.prototype.ensurePolled = function () {
  11332. if (this.pollingFast && this.poll()) {
  11333. this.pollingFast = false;
  11334. }
  11335. };
  11336. TextareaInput.prototype.onKeyPress = function () {
  11337. if (ie && ie_version >= 9) {
  11338. this.hasSelection = null;
  11339. }
  11340. this.fastPoll();
  11341. };
  11342. TextareaInput.prototype.onContextMenu = function (e) {
  11343. var input = this,
  11344. cm = input.cm,
  11345. display = cm.display,
  11346. te = input.textarea;
  11347. if (input.contextMenuPending) {
  11348. input.contextMenuPending();
  11349. }
  11350. var pos = posFromMouse(cm, e),
  11351. scrollPos = display.scroller.scrollTop;
  11352. if (!pos || presto) {
  11353. return;
  11354. } // Opera is difficult.
  11355. // Reset the current text selection only if the click is done outside of the selection
  11356. // and 'resetSelectionOnContextMenu' option is true.
  11357. var reset = cm.options.resetSelectionOnContextMenu;
  11358. if (reset && cm.doc.sel.contains(pos) == -1) {
  11359. operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
  11360. }
  11361. var oldCSS = te.style.cssText,
  11362. oldWrapperCSS = input.wrapper.style.cssText;
  11363. var wrapperBox = input.wrapper.offsetParent.getBoundingClientRect();
  11364. input.wrapper.style.cssText = "position: static";
  11365. te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
  11366. var oldScrollY;
  11367. if (webkit) {
  11368. oldScrollY = window.scrollY;
  11369. } // Work around Chrome issue (#2712)
  11370. display.input.focus();
  11371. if (webkit) {
  11372. window.scrollTo(null, oldScrollY);
  11373. }
  11374. display.input.reset();
  11375. // Adds "Select all" to context menu in FF
  11376. if (!cm.somethingSelected()) {
  11377. te.value = input.prevInput = " ";
  11378. }
  11379. input.contextMenuPending = rehide;
  11380. display.selForContextMenu = cm.doc.sel;
  11381. clearTimeout(display.detectingSelectAll);
  11382. // Select-all will be greyed out if there's nothing to select, so
  11383. // this adds a zero-width space so that we can later check whether
  11384. // it got selected.
  11385. function prepareSelectAllHack() {
  11386. if (te.selectionStart != null) {
  11387. var selected = cm.somethingSelected();
  11388. var extval = "\u200B" + (selected ? te.value : "");
  11389. te.value = "\u21DA"; // Used to catch context-menu undo
  11390. te.value = extval;
  11391. input.prevInput = selected ? "" : "\u200B";
  11392. te.selectionStart = 1;
  11393. te.selectionEnd = extval.length;
  11394. // Re-set this, in case some other handler touched the
  11395. // selection in the meantime.
  11396. display.selForContextMenu = cm.doc.sel;
  11397. }
  11398. }
  11399. function rehide() {
  11400. if (input.contextMenuPending != rehide) {
  11401. return;
  11402. }
  11403. input.contextMenuPending = false;
  11404. input.wrapper.style.cssText = oldWrapperCSS;
  11405. te.style.cssText = oldCSS;
  11406. if (ie && ie_version < 9) {
  11407. display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
  11408. }
  11409. // Try to detect the user choosing select-all
  11410. if (te.selectionStart != null) {
  11411. if (!ie || ie && ie_version < 9) {
  11412. prepareSelectAllHack();
  11413. }
  11414. var i = 0,
  11415. poll = function poll() {
  11416. if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 && te.selectionEnd > 0 && input.prevInput == "\u200B") {
  11417. operation(cm, selectAll)(cm);
  11418. } else if (i++ < 10) {
  11419. display.detectingSelectAll = setTimeout(poll, 500);
  11420. } else {
  11421. display.selForContextMenu = null;
  11422. display.input.reset();
  11423. }
  11424. };
  11425. display.detectingSelectAll = setTimeout(poll, 200);
  11426. }
  11427. }
  11428. if (ie && ie_version >= 9) {
  11429. prepareSelectAllHack();
  11430. }
  11431. if (captureRightClick) {
  11432. e_stop(e);
  11433. var mouseup = function mouseup() {
  11434. off(window, "mouseup", mouseup);
  11435. setTimeout(rehide, 20);
  11436. };
  11437. on(window, "mouseup", mouseup);
  11438. } else {
  11439. setTimeout(rehide, 50);
  11440. }
  11441. };
  11442. TextareaInput.prototype.readOnlyChanged = function (val) {
  11443. if (!val) {
  11444. this.reset();
  11445. }
  11446. this.textarea.disabled = val == "nocursor";
  11447. };
  11448. TextareaInput.prototype.setUneditable = function () {};
  11449. TextareaInput.prototype.needsContentAttribute = false;
  11450. function fromTextArea(textarea, options) {
  11451. options = options ? copyObj(options) : {};
  11452. options.value = textarea.value;
  11453. if (!options.tabindex && textarea.tabIndex) {
  11454. options.tabindex = textarea.tabIndex;
  11455. }
  11456. if (!options.placeholder && textarea.placeholder) {
  11457. options.placeholder = textarea.placeholder;
  11458. }
  11459. // Set autofocus to true if this textarea is focused, or if it has
  11460. // autofocus and no other element is focused.
  11461. if (options.autofocus == null) {
  11462. var hasFocus = activeElt();
  11463. options.autofocus = hasFocus == textarea || textarea.getAttribute("autofocus") != null && hasFocus == document.body;
  11464. }
  11465. function save() {
  11466. textarea.value = cm.getValue();
  11467. }
  11468. var realSubmit;
  11469. if (textarea.form) {
  11470. on(textarea.form, "submit", save);
  11471. // Deplorable hack to make the submit method do the right thing.
  11472. if (!options.leaveSubmitMethodAlone) {
  11473. var form = textarea.form;
  11474. realSubmit = form.submit;
  11475. try {
  11476. var wrappedSubmit = form.submit = function () {
  11477. save();
  11478. form.submit = realSubmit;
  11479. form.submit();
  11480. form.submit = wrappedSubmit;
  11481. };
  11482. } catch (e) {}
  11483. }
  11484. }
  11485. options.finishInit = function (cm) {
  11486. cm.save = save;
  11487. cm.getTextArea = function () {
  11488. return textarea;
  11489. };
  11490. cm.toTextArea = function () {
  11491. cm.toTextArea = isNaN; // Prevent this from being ran twice
  11492. save();
  11493. textarea.parentNode.removeChild(cm.getWrapperElement());
  11494. textarea.style.display = "";
  11495. if (textarea.form) {
  11496. off(textarea.form, "submit", save);
  11497. if (!options.leaveSubmitMethodAlone && typeof textarea.form.submit == "function") {
  11498. textarea.form.submit = realSubmit;
  11499. }
  11500. }
  11501. };
  11502. };
  11503. textarea.style.display = "none";
  11504. var cm = CodeMirror(function (node) {
  11505. return textarea.parentNode.insertBefore(node, textarea.nextSibling);
  11506. }, options);
  11507. return cm;
  11508. }
  11509. function addLegacyProps(CodeMirror) {
  11510. CodeMirror.off = off;
  11511. CodeMirror.on = on;
  11512. CodeMirror.wheelEventPixels = wheelEventPixels;
  11513. CodeMirror.Doc = Doc;
  11514. CodeMirror.splitLines = splitLinesAuto;
  11515. CodeMirror.countColumn = countColumn;
  11516. CodeMirror.findColumn = findColumn;
  11517. CodeMirror.isWordChar = isWordCharBasic;
  11518. CodeMirror.Pass = Pass;
  11519. CodeMirror.signal = signal;
  11520. CodeMirror.Line = Line;
  11521. CodeMirror.changeEnd = changeEnd;
  11522. CodeMirror.scrollbarModel = scrollbarModel;
  11523. CodeMirror.Pos = Pos;
  11524. CodeMirror.cmpPos = cmp;
  11525. CodeMirror.modes = modes;
  11526. CodeMirror.mimeModes = mimeModes;
  11527. CodeMirror.resolveMode = resolveMode;
  11528. CodeMirror.getMode = getMode;
  11529. CodeMirror.modeExtensions = modeExtensions;
  11530. CodeMirror.extendMode = extendMode;
  11531. CodeMirror.copyState = copyState;
  11532. CodeMirror.startState = startState;
  11533. CodeMirror.innerMode = innerMode;
  11534. CodeMirror.commands = commands;
  11535. CodeMirror.keyMap = keyMap;
  11536. CodeMirror.keyName = keyName;
  11537. CodeMirror.isModifierKey = isModifierKey;
  11538. CodeMirror.lookupKey = lookupKey;
  11539. CodeMirror.normalizeKeyMap = normalizeKeyMap;
  11540. CodeMirror.StringStream = StringStream;
  11541. CodeMirror.SharedTextMarker = SharedTextMarker;
  11542. CodeMirror.TextMarker = TextMarker;
  11543. CodeMirror.LineWidget = LineWidget;
  11544. CodeMirror.e_preventDefault = e_preventDefault;
  11545. CodeMirror.e_stopPropagation = e_stopPropagation;
  11546. CodeMirror.e_stop = e_stop;
  11547. CodeMirror.addClass = addClass;
  11548. CodeMirror.contains = contains;
  11549. CodeMirror.rmClass = rmClass;
  11550. // CodeMirror.keyNames = keyNames;
  11551. }
  11552. // EDITOR CONSTRUCTOR
  11553. defineOptions(CodeMirror);
  11554. addEditorMethods(CodeMirror);
  11555. // Set up methods on CodeMirror's prototype to redirect to the src's document.
  11556. var dontDelegate = "iter insert remove copy getEditor constructor".split(" ");
  11557. for (var prop in Doc.prototype) {
  11558. if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0) {
  11559. CodeMirror.prototype[prop] = function (method) {
  11560. return function () {
  11561. return method.apply(this.doc, arguments);
  11562. };
  11563. }(Doc.prototype[prop]);
  11564. }
  11565. }
  11566. eventMixin(Doc);
  11567. CodeMirror.inputStyles = { "textarea": TextareaInput, "contenteditable": ContentEditableInput };
  11568. // Extra arguments are stored as the mode's dependencies, which is
  11569. // used by (legacy) mechanisms like loadmode.js to automatically
  11570. // load a mode. (Preferred mechanism is the require/define calls.)
  11571. CodeMirror.defineMode = function (name /*, mode, …*/) {
  11572. if (!CodeMirror.defaults.mode && name != "null") {
  11573. CodeMirror.defaults.mode = name;
  11574. }
  11575. defineMode.apply(this, arguments);
  11576. };
  11577. CodeMirror.defineMIME = defineMIME;
  11578. // Minimal default mode.
  11579. CodeMirror.defineMode("null", function () {
  11580. return {
  11581. token: function token(stream) {
  11582. return stream.skipToEnd();
  11583. }
  11584. };
  11585. });
  11586. CodeMirror.defineMIME("text/plain", "null");
  11587. // EXTENSIONS
  11588. CodeMirror.defineExtension = function (name, func) {
  11589. CodeMirror.prototype[name] = func;
  11590. };
  11591. CodeMirror.defineDocExtension = function (name, func) {
  11592. Doc.prototype[name] = func;
  11593. };
  11594. CodeMirror.fromTextArea = fromTextArea;
  11595. addLegacyProps(CodeMirror);
  11596. CodeMirror.version = "5.49.2";
  11597. window.CodeMirror = CodeMirror;
  11598. /* harmony default export */ __webpack_exports__["a"] = (CodeMirror);
  11599. /***/ }),
  11600. /***/ 405:
  11601. /***/ (function(module, exports, __webpack_require__) {
  11602. var escape = __webpack_require__(287);
  11603. exports = module.exports = __webpack_require__(0)(false);
  11604. // imports
  11605. // module
  11606. exports.push([module.i, "@font-face {font-family: \"iconfont\";\r\n src: url(" + escape(__webpack_require__(320)) + "); /* IE9 */\r\n src: url(" + escape(__webpack_require__(320)) + "#iefix) format('embedded-opentype'), \r\n url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAABBoAAsAAAAAH4gAABAXAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCHNAqrGKENATYCJAOBAAtCAAQgBYRtB4I0G3MZM6M2lLTSTfZfJ3BzyOqYZkDBRZ2HprCitPZ3M8J36RIFoV+G+/sYnCYldv0I8xP3uCYjaM7/PYldjAhiEUzzMA2QIPZTSUVTap7SplSDVS1QFajwRBw61IQgv72KhZq8zPfO2kzlgJkk7T4iPTP9Ao/snqj1ZwI+AR+pnFgdsb1FKrikLeIB0AABBLNBwG3sJrh0YieT5piEFlvapTXhESZVxn7z1XMwlGSPvV8g5XsAQOD//62ldqfIqjJ5W5yyMH0RqkLWyJ0JDl3vH2ZCvMHdEpDKq5AV6vZCeyUCDyhMhanQFUJUSF+D5awMrAmEpUSMBqL+u96FgQDAQCUGYXgvHww+aDBOYL4ZcfI48GNh0DlDCfADXM0JaRCbioNPrl47gI3q6xMPkBAfIMGhwC7KNMk4AXqWejiMsp9gM2WP1KcBvJwIoADEAGiA1GkriShQPotRgtEV0vgv/nw0aIhYmpWyISIlSpGpmC1lR7A2toZtsMlp11jXnb47j+64Hg5zn6UsUfjoZBmKutd1v9rr4fphDQRixHGUMDpJirTuWd1zkP6/4AFKBLx5ISGFJwr+FLjwIISKCGIwCCRHgwMJBOCBjwA+fPmRUQPBBeYVAQDRQBvVwFICgxJYGgMBsFIM3sCGYPACNhwDCbARHF8yEhg8gU3EQAFsMgZ/YFMwKIDNwMAF2EwMHsAWAYSQxQCoIEsBEEGOAEAMaQOAgawBIBCyDgA5ZD0ANGQDABzITQBIIE8DIIC8CgAP8hoAfEgXMATAnT6Aj5IPAfCFfASAH6QLGGTwcNgSUAMAjTyBHsAsgPtJgC8GU++pILhNgQSfWmA0EEeRuu4EY14UN4/qGZcT5UhhGA+RzF1SKhUR4hBC68GmUDSfJxZ70tpH5uMJtAFv8k3IHkwQsbghCBGyO1rAEch8KV/ADNGEcnmltkOGKDqMSyXPTB0/f1gqqQ2GOhqiJgftys1wX+tg4SHhrzbqdj3PXQi/2m47jteF30zc/s3hA4btyn6r4/K6TDjNfkX8BZ51Du7ZDf/91en8caT7+06wdx/477cLWrE5JJ5vTUwUGoNjmfpWYWpMj3EjIa2djJquyNcCw/FkoZLVDe/crk7HlF2v3TZYaEO48Z1w1PX2/IHu2BudBRCCYtWvBRVSHgdpaN+n+n7rv7jBDQ41V3FSplXfmsIQFb4MONEnSxwYa4X9U0G67cNIpow0Wh0SzdewKnxLu1VOxbIVnAhqMHornbxVT0WyjfE9pdbQaK7Z+5oiSasw6tdwT1ABCOUhgLAB18k2I80+hAGCwnOPrbkI9MCNCKLYKXcZ/TjoQr+DKJrnBcZTsnHIVYM2IKHdls8KKdCbGp/gempUeVCNKPsiarRXiao7c1VaTpGsEWMZkK0EtaF+zozL/C5XUN1mc6qluTG8qp3ZRtDym7Tu9lABY77EyYCDOGGbSaX751iDcb86IXmrDLwE0OIqWKdHSLsjDVHThTg6e4hoZ0W1836P0nv3Sb9K9d17BS0TY89uRiqBtW8PD2r+uXx1QRH6ltVfNulEDoj+Tjm1OVOZHyxye8FtRMNx4u4SAx8MTWuMkQ4+KV/0Fm8XcxAikH13HgPEKC3sOv3jJfQPSis/NF8bGI8jOIpL/ZXB2cGcB5Z1ZUiOX1iO6uuYrghzg0A0c+naMI6D9DpkvdhphTJ9kdKwGkirDAkBUR5wsCOzDBCmo0JKjNunC1wOIoTbEZD+VCiMAURVWa4nDe1Uln4k54baR4hyhhCcUo33BZUwOqTO9uGIEu3sckJb9ZOAtBpUQIyUJ2wTFL+KLQjgHRCBXRiiowDDHW0vkLDrou0JF3AhCp2uQNv7oSZ/Zq8HJE+5VVSctLt8fbKj7qvd2K24Qljenm39DVKnTb/V54W3JQ4A16ajoC9ROEBhrRiupOO7TmnIt97OMqPbDs+Wd9Bq3vJckauVDIeTrXR126kpctY2WSpk9c2MHRO6XQ9XNLsrPWmuiIwVEqcdeCff1qG2zYzl3PJa3eWNcJmju/52k6wPlzQPrZSiQcZqLufWSkeANGW5t5zLe9SIPBNL1x4h9GWuIMQC46ZamifvFawQbH8TO9I0rWsNNjFoVxBYXmmJLzzjwApSTHhfP6YHrnT8ys8LlM0drRhLRqdJw6g4b54gcvmn+YmBX04ilmmEBR3wyJmoOKTz/7x2u72tOTTFq0y9YyvkJUtybl4LBb35iRHt5/TO+DOA/KGyNL40uZIiKaYvcjlOuvqIwScG1qSjFgfIfbLP6jMG8vOVPAijNL4AiM50bvAUmVSewIpmDqY1Wgcx0sAJqIgdRzrDwEEq9Ju9VwQ9uMGVQNYXahAuP79e5t78jSnVz8fdegMM8RyCb4a6viUlDgoko9Oi2TvWJofjwsQrQLviVhXtZw2YRlAB6J0fh8Wmho2cPr1dBSM3lCjc80GaD03EtTI11wPiQgXYsgRhNYuWASCFtPZOvTBqoNYTaO53H3b2Pdh5VsbHPrh06uYJD41afQ2dV1Ox53dGN6P3433qG3c4d93jvbLy4orHh6+df55b8kmvfHzFxbpnQKQHfUt5p1ImhA00zzRHfBFBLeQs4K1jFm7S5kVGDh0dNpRzCknDOjKzMjPPMVSR8n9r2tpnHEdHqOcoUjLUuUxWntVRyE92lLRftK3NINwmNLSpJfx/lbqsLqlV/p6q99SoaurrHSJ5YM2MGS5Xdr9M5CiwMO5fmMVsaY6LExZNNJvZtleQvnnPbCGYI7YnO58kSaS3nyzqAk6aunXdMQiaQJ1VPXNKS318EJljpwvbcyZxP/Jv0Rr4FOrVA/O4TJenp8KY3yDiW32/CpT5O37iS7orQBHVrJikbKa+wc0qr6jUKoH+W04U/Z3n357tnitXIiN/Q7Fdxj/Ml9kdl+An30RfEVVTAFNdmYZL2bHO9hmKfVZc6tf3L+8P6r/8ImBfnft2F7nL3MMDLo7qH32ueDL2GHUa2aRRJQNKhxQP9ZPJkM8xKUeYiysMlfqBkp/ph/pRy+0jRhoGjTQpq4hZ44bO3F69flKagSubojZwoN20wblhcHB18Kvjzg3O5OP+L1ofcTviOriSK1+8/OKK5PV60MpWzqjxrNn016KlnTs6ly66lb7Gc1H5VCYxhbvP1I/ireJ9J7JVB8mtyhbdKF2L8jvnaeBIyan0U7fDY5/dzB9VUTl8YMkgS7JbT8fei73VnWtfPndj2ewwaomyxJhzU08hxVQZzxpbVENU33jDJqlaRrSqJj73b1RmFWSnihoHU1Kaigw2kCrfQvKZP1fmGnSnqNpStG3+MwkvOlFHaH2N5LNonqTPzClC0rjV69oe+zxuk2/q2SlVKRGdwivDr3Dzfq+V8Hz69UaykNT1+vA8TprylNt/P/DHqs5x6uHq2Z2r/9z0W6NyK5NXfyAjtTChQd7W0NNW9lPPvJ95TH31jq3zhTSytHavdq9QIWKQFL4XuFKmXeAhtqmUIfXmZL/edJN5/RrdFH4tSuZ9R9n+mKud+WZTu1KKTiubkaps4mydXiG1JEXyOlVO0X5Ml/XXwZpCaadNLBW0byIxTWj2HK+/3it87M0vACmTm4KDSdEzLM2vOmLmOKzRu0UszatqHbUZmmB+rbZF49C2uhjVCfXewBMqZ5bT4VTCcdOhgH9lkX9v79pevmM6JoNaQMMIQ7dyq3Obc3vqX45upCDy6GZ6Ig6QXdu6nm4zu6+YP1OZpvzv0pMnhkC7bN+BIGXS8OHruLxgRZz36JKSRB5x+zYIbLuvd5dwO1jXu4upURy4O30Gb6IUC0Nsiij5ypBVMmWUxvY7RBPlgVYWKmyh2oShK6FuFq50tq/yW/XndFgI3qo/vuDzruKSn3DFJK3mERZHrt9KSxVnwOHtZU/GZQ5b2Jh580+7h2x2UMG86mNW6sZZyrra909Ktg0qqJ6Xk38qJy8/91Re7qsjKfk6kZ/zFM2pzvnEaoeVevADZa2pNg0GzvXCfX1xersSyI88TkzTtyh0ZkrRQtcnPt6wYfDgdqPxbppzrA0bHifW04oWyqxrUejT9K2NRrrCguZml9wbQmq8Ipbt59QVdG1Y/9w3wlRmpPl9twpTRNIjA95esJ+z4Ai04c61zLT1XQV1nHhDFHZWtFTogXRTxQzRtz9NkFyLzs4Jcpt8hkLklSit2CNK5Yv3iPV3tOSnbxMrsnu+XPfVLZvS1v7/Jcd7cjzyCrsH7zeXFzWdQq3gW4x6p7Y447os0tkV5/QyqL0jYac3CGhaWPL+FbdW+v1UNdnsTZHB30c2xBy6utz/Q6tU2Lt/LhtWJgr2rFt2FvvztIxn2/dvIgyhg7T1yrkBOiZtGZgJq0S8pdbfOwN++vWKmnF69YmCJU1Nk7Z8+pM9TuLtsds8fq75P44PWfCzq2O9XYHU8d6P/BL9a/wT/eS5zzoJcbqYlJyRkOJdOd8CRj3aLGcwZNgq3yCfJvmvYqIN0l/NTT6xu9/cX3TiWOjg1cd3nwvkBJsCxf8s0EocXp/zRWrfvk+k8cLJy5t9muvr5swGGRmYkrza/kabNJrZ83aYVu3eNZW/CvhooMuPeEn4WRK5kdxES5RK/TZtmU02Xx4lny97/pdilUIpDMXD00iX8hJNuZZE3lKpZpXikimatkqsFcGXSCuWIuFwdW7uyK1D4kODLl38t+n8gn+x3M0Wcb9U2FOkX2cdhXVfPtNzzxCNB1AXqLQZesgNc7j/U+QZFxm29kHKSY0h6KmQYPiI4auhc4ePG14spLhlhu8c8Qt/JT7rQyHFEG0efoOGNz6kBLRwLbka/jP5YHgXeX64HXHwwuHrvtp9dghG+i2fSCj+nE/bqJ+5y+Q8rGwPN2zq51+V9cLh/2m2uu6bRVW4D9IYRzX4IB9MSDyIFHSrG9HfOSyi2ecGFjuAKIMwBzTWItJAAmDCWW6Uyjn7rDytsx7ZKs/QJMFDoEmBjxBE94wxORAiyeSCj1yTQbSikwuhYAUFghYAiNLomAQ8nDFJSPAjo3Q9OxiNnl0mB14e5XExMIr+Y6cUOEMhwjbXv3wR6AKr2qeKhpNzY2Xpzf8JX0kLyXnq7BeSIyd13B1+mz+QIHWkyDd/KsUpJ9ypd8cHRKx64QtM2QU09ef93r1dxc5w1yybF4EusEr7lNNGw8kdvixTX/4TvpKWnNV+TfsLyfHolaOdgwX6EMlqtX1ZNN/8SSHaKbGscKe8Ew3iDaz0+rYuMGUnlLD7sz3ZnLMVu/ZVd2QUNuIa2EerSSBRaAwWhycQSWRKKmoaWjp6BkYmZhZWNnYOTi5unmLY2bHA8rgmyzMTYK6wG3WXt05TxqwX3CLuQ04jdm5u+Z6ItR23THbihWs/ip1flj53yJZiwsQQZ0xj0RTNnG8QzRTLwBL/OSWalIAOk7/KRVYU3ZK5J7QMK40NW4zfPK9LV4myESBZoZjMapY6ZFrWvnG2bXGOcdY3LPo627blR9MAAAAA') format('woff2'),\r\n url(" + escape(__webpack_require__(406)) + ") format('woff'),\r\n url(" + escape(__webpack_require__(407)) + ") format('truetype'), \r\n url(" + escape(__webpack_require__(408)) + "#iconfont) format('svg'); /* iOS 4.1- */\r\n}\r\n\r\n.iconfont {\r\n font-family: \"iconfont\" !important;\r\n font-size: 16px;\r\n font-style: normal;\r\n -webkit-font-smoothing: antialiased;\r\n -moz-osx-font-smoothing: grayscale;\r\n}\r\n\r\n.icon-md:before {\r\n content: \"\\E604\";\r\n}\r\n\r\n.icon-redo:before {\r\n content: \"\\E627\";\r\n}\r\n\r\n.icon-undo:before {\r\n content: \"\\E633\";\r\n}\r\n\r\n.icon-checked:before {\r\n content: \"\\E683\";\r\n}\r\n\r\n.icon-checked-false:before {\r\n content: \"\\E684\";\r\n}\r\n\r\n.icon-preview:before {\r\n content: \"\\E63A\";\r\n}\r\n\r\n.icon-on:before {\r\n content: \"\\E6D8\";\r\n}\r\n\r\n.icon-off:before {\r\n content: \"\\E6D9\";\r\n}\r\n\r\n.icon-download:before {\r\n content: \"\\E6AE\";\r\n}\r\n\r\n.icon-bold:before {\r\n content: \"\\E677\";\r\n}\r\n\r\n.icon-group:before {\r\n content: \"\\E647\";\r\n}\r\n\r\n.icon-img:before {\r\n content: \"\\E64A\";\r\n}\r\n\r\n.icon-under-line:before {\r\n content: \"\\E65A\";\r\n}\r\n\r\n.icon-close:before {\r\n content: \"\\E690\";\r\n}\r\n\r\n.icon-italic:before {\r\n content: \"\\E628\";\r\n}\r\n\r\n.icon-overline:before {\r\n content: \"\\E63B\";\r\n}\r\n\r\n.icon-horizontal:before {\r\n content: \"\\E7F0\";\r\n}\r\n\r\n.icon-theme:before {\r\n content: \"\\E682\";\r\n}\r\n\r\n.icon-quote:before {\r\n content: \"\\E636\";\r\n}\r\n\r\n.icon-table:before {\r\n content: \"\\E603\";\r\n}\r\n\r\n.icon-clear:before {\r\n content: \"\\E629\";\r\n}\r\n\r\n.icon-ul:before {\r\n content: \"\\E624\";\r\n}\r\n\r\n.icon-code:before {\r\n content: \"\\E60F\";\r\n}\r\n\r\n.icon-link:before {\r\n content: \"\\E7E2\";\r\n}\r\n\r\n.icon-fullscreen:before {\r\n content: \"\\E7EC\";\r\n}\r\n\r\n.icon-quite:before {\r\n content: \"\\E7ED\";\r\n}\r\n\r\n.icon-daoru:before {\r\n content: \"\\E635\";\r\n}\r\n\r\n.icon-ol:before {\r\n content: \"\\E6F0\";\r\n}\r\n\r\n.icon-upload-img:before {\r\n content: \"\\E679\";\r\n}\r\n\r\n.icon-save:before {\r\n content: \"\\E648\";\r\n}\r\n\r\n.icon-check-box:before {\r\n content: \"\\EC58\";\r\n}\r\n\r\n", ""]);
  11607. // exports
  11608. /***/ }),
  11609. /***/ 406:
  11610. /***/ (function(module, exports) {
  11611. module.exports = "/fonts/pages/main/components/MDEditor/assets/font/iconfont.woff?70e0362d";
  11612. /***/ }),
  11613. /***/ 407:
  11614. /***/ (function(module, exports) {
  11615. module.exports = "/fonts/pages/main/components/MDEditor/assets/font/iconfont.ttf?b5f4d512";
  11616. /***/ }),
  11617. /***/ 408:
  11618. /***/ (function(module, exports) {
  11619. module.exports = "/fonts/pages/main/components/MDEditor/assets/font/iconfont.svg?3a9bde8a";
  11620. /***/ }),
  11621. /***/ 409:
  11622. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11623. "use strict";
  11624. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__assets_js_hightlight__ = __webpack_require__(410);
  11625. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__assets_js_marked__ = __webpack_require__(424);
  11626. __WEBPACK_IMPORTED_MODULE_0__assets_js_hightlight__["a" /* default */].initHighlightingOnLoad();
  11627. var renderer = new __WEBPACK_IMPORTED_MODULE_1__assets_js_marked__["a" /* default */].Renderer();
  11628. /* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_1__assets_js_marked__["a" /* default */].setOptions({
  11629. renderer: renderer,
  11630. gfm: true,
  11631. tables: true,
  11632. breaks: false,
  11633. pedantic: false,
  11634. sanitize: false,
  11635. smartLists: true,
  11636. highlight: function highlight(code) {
  11637. return __WEBPACK_IMPORTED_MODULE_0__assets_js_hightlight__["a" /* default */].highlightAuto(code).value;
  11638. }
  11639. }));
  11640. /***/ }),
  11641. /***/ 410:
  11642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11643. "use strict";
  11644. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__highlight__ = __webpack_require__(411);
  11645. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__languages_javascript__ = __webpack_require__(412);
  11646. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__languages_javascript___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__languages_javascript__);
  11647. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__languages_java__ = __webpack_require__(413);
  11648. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__languages_java___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2__languages_java__);
  11649. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__languages_css__ = __webpack_require__(414);
  11650. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__languages_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3__languages_css__);
  11651. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__languages_less__ = __webpack_require__(415);
  11652. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__languages_less___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4__languages_less__);
  11653. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__languages_go__ = __webpack_require__(416);
  11654. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__languages_go___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5__languages_go__);
  11655. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__languages_markdown__ = __webpack_require__(417);
  11656. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__languages_markdown___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6__languages_markdown__);
  11657. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__languages_php__ = __webpack_require__(418);
  11658. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__languages_php___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7__languages_php__);
  11659. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__languages_python__ = __webpack_require__(419);
  11660. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__languages_python___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8__languages_python__);
  11661. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__languages_typescript__ = __webpack_require__(420);
  11662. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__languages_typescript___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_9__languages_typescript__);
  11663. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__languages_xml__ = __webpack_require__(421);
  11664. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__languages_xml___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_10__languages_xml__);
  11665. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__languages_autohotkey__ = __webpack_require__(422);
  11666. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__languages_autohotkey___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_11__languages_autohotkey__);
  11667. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__languages_autoit__ = __webpack_require__(423);
  11668. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__languages_autoit___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_12__languages_autoit__);
  11669. //hljs体积过大,多数为解决代码高亮显示的问题,所以只引入部分语言,如果需要可自行加载
  11670. var languages = {
  11671. javascript: __WEBPACK_IMPORTED_MODULE_1__languages_javascript___default.a,
  11672. java: __WEBPACK_IMPORTED_MODULE_2__languages_java___default.a,
  11673. css: __WEBPACK_IMPORTED_MODULE_3__languages_css___default.a,
  11674. less: __WEBPACK_IMPORTED_MODULE_4__languages_less___default.a,
  11675. markdown: __WEBPACK_IMPORTED_MODULE_6__languages_markdown___default.a,
  11676. go: __WEBPACK_IMPORTED_MODULE_5__languages_go___default.a,
  11677. php: __WEBPACK_IMPORTED_MODULE_7__languages_php___default.a,
  11678. python: __WEBPACK_IMPORTED_MODULE_8__languages_python___default.a,
  11679. typescript: __WEBPACK_IMPORTED_MODULE_9__languages_typescript___default.a,
  11680. xml: __WEBPACK_IMPORTED_MODULE_10__languages_xml___default.a,
  11681. autohotkey: __WEBPACK_IMPORTED_MODULE_11__languages_autohotkey___default.a,
  11682. auto: __WEBPACK_IMPORTED_MODULE_12__languages_autoit___default.a
  11683. };
  11684. Object.keys(languages).forEach(function (key) {
  11685. __WEBPACK_IMPORTED_MODULE_0__highlight__["a" /* default */].registerLanguage(key, languages[key]);
  11686. });
  11687. /* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__highlight__["a" /* default */]);
  11688. /***/ }),
  11689. /***/ 411:
  11690. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11691. "use strict";
  11692. var hljs = {};
  11693. // Convenience variables for build-in objects
  11694. var ArrayProto = [],
  11695. objectKeys = Object.keys;
  11696. // Global internal variables used within the highlight.js library.
  11697. var languages = {},
  11698. aliases = {};
  11699. // Regular expressions used throughout the highlight.js library.
  11700. var noHighlightRe = /^(no-?highlight|plain|text)$/i,
  11701. languagePrefixRe = /\blang(?:uage)?-([\w-]+)\b/i,
  11702. fixMarkupRe = /((^(<[^>]+>|\t|)+|(?:\n)))/gm;
  11703. // The object will be assigned by the build tool. It used to synchronize API
  11704. // of external language files with minified version of the highlight.js library.
  11705. var API_REPLACES;
  11706. var spanEndTag = '</span>';
  11707. // Global options used when within external APIs. This is modified when
  11708. // calling the `hljs.configure` function.
  11709. var options = {
  11710. classPrefix: 'hljs-',
  11711. tabReplace: null,
  11712. useBR: false,
  11713. languages: undefined
  11714. };
  11715. /* Utility functions */
  11716. function escape(value) {
  11717. return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  11718. }
  11719. function tag(node) {
  11720. return node.nodeName.toLowerCase();
  11721. }
  11722. function testRe(re, lexeme) {
  11723. var match = re && re.exec(lexeme);
  11724. return match && match.index === 0;
  11725. }
  11726. function isNotHighlighted(language) {
  11727. return noHighlightRe.test(language);
  11728. }
  11729. function blockLanguage(block) {
  11730. var i, match, length, _class;
  11731. var classes = block.className + ' ';
  11732. classes += block.parentNode ? block.parentNode.className : '';
  11733. // language-* takes precedence over non-prefixed class names.
  11734. match = languagePrefixRe.exec(classes);
  11735. if (match) {
  11736. return getLanguage(match[1]) ? match[1] : 'no-highlight';
  11737. }
  11738. classes = classes.split(/\s+/);
  11739. for (i = 0, length = classes.length; i < length; i++) {
  11740. _class = classes[i];
  11741. if (isNotHighlighted(_class) || getLanguage(_class)) {
  11742. return _class;
  11743. }
  11744. }
  11745. }
  11746. function inherit(parent) {
  11747. // inherit(parent, override_obj, override_obj, ...)
  11748. var key;
  11749. var result = {};
  11750. var objects = Array.prototype.slice.call(arguments, 1);
  11751. for (key in parent) {
  11752. result[key] = parent[key];
  11753. }objects.forEach(function (obj) {
  11754. for (key in obj) {
  11755. result[key] = obj[key];
  11756. }
  11757. });
  11758. return result;
  11759. }
  11760. /* Stream merging */
  11761. function nodeStream(node) {
  11762. var result = [];
  11763. (function _nodeStream(node, offset) {
  11764. for (var child = node.firstChild; child; child = child.nextSibling) {
  11765. if (child.nodeType === 3) offset += child.nodeValue.length;else if (child.nodeType === 1) {
  11766. result.push({
  11767. event: 'start',
  11768. offset: offset,
  11769. node: child
  11770. });
  11771. offset = _nodeStream(child, offset);
  11772. // Prevent void elements from having an end tag that would actually
  11773. // double them in the output. There are more void elements in HTML
  11774. // but we list only those realistically expected in code display.
  11775. if (!tag(child).match(/br|hr|img|input/)) {
  11776. result.push({
  11777. event: 'stop',
  11778. offset: offset,
  11779. node: child
  11780. });
  11781. }
  11782. }
  11783. }
  11784. return offset;
  11785. })(node, 0);
  11786. return result;
  11787. }
  11788. function mergeStreams(original, highlighted, value) {
  11789. var processed = 0;
  11790. var result = '';
  11791. var nodeStack = [];
  11792. function selectStream() {
  11793. if (!original.length || !highlighted.length) {
  11794. return original.length ? original : highlighted;
  11795. }
  11796. if (original[0].offset !== highlighted[0].offset) {
  11797. return original[0].offset < highlighted[0].offset ? original : highlighted;
  11798. }
  11799. /*
  11800. To avoid starting the stream just before it should stop the order is
  11801. ensured that original always starts first and closes last:
  11802. if (event1 == 'start' && event2 == 'start')
  11803. return original;
  11804. if (event1 == 'start' && event2 == 'stop')
  11805. return highlighted;
  11806. if (event1 == 'stop' && event2 == 'start')
  11807. return original;
  11808. if (event1 == 'stop' && event2 == 'stop')
  11809. return highlighted;
  11810. ... which is collapsed to:
  11811. */
  11812. return highlighted[0].event === 'start' ? original : highlighted;
  11813. }
  11814. function open(node) {
  11815. function attr_str(a) {
  11816. return ' ' + a.nodeName + '="' + escape(a.value).replace('"', '&quot;') + '"';
  11817. }
  11818. result += '<' + tag(node) + ArrayProto.map.call(node.attributes, attr_str).join('') + '>';
  11819. }
  11820. function close(node) {
  11821. result += '</' + tag(node) + '>';
  11822. }
  11823. function render(event) {
  11824. (event.event === 'start' ? open : close)(event.node);
  11825. }
  11826. while (original.length || highlighted.length) {
  11827. var stream = selectStream();
  11828. result += escape(value.substring(processed, stream[0].offset));
  11829. processed = stream[0].offset;
  11830. if (stream === original) {
  11831. /*
  11832. On any opening or closing tag of the original markup we first close
  11833. the entire highlighted node stack, then render the original tag along
  11834. with all the following original tags at the same offset and then
  11835. reopen all the tags on the highlighted stack.
  11836. */
  11837. nodeStack.reverse().forEach(close);
  11838. do {
  11839. render(stream.splice(0, 1)[0]);
  11840. stream = selectStream();
  11841. } while (stream === original && stream.length && stream[0].offset === processed);
  11842. nodeStack.reverse().forEach(open);
  11843. } else {
  11844. if (stream[0].event === 'start') {
  11845. nodeStack.push(stream[0].node);
  11846. } else {
  11847. nodeStack.pop();
  11848. }
  11849. render(stream.splice(0, 1)[0]);
  11850. }
  11851. }
  11852. return result + escape(value.substr(processed));
  11853. }
  11854. /* Initialization */
  11855. function expand_mode(mode) {
  11856. if (mode.variants && !mode.cached_variants) {
  11857. mode.cached_variants = mode.variants.map(function (variant) {
  11858. return inherit(mode, { variants: null }, variant);
  11859. });
  11860. }
  11861. return mode.cached_variants || mode.endsWithParent && [inherit(mode)] || [mode];
  11862. }
  11863. function restoreLanguageApi(obj) {
  11864. if (API_REPLACES && !obj.langApiRestored) {
  11865. obj.langApiRestored = true;
  11866. for (var key in API_REPLACES) {
  11867. obj[key] && (obj[API_REPLACES[key]] = obj[key]);
  11868. }(obj.contains || []).concat(obj.variants || []).forEach(restoreLanguageApi);
  11869. }
  11870. }
  11871. function compileLanguage(language) {
  11872. function reStr(re) {
  11873. return re && re.source || re;
  11874. }
  11875. function langRe(value, global) {
  11876. return new RegExp(reStr(value), 'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : ''));
  11877. }
  11878. // joinRe logically computes regexps.join(separator), but fixes the
  11879. // backreferences so they continue to match.
  11880. function joinRe(regexps, separator) {
  11881. // backreferenceRe matches an open parenthesis or backreference. To avoid
  11882. // an incorrect parse, it additionally matches the following:
  11883. // - [...] elements, where the meaning of parentheses and escapes change
  11884. // - other escape sequences, so we do not misparse escape sequences as
  11885. // interesting elements
  11886. // - non-matching or lookahead parentheses, which do not capture. These
  11887. // follow the '(' with a '?'.
  11888. var backreferenceRe = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
  11889. var numCaptures = 0;
  11890. var ret = '';
  11891. for (var i = 0; i < regexps.length; i++) {
  11892. var offset = numCaptures;
  11893. var re = reStr(regexps[i]);
  11894. if (i > 0) {
  11895. ret += separator;
  11896. }
  11897. while (re.length > 0) {
  11898. var match = backreferenceRe.exec(re);
  11899. if (match == null) {
  11900. ret += re;
  11901. break;
  11902. }
  11903. ret += re.substring(0, match.index);
  11904. re = re.substring(match.index + match[0].length);
  11905. if (match[0][0] == '\\' && match[1]) {
  11906. // Adjust the backreference.
  11907. ret += '\\' + String(Number(match[1]) + offset);
  11908. } else {
  11909. ret += match[0];
  11910. if (match[0] == '(') {
  11911. numCaptures++;
  11912. }
  11913. }
  11914. }
  11915. }
  11916. return ret;
  11917. }
  11918. function compileMode(mode, parent) {
  11919. if (mode.compiled) return;
  11920. mode.compiled = true;
  11921. mode.keywords = mode.keywords || mode.beginKeywords;
  11922. if (mode.keywords) {
  11923. var compiled_keywords = {};
  11924. var flatten = function flatten(className, str) {
  11925. if (language.case_insensitive) {
  11926. str = str.toLowerCase();
  11927. }
  11928. str.split(' ').forEach(function (kw) {
  11929. var pair = kw.split('|');
  11930. compiled_keywords[pair[0]] = [className, pair[1] ? Number(pair[1]) : 1];
  11931. });
  11932. };
  11933. if (typeof mode.keywords === 'string') {
  11934. // string
  11935. flatten('keyword', mode.keywords);
  11936. } else {
  11937. objectKeys(mode.keywords).forEach(function (className) {
  11938. flatten(className, mode.keywords[className]);
  11939. });
  11940. }
  11941. mode.keywords = compiled_keywords;
  11942. }
  11943. mode.lexemesRe = langRe(mode.lexemes || /\w+/, true);
  11944. if (parent) {
  11945. if (mode.beginKeywords) {
  11946. mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')\\b';
  11947. }
  11948. if (!mode.begin) mode.begin = /\B|\b/;
  11949. mode.beginRe = langRe(mode.begin);
  11950. if (mode.endSameAsBegin) mode.end = mode.begin;
  11951. if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b/;
  11952. if (mode.end) mode.endRe = langRe(mode.end);
  11953. mode.terminator_end = reStr(mode.end) || '';
  11954. if (mode.endsWithParent && parent.terminator_end) mode.terminator_end += (mode.end ? '|' : '') + parent.terminator_end;
  11955. }
  11956. if (mode.illegal) mode.illegalRe = langRe(mode.illegal);
  11957. if (mode.relevance == null) mode.relevance = 1;
  11958. if (!mode.contains) {
  11959. mode.contains = [];
  11960. }
  11961. mode.contains = Array.prototype.concat.apply([], mode.contains.map(function (c) {
  11962. return expand_mode(c === 'self' ? mode : c);
  11963. }));
  11964. mode.contains.forEach(function (c) {
  11965. compileMode(c, mode);
  11966. });
  11967. if (mode.starts) {
  11968. compileMode(mode.starts, parent);
  11969. }
  11970. var terminators = mode.contains.map(function (c) {
  11971. return c.beginKeywords ? '\\.?(?:' + c.begin + ')\\.?' : c.begin;
  11972. }).concat([mode.terminator_end, mode.illegal]).map(reStr).filter(Boolean);
  11973. mode.terminators = terminators.length ? langRe(joinRe(terminators, '|'), true) : {
  11974. exec: function exec() /*s*/{
  11975. return null;
  11976. }
  11977. };
  11978. }
  11979. compileMode(language);
  11980. }
  11981. /*
  11982. Core highlighting function. Accepts a language name, or an alias, and a
  11983. string with the code to highlight. Returns an object with the following
  11984. properties:
  11985. - relevance (int)
  11986. - value (an HTML string with highlighting markup)
  11987. */
  11988. function highlight(name, value, ignore_illegals, continuation) {
  11989. function escapeRe(value) {
  11990. return new RegExp(value.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'm');
  11991. }
  11992. function subMode(lexeme, mode) {
  11993. var i, length;
  11994. for (i = 0, length = mode.contains.length; i < length; i++) {
  11995. if (testRe(mode.contains[i].beginRe, lexeme)) {
  11996. if (mode.contains[i].endSameAsBegin) {
  11997. mode.contains[i].endRe = escapeRe(mode.contains[i].beginRe.exec(lexeme)[0]);
  11998. }
  11999. return mode.contains[i];
  12000. }
  12001. }
  12002. }
  12003. function endOfMode(mode, lexeme) {
  12004. if (testRe(mode.endRe, lexeme)) {
  12005. while (mode.endsParent && mode.parent) {
  12006. mode = mode.parent;
  12007. }
  12008. return mode;
  12009. }
  12010. if (mode.endsWithParent) {
  12011. return endOfMode(mode.parent, lexeme);
  12012. }
  12013. }
  12014. function isIllegal(lexeme, mode) {
  12015. return !ignore_illegals && testRe(mode.illegalRe, lexeme);
  12016. }
  12017. function keywordMatch(mode, match) {
  12018. var match_str = language.case_insensitive ? match[0].toLowerCase() : match[0];
  12019. return mode.keywords.hasOwnProperty(match_str) && mode.keywords[match_str];
  12020. }
  12021. function buildSpan(classname, insideSpan, leaveOpen, noPrefix) {
  12022. var classPrefix = noPrefix ? '' : options.classPrefix,
  12023. openSpan = '<span class="' + classPrefix,
  12024. closeSpan = leaveOpen ? '' : spanEndTag;
  12025. openSpan += classname + '">';
  12026. if (!classname) return insideSpan;
  12027. return openSpan + insideSpan + closeSpan;
  12028. }
  12029. function processKeywords() {
  12030. var keyword_match, last_index, match, result;
  12031. if (!top.keywords) return escape(mode_buffer);
  12032. result = '';
  12033. last_index = 0;
  12034. top.lexemesRe.lastIndex = 0;
  12035. match = top.lexemesRe.exec(mode_buffer);
  12036. while (match) {
  12037. result += escape(mode_buffer.substring(last_index, match.index));
  12038. keyword_match = keywordMatch(top, match);
  12039. if (keyword_match) {
  12040. relevance += keyword_match[1];
  12041. result += buildSpan(keyword_match[0], escape(match[0]));
  12042. } else {
  12043. result += escape(match[0]);
  12044. }
  12045. last_index = top.lexemesRe.lastIndex;
  12046. match = top.lexemesRe.exec(mode_buffer);
  12047. }
  12048. return result + escape(mode_buffer.substr(last_index));
  12049. }
  12050. function processSubLanguage() {
  12051. var explicit = typeof top.subLanguage === 'string';
  12052. if (explicit && !languages[top.subLanguage]) {
  12053. return escape(mode_buffer);
  12054. }
  12055. var result = explicit ? highlight(top.subLanguage, mode_buffer, true, continuations[top.subLanguage]) : highlightAuto(mode_buffer, top.subLanguage.length ? top.subLanguage : undefined);
  12056. // Counting embedded language score towards the host language may be disabled
  12057. // with zeroing the containing mode relevance. Usecase in point is Markdown that
  12058. // allows XML everywhere and makes every XML snippet to have a much larger Markdown
  12059. // score.
  12060. if (top.relevance > 0) {
  12061. relevance += result.relevance;
  12062. }
  12063. if (explicit) {
  12064. continuations[top.subLanguage] = result.top;
  12065. }
  12066. return buildSpan(result.language, result.value, false, true);
  12067. }
  12068. function processBuffer() {
  12069. result += top.subLanguage != null ? processSubLanguage() : processKeywords();
  12070. mode_buffer = '';
  12071. }
  12072. function startNewMode(mode) {
  12073. result += mode.className ? buildSpan(mode.className, '', true) : '';
  12074. top = Object.create(mode, { parent: { value: top } });
  12075. }
  12076. function processLexeme(buffer, lexeme) {
  12077. mode_buffer += buffer;
  12078. if (lexeme == null) {
  12079. processBuffer();
  12080. return 0;
  12081. }
  12082. var new_mode = subMode(lexeme, top);
  12083. if (new_mode) {
  12084. if (new_mode.skip) {
  12085. mode_buffer += lexeme;
  12086. } else {
  12087. if (new_mode.excludeBegin) {
  12088. mode_buffer += lexeme;
  12089. }
  12090. processBuffer();
  12091. if (!new_mode.returnBegin && !new_mode.excludeBegin) {
  12092. mode_buffer = lexeme;
  12093. }
  12094. }
  12095. startNewMode(new_mode, lexeme);
  12096. return new_mode.returnBegin ? 0 : lexeme.length;
  12097. }
  12098. var end_mode = endOfMode(top, lexeme);
  12099. if (end_mode) {
  12100. var origin = top;
  12101. if (origin.skip) {
  12102. mode_buffer += lexeme;
  12103. } else {
  12104. if (!(origin.returnEnd || origin.excludeEnd)) {
  12105. mode_buffer += lexeme;
  12106. }
  12107. processBuffer();
  12108. if (origin.excludeEnd) {
  12109. mode_buffer = lexeme;
  12110. }
  12111. }
  12112. do {
  12113. if (top.className) {
  12114. result += spanEndTag;
  12115. }
  12116. if (!top.skip && !top.subLanguage) {
  12117. relevance += top.relevance;
  12118. }
  12119. top = top.parent;
  12120. } while (top !== end_mode.parent);
  12121. if (end_mode.starts) {
  12122. if (end_mode.endSameAsBegin) {
  12123. end_mode.starts.endRe = end_mode.endRe;
  12124. }
  12125. startNewMode(end_mode.starts, '');
  12126. }
  12127. return origin.returnEnd ? 0 : lexeme.length;
  12128. }
  12129. if (isIllegal(lexeme, top)) throw new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.className || '<unnamed>') + '"');
  12130. /*
  12131. Parser should not reach this point as all types of lexemes should be caught
  12132. earlier, but if it does due to some bug make sure it advances at least one
  12133. character forward to prevent infinite looping.
  12134. */
  12135. mode_buffer += lexeme;
  12136. return lexeme.length || 1;
  12137. }
  12138. var language = getLanguage(name);
  12139. if (!language) {
  12140. throw new Error('Unknown language: "' + name + '"');
  12141. }
  12142. compileLanguage(language);
  12143. var top = continuation || language;
  12144. var continuations = {}; // keep continuations for sub-languages
  12145. var result = '',
  12146. current;
  12147. for (current = top; current !== language; current = current.parent) {
  12148. if (current.className) {
  12149. result = buildSpan(current.className, '', true) + result;
  12150. }
  12151. }
  12152. var mode_buffer = '';
  12153. var relevance = 0;
  12154. try {
  12155. var match,
  12156. count,
  12157. index = 0;
  12158. while (true) {
  12159. top.terminators.lastIndex = index;
  12160. match = top.terminators.exec(value);
  12161. if (!match) break;
  12162. count = processLexeme(value.substring(index, match.index), match[0]);
  12163. index = match.index + count;
  12164. }
  12165. processLexeme(value.substr(index));
  12166. for (current = top; current.parent; current = current.parent) {
  12167. // close dangling modes
  12168. if (current.className) {
  12169. result += spanEndTag;
  12170. }
  12171. }
  12172. return {
  12173. relevance: relevance,
  12174. value: result,
  12175. language: name,
  12176. top: top
  12177. };
  12178. } catch (e) {
  12179. if (e.message && e.message.indexOf('Illegal') !== -1) {
  12180. return {
  12181. relevance: 0,
  12182. value: escape(value)
  12183. };
  12184. } else {
  12185. throw e;
  12186. }
  12187. }
  12188. }
  12189. /*
  12190. Highlighting with language detection. Accepts a string with the code to
  12191. highlight. Returns an object with the following properties:
  12192. - language (detected language)
  12193. - relevance (int)
  12194. - value (an HTML string with highlighting markup)
  12195. - second_best (object with the same structure for second-best heuristically
  12196. detected language, may be absent)
  12197. */
  12198. function highlightAuto(text, languageSubset) {
  12199. languageSubset = languageSubset || options.languages || objectKeys(languages);
  12200. var result = {
  12201. relevance: 0,
  12202. value: escape(text)
  12203. };
  12204. var second_best = result;
  12205. languageSubset.filter(getLanguage).filter(autoDetection).forEach(function (name) {
  12206. var current = highlight(name, text, false);
  12207. current.language = name;
  12208. if (current.relevance > second_best.relevance) {
  12209. second_best = current;
  12210. }
  12211. if (current.relevance > result.relevance) {
  12212. second_best = result;
  12213. result = current;
  12214. }
  12215. });
  12216. if (second_best.language) {
  12217. result.second_best = second_best;
  12218. }
  12219. return result;
  12220. }
  12221. /*
  12222. Post-processing of the highlighted markup:
  12223. - replace TABs with something more useful
  12224. - replace real line-breaks with '<br>' for non-pre containers
  12225. */
  12226. function fixMarkup(value) {
  12227. return !(options.tabReplace || options.useBR) ? value : value.replace(fixMarkupRe, function (match, p1) {
  12228. if (options.useBR && match === '\n') {
  12229. return '<br>';
  12230. } else if (options.tabReplace) {
  12231. return p1.replace(/\t/g, options.tabReplace);
  12232. }
  12233. return '';
  12234. });
  12235. }
  12236. function buildClassName(prevClassName, currentLang, resultLang) {
  12237. var language = currentLang ? aliases[currentLang] : resultLang,
  12238. result = [prevClassName.trim()];
  12239. if (!prevClassName.match(/\bhljs\b/)) {
  12240. result.push('hljs');
  12241. }
  12242. if (prevClassName.indexOf(language) === -1) {
  12243. result.push(language);
  12244. }
  12245. return result.join(' ').trim();
  12246. }
  12247. /*
  12248. Applies highlighting to a DOM node containing code. Accepts a DOM node and
  12249. two optional parameters for fixMarkup.
  12250. */
  12251. function highlightBlock(block) {
  12252. var node, originalStream, result, resultNode, text;
  12253. var language = blockLanguage(block);
  12254. if (isNotHighlighted(language)) return;
  12255. if (options.useBR) {
  12256. node = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
  12257. node.innerHTML = block.innerHTML.replace(/\n/g, '').replace(/<br[ \/]*>/g, '\n');
  12258. } else {
  12259. node = block;
  12260. }
  12261. text = node.textContent;
  12262. result = language ? highlight(language, text, true) : highlightAuto(text);
  12263. originalStream = nodeStream(node);
  12264. if (originalStream.length) {
  12265. resultNode = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
  12266. resultNode.innerHTML = result.value;
  12267. result.value = mergeStreams(originalStream, nodeStream(resultNode), text);
  12268. }
  12269. result.value = fixMarkup(result.value);
  12270. block.innerHTML = result.value;
  12271. block.className = buildClassName(block.className, language, result.language);
  12272. block.result = {
  12273. language: result.language,
  12274. re: result.relevance
  12275. };
  12276. if (result.second_best) {
  12277. block.second_best = {
  12278. language: result.second_best.language,
  12279. re: result.second_best.relevance
  12280. };
  12281. }
  12282. }
  12283. /*
  12284. Updates highlight.js global options with values passed in the form of an object.
  12285. */
  12286. function configure(user_options) {
  12287. options = inherit(options, user_options);
  12288. }
  12289. /*
  12290. Applies highlighting to all <pre><code>..</code></pre> blocks on a page.
  12291. */
  12292. function initHighlighting() {
  12293. if (initHighlighting.called) return;
  12294. initHighlighting.called = true;
  12295. var blocks = document.querySelectorAll('pre code');
  12296. ArrayProto.forEach.call(blocks, highlightBlock);
  12297. }
  12298. /*
  12299. Attaches highlighting to the page load event.
  12300. */
  12301. function initHighlightingOnLoad() {
  12302. addEventListener('DOMContentLoaded', initHighlighting, false);
  12303. addEventListener('load', initHighlighting, false);
  12304. }
  12305. function registerLanguage(name, language) {
  12306. var lang = languages[name] = language(hljs);
  12307. restoreLanguageApi(lang);
  12308. if (lang.aliases) {
  12309. lang.aliases.forEach(function (alias) {
  12310. aliases[alias] = name;
  12311. });
  12312. }
  12313. }
  12314. function listLanguages() {
  12315. return objectKeys(languages);
  12316. }
  12317. function getLanguage(name) {
  12318. name = (name || '').toLowerCase();
  12319. return languages[name] || languages[aliases[name]];
  12320. }
  12321. function autoDetection(name) {
  12322. var lang = getLanguage(name);
  12323. return lang && !lang.disableAutodetect;
  12324. }
  12325. /* Interface definition */
  12326. hljs.highlight = highlight;
  12327. hljs.highlightAuto = highlightAuto;
  12328. hljs.fixMarkup = fixMarkup;
  12329. hljs.highlightBlock = highlightBlock;
  12330. hljs.configure = configure;
  12331. hljs.initHighlighting = initHighlighting;
  12332. hljs.initHighlightingOnLoad = initHighlightingOnLoad;
  12333. hljs.registerLanguage = registerLanguage;
  12334. hljs.listLanguages = listLanguages;
  12335. hljs.getLanguage = getLanguage;
  12336. hljs.autoDetection = autoDetection;
  12337. hljs.inherit = inherit;
  12338. // Common regexps
  12339. hljs.IDENT_RE = '[a-zA-Z]\\w*';
  12340. hljs.UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*';
  12341. hljs.NUMBER_RE = '\\b\\d+(\\.\\d+)?';
  12342. hljs.C_NUMBER_RE = '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)'; // 0x..., 0..., decimal, float
  12343. hljs.BINARY_NUMBER_RE = '\\b(0b[01]+)'; // 0b...
  12344. hljs.RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~';
  12345. // Common modes
  12346. hljs.BACKSLASH_ESCAPE = {
  12347. begin: '\\\\[\\s\\S]', relevance: 0
  12348. };
  12349. hljs.APOS_STRING_MODE = {
  12350. className: 'string',
  12351. begin: '\'', end: '\'',
  12352. illegal: '\\n',
  12353. contains: [hljs.BACKSLASH_ESCAPE]
  12354. };
  12355. hljs.QUOTE_STRING_MODE = {
  12356. className: 'string',
  12357. begin: '"', end: '"',
  12358. illegal: '\\n',
  12359. contains: [hljs.BACKSLASH_ESCAPE]
  12360. };
  12361. hljs.PHRASAL_WORDS_MODE = {
  12362. begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
  12363. };
  12364. hljs.COMMENT = function (begin, end, inherits) {
  12365. var mode = hljs.inherit({
  12366. className: 'comment',
  12367. begin: begin, end: end,
  12368. contains: []
  12369. }, inherits || {});
  12370. mode.contains.push(hljs.PHRASAL_WORDS_MODE);
  12371. mode.contains.push({
  12372. className: 'doctag',
  12373. begin: '(?:TODO|FIXME|NOTE|BUG|XXX):',
  12374. relevance: 0
  12375. });
  12376. return mode;
  12377. };
  12378. hljs.C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$');
  12379. hljs.C_BLOCK_COMMENT_MODE = hljs.COMMENT('/\\*', '\\*/');
  12380. hljs.HASH_COMMENT_MODE = hljs.COMMENT('#', '$');
  12381. hljs.NUMBER_MODE = {
  12382. className: 'number',
  12383. begin: hljs.NUMBER_RE,
  12384. relevance: 0
  12385. };
  12386. hljs.C_NUMBER_MODE = {
  12387. className: 'number',
  12388. begin: hljs.C_NUMBER_RE,
  12389. relevance: 0
  12390. };
  12391. hljs.BINARY_NUMBER_MODE = {
  12392. className: 'number',
  12393. begin: hljs.BINARY_NUMBER_RE,
  12394. relevance: 0
  12395. };
  12396. hljs.CSS_NUMBER_MODE = {
  12397. className: 'number',
  12398. begin: hljs.NUMBER_RE + '(' + '%|em|ex|ch|rem' + '|vw|vh|vmin|vmax' + '|cm|mm|in|pt|pc|px' + '|deg|grad|rad|turn' + '|s|ms' + '|Hz|kHz' + '|dpi|dpcm|dppx' + ')?',
  12399. relevance: 0
  12400. };
  12401. hljs.REGEXP_MODE = {
  12402. className: 'regexp',
  12403. begin: /\//, end: /\/[gimuy]*/,
  12404. illegal: /\n/,
  12405. contains: [hljs.BACKSLASH_ESCAPE, {
  12406. begin: /\[/, end: /\]/,
  12407. relevance: 0,
  12408. contains: [hljs.BACKSLASH_ESCAPE]
  12409. }]
  12410. };
  12411. hljs.TITLE_MODE = {
  12412. className: 'title',
  12413. begin: hljs.IDENT_RE,
  12414. relevance: 0
  12415. };
  12416. hljs.UNDERSCORE_TITLE_MODE = {
  12417. className: 'title',
  12418. begin: hljs.UNDERSCORE_IDENT_RE,
  12419. relevance: 0
  12420. };
  12421. hljs.METHOD_GUARD = {
  12422. // excludes method names from keyword processing
  12423. begin: '\\.\\s*' + hljs.UNDERSCORE_IDENT_RE,
  12424. relevance: 0
  12425. };
  12426. /* harmony default export */ __webpack_exports__["a"] = (hljs);
  12427. /***/ }),
  12428. /***/ 412:
  12429. /***/ (function(module, exports) {
  12430. module.exports = function (hljs) {
  12431. var IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
  12432. var KEYWORDS = {
  12433. keyword: 'in of if for while finally var new function do return void else break catch ' + 'instanceof with throw case default try this switch continue typeof delete ' + 'let yield const export super debugger as async await static ' +
  12434. // ECMAScript 6 modules import
  12435. 'import from as',
  12436. literal: 'true false null undefined NaN Infinity',
  12437. built_in: 'eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent ' + 'encodeURI encodeURIComponent escape unescape Object Function Boolean Error ' + 'EvalError InternalError RangeError ReferenceError StopIteration SyntaxError ' + 'TypeError URIError Number Math Date String RegExp Array Float32Array ' + 'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array ' + 'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require ' + 'module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect ' + 'Promise'
  12438. };
  12439. var NUMBER = {
  12440. className: 'number',
  12441. variants: [{ begin: '\\b(0[bB][01]+)' }, { begin: '\\b(0[oO][0-7]+)' }, { begin: hljs.C_NUMBER_RE }],
  12442. relevance: 0
  12443. };
  12444. var SUBST = {
  12445. className: 'subst',
  12446. begin: '\\$\\{', end: '\\}',
  12447. keywords: KEYWORDS,
  12448. contains: [] // defined later
  12449. };
  12450. var HTML_TEMPLATE = {
  12451. begin: 'html`', end: '',
  12452. starts: {
  12453. end: '`', returnEnd: false,
  12454. contains: [hljs.BACKSLASH_ESCAPE, SUBST],
  12455. subLanguage: 'xml'
  12456. }
  12457. };
  12458. var CSS_TEMPLATE = {
  12459. begin: 'css`', end: '',
  12460. starts: {
  12461. end: '`', returnEnd: false,
  12462. contains: [hljs.BACKSLASH_ESCAPE, SUBST],
  12463. subLanguage: 'css'
  12464. }
  12465. };
  12466. var TEMPLATE_STRING = {
  12467. className: 'string',
  12468. begin: '`', end: '`',
  12469. contains: [hljs.BACKSLASH_ESCAPE, SUBST]
  12470. };
  12471. SUBST.contains = [hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, HTML_TEMPLATE, CSS_TEMPLATE, TEMPLATE_STRING, NUMBER, hljs.REGEXP_MODE];
  12472. var PARAMS_CONTAINS = SUBST.contains.concat([hljs.C_BLOCK_COMMENT_MODE, hljs.C_LINE_COMMENT_MODE]);
  12473. return {
  12474. aliases: ['js', 'jsx'],
  12475. keywords: KEYWORDS,
  12476. contains: [{
  12477. className: 'meta',
  12478. relevance: 10,
  12479. begin: /^\s*['"]use (strict|asm)['"]/
  12480. }, {
  12481. className: 'meta',
  12482. begin: /^#!/, end: /$/
  12483. }, hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, HTML_TEMPLATE, CSS_TEMPLATE, TEMPLATE_STRING, hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, NUMBER, { // object attr container
  12484. begin: /[{,]\s*/, relevance: 0,
  12485. contains: [{
  12486. begin: IDENT_RE + '\\s*:', returnBegin: true,
  12487. relevance: 0,
  12488. contains: [{ className: 'attr', begin: IDENT_RE, relevance: 0 }]
  12489. }]
  12490. }, { // "value" container
  12491. begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
  12492. keywords: 'return throw case',
  12493. contains: [hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, hljs.REGEXP_MODE, {
  12494. className: 'function',
  12495. begin: '(\\(.*?\\)|' + IDENT_RE + ')\\s*=>', returnBegin: true,
  12496. end: '\\s*=>',
  12497. contains: [{
  12498. className: 'params',
  12499. variants: [{
  12500. begin: IDENT_RE
  12501. }, {
  12502. begin: /\(\s*\)/
  12503. }, {
  12504. begin: /\(/, end: /\)/,
  12505. excludeBegin: true, excludeEnd: true,
  12506. keywords: KEYWORDS,
  12507. contains: PARAMS_CONTAINS
  12508. }]
  12509. }]
  12510. }, {
  12511. className: '',
  12512. begin: /\s/,
  12513. end: /\s*/,
  12514. skip: true
  12515. }, { // E4X / JSX
  12516. begin: /</, end: /(\/[A-Za-z0-9\\._:-]+|[A-Za-z0-9\\._:-]+\/)>/,
  12517. subLanguage: 'xml',
  12518. contains: [{ begin: /<[A-Za-z0-9\\._:-]+\s*\/>/, skip: true }, {
  12519. begin: /<[A-Za-z0-9\\._:-]+/, end: /(\/[A-Za-z0-9\\._:-]+|[A-Za-z0-9\\._:-]+\/)>/, skip: true,
  12520. contains: [{ begin: /<[A-Za-z0-9\\._:-]+\s*\/>/, skip: true }, 'self']
  12521. }]
  12522. }],
  12523. relevance: 0
  12524. }, {
  12525. className: 'function',
  12526. beginKeywords: 'function', end: /\{/, excludeEnd: true,
  12527. contains: [hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE }), {
  12528. className: 'params',
  12529. begin: /\(/, end: /\)/,
  12530. excludeBegin: true,
  12531. excludeEnd: true,
  12532. contains: PARAMS_CONTAINS
  12533. }],
  12534. illegal: /\[|%/
  12535. }, {
  12536. begin: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
  12537. }, hljs.METHOD_GUARD, { // ES6 class
  12538. className: 'class',
  12539. beginKeywords: 'class', end: /[{;=]/, excludeEnd: true,
  12540. illegal: /[:"\[\]]/,
  12541. contains: [{ beginKeywords: 'extends' }, hljs.UNDERSCORE_TITLE_MODE]
  12542. }, {
  12543. beginKeywords: 'constructor get set', end: /\{/, excludeEnd: true
  12544. }],
  12545. illegal: /#(?!!)/
  12546. };
  12547. };
  12548. /***/ }),
  12549. /***/ 413:
  12550. /***/ (function(module, exports) {
  12551. module.exports = function (hljs) {
  12552. var JAVA_IDENT_RE = '[\xC0-\u02B8a-zA-Z_$][\xC0-\u02B8a-zA-Z_$0-9]*';
  12553. var GENERIC_IDENT_RE = JAVA_IDENT_RE + '(<' + JAVA_IDENT_RE + '(\\s*,\\s*' + JAVA_IDENT_RE + ')*>)?';
  12554. var KEYWORDS = 'false synchronized int abstract float private char boolean var static null if const ' + 'for true while long strictfp finally protected import native final void ' + 'enum else break transient catch instanceof byte super volatile case assert short ' + 'package default double public try this switch continue throws protected public private ' + 'module requires exports do';
  12555. // https://docs.oracle.com/javase/7/docs/technotes/guides/language/underscores-literals.html
  12556. var JAVA_NUMBER_RE = '\\b' + '(' + '0[bB]([01]+[01_]+[01]+|[01]+)' + // 0b...
  12557. '|' + '0[xX]([a-fA-F0-9]+[a-fA-F0-9_]+[a-fA-F0-9]+|[a-fA-F0-9]+)' + // 0x...
  12558. '|' + '(' + '([\\d]+[\\d_]+[\\d]+|[\\d]+)(\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))?' + '|' + '\\.([\\d]+[\\d_]+[\\d]+|[\\d]+)' + ')' + '([eE][-+]?\\d+)?' + // octal, decimal, float
  12559. ')' + '[lLfF]?';
  12560. var JAVA_NUMBER_MODE = {
  12561. className: 'number',
  12562. begin: JAVA_NUMBER_RE,
  12563. relevance: 0
  12564. };
  12565. return {
  12566. aliases: ['jsp'],
  12567. keywords: KEYWORDS,
  12568. illegal: /<\/|#/,
  12569. contains: [hljs.COMMENT('/\\*\\*', '\\*/', {
  12570. relevance: 0,
  12571. contains: [{
  12572. // eat up @'s in emails to prevent them to be recognized as doctags
  12573. begin: /\w+@/, relevance: 0
  12574. }, {
  12575. className: 'doctag',
  12576. begin: '@[A-Za-z]+'
  12577. }]
  12578. }), hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, {
  12579. className: 'class',
  12580. beginKeywords: 'class interface', end: /[{;=]/, excludeEnd: true,
  12581. keywords: 'class interface',
  12582. illegal: /[:"\[\]]/,
  12583. contains: [{ beginKeywords: 'extends implements' }, hljs.UNDERSCORE_TITLE_MODE]
  12584. }, {
  12585. // Expression keywords prevent 'keyword Name(...)' from being
  12586. // recognized as a function definition
  12587. beginKeywords: 'new throw return else',
  12588. relevance: 0
  12589. }, {
  12590. className: 'function',
  12591. begin: '(' + GENERIC_IDENT_RE + '\\s+)+' + hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true, end: /[{;=]/,
  12592. excludeEnd: true,
  12593. keywords: KEYWORDS,
  12594. contains: [{
  12595. begin: hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true,
  12596. relevance: 0,
  12597. contains: [hljs.UNDERSCORE_TITLE_MODE]
  12598. }, {
  12599. className: 'params',
  12600. begin: /\(/, end: /\)/,
  12601. keywords: KEYWORDS,
  12602. relevance: 0,
  12603. contains: [hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, hljs.C_NUMBER_MODE, hljs.C_BLOCK_COMMENT_MODE]
  12604. }, hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE]
  12605. }, JAVA_NUMBER_MODE, {
  12606. className: 'meta', begin: '@[A-Za-z]+'
  12607. }]
  12608. };
  12609. };
  12610. /***/ }),
  12611. /***/ 414:
  12612. /***/ (function(module, exports) {
  12613. module.exports = function (hljs) {
  12614. var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
  12615. var RULE = {
  12616. begin: /(?:[A-Z\_\.\-]+|--[a-zA-Z0-9_-]+)\s*:/, returnBegin: true, end: ';', endsWithParent: true,
  12617. contains: [{
  12618. className: 'attribute',
  12619. begin: /\S/, end: ':', excludeEnd: true,
  12620. starts: {
  12621. endsWithParent: true, excludeEnd: true,
  12622. contains: [{
  12623. begin: /[\w-]+\(/, returnBegin: true,
  12624. contains: [{
  12625. className: 'built_in',
  12626. begin: /[\w-]+/
  12627. }, {
  12628. begin: /\(/, end: /\)/,
  12629. contains: [hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE]
  12630. }]
  12631. }, hljs.CSS_NUMBER_MODE, hljs.QUOTE_STRING_MODE, hljs.APOS_STRING_MODE, hljs.C_BLOCK_COMMENT_MODE, {
  12632. className: 'number', begin: '#[0-9A-Fa-f]+'
  12633. }, {
  12634. className: 'meta', begin: '!important'
  12635. }]
  12636. }
  12637. }]
  12638. };
  12639. return {
  12640. case_insensitive: true,
  12641. illegal: /[=\/|'\$]/,
  12642. contains: [hljs.C_BLOCK_COMMENT_MODE, {
  12643. className: 'selector-id', begin: /#[A-Za-z0-9_-]+/
  12644. }, {
  12645. className: 'selector-class', begin: /\.[A-Za-z0-9_-]+/
  12646. }, {
  12647. className: 'selector-attr',
  12648. begin: /\[/, end: /\]/,
  12649. illegal: '$'
  12650. }, {
  12651. className: 'selector-pseudo',
  12652. begin: /:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/
  12653. }, {
  12654. begin: '@(font-face|page)',
  12655. lexemes: '[a-z-]+',
  12656. keywords: 'font-face page'
  12657. }, {
  12658. begin: '@', end: '[{;]', // at_rule eating first "{" is a good thing
  12659. // because it doesn’t let it to be parsed as
  12660. // a rule set but instead drops parser into
  12661. // the default mode which is how it should be.
  12662. illegal: /:/, // break on Less variables @var: ...
  12663. contains: [{
  12664. className: 'keyword',
  12665. begin: /\w+/
  12666. }, {
  12667. begin: /\s/, endsWithParent: true, excludeEnd: true,
  12668. relevance: 0,
  12669. contains: [hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, hljs.CSS_NUMBER_MODE]
  12670. }]
  12671. }, {
  12672. className: 'selector-tag', begin: IDENT_RE,
  12673. relevance: 0
  12674. }, {
  12675. begin: '{', end: '}',
  12676. illegal: /\S/,
  12677. contains: [hljs.C_BLOCK_COMMENT_MODE, RULE]
  12678. }]
  12679. };
  12680. };
  12681. /***/ }),
  12682. /***/ 415:
  12683. /***/ (function(module, exports) {
  12684. module.exports = function (hljs) {
  12685. var IDENT_RE = '[\\w-]+'; // yes, Less identifiers may begin with a digit
  12686. var INTERP_IDENT_RE = '(' + IDENT_RE + '|@{' + IDENT_RE + '})';
  12687. /* Generic Modes */
  12688. var RULES = [],
  12689. VALUE = []; // forward def. for recursive modes
  12690. var STRING_MODE = function STRING_MODE(c) {
  12691. return {
  12692. // Less strings are not multiline (also include '~' for more consistent coloring of "escaped" strings)
  12693. className: 'string', begin: '~?' + c + '.*?' + c
  12694. };
  12695. };
  12696. var IDENT_MODE = function IDENT_MODE(name, begin, relevance) {
  12697. return {
  12698. className: name, begin: begin, relevance: relevance
  12699. };
  12700. };
  12701. var PARENS_MODE = {
  12702. // used only to properly balance nested parens inside mixin call, def. arg list
  12703. begin: '\\(', end: '\\)', contains: VALUE, relevance: 0
  12704. };
  12705. // generic Less highlighter (used almost everywhere except selectors):
  12706. VALUE.push(hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, STRING_MODE("'"), STRING_MODE('"'), hljs.CSS_NUMBER_MODE, // fixme: it does not include dot for numbers like .5em :(
  12707. {
  12708. begin: '(url|data-uri)\\(',
  12709. starts: { className: 'string', end: '[\\)\\n]', excludeEnd: true }
  12710. }, IDENT_MODE('number', '#[0-9A-Fa-f]+\\b'), PARENS_MODE, IDENT_MODE('variable', '@@?' + IDENT_RE, 10), IDENT_MODE('variable', '@{' + IDENT_RE + '}'), IDENT_MODE('built_in', '~?`[^`]*?`'), // inline javascript (or whatever host language) *multiline* string
  12711. { // @media features (it’s here to not duplicate things in AT_RULE_MODE with extra PARENS_MODE overriding):
  12712. className: 'attribute', begin: IDENT_RE + '\\s*:', end: ':', returnBegin: true, excludeEnd: true
  12713. }, {
  12714. className: 'meta',
  12715. begin: '!important'
  12716. });
  12717. var VALUE_WITH_RULESETS = VALUE.concat({
  12718. begin: '{', end: '}', contains: RULES
  12719. });
  12720. var MIXIN_GUARD_MODE = {
  12721. beginKeywords: 'when', endsWithParent: true,
  12722. contains: [{ beginKeywords: 'and not' }].concat(VALUE) // using this form to override VALUE’s 'function' match
  12723. };
  12724. /* Rule-Level Modes */
  12725. var RULE_MODE = {
  12726. begin: INTERP_IDENT_RE + '\\s*:', returnBegin: true, end: '[;}]',
  12727. relevance: 0,
  12728. contains: [{
  12729. className: 'attribute',
  12730. begin: INTERP_IDENT_RE, end: ':', excludeEnd: true,
  12731. starts: {
  12732. endsWithParent: true, illegal: '[<=$]',
  12733. relevance: 0,
  12734. contains: VALUE
  12735. }
  12736. }]
  12737. };
  12738. var AT_RULE_MODE = {
  12739. className: 'keyword',
  12740. begin: '@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b',
  12741. starts: { end: '[;{}]', returnEnd: true, contains: VALUE, relevance: 0 }
  12742. };
  12743. // variable definitions and calls
  12744. var VAR_RULE_MODE = {
  12745. className: 'variable',
  12746. variants: [
  12747. // using more strict pattern for higher relevance to increase chances of Less detection.
  12748. // this is *the only* Less specific statement used in most of the sources, so...
  12749. // (we’ll still often loose to the css-parser unless there's '//' comment,
  12750. // simply because 1 variable just can't beat 99 properties :)
  12751. { begin: '@' + IDENT_RE + '\\s*:', relevance: 15 }, { begin: '@' + IDENT_RE }],
  12752. starts: { end: '[;}]', returnEnd: true, contains: VALUE_WITH_RULESETS }
  12753. };
  12754. var SELECTOR_MODE = {
  12755. // first parse unambiguous selectors (i.e. those not starting with tag)
  12756. // then fall into the scary lookahead-discriminator variant.
  12757. // this mode also handles mixin definitions and calls
  12758. variants: [{
  12759. begin: '[\\.#:&\\[>]', end: '[;{}]' // mixin calls end with ';'
  12760. }, {
  12761. begin: INTERP_IDENT_RE, end: '{'
  12762. }],
  12763. returnBegin: true,
  12764. returnEnd: true,
  12765. illegal: '[<=\'$"]',
  12766. relevance: 0,
  12767. contains: [hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, MIXIN_GUARD_MODE, IDENT_MODE('keyword', 'all\\b'), IDENT_MODE('variable', '@{' + IDENT_RE + '}'), // otherwise it’s identified as tag
  12768. IDENT_MODE('selector-tag', INTERP_IDENT_RE + '%?', 0), // '%' for more consistent coloring of @keyframes "tags"
  12769. IDENT_MODE('selector-id', '#' + INTERP_IDENT_RE), IDENT_MODE('selector-class', '\\.' + INTERP_IDENT_RE, 0), IDENT_MODE('selector-tag', '&', 0), { className: 'selector-attr', begin: '\\[', end: '\\]' }, { className: 'selector-pseudo', begin: /:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/ }, { begin: '\\(', end: '\\)', contains: VALUE_WITH_RULESETS }, // argument list of parametric mixins
  12770. { begin: '!important' // eat !important after mixin call or it will be colored as tag
  12771. }]
  12772. };
  12773. RULES.push(hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, AT_RULE_MODE, VAR_RULE_MODE, RULE_MODE, SELECTOR_MODE);
  12774. return {
  12775. case_insensitive: true,
  12776. illegal: '[=>\'/<($"]',
  12777. contains: RULES
  12778. };
  12779. };
  12780. /***/ }),
  12781. /***/ 416:
  12782. /***/ (function(module, exports) {
  12783. module.exports = function (hljs) {
  12784. var GO_KEYWORDS = {
  12785. keyword: 'break default func interface select case map struct chan else goto package switch ' + 'const fallthrough if range type continue for import return var go defer ' + 'bool byte complex64 complex128 float32 float64 int8 int16 int32 int64 string uint8 ' + 'uint16 uint32 uint64 int uint uintptr rune',
  12786. literal: 'true false iota nil',
  12787. built_in: 'append cap close complex copy imag len make new panic print println real recover delete'
  12788. };
  12789. return {
  12790. aliases: ['golang'],
  12791. keywords: GO_KEYWORDS,
  12792. illegal: '</',
  12793. contains: [hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, {
  12794. className: 'string',
  12795. variants: [hljs.QUOTE_STRING_MODE, { begin: '\'', end: '[^\\\\]\'' }, { begin: '`', end: '`' }]
  12796. }, {
  12797. className: 'number',
  12798. variants: [{ begin: hljs.C_NUMBER_RE + '[i]', relevance: 1 }, hljs.C_NUMBER_MODE]
  12799. }, {
  12800. begin: /:=/ // relevance booster
  12801. }, {
  12802. className: 'function',
  12803. beginKeywords: 'func', end: /\s*\{/, excludeEnd: true,
  12804. contains: [hljs.TITLE_MODE, {
  12805. className: 'params',
  12806. begin: /\(/, end: /\)/,
  12807. keywords: GO_KEYWORDS,
  12808. illegal: /["']/
  12809. }]
  12810. }]
  12811. };
  12812. };
  12813. /***/ }),
  12814. /***/ 417:
  12815. /***/ (function(module, exports) {
  12816. module.exports = function (hljs) {
  12817. return {
  12818. aliases: ['md', 'mkdown', 'mkd'],
  12819. contains: [
  12820. // highlight headers
  12821. {
  12822. className: 'section',
  12823. variants: [{ begin: '^#{1,6}', end: '$' }, { begin: '^.+?\\n[=-]{2,}$' }]
  12824. },
  12825. // inline html
  12826. {
  12827. begin: '<', end: '>',
  12828. subLanguage: 'xml',
  12829. relevance: 0
  12830. },
  12831. // lists (indicators only)
  12832. {
  12833. className: 'bullet',
  12834. begin: '^\\s*([*+-]|(\\d+\\.))\\s+'
  12835. },
  12836. // strong segments
  12837. {
  12838. className: 'strong',
  12839. begin: '[*_]{2}.+?[*_]{2}'
  12840. },
  12841. // emphasis segments
  12842. {
  12843. className: 'emphasis',
  12844. variants: [{ begin: '\\*.+?\\*' }, { begin: '_.+?_',
  12845. relevance: 0
  12846. }]
  12847. },
  12848. // blockquotes
  12849. {
  12850. className: 'quote',
  12851. begin: '^>\\s+', end: '$'
  12852. },
  12853. // code snippets
  12854. {
  12855. className: 'code',
  12856. variants: [{
  12857. begin: '^```\w*\s*$', end: '^```\s*$'
  12858. }, {
  12859. begin: '`.+?`'
  12860. }, {
  12861. begin: '^( {4}|\t)', end: '$',
  12862. relevance: 0
  12863. }]
  12864. },
  12865. // horizontal rules
  12866. {
  12867. begin: '^[-\\*]{3,}', end: '$'
  12868. },
  12869. // using links - title and link
  12870. {
  12871. begin: '\\[.+?\\][\\(\\[].*?[\\)\\]]',
  12872. returnBegin: true,
  12873. contains: [{
  12874. className: 'string',
  12875. begin: '\\[', end: '\\]',
  12876. excludeBegin: true,
  12877. returnEnd: true,
  12878. relevance: 0
  12879. }, {
  12880. className: 'link',
  12881. begin: '\\]\\(', end: '\\)',
  12882. excludeBegin: true, excludeEnd: true
  12883. }, {
  12884. className: 'symbol',
  12885. begin: '\\]\\[', end: '\\]',
  12886. excludeBegin: true, excludeEnd: true
  12887. }],
  12888. relevance: 10
  12889. }, {
  12890. begin: /^\[[^\n]+\]:/,
  12891. returnBegin: true,
  12892. contains: [{
  12893. className: 'symbol',
  12894. begin: /\[/, end: /\]/,
  12895. excludeBegin: true, excludeEnd: true
  12896. }, {
  12897. className: 'link',
  12898. begin: /:\s*/, end: /$/,
  12899. excludeBegin: true
  12900. }]
  12901. }]
  12902. };
  12903. };
  12904. /***/ }),
  12905. /***/ 418:
  12906. /***/ (function(module, exports) {
  12907. module.exports = function (hljs) {
  12908. var VARIABLE = {
  12909. begin: '\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
  12910. };
  12911. var PREPROCESSOR = {
  12912. className: 'meta', begin: /<\?(php)?|\?>/
  12913. };
  12914. var STRING = {
  12915. className: 'string',
  12916. contains: [hljs.BACKSLASH_ESCAPE, PREPROCESSOR],
  12917. variants: [{
  12918. begin: 'b"', end: '"'
  12919. }, {
  12920. begin: 'b\'', end: '\''
  12921. }, hljs.inherit(hljs.APOS_STRING_MODE, { illegal: null }), hljs.inherit(hljs.QUOTE_STRING_MODE, { illegal: null })]
  12922. };
  12923. var NUMBER = { variants: [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE] };
  12924. return {
  12925. aliases: ['php', 'php3', 'php4', 'php5', 'php6', 'php7'],
  12926. case_insensitive: true,
  12927. keywords: 'and include_once list abstract global private echo interface as static endswitch ' + 'array null if endwhile or const for endforeach self var while isset public ' + 'protected exit foreach throw elseif include __FILE__ empty require_once do xor ' + 'return parent clone use __CLASS__ __LINE__ else break print eval new ' + 'catch __METHOD__ case exception default die require __FUNCTION__ ' + 'enddeclare final try switch continue endfor endif declare unset true false ' + 'trait goto instanceof insteadof __DIR__ __NAMESPACE__ ' + 'yield finally',
  12928. contains: [hljs.HASH_COMMENT_MODE, hljs.COMMENT('//', '$', { contains: [PREPROCESSOR] }), hljs.COMMENT('/\\*', '\\*/', {
  12929. contains: [{
  12930. className: 'doctag',
  12931. begin: '@[A-Za-z]+'
  12932. }]
  12933. }), hljs.COMMENT('__halt_compiler.+?;', false, {
  12934. endsWithParent: true,
  12935. keywords: '__halt_compiler',
  12936. lexemes: hljs.UNDERSCORE_IDENT_RE
  12937. }), {
  12938. className: 'string',
  12939. begin: /<<<['"]?\w+['"]?$/, end: /^\w+;?$/,
  12940. contains: [hljs.BACKSLASH_ESCAPE, {
  12941. className: 'subst',
  12942. variants: [{ begin: /\$\w+/ }, { begin: /\{\$/, end: /\}/ }]
  12943. }]
  12944. }, PREPROCESSOR, {
  12945. className: 'keyword', begin: /\$this\b/
  12946. }, VARIABLE, {
  12947. // swallow composed identifiers to avoid parsing them as keywords
  12948. begin: /(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/
  12949. }, {
  12950. className: 'function',
  12951. beginKeywords: 'function', end: /[;{]/, excludeEnd: true,
  12952. illegal: '\\$|\\[|%',
  12953. contains: [hljs.UNDERSCORE_TITLE_MODE, {
  12954. className: 'params',
  12955. begin: '\\(', end: '\\)',
  12956. contains: ['self', VARIABLE, hljs.C_BLOCK_COMMENT_MODE, STRING, NUMBER]
  12957. }]
  12958. }, {
  12959. className: 'class',
  12960. beginKeywords: 'class interface', end: '{', excludeEnd: true,
  12961. illegal: /[:\(\$"]/,
  12962. contains: [{ beginKeywords: 'extends implements' }, hljs.UNDERSCORE_TITLE_MODE]
  12963. }, {
  12964. beginKeywords: 'namespace', end: ';',
  12965. illegal: /[\.']/,
  12966. contains: [hljs.UNDERSCORE_TITLE_MODE]
  12967. }, {
  12968. beginKeywords: 'use', end: ';',
  12969. contains: [hljs.UNDERSCORE_TITLE_MODE]
  12970. }, {
  12971. begin: '=>' // No markup, just a relevance booster
  12972. }, STRING, NUMBER]
  12973. };
  12974. };
  12975. /***/ }),
  12976. /***/ 419:
  12977. /***/ (function(module, exports) {
  12978. module.exports = function (hljs) {
  12979. var KEYWORDS = {
  12980. keyword: 'and elif is global as in if from raise for except finally print import pass return ' + 'exec else break not with class assert yield try while continue del or def lambda ' + 'async await nonlocal|10',
  12981. built_in: 'Ellipsis NotImplemented',
  12982. literal: 'False None True'
  12983. };
  12984. var PROMPT = {
  12985. className: 'meta', begin: /^(>>>|\.\.\.) /
  12986. };
  12987. var SUBST = {
  12988. className: 'subst',
  12989. begin: /\{/, end: /\}/,
  12990. keywords: KEYWORDS,
  12991. illegal: /#/
  12992. };
  12993. var STRING = {
  12994. className: 'string',
  12995. contains: [hljs.BACKSLASH_ESCAPE],
  12996. variants: [{
  12997. begin: /(u|b)?r?'''/, end: /'''/,
  12998. contains: [hljs.BACKSLASH_ESCAPE, PROMPT],
  12999. relevance: 10
  13000. }, {
  13001. begin: /(u|b)?r?"""/, end: /"""/,
  13002. contains: [hljs.BACKSLASH_ESCAPE, PROMPT],
  13003. relevance: 10
  13004. }, {
  13005. begin: /(fr|rf|f)'''/, end: /'''/,
  13006. contains: [hljs.BACKSLASH_ESCAPE, PROMPT, SUBST]
  13007. }, {
  13008. begin: /(fr|rf|f)"""/, end: /"""/,
  13009. contains: [hljs.BACKSLASH_ESCAPE, PROMPT, SUBST]
  13010. }, {
  13011. begin: /(u|r|ur)'/, end: /'/,
  13012. relevance: 10
  13013. }, {
  13014. begin: /(u|r|ur)"/, end: /"/,
  13015. relevance: 10
  13016. }, {
  13017. begin: /(b|br)'/, end: /'/
  13018. }, {
  13019. begin: /(b|br)"/, end: /"/
  13020. }, {
  13021. begin: /(fr|rf|f)'/, end: /'/,
  13022. contains: [hljs.BACKSLASH_ESCAPE, SUBST]
  13023. }, {
  13024. begin: /(fr|rf|f)"/, end: /"/,
  13025. contains: [hljs.BACKSLASH_ESCAPE, SUBST]
  13026. }, hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE]
  13027. };
  13028. var NUMBER = {
  13029. className: 'number', relevance: 0,
  13030. variants: [{ begin: hljs.BINARY_NUMBER_RE + '[lLjJ]?' }, { begin: '\\b(0o[0-7]+)[lLjJ]?' }, { begin: hljs.C_NUMBER_RE + '[lLjJ]?' }]
  13031. };
  13032. var PARAMS = {
  13033. className: 'params',
  13034. begin: /\(/, end: /\)/,
  13035. contains: ['self', PROMPT, NUMBER, STRING]
  13036. };
  13037. SUBST.contains = [STRING, NUMBER, PROMPT];
  13038. return {
  13039. aliases: ['py', 'gyp', 'ipython'],
  13040. keywords: KEYWORDS,
  13041. illegal: /(<\/|->|\?)|=>/,
  13042. contains: [PROMPT, NUMBER, STRING, hljs.HASH_COMMENT_MODE, {
  13043. variants: [{ className: 'function', beginKeywords: 'def' }, { className: 'class', beginKeywords: 'class' }],
  13044. end: /:/,
  13045. illegal: /[${=;\n,]/,
  13046. contains: [hljs.UNDERSCORE_TITLE_MODE, PARAMS, {
  13047. begin: /->/, endsWithParent: true,
  13048. keywords: 'None'
  13049. }]
  13050. }, {
  13051. className: 'meta',
  13052. begin: /^[\t ]*@/, end: /$/
  13053. }, {
  13054. begin: /\b(print|exec)\(/ // don’t highlight keywords-turned-functions in Python 3
  13055. }]
  13056. };
  13057. };
  13058. /***/ }),
  13059. /***/ 420:
  13060. /***/ (function(module, exports) {
  13061. module.exports = function (hljs) {
  13062. var JS_IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
  13063. var KEYWORDS = {
  13064. keyword: 'in if for while finally var new function do return void else break catch ' + 'instanceof with throw case default try this switch continue typeof delete ' + 'let yield const class public private protected get set super ' + 'static implements enum export import declare type namespace abstract ' + 'as from extends async await',
  13065. literal: 'true false null undefined NaN Infinity',
  13066. built_in: 'eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent ' + 'encodeURI encodeURIComponent escape unescape Object Function Boolean Error ' + 'EvalError InternalError RangeError ReferenceError StopIteration SyntaxError ' + 'TypeError URIError Number Math Date String RegExp Array Float32Array ' + 'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array ' + 'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require ' + 'module console window document any number boolean string void Promise'
  13067. };
  13068. var DECORATOR = {
  13069. className: 'meta',
  13070. begin: '@' + JS_IDENT_RE
  13071. };
  13072. var ARGS = {
  13073. begin: '\\(',
  13074. end: /\)/,
  13075. keywords: KEYWORDS,
  13076. contains: ['self', hljs.QUOTE_STRING_MODE, hljs.APOS_STRING_MODE, hljs.NUMBER_MODE]
  13077. };
  13078. var PARAMS = {
  13079. className: 'params',
  13080. begin: /\(/, end: /\)/,
  13081. excludeBegin: true,
  13082. excludeEnd: true,
  13083. keywords: KEYWORDS,
  13084. contains: [hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, DECORATOR, ARGS]
  13085. };
  13086. var NUMBER = {
  13087. className: 'number',
  13088. variants: [{ begin: '\\b(0[bB][01]+)' }, { begin: '\\b(0[oO][0-7]+)' }, { begin: hljs.C_NUMBER_RE }],
  13089. relevance: 0
  13090. };
  13091. var SUBST = {
  13092. className: 'subst',
  13093. begin: '\\$\\{', end: '\\}',
  13094. keywords: KEYWORDS,
  13095. contains: [] // defined later
  13096. };
  13097. var HTML_TEMPLATE = {
  13098. begin: 'html`', end: '',
  13099. starts: {
  13100. end: '`', returnEnd: false,
  13101. contains: [hljs.BACKSLASH_ESCAPE, SUBST],
  13102. subLanguage: 'xml'
  13103. }
  13104. };
  13105. var CSS_TEMPLATE = {
  13106. begin: 'css`', end: '',
  13107. starts: {
  13108. end: '`', returnEnd: false,
  13109. contains: [hljs.BACKSLASH_ESCAPE, SUBST],
  13110. subLanguage: 'css'
  13111. }
  13112. };
  13113. var TEMPLATE_STRING = {
  13114. className: 'string',
  13115. begin: '`', end: '`',
  13116. contains: [hljs.BACKSLASH_ESCAPE, SUBST]
  13117. };
  13118. SUBST.contains = [hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, HTML_TEMPLATE, CSS_TEMPLATE, TEMPLATE_STRING, NUMBER, hljs.REGEXP_MODE];
  13119. return {
  13120. aliases: ['ts'],
  13121. keywords: KEYWORDS,
  13122. contains: [{
  13123. className: 'meta',
  13124. begin: /^\s*['"]use strict['"]/
  13125. }, hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, HTML_TEMPLATE, CSS_TEMPLATE, TEMPLATE_STRING, hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, NUMBER, { // "value" container
  13126. begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
  13127. keywords: 'return throw case',
  13128. contains: [hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, hljs.REGEXP_MODE, {
  13129. className: 'function',
  13130. begin: '(\\(.*?\\)|' + hljs.IDENT_RE + ')\\s*=>', returnBegin: true,
  13131. end: '\\s*=>',
  13132. contains: [{
  13133. className: 'params',
  13134. variants: [{
  13135. begin: hljs.IDENT_RE
  13136. }, {
  13137. begin: /\(\s*\)/
  13138. }, {
  13139. begin: /\(/, end: /\)/,
  13140. excludeBegin: true, excludeEnd: true,
  13141. keywords: KEYWORDS,
  13142. contains: ['self', hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE]
  13143. }]
  13144. }]
  13145. }],
  13146. relevance: 0
  13147. }, {
  13148. className: 'function',
  13149. begin: 'function', end: /[\{;]/, excludeEnd: true,
  13150. keywords: KEYWORDS,
  13151. contains: ['self', hljs.inherit(hljs.TITLE_MODE, { begin: JS_IDENT_RE }), PARAMS],
  13152. illegal: /%/,
  13153. relevance: 0 // () => {} is more typical in TypeScript
  13154. }, {
  13155. beginKeywords: 'constructor', end: /\{/, excludeEnd: true,
  13156. contains: ['self', PARAMS]
  13157. }, { // prevent references like module.id from being higlighted as module definitions
  13158. begin: /module\./,
  13159. keywords: { built_in: 'module' },
  13160. relevance: 0
  13161. }, {
  13162. beginKeywords: 'module', end: /\{/, excludeEnd: true
  13163. }, {
  13164. beginKeywords: 'interface', end: /\{/, excludeEnd: true,
  13165. keywords: 'interface extends'
  13166. }, {
  13167. begin: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
  13168. }, {
  13169. begin: '\\.' + hljs.IDENT_RE, relevance: 0 // hack: prevents detection of keywords after dots
  13170. }, DECORATOR, ARGS]
  13171. };
  13172. };
  13173. /***/ }),
  13174. /***/ 421:
  13175. /***/ (function(module, exports) {
  13176. module.exports = function (hljs) {
  13177. var XML_IDENT_RE = '[A-Za-z0-9\\._:-]+';
  13178. var TAG_INTERNALS = {
  13179. endsWithParent: true,
  13180. illegal: /</,
  13181. relevance: 0,
  13182. contains: [{
  13183. className: 'attr',
  13184. begin: XML_IDENT_RE,
  13185. relevance: 0
  13186. }, {
  13187. begin: /=\s*/,
  13188. relevance: 0,
  13189. contains: [{
  13190. className: 'string',
  13191. endsParent: true,
  13192. variants: [{ begin: /"/, end: /"/ }, { begin: /'/, end: /'/ }, { begin: /[^\s"'=<>`]+/ }]
  13193. }]
  13194. }]
  13195. };
  13196. return {
  13197. aliases: ['html', 'xhtml', 'rss', 'atom', 'xjb', 'xsd', 'xsl', 'plist', 'wsf'],
  13198. case_insensitive: true,
  13199. contains: [{
  13200. className: 'meta',
  13201. begin: '<!DOCTYPE', end: '>',
  13202. relevance: 10,
  13203. contains: [{ begin: '\\[', end: '\\]' }]
  13204. }, hljs.COMMENT('<!--', '-->', {
  13205. relevance: 10
  13206. }), {
  13207. begin: '<\\!\\[CDATA\\[', end: '\\]\\]>',
  13208. relevance: 10
  13209. }, {
  13210. className: 'meta',
  13211. begin: /<\?xml/, end: /\?>/, relevance: 10
  13212. }, {
  13213. begin: /<\?(php)?/, end: /\?>/,
  13214. subLanguage: 'php',
  13215. contains: [
  13216. // We don't want the php closing tag ?> to close the PHP block when
  13217. // inside any of the following blocks:
  13218. { begin: '/\\*', end: '\\*/', skip: true }, { begin: 'b"', end: '"', skip: true }, { begin: 'b\'', end: '\'', skip: true }, hljs.inherit(hljs.APOS_STRING_MODE, { illegal: null, className: null, contains: null, skip: true }), hljs.inherit(hljs.QUOTE_STRING_MODE, { illegal: null, className: null, contains: null, skip: true })]
  13219. }, {
  13220. className: 'tag',
  13221. /*
  13222. The lookahead pattern (?=...) ensures that 'begin' only matches
  13223. '<style' as a single word, followed by a whitespace or an
  13224. ending braket. The '$' is needed for the lexeme to be recognized
  13225. by hljs.subMode() that tests lexemes outside the stream.
  13226. */
  13227. begin: '<style(?=\\s|>|$)', end: '>',
  13228. keywords: { name: 'style' },
  13229. contains: [TAG_INTERNALS],
  13230. starts: {
  13231. end: '</style>', returnEnd: true,
  13232. subLanguage: ['css', 'xml']
  13233. }
  13234. }, {
  13235. className: 'tag',
  13236. // See the comment in the <style tag about the lookahead pattern
  13237. begin: '<script(?=\\s|>|$)', end: '>',
  13238. keywords: { name: 'script' },
  13239. contains: [TAG_INTERNALS],
  13240. starts: {
  13241. end: '\<\/script\>', returnEnd: true,
  13242. subLanguage: ['actionscript', 'javascript', 'handlebars', 'xml', 'vbscript']
  13243. }
  13244. }, {
  13245. className: 'tag',
  13246. begin: '</?', end: '/?>',
  13247. contains: [{
  13248. className: 'name', begin: /[^\/><\s]+/, relevance: 0
  13249. }, TAG_INTERNALS]
  13250. }]
  13251. };
  13252. };
  13253. /***/ }),
  13254. /***/ 422:
  13255. /***/ (function(module, exports) {
  13256. module.exports = function (hljs) {
  13257. var BACKTICK_ESCAPE = {
  13258. begin: '`[\\s\\S]'
  13259. };
  13260. return {
  13261. case_insensitive: true,
  13262. aliases: ['ahk'],
  13263. keywords: {
  13264. keyword: 'Break Continue Critical Exit ExitApp Gosub Goto New OnExit Pause return SetBatchLines SetTimer Suspend Thread Throw Until ahk_id ahk_class ahk_pid ahk_exe ahk_group',
  13265. literal: 'true false NOT AND OR',
  13266. built_in: 'ComSpec Clipboard ClipboardAll ErrorLevel'
  13267. },
  13268. contains: [BACKTICK_ESCAPE, hljs.inherit(hljs.QUOTE_STRING_MODE, { contains: [BACKTICK_ESCAPE] }), hljs.COMMENT(';', '$', { relevance: 0 }), hljs.C_BLOCK_COMMENT_MODE, {
  13269. className: 'number',
  13270. begin: hljs.NUMBER_RE,
  13271. relevance: 0
  13272. }, {
  13273. className: 'variable', //subst would be the most accurate however fails the point of highlighting. variable is comparably the most accurate that actually has some effect
  13274. begin: '%[a-zA-Z0-9#_$@]+%'
  13275. }, {
  13276. className: 'built_in',
  13277. begin: '^\\s*\\w+\\s*(,|%)'
  13278. //I don't really know if this is totally relevant
  13279. }, {
  13280. className: 'title', //symbol would be most accurate however is higlighted just like built_in and that makes up a lot of AutoHotkey code
  13281. //meaning that it would fail to highlight anything
  13282. variants: [{ begin: '^[^\\n";]+::(?!=)' }, { begin: '^[^\\n";]+:(?!=)', relevance: 0 // zero relevance as it catches a lot of things
  13283. // followed by a single ':' in many languages
  13284. }]
  13285. }, {
  13286. className: 'meta',
  13287. begin: '^\\s*#\\w+', end: '$',
  13288. relevance: 0
  13289. }, {
  13290. className: 'built_in',
  13291. begin: 'A_[a-zA-Z0-9]+'
  13292. }, {
  13293. // consecutive commas, not for highlighting but just for relevance
  13294. begin: ',\\s*,'
  13295. }]
  13296. };
  13297. };
  13298. /***/ }),
  13299. /***/ 423:
  13300. /***/ (function(module, exports) {
  13301. module.exports = function (hljs) {
  13302. var KEYWORDS = 'ByRef Case Const ContinueCase ContinueLoop ' + 'Default Dim Do Else ElseIf EndFunc EndIf EndSelect ' + 'EndSwitch EndWith Enum Exit ExitLoop For Func ' + 'Global If In Local Next ReDim Return Select Static ' + 'Step Switch Then To Until Volatile WEnd While With',
  13303. LITERAL = 'True False And Null Not Or',
  13304. BUILT_IN = 'Abs ACos AdlibRegister AdlibUnRegister Asc AscW ASin Assign ATan AutoItSetOption AutoItWinGetTitle AutoItWinSetTitle Beep Binary BinaryLen BinaryMid BinaryToString BitAND BitNOT BitOR BitRotate BitShift BitXOR BlockInput Break Call CDTray Ceiling Chr ChrW ClipGet ClipPut ConsoleRead ConsoleWrite ConsoleWriteError ControlClick ControlCommand ControlDisable ControlEnable ControlFocus ControlGetFocus ControlGetHandle ControlGetPos ControlGetText ControlHide ControlListView ControlMove ControlSend ControlSetText ControlShow ControlTreeView Cos Dec DirCopy DirCreate DirGetSize DirMove DirRemove DllCall DllCallAddress DllCallbackFree DllCallbackGetPtr DllCallbackRegister DllClose DllOpen DllStructCreate DllStructGetData DllStructGetPtr DllStructGetSize DllStructSetData DriveGetDrive DriveGetFileSystem DriveGetLabel DriveGetSerial DriveGetType DriveMapAdd DriveMapDel DriveMapGet DriveSetLabel DriveSpaceFree DriveSpaceTotal DriveStatus EnvGet EnvSet EnvUpdate Eval Execute Exp FileChangeDir FileClose FileCopy FileCreateNTFSLink FileCreateShortcut FileDelete FileExists FileFindFirstFile FileFindNextFile FileFlush FileGetAttrib FileGetEncoding FileGetLongName FileGetPos FileGetShortcut FileGetShortName FileGetSize FileGetTime FileGetVersion FileInstall FileMove FileOpen FileOpenDialog FileRead FileReadLine FileReadToArray FileRecycle FileRecycleEmpty FileSaveDialog FileSelectFolder FileSetAttrib FileSetEnd FileSetPos FileSetTime FileWrite FileWriteLine Floor FtpSetProxy FuncName GUICreate GUICtrlCreateAvi GUICtrlCreateButton GUICtrlCreateCheckbox GUICtrlCreateCombo GUICtrlCreateContextMenu GUICtrlCreateDate GUICtrlCreateDummy GUICtrlCreateEdit GUICtrlCreateGraphic GUICtrlCreateGroup GUICtrlCreateIcon GUICtrlCreateInput GUICtrlCreateLabel GUICtrlCreateList GUICtrlCreateListView GUICtrlCreateListViewItem GUICtrlCreateMenu GUICtrlCreateMenuItem GUICtrlCreateMonthCal GUICtrlCreateObj GUICtrlCreatePic GUICtrlCreateProgress GUICtrlCreateRadio GUICtrlCreateSlider GUICtrlCreateTab GUICtrlCreateTabItem GUICtrlCreateTreeView GUICtrlCreateTreeViewItem GUICtrlCreateUpdown GUICtrlDelete GUICtrlGetHandle GUICtrlGetState GUICtrlRead GUICtrlRecvMsg GUICtrlRegisterListViewSort GUICtrlSendMsg GUICtrlSendToDummy GUICtrlSetBkColor GUICtrlSetColor GUICtrlSetCursor GUICtrlSetData GUICtrlSetDefBkColor GUICtrlSetDefColor GUICtrlSetFont GUICtrlSetGraphic GUICtrlSetImage GUICtrlSetLimit GUICtrlSetOnEvent GUICtrlSetPos GUICtrlSetResizing GUICtrlSetState GUICtrlSetStyle GUICtrlSetTip GUIDelete GUIGetCursorInfo GUIGetMsg GUIGetStyle GUIRegisterMsg GUISetAccelerators GUISetBkColor GUISetCoord GUISetCursor GUISetFont GUISetHelp GUISetIcon GUISetOnEvent GUISetState GUISetStyle GUIStartGroup GUISwitch Hex HotKeySet HttpSetProxy HttpSetUserAgent HWnd InetClose InetGet InetGetInfo InetGetSize InetRead IniDelete IniRead IniReadSection IniReadSectionNames IniRenameSection IniWrite IniWriteSection InputBox Int IsAdmin IsArray IsBinary IsBool IsDeclared IsDllStruct IsFloat IsFunc IsHWnd IsInt IsKeyword IsNumber IsObj IsPtr IsString Log MemGetStats Mod MouseClick MouseClickDrag MouseDown MouseGetCursor MouseGetPos MouseMove MouseUp MouseWheel MsgBox Number ObjCreate ObjCreateInterface ObjEvent ObjGet ObjName OnAutoItExitRegister OnAutoItExitUnRegister Ping PixelChecksum PixelGetColor PixelSearch ProcessClose ProcessExists ProcessGetStats ProcessList ProcessSetPriority ProcessWait ProcessWaitClose ProgressOff ProgressOn ProgressSet Ptr Random RegDelete RegEnumKey RegEnumVal RegRead RegWrite Round Run RunAs RunAsWait RunWait Send SendKeepActive SetError SetExtended ShellExecute ShellExecuteWait Shutdown Sin Sleep SoundPlay SoundSetWaveVolume SplashImageOn SplashOff SplashTextOn Sqrt SRandom StatusbarGetText StderrRead StdinWrite StdioClose StdoutRead String StringAddCR StringCompare StringFormat StringFromASCIIArray StringInStr StringIsAlNum StringIsAlpha StringIsASCII StringIsDigit StringIsFloat StringIsInt StringIsLower StringIsSpace StringIsUpper StringIsXDigit StringLeft StringLen StringLower StringMid StringRegExp StringRegExpReplace StringReplace StringReverse StringRight StringSplit StringStripCR StringStripWS StringToASCIIArray StringToBinary StringTrimLeft StringTrimRight StringUpper Tan TCPAccept TCPCloseSocket TCPConnect TCPListen TCPNameToIP TCPRecv TCPSend TCPShutdown, UDPShutdown TCPStartup, UDPStartup TimerDiff TimerInit ToolTip TrayCreateItem TrayCreateMenu TrayGetMsg TrayItemDelete TrayItemGetHandle TrayItemGetState TrayItemGetText TrayItemSetOnEvent TrayItemSetState TrayItemSetText TraySetClick TraySetIcon TraySetOnEvent TraySetPauseIcon TraySetState TraySetToolTip TrayTip UBound UDPBind UDPCloseSocket UDPOpen UDPRecv UDPSend VarGetType WinActivate WinActive WinClose WinExists WinFlash WinGetCaretPos WinGetClassList WinGetClientSize WinGetHandle WinGetPos WinGetProcess WinGetState WinGetText WinGetTitle WinKill WinList WinMenuSelectItem WinMinimizeAll WinMinimizeAllUndo WinMove WinSetOnTop WinSetState WinSetTitle WinSetTrans WinWait',
  13305. COMMENT = {
  13306. variants: [hljs.COMMENT(';', '$', { relevance: 0 }), hljs.COMMENT('#cs', '#ce'), hljs.COMMENT('#comments-start', '#comments-end')]
  13307. },
  13308. VARIABLE = {
  13309. begin: '\\$[A-z0-9_]+'
  13310. },
  13311. STRING = {
  13312. className: 'string',
  13313. variants: [{
  13314. begin: /"/,
  13315. end: /"/,
  13316. contains: [{
  13317. begin: /""/,
  13318. relevance: 0
  13319. }]
  13320. }, {
  13321. begin: /'/,
  13322. end: /'/,
  13323. contains: [{
  13324. begin: /''/,
  13325. relevance: 0
  13326. }]
  13327. }]
  13328. },
  13329. NUMBER = {
  13330. variants: [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE]
  13331. },
  13332. PREPROCESSOR = {
  13333. className: 'meta',
  13334. begin: '#',
  13335. end: '$',
  13336. keywords: { 'meta-keyword': 'comments include include-once NoTrayIcon OnAutoItStartRegister pragma compile RequireAdmin' },
  13337. contains: [{
  13338. begin: /\\\n/,
  13339. relevance: 0
  13340. }, {
  13341. beginKeywords: 'include',
  13342. keywords: { 'meta-keyword': 'include' },
  13343. end: '$',
  13344. contains: [STRING, {
  13345. className: 'meta-string',
  13346. variants: [{
  13347. begin: '<',
  13348. end: '>'
  13349. }, {
  13350. begin: /"/,
  13351. end: /"/,
  13352. contains: [{
  13353. begin: /""/,
  13354. relevance: 0
  13355. }]
  13356. }, {
  13357. begin: /'/,
  13358. end: /'/,
  13359. contains: [{
  13360. begin: /''/,
  13361. relevance: 0
  13362. }]
  13363. }]
  13364. }]
  13365. }, STRING, COMMENT]
  13366. },
  13367. CONSTANT = {
  13368. className: 'symbol',
  13369. // begin: '@',
  13370. // end: '$',
  13371. // keywords: 'AppDataCommonDir AppDataDir AutoItExe AutoItPID AutoItVersion AutoItX64 COM_EventObj CommonFilesDir Compiled ComputerName ComSpec CPUArch CR CRLF DesktopCommonDir DesktopDepth DesktopDir DesktopHeight DesktopRefresh DesktopWidth DocumentsCommonDir error exitCode exitMethod extended FavoritesCommonDir FavoritesDir GUI_CtrlHandle GUI_CtrlId GUI_DragFile GUI_DragId GUI_DropId GUI_WinHandle HomeDrive HomePath HomeShare HotKeyPressed HOUR IPAddress1 IPAddress2 IPAddress3 IPAddress4 KBLayout LF LocalAppDataDir LogonDNSDomain LogonDomain LogonServer MDAY MIN MON MSEC MUILang MyDocumentsDir NumParams OSArch OSBuild OSLang OSServicePack OSType OSVersion ProgramFilesDir ProgramsCommonDir ProgramsDir ScriptDir ScriptFullPath ScriptLineNumber ScriptName SEC StartMenuCommonDir StartMenuDir StartupCommonDir StartupDir SW_DISABLE SW_ENABLE SW_HIDE SW_LOCK SW_MAXIMIZE SW_MINIMIZE SW_RESTORE SW_SHOW SW_SHOWDEFAULT SW_SHOWMAXIMIZED SW_SHOWMINIMIZED SW_SHOWMINNOACTIVE SW_SHOWNA SW_SHOWNOACTIVATE SW_SHOWNORMAL SW_UNLOCK SystemDir TAB TempDir TRAY_ID TrayIconFlashing TrayIconVisible UserName UserProfileDir WDAY WindowsDir WorkingDir YDAY YEAR',
  13372. // relevance: 5
  13373. begin: '@[A-z0-9_]+'
  13374. },
  13375. FUNCTION = {
  13376. className: 'function',
  13377. beginKeywords: 'Func',
  13378. end: '$',
  13379. illegal: '\\$|\\[|%',
  13380. contains: [hljs.UNDERSCORE_TITLE_MODE, {
  13381. className: 'params',
  13382. begin: '\\(',
  13383. end: '\\)',
  13384. contains: [VARIABLE, STRING, NUMBER]
  13385. }]
  13386. };
  13387. return {
  13388. case_insensitive: true,
  13389. illegal: /\/\*/,
  13390. keywords: {
  13391. keyword: KEYWORDS,
  13392. built_in: BUILT_IN,
  13393. literal: LITERAL
  13394. },
  13395. contains: [COMMENT, VARIABLE, STRING, NUMBER, PREPROCESSOR, CONSTANT, FUNCTION]
  13396. };
  13397. };
  13398. /***/ }),
  13399. /***/ 424:
  13400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13401. "use strict";
  13402. var block = {
  13403. newline: /^\n+/,
  13404. code: /^( {4}[^\n]+\n*)+/,
  13405. fences: /^ {0,3}(`{3,}|~{3,})([^`~\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
  13406. hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
  13407. heading: /^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,
  13408. blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
  13409. list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
  13410. html: '^ {0,3}(?:' // optional indentation
  13411. + '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
  13412. + '|comment[^\\n]*(\\n+|$)' // (2)
  13413. + '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
  13414. + '|<![A-Z][\\s\\S]*?>\\n*' // (4)
  13415. + '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' // (5)
  13416. + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
  13417. + '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
  13418. + '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
  13419. + ')',
  13420. def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
  13421. nptable: noop,
  13422. table: noop,
  13423. lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
  13424. // regex template, placeholders will be replaced according to different paragraph
  13425. // interruption rules of commonmark and the original src spec:
  13426. _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,
  13427. text: /^[^\n]+/
  13428. };
  13429. block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
  13430. block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
  13431. block.def = edit(block.def).replace('label', block._label).replace('title', block._title).getRegex();
  13432. block.bullet = /(?:[*+-]|\d{1,9}\.)/;
  13433. block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/;
  13434. block.item = edit(block.item, 'gm').replace(/bull/g, block.bullet).getRegex();
  13435. block.list = edit(block.list).replace(/bull/g, block.bullet).replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))').replace('def', '\\n+(?=' + block.def.source + ')').getRegex();
  13436. block._tag = 'address|article|aside|base|basefont|blockquote|body|caption' + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption' + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe' + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr' + '|track|ul';
  13437. block._comment = /<!--(?!-?>)[\s\S]*?-->/;
  13438. block.html = edit(block.html, 'i').replace('comment', block._comment).replace('tag', block._tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
  13439. block.paragraph = edit(block._paragraph).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} +').replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
  13440. .replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}|~{3,})[^`\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
  13441. .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
  13442. .getRegex();
  13443. block.blockquote = edit(block.blockquote).replace('paragraph', block.paragraph).getRegex();
  13444. /**
  13445. * Normal Block Grammar
  13446. */
  13447. block.normal = merge({}, block);
  13448. /**
  13449. * GFM Block Grammar
  13450. */
  13451. block.gfm = merge({}, block.normal, {
  13452. nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,
  13453. table: /^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/
  13454. });
  13455. /**
  13456. * Pedantic grammar (original John Gruber's loose src specification)
  13457. */
  13458. block.pedantic = merge({}, block.normal, {
  13459. html: edit('^ *(?:comment *(?:\\n|\\s*$)' + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
  13460. + '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))').replace('comment', block._comment).replace(/tag/g, '(?!(?:' + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub' + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)' + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b').getRegex(),
  13461. def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
  13462. heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
  13463. fences: noop, // fences not supported
  13464. paragraph: edit(block.normal._paragraph).replace('hr', block.hr).replace('heading', ' *#{1,6} *[^\n]').replace('lheading', block.lheading).replace('blockquote', ' {0,3}>').replace('|fences', '').replace('|list', '').replace('|html', '').getRegex()
  13465. });
  13466. /**
  13467. * Block Lexer
  13468. */
  13469. function Lexer(options) {
  13470. this.tokens = [];
  13471. this.tokens.links = Object.create(null);
  13472. this.options = options || index.defaults;
  13473. this.rules = block.normal;
  13474. if (this.options.pedantic) {
  13475. this.rules = block.pedantic;
  13476. } else if (this.options.gfm) {
  13477. this.rules = block.gfm;
  13478. }
  13479. }
  13480. /**
  13481. * Expose Block Rules
  13482. */
  13483. Lexer.rules = block;
  13484. /**
  13485. * Static Lex Method
  13486. */
  13487. Lexer.lex = function (src, options) {
  13488. var lexer = new Lexer(options);
  13489. return lexer.lex(src);
  13490. };
  13491. /**
  13492. * Preprocessing
  13493. */
  13494. Lexer.prototype.lex = function (src) {
  13495. src = src.replace(/\r\n|\r/g, '\n').replace(/\t/g, ' ').replace(/\u00a0/g, ' ').replace(/\u2424/g, '\n');
  13496. return this.token(src, true);
  13497. };
  13498. /**
  13499. * Lexing
  13500. */
  13501. Lexer.prototype.token = function (src, top) {
  13502. src = src.replace(/^ +$/gm, '');
  13503. var next, loose, cap, bull, b, item, listStart, listItems, t, space, i, tag, l, isordered, istask, ischecked;
  13504. while (src) {
  13505. // newline
  13506. if (cap = this.rules.newline.exec(src)) {
  13507. src = src.substring(cap[0].length);
  13508. if (cap[0].length > 1) {
  13509. this.tokens.push({
  13510. type: 'space'
  13511. });
  13512. }
  13513. }
  13514. // code
  13515. if (cap = this.rules.code.exec(src)) {
  13516. var lastToken = this.tokens[this.tokens.length - 1];
  13517. src = src.substring(cap[0].length);
  13518. // An indented code block cannot interrupt a paragraph.
  13519. if (lastToken && lastToken.type === 'paragraph') {
  13520. lastToken.text += '\n' + cap[0].trimRight();
  13521. } else {
  13522. cap = cap[0].replace(/^ {4}/gm, '');
  13523. this.tokens.push({
  13524. type: 'code',
  13525. codeBlockStyle: 'indented',
  13526. text: !this.options.pedantic ? rtrim(cap, '\n') : cap
  13527. });
  13528. }
  13529. continue;
  13530. }
  13531. // fences
  13532. if (cap = this.rules.fences.exec(src)) {
  13533. src = src.substring(cap[0].length);
  13534. this.tokens.push({
  13535. type: 'code',
  13536. lang: cap[2] ? cap[2].trim() : cap[2],
  13537. text: cap[3] || ''
  13538. });
  13539. continue;
  13540. }
  13541. // heading
  13542. if (cap = this.rules.heading.exec(src)) {
  13543. src = src.substring(cap[0].length);
  13544. this.tokens.push({
  13545. type: 'heading',
  13546. depth: cap[1].length,
  13547. text: cap[2]
  13548. });
  13549. continue;
  13550. }
  13551. // table no leading pipe (gfm)
  13552. if (cap = this.rules.nptable.exec(src)) {
  13553. item = {
  13554. type: 'table',
  13555. header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
  13556. align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
  13557. cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
  13558. };
  13559. if (item.header.length === item.align.length) {
  13560. src = src.substring(cap[0].length);
  13561. for (i = 0; i < item.align.length; i++) {
  13562. if (/^ *-+: *$/.test(item.align[i])) {
  13563. item.align[i] = 'right';
  13564. } else if (/^ *:-+: *$/.test(item.align[i])) {
  13565. item.align[i] = 'center';
  13566. } else if (/^ *:-+ *$/.test(item.align[i])) {
  13567. item.align[i] = 'left';
  13568. } else {
  13569. item.align[i] = null;
  13570. }
  13571. }
  13572. for (i = 0; i < item.cells.length; i++) {
  13573. item.cells[i] = splitCells(item.cells[i], item.header.length);
  13574. }
  13575. this.tokens.push(item);
  13576. continue;
  13577. }
  13578. }
  13579. // hr
  13580. if (cap = this.rules.hr.exec(src)) {
  13581. src = src.substring(cap[0].length);
  13582. this.tokens.push({
  13583. type: 'hr'
  13584. });
  13585. continue;
  13586. }
  13587. // blockquote
  13588. if (cap = this.rules.blockquote.exec(src)) {
  13589. src = src.substring(cap[0].length);
  13590. this.tokens.push({
  13591. type: 'blockquote_start'
  13592. });
  13593. cap = cap[0].replace(/^ *> ?/gm, '');
  13594. // Pass `top` to keep the current
  13595. // "toplevel" state. This is exactly
  13596. // how src.pl works.
  13597. this.token(cap, top);
  13598. this.tokens.push({
  13599. type: 'blockquote_end'
  13600. });
  13601. continue;
  13602. }
  13603. // list
  13604. if (cap = this.rules.list.exec(src)) {
  13605. src = src.substring(cap[0].length);
  13606. bull = cap[2];
  13607. isordered = bull.length > 1;
  13608. listStart = {
  13609. type: 'list_start',
  13610. ordered: isordered,
  13611. start: isordered ? +bull : '',
  13612. loose: false
  13613. };
  13614. this.tokens.push(listStart);
  13615. // Get each top-level item.
  13616. cap = cap[0].match(this.rules.item);
  13617. listItems = [];
  13618. next = false;
  13619. l = cap.length;
  13620. i = 0;
  13621. for (; i < l; i++) {
  13622. item = cap[i];
  13623. // Remove the list item's bullet
  13624. // so it is seen as the next token.
  13625. space = item.length;
  13626. item = item.replace(/^ *([*+-]|\d+\.) */, '');
  13627. // Outdent whatever the
  13628. // list item contains. Hacky.
  13629. if (~item.indexOf('\n ')) {
  13630. space -= item.length;
  13631. item = !this.options.pedantic ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '') : item.replace(/^ {1,4}/gm, '');
  13632. }
  13633. // Determine whether the next list item belongs here.
  13634. // Backpedal if it does not belong in this list.
  13635. if (i !== l - 1) {
  13636. b = block.bullet.exec(cap[i + 1])[0];
  13637. if (bull.length > 1 ? b.length === 1 : b.length > 1 || this.options.smartLists && b !== bull) {
  13638. src = cap.slice(i + 1).join('\n') + src;
  13639. i = l - 1;
  13640. }
  13641. }
  13642. // Determine whether item is loose or not.
  13643. // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
  13644. // for discount behavior.
  13645. loose = next || /\n\n(?!\s*$)/.test(item);
  13646. if (i !== l - 1) {
  13647. next = item.charAt(item.length - 1) === '\n';
  13648. if (!loose) loose = next;
  13649. }
  13650. if (loose) {
  13651. listStart.loose = true;
  13652. }
  13653. // Check for task list items
  13654. istask = /^\[[ xX]\] /.test(item);
  13655. ischecked = undefined;
  13656. if (istask) {
  13657. ischecked = item[1] !== ' ';
  13658. item = item.replace(/^\[[ xX]\] +/, '');
  13659. }
  13660. t = {
  13661. type: 'list_item_start',
  13662. task: istask,
  13663. checked: ischecked,
  13664. loose: loose
  13665. };
  13666. listItems.push(t);
  13667. this.tokens.push(t);
  13668. // Recurse.
  13669. this.token(item, false);
  13670. this.tokens.push({
  13671. type: 'list_item_end'
  13672. });
  13673. }
  13674. if (listStart.loose) {
  13675. l = listItems.length;
  13676. i = 0;
  13677. for (; i < l; i++) {
  13678. listItems[i].loose = true;
  13679. }
  13680. }
  13681. this.tokens.push({
  13682. type: 'list_end'
  13683. });
  13684. continue;
  13685. }
  13686. // html
  13687. if (cap = this.rules.html.exec(src)) {
  13688. src = src.substring(cap[0].length);
  13689. this.tokens.push({
  13690. type: this.options.sanitize ? 'paragraph' : 'html',
  13691. pre: !this.options.sanitizer && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
  13692. text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0]
  13693. });
  13694. continue;
  13695. }
  13696. // def
  13697. if (top && (cap = this.rules.def.exec(src))) {
  13698. src = src.substring(cap[0].length);
  13699. if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
  13700. tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
  13701. if (!this.tokens.links[tag]) {
  13702. this.tokens.links[tag] = {
  13703. href: cap[2],
  13704. title: cap[3]
  13705. };
  13706. }
  13707. continue;
  13708. }
  13709. // table (gfm)
  13710. if (cap = this.rules.table.exec(src)) {
  13711. item = {
  13712. type: 'table',
  13713. header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
  13714. align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
  13715. cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
  13716. };
  13717. if (item.header.length === item.align.length) {
  13718. src = src.substring(cap[0].length);
  13719. for (i = 0; i < item.align.length; i++) {
  13720. if (/^ *-+: *$/.test(item.align[i])) {
  13721. item.align[i] = 'right';
  13722. } else if (/^ *:-+: *$/.test(item.align[i])) {
  13723. item.align[i] = 'center';
  13724. } else if (/^ *:-+ *$/.test(item.align[i])) {
  13725. item.align[i] = 'left';
  13726. } else {
  13727. item.align[i] = null;
  13728. }
  13729. }
  13730. for (i = 0; i < item.cells.length; i++) {
  13731. item.cells[i] = splitCells(item.cells[i].replace(/^ *\| *| *\| *$/g, ''), item.header.length);
  13732. }
  13733. this.tokens.push(item);
  13734. continue;
  13735. }
  13736. }
  13737. // lheading
  13738. if (cap = this.rules.lheading.exec(src)) {
  13739. src = src.substring(cap[0].length);
  13740. this.tokens.push({
  13741. type: 'heading',
  13742. depth: cap[2].charAt(0) === '=' ? 1 : 2,
  13743. text: cap[1]
  13744. });
  13745. continue;
  13746. }
  13747. // top-level paragraph
  13748. if (top && (cap = this.rules.paragraph.exec(src))) {
  13749. src = src.substring(cap[0].length);
  13750. this.tokens.push({
  13751. type: 'paragraph',
  13752. text: cap[1].charAt(cap[1].length - 1) === '\n' ? cap[1].slice(0, -1) : cap[1]
  13753. });
  13754. continue;
  13755. }
  13756. if (cap = this.rules.text.exec(src)) {
  13757. src = src.substring(cap[0].length);
  13758. this.tokens.push({
  13759. type: 'text',
  13760. text: cap[0]
  13761. });
  13762. continue;
  13763. }
  13764. if (src) {
  13765. throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
  13766. }
  13767. }
  13768. return this.tokens;
  13769. };
  13770. /**
  13771. * Inline-Level Grammar
  13772. */
  13773. var inline = {
  13774. escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
  13775. autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
  13776. url: noop,
  13777. tag: '^comment' + '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
  13778. + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
  13779. + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
  13780. + '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
  13781. + '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>', // CDATA section
  13782. link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
  13783. reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
  13784. nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
  13785. strong: /^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
  13786. em: /^_([^\s_])_(?!_)|^\*([^\s*<\[])\*(?!\*)|^_([^\s<][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s<"][\s\S]*?[^\s\*])\*(?!\*|[^\spunctuation])|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,
  13787. code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
  13788. br: /^( {2,}|\\)\n(?!\s*$)/,
  13789. del: noop,
  13790. text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/
  13791. };
  13792. // list of punctuation marks from common mark spec
  13793. // without ` and ] to workaround Rule 17 (inline code blocks/links)
  13794. inline._punctuation = '!"#$%&\'()*+,\\-./:;<=>?@\\[^_{|}~';
  13795. inline.em = edit(inline.em).replace(/punctuation/g, inline._punctuation).getRegex();
  13796. inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
  13797. inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
  13798. inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
  13799. inline.autolink = edit(inline.autolink).replace('scheme', inline._scheme).replace('email', inline._email).getRegex();
  13800. inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
  13801. inline.tag = edit(inline.tag).replace('comment', block._comment).replace('attribute', inline._attribute).getRegex();
  13802. inline._label = /(?:\[[^\[\]]*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
  13803. inline._href = /<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/;
  13804. inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
  13805. inline.link = edit(inline.link).replace('label', inline._label).replace('href', inline._href).replace('title', inline._title).getRegex();
  13806. inline.reflink = edit(inline.reflink).replace('label', inline._label).getRegex();
  13807. /**
  13808. * Normal Inline Grammar
  13809. */
  13810. inline.normal = merge({}, inline);
  13811. /**
  13812. * Pedantic Inline Grammar
  13813. */
  13814. inline.pedantic = merge({}, inline.normal, {
  13815. strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
  13816. em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
  13817. link: edit(/^!?\[(label)\]\((.*?)\)/).replace('label', inline._label).getRegex(),
  13818. reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace('label', inline._label).getRegex()
  13819. });
  13820. /**
  13821. * GFM Inline Grammar
  13822. */
  13823. inline.gfm = merge({}, inline.normal, {
  13824. escape: edit(inline.escape).replace('])', '~|])').getRegex(),
  13825. _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
  13826. url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
  13827. _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
  13828. del: /^~+(?=\S)([\s\S]*?\S)~+/,
  13829. text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/
  13830. });
  13831. inline.gfm.url = edit(inline.gfm.url, 'i').replace('email', inline.gfm._extended_email).getRegex();
  13832. /**
  13833. * GFM + Line Breaks Inline Grammar
  13834. */
  13835. inline.breaks = merge({}, inline.gfm, {
  13836. br: edit(inline.br).replace('{2,}', '*').getRegex(),
  13837. text: edit(inline.gfm.text).replace('\\b_', '\\b_| {2,}\\n').replace(/\{2,\}/g, '*').getRegex()
  13838. });
  13839. /**
  13840. * Inline Lexer & Compiler
  13841. */
  13842. function InlineLexer(links, options) {
  13843. this.options = options || index.defaults;
  13844. this.links = links;
  13845. this.rules = inline.normal;
  13846. this.renderer = this.options.renderer || new Renderer();
  13847. this.renderer.options = this.options;
  13848. if (!this.links) {
  13849. throw new Error('Tokens array requires a `links` property.');
  13850. }
  13851. if (this.options.pedantic) {
  13852. this.rules = inline.pedantic;
  13853. } else if (this.options.gfm) {
  13854. if (this.options.breaks) {
  13855. this.rules = inline.breaks;
  13856. } else {
  13857. this.rules = inline.gfm;
  13858. }
  13859. }
  13860. }
  13861. /**
  13862. * Expose Inline Rules
  13863. */
  13864. InlineLexer.rules = inline;
  13865. /**
  13866. * Static Lexing/Compiling Method
  13867. */
  13868. InlineLexer.output = function (src, links, options) {
  13869. var inline = new InlineLexer(links, options);
  13870. return inline.output(src);
  13871. };
  13872. /**
  13873. * Lexing/Compiling
  13874. */
  13875. InlineLexer.prototype.output = function (src) {
  13876. var out = '',
  13877. link,
  13878. text,
  13879. href,
  13880. title,
  13881. cap,
  13882. prevCapZero;
  13883. while (src) {
  13884. // escape
  13885. if (cap = this.rules.escape.exec(src)) {
  13886. src = src.substring(cap[0].length);
  13887. out += escape(cap[1]);
  13888. continue;
  13889. }
  13890. // tag
  13891. if (cap = this.rules.tag.exec(src)) {
  13892. if (!this.inLink && /^<a /i.test(cap[0])) {
  13893. this.inLink = true;
  13894. } else if (this.inLink && /^<\/a>/i.test(cap[0])) {
  13895. this.inLink = false;
  13896. }
  13897. if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
  13898. this.inRawBlock = true;
  13899. } else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
  13900. this.inRawBlock = false;
  13901. }
  13902. src = src.substring(cap[0].length);
  13903. out += this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0];
  13904. continue;
  13905. }
  13906. // link
  13907. if (cap = this.rules.link.exec(src)) {
  13908. var lastParenIndex = findClosingBracket(cap[2], '()');
  13909. if (lastParenIndex > -1) {
  13910. var linkLen = 4 + cap[1].length + lastParenIndex;
  13911. cap[2] = cap[2].substring(0, lastParenIndex);
  13912. cap[0] = cap[0].substring(0, linkLen).trim();
  13913. cap[3] = '';
  13914. }
  13915. src = src.substring(cap[0].length);
  13916. this.inLink = true;
  13917. href = cap[2];
  13918. if (this.options.pedantic) {
  13919. link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
  13920. if (link) {
  13921. href = link[1];
  13922. title = link[3];
  13923. } else {
  13924. title = '';
  13925. }
  13926. } else {
  13927. title = cap[3] ? cap[3].slice(1, -1) : '';
  13928. }
  13929. href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
  13930. out += this.outputLink(cap, {
  13931. href: InlineLexer.escapes(href),
  13932. title: InlineLexer.escapes(title)
  13933. });
  13934. this.inLink = false;
  13935. continue;
  13936. }
  13937. // reflink, nolink
  13938. if ((cap = this.rules.reflink.exec(src)) || (cap = this.rules.nolink.exec(src))) {
  13939. src = src.substring(cap[0].length);
  13940. link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
  13941. link = this.links[link.toLowerCase()];
  13942. if (!link || !link.href) {
  13943. out += cap[0].charAt(0);
  13944. src = cap[0].substring(1) + src;
  13945. continue;
  13946. }
  13947. this.inLink = true;
  13948. out += this.outputLink(cap, link);
  13949. this.inLink = false;
  13950. continue;
  13951. }
  13952. // strong
  13953. if (cap = this.rules.strong.exec(src)) {
  13954. src = src.substring(cap[0].length);
  13955. out += this.renderer.strong(this.output(cap[4] || cap[3] || cap[2] || cap[1]));
  13956. continue;
  13957. }
  13958. // em
  13959. if (cap = this.rules.em.exec(src)) {
  13960. src = src.substring(cap[0].length);
  13961. out += this.renderer.em(this.output(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1]));
  13962. continue;
  13963. }
  13964. // code
  13965. if (cap = this.rules.code.exec(src)) {
  13966. src = src.substring(cap[0].length);
  13967. out += this.renderer.codespan(escape(cap[2].trim(), true));
  13968. continue;
  13969. }
  13970. // br
  13971. if (cap = this.rules.br.exec(src)) {
  13972. src = src.substring(cap[0].length);
  13973. out += this.renderer.br();
  13974. continue;
  13975. }
  13976. // del (gfm)
  13977. if (cap = this.rules.del.exec(src)) {
  13978. src = src.substring(cap[0].length);
  13979. out += this.renderer.del(this.output(cap[1]));
  13980. continue;
  13981. }
  13982. // autolink
  13983. if (cap = this.rules.autolink.exec(src)) {
  13984. src = src.substring(cap[0].length);
  13985. if (cap[2] === '@') {
  13986. text = escape(this.mangle(cap[1]));
  13987. href = 'mailto:' + text;
  13988. } else {
  13989. text = escape(cap[1]);
  13990. href = text;
  13991. }
  13992. out += this.renderer.link(href, null, text);
  13993. continue;
  13994. }
  13995. // url (gfm)
  13996. if (!this.inLink && (cap = this.rules.url.exec(src))) {
  13997. if (cap[2] === '@') {
  13998. text = escape(cap[0]);
  13999. href = 'mailto:' + text;
  14000. } else {
  14001. // do extended autolink path validation
  14002. do {
  14003. prevCapZero = cap[0];
  14004. cap[0] = this.rules._backpedal.exec(cap[0])[0];
  14005. } while (prevCapZero !== cap[0]);
  14006. text = escape(cap[0]);
  14007. if (cap[1] === 'www.') {
  14008. href = 'http://' + text;
  14009. } else {
  14010. href = text;
  14011. }
  14012. }
  14013. src = src.substring(cap[0].length);
  14014. out += this.renderer.link(href, null, text);
  14015. continue;
  14016. }
  14017. // text
  14018. if (cap = this.rules.text.exec(src)) {
  14019. src = src.substring(cap[0].length);
  14020. if (this.inRawBlock) {
  14021. out += this.renderer.text(this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0]);
  14022. } else {
  14023. out += this.renderer.text(escape(this.smartypants(cap[0])));
  14024. }
  14025. continue;
  14026. }
  14027. if (src) {
  14028. throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
  14029. }
  14030. }
  14031. return out;
  14032. };
  14033. InlineLexer.escapes = function (text) {
  14034. return text ? text.replace(InlineLexer.rules._escapes, '$1') : text;
  14035. };
  14036. /**
  14037. * Compile Link
  14038. */
  14039. InlineLexer.prototype.outputLink = function (cap, link) {
  14040. var href = link.href,
  14041. title = link.title ? escape(link.title) : null;
  14042. return cap[0].charAt(0) !== '!' ? this.renderer.link(href, title, this.output(cap[1])) : this.renderer.image(href, title, escape(cap[1]));
  14043. };
  14044. /**
  14045. * Smartypants Transformations
  14046. */
  14047. InlineLexer.prototype.smartypants = function (text) {
  14048. if (!this.options.smartypants) return text;
  14049. return text
  14050. // em-dashes
  14051. .replace(/---/g, '\u2014')
  14052. // en-dashes
  14053. .replace(/--/g, '\u2013')
  14054. // opening singles
  14055. .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
  14056. // closing singles & apostrophes
  14057. .replace(/'/g, '\u2019')
  14058. // opening doubles
  14059. .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201C')
  14060. // closing doubles
  14061. .replace(/"/g, '\u201D')
  14062. // ellipses
  14063. .replace(/\.{3}/g, '\u2026');
  14064. };
  14065. /**
  14066. * Mangle Links
  14067. */
  14068. InlineLexer.prototype.mangle = function (text) {
  14069. if (!this.options.mangle) return text;
  14070. var out = '',
  14071. l = text.length,
  14072. i = 0,
  14073. ch;
  14074. for (; i < l; i++) {
  14075. ch = text.charCodeAt(i);
  14076. if (Math.random() > 0.5) {
  14077. ch = 'x' + ch.toString(16);
  14078. }
  14079. out += '&#' + ch + ';';
  14080. }
  14081. return out;
  14082. };
  14083. /**
  14084. * Renderer
  14085. */
  14086. function Renderer(options) {
  14087. this.options = options || index.defaults;
  14088. }
  14089. Renderer.prototype.code = function (code, infostring, escaped) {
  14090. var lang = (infostring || '').match(/\S*/)[0];
  14091. if (this.options.highlight) {
  14092. var out = this.options.highlight(code, lang);
  14093. if (out != null && out !== code) {
  14094. escaped = true;
  14095. code = out;
  14096. }
  14097. }
  14098. if (!lang) {
  14099. return '<pre><code>' + (escaped ? code : escape(code, true)) + '</code></pre>';
  14100. }
  14101. return '<pre><code class="' + this.options.langPrefix + escape(lang, true) + '">' + (escaped ? code : escape(code, true)) + '</code></pre>\n';
  14102. };
  14103. Renderer.prototype.blockquote = function (quote) {
  14104. return '<blockquote>\n' + quote + '</blockquote>\n';
  14105. };
  14106. Renderer.prototype.html = function (html) {
  14107. return html;
  14108. };
  14109. Renderer.prototype.heading = function (text, level, raw, slugger) {
  14110. if (this.options.headerIds) {
  14111. return '<h' + level + ' id="' + this.options.headerPrefix + slugger.slug(raw) + '">' + text + '</h' + level + '>\n';
  14112. }
  14113. // ignore IDs
  14114. return '<h' + level + '>' + text + '</h' + level + '>\n';
  14115. };
  14116. Renderer.prototype.hr = function () {
  14117. return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
  14118. };
  14119. Renderer.prototype.list = function (body, ordered, start) {
  14120. var type = ordered ? 'ol' : 'ul',
  14121. startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
  14122. return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
  14123. };
  14124. Renderer.prototype.listitem = function (text) {
  14125. var reg = /\<input.+\>/;
  14126. var className = '';
  14127. if (reg.test(text)) {
  14128. className = 'list-item-checkbox';
  14129. if (/checked/.test(text)) {
  14130. className += ' list-item-checkbox-checked';
  14131. }
  14132. }
  14133. return '<li class="' + className + ' ">' + text + '</li>\n';
  14134. };
  14135. Renderer.prototype.checkbox = function (checked) {
  14136. return '<input ' + (checked ? 'checked ' : '') + 'disabled type="checkbox"' + (this.options.xhtml ? ' /' : '') + '> ';
  14137. };
  14138. Renderer.prototype.paragraph = function (text) {
  14139. return '<p>' + text + '</p>\n';
  14140. };
  14141. Renderer.prototype.table = function (header, body) {
  14142. if (body) body = '<tbody>' + body + '</tbody>';
  14143. return '<table>\n' + '<thead>\n' + header + '</thead>\n' + body + '</table>\n';
  14144. };
  14145. Renderer.prototype.tablerow = function (content) {
  14146. return '<tr>\n' + content + '</tr>\n';
  14147. };
  14148. Renderer.prototype.tablecell = function (content, flags) {
  14149. var type = flags.header ? 'th' : 'td';
  14150. var tag = flags.align ? '<' + type + ' align="' + flags.align + '">' : '<' + type + '>';
  14151. return tag + content + '</' + type + '>\n';
  14152. };
  14153. // span level renderer
  14154. Renderer.prototype.strong = function (text) {
  14155. return '<strong>' + text + '</strong>';
  14156. };
  14157. Renderer.prototype.em = function (text) {
  14158. return '<em>' + text + '</em>';
  14159. };
  14160. Renderer.prototype.codespan = function (text) {
  14161. return '<code>' + text + '</code>';
  14162. };
  14163. Renderer.prototype.br = function () {
  14164. return this.options.xhtml ? '<br/>' : '<br>';
  14165. };
  14166. Renderer.prototype.del = function (text) {
  14167. return '<del>' + text + '</del>';
  14168. };
  14169. Renderer.prototype.link = function (href, title, text) {
  14170. href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
  14171. if (href === null) {
  14172. return text;
  14173. }
  14174. var out = '<a href="' + escape(href) + '"';
  14175. if (title) {
  14176. out += ' title="' + title + '"';
  14177. }
  14178. out += '>' + text + '</a>';
  14179. return out;
  14180. };
  14181. Renderer.prototype.image = function (href, title, text) {
  14182. href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
  14183. if (href === null) {
  14184. return text;
  14185. }
  14186. var out = '<img src="' + href + '" alt="' + text + '"';
  14187. if (title) {
  14188. out += ' title="' + title + '"';
  14189. }
  14190. out += this.options.xhtml ? '/>' : '>';
  14191. return out;
  14192. };
  14193. Renderer.prototype.text = function (text) {
  14194. return text;
  14195. };
  14196. /**
  14197. * TextRenderer
  14198. * returns only the textual part of the token
  14199. */
  14200. function TextRenderer() {}
  14201. // no need for block level renderers
  14202. TextRenderer.prototype.strong = TextRenderer.prototype.em = TextRenderer.prototype.codespan = TextRenderer.prototype.del = TextRenderer.prototype.text = function (text) {
  14203. return text;
  14204. };
  14205. TextRenderer.prototype.link = TextRenderer.prototype.image = function (href, title, text) {
  14206. return '' + text;
  14207. };
  14208. TextRenderer.prototype.br = function () {
  14209. return '';
  14210. };
  14211. /**
  14212. * Parsing & Compiling
  14213. */
  14214. function Parser(options) {
  14215. this.tokens = [];
  14216. this.token = null;
  14217. this.options = options || index.defaults;
  14218. this.options.renderer = this.options.renderer || new Renderer();
  14219. this.renderer = this.options.renderer;
  14220. this.renderer.options = this.options;
  14221. this.slugger = new Slugger();
  14222. }
  14223. /**
  14224. * Static Parse Method
  14225. */
  14226. Parser.parse = function (src, options) {
  14227. var parser = new Parser(options);
  14228. return parser.parse(src);
  14229. };
  14230. /**
  14231. * Parse Loop
  14232. */
  14233. Parser.prototype.parse = function (src) {
  14234. this.inline = new InlineLexer(src.links, this.options);
  14235. // use an InlineLexer with a TextRenderer to extract pure text
  14236. this.inlineText = new InlineLexer(src.links, merge({}, this.options, { renderer: new TextRenderer() }));
  14237. this.tokens = src.reverse();
  14238. var out = '';
  14239. while (this.next()) {
  14240. out += this.tok();
  14241. }
  14242. return out;
  14243. };
  14244. /**
  14245. * Next Token
  14246. */
  14247. Parser.prototype.next = function () {
  14248. this.token = this.tokens.pop();
  14249. return this.token;
  14250. };
  14251. /**
  14252. * Preview Next Token
  14253. */
  14254. Parser.prototype.peek = function () {
  14255. return this.tokens[this.tokens.length - 1] || 0;
  14256. };
  14257. /**
  14258. * Parse Text Tokens
  14259. */
  14260. Parser.prototype.parseText = function () {
  14261. var body = this.token.text;
  14262. while (this.peek().type === 'text') {
  14263. body += '\n' + this.next().text;
  14264. }
  14265. return this.inline.output(body);
  14266. };
  14267. /**
  14268. * Parse Current Token
  14269. */
  14270. Parser.prototype.tok = function () {
  14271. switch (this.token.type) {
  14272. case 'space':
  14273. {
  14274. return '';
  14275. }
  14276. case 'hr':
  14277. {
  14278. return this.renderer.hr();
  14279. }
  14280. case 'heading':
  14281. {
  14282. return this.renderer.heading(this.inline.output(this.token.text), this.token.depth, unescape(this.inlineText.output(this.token.text)), this.slugger);
  14283. }
  14284. case 'code':
  14285. {
  14286. return this.renderer.code(this.token.text, this.token.lang, this.token.escaped);
  14287. }
  14288. case 'table':
  14289. {
  14290. var header = '',
  14291. body = '',
  14292. i,
  14293. row,
  14294. cell,
  14295. j;
  14296. // header
  14297. cell = '';
  14298. for (i = 0; i < this.token.header.length; i++) {
  14299. cell += this.renderer.tablecell(this.inline.output(this.token.header[i]), { header: true, align: this.token.align[i] });
  14300. }
  14301. header += this.renderer.tablerow(cell);
  14302. for (i = 0; i < this.token.cells.length; i++) {
  14303. row = this.token.cells[i];
  14304. cell = '';
  14305. for (j = 0; j < row.length; j++) {
  14306. cell += this.renderer.tablecell(this.inline.output(row[j]), { header: false, align: this.token.align[j] });
  14307. }
  14308. body += this.renderer.tablerow(cell);
  14309. }
  14310. return this.renderer.table(header, body);
  14311. }
  14312. case 'blockquote_start':
  14313. {
  14314. body = '';
  14315. while (this.next().type !== 'blockquote_end') {
  14316. body += this.tok();
  14317. }
  14318. return this.renderer.blockquote(body);
  14319. }
  14320. case 'list_start':
  14321. {
  14322. body = '';
  14323. var ordered = this.token.ordered,
  14324. start = this.token.start;
  14325. while (this.next().type !== 'list_end') {
  14326. body += this.tok();
  14327. }
  14328. return this.renderer.list(body, ordered, start);
  14329. }
  14330. case 'list_item_start':
  14331. {
  14332. body = '';
  14333. var loose = this.token.loose;
  14334. var checked = this.token.checked;
  14335. var task = this.token.task;
  14336. if (this.token.task) {
  14337. body += this.renderer.checkbox(checked);
  14338. }
  14339. while (this.next().type !== 'list_item_end') {
  14340. body += !loose && this.token.type === 'text' ? this.parseText() : this.tok();
  14341. }
  14342. return this.renderer.listitem(body, task, checked);
  14343. }
  14344. case 'html':
  14345. {
  14346. // TODO parse inline content if parameter src=1
  14347. return this.renderer.html(this.token.text);
  14348. }
  14349. case 'paragraph':
  14350. {
  14351. return this.renderer.paragraph(this.inline.output(this.token.text));
  14352. }
  14353. case 'text':
  14354. {
  14355. return this.renderer.paragraph(this.parseText());
  14356. }
  14357. default:
  14358. {
  14359. var errMsg = 'Token with "' + this.token.type + '" type was not found.';
  14360. if (this.options.silent) {
  14361. console.log(errMsg);
  14362. } else {
  14363. throw new Error(errMsg);
  14364. }
  14365. }
  14366. }
  14367. };
  14368. /**
  14369. * Slugger generates header id
  14370. */
  14371. function Slugger() {
  14372. this.seen = {};
  14373. }
  14374. /**
  14375. * Convert string to unique id
  14376. */
  14377. Slugger.prototype.slug = function (value) {
  14378. var slug = value.toLowerCase().trim().replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '').replace(/\s/g, '-');
  14379. if (this.seen.hasOwnProperty(slug)) {
  14380. var originalSlug = slug;
  14381. do {
  14382. this.seen[originalSlug]++;
  14383. slug = originalSlug + '-' + this.seen[originalSlug];
  14384. } while (this.seen.hasOwnProperty(slug));
  14385. }
  14386. this.seen[slug] = 0;
  14387. return slug;
  14388. };
  14389. /**
  14390. * Helpers
  14391. */
  14392. function escape(html, encode) {
  14393. if (encode) {
  14394. if (escape.escapeTest.test(html)) {
  14395. return html.replace(escape.escapeReplace, function (ch) {
  14396. return escape.replacements[ch];
  14397. });
  14398. }
  14399. } else {
  14400. if (escape.escapeTestNoEncode.test(html)) {
  14401. return html.replace(escape.escapeReplaceNoEncode, function (ch) {
  14402. return escape.replacements[ch];
  14403. });
  14404. }
  14405. }
  14406. return html;
  14407. }
  14408. escape.escapeTest = /[&<>"']/;
  14409. escape.escapeReplace = /[&<>"']/g;
  14410. escape.replacements = {
  14411. '&': '&amp;',
  14412. '<': '&lt;',
  14413. '>': '&gt;',
  14414. '"': '&quot;',
  14415. "'": '&#39;'
  14416. };
  14417. escape.escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
  14418. escape.escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
  14419. function unescape(html) {
  14420. // explicitly match decimal, hex, and named HTML entities
  14421. return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function (_, n) {
  14422. n = n.toLowerCase();
  14423. if (n === 'colon') return ':';
  14424. if (n.charAt(0) === '#') {
  14425. return n.charAt(1) === 'x' ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
  14426. }
  14427. return '';
  14428. });
  14429. }
  14430. function edit(regex, opt) {
  14431. regex = regex.source || regex;
  14432. opt = opt || '';
  14433. return {
  14434. replace: function replace(name, val) {
  14435. val = val.source || val;
  14436. val = val.replace(/(^|[^\[])\^/g, '$1');
  14437. regex = regex.replace(name, val);
  14438. return this;
  14439. },
  14440. getRegex: function getRegex() {
  14441. return new RegExp(regex, opt);
  14442. }
  14443. };
  14444. }
  14445. function cleanUrl(sanitize, base, href) {
  14446. if (sanitize) {
  14447. try {
  14448. var prot = decodeURIComponent(unescape(href)).replace(/[^\w:]/g, '').toLowerCase();
  14449. } catch (e) {
  14450. return null;
  14451. }
  14452. if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
  14453. return null;
  14454. }
  14455. }
  14456. if (base && !originIndependentUrl.test(href)) {
  14457. href = resolveUrl(base, href);
  14458. }
  14459. try {
  14460. href = encodeURI(href).replace(/%25/g, '%');
  14461. } catch (e) {
  14462. return null;
  14463. }
  14464. return href;
  14465. }
  14466. function resolveUrl(base, href) {
  14467. if (!baseUrls[' ' + base]) {
  14468. // we can ignore everything in base after the last slash of its path component,
  14469. // but we might need to add _that_
  14470. // https://tools.ietf.org/html/rfc3986#section-3
  14471. if (/^[^:]+:\/*[^/]*$/.test(base)) {
  14472. baseUrls[' ' + base] = base + '/';
  14473. } else {
  14474. baseUrls[' ' + base] = rtrim(base, '/', true);
  14475. }
  14476. }
  14477. base = baseUrls[' ' + base];
  14478. if (href.slice(0, 2) === '//') {
  14479. return base.replace(/:[\s\S]*/, ':') + href;
  14480. } else if (href.charAt(0) === '/') {
  14481. return base.replace(/(:\/*[^/]*)[\s\S]*/, '$1') + href;
  14482. } else {
  14483. return base + href;
  14484. }
  14485. }
  14486. var baseUrls = {};
  14487. var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
  14488. function noop() {}
  14489. noop.exec = noop;
  14490. function merge(obj) {
  14491. var i = 1,
  14492. target,
  14493. key;
  14494. for (; i < arguments.length; i++) {
  14495. target = arguments[i];
  14496. for (key in target) {
  14497. if (Object.prototype.hasOwnProperty.call(target, key)) {
  14498. obj[key] = target[key];
  14499. }
  14500. }
  14501. }
  14502. return obj;
  14503. }
  14504. function splitCells(tableRow, count) {
  14505. // ensure that every cell-delimiting pipe has a space
  14506. // before it to distinguish it from an escaped pipe
  14507. var row = tableRow.replace(/\|/g, function (match, offset, str) {
  14508. var escaped = false,
  14509. curr = offset;
  14510. while (--curr >= 0 && str[curr] === '\\') {
  14511. escaped = !escaped;
  14512. }if (escaped) {
  14513. // odd number of slashes means | is escaped
  14514. // so we leave it alone
  14515. return '|';
  14516. } else {
  14517. // add space before unescaped |
  14518. return ' |';
  14519. }
  14520. }),
  14521. cells = row.split(/ \|/),
  14522. i = 0;
  14523. if (cells.length > count) {
  14524. cells.splice(count);
  14525. } else {
  14526. while (cells.length < count) {
  14527. cells.push('');
  14528. }
  14529. }
  14530. for (; i < cells.length; i++) {
  14531. // leading or trailing whitespace is ignored per the gfm spec
  14532. cells[i] = cells[i].trim().replace(/\\\|/g, '|');
  14533. }
  14534. return cells;
  14535. }
  14536. // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
  14537. // /c*$/ is vulnerable to REDOS.
  14538. // invert: Remove suffix of non-c chars instead. Default falsey.
  14539. function rtrim(str, c, invert) {
  14540. if (str.length === 0) {
  14541. return '';
  14542. }
  14543. // Length of suffix matching the invert condition.
  14544. var suffLen = 0;
  14545. // Step left until we fail to match the invert condition.
  14546. while (suffLen < str.length) {
  14547. var currChar = str.charAt(str.length - suffLen - 1);
  14548. if (currChar === c && !invert) {
  14549. suffLen++;
  14550. } else if (currChar !== c && invert) {
  14551. suffLen++;
  14552. } else {
  14553. break;
  14554. }
  14555. }
  14556. return str.substr(0, str.length - suffLen);
  14557. }
  14558. function findClosingBracket(str, b) {
  14559. if (str.indexOf(b[1]) === -1) {
  14560. return -1;
  14561. }
  14562. var level = 0;
  14563. for (var i = 0; i < str.length; i++) {
  14564. if (str[i] === '\\') {
  14565. i++;
  14566. } else if (str[i] === b[0]) {
  14567. level++;
  14568. } else if (str[i] === b[1]) {
  14569. level--;
  14570. if (level < 0) {
  14571. return i;
  14572. }
  14573. }
  14574. }
  14575. return -1;
  14576. }
  14577. function checkSanitizeDeprecation(opt) {
  14578. if (opt && opt.sanitize && !opt.silent) {
  14579. console.warn('index(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options');
  14580. }
  14581. }
  14582. /**
  14583. * Marked
  14584. */
  14585. function index(src, opt, callback) {
  14586. // throw error in case of non string input
  14587. if (typeof src === 'undefined' || src === null) {
  14588. throw new Error('index(): input parameter is undefined or null');
  14589. }
  14590. if (typeof src !== 'string') {
  14591. throw new Error('index(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected');
  14592. }
  14593. if (callback || typeof opt === 'function') {
  14594. if (!callback) {
  14595. callback = opt;
  14596. opt = null;
  14597. }
  14598. opt = merge({}, index.defaults, opt || {});
  14599. checkSanitizeDeprecation(opt);
  14600. var highlight = opt.highlight,
  14601. tokens,
  14602. pending,
  14603. i = 0;
  14604. try {
  14605. tokens = Lexer.lex(src, opt);
  14606. } catch (e) {
  14607. return callback(e);
  14608. }
  14609. pending = tokens.length;
  14610. var done = function done(err) {
  14611. if (err) {
  14612. opt.highlight = highlight;
  14613. return callback(err);
  14614. }
  14615. var out;
  14616. try {
  14617. out = Parser.parse(tokens, opt);
  14618. } catch (e) {
  14619. err = e;
  14620. }
  14621. opt.highlight = highlight;
  14622. return err ? callback(err) : callback(null, out);
  14623. };
  14624. if (!highlight || highlight.length < 3) {
  14625. return done();
  14626. }
  14627. delete opt.highlight;
  14628. if (!pending) return done();
  14629. for (; i < tokens.length; i++) {
  14630. (function (token) {
  14631. if (token.type !== 'code') {
  14632. return --pending || done();
  14633. }
  14634. return highlight(token.text, token.lang, function (err, code) {
  14635. if (err) return done(err);
  14636. if (code == null || code === token.text) {
  14637. return --pending || done();
  14638. }
  14639. token.text = code;
  14640. token.escaped = true;
  14641. --pending || done();
  14642. });
  14643. })(tokens[i]);
  14644. }
  14645. return;
  14646. }
  14647. try {
  14648. if (opt) opt = merge({}, index.defaults, opt);
  14649. checkSanitizeDeprecation(opt);
  14650. return Parser.parse(Lexer.lex(src, opt), opt);
  14651. } catch (e) {
  14652. e.message += '\nPlease report this to https://github.com/markedjs/marked.';
  14653. if ((opt || index.defaults).silent) {
  14654. return '<p>An error occurred:</p><pre>' + escape(e.message + '', true) + '</pre>';
  14655. }
  14656. throw e;
  14657. }
  14658. }
  14659. /**
  14660. * Options
  14661. */
  14662. index.options = index.setOptions = function (opt) {
  14663. merge(index.defaults, opt);
  14664. return index;
  14665. };
  14666. index.getDefaults = function () {
  14667. return {
  14668. baseUrl: null,
  14669. breaks: false,
  14670. gfm: true,
  14671. headerIds: true,
  14672. headerPrefix: '',
  14673. highlight: null,
  14674. langPrefix: 'language-',
  14675. mangle: true,
  14676. pedantic: false,
  14677. renderer: new Renderer(),
  14678. sanitize: false,
  14679. sanitizer: null,
  14680. silent: false,
  14681. smartLists: false,
  14682. smartypants: false,
  14683. xhtml: false
  14684. };
  14685. };
  14686. index.defaults = index.getDefaults();
  14687. /**
  14688. * Expose
  14689. */
  14690. index.Parser = Parser;
  14691. index.parser = Parser.parse;
  14692. index.Renderer = Renderer;
  14693. index.TextRenderer = TextRenderer;
  14694. index.Lexer = Lexer;
  14695. index.lexer = Lexer.lex;
  14696. index.InlineLexer = InlineLexer;
  14697. index.inlineLexer = InlineLexer.output;
  14698. index.Slugger = Slugger;
  14699. index.parse = index;
  14700. /* harmony default export */ __webpack_exports__["a"] = (index);
  14701. /***/ }),
  14702. /***/ 862:
  14703. /***/ (function(module, exports, __webpack_require__) {
  14704. var disposed = false
  14705. function injectStyle (ssrContext) {
  14706. if (disposed) return
  14707. __webpack_require__(863)
  14708. __webpack_require__(865)
  14709. }
  14710. var normalizeComponent = __webpack_require__(2)
  14711. /* script */
  14712. var __vue_script__ = __webpack_require__(867)
  14713. /* template */
  14714. var __vue_template__ = __webpack_require__(885)
  14715. /* template functional */
  14716. var __vue_template_functional__ = false
  14717. /* styles */
  14718. var __vue_styles__ = injectStyle
  14719. /* scopeId */
  14720. var __vue_scopeId__ = "data-v-ca28cc48"
  14721. /* moduleIdentifier (server only) */
  14722. var __vue_module_identifier__ = null
  14723. var Component = normalizeComponent(
  14724. __vue_script__,
  14725. __vue_template__,
  14726. __vue_template_functional__,
  14727. __vue_styles__,
  14728. __vue_scopeId__,
  14729. __vue_module_identifier__
  14730. )
  14731. Component.options.__file = "resources/assets/js/main/components/MDEditor/index.vue"
  14732. /* hot reload */
  14733. if (false) {(function () {
  14734. var hotAPI = require("vue-hot-reload-api")
  14735. hotAPI.install(require("vue"), false)
  14736. if (!hotAPI.compatible) return
  14737. module.hot.accept()
  14738. if (!module.hot.data) {
  14739. hotAPI.createRecord("data-v-ca28cc48", Component.options)
  14740. } else {
  14741. hotAPI.reload("data-v-ca28cc48", Component.options)
  14742. }
  14743. module.hot.dispose(function (data) {
  14744. disposed = true
  14745. })
  14746. })()}
  14747. module.exports = Component.exports
  14748. /***/ }),
  14749. /***/ 863:
  14750. /***/ (function(module, exports, __webpack_require__) {
  14751. // style-loader: Adds some css to the DOM by adding a <style> tag
  14752. // load the styles
  14753. var content = __webpack_require__(864);
  14754. if(typeof content === 'string') content = [[module.i, content, '']];
  14755. if(content.locals) module.exports = content.locals;
  14756. // add the styles to the DOM
  14757. var update = __webpack_require__(1)("1b729ad3", content, false, {});
  14758. // Hot Module Replacement
  14759. if(false) {
  14760. // When the styles change, update the <style> tags
  14761. if(!content.locals) {
  14762. module.hot.accept("!!../../../../../../node_modules/css-loader/index.js!../../../../../../node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-ca28cc48\",\"scoped\":false,\"hasInlineConfig\":true}!../../../../../../node_modules/sass-loader/lib/loader.js!../../../../../../node_modules/vue-loader/lib/selector.js?type=styles&index=0!./index.vue", function() {
  14763. var newContent = require("!!../../../../../../node_modules/css-loader/index.js!../../../../../../node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-ca28cc48\",\"scoped\":false,\"hasInlineConfig\":true}!../../../../../../node_modules/sass-loader/lib/loader.js!../../../../../../node_modules/vue-loader/lib/selector.js?type=styles&index=0!./index.vue");
  14764. if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
  14765. update(newContent);
  14766. });
  14767. }
  14768. // When the module is disposed, remove the <style> tags
  14769. module.hot.dispose(function() { update(); });
  14770. }
  14771. /***/ }),
  14772. /***/ 864:
  14773. /***/ (function(module, exports, __webpack_require__) {
  14774. exports = module.exports = __webpack_require__(0)(false);
  14775. // imports
  14776. // module
  14777. exports.push([module.i, "\n.mdeditor-transfer {\n background-color: #ffffff;\n}\n.mdeditor-transfer .ivu-modal-header {\n display: none;\n}\n.mdeditor-transfer .ivu-modal-close {\n top: 7px;\n}\n.mdeditor-transfer .mdeditor-transfer-body {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n padding: 0;\n margin: 0;\n}\n", ""]);
  14778. // exports
  14779. /***/ }),
  14780. /***/ 865:
  14781. /***/ (function(module, exports, __webpack_require__) {
  14782. // style-loader: Adds some css to the DOM by adding a <style> tag
  14783. // load the styles
  14784. var content = __webpack_require__(866);
  14785. if(typeof content === 'string') content = [[module.i, content, '']];
  14786. if(content.locals) module.exports = content.locals;
  14787. // add the styles to the DOM
  14788. var update = __webpack_require__(1)("519ec43a", content, false, {});
  14789. // Hot Module Replacement
  14790. if(false) {
  14791. // When the styles change, update the <style> tags
  14792. if(!content.locals) {
  14793. module.hot.accept("!!../../../../../../node_modules/css-loader/index.js!../../../../../../node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-ca28cc48\",\"scoped\":true,\"hasInlineConfig\":true}!../../../../../../node_modules/sass-loader/lib/loader.js!../../../../../../node_modules/vue-loader/lib/selector.js?type=styles&index=1!./index.vue", function() {
  14794. var newContent = require("!!../../../../../../node_modules/css-loader/index.js!../../../../../../node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-ca28cc48\",\"scoped\":true,\"hasInlineConfig\":true}!../../../../../../node_modules/sass-loader/lib/loader.js!../../../../../../node_modules/vue-loader/lib/selector.js?type=styles&index=1!./index.vue");
  14795. if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
  14796. update(newContent);
  14797. });
  14798. }
  14799. // When the module is disposed, remove the <style> tags
  14800. module.hot.dispose(function() { update(); });
  14801. }
  14802. /***/ }),
  14803. /***/ 866:
  14804. /***/ (function(module, exports, __webpack_require__) {
  14805. exports = module.exports = __webpack_require__(0)(false);
  14806. // imports
  14807. // module
  14808. exports.push([module.i, "\n.mdeditor-box[data-v-ca28cc48] {\n position: relative;\n}\n.upload-control[data-v-ca28cc48] {\n display: none;\n width: 0;\n height: 0;\n overflow: hidden;\n}\n", ""]);
  14809. // exports
  14810. /***/ }),
  14811. /***/ 867:
  14812. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14813. "use strict";
  14814. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  14815. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__pro__ = __webpack_require__(868);
  14816. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__ImgUpload__ = __webpack_require__(17);
  14817. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__ImgUpload___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__ImgUpload__);
  14818. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  14819. //
  14820. //
  14821. //
  14822. //
  14823. //
  14824. //
  14825. //
  14826. //
  14827. //
  14828. //
  14829. //
  14830. //
  14831. //
  14832. //
  14833. //
  14834. //
  14835. //
  14836. //
  14837. //
  14838. //
  14839. //
  14840. //
  14841. //
  14842. //
  14843. //
  14844. //
  14845. //
  14846. //
  14847. //
  14848. //
  14849. //
  14850. //
  14851. //
  14852. //
  14853. //
  14854. //
  14855. //
  14856. //
  14857. //
  14858. //
  14859. //
  14860. //
  14861. //
  14862. //
  14863. //
  14864. //
  14865. //
  14866. //
  14867. //
  14868. //
  14869. //
  14870. //
  14871. //
  14872. //
  14873. //
  14874. //
  14875. //
  14876. //
  14877. //
  14878. //
  14879. //
  14880. //
  14881. //
  14882. //
  14883. //
  14884. //
  14885. //
  14886. //
  14887. //
  14888. //
  14889. //
  14890. //
  14891. //
  14892. //
  14893. //
  14894. //
  14895. //
  14896. //
  14897. /* harmony default export */ __webpack_exports__["default"] = ({
  14898. name: 'MDEditor',
  14899. components: { ImgUpload: __WEBPACK_IMPORTED_MODULE_1__ImgUpload___default.a, MarkdownPro: __WEBPACK_IMPORTED_MODULE_0__pro__["a" /* default */] },
  14900. props: {
  14901. value: {
  14902. default: ''
  14903. },
  14904. height: {
  14905. default: 380
  14906. },
  14907. toolbars: {
  14908. type: Object,
  14909. default: function _default() {
  14910. return {
  14911. strong: true,
  14912. italic: true,
  14913. overline: true,
  14914. h1: true,
  14915. h2: true,
  14916. h3: true,
  14917. h4: false,
  14918. h5: false,
  14919. h6: false,
  14920. hr: true,
  14921. quote: true,
  14922. ul: true,
  14923. ol: true,
  14924. code: true,
  14925. link: true,
  14926. image: false,
  14927. uploadImage: false,
  14928. table: true,
  14929. checked: true,
  14930. notChecked: true,
  14931. split: true,
  14932. preview: true,
  14933. fullscreen: false,
  14934. theme: false,
  14935. exportmd: false,
  14936. importmd: false,
  14937. save: false,
  14938. clear: false,
  14939. custom_image: true,
  14940. custom_uploadImage: true,
  14941. custom_uploadFile: true,
  14942. custom_fullscreen: true
  14943. };
  14944. }
  14945. }
  14946. },
  14947. data: function data() {
  14948. return {
  14949. content: '',
  14950. transfer: false,
  14951. html2md: false,
  14952. htmlValue: '',
  14953. uploadIng: 0,
  14954. uploadFormat: ['jpg', 'jpeg', 'png', 'gif', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'esp', 'pdf', 'rar', 'zip', 'gz', 'ai', 'avi', 'bmp', 'cdr', 'eps', 'mov', 'mp3', 'mp4', 'pr', 'psd', 'svg', 'tif'],
  14955. actionUrl: $A.apiUrl('system/fileupload'),
  14956. params: { token: $A.getToken() },
  14957. maxSize: 204800
  14958. };
  14959. },
  14960. mounted: function mounted() {
  14961. this.content = this.value;
  14962. },
  14963. activated: function activated() {
  14964. this.content = this.value;
  14965. },
  14966. watch: {
  14967. value: function value(newValue) {
  14968. if (newValue == null) {
  14969. newValue = "";
  14970. }
  14971. this.content = newValue;
  14972. },
  14973. content: function content(val) {
  14974. this.$emit('input', val);
  14975. }
  14976. },
  14977. methods: {
  14978. editorImage: function editorImage(lists) {
  14979. for (var i = 0; i < lists.length; i++) {
  14980. var item = lists[i];
  14981. if ((typeof item === 'undefined' ? 'undefined' : _typeof(item)) === 'object' && typeof item.url === "string") {
  14982. if (this.transfer) {
  14983. this.$refs.md2.insertContent('\n![image](' + item.url + ')');
  14984. } else {
  14985. this.$refs.md1.insertContent('\n![image](' + item.url + ')');
  14986. }
  14987. }
  14988. }
  14989. },
  14990. customClick: function customClick(act) {
  14991. switch (act) {
  14992. case "image-browse":
  14993. {
  14994. this.$refs.myUpload.browsePicture();
  14995. break;
  14996. }
  14997. case "image-upload":
  14998. {
  14999. this.$refs.myUpload.handleClick();
  15000. break;
  15001. }
  15002. case "file-upload":
  15003. {
  15004. this.$refs.fileUpload.handleClick();
  15005. break;
  15006. }
  15007. case "fullscreen":
  15008. {
  15009. this.transfer = !this.transfer;
  15010. break;
  15011. }
  15012. case "html2md":
  15013. {
  15014. this.html2md = true;
  15015. break;
  15016. }
  15017. }
  15018. },
  15019. htmlOk: function htmlOk() {
  15020. var _this = this;
  15021. this.loadScript(window.location.origin + '/js/html2md.js', function () {
  15022. if (typeof toMarkdown !== 'function') {
  15023. alert("组件加载失败!");
  15024. return;
  15025. }
  15026. if (_this.transfer) {
  15027. _this.$refs.md2.insertContent('\n' + toMarkdown(_this.htmlValue, { gfm: true }));
  15028. } else {
  15029. _this.$refs.md1.insertContent('\n' + toMarkdown(_this.htmlValue, { gfm: true }));
  15030. }
  15031. _this.htmlValue = "";
  15032. });
  15033. },
  15034. loadScript: function loadScript(url, callback) {
  15035. var script = document.createElement("script");
  15036. script.type = "text/javascript";
  15037. if (script.readyState) {
  15038. script.onreadystatechange = function () {
  15039. if (script.readyState === "loaded" || script.readyState === "complete") {
  15040. script.onreadystatechange = null;
  15041. callback();
  15042. }
  15043. };
  15044. } else {
  15045. script.onload = function () {
  15046. callback();
  15047. };
  15048. }
  15049. script.src = url;
  15050. document.body.appendChild(script);
  15051. },
  15052. handleUploadImageUpload: function handleUploadImageUpload(file) {
  15053. //手动传图片
  15054. this.$refs.myUpload.handleManual(file);
  15055. },
  15056. /********************文件上传部分************************/
  15057. handleProgress: function handleProgress() {
  15058. //开始上传
  15059. this.uploadIng++;
  15060. },
  15061. handleSuccess: function handleSuccess(res, file) {
  15062. //上传完成
  15063. this.uploadIng--;
  15064. if (res.ret === 1) {
  15065. var con = '[' + res.data.name + ' (' + $A.bytesToSize(res.data.size * 1024) + ')](' + res.data.url + ')';
  15066. if (this.transfer) {
  15067. this.$refs.md2.insertContent(con);
  15068. } else {
  15069. this.$refs.md1.insertContent(con);
  15070. }
  15071. } else {
  15072. this.$Modal.warning({
  15073. title: this.$L('上传失败'),
  15074. content: this.$L('文件 % 上传失败,%', file.name, res.msg)
  15075. });
  15076. }
  15077. },
  15078. handleError: function handleError() {
  15079. //上传错误
  15080. this.uploadIng--;
  15081. },
  15082. handleFormatError: function handleFormatError(file) {
  15083. //上传类型错误
  15084. this.$Modal.warning({
  15085. title: this.$L('文件格式不正确'),
  15086. content: this.$L('文件 % 格式不正确,仅支持上传:%', file.name, this.uploadFormat.join(','))
  15087. });
  15088. },
  15089. handleMaxSize: function handleMaxSize(file) {
  15090. //上传大小错误
  15091. this.$Modal.warning({
  15092. title: this.$L('超出文件大小限制'),
  15093. content: this.$L('文件 % 太大,不能超过%。', file.name, $A.bytesToSize(this.maxSize * 1024))
  15094. });
  15095. },
  15096. handleBeforeUpload: function handleBeforeUpload() {
  15097. //上传前判断
  15098. this.params = {
  15099. token: $A.getToken()
  15100. };
  15101. return true;
  15102. }
  15103. }
  15104. });
  15105. /***/ }),
  15106. /***/ 868:
  15107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15108. "use strict";
  15109. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_pro_index_vue__ = __webpack_require__(869);
  15110. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_pro_index_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__components_pro_index_vue__);
  15111. /* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__components_pro_index_vue___default.a);
  15112. /***/ }),
  15113. /***/ 869:
  15114. /***/ (function(module, exports, __webpack_require__) {
  15115. var disposed = false
  15116. function injectStyle (ssrContext) {
  15117. if (disposed) return
  15118. __webpack_require__(870)
  15119. }
  15120. var normalizeComponent = __webpack_require__(2)
  15121. /* script */
  15122. var __vue_script__ = __webpack_require__(872)
  15123. /* template */
  15124. var __vue_template__ = __webpack_require__(884)
  15125. /* template functional */
  15126. var __vue_template_functional__ = false
  15127. /* styles */
  15128. var __vue_styles__ = injectStyle
  15129. /* scopeId */
  15130. var __vue_scopeId__ = "data-v-e13e76c6"
  15131. /* moduleIdentifier (server only) */
  15132. var __vue_module_identifier__ = null
  15133. var Component = normalizeComponent(
  15134. __vue_script__,
  15135. __vue_template__,
  15136. __vue_template_functional__,
  15137. __vue_styles__,
  15138. __vue_scopeId__,
  15139. __vue_module_identifier__
  15140. )
  15141. Component.options.__file = "resources/assets/js/main/components/MDEditor/components/pro/index.vue"
  15142. /* hot reload */
  15143. if (false) {(function () {
  15144. var hotAPI = require("vue-hot-reload-api")
  15145. hotAPI.install(require("vue"), false)
  15146. if (!hotAPI.compatible) return
  15147. module.hot.accept()
  15148. if (!module.hot.data) {
  15149. hotAPI.createRecord("data-v-e13e76c6", Component.options)
  15150. } else {
  15151. hotAPI.reload("data-v-e13e76c6", Component.options)
  15152. }
  15153. module.hot.dispose(function (data) {
  15154. disposed = true
  15155. })
  15156. })()}
  15157. module.exports = Component.exports
  15158. /***/ }),
  15159. /***/ 870:
  15160. /***/ (function(module, exports, __webpack_require__) {
  15161. // style-loader: Adds some css to the DOM by adding a <style> tag
  15162. // load the styles
  15163. var content = __webpack_require__(871);
  15164. if(typeof content === 'string') content = [[module.i, content, '']];
  15165. if(content.locals) module.exports = content.locals;
  15166. // add the styles to the DOM
  15167. var update = __webpack_require__(1)("467f1dbc", content, false, {});
  15168. // Hot Module Replacement
  15169. if(false) {
  15170. // When the styles change, update the <style> tags
  15171. if(!content.locals) {
  15172. module.hot.accept("!!../../../../../../../../node_modules/css-loader/index.js!../../../../../../../../node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-e13e76c6\",\"scoped\":true,\"hasInlineConfig\":true}!../../../../../../../../node_modules/less-loader/dist/cjs.js!../../../../../../../../node_modules/vue-loader/lib/selector.js?type=styles&index=0!./index.vue", function() {
  15173. var newContent = require("!!../../../../../../../../node_modules/css-loader/index.js!../../../../../../../../node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-e13e76c6\",\"scoped\":true,\"hasInlineConfig\":true}!../../../../../../../../node_modules/less-loader/dist/cjs.js!../../../../../../../../node_modules/vue-loader/lib/selector.js?type=styles&index=0!./index.vue");
  15174. if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
  15175. update(newContent);
  15176. });
  15177. }
  15178. // When the module is disposed, remove the <style> tags
  15179. module.hot.dispose(function() { update(); });
  15180. }
  15181. /***/ }),
  15182. /***/ 871:
  15183. /***/ (function(module, exports, __webpack_require__) {
  15184. exports = module.exports = __webpack_require__(0)(false);
  15185. // imports
  15186. exports.i(__webpack_require__(405), "");
  15187. // module
  15188. exports.push([module.i, "\n@charset \"utf-8\";\n/*\n*Author zhaoxuhui\n*/\n/*\n*Author zhaoxuhui\n*/\n[data-v-e13e76c6] .markdown-theme-light pre {\n font-size: 14px !important;\n line-height: 1.6 !important;\n word-break: break-all;\n word-wrap: break-word;\n border: 0 !important;\n border-radius: 0 !important;\n background: #f7f8fb !important;\n padding: 20px 10px!important;\n border-radius: 4px !important;\n overflow-y: hidden !important;\n overflow-x: auto !important;\n margin: 10px 0 !important;\n}\n[data-v-e13e76c6] .markdown-theme-light pre code {\n font-family: Consolas !important;\n font-size: 13px;\n line-height: 22px !important;\n color: #444;\n}\n[data-v-e13e76c6] .markdown-theme-light .hljs {\n display: block;\n overflow-x: auto;\n color: #525252;\n padding: 15px;\n -webkit-text-size-adjust: none;\n}\n[data-v-e13e76c6] .markdown-theme-light .hljs-doctype {\n color: #999;\n}\n[data-v-e13e76c6] .markdown-theme-light .hljs-tag {\n color: #3e76f6;\n}\n[data-v-e13e76c6] .markdown-theme-light .hljs-attribute {\n color: #e96900;\n}\n[data-v-e13e76c6] .markdown-theme-light .hljs-value {\n color: #42b983;\n}\n[data-v-e13e76c6] .markdown-theme-light .hljs-keyword {\n color: #e96900;\n}\n[data-v-e13e76c6] .markdown-theme-light .hljs-string {\n color: #42b983;\n}\n[data-v-e13e76c6] .markdown-theme-light .hljs-comment {\n color: #b3b3b3;\n}\n[data-v-e13e76c6] .markdown-theme-light .hljs-operator .hljs-comment {\n color: #525252;\n}\n[data-v-e13e76c6] .markdown-theme-light .hljs-regexp {\n color: #af7dff;\n}\n[data-v-e13e76c6] .markdown-theme-light .hljs-built_in {\n color: #2db7f5;\n}\n[data-v-e13e76c6] .markdown-theme-light .css .hljs-class {\n color: #e96900;\n}\n[data-v-e13e76c6] .markdown-theme-light .css .hljs-number,[data-v-e13e76c6] .markdown-theme-light .javascript .hljs-number {\n color: #fc1e70;\n}\n[data-v-e13e76c6] .markdown-theme-light .css .hljs-attribute {\n color: #af7dff;\n}\n[data-v-e13e76c6] .markdown-theme-light .css .hljs-important {\n color: red;\n}\n[data-v-e13e76c6] .markdown-theme-light .actionscript .hljs-literal,[data-v-e13e76c6] .markdown-theme-light .javascript .hljs-literal {\n color: #fc1e70;\n}\n[data-v-e13e76c6] .markdown-theme-light pre {\n padding: 0;\n margin: 0;\n background: #f7f7f7 !important;\n}\n[data-v-e13e76c6] .markdown-theme-light code {\n display: inline-block;\n background: #f7f7f7;\n font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;\n margin: 0 3px;\n padding: 1px 5px;\n border-radius: 3px;\n color: #666;\n border: 1px solid #eee;\n}\n[data-v-e13e76c6] .markdown-theme-light pre code {\n display: inline;\n margin: 0;\n padding: 0;\n border: none;\n background: transparent;\n}\n[data-v-e13e76c6] .markdown-theme-light pre.bg code {\n background: #f7f7f7;\n}\n/*\n*Author zhaoxuhui\n*/\n[data-v-e13e76c6] .markdown-theme-dark pre {\n display: block;\n padding: 20px 10px!important;\n border-radius: 4px;\n margin: 20px 0 !important;\n background: #1e1e1e;\n color: #DCDCDC;\n overflow-y: hidden !important;\n overflow-x: auto !important;\n font-family: Menlo, Consolas, \"Courier New\", Courier, FreeMono, monospace !important;\n}\n[data-v-e13e76c6] .markdown-theme-dark pre * {\n line-height: 1.6 !important;\n font-size: 14px;\n font-family: Menlo, Consolas, \"Courier New\", Courier, FreeMono, monospace !important;\n}\n[data-v-e13e76c6] .markdown-theme-dark code {\n padding: 0 !important;\n margin: 0 !important;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-literal,[data-v-e13e76c6] .markdown-theme-dark .hljs-name,[data-v-e13e76c6] .markdown-theme-dark .hljs-symbol {\n color: #659bd1;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-keyword {\n color: #bc89bd;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-link {\n color: #569CD6;\n text-decoration: underline;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-built_in,[data-v-e13e76c6] .markdown-theme-dark .hljs-type {\n color: #4EC9B0;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-class,[data-v-e13e76c6] .markdown-theme-dark .hljs-number {\n color: #B8D7A3;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-meta-string,[data-v-e13e76c6] .markdown-theme-dark .hljs-string {\n color: #D69D85;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-regexp,[data-v-e13e76c6] .markdown-theme-dark .hljs-template-tag {\n color: #9A5334;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-formula,[data-v-e13e76c6] .markdown-theme-dark .hljs-function,[data-v-e13e76c6] .markdown-theme-dark .hljs-params,[data-v-e13e76c6] .markdown-theme-dark .hljs-subst,[data-v-e13e76c6] .markdown-theme-dark .hljs-title {\n color: #DCDCDC;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-comment,[data-v-e13e76c6] .markdown-theme-dark .hljs-quote {\n color: #57A64A;\n font-style: italic;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-doctag {\n color: #608B4E;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-meta,[data-v-e13e76c6] .markdown-theme-dark .hljs-meta-keyword,[data-v-e13e76c6] .markdown-theme-dark .hljs-tag {\n color: #9B9B9B;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-template-variable,[data-v-e13e76c6] .markdown-theme-dark .hljs-variable {\n color: #BD63C5;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-attr,[data-v-e13e76c6] .markdown-theme-dark .hljs-attribute,[data-v-e13e76c6] .markdown-theme-dark .hljs-builtin-name {\n color: #9CDCFE;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-section {\n color: gold;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-emphasis {\n font-style: italic;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-strong {\n font-weight: bold;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-bullet,[data-v-e13e76c6] .markdown-theme-dark .hljs-selector-attr,[data-v-e13e76c6] .markdown-theme-dark .hljs-selector-class,[data-v-e13e76c6] .markdown-theme-dark .hljs-selector-id,[data-v-e13e76c6] .markdown-theme-dark .hljs-selector-pseudo,[data-v-e13e76c6] .markdown-theme-dark .hljs-selector-tag {\n color: #D7BA7D;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-addition {\n background-color: #144212;\n display: inline-block;\n width: 100%;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-deletion {\n background-color: #600;\n display: inline-block;\n width: 100%;\n}\n[data-v-e13e76c6] .markdown-theme-dark .hljs-comment {\n font-style: normal;\n}\n/*\n*Author zhaoxuhui\n*/\n[data-v-e13e76c6] .markdown-theme-oneDark pre {\n padding: 20px 10px!important;\n display: block;\n color: #abb2bf;\n font-family: Menlo, Consolas, \"Courier New\", Courier, FreeMono, monospace;\n background: #292c34;\n border-radius: 4px;\n overflow-y: hidden !important;\n overflow-x: auto !important;\n margin: 10px 0 !important;\n}\n[data-v-e13e76c6] .markdown-theme-oneDark pre * {\n line-height: 1.6 !important;\n font-size: 14px;\n font-family: Menlo, Consolas, \"Courier New\", Courier, FreeMono, monospace;\n}\n[data-v-e13e76c6] .markdown-theme-oneDark .hljs-comment,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-quote {\n color: #5c6370;\n font-style: italic;\n}\n[data-v-e13e76c6] .markdown-theme-oneDark .hljs-doctag,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-formula,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-keyword {\n color: #c678dd;\n}\n[data-v-e13e76c6] .markdown-theme-oneDark .hljs-deletion,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-name,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-section,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-selector-tag,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-subst {\n color: #e06c75;\n}\n[data-v-e13e76c6] .markdown-theme-oneDark .hljs-literal {\n color: #56b6c2;\n}\n[data-v-e13e76c6] .markdown-theme-oneDark .hljs-addition,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-attribute,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-meta-string,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-regexp,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-string {\n color: #98c379;\n}\n[data-v-e13e76c6] .markdown-theme-oneDark .hljs-built_in,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-class .hljs-title {\n color: #e6c07b;\n}\n[data-v-e13e76c6] .markdown-theme-oneDark .hljs-attr,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-number,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-selector-attr,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-selector-class,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-selector-pseudo,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-template-variable,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-type,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-variable {\n color: #d19a66;\n}\n[data-v-e13e76c6] .markdown-theme-oneDark .hljs-bullet,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-link,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-meta,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-selector-id,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-symbol,[data-v-e13e76c6] .markdown-theme-oneDark .hljs-title {\n color: #61aeee;\n}\n[data-v-e13e76c6] .markdown-theme-oneDark .hljs-emphasis {\n font-style: italic;\n}\n[data-v-e13e76c6] .markdown-theme-oneDark .hljs-strong {\n font-weight: bold;\n}\n[data-v-e13e76c6] .markdown-theme-oneDark .hljs-link {\n text-decoration: underline;\n}\n/*\n*Author zhaoxuhui\n*/\n[data-v-e13e76c6] .markdown-theme-gitHub pre {\n padding: 20px 10px!important;\n display: block;\n overflow-x: auto;\n color: #333;\n background: #f7f8fa !important;\n font-size: 13px;\n line-height: 20px;\n border-radius: 4px;\n margin: 10px 0 !important;\n overflow-x: auto !important;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub pre * {\n font-family: Consolas !important;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-comment,[data-v-e13e76c6] .markdown-theme-gitHub .hljs-quote {\n color: #998;\n font-style: italic;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-selector-tag,[data-v-e13e76c6] .markdown-theme-gitHub .hljs-subst {\n color: #333;\n font-weight: bold;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-keyword {\n color: #d73a49;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-literal,[data-v-e13e76c6] .markdown-theme-gitHub .hljs-number,[data-v-e13e76c6] .markdown-theme-gitHub .hljs-tag .hljs-attr,[data-v-e13e76c6] .markdown-theme-gitHub .hljs-template-variable,[data-v-e13e76c6] .markdown-theme-gitHub .hljs-variable {\n color: #008080;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-doctag,[data-v-e13e76c6] .markdown-theme-gitHub .hljs-string {\n color: #d73a49;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-section,[data-v-e13e76c6] .markdown-theme-gitHub .hljs-selector-id,[data-v-e13e76c6] .markdown-theme-gitHub .hljs-title {\n color: #900;\n font-weight: bold;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-subst {\n font-weight: normal;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-class .hljs-title,[data-v-e13e76c6] .markdown-theme-gitHub .hljs-type {\n color: #458;\n font-weight: bold;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-attribute,[data-v-e13e76c6] .markdown-theme-gitHub .hljs-name,[data-v-e13e76c6] .markdown-theme-gitHub .hljs-tag {\n color: #000080;\n font-weight: normal;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-link,[data-v-e13e76c6] .markdown-theme-gitHub .hljs-regexp {\n color: #009926;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-bullet,[data-v-e13e76c6] .markdown-theme-gitHub .hljs-symbol {\n color: #990073;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-built_in,[data-v-e13e76c6] .markdown-theme-gitHub .hljs-builtin-name {\n color: #0086b3;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-meta {\n color: #999;\n font-weight: bold;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-deletion {\n background: #fdd;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-addition {\n background: #dfd;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-emphasis {\n font-style: italic;\n}\n[data-v-e13e76c6] .markdown-theme-gitHub .hljs-strong {\n font-weight: bold;\n}\n.markdown[data-v-e13e76c6] {\n overflow: hidden;\n position: relative;\n margin: 0;\n padding: 0;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: justify;\n -ms-flex-pack: justify;\n justify-content: space-between;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n background: #f7f7f7;\n}\n.markdown.border[data-v-e13e76c6] {\n border: 1px solid #d9d9d9;\n}\n.markdown *[data-v-e13e76c6] {\n margin: 0;\n padding: 0;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n.markdown.fullscreen[data-v-e13e76c6] {\n position: fixed;\n z-index: 999999;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n height: 100% !important;\n width: 100%;\n border: none;\n}\n.markdown.fullscreen .markdown-content[data-v-e13e76c6] {\n padding: 0;\n padding-top: 10px;\n}\n.markdown .markdown-toolbars[data-v-e13e76c6] {\n width: 100%;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n list-style: none;\n background: #fff;\n color: #6a6f7b;\n height: 40px;\n cursor: pointer;\n padding-left: 4px;\n border-bottom: 1px solid #d9d9d9;\n}\n.markdown .markdown-toolbars > li[data-v-e13e76c6] {\n position: relative;\n cursor: pointer;\n margin: 0;\n line-height: normal;\n min-height: auto;\n}\n.markdown .markdown-toolbars > li[data-v-e13e76c6]:after {\n display: block;\n content: attr(name);\n position: absolute;\n z-index: 999999999999;\n top: 32px;\n left: 20px;\n background: #000;\n color: #fff;\n white-space: nowrap;\n font-size: 12px;\n line-height: 28px;\n padding: 0 6px;\n -webkit-transition: all 0.3s 0.1s;\n transition: all 0.3s 0.1s;\n -webkit-transform: scale(0);\n transform: scale(0);\n opacity: 0;\n -webkit-transform-origin: top;\n transform-origin: top;\n border-radius: 2px;\n}\n.markdown .markdown-toolbars > li[data-v-e13e76c6]:hover:after {\n -webkit-transform: scale(1);\n transform: scale(1);\n opacity: 1;\n}\n.markdown .markdown-toolbars > li[data-v-e13e76c6]:last-child:after {\n right: 20%;\n left: auto;\n}\n.markdown .markdown-toolbars > li .title[data-v-e13e76c6] {\n font-size: 16px !important;\n}\n.markdown .markdown-toolbars > li .icon-svg[data-v-e13e76c6] {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n}\n.markdown .markdown-toolbars .empty[data-v-e13e76c6] {\n -webkit-box-flex: 1;\n -ms-flex: 1;\n flex: 1;\n width: 12px;\n}\n.markdown .markdown-toolbars span[data-v-e13e76c6] {\n font-size: 18px;\n color: #999;\n cursor: pointer;\n display: block;\n width: 30px;\n height: 30px;\n border-radius: 3px;\n line-height: 30px;\n text-align: center;\n}\n.markdown .markdown-toolbars span[data-v-e13e76c6]:hover {\n background: #f7f7f7;\n color: #1890ff;\n}\n.markdown .markdown-toolbars .title[data-v-e13e76c6] {\n padding-left: 4px;\n padding-right: 10px;\n}\n.markdown .markdown-toolbars li:last-child span[data-v-e13e76c6] {\n font-size: 20px !important;\n margin-right: 4px;\n}\n.markdown .markdown-toolbars .shift-theme[data-v-e13e76c6],\n.markdown .markdown-toolbars .export-file[data-v-e13e76c6] {\n height: 46px;\n position: relative;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n}\n.markdown .markdown-toolbars .shift-theme span[data-v-e13e76c6],\n.markdown .markdown-toolbars .export-file span[data-v-e13e76c6] {\n padding: 0 8px;\n -webkit-transition: all 0.3s;\n transition: all 0.3s;\n font-size: 18px;\n display: inline-block;\n line-height: 32px;\n}\n.markdown .markdown-toolbars .shift-theme span[data-v-e13e76c6]:hover,\n.markdown .markdown-toolbars .export-file span[data-v-e13e76c6]:hover {\n color: #0084ff;\n background: #f7f7f7;\n border-radius: 3px;\n}\n.markdown .markdown-toolbars .shift-theme ul[data-v-e13e76c6],\n.markdown .markdown-toolbars .export-file ul[data-v-e13e76c6] {\n -webkit-transform: scale(0);\n transform: scale(0);\n -webkit-transition: all 0.3s;\n transition: all 0.3s;\n left: -50%;\n top: 40px;\n width: 160px;\n -webkit-transform-origin: top center;\n transform-origin: top center;\n list-style: none;\n margin: 0;\n padding: 6px 0;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n border: 1px solid #d9d9d9;\n background: #fff;\n border-radius: 4px;\n position: absolute;\n z-index: 9999999;\n -webkit-box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);\n box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);\n}\n.markdown .markdown-toolbars .shift-theme ul.active[data-v-e13e76c6],\n.markdown .markdown-toolbars .export-file ul.active[data-v-e13e76c6] {\n opacity: 1;\n -webkit-transform: scaleY(1);\n transform: scaleY(1);\n}\n.markdown .markdown-toolbars .shift-theme ul li[data-v-e13e76c6],\n.markdown .markdown-toolbars .export-file ul li[data-v-e13e76c6] {\n line-height: 30px;\n padding: 0 12px;\n padding-left: 12px;\n font-size: 13px;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n color: #262626;\n}\n.markdown .markdown-toolbars .shift-theme ul li .iconfont[data-v-e13e76c6],\n.markdown .markdown-toolbars .export-file ul li .iconfont[data-v-e13e76c6] {\n font-size: 14px;\n display: block;\n height: 30px;\n width: 30px;\n line-height: 30px;\n overflow: hidden;\n}\n.markdown .markdown-toolbars .shift-theme ul li .iconfont[data-v-e13e76c6]:hover,\n.markdown .markdown-toolbars .export-file ul li .iconfont[data-v-e13e76c6]:hover {\n color: #262626;\n}\n.markdown .markdown-toolbars .shift-theme ul li i[data-v-e13e76c6],\n.markdown .markdown-toolbars .export-file ul li i[data-v-e13e76c6] {\n font-size: 13px;\n display: block;\n font-style: normal;\n -webkit-box-flex: 1;\n -ms-flex: 1;\n flex: 1;\n white-space: normal;\n}\n.markdown .markdown-toolbars .shift-theme ul li[data-v-e13e76c6]:last-child,\n.markdown .markdown-toolbars .export-file ul li[data-v-e13e76c6]:last-child {\n border-bottom: 0;\n}\n.markdown .markdown-toolbars .shift-theme ul li:last-child .iconfont[data-v-e13e76c6],\n.markdown .markdown-toolbars .export-file ul li:last-child .iconfont[data-v-e13e76c6] {\n font-size: 14px !important;\n margin: 0 !important;\n}\n.markdown .markdown-toolbars .shift-theme ul li[data-v-e13e76c6]:hover,\n.markdown .markdown-toolbars .export-file ul li[data-v-e13e76c6]:hover {\n background: #f7f7f7;\n}\n.markdown .markdown-toolbars .shift-theme ul li.disabled[data-v-e13e76c6],\n.markdown .markdown-toolbars .export-file ul li.disabled[data-v-e13e76c6] {\n cursor: not-allowed;\n color: #bbbec4;\n}\n.markdown .markdown-toolbars .shift-theme ul li.disabled[data-v-e13e76c6]:hover,\n.markdown .markdown-toolbars .export-file ul li.disabled[data-v-e13e76c6]:hover {\n background: transparent;\n}\n.markdown .markdown-toolbars .import-file[data-v-e13e76c6] {\n position: relative;\n}\n.markdown .markdown-toolbars .import-file input[data-v-e13e76c6] {\n position: absolute;\n z-index: 9999;\n left: 0;\n top: 0;\n display: block;\n width: 100%;\n height: 100%;\n opacity: 0;\n cursor: pointer;\n font-size: 0;\n}\n.markdown .markdown-toolbars .import-file:hover span[data-v-e13e76c6] {\n background: #f7f7f7;\n color: #1890ff;\n}\n.markdown .markdown-toolbars .import-file[data-v-e13e76c6]:hover:after {\n -webkit-transform: scale(1);\n transform: scale(1);\n opacity: 1;\n}\n.markdown .close-preview[data-v-e13e76c6] {\n position: absolute;\n z-index: 999;\n right: 0;\n top: 0;\n height: 40px;\n width: 40px;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n cursor: pointer;\n color: #262626;\n}\n.markdown .close-preview span[data-v-e13e76c6] {\n font-size: 22px;\n}\n.markdown .close-preview span[data-v-e13e76c6]:hover {\n color: #262626;\n}\n.markdown .markdown-content[data-v-e13e76c6] {\n -webkit-box-flex: 1;\n -ms-flex: 1;\n flex: 1;\n width: 100%;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: justify;\n -ms-flex-pack: justify;\n justify-content: space-between;\n position: relative;\n overflow: hidden;\n padding-bottom: 0;\n}\n.markdown .markdown-content .markdown-editor[data-v-e13e76c6] {\n -webkit-box-flex: 1;\n -ms-flex: 1;\n flex: 1;\n height: 100%;\n position: relative;\n margin: 0 !important;\n overflow: hidden;\n overflow-y: scroll;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: justify;\n -ms-flex-pack: justify;\n justify-content: space-between;\n background: #2d2d2d;\n}\n.markdown .markdown-content .markdown-editor[data-v-e13e76c6]::-webkit-scrollbar {\n display: none;\n}\n.markdown .markdown-content .markdown-editor .index[data-v-e13e76c6] {\n background: #272727;\n min-height: 100%;\n width: 36px;\n line-height: 22px;\n padding: 12px 0;\n}\n.markdown .markdown-content .markdown-editor .index li[data-v-e13e76c6] {\n background: #272727;\n color: #ccc;\n font-size: 14px;\n text-align: center;\n font-family: Consolas;\n}\n.markdown .markdown-content .markdown-editor textarea[data-v-e13e76c6] {\n width: 100%;\n min-height: 100%;\n outline: none;\n border: 0;\n background: #2d2d2d;\n line-height: 22px;\n caret-color: #ccc;\n color: #669acc;\n font-size: 14px;\n font-family: Consolas;\n resize: none;\n padding: 12px 8px;\n overflow: hidden;\n white-space: nowrap;\n overflow-x: auto;\n}\n.markdown .markdown-content .markdown-editor textarea[data-v-e13e76c6]::-moz-selection {\n background: #999;\n color: #0084ff;\n}\n.markdown .markdown-content .markdown-editor textarea[data-v-e13e76c6]::selection {\n background: #999;\n color: #0084ff;\n}\n.markdown .markdown-content .codemirror[data-v-e13e76c6] {\n -webkit-box-flex: 1;\n -ms-flex: 1;\n flex: 1;\n width: 0;\n height: 100%;\n overflow: auto;\n}\n.markdown .markdown-content .markdown-preview[data-v-e13e76c6] {\n -webkit-box-flex: 1;\n -ms-flex: 1;\n flex: 1;\n width: 0;\n height: 100%;\n}\n.insert-img-model[data-v-e13e76c6] {\n position: fixed;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n z-index: 99999;\n background: rgba(0, 0, 0, 0.3);\n padding-top: 12%;\n -webkit-transition: all 0.3s;\n transition: all 0.3s;\n opacity: 0;\n display: none;\n}\n.insert-img-model .model-container[data-v-e13e76c6] {\n background: #fff;\n width: 480px;\n margin: 0 auto;\n border-radius: 4px;\n -webkit-transition: all 0.3s;\n transition: all 0.3s;\n -webkit-transform: scale(0);\n transform: scale(0);\n -webkit-transform-origin: center;\n transform-origin: center;\n}\n.insert-img-model .model-container .model-head[data-v-e13e76c6] {\n line-height: 32px;\n padding: 0 12px;\n background: #f7f7f7;\n border-radius: 4px 4px 0 0;\n -webkit-box-shadow: 0 1px 2px #d9d9d9;\n box-shadow: 0 1px 2px #d9d9d9;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: justify;\n -ms-flex-pack: justify;\n justify-content: space-between;\n}\n.insert-img-model .model-container .model-head span[data-v-e13e76c6]:nth-of-type(2) {\n font-size: 14px;\n padding-left: 12px;\n cursor: pointer;\n}\n.insert-img-model .model-container .model-head span[data-v-e13e76c6]:nth-of-type(2):hover {\n color: #ed3f14;\n}\n.insert-img-model .model-container .model-content[data-v-e13e76c6] {\n padding: 20px 12px;\n padding-top: 0;\n min-height: 180px;\n}\n.insert-img-model .model-container .model-content .insert-url[data-v-e13e76c6] {\n padding: 42px 0;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: justify;\n -ms-flex-pack: justify;\n justify-content: space-between;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n}\n.insert-img-model .model-container .model-content .insert-url input[data-v-e13e76c6] {\n display: block;\n border: 1px solid #ccc;\n font-size: 14px;\n padding: 4px 8px;\n line-height: 24px;\n color: #333;\n background: #fff;\n border-radius: 4px;\n -webkit-writing-mode: horizontal-tb;\n -ms-writing-mode: lr-tb;\n writing-mode: horizontal-tb;\n text-rendering: auto;\n -webkit-transition: -webkit-box-shadow 2s;\n transition: -webkit-box-shadow 2s;\n transition: box-shadow 2s;\n transition: box-shadow 2s, -webkit-box-shadow 2s;\n -webkit-box-flex: 1;\n -ms-flex: 1;\n flex: 1;\n}\n.insert-img-model .model-container .model-content .insert-url input[data-v-e13e76c6]:focus {\n border-color: #1890ff;\n}\n.insert-img-model .model-container .model-content .insert-url input[data-v-e13e76c6]::-webkit-input-placeholder {\n color: #c1c1c1;\n}\n.insert-img-model .model-container .model-content .insert-url input[data-v-e13e76c6]::-moz-placeholder {\n color: #c1c1c1;\n}\n.insert-img-model .model-container .model-content .insert-url input[data-v-e13e76c6]::-ms-input-placeholder {\n color: #c1c1c1;\n}\n.insert-img-model .model-container .model-content .insert-url input[data-v-e13e76c6]::placeholder {\n color: #c1c1c1;\n}\n.insert-img-model .model-container .model-content .insert-url a[data-v-e13e76c6] {\n display: block;\n background: #1890ff;\n color: #fff;\n line-height: 32px;\n height: 32px;\n font-size: 13px;\n padding: 0 12px;\n border-radius: 3px;\n margin-left: 20px;\n border: 1px solid #d9d9d9;\n -webkit-transition: all 0.3s;\n transition: all 0.3s;\n}\n.insert-img-model .model-container .model-content .insert-url a[data-v-e13e76c6]:hover {\n background: #0169af;\n}\n.insert-img-model .model-container .model-content .insert-local[data-v-e13e76c6] {\n height: 120px;\n border: 1px dashed #d9d9d9;\n border-radius: 4px;\n -webkit-transition: all 0.3s;\n transition: all 0.3s;\n position: relative;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n cursor: pointer;\n}\n.insert-img-model .model-container .model-content .insert-local span[data-v-e13e76c6] {\n font-size: 40px;\n color: #d9d9d9;\n line-height: 50px;\n -webkit-transition: all 0.3s;\n transition: all 0.3s;\n}\n.insert-img-model .model-container .model-content .insert-local p[data-v-e13e76c6] {\n font-size: 14px;\n color: #262626;\n -webkit-transition: all 0.3s;\n transition: all 0.3s;\n}\n.insert-img-model .model-container .model-content .insert-local[data-v-e13e76c6]:hover {\n border-color: #1890ff;\n}\n.insert-img-model .model-container .model-content .insert-local:hover span[data-v-e13e76c6],\n.insert-img-model .model-container .model-content .insert-local:hover p[data-v-e13e76c6] {\n color: #1890ff;\n}\n.insert-img-model .model-container .model-content .insert-local input[data-v-e13e76c6] {\n display: block;\n position: absolute;\n width: 100%;\n height: 100%;\n opacity: 0;\n}\n.insert-img-model .model-container .model-foot[data-v-e13e76c6] {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: end;\n -ms-flex-pack: end;\n justify-content: flex-end;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n padding: 10px 12px;\n display: none;\n}\n.insert-img-model .model-container .model-foot a[data-v-e13e76c6] {\n display: block;\n background: #f7f7f7;\n color: #262626;\n line-height: 26px;\n height: 26px;\n font-size: 13px;\n padding: 0 12px;\n border-radius: 3px;\n margin-left: 12px;\n border: 1px solid #d9d9d9;\n -webkit-transition: all 0.3s;\n transition: all 0.3s;\n}\n.insert-img-model .model-container .model-foot a[data-v-e13e76c6]:hover {\n background: #d9d9d9;\n}\n.insert-img-model .model-container .model-foot a.ok[data-v-e13e76c6] {\n background: #1890ff;\n color: #fff;\n border-color: #1890ff;\n}\n.insert-img-model .model-container .model-foot a.ok[data-v-e13e76c6]:hover {\n background: #0169af;\n}\n.insert-img-model.active[data-v-e13e76c6] {\n opacity: 1;\n display: block;\n}\n.insert-img-model.active .model-container[data-v-e13e76c6] {\n -webkit-transform: scale(1);\n transform: scale(1);\n}\nul.shift[data-v-e13e76c6] {\n padding: 6px 12px;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n}\nul.shift span[data-v-e13e76c6] {\n font-size: 12px;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\nul.shift span.iconfont[data-v-e13e76c6] {\n font-size: 14px;\n}\nul.shift label[data-v-e13e76c6] {\n font-size: 12px;\n padding-right: 10px;\n position: relative;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\nul.shift input[type='radio'][data-v-e13e76c6],\nul.shift label[data-v-e13e76c6] {\n -webkit-transition: all 0.6s ease;\n transition: all 0.6s ease;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\nul.shift input[type=\"radio\"] + label[data-v-e13e76c6]::before {\n content: \"\\A0\";\n display: inline-block;\n vertical-align: middle;\n margin-right: 4px;\n width: 8px;\n height: 8px;\n border-radius: 50%;\n border: 1px solid #292d35;\n padding: 2px;\n}\nul.shift input[type=\"radio\"]:checked + label[data-v-e13e76c6]::before {\n background-color: #292d35;\n background-clip: content-box;\n padding: 2px;\n}\nul.shift input[type=\"radio\"][data-v-e13e76c6] {\n position: absolute;\n clip: rect(0, 0, 0, 0);\n}\nul.shift input[type=\"radio\"]:checked + label[data-v-e13e76c6] {\n color: #292d35;\n}\n[data-v-e13e76c6] .markdown-preview {\n -webkit-box-flex: 1;\n -ms-flex: 1;\n flex: 1;\n overflow: hidden;\n overflow-y: scroll;\n background: #fff;\n padding: 20px 12px !important;\n font-family: 'Tahoma For Number', 'Chinese Quote', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;\n /*基本样式*/\n}\n[data-v-e13e76c6] .markdown-preview * {\n margin: 0;\n padding: 0;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n[data-v-e13e76c6] .markdown-preview > div {\n padding: 10px 12px !important;\n background: #fff;\n}\n[data-v-e13e76c6] .markdown-preview > div::-webkit-scrollbar {\n display: none;\n}\n[data-v-e13e76c6] .markdown-preview::-webkit-scrollbar {\n display: none;\n}\n[data-v-e13e76c6] .markdown-preview em {\n font-style: oblique;\n}\n[data-v-e13e76c6] .markdown-preview ul {\n list-style: none;\n padding: 0 20px;\n}\n[data-v-e13e76c6] .markdown-preview ul li {\n position: relative;\n}\n[data-v-e13e76c6] .markdown-preview ul li:after {\n display: block;\n content: \"\";\n width: 8px;\n height: 8px;\n border-radius: 50%;\n position: absolute;\n z-index: 99;\n top: 12px;\n left: -16px;\n background: #262626;\n}\n[data-v-e13e76c6] .markdown-preview ol,[data-v-e13e76c6] .markdown-preview ul {\n margin: 10px 0;\n}\n[data-v-e13e76c6] .markdown-preview ol li,[data-v-e13e76c6] .markdown-preview ul li {\n font-size: 14px !important;\n color: #262626;\n line-height: 22px !important;\n padding: 4px 0;\n padding-left: 6px;\n min-height: 28px;\n}\n[data-v-e13e76c6] .markdown-preview ol li input[type=\"checkbox\"],[data-v-e13e76c6] .markdown-preview ul li input[type=\"checkbox\"] {\n position: relative;\n cursor: pointer;\n overflow: visible;\n position: absolute;\n left: -14px;\n top: 5px;\n}\n[data-v-e13e76c6] .markdown-preview ol li input[type=\"checkbox\"]:before,[data-v-e13e76c6] .markdown-preview ul li input[type=\"checkbox\"]:before {\n font-family: \"iconfont\" !important;\n color: #999;\n display: block;\n width: 18px;\n height: 18px;\n position: absolute;\n content: \"\\E684\";\n top: 0px;\n left: -4px;\n z-index: 999999;\n background-position: center;\n background: #fff;\n font-size: 18px;\n text-align: center;\n line-height: 18px;\n}\n[data-v-e13e76c6] .markdown-preview ol li input[type=\"checkbox\"]:checked:before,[data-v-e13e76c6] .markdown-preview ul li input[type=\"checkbox\"]:checked:before {\n content: \"\\E683\";\n}\n[data-v-e13e76c6] .markdown-preview ol {\n list-style-type: decimal;\n padding-left: 20px;\n}\n[data-v-e13e76c6] .markdown-preview ol li {\n list-style: decimal;\n}\n[data-v-e13e76c6] .markdown-preview hr {\n color: #d9d9d9;\n height: 1px;\n border: 0;\n border-top: 1px solid #d9d9d9;\n margin: 20px 0;\n padding: 0;\n}\n[data-v-e13e76c6] .markdown-preview del,[data-v-e13e76c6] .markdown-preview em,[data-v-e13e76c6] .markdown-preview strong {\n display: inline-block;\n}\n[data-v-e13e76c6] .markdown-preview blockquote {\n position: relative;\n background: #f7f7f7;\n padding: 6px 12px;\n border-left: 5px solid #d9d9d9;\n border-radius: 2px;\n margin: 8px 0;\n}\n[data-v-e13e76c6] .markdown-preview h1,[data-v-e13e76c6] .markdown-preview h2,[data-v-e13e76c6] .markdown-preview h3,[data-v-e13e76c6] .markdown-preview h4,[data-v-e13e76c6] .markdown-preview h5,[data-v-e13e76c6] .markdown-preview h6 {\n color: #262626;\n}\n[data-v-e13e76c6] .markdown-preview h1 {\n font-size: 28px;\n border-bottom: 1px solid #d9d9d9;\n}\n[data-v-e13e76c6] .markdown-preview h2 {\n font-size: 24px;\n}\n[data-v-e13e76c6] .markdown-preview h3 {\n font-size: 18px;\n}\n[data-v-e13e76c6] .markdown-preview h4 {\n font-size: 16px;\n}\n[data-v-e13e76c6] .markdown-preview h5 {\n font-size: 14px;\n}\n[data-v-e13e76c6] .markdown-preview h6 {\n font-size: 12px;\n}\n[data-v-e13e76c6] .markdown-preview h1,[data-v-e13e76c6] .markdown-preview h2,[data-v-e13e76c6] .markdown-preview h3,[data-v-e13e76c6] .markdown-preview h4,[data-v-e13e76c6] .markdown-preview h5,[data-v-e13e76c6] .markdown-preview h6 {\n padding: 8px 0;\n font-weight: 600;\n}\n[data-v-e13e76c6] .markdown-preview p {\n font-size: 14px !important;\n color: #262626;\n margin-bottom: 8px;\n line-height: 22px;\n}\n[data-v-e13e76c6] .markdown-preview img {\n display: block;\n max-width: 100%;\n margin: 20px 0;\n cursor: pointer;\n}\n[data-v-e13e76c6] .markdown-preview table {\n width: 100%;\n border: 1px solid #d9d9d9;\n border-bottom: 0;\n background: #fff;\n border-spacing: 0;\n border-collapse: collapse;\n margin: 20px 0;\n}\n[data-v-e13e76c6] .markdown-preview table tr {\n -webkit-transition: background 0.1s;\n transition: background 0.1s;\n}\n[data-v-e13e76c6] .markdown-preview table tr td,[data-v-e13e76c6] .markdown-preview table tr th {\n padding: 4px 8px;\n font-size: 14px;\n line-height: 24px;\n color: #333;\n border-bottom: 1px solid #d9d9d9;\n cursor: pointer;\n}\n[data-v-e13e76c6] .markdown-preview table th {\n background: #f8f8f9;\n text-align: left;\n font-weight: bold;\n}\n[data-v-e13e76c6] .markdown-preview table tr:nth-of-type(even) td {\n background: #fafafa;\n}\n[data-v-e13e76c6] .markdown-preview table tr:hover td {\n background: #f5f5f5;\n}\n[data-v-e13e76c6] .markdown-preview table td,[data-v-e13e76c6] .markdown-preview table th {\n border: 1px solid #d9d9d9;\n word-break: break-all;\n}\n[data-v-e13e76c6] .markdown-preview input[type=\"checkbox\"] {\n display: inline-block;\n border-radius: 0;\n margin-right: 8px;\n}\n[data-v-e13e76c6] .markdown-preview a {\n text-decoration: none;\n color: #1890ff;\n font-size: 14px;\n line-height: 22px;\n}\n[data-v-e13e76c6] .markdown-preview .code-block {\n position: relative;\n padding: 0 !important;\n}\n[data-v-e13e76c6] .markdown-preview .code-block .copy-code {\n position: absolute;\n z-index: 999;\n top: 5px;\n right: 10px;\n font-size: 12px;\n color: #d9d9d9;\n line-height: 20px;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n -webkit-transition: all 0.3s;\n transition: all 0.3s;\n opacity: 0;\n}\n[data-v-e13e76c6] .markdown-preview .code-block .copy-code:hover {\n color: #1890ff;\n}\n[data-v-e13e76c6] .markdown-preview .code-block:hover .copy-code {\n opacity: 1;\n}\n.preview-img[data-v-e13e76c6] {\n position: fixed;\n width: 100vw;\n height: 100vh;\n z-index: 99999999;\n left: 0;\n top: 0;\n background: rgba(0, 0, 0, 0.5);\n display: none;\n opacity: 0;\n -webkit-transition: opacity 0.3s 0.1s;\n transition: opacity 0.3s 0.1s;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n}\n.preview-img .close[data-v-e13e76c6] {\n position: absolute;\n right: 0;\n top: 0;\n color: #fff;\n padding: 10px;\n font-size: 20px;\n cursor: pointer;\n}\n.preview-img img[data-v-e13e76c6] {\n display: block;\n}\n.preview-img img.vertical[data-v-e13e76c6] {\n height: 80%;\n width: auto;\n}\n.preview-img img.horizontal[data-v-e13e76c6] {\n width: 80%;\n height: auto;\n}\n.preview-img.active[data-v-e13e76c6] {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n opacity: 1;\n}\n", ""]);
  15189. // exports
  15190. /***/ }),
  15191. /***/ 872:
  15192. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15193. "use strict";
  15194. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  15195. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__pro__ = __webpack_require__(873);
  15196. //
  15197. //
  15198. //
  15199. //
  15200. //
  15201. //
  15202. //
  15203. //
  15204. //
  15205. //
  15206. //
  15207. //
  15208. //
  15209. //
  15210. //
  15211. //
  15212. //
  15213. //
  15214. //
  15215. //
  15216. //
  15217. //
  15218. //
  15219. //
  15220. //
  15221. //
  15222. //
  15223. //
  15224. //
  15225. //
  15226. //
  15227. //
  15228. //
  15229. //
  15230. //
  15231. //
  15232. //
  15233. //
  15234. //
  15235. //
  15236. //
  15237. //
  15238. //
  15239. //
  15240. //
  15241. //
  15242. //
  15243. //
  15244. //
  15245. //
  15246. //
  15247. //
  15248. //
  15249. //
  15250. //
  15251. //
  15252. //
  15253. //
  15254. //
  15255. //
  15256. //
  15257. //
  15258. //
  15259. //
  15260. //
  15261. //
  15262. //
  15263. //
  15264. //
  15265. //
  15266. //
  15267. //
  15268. //
  15269. //
  15270. //
  15271. //
  15272. //
  15273. //
  15274. //
  15275. //
  15276. //
  15277. //
  15278. //
  15279. //
  15280. //
  15281. //
  15282. //
  15283. //
  15284. //
  15285. //
  15286. //
  15287. //
  15288. //
  15289. //
  15290. //
  15291. //
  15292. //
  15293. //
  15294. //
  15295. //
  15296. //
  15297. //
  15298. //
  15299. //
  15300. //
  15301. //
  15302. //
  15303. //
  15304. //
  15305. //
  15306. //
  15307. //
  15308. //
  15309. //
  15310. //
  15311. //
  15312. //
  15313. //
  15314. //
  15315. //
  15316. //
  15317. //
  15318. //
  15319. //
  15320. //
  15321. //
  15322. //
  15323. //
  15324. //
  15325. //
  15326. //
  15327. //
  15328. //
  15329. //
  15330. //
  15331. //
  15332. //
  15333. //
  15334. //
  15335. //
  15336. //
  15337. //
  15338. //
  15339. //
  15340. //
  15341. //
  15342. //
  15343. //
  15344. //
  15345. //
  15346. //
  15347. //
  15348. //
  15349. //
  15350. //
  15351. //
  15352. //
  15353. //
  15354. //
  15355. //
  15356. //
  15357. //
  15358. //
  15359. //
  15360. //
  15361. //
  15362. //
  15363. //
  15364. //
  15365. //
  15366. //
  15367. //
  15368. //
  15369. //
  15370. //
  15371. //
  15372. //
  15373. //
  15374. //
  15375. //
  15376. //
  15377. /* harmony default export */ __webpack_exports__["default"] = (__WEBPACK_IMPORTED_MODULE_0__pro__["a" /* default */]);
  15378. /***/ }),
  15379. /***/ 873:
  15380. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15381. "use strict";
  15382. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__assets_js_codemirror__ = __webpack_require__(321);
  15383. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__assets_js_codemirror_mode_xml__ = __webpack_require__(874);
  15384. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__assets_js_codemirror_mode_css__ = __webpack_require__(875);
  15385. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__assets_js_codemirror_mode_javascript__ = __webpack_require__(876);
  15386. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__assets_js_codemirror_mode_markdown__ = __webpack_require__(877);
  15387. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__assets_js_codemirror_config__ = __webpack_require__(878);
  15388. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__assets_js_codemirror_styles_codemirror_css__ = __webpack_require__(879);
  15389. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__assets_js_codemirror_styles_codemirror_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6__assets_js_codemirror_styles_codemirror_css__);
  15390. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__mixins_common__ = __webpack_require__(881);
  15391. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__config_marked__ = __webpack_require__(409);
  15392. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  15393. /* harmony default export */ __webpack_exports__["a"] = ({
  15394. name: 'markdown-pro',
  15395. mixins: [__WEBPACK_IMPORTED_MODULE_7__mixins_common__["a" /* default */]],
  15396. data: function data() {
  15397. return {
  15398. pro: true,
  15399. editor: null, // 编辑器实例
  15400. lastPos: '' // 光标最后所在位置
  15401. };
  15402. },
  15403. mounted: function mounted() {
  15404. this.init();
  15405. this.createEditor();
  15406. },
  15407. methods: {
  15408. init: function init() {
  15409. var _this = this;
  15410. // 初始化
  15411. this.currentValue = this.value;
  15412. this.themeName = this.theme;
  15413. this.preview = this.isPreview;
  15414. this.currentValue = this.value;
  15415. if (this.isPreview) {
  15416. return;
  15417. }
  15418. setTimeout(function () {
  15419. if (_this.autoSave) {
  15420. _this.timerId = setInterval(function () {
  15421. _this.handleSave();
  15422. }, _this.interval);
  15423. }
  15424. }, 20);
  15425. },
  15426. createEditor: function createEditor() {
  15427. var _this2 = this;
  15428. // 初始化左侧编辑器
  15429. this.editor = new __WEBPACK_IMPORTED_MODULE_0__assets_js_codemirror__["a" /* default */](this.$refs.codemirror, _extends({
  15430. value: this.currentValue,
  15431. onload: function onload(data) {
  15432. var _data$doc$height = data.doc.height,
  15433. height = _data$doc$height === undefined ? 0 : _data$doc$height;
  15434. _this2.editorScrollHeight = height;
  15435. }
  15436. }, __WEBPACK_IMPORTED_MODULE_5__assets_js_codemirror_config__["a" /* default */]));
  15437. this.addEditorLintener();
  15438. this.$emit('on-ready', {
  15439. vm: this,
  15440. insertContent: this.insertContent
  15441. });
  15442. },
  15443. addEditorLintener: function addEditorLintener() {
  15444. var _this3 = this;
  15445. //绑定监听事件
  15446. var editor = this.editor;
  15447. editor.on('change', function (data) {
  15448. _this3.lastPos = editor.getCursor();
  15449. _this3.currentValue = editor.getValue();
  15450. var height = data.doc.height;
  15451. _this3.editorScrollHeight = height;
  15452. });
  15453. editor.on('scroll', this.markdownScroll);
  15454. editor.on('paste', this.handlePaste);
  15455. editor.on('keydown', function (data, e) {
  15456. if (e.keyCode === 83) {
  15457. if (e.metaKey || e.ctrlKey) {
  15458. e.preventDefault();
  15459. _this3.handleSave();
  15460. }
  15461. } else if (e.keyCode === 13) {
  15462. _this3.listerenKeyupEnter(e);
  15463. } else if (e.keyCode === 8) {
  15464. _this3.listerenDelete(data);
  15465. }
  15466. });
  15467. editor.on('focus', function () {
  15468. _this3.lastPos = editor.getCursor();
  15469. });
  15470. },
  15471. insertContent: function insertContent(str) {
  15472. // 插入文本
  15473. this.editor.replaceSelection(str);
  15474. this.lastInsert = str.replace(/\n/g, '');
  15475. },
  15476. setCursor: function setCursor() {
  15477. var line = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  15478. var ch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  15479. // 设置焦点
  15480. var editor = this.editor;
  15481. editor.setCursor(line, ch);
  15482. editor.focus();
  15483. },
  15484. insertStrong: function insertStrong() {
  15485. // 粗体
  15486. var editor = this.editor,
  15487. _lastPos = this.lastPos,
  15488. lastPos = _lastPos === undefined ? {} : _lastPos;
  15489. var _lastPos$line = lastPos.line,
  15490. line = _lastPos$line === undefined ? 0 : _lastPos$line,
  15491. _lastPos$ch = lastPos.ch,
  15492. ch = _lastPos$ch === undefined ? 0 : _lastPos$ch;
  15493. var selection = editor.getSelection();
  15494. if (selection) {
  15495. this.insertContent('**' + selection + '**');
  15496. } else {
  15497. this.insertContent('****');
  15498. this.setCursor(line, ch + 2);
  15499. }
  15500. },
  15501. insertItalic: function insertItalic() {
  15502. // 斜体
  15503. var editor = this.editor,
  15504. _lastPos2 = this.lastPos,
  15505. lastPos = _lastPos2 === undefined ? {} : _lastPos2;
  15506. var _lastPos$line2 = lastPos.line,
  15507. line = _lastPos$line2 === undefined ? 0 : _lastPos$line2,
  15508. _lastPos$ch2 = lastPos.ch,
  15509. ch = _lastPos$ch2 === undefined ? 0 : _lastPos$ch2;
  15510. var selection = editor.getSelection();
  15511. if (selection) {
  15512. this.insertContent('*' + selection + '*');
  15513. } else {
  15514. this.insertContent('**');
  15515. this.setCursor(line, ch + 1);
  15516. }
  15517. },
  15518. insertUnderline: function insertUnderline() {
  15519. // 下划线
  15520. var editor = this.editor,
  15521. _lastPos3 = this.lastPos,
  15522. lastPos = _lastPos3 === undefined ? {} : _lastPos3;
  15523. var _lastPos$line3 = lastPos.line,
  15524. line = _lastPos$line3 === undefined ? 0 : _lastPos$line3,
  15525. _lastPos$ch3 = lastPos.ch,
  15526. ch = _lastPos$ch3 === undefined ? 0 : _lastPos$ch3;
  15527. var selection = editor.getSelection();
  15528. if (selection) {
  15529. this.insertContent('<u>' + selection + '</u>');
  15530. } else {
  15531. this.insertContent('<u></u>');
  15532. this.setCursor(line, ch + 3);
  15533. }
  15534. },
  15535. insertOverline: function insertOverline() {
  15536. // 删除线
  15537. var editor = this.editor,
  15538. _lastPos4 = this.lastPos,
  15539. lastPos = _lastPos4 === undefined ? {} : _lastPos4;
  15540. var _lastPos$line4 = lastPos.line,
  15541. line = _lastPos$line4 === undefined ? 0 : _lastPos$line4,
  15542. _lastPos$ch4 = lastPos.ch,
  15543. ch = _lastPos$ch4 === undefined ? 0 : _lastPos$ch4;
  15544. var selection = editor.getSelection();
  15545. if (selection) {
  15546. this.insertContent('~~' + selection + '~~');
  15547. } else {
  15548. this.insertContent('~~~~');
  15549. this.setCursor(line, ch + 2);
  15550. }
  15551. },
  15552. insertTitle: function insertTitle(level) {
  15553. // 插入标题
  15554. var titles = {
  15555. 1: '# ',
  15556. 2: '## ',
  15557. 3: '### ',
  15558. 4: '#### ',
  15559. 5: '##### ',
  15560. 6: '###### '
  15561. };
  15562. var editor = this.editor,
  15563. _lastPos5 = this.lastPos,
  15564. lastPos = _lastPos5 === undefined ? {} : _lastPos5;
  15565. var line = lastPos.line;
  15566. var selection = editor.getSelection();
  15567. if (selection) {
  15568. this.insertContent('\n' + titles[level] + selection + '\n');
  15569. } else {
  15570. var title = titles[level];
  15571. if (editor.isClean()) {
  15572. this.insertContent(title);
  15573. this.setCursor(0, title.length);
  15574. } else {
  15575. this.insertContent('\n' + title);
  15576. this.setCursor(line + 1, title.length);
  15577. }
  15578. }
  15579. },
  15580. insertLine: function insertLine() {
  15581. // 插入分割线
  15582. var editor = this.editor;
  15583. if (editor.isClean()) {
  15584. this.insertContent('----\n');
  15585. } else {
  15586. this.insertContent('\n\n----\n');
  15587. }
  15588. },
  15589. insertQuote: function insertQuote() {
  15590. // 引用
  15591. var editor = this.editor,
  15592. _lastPos6 = this.lastPos,
  15593. lastPos = _lastPos6 === undefined ? {} : _lastPos6;
  15594. var _lastPos$line5 = lastPos.line,
  15595. line = _lastPos$line5 === undefined ? 0 : _lastPos$line5;
  15596. var selection = editor.getSelection();
  15597. if (selection) {
  15598. this.insertContent('\n> ' + selection + '\n\n');
  15599. } else {
  15600. if (editor.isClean()) {
  15601. this.insertContent('> ');
  15602. this.setCursor(0, 3);
  15603. } else {
  15604. this.insertContent('\n> ');
  15605. this.setCursor(line + 1, 3);
  15606. }
  15607. }
  15608. },
  15609. insertUl: function insertUl() {
  15610. // 无序列表
  15611. var editor = this.editor,
  15612. _lastPos7 = this.lastPos,
  15613. lastPos = _lastPos7 === undefined ? {} : _lastPos7;
  15614. var _lastPos$line6 = lastPos.line,
  15615. line = _lastPos$line6 === undefined ? 0 : _lastPos$line6,
  15616. _lastPos$ch5 = lastPos.ch,
  15617. ch = _lastPos$ch5 === undefined ? 0 : _lastPos$ch5;
  15618. var selection = editor.getSelection();
  15619. if (selection) {
  15620. this.insertContent('\n- ' + selection + '\n\n');
  15621. } else {
  15622. if (editor.isClean() || ch === 0) {
  15623. this.insertContent('- ');
  15624. this.setCursor(line, 3);
  15625. } else {
  15626. this.insertContent('\n- ');
  15627. this.setCursor(line + 1, 3);
  15628. }
  15629. }
  15630. },
  15631. insertOl: function insertOl() {
  15632. // 有序列表
  15633. var editor = this.editor,
  15634. _lastPos8 = this.lastPos,
  15635. lastPos = _lastPos8 === undefined ? {} : _lastPos8;
  15636. var _lastPos$line7 = lastPos.line,
  15637. line = _lastPos$line7 === undefined ? 0 : _lastPos$line7,
  15638. _lastPos$ch6 = lastPos.ch,
  15639. ch = _lastPos$ch6 === undefined ? 0 : _lastPos$ch6;
  15640. var selection = editor.getSelection();
  15641. if (selection) {
  15642. this.insertContent('\n1. ' + selection + '\n\n');
  15643. } else {
  15644. if (editor.isClean() || ch === 0) {
  15645. this.insertContent('1. ');
  15646. this.setCursor(line, 4);
  15647. } else {
  15648. this.insertContent('\n1. ');
  15649. this.setCursor(line + 1, 4);
  15650. }
  15651. }
  15652. },
  15653. insertCode: function insertCode() {
  15654. // 插入code
  15655. var editor = this.editor,
  15656. _lastPos9 = this.lastPos,
  15657. lastPos = _lastPos9 === undefined ? {} : _lastPos9;
  15658. var line = lastPos.line;
  15659. var selection = editor.getSelection();
  15660. if (selection) {
  15661. this.insertContent('\n```\n' + selection + '\n```\n');
  15662. } else {
  15663. if (editor.isClean()) {
  15664. this.insertContent('```\n\n```');
  15665. this.setCursor(1, 0);
  15666. } else {
  15667. this.insertContent('\n```\n\n```');
  15668. this.setCursor(line + 2, 0);
  15669. }
  15670. }
  15671. },
  15672. insertFinished: function insertFinished() {
  15673. // 已完成列表
  15674. var editor = this.editor,
  15675. _lastPos10 = this.lastPos,
  15676. lastPos = _lastPos10 === undefined ? {} : _lastPos10;
  15677. var _lastPos$line8 = lastPos.line,
  15678. line = _lastPos$line8 === undefined ? 0 : _lastPos$line8,
  15679. _lastPos$ch7 = lastPos.ch,
  15680. ch = _lastPos$ch7 === undefined ? 0 : _lastPos$ch7;
  15681. var selection = editor.getSelection();
  15682. if (selection) {
  15683. this.insertContent('\n- [x] ' + selection + '\n\n');
  15684. } else {
  15685. if (editor.isClean() || ch === 0) {
  15686. this.insertContent('- [x] ');
  15687. this.setCursor(line, 6);
  15688. } else {
  15689. this.insertContent('\n- [x] ');
  15690. this.setCursor(line + 1, 6);
  15691. }
  15692. }
  15693. },
  15694. insertNotFinished: function insertNotFinished() {
  15695. // 未完成列表
  15696. var editor = this.editor,
  15697. _lastPos11 = this.lastPos,
  15698. lastPos = _lastPos11 === undefined ? {} : _lastPos11;
  15699. var _lastPos$line9 = lastPos.line,
  15700. line = _lastPos$line9 === undefined ? 0 : _lastPos$line9,
  15701. _lastPos$ch8 = lastPos.ch,
  15702. ch = _lastPos$ch8 === undefined ? 0 : _lastPos$ch8;
  15703. var selection = editor.getSelection();
  15704. if (selection) {
  15705. this.insertContent('\n- [ ] ' + selection + '\n\n');
  15706. } else {
  15707. if (editor.isClean() || ch === 0) {
  15708. this.insertContent('- [ ] ');
  15709. this.setCursor(line, 6);
  15710. } else {
  15711. this.insertContent('\n- [ ] ');
  15712. this.setCursor(line + 1, 6);
  15713. }
  15714. }
  15715. },
  15716. listerenKeyupEnter: function listerenKeyupEnter(e) {
  15717. // 回车事件
  15718. var lastInsert = this.lastInsert;
  15719. if (lastInsert) {
  15720. var list = ['-', '- [ ]', '- [x]'];
  15721. if (list.includes(lastInsert.trim())) {
  15722. e.preventDefault();
  15723. this.insertContent('\n' + lastInsert);
  15724. } else if (/^\d+\.$/.test(lastInsert.trim())) {
  15725. e.preventDefault();
  15726. this.insertContent('\n' + (parseInt(lastInsert, 0) + 1) + '. ');
  15727. }
  15728. }
  15729. },
  15730. listerenDelete: function listerenDelete() {
  15731. var _this4 = this;
  15732. // 删除 backup
  15733. setTimeout(function () {
  15734. var editor = _this4.editor;
  15735. if (!editor.isClean()) {
  15736. var value = editor.getValue();
  15737. if (value.split('\n').pop() === '') {
  15738. _this4.lastInsert = '';
  15739. }
  15740. }
  15741. }, 20);
  15742. },
  15743. onDelete: function onDelete() {
  15744. // 删除时,以回车为界分割,如果数组最后一个元素为''时,将行一次插入的共嗯那个置为空,避免回车时再次插入
  15745. var lines = this.currentValue.split('\n');
  15746. if (lines[lines.length - 1] === '') {
  15747. this.lastInsert = '';
  15748. }
  15749. },
  15750. markdownScroll: function markdownScroll() {
  15751. var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  15752. //编辑器区域滚动
  15753. if (this.scrolling && this.scrollSide === 'left') {
  15754. var _data$doc = data.doc,
  15755. height = _data$doc.height,
  15756. scrollTop = _data$doc.scrollTop;
  15757. var preview = this.$refs.preview;
  15758. var contentHeight = preview.offsetHeight;
  15759. var previewScrollHeight = preview.scrollHeight;
  15760. preview.scrollTop = parseInt(scrollTop * (previewScrollHeight - contentHeight) / (height - contentHeight), 0);
  15761. }
  15762. },
  15763. previewScroll: function previewScroll() {
  15764. //预览内容区域滚动
  15765. if (this.scrolling && this.scrollSide === 'right') {
  15766. var preview = this.$refs.preview;
  15767. var contentHeight = preview.offsetHeight;
  15768. var previewScrollHeight = preview.scrollHeight;
  15769. var previewScrollTop = preview.scrollTop;
  15770. var scrollTop = parseInt(previewScrollTop * (this.editorScrollHeight - contentHeight) / (previewScrollHeight - contentHeight), 0);
  15771. this.editor.scrollTo(0, scrollTop);
  15772. }
  15773. },
  15774. redo: function redo() {
  15775. var editor = this.editor;
  15776. editor.redo();
  15777. setTimeout(function () {
  15778. editor.refresh();
  15779. }, 20);
  15780. }
  15781. },
  15782. watch: {
  15783. currentValue: function currentValue() {
  15784. var _this5 = this;
  15785. clearTimeout(this.timeoutId);
  15786. this.timeoutId = setTimeout(function () {
  15787. var currentValue = _this5.currentValue;
  15788. var html = Object(__WEBPACK_IMPORTED_MODULE_8__config_marked__["a" /* default */])(currentValue, _extends({
  15789. sanitize: false
  15790. }, _this5.markedOptions)).replace(/href="/gi, 'target="_blank" href="');
  15791. if (_this5.copyCode && html !== '') {
  15792. html = html.replace(/<pre>/g, '<div class="code-block"><span class="copy-code">' + _this5.copyBtnText + '</span><pre>').replace(/<\/pre>/g, '</pre></div>');
  15793. }
  15794. _this5.html = html;
  15795. _this5.addImageClickListener();
  15796. _this5.addCopyListener();
  15797. _this5.$emit('input', currentValue);
  15798. }, 30);
  15799. },
  15800. value: function value() {
  15801. var value = this.value,
  15802. currentValue = this.currentValue;
  15803. if (currentValue !== value) {
  15804. // 由于用户输入而造成的value变化,不对editor设置值
  15805. this.currentValue = value;
  15806. this.editor.setOption('value', value);
  15807. }
  15808. }
  15809. }
  15810. });
  15811. /***/ }),
  15812. /***/ 874:
  15813. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15814. "use strict";
  15815. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__(321);
  15816. var htmlConfig = {
  15817. autoSelfClosers: {
  15818. area: true,
  15819. base: true,
  15820. br: true,
  15821. col: true,
  15822. command: true,
  15823. embed: true,
  15824. frame: true,
  15825. hr: true,
  15826. img: true,
  15827. input: true,
  15828. keygen: true,
  15829. link: true,
  15830. meta: true,
  15831. param: true,
  15832. source: true,
  15833. track: true,
  15834. wbr: true,
  15835. menuitem: true
  15836. },
  15837. implicitlyClosed: {
  15838. dd: true,
  15839. li: true,
  15840. optgroup: true,
  15841. option: true,
  15842. p: true,
  15843. rp: true,
  15844. rt: true,
  15845. tbody: true,
  15846. td: true,
  15847. tfoot: true,
  15848. th: true,
  15849. tr: true
  15850. },
  15851. contextGrabbers: {
  15852. dd: { dd: true, dt: true },
  15853. dt: { dd: true, dt: true },
  15854. li: { li: true },
  15855. option: { option: true, optgroup: true },
  15856. optgroup: { optgroup: true },
  15857. p: {
  15858. address: true,
  15859. article: true,
  15860. aside: true,
  15861. blockquote: true,
  15862. dir: true,
  15863. div: true,
  15864. dl: true,
  15865. fieldset: true,
  15866. footer: true,
  15867. form: true,
  15868. h1: true,
  15869. h2: true,
  15870. h3: true,
  15871. h4: true,
  15872. h5: true,
  15873. h6: true,
  15874. header: true,
  15875. hgroup: true,
  15876. hr: true,
  15877. menu: true,
  15878. nav: true,
  15879. ol: true,
  15880. p: true,
  15881. pre: true,
  15882. section: true,
  15883. table: true,
  15884. ul: true
  15885. },
  15886. rp: { rp: true, rt: true },
  15887. rt: { rp: true, rt: true },
  15888. tbody: { tbody: true, tfoot: true },
  15889. td: { td: true, th: true },
  15890. tfoot: { tbody: true },
  15891. th: { td: true, th: true },
  15892. thead: { tbody: true, tfoot: true },
  15893. tr: { tr: true }
  15894. },
  15895. doNotIndent: { pre: true },
  15896. allowUnquoted: true,
  15897. allowMissing: true,
  15898. caseFold: true
  15899. };
  15900. var xmlConfig = {
  15901. autoSelfClosers: {},
  15902. implicitlyClosed: {},
  15903. contextGrabbers: {},
  15904. doNotIndent: {},
  15905. allowUnquoted: false,
  15906. allowMissing: false,
  15907. allowMissingTagName: false,
  15908. caseFold: false
  15909. };
  15910. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMode('xml', defineMode);
  15911. function defineMode(editorConf, config_) {
  15912. var indentUnit = editorConf.indentUnit;
  15913. var config = {};
  15914. var defaults = config_.htmlMode ? htmlConfig : xmlConfig;
  15915. for (var prop in defaults) {
  15916. config[prop] = defaults[prop];
  15917. }
  15918. for (var prop in config_) {
  15919. config[prop] = config_[prop];
  15920. }
  15921. // Return variables for tokenizers
  15922. var type, setStyle;
  15923. function inText(stream, state) {
  15924. function chain(parser) {
  15925. state.tokenize = parser;
  15926. return parser(stream, state);
  15927. }
  15928. var ch = stream.next();
  15929. if (ch == '<') {
  15930. if (stream.eat('!')) {
  15931. if (stream.eat('[')) {
  15932. if (stream.match('CDATA[')) {
  15933. return chain(inBlock('atom', ']]>'));
  15934. } else {
  15935. return null;
  15936. }
  15937. } else if (stream.match('--')) {
  15938. return chain(inBlock('comment', '-->'));
  15939. } else if (stream.match('DOCTYPE', true, true)) {
  15940. stream.eatWhile(/[\w\._\-]/);
  15941. return chain(doctype(1));
  15942. } else {
  15943. return null;
  15944. }
  15945. } else if (stream.eat('?')) {
  15946. stream.eatWhile(/[\w\._\-]/);
  15947. state.tokenize = inBlock('meta', '?>');
  15948. return 'meta';
  15949. } else {
  15950. type = stream.eat('/') ? 'closeTag' : 'openTag';
  15951. state.tokenize = inTag;
  15952. return 'tag bracket';
  15953. }
  15954. } else if (ch == '&') {
  15955. var ok;
  15956. if (stream.eat('#')) {
  15957. if (stream.eat('x')) {
  15958. ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(';');
  15959. } else {
  15960. ok = stream.eatWhile(/[\d]/) && stream.eat(';');
  15961. }
  15962. } else {
  15963. ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(';');
  15964. }
  15965. return ok ? 'atom' : 'error';
  15966. } else {
  15967. stream.eatWhile(/[^&<]/);
  15968. return null;
  15969. }
  15970. }
  15971. inText.isInText = true;
  15972. function inTag(stream, state) {
  15973. var ch = stream.next();
  15974. if (ch == '>' || ch == '/' && stream.eat('>')) {
  15975. state.tokenize = inText;
  15976. type = ch == '>' ? 'endTag' : 'selfcloseTag';
  15977. return 'tag bracket';
  15978. } else if (ch == '=') {
  15979. type = 'equals';
  15980. return null;
  15981. } else if (ch == '<') {
  15982. state.tokenize = inText;
  15983. state.state = baseState;
  15984. state.tagName = state.tagStart = null;
  15985. var next = state.tokenize(stream, state);
  15986. return next ? next + ' tag error' : 'tag error';
  15987. } else if (/[\'\"]/.test(ch)) {
  15988. state.tokenize = inAttribute(ch);
  15989. state.stringStartCol = stream.column();
  15990. return state.tokenize(stream, state);
  15991. } else {
  15992. stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
  15993. return 'word';
  15994. }
  15995. }
  15996. function inAttribute(quote) {
  15997. var closure = function closure(stream, state) {
  15998. while (!stream.eol()) {
  15999. if (stream.next() == quote) {
  16000. state.tokenize = inTag;
  16001. break;
  16002. }
  16003. }
  16004. return 'string';
  16005. };
  16006. closure.isInAttribute = true;
  16007. return closure;
  16008. }
  16009. function inBlock(style, terminator) {
  16010. return function (stream, state) {
  16011. while (!stream.eol()) {
  16012. if (stream.match(terminator)) {
  16013. state.tokenize = inText;
  16014. break;
  16015. }
  16016. stream.next();
  16017. }
  16018. return style;
  16019. };
  16020. }
  16021. function doctype(depth) {
  16022. return function (stream, state) {
  16023. var ch;
  16024. while ((ch = stream.next()) != null) {
  16025. if (ch == '<') {
  16026. state.tokenize = doctype(depth + 1);
  16027. return state.tokenize(stream, state);
  16028. } else if (ch == '>') {
  16029. if (depth == 1) {
  16030. state.tokenize = inText;
  16031. break;
  16032. } else {
  16033. state.tokenize = doctype(depth - 1);
  16034. return state.tokenize(stream, state);
  16035. }
  16036. }
  16037. }
  16038. return 'meta';
  16039. };
  16040. }
  16041. function Context(state, tagName, startOfLine) {
  16042. this.prev = state.context;
  16043. this.tagName = tagName;
  16044. this.indent = state.indented;
  16045. this.startOfLine = startOfLine;
  16046. if (config.doNotIndent.hasOwnProperty(tagName) || state.context && state.context.noIndent) {
  16047. this.noIndent = true;
  16048. }
  16049. }
  16050. function popContext(state) {
  16051. if (state.context) {
  16052. state.context = state.context.prev;
  16053. }
  16054. }
  16055. function maybePopContext(state, nextTagName) {
  16056. var parentTagName;
  16057. while (true) {
  16058. if (!state.context) {
  16059. return;
  16060. }
  16061. parentTagName = state.context.tagName;
  16062. if (!config.contextGrabbers.hasOwnProperty(parentTagName) || !config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
  16063. return;
  16064. }
  16065. popContext(state);
  16066. }
  16067. }
  16068. function baseState(type, stream, state) {
  16069. if (type == 'openTag') {
  16070. state.tagStart = stream.column();
  16071. return tagNameState;
  16072. } else if (type == 'closeTag') {
  16073. return closeTagNameState;
  16074. } else {
  16075. return baseState;
  16076. }
  16077. }
  16078. function tagNameState(type, stream, state) {
  16079. if (type == 'word') {
  16080. state.tagName = stream.current();
  16081. setStyle = 'tag';
  16082. return attrState;
  16083. } else if (config.allowMissingTagName && type == 'endTag') {
  16084. setStyle = 'tag bracket';
  16085. return attrState(type, stream, state);
  16086. } else {
  16087. setStyle = 'error';
  16088. return tagNameState;
  16089. }
  16090. }
  16091. function closeTagNameState(type, stream, state) {
  16092. if (type == 'word') {
  16093. var tagName = stream.current();
  16094. if (state.context && state.context.tagName != tagName && config.implicitlyClosed.hasOwnProperty(state.context.tagName)) {
  16095. popContext(state);
  16096. }
  16097. if (state.context && state.context.tagName == tagName || config.matchClosing === false) {
  16098. setStyle = 'tag';
  16099. return closeState;
  16100. } else {
  16101. setStyle = 'tag error';
  16102. return closeStateErr;
  16103. }
  16104. } else if (config.allowMissingTagName && type == 'endTag') {
  16105. setStyle = 'tag bracket';
  16106. return closeState(type, stream, state);
  16107. } else {
  16108. setStyle = 'error';
  16109. return closeStateErr;
  16110. }
  16111. }
  16112. function closeState(type, _stream, state) {
  16113. if (type != 'endTag') {
  16114. setStyle = 'error';
  16115. return closeState;
  16116. }
  16117. popContext(state);
  16118. return baseState;
  16119. }
  16120. function closeStateErr(type, stream, state) {
  16121. setStyle = 'error';
  16122. return closeState(type, stream, state);
  16123. }
  16124. function attrState(type, _stream, state) {
  16125. if (type == 'word') {
  16126. setStyle = 'attribute';
  16127. return attrEqState;
  16128. } else if (type == 'endTag' || type == 'selfcloseTag') {
  16129. var tagName = state.tagName,
  16130. tagStart = state.tagStart;
  16131. state.tagName = state.tagStart = null;
  16132. if (type == 'selfcloseTag' || config.autoSelfClosers.hasOwnProperty(tagName)) {
  16133. maybePopContext(state, tagName);
  16134. } else {
  16135. maybePopContext(state, tagName);
  16136. state.context = new Context(state, tagName, tagStart == state.indented);
  16137. }
  16138. return baseState;
  16139. }
  16140. setStyle = 'error';
  16141. return attrState;
  16142. }
  16143. function attrEqState(type, stream, state) {
  16144. if (type == 'equals') {
  16145. return attrValueState;
  16146. }
  16147. if (!config.allowMissing) {
  16148. setStyle = 'error';
  16149. }
  16150. return attrState(type, stream, state);
  16151. }
  16152. function attrValueState(type, stream, state) {
  16153. if (type == 'string') {
  16154. return attrContinuedState;
  16155. }
  16156. if (type == 'word' && config.allowUnquoted) {
  16157. setStyle = 'string';
  16158. return attrState;
  16159. }
  16160. setStyle = 'error';
  16161. return attrState(type, stream, state);
  16162. }
  16163. function attrContinuedState(type, stream, state) {
  16164. if (type == 'string') {
  16165. return attrContinuedState;
  16166. }
  16167. return attrState(type, stream, state);
  16168. }
  16169. return {
  16170. startState: function startState(baseIndent) {
  16171. var state = {
  16172. tokenize: inText,
  16173. state: baseState,
  16174. indented: baseIndent || 0,
  16175. tagName: null,
  16176. tagStart: null,
  16177. context: null
  16178. };
  16179. if (baseIndent != null) {
  16180. state.baseIndent = baseIndent;
  16181. }
  16182. return state;
  16183. },
  16184. token: function token(stream, state) {
  16185. if (!state.tagName && stream.sol()) {
  16186. state.indented = stream.indentation();
  16187. }
  16188. if (stream.eatSpace()) {
  16189. return null;
  16190. }
  16191. type = null;
  16192. var style = state.tokenize(stream, state);
  16193. if ((style || type) && style != 'comment') {
  16194. setStyle = null;
  16195. state.state = state.state(type || style, stream, state);
  16196. if (setStyle) {
  16197. style = setStyle == 'error' ? style + ' error' : setStyle;
  16198. }
  16199. }
  16200. return style;
  16201. },
  16202. indent: function indent(state, textAfter, fullLine) {
  16203. var context = state.context;
  16204. // Indent multi-line strings (e.g. css).
  16205. if (state.tokenize.isInAttribute) {
  16206. if (state.tagStart == state.indented) {
  16207. return state.stringStartCol + 1;
  16208. } else {
  16209. return state.indented + indentUnit;
  16210. }
  16211. }
  16212. if (context && context.noIndent) {
  16213. return __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].Pass;
  16214. }
  16215. if (state.tokenize != inTag && state.tokenize != inText) {
  16216. return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
  16217. }
  16218. // Indent the starts of attribute names.
  16219. if (state.tagName) {
  16220. if (config.multilineTagIndentPastTag !== false) {
  16221. return state.tagStart + state.tagName.length + 2;
  16222. } else {
  16223. return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
  16224. }
  16225. }
  16226. if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) {
  16227. return 0;
  16228. }
  16229. var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
  16230. if (tagAfter && tagAfter[1]) {
  16231. // Closing tag spotted
  16232. while (context) {
  16233. if (context.tagName == tagAfter[2]) {
  16234. context = context.prev;
  16235. break;
  16236. } else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
  16237. context = context.prev;
  16238. } else {
  16239. break;
  16240. }
  16241. }
  16242. } else if (tagAfter) {
  16243. // Opening tag spotted
  16244. while (context) {
  16245. var grabbers = config.contextGrabbers[context.tagName];
  16246. if (grabbers && grabbers.hasOwnProperty(tagAfter[2])) {
  16247. context = context.prev;
  16248. } else {
  16249. break;
  16250. }
  16251. }
  16252. }
  16253. while (context && context.prev && !context.startOfLine) {
  16254. context = context.prev;
  16255. }
  16256. if (context) {
  16257. return context.indent + indentUnit;
  16258. } else {
  16259. return state.baseIndent || 0;
  16260. }
  16261. },
  16262. electricInput: /<\/[\s\w:]+>$/,
  16263. blockCommentStart: '<!--',
  16264. blockCommentEnd: '-->',
  16265. configuration: config.htmlMode ? 'html' : 'xml',
  16266. helperType: config.htmlMode ? 'html' : 'xml',
  16267. skipAttribute: function skipAttribute(state) {
  16268. if (state.state == attrValueState) {
  16269. state.state = attrState;
  16270. }
  16271. },
  16272. xmlCurrentTag: function xmlCurrentTag(state) {
  16273. return state.tagName ? { name: state.tagName, close: state.type == 'closeTag' } : null;
  16274. },
  16275. xmlCurrentContext: function xmlCurrentContext(state) {
  16276. var context = [];
  16277. for (var cx = state.context; cx; cx = cx.prev) {
  16278. if (cx.tagName) {
  16279. context.push(cx.tagName);
  16280. }
  16281. }
  16282. return context.reverse();
  16283. }
  16284. };
  16285. }
  16286. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('text/xml', 'xml');
  16287. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('php', 'xml');
  16288. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('vue', 'xml');
  16289. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('html', 'xml');
  16290. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('application/xml', 'xml');
  16291. if (!__WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].mimeModes.hasOwnProperty('text/html')) {
  16292. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('text/html', { name: 'xml', htmlMode: true });
  16293. }
  16294. /***/ }),
  16295. /***/ 875:
  16296. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16297. "use strict";
  16298. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__(321);
  16299. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  16300. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMode('css', function (config, parserConfig) {
  16301. var inline = parserConfig.inline;
  16302. if (!parserConfig.propertyKeywords) {
  16303. parserConfig = __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].resolveMode('text/css');
  16304. }
  16305. var indentUnit = config.indentUnit,
  16306. tokenHooks = parserConfig.tokenHooks,
  16307. documentTypes = parserConfig.documentTypes || {},
  16308. mediaTypes = parserConfig.mediaTypes || {},
  16309. mediaFeatures = parserConfig.mediaFeatures || {},
  16310. mediaValueKeywords = parserConfig.mediaValueKeywords || {},
  16311. propertyKeywords = parserConfig.propertyKeywords || {},
  16312. nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
  16313. fontProperties = parserConfig.fontProperties || {},
  16314. counterDescriptors = parserConfig.counterDescriptors || {},
  16315. colorKeywords = parserConfig.colorKeywords || {},
  16316. valueKeywords = parserConfig.valueKeywords || {},
  16317. allowNested = parserConfig.allowNested,
  16318. lineComment = parserConfig.lineComment,
  16319. supportsAtComponent = parserConfig.supportsAtComponent === true;
  16320. var type, override;
  16321. function ret(style, tp) {
  16322. type = tp;
  16323. return style;
  16324. }
  16325. // Tokenizers
  16326. function tokenBase(stream, state) {
  16327. var ch = stream.next();
  16328. if (tokenHooks[ch]) {
  16329. var result = tokenHooks[ch](stream, state);
  16330. if (result !== false) {
  16331. return result;
  16332. }
  16333. }
  16334. if (ch == '@') {
  16335. stream.eatWhile(/[\w\\\-]/);
  16336. return ret('def', stream.current());
  16337. } else if (ch == '=' || (ch == '~' || ch == '|') && stream.eat('=')) {
  16338. return ret(null, 'compare');
  16339. } else if (ch == '"' || ch == '\'') {
  16340. state.tokenize = tokenString(ch);
  16341. return state.tokenize(stream, state);
  16342. } else if (ch == '#') {
  16343. stream.eatWhile(/[\w\\\-]/);
  16344. return ret('atom', 'hash');
  16345. } else if (ch == '!') {
  16346. stream.match(/^\s*\w*/);
  16347. return ret('keyword', 'important');
  16348. } else if (/\d/.test(ch) || ch == '.' && stream.eat(/\d/)) {
  16349. stream.eatWhile(/[\w.%]/);
  16350. return ret('number', 'unit');
  16351. } else if (ch === '-') {
  16352. if (/[\d.]/.test(stream.peek())) {
  16353. stream.eatWhile(/[\w.%]/);
  16354. return ret('number', 'unit');
  16355. } else if (stream.match(/^-[\w\\\-]*/)) {
  16356. stream.eatWhile(/[\w\\\-]/);
  16357. if (stream.match(/^\s*:/, false)) {
  16358. return ret('variable-2', 'variable-definition');
  16359. }
  16360. return ret('variable-2', 'variable');
  16361. } else if (stream.match(/^\w+-/)) {
  16362. return ret('meta', 'meta');
  16363. }
  16364. } else if (/[,+>*\/]/.test(ch)) {
  16365. return ret(null, 'select-op');
  16366. } else if (ch == '.' && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
  16367. return ret('qualifier', 'qualifier');
  16368. } else if (/[:;{}\[\]\(\)]/.test(ch)) {
  16369. return ret(null, ch);
  16370. } else if (stream.match(/[\w-.]+(?=\()/)) {
  16371. if (/^(url(-prefix)?|domain|regexp)$/.test(stream.current().toLowerCase())) {
  16372. state.tokenize = tokenParenthesized;
  16373. }
  16374. return ret('variable callee', 'variable');
  16375. } else if (/[\w\\\-]/.test(ch)) {
  16376. stream.eatWhile(/[\w\\\-]/);
  16377. return ret('property', 'word');
  16378. } else {
  16379. return ret(null, null);
  16380. }
  16381. }
  16382. function tokenString(quote) {
  16383. return function (stream, state) {
  16384. var escaped = false,
  16385. ch;
  16386. while ((ch = stream.next()) != null) {
  16387. if (ch == quote && !escaped) {
  16388. if (quote == ')') {
  16389. stream.backUp(1);
  16390. }
  16391. break;
  16392. }
  16393. escaped = !escaped && ch == '\\';
  16394. }
  16395. if (ch == quote || !escaped && quote != ')') {
  16396. state.tokenize = null;
  16397. }
  16398. return ret('string', 'string');
  16399. };
  16400. }
  16401. function tokenParenthesized(stream, state) {
  16402. stream.next(); // Must be '('
  16403. if (!stream.match(/\s*[\"\')]/, false)) {
  16404. state.tokenize = tokenString(')');
  16405. } else {
  16406. state.tokenize = null;
  16407. }
  16408. return ret(null, '(');
  16409. }
  16410. // Context management
  16411. function Context(type, indent, prev) {
  16412. this.type = type;
  16413. this.indent = indent;
  16414. this.prev = prev;
  16415. }
  16416. function pushContext(state, stream, type, indent) {
  16417. state.context = new Context(type, stream.indentation() + (indent === false ? 0 : indentUnit), state.context);
  16418. return type;
  16419. }
  16420. function popContext(state) {
  16421. if (state.context.prev) {
  16422. state.context = state.context.prev;
  16423. }
  16424. return state.context.type;
  16425. }
  16426. function pass(type, stream, state) {
  16427. return states[state.context.type](type, stream, state);
  16428. }
  16429. function popAndPass(type, stream, state, n) {
  16430. for (var i = n || 1; i > 0; i--) {
  16431. state.context = state.context.prev;
  16432. }
  16433. return pass(type, stream, state);
  16434. }
  16435. // Parser
  16436. function wordAsValue(stream) {
  16437. var word = stream.current().toLowerCase();
  16438. if (valueKeywords.hasOwnProperty(word)) {
  16439. override = 'atom';
  16440. } else if (colorKeywords.hasOwnProperty(word)) {
  16441. override = 'keyword';
  16442. } else {
  16443. override = 'variable';
  16444. }
  16445. }
  16446. var states = {};
  16447. states.top = function (type, stream, state) {
  16448. if (type == '{') {
  16449. return pushContext(state, stream, 'block');
  16450. } else if (type == '}' && state.context.prev) {
  16451. return popContext(state);
  16452. } else if (supportsAtComponent && /@component/i.test(type)) {
  16453. return pushContext(state, stream, 'atComponentBlock');
  16454. } else if (/^@(-moz-)?document$/i.test(type)) {
  16455. return pushContext(state, stream, 'documentTypes');
  16456. } else if (/^@(media|supports|(-moz-)?document|import)$/i.test(type)) {
  16457. return pushContext(state, stream, 'atBlock');
  16458. } else if (/^@(font-face|counter-style)/i.test(type)) {
  16459. state.stateArg = type;
  16460. return 'restricted_atBlock_before';
  16461. } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(type)) {
  16462. return 'keyframes';
  16463. } else if (type && type.charAt(0) == '@') {
  16464. return pushContext(state, stream, 'at');
  16465. } else if (type == 'hash') {
  16466. override = 'builtin';
  16467. } else if (type == 'word') {
  16468. override = 'tag';
  16469. } else if (type == 'variable-definition') {
  16470. return 'maybeprop';
  16471. } else if (type == 'interpolation') {
  16472. return pushContext(state, stream, 'interpolation');
  16473. } else if (type == ':') {
  16474. return 'pseudo';
  16475. } else if (allowNested && type == '(') {
  16476. return pushContext(state, stream, 'parens');
  16477. }
  16478. return state.context.type;
  16479. };
  16480. states.block = function (type, stream, state) {
  16481. if (type == 'word') {
  16482. var word = stream.current().toLowerCase();
  16483. if (propertyKeywords.hasOwnProperty(word)) {
  16484. override = 'property';
  16485. return 'maybeprop';
  16486. } else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
  16487. override = 'string-2';
  16488. return 'maybeprop';
  16489. } else if (allowNested) {
  16490. override = stream.match(/^\s*:(?:\s|$)/, false) ? 'property' : 'tag';
  16491. return 'block';
  16492. } else {
  16493. override += ' error';
  16494. return 'maybeprop';
  16495. }
  16496. } else if (type == 'meta') {
  16497. return 'block';
  16498. } else if (!allowNested && (type == 'hash' || type == 'qualifier')) {
  16499. override = 'error';
  16500. return 'block';
  16501. } else {
  16502. return states.top(type, stream, state);
  16503. }
  16504. };
  16505. states.maybeprop = function (type, stream, state) {
  16506. if (type == ':') {
  16507. return pushContext(state, stream, 'prop');
  16508. }
  16509. return pass(type, stream, state);
  16510. };
  16511. states.prop = function (type, stream, state) {
  16512. if (type == ';') {
  16513. return popContext(state);
  16514. }
  16515. if (type == '{' && allowNested) {
  16516. return pushContext(state, stream, 'propBlock');
  16517. }
  16518. if (type == '}' || type == '{') {
  16519. return popAndPass(type, stream, state);
  16520. }
  16521. if (type == '(') {
  16522. return pushContext(state, stream, 'parens');
  16523. }
  16524. if (type == 'hash' && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) {
  16525. override += ' error';
  16526. } else if (type == 'word') {
  16527. wordAsValue(stream);
  16528. } else if (type == 'interpolation') {
  16529. return pushContext(state, stream, 'interpolation');
  16530. }
  16531. return 'prop';
  16532. };
  16533. states.propBlock = function (type, _stream, state) {
  16534. if (type == '}') {
  16535. return popContext(state);
  16536. }
  16537. if (type == 'word') {
  16538. override = 'property';
  16539. return 'maybeprop';
  16540. }
  16541. return state.context.type;
  16542. };
  16543. states.parens = function (type, stream, state) {
  16544. if (type == '{' || type == '}') {
  16545. return popAndPass(type, stream, state);
  16546. }
  16547. if (type == ')') {
  16548. return popContext(state);
  16549. }
  16550. if (type == '(') {
  16551. return pushContext(state, stream, 'parens');
  16552. }
  16553. if (type == 'interpolation') {
  16554. return pushContext(state, stream, 'interpolation');
  16555. }
  16556. if (type == 'word') {
  16557. wordAsValue(stream);
  16558. }
  16559. return 'parens';
  16560. };
  16561. states.pseudo = function (type, stream, state) {
  16562. if (type == 'meta') {
  16563. return 'pseudo';
  16564. }
  16565. if (type == 'word') {
  16566. override = 'variable-3';
  16567. return state.context.type;
  16568. }
  16569. return pass(type, stream, state);
  16570. };
  16571. states.documentTypes = function (type, stream, state) {
  16572. if (type == 'word' && documentTypes.hasOwnProperty(stream.current())) {
  16573. override = 'tag';
  16574. return state.context.type;
  16575. } else {
  16576. return states.atBlock(type, stream, state);
  16577. }
  16578. };
  16579. states.atBlock = function (type, stream, state) {
  16580. if (type == '(') {
  16581. return pushContext(state, stream, 'atBlock_parens');
  16582. }
  16583. if (type == '}' || type == ';') {
  16584. return popAndPass(type, stream, state);
  16585. }
  16586. if (type == '{') {
  16587. return popContext(state) && pushContext(state, stream, allowNested ? 'block' : 'top');
  16588. }
  16589. if (type == 'interpolation') {
  16590. return pushContext(state, stream, 'interpolation');
  16591. }
  16592. if (type == 'word') {
  16593. var word = stream.current().toLowerCase();
  16594. if (word == 'only' || word == 'not' || word == 'and' || word == 'or') {
  16595. override = 'keyword';
  16596. } else if (mediaTypes.hasOwnProperty(word)) {
  16597. override = 'attribute';
  16598. } else if (mediaFeatures.hasOwnProperty(word)) {
  16599. override = 'property';
  16600. } else if (mediaValueKeywords.hasOwnProperty(word)) {
  16601. override = 'keyword';
  16602. } else if (propertyKeywords.hasOwnProperty(word)) {
  16603. override = 'property';
  16604. } else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
  16605. override = 'string-2';
  16606. } else if (valueKeywords.hasOwnProperty(word)) {
  16607. override = 'atom';
  16608. } else if (colorKeywords.hasOwnProperty(word)) {
  16609. override = 'keyword';
  16610. } else {
  16611. override = 'error';
  16612. }
  16613. }
  16614. return state.context.type;
  16615. };
  16616. states.atComponentBlock = function (type, stream, state) {
  16617. if (type == '}') {
  16618. return popAndPass(type, stream, state);
  16619. }
  16620. if (type == '{') {
  16621. return popContext(state) && pushContext(state, stream, allowNested ? 'block' : 'top', false);
  16622. }
  16623. if (type == 'word') {
  16624. override = 'error';
  16625. }
  16626. return state.context.type;
  16627. };
  16628. states.atBlock_parens = function (type, stream, state) {
  16629. if (type == ')') {
  16630. return popContext(state);
  16631. }
  16632. if (type == '{' || type == '}') {
  16633. return popAndPass(type, stream, state, 2);
  16634. }
  16635. return states.atBlock(type, stream, state);
  16636. };
  16637. states.restricted_atBlock_before = function (type, stream, state) {
  16638. if (type == '{') {
  16639. return pushContext(state, stream, 'restricted_atBlock');
  16640. }
  16641. if (type == 'word' && state.stateArg == '@counter-style') {
  16642. override = 'variable';
  16643. return 'restricted_atBlock_before';
  16644. }
  16645. return pass(type, stream, state);
  16646. };
  16647. states.restricted_atBlock = function (type, stream, state) {
  16648. if (type == '}') {
  16649. state.stateArg = null;
  16650. return popContext(state);
  16651. }
  16652. if (type == 'word') {
  16653. if (state.stateArg == '@font-face' && !fontProperties.hasOwnProperty(stream.current().toLowerCase()) || state.stateArg == '@counter-style' && !counterDescriptors.hasOwnProperty(stream.current().toLowerCase())) {
  16654. override = 'error';
  16655. } else {
  16656. override = 'property';
  16657. }
  16658. return 'maybeprop';
  16659. }
  16660. return 'restricted_atBlock';
  16661. };
  16662. states.keyframes = function (type, stream, state) {
  16663. if (type == 'word') {
  16664. override = 'variable';
  16665. return 'keyframes';
  16666. }
  16667. if (type == '{') {
  16668. return pushContext(state, stream, 'top');
  16669. }
  16670. return pass(type, stream, state);
  16671. };
  16672. states.at = function (type, stream, state) {
  16673. if (type == ';') {
  16674. return popContext(state);
  16675. }
  16676. if (type == '{' || type == '}') {
  16677. return popAndPass(type, stream, state);
  16678. }
  16679. if (type == 'word') {
  16680. override = 'tag';
  16681. } else if (type == 'hash') {
  16682. override = 'builtin';
  16683. }
  16684. return 'at';
  16685. };
  16686. states.interpolation = function (type, stream, state) {
  16687. if (type == '}') {
  16688. return popContext(state);
  16689. }
  16690. if (type == '{' || type == ';') {
  16691. return popAndPass(type, stream, state);
  16692. }
  16693. if (type == 'word') {
  16694. override = 'variable';
  16695. } else if (type != 'variable' && type != '(' && type != ')') {
  16696. override = 'error';
  16697. }
  16698. return 'interpolation';
  16699. };
  16700. return {
  16701. startState: function startState(base) {
  16702. return {
  16703. tokenize: null,
  16704. state: inline ? 'block' : 'top',
  16705. stateArg: null,
  16706. context: new Context(inline ? 'block' : 'top', base || 0, null)
  16707. };
  16708. },
  16709. token: function token(stream, state) {
  16710. if (!state.tokenize && stream.eatSpace()) {
  16711. return null;
  16712. }
  16713. var style = (state.tokenize || tokenBase)(stream, state);
  16714. if (style && (typeof style === 'undefined' ? 'undefined' : _typeof(style)) === 'object') {
  16715. type = style[1];
  16716. style = style[0];
  16717. }
  16718. override = style;
  16719. if (type != 'comment') {
  16720. state.state = states[state.state](type, stream, state);
  16721. }
  16722. return override;
  16723. },
  16724. indent: function indent(state, textAfter) {
  16725. var cx = state.context,
  16726. ch = textAfter && textAfter.charAt(0);
  16727. var indent = cx.indent;
  16728. if (cx.type == 'prop' && (ch == '}' || ch == ')')) {
  16729. cx = cx.prev;
  16730. }
  16731. if (cx.prev) {
  16732. if (ch == '}' && (cx.type == 'block' || cx.type == 'top' || cx.type == 'interpolation' || cx.type == 'restricted_atBlock')) {
  16733. // Resume indentation from parent context.
  16734. cx = cx.prev;
  16735. indent = cx.indent;
  16736. } else if (ch == ')' && (cx.type == 'parens' || cx.type == 'atBlock_parens') || ch == '{' && (cx.type == 'at' || cx.type == 'atBlock')) {
  16737. // Dedent relative to current context.
  16738. indent = Math.max(0, cx.indent - indentUnit);
  16739. }
  16740. }
  16741. return indent;
  16742. },
  16743. electricChars: '}',
  16744. blockCommentStart: '/*',
  16745. blockCommentEnd: '*/',
  16746. blockCommentContinue: ' * ',
  16747. lineComment: lineComment,
  16748. fold: 'brace'
  16749. };
  16750. });
  16751. function keySet(array) {
  16752. var keys = {};
  16753. for (var i = 0; i < array.length; ++i) {
  16754. keys[array[i].toLowerCase()] = true;
  16755. }
  16756. return keys;
  16757. }
  16758. var documentTypes_ = ['domain', 'regexp', 'url', 'url-prefix'],
  16759. documentTypes = keySet(documentTypes_);
  16760. var mediaTypes_ = ['all', 'aural', 'braille', 'handheld', 'print', 'projection', 'screen', 'tty', 'tv', 'embossed'],
  16761. mediaTypes = keySet(mediaTypes_);
  16762. var mediaFeatures_ = ['width', 'min-width', 'max-width', 'height', 'min-height', 'max-height', 'device-width', 'min-device-width', 'max-device-width', 'device-height', 'min-device-height', 'max-device-height', 'aspect-ratio', 'min-aspect-ratio', 'max-aspect-ratio', 'device-aspect-ratio', 'min-device-aspect-ratio', 'max-device-aspect-ratio', 'color', 'min-color', 'max-color', 'color-index', 'min-color-index', 'max-color-index', 'monochrome', 'min-monochrome', 'max-monochrome', 'resolution', 'min-resolution', 'max-resolution', 'scan', 'grid', 'orientation', 'device-pixel-ratio', 'min-device-pixel-ratio', 'max-device-pixel-ratio', 'pointer', 'any-pointer', 'hover', 'any-hover'],
  16763. mediaFeatures = keySet(mediaFeatures_);
  16764. var mediaValueKeywords_ = ['landscape', 'portrait', 'none', 'coarse', 'fine', 'on-demand', 'hover', 'interlace', 'progressive'],
  16765. mediaValueKeywords = keySet(mediaValueKeywords_);
  16766. var propertyKeywords_ = ['align-content', 'align-items', 'align-self', 'alignment-adjust', 'alignment-baseline', 'anchor-point', 'animation', 'animation-delay', 'animation-direction', 'animation-duration', 'animation-fill-mode', 'animation-iteration-count', 'animation-name', 'animation-play-state', 'animation-timing-function', 'appearance', 'azimuth', 'backface-visibility', 'background', 'background-attachment', 'background-blend-mode', 'background-clip', 'background-color', 'background-image', 'background-origin', 'background-position', 'background-repeat', 'background-size', 'baseline-shift', 'binding', 'bleed', 'bookmark-label', 'bookmark-level', 'bookmark-state', 'bookmark-target', 'border', 'border-bottom', 'border-bottom-color', 'border-bottom-left-radius', 'border-bottom-right-radius', 'border-bottom-style', 'border-bottom-width', 'border-collapse', 'border-color', 'border-image', 'border-image-outset', 'border-image-repeat', 'border-image-slice', 'border-image-source', 'border-image-width', 'border-left', 'border-left-color', 'border-left-style', 'border-left-width', 'border-radius', 'border-right', 'border-right-color', 'border-right-style', 'border-right-width', 'border-spacing', 'border-style', 'border-top', 'border-top-color', 'border-top-left-radius', 'border-top-right-radius', 'border-top-style', 'border-top-width', 'border-width', 'bottom', 'box-decoration-break', 'box-shadow', 'box-sizing', 'break-after', 'break-before', 'break-inside', 'caption-side', 'caret-color', 'clear', 'clip', 'color', 'color-profile', 'column-count', 'column-fill', 'column-gap', 'column-rule', 'column-rule-color', 'column-rule-style', 'column-rule-width', 'column-span', 'column-width', 'columns', 'content', 'counter-increment', 'counter-reset', 'crop', 'cue', 'cue-after', 'cue-before', 'cursor', 'direction', 'display', 'dominant-baseline', 'drop-initial-after-adjust', 'drop-initial-after-align', 'drop-initial-before-adjust', 'drop-initial-before-align', 'drop-initial-size', 'drop-initial-value', 'elevation', 'empty-cells', 'fit', 'fit-position', 'flex', 'flex-basis', 'flex-direction', 'flex-flow', 'flex-grow', 'flex-shrink', 'flex-wrap', 'float', 'float-offset', 'flow-from', 'flow-into', 'font', 'font-feature-settings', 'font-family', 'font-kerning', 'font-language-override', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-synthesis', 'font-variant', 'font-variant-alternates', 'font-variant-caps', 'font-variant-east-asian', 'font-variant-ligatures', 'font-variant-numeric', 'font-variant-position', 'font-weight', 'grid', 'grid-area', 'grid-auto-columns', 'grid-auto-flow', 'grid-auto-rows', 'grid-column', 'grid-column-end', 'grid-column-gap', 'grid-column-start', 'grid-gap', 'grid-row', 'grid-row-end', 'grid-row-gap', 'grid-row-start', 'grid-template', 'grid-template-areas', 'grid-template-columns', 'grid-template-rows', 'hanging-punctuation', 'height', 'hyphens', 'icon', 'image-orientation', 'image-rendering', 'image-resolution', 'inline-box-align', 'justify-content', 'justify-items', 'justify-self', 'left', 'letter-spacing', 'line-break', 'line-height', 'line-stacking', 'line-stacking-ruby', 'line-stacking-shift', 'line-stacking-strategy', 'list-style', 'list-style-image', 'list-style-position', 'list-style-type', 'margin', 'margin-bottom', 'margin-left', 'margin-right', 'margin-top', 'marks', 'marquee-direction', 'marquee-loop', 'marquee-play-count', 'marquee-speed', 'marquee-style', 'max-height', 'max-width', 'min-height', 'min-width', 'mix-blend-mode', 'move-to', 'nav-down', 'nav-index', 'nav-left', 'nav-right', 'nav-up', 'object-fit', 'object-position', 'opacity', 'order', 'orphans', 'outline', 'outline-color', 'outline-offset', 'outline-style', 'outline-width', 'overflow', 'overflow-style', 'overflow-wrap', 'overflow-x', 'overflow-y', 'padding', 'padding-bottom', 'padding-left', 'padding-right', 'padding-top', 'page', 'page-break-after', 'page-break-before', 'page-break-inside', 'page-policy', 'pause', 'pause-after', 'pause-before', 'perspective', 'perspective-origin', 'pitch', 'pitch-range', 'place-content', 'place-items', 'place-self', 'play-during', 'position', 'presentation-level', 'punctuation-trim', 'quotes', 'region-break-after', 'region-break-before', 'region-break-inside', 'region-fragment', 'rendering-intent', 'resize', 'rest', 'rest-after', 'rest-before', 'richness', 'right', 'rotation', 'rotation-point', 'ruby-align', 'ruby-overhang', 'ruby-position', 'ruby-span', 'shape-image-threshold', 'shape-inside', 'shape-margin', 'shape-outside', 'size', 'speak', 'speak-as', 'speak-header', 'speak-numeral', 'speak-punctuation', 'speech-rate', 'stress', 'string-set', 'tab-size', 'table-layout', 'target', 'target-name', 'target-new', 'target-position', 'text-align', 'text-align-last', 'text-decoration', 'text-decoration-color', 'text-decoration-line', 'text-decoration-skip', 'text-decoration-style', 'text-emphasis', 'text-emphasis-color', 'text-emphasis-position', 'text-emphasis-style', 'text-height', 'text-indent', 'text-justify', 'text-outline', 'text-overflow', 'text-shadow', 'text-size-adjust', 'text-space-collapse', 'text-transform', 'text-underline-position', 'text-wrap', 'top', 'transform', 'transform-origin', 'transform-style', 'transition', 'transition-delay', 'transition-duration', 'transition-property', 'transition-timing-function', 'unicode-bidi', 'user-select', 'vertical-align', 'visibility', 'voice-balance', 'voice-duration', 'voice-family', 'voice-pitch', 'voice-range', 'voice-rate', 'voice-stress', 'voice-volume', 'volume', 'white-space', 'widows', 'width', 'will-change', 'word-break', 'word-spacing', 'word-wrap', 'z-index',
  16767. // SVG-specific
  16768. 'clip-path', 'clip-rule', 'mask', 'enable-background', 'filter', 'flood-color', 'flood-opacity', 'lighting-color', 'stop-color', 'stop-opacity', 'pointer-events', 'color-interpolation', 'color-interpolation-filters', 'color-rendering', 'fill', 'fill-opacity', 'fill-rule', 'image-rendering', 'marker', 'marker-end', 'marker-mid', 'marker-start', 'shape-rendering', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-rendering', 'baseline-shift', 'dominant-baseline', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'text-anchor', 'writing-mode'],
  16769. propertyKeywords = keySet(propertyKeywords_);
  16770. var nonStandardPropertyKeywords_ = ['scrollbar-arrow-color', 'scrollbar-base-color', 'scrollbar-dark-shadow-color', 'scrollbar-face-color', 'scrollbar-highlight-color', 'scrollbar-shadow-color', 'scrollbar-3d-light-color', 'scrollbar-track-color', 'shape-inside', 'searchfield-cancel-button', 'searchfield-decoration', 'searchfield-results-button', 'searchfield-results-decoration', 'zoom'],
  16771. nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
  16772. var fontProperties_ = ['font-family', 'src', 'unicode-range', 'font-variant', 'font-feature-settings', 'font-stretch', 'font-weight', 'font-style'],
  16773. fontProperties = keySet(fontProperties_);
  16774. var counterDescriptors_ = ['additive-symbols', 'fallback', 'negative', 'pad', 'prefix', 'range', 'speak-as', 'suffix', 'symbols', 'system'],
  16775. counterDescriptors = keySet(counterDescriptors_);
  16776. var colorKeywords_ = ['aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'grey', 'green', 'greenyellow', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'rebeccapurple', 'red', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray', 'snow', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen'],
  16777. colorKeywords = keySet(colorKeywords_);
  16778. var valueKeywords_ = ['above', 'absolute', 'activeborder', 'additive', 'activecaption', 'afar', 'after-white-space', 'ahead', 'alias', 'all', 'all-scroll', 'alphabetic', 'alternate', 'always', 'amharic', 'amharic-abegede', 'antialiased', 'appworkspace', 'arabic-indic', 'armenian', 'asterisks', 'attr', 'auto', 'auto-flow', 'avoid', 'avoid-column', 'avoid-page', 'avoid-region', 'background', 'backwards', 'baseline', 'below', 'bidi-override', 'binary', 'bengali', 'blink', 'block', 'block-axis', 'bold', 'bolder', 'border', 'border-box', 'both', 'bottom', 'break', 'break-all', 'break-word', 'bullets', 'button', 'button-bevel', 'buttonface', 'buttonhighlight', 'buttonshadow', 'buttontext', 'calc', 'cambodian', 'capitalize', 'caps-lock-indicator', 'caption', 'captiontext', 'caret', 'cell', 'center', 'checkbox', 'circle', 'cjk-decimal', 'cjk-earthly-branch', 'cjk-heavenly-stem', 'cjk-ideographic', 'clear', 'clip', 'close-quote', 'col-resize', 'collapse', 'color', 'color-burn', 'color-dodge', 'column', 'column-reverse', 'compact', 'condensed', 'contain', 'content', 'contents', 'content-box', 'context-menu', 'continuous', 'copy', 'counter', 'counters', 'cover', 'crop', 'cross', 'crosshair', 'currentcolor', 'cursive', 'cyclic', 'darken', 'dashed', 'decimal', 'decimal-leading-zero', 'default', 'default-button', 'dense', 'destination-atop', 'destination-in', 'destination-out', 'destination-over', 'devanagari', 'difference', 'disc', 'discard', 'disclosure-closed', 'disclosure-open', 'document', 'dot-dash', 'dot-dot-dash', 'dotted', 'double', 'down', 'e-resize', 'ease', 'ease-in', 'ease-in-out', 'ease-out', 'element', 'ellipse', 'ellipsis', 'embed', 'end', 'ethiopic', 'ethiopic-abegede', 'ethiopic-abegede-am-et', 'ethiopic-abegede-gez', 'ethiopic-abegede-ti-er', 'ethiopic-abegede-ti-et', 'ethiopic-halehame-aa-er', 'ethiopic-halehame-aa-et', 'ethiopic-halehame-am-et', 'ethiopic-halehame-gez', 'ethiopic-halehame-om-et', 'ethiopic-halehame-sid-et', 'ethiopic-halehame-so-et', 'ethiopic-halehame-ti-er', 'ethiopic-halehame-ti-et', 'ethiopic-halehame-tig', 'ethiopic-numeric', 'ew-resize', 'exclusion', 'expanded', 'extends', 'extra-condensed', 'extra-expanded', 'fantasy', 'fast', 'fill', 'fixed', 'flat', 'flex', 'flex-end', 'flex-start', 'footnotes', 'forwards', 'from', 'geometricPrecision', 'georgian', 'graytext', 'grid', 'groove', 'gujarati', 'gurmukhi', 'hand', 'hangul', 'hangul-consonant', 'hard-light', 'hebrew', 'help', 'hidden', 'hide', 'higher', 'highlight', 'highlighttext', 'hiragana', 'hiragana-iroha', 'horizontal', 'hsl', 'hsla', 'hue', 'icon', 'ignore', 'inactiveborder', 'inactivecaption', 'inactivecaptiontext', 'infinite', 'infobackground', 'infotext', 'inherit', 'initial', 'inline', 'inline-axis', 'inline-block', 'inline-flex', 'inline-grid', 'inline-table', 'inset', 'inside', 'intrinsic', 'invert', 'italic', 'japanese-formal', 'japanese-informal', 'justify', 'kannada', 'katakana', 'katakana-iroha', 'keep-all', 'khmer', 'korean-hangul-formal', 'korean-hanja-formal', 'korean-hanja-informal', 'landscape', 'lao', 'large', 'larger', 'left', 'level', 'lighter', 'lighten', 'line-through', 'linear', 'linear-gradient', 'lines', 'list-item', 'listbox', 'listitem', 'local', 'logical', 'loud', 'lower', 'lower-alpha', 'lower-armenian', 'lower-greek', 'lower-hexadecimal', 'lower-latin', 'lower-norwegian', 'lower-roman', 'lowercase', 'ltr', 'luminosity', 'malayalam', 'match', 'matrix', 'matrix3d', 'media-controls-background', 'media-current-time-display', 'media-fullscreen-button', 'media-mute-button', 'media-play-button', 'media-return-to-realtime-button', 'media-rewind-button', 'media-seek-back-button', 'media-seek-forward-button', 'media-slider', 'media-sliderthumb', 'media-time-remaining-display', 'media-volume-slider', 'media-volume-slider-container', 'media-volume-sliderthumb', 'medium', 'menu', 'menulist', 'menulist-button', 'menulist-text', 'menulist-textfield', 'menutext', 'message-box', 'middle', 'min-intrinsic', 'mix', 'mongolian', 'monospace', 'move', 'multiple', 'multiply', 'myanmar', 'n-resize', 'narrower', 'ne-resize', 'nesw-resize', 'no-close-quote', 'no-drop', 'no-open-quote', 'no-repeat', 'none', 'normal', 'not-allowed', 'nowrap', 'ns-resize', 'numbers', 'numeric', 'nw-resize', 'nwse-resize', 'oblique', 'octal', 'opacity', 'open-quote', 'optimizeLegibility', 'optimizeSpeed', 'oriya', 'oromo', 'outset', 'outside', 'outside-shape', 'overlay', 'overline', 'padding', 'padding-box', 'painted', 'page', 'paused', 'persian', 'perspective', 'plus-darker', 'plus-lighter', 'pointer', 'polygon', 'portrait', 'pre', 'pre-line', 'pre-wrap', 'preserve-3d', 'progress', 'push-button', 'radial-gradient', 'radio', 'read-only', 'read-write', 'read-write-plaintext-only', 'rectangle', 'region', 'relative', 'repeat', 'repeating-linear-gradient', 'repeating-radial-gradient', 'repeat-x', 'repeat-y', 'reset', 'reverse', 'rgb', 'rgba', 'ridge', 'right', 'rotate', 'rotate3d', 'rotateX', 'rotateY', 'rotateZ', 'round', 'row', 'row-resize', 'row-reverse', 'rtl', 'run-in', 'running', 's-resize', 'sans-serif', 'saturation', 'scale', 'scale3d', 'scaleX', 'scaleY', 'scaleZ', 'screen', 'scroll', 'scrollbar', 'scroll-position', 'se-resize', 'searchfield', 'searchfield-cancel-button', 'searchfield-decoration', 'searchfield-results-button', 'searchfield-results-decoration', 'self-start', 'self-end', 'semi-condensed', 'semi-expanded', 'separate', 'serif', 'show', 'sidama', 'simp-chinese-formal', 'simp-chinese-informal', 'single', 'skew', 'skewX', 'skewY', 'skip-white-space', 'slide', 'slider-horizontal', 'slider-vertical', 'sliderthumb-horizontal', 'sliderthumb-vertical', 'slow', 'small', 'small-caps', 'small-caption', 'smaller', 'soft-light', 'solid', 'somali', 'source-atop', 'source-in', 'source-out', 'source-over', 'space', 'space-around', 'space-between', 'space-evenly', 'spell-out', 'square', 'square-button', 'start', 'static', 'status-bar', 'stretch', 'stroke', 'sub', 'subpixel-antialiased', 'super', 'sw-resize', 'symbolic', 'symbols', 'system-ui', 'table', 'table-caption', 'table-cell', 'table-column', 'table-column-group', 'table-footer-group', 'table-header-group', 'table-row', 'table-row-group', 'tamil', 'telugu', 'text', 'text-bottom', 'text-top', 'textarea', 'textfield', 'thai', 'thick', 'thin', 'threeddarkshadow', 'threedface', 'threedhighlight', 'threedlightshadow', 'threedshadow', 'tibetan', 'tigre', 'tigrinya-er', 'tigrinya-er-abegede', 'tigrinya-et', 'tigrinya-et-abegede', 'to', 'top', 'trad-chinese-formal', 'trad-chinese-informal', 'transform', 'translate', 'translate3d', 'translateX', 'translateY', 'translateZ', 'transparent', 'ultra-condensed', 'ultra-expanded', 'underline', 'unset', 'up', 'upper-alpha', 'upper-armenian', 'upper-greek', 'upper-hexadecimal', 'upper-latin', 'upper-norwegian', 'upper-roman', 'uppercase', 'urdu', 'url', 'var', 'vertical', 'vertical-text', 'visible', 'visibleFill', 'visiblePainted', 'visibleStroke', 'visual', 'w-resize', 'wait', 'wave', 'wider', 'window', 'windowframe', 'windowtext', 'words', 'wrap', 'wrap-reverse', 'x-large', 'x-small', 'xor', 'xx-large', 'xx-small'],
  16779. valueKeywords = keySet(valueKeywords_);
  16780. var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_).concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_).concat(valueKeywords_);
  16781. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].registerHelper('hintWords', 'css', allWords);
  16782. function tokenCComment(stream, state) {
  16783. var maybeEnd = false,
  16784. ch;
  16785. while ((ch = stream.next()) != null) {
  16786. if (maybeEnd && ch == '/') {
  16787. state.tokenize = null;
  16788. break;
  16789. }
  16790. maybeEnd = ch == '*';
  16791. }
  16792. return ['comment', 'comment'];
  16793. }
  16794. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('text/css', {
  16795. documentTypes: documentTypes,
  16796. mediaTypes: mediaTypes,
  16797. mediaFeatures: mediaFeatures,
  16798. mediaValueKeywords: mediaValueKeywords,
  16799. propertyKeywords: propertyKeywords,
  16800. nonStandardPropertyKeywords: nonStandardPropertyKeywords,
  16801. fontProperties: fontProperties,
  16802. counterDescriptors: counterDescriptors,
  16803. colorKeywords: colorKeywords,
  16804. valueKeywords: valueKeywords,
  16805. tokenHooks: {
  16806. '/': function _(stream, state) {
  16807. if (!stream.eat('*')) {
  16808. return false;
  16809. }
  16810. state.tokenize = tokenCComment;
  16811. return tokenCComment(stream, state);
  16812. }
  16813. },
  16814. name: 'css'
  16815. });
  16816. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('text/x-scss', {
  16817. mediaTypes: mediaTypes,
  16818. mediaFeatures: mediaFeatures,
  16819. mediaValueKeywords: mediaValueKeywords,
  16820. propertyKeywords: propertyKeywords,
  16821. nonStandardPropertyKeywords: nonStandardPropertyKeywords,
  16822. colorKeywords: colorKeywords,
  16823. valueKeywords: valueKeywords,
  16824. fontProperties: fontProperties,
  16825. allowNested: true,
  16826. lineComment: '//',
  16827. tokenHooks: {
  16828. '/': function _(stream, state) {
  16829. if (stream.eat('/')) {
  16830. stream.skipToEnd();
  16831. return ['comment', 'comment'];
  16832. } else if (stream.eat('*')) {
  16833. state.tokenize = tokenCComment;
  16834. return tokenCComment(stream, state);
  16835. } else {
  16836. return ['operator', 'operator'];
  16837. }
  16838. },
  16839. ':': function _(stream) {
  16840. if (stream.match(/\s*\{/, false)) {
  16841. return [null, null];
  16842. }
  16843. return false;
  16844. },
  16845. $: function $(stream) {
  16846. stream.match(/^[\w-]+/);
  16847. if (stream.match(/^\s*:/, false)) {
  16848. return ['variable-2', 'variable-definition'];
  16849. }
  16850. return ['variable-2', 'variable'];
  16851. },
  16852. '#': function _(stream) {
  16853. if (!stream.eat('{')) {
  16854. return false;
  16855. }
  16856. return [null, 'interpolation'];
  16857. }
  16858. },
  16859. name: 'css',
  16860. helperType: 'scss'
  16861. });
  16862. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('text/x-less', {
  16863. mediaTypes: mediaTypes,
  16864. mediaFeatures: mediaFeatures,
  16865. mediaValueKeywords: mediaValueKeywords,
  16866. propertyKeywords: propertyKeywords,
  16867. nonStandardPropertyKeywords: nonStandardPropertyKeywords,
  16868. colorKeywords: colorKeywords,
  16869. valueKeywords: valueKeywords,
  16870. fontProperties: fontProperties,
  16871. allowNested: true,
  16872. lineComment: '//',
  16873. tokenHooks: {
  16874. '/': function _(stream, state) {
  16875. if (stream.eat('/')) {
  16876. stream.skipToEnd();
  16877. return ['comment', 'comment'];
  16878. } else if (stream.eat('*')) {
  16879. state.tokenize = tokenCComment;
  16880. return tokenCComment(stream, state);
  16881. } else {
  16882. return ['operator', 'operator'];
  16883. }
  16884. },
  16885. '@': function _(stream) {
  16886. if (stream.eat('{')) {
  16887. return [null, 'interpolation'];
  16888. }
  16889. if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i, false)) {
  16890. return false;
  16891. }
  16892. stream.eatWhile(/[\w\\\-]/);
  16893. if (stream.match(/^\s*:/, false)) {
  16894. return ['variable-2', 'variable-definition'];
  16895. }
  16896. return ['variable-2', 'variable'];
  16897. },
  16898. '&': function _() {
  16899. return ['atom', 'atom'];
  16900. }
  16901. },
  16902. name: 'css',
  16903. helperType: 'less'
  16904. });
  16905. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('text/x-gss', {
  16906. documentTypes: documentTypes,
  16907. mediaTypes: mediaTypes,
  16908. mediaFeatures: mediaFeatures,
  16909. propertyKeywords: propertyKeywords,
  16910. nonStandardPropertyKeywords: nonStandardPropertyKeywords,
  16911. fontProperties: fontProperties,
  16912. counterDescriptors: counterDescriptors,
  16913. colorKeywords: colorKeywords,
  16914. valueKeywords: valueKeywords,
  16915. supportsAtComponent: true,
  16916. tokenHooks: {
  16917. '/': function _(stream, state) {
  16918. if (!stream.eat('*')) {
  16919. return false;
  16920. }
  16921. state.tokenize = tokenCComment;
  16922. return tokenCComment(stream, state);
  16923. }
  16924. },
  16925. name: 'css',
  16926. helperType: 'gss'
  16927. });
  16928. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('less', 'css');
  16929. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('scss', 'css');
  16930. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('sass', 'css');
  16931. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('style', 'css');
  16932. /***/ }),
  16933. /***/ 876:
  16934. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16935. "use strict";
  16936. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__(321);
  16937. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  16938. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMode('javascript', defineJSMode);
  16939. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMode('js', defineJSMode);
  16940. function defineJSMode(config, parserConfig) {
  16941. var indentUnit = config.indentUnit;
  16942. var statementIndent = parserConfig.statementIndent;
  16943. var jsonldMode = parserConfig.jsonld;
  16944. var jsonMode = parserConfig.json || jsonldMode;
  16945. var isTS = parserConfig.typescript;
  16946. var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
  16947. // Tokenizer
  16948. var keywords = function () {
  16949. function kw(type) {
  16950. return { type: type, style: 'keyword' };
  16951. }
  16952. var A = kw('keyword a'),
  16953. B = kw('keyword b'),
  16954. C = kw('keyword c'),
  16955. D = kw('keyword d');
  16956. var operator = kw('operator'),
  16957. atom = { type: 'atom', style: 'atom' };
  16958. return {
  16959. if: kw('if'),
  16960. while: A,
  16961. with: A,
  16962. else: B,
  16963. do: B,
  16964. try: B,
  16965. finally: B,
  16966. return: D,
  16967. break: D,
  16968. continue: D,
  16969. new: kw('new'),
  16970. delete: C,
  16971. void: C,
  16972. throw: C,
  16973. debugger: kw('debugger'),
  16974. var: kw('var'),
  16975. const: kw('var'),
  16976. let: kw('var'),
  16977. function: kw('function'),
  16978. catch: kw('catch'),
  16979. for: kw('for'),
  16980. switch: kw('switch'),
  16981. case: kw('case'),
  16982. default: kw('default'),
  16983. in: operator,
  16984. typeof: operator,
  16985. instanceof: operator,
  16986. true: atom,
  16987. false: atom,
  16988. null: atom,
  16989. undefined: atom,
  16990. NaN: atom,
  16991. Infinity: atom,
  16992. this: kw('this'),
  16993. class: kw('class'),
  16994. super: kw('atom'),
  16995. yield: C,
  16996. export: kw('export'),
  16997. import: kw('import'),
  16998. extends: C,
  16999. await: C
  17000. };
  17001. }();
  17002. var isOperatorChar = /[+\-*&%=<>!?|~^@]/;
  17003. var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
  17004. function readRegexp(stream) {
  17005. var escaped = false,
  17006. next,
  17007. inSet = false;
  17008. while ((next = stream.next()) != null) {
  17009. if (!escaped) {
  17010. if (next == '/' && !inSet) {
  17011. return;
  17012. }
  17013. if (next == '[') {
  17014. inSet = true;
  17015. } else if (inSet && next == ']') {
  17016. inSet = false;
  17017. }
  17018. }
  17019. escaped = !escaped && next == '\\';
  17020. }
  17021. }
  17022. // Used as scratch variables to communicate multiple values without
  17023. // consing up tons of objects.
  17024. var type, content;
  17025. function ret(tp, style, cont) {
  17026. type = tp;
  17027. content = cont;
  17028. return style;
  17029. }
  17030. function tokenBase(stream, state) {
  17031. var ch = stream.next();
  17032. if (ch == '"' || ch == '\'') {
  17033. state.tokenize = tokenString(ch);
  17034. return state.tokenize(stream, state);
  17035. } else if (ch == '.' && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) {
  17036. return ret('number', 'number');
  17037. } else if (ch == '.' && stream.match('..')) {
  17038. return ret('spread', 'meta');
  17039. } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
  17040. return ret(ch);
  17041. } else if (ch == '=' && stream.eat('>')) {
  17042. return ret('=>', 'operator');
  17043. } else if (ch == '0' && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) {
  17044. return ret('number', 'number');
  17045. } else if (/\d/.test(ch)) {
  17046. stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/);
  17047. return ret('number', 'number');
  17048. } else if (ch == '/') {
  17049. if (stream.eat('*')) {
  17050. state.tokenize = tokenComment;
  17051. return tokenComment(stream, state);
  17052. } else if (stream.eat('/')) {
  17053. stream.skipToEnd();
  17054. return ret('comment', 'comment');
  17055. } else if (expressionAllowed(stream, state, 1)) {
  17056. readRegexp(stream);
  17057. stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/);
  17058. return ret('regexp', 'string-2');
  17059. } else {
  17060. stream.eat('=');
  17061. return ret('operator', 'operator', stream.current());
  17062. }
  17063. } else if (ch == '`') {
  17064. state.tokenize = tokenQuasi;
  17065. return tokenQuasi(stream, state);
  17066. } else if (ch == '#') {
  17067. stream.skipToEnd();
  17068. return ret('error', 'error');
  17069. } else if (ch == '<' && stream.match('!--') || ch == '-' && stream.match('->')) {
  17070. stream.skipToEnd();
  17071. return ret('comment', 'comment');
  17072. } else if (isOperatorChar.test(ch)) {
  17073. if (ch != '>' || !state.lexical || state.lexical.type != '>') {
  17074. if (stream.eat('=')) {
  17075. if (ch == '!' || ch == '=') {
  17076. stream.eat('=');
  17077. }
  17078. } else if (/[<>*+\-]/.test(ch)) {
  17079. stream.eat(ch);
  17080. if (ch == '>') {
  17081. stream.eat(ch);
  17082. }
  17083. }
  17084. }
  17085. return ret('operator', 'operator', stream.current());
  17086. } else if (wordRE.test(ch)) {
  17087. stream.eatWhile(wordRE);
  17088. var word = stream.current();
  17089. if (state.lastType != '.') {
  17090. if (keywords.propertyIsEnumerable(word)) {
  17091. var kw = keywords[word];
  17092. return ret(kw.type, kw.style, word);
  17093. }
  17094. if (word == 'async' && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false)) {
  17095. return ret('async', 'keyword', word);
  17096. }
  17097. }
  17098. return ret('variable', 'variable', word);
  17099. }
  17100. }
  17101. function tokenString(quote) {
  17102. return function (stream, state) {
  17103. var escaped = false,
  17104. next;
  17105. if (jsonldMode && stream.peek() == '@' && stream.match(isJsonldKeyword)) {
  17106. state.tokenize = tokenBase;
  17107. return ret('jsonld-keyword', 'meta');
  17108. }
  17109. while ((next = stream.next()) != null) {
  17110. if (next == quote && !escaped) {
  17111. break;
  17112. }
  17113. escaped = !escaped && next == '\\';
  17114. }
  17115. if (!escaped) {
  17116. state.tokenize = tokenBase;
  17117. }
  17118. return ret('string', 'string');
  17119. };
  17120. }
  17121. function tokenComment(stream, state) {
  17122. var maybeEnd = false,
  17123. ch;
  17124. while (ch = stream.next()) {
  17125. if (ch == '/' && maybeEnd) {
  17126. state.tokenize = tokenBase;
  17127. break;
  17128. }
  17129. maybeEnd = ch == '*';
  17130. }
  17131. return ret('comment', 'comment');
  17132. }
  17133. function tokenQuasi(stream, state) {
  17134. var escaped = false,
  17135. next;
  17136. while ((next = stream.next()) != null) {
  17137. if (!escaped && (next == '`' || next == '$' && stream.eat('{'))) {
  17138. state.tokenize = tokenBase;
  17139. break;
  17140. }
  17141. escaped = !escaped && next == '\\';
  17142. }
  17143. return ret('quasi', 'string-2', stream.current());
  17144. }
  17145. var brackets = '([{}])';
  17146. // This is a crude lookahead trick to try and notice that we're
  17147. // parsing the argument patterns for a fat-arrow function before we
  17148. // actually hit the arrow token. It only works if the arrow is on
  17149. // the same line as the arguments and there's no strange noise
  17150. // (comments) in between. Fallback is to only notice when we hit the
  17151. // arrow, and not declare the arguments as locals for the arrow
  17152. // body.
  17153. function findFatArrow(stream, state) {
  17154. if (state.fatArrowAt) {
  17155. state.fatArrowAt = null;
  17156. }
  17157. var arrow = stream.string.indexOf('=>', stream.start);
  17158. if (arrow < 0) {
  17159. return;
  17160. }
  17161. if (isTS) {
  17162. // Try to skip TypeScript return type declarations after the arguments
  17163. var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow));
  17164. if (m) {
  17165. arrow = m.index;
  17166. }
  17167. }
  17168. var depth = 0,
  17169. sawSomething = false;
  17170. for (var pos = arrow - 1; pos >= 0; --pos) {
  17171. var ch = stream.string.charAt(pos);
  17172. var bracket = brackets.indexOf(ch);
  17173. if (bracket >= 0 && bracket < 3) {
  17174. if (!depth) {
  17175. ++pos;
  17176. break;
  17177. }
  17178. if (--depth == 0) {
  17179. if (ch == '(') {
  17180. sawSomething = true;
  17181. }
  17182. break;
  17183. }
  17184. } else if (bracket >= 3 && bracket < 6) {
  17185. ++depth;
  17186. } else if (wordRE.test(ch)) {
  17187. sawSomething = true;
  17188. } else if (/["'\/`]/.test(ch)) {
  17189. for (;; --pos) {
  17190. if (pos == 0) {
  17191. return;
  17192. }
  17193. var next = stream.string.charAt(pos - 1);
  17194. if (next == ch && stream.string.charAt(pos - 2) != '\\') {
  17195. pos--;
  17196. break;
  17197. }
  17198. }
  17199. } else if (sawSomething && !depth) {
  17200. ++pos;
  17201. break;
  17202. }
  17203. }
  17204. if (sawSomething && !depth) {
  17205. state.fatArrowAt = pos;
  17206. }
  17207. }
  17208. // Parser
  17209. var atomicTypes = {
  17210. atom: true,
  17211. number: true,
  17212. variable: true,
  17213. string: true,
  17214. regexp: true,
  17215. this: true,
  17216. 'jsonld-keyword': true
  17217. };
  17218. function JSLexical(indented, column, type, align, prev, info) {
  17219. this.indented = indented;
  17220. this.column = column;
  17221. this.type = type;
  17222. this.prev = prev;
  17223. this.info = info;
  17224. if (align != null) {
  17225. this.align = align;
  17226. }
  17227. }
  17228. function inScope(state, varname) {
  17229. for (var v = state.localVars; v; v = v.next) {
  17230. if (v.name == varname) {
  17231. return true;
  17232. }
  17233. }
  17234. for (var cx = state.context; cx; cx = cx.prev) {
  17235. for (var v = cx.vars; v; v = v.next) {
  17236. if (v.name == varname) {
  17237. return true;
  17238. }
  17239. }
  17240. }
  17241. }
  17242. function parseJS(state, style, type, content, stream) {
  17243. var cc = state.cc;
  17244. // Communicate our context to the combinators.
  17245. // (Less wasteful than consing up a hundred closures on every call.)
  17246. cx.state = state;
  17247. cx.stream = stream;
  17248. cx.marked = null, cx.cc = cc;
  17249. cx.style = style;
  17250. if (!state.lexical.hasOwnProperty('align')) {
  17251. state.lexical.align = true;
  17252. }
  17253. while (true) {
  17254. var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
  17255. if (combinator(type, content)) {
  17256. while (cc.length && cc[cc.length - 1].lex) {
  17257. cc.pop()();
  17258. }
  17259. if (cx.marked) {
  17260. return cx.marked;
  17261. }
  17262. if (type == 'variable' && inScope(state, content)) {
  17263. return 'variable-2';
  17264. }
  17265. return style;
  17266. }
  17267. }
  17268. }
  17269. // Combinator utils
  17270. var cx = { state: null, column: null, marked: null, cc: null };
  17271. function pass() {
  17272. for (var i = arguments.length - 1; i >= 0; i--) {
  17273. cx.cc.push(arguments[i]);
  17274. }
  17275. }
  17276. function cont() {
  17277. pass.apply(null, arguments);
  17278. return true;
  17279. }
  17280. function inList(name, list) {
  17281. for (var v = list; v; v = v.next) {
  17282. if (v.name == name) {
  17283. return true;
  17284. }
  17285. }
  17286. return false;
  17287. }
  17288. function register(varname) {
  17289. var state = cx.state;
  17290. cx.marked = 'def';
  17291. if (state.context) {
  17292. if (state.lexical.info == 'var' && state.context && state.context.block) {
  17293. // FIXME function decls are also not block scoped
  17294. var newContext = registerVarScoped(varname, state.context);
  17295. if (newContext != null) {
  17296. state.context = newContext;
  17297. return;
  17298. }
  17299. } else if (!inList(varname, state.localVars)) {
  17300. state.localVars = new Var(varname, state.localVars);
  17301. return;
  17302. }
  17303. }
  17304. // Fall through means this is global
  17305. if (parserConfig.globalVars && !inList(varname, state.globalVars)) {
  17306. state.globalVars = new Var(varname, state.globalVars);
  17307. }
  17308. }
  17309. function registerVarScoped(varname, context) {
  17310. if (!context) {
  17311. return null;
  17312. } else if (context.block) {
  17313. var inner = registerVarScoped(varname, context.prev);
  17314. if (!inner) {
  17315. return null;
  17316. }
  17317. if (inner == context.prev) {
  17318. return context;
  17319. }
  17320. return new Context(inner, context.vars, true);
  17321. } else if (inList(varname, context.vars)) {
  17322. return context;
  17323. } else {
  17324. return new Context(context.prev, new Var(varname, context.vars), false);
  17325. }
  17326. }
  17327. function isModifier(name) {
  17328. return name == 'public' || name == 'private' || name == 'protected' || name == 'abstract' || name == 'readonly';
  17329. }
  17330. // Combinators
  17331. function Context(prev, vars, block) {
  17332. this.prev = prev;
  17333. this.vars = vars;
  17334. this.block = block;
  17335. }
  17336. function Var(name, next) {
  17337. this.name = name;
  17338. this.next = next;
  17339. }
  17340. var defaultVars = new Var('this', new Var('arguments', null));
  17341. function pushcontext() {
  17342. cx.state.context = new Context(cx.state.context, cx.state.localVars, false);
  17343. cx.state.localVars = defaultVars;
  17344. }
  17345. function pushblockcontext() {
  17346. cx.state.context = new Context(cx.state.context, cx.state.localVars, true);
  17347. cx.state.localVars = null;
  17348. }
  17349. function popcontext() {
  17350. cx.state.localVars = cx.state.context.vars;
  17351. cx.state.context = cx.state.context.prev;
  17352. }
  17353. popcontext.lex = true;
  17354. function pushlex(type, info) {
  17355. var result = function result() {
  17356. var state = cx.state,
  17357. indent = state.indented;
  17358. if (state.lexical.type == 'stat') {
  17359. indent = state.lexical.indented;
  17360. } else {
  17361. for (var outer = state.lexical; outer && outer.type == ')' && outer.align; outer = outer.prev) {
  17362. indent = outer.indented;
  17363. }
  17364. }
  17365. state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
  17366. };
  17367. result.lex = true;
  17368. return result;
  17369. }
  17370. function poplex() {
  17371. var state = cx.state;
  17372. if (state.lexical.prev) {
  17373. if (state.lexical.type == ')') {
  17374. state.indented = state.lexical.indented;
  17375. }
  17376. state.lexical = state.lexical.prev;
  17377. }
  17378. }
  17379. poplex.lex = true;
  17380. function expect(wanted) {
  17381. function exp(type) {
  17382. if (type == wanted) {
  17383. return cont();
  17384. } else if (wanted == ';' || type == '}' || type == ')' || type == ']') {
  17385. return pass();
  17386. } else {
  17387. return cont(exp);
  17388. }
  17389. }
  17390. return exp;
  17391. }
  17392. function statement(type, value) {
  17393. if (type == 'var') {
  17394. return cont(pushlex('vardef', value), vardef, expect(';'), poplex);
  17395. }
  17396. if (type == 'keyword a') {
  17397. return cont(pushlex('form'), parenExpr, statement, poplex);
  17398. }
  17399. if (type == 'keyword b') {
  17400. return cont(pushlex('form'), statement, poplex);
  17401. }
  17402. if (type == 'keyword d') {
  17403. return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex('stat'), maybeexpression, expect(';'), poplex);
  17404. }
  17405. if (type == 'debugger') {
  17406. return cont(expect(';'));
  17407. }
  17408. if (type == '{') {
  17409. return cont(pushlex('}'), pushblockcontext, block, poplex, popcontext);
  17410. }
  17411. if (type == ';') {
  17412. return cont();
  17413. }
  17414. if (type == 'if') {
  17415. if (cx.state.lexical.info == 'else' && cx.state.cc[cx.state.cc.length - 1] == poplex) {
  17416. cx.state.cc.pop()();
  17417. }
  17418. return cont(pushlex('form'), parenExpr, statement, poplex, maybeelse);
  17419. }
  17420. if (type == 'function') {
  17421. return cont(functiondef);
  17422. }
  17423. if (type == 'for') {
  17424. return cont(pushlex('form'), forspec, statement, poplex);
  17425. }
  17426. if (type == 'class' || isTS && value == 'interface') {
  17427. cx.marked = 'keyword';
  17428. return cont(pushlex('form', type == 'class' ? type : value), className, poplex);
  17429. }
  17430. if (type == 'variable') {
  17431. if (isTS && value == 'declare') {
  17432. cx.marked = 'keyword';
  17433. return cont(statement);
  17434. } else if (isTS && (value == 'module' || value == 'enum' || value == 'type') && cx.stream.match(/^\s*\w/, false)) {
  17435. cx.marked = 'keyword';
  17436. if (value == 'enum') {
  17437. return cont(enumdef);
  17438. } else if (value == 'type') {
  17439. return cont(typename, expect('operator'), typeexpr, expect(';'));
  17440. } else {
  17441. return cont(pushlex('form'), pattern, expect('{'), pushlex('}'), block, poplex, poplex);
  17442. }
  17443. } else if (isTS && value == 'namespace') {
  17444. cx.marked = 'keyword';
  17445. return cont(pushlex('form'), expression, statement, poplex);
  17446. } else if (isTS && value == 'abstract') {
  17447. cx.marked = 'keyword';
  17448. return cont(statement);
  17449. } else {
  17450. return cont(pushlex('stat'), maybelabel);
  17451. }
  17452. }
  17453. if (type == 'switch') {
  17454. return cont(pushlex('form'), parenExpr, expect('{'), pushlex('}', 'switch'), pushblockcontext, block, poplex, poplex, popcontext);
  17455. }
  17456. if (type == 'case') {
  17457. return cont(expression, expect(':'));
  17458. }
  17459. if (type == 'default') {
  17460. return cont(expect(':'));
  17461. }
  17462. if (type == 'catch') {
  17463. return cont(pushlex('form'), pushcontext, maybeCatchBinding, statement, poplex, popcontext);
  17464. }
  17465. if (type == 'export') {
  17466. return cont(pushlex('stat'), afterExport, poplex);
  17467. }
  17468. if (type == 'import') {
  17469. return cont(pushlex('stat'), afterImport, poplex);
  17470. }
  17471. if (type == 'async') {
  17472. return cont(statement);
  17473. }
  17474. if (value == '@') {
  17475. return cont(expression, statement);
  17476. }
  17477. return pass(pushlex('stat'), expression, expect(';'), poplex);
  17478. }
  17479. function maybeCatchBinding(type) {
  17480. if (type == '(') {
  17481. return cont(funarg, expect(')'));
  17482. }
  17483. }
  17484. function expression(type, value) {
  17485. return expressionInner(type, value, false);
  17486. }
  17487. function expressionNoComma(type, value) {
  17488. return expressionInner(type, value, true);
  17489. }
  17490. function parenExpr(type) {
  17491. if (type != '(') {
  17492. return pass();
  17493. }
  17494. return cont(pushlex(')'), expression, expect(')'), poplex);
  17495. }
  17496. function expressionInner(type, value, noComma) {
  17497. if (cx.state.fatArrowAt == cx.stream.start) {
  17498. var body = noComma ? arrowBodyNoComma : arrowBody;
  17499. if (type == '(') {
  17500. return cont(pushcontext, pushlex(')'), commasep(funarg, ')'), poplex, expect('=>'), body, popcontext);
  17501. } else if (type == 'variable') {
  17502. return pass(pushcontext, pattern, expect('=>'), body, popcontext);
  17503. }
  17504. }
  17505. var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
  17506. if (atomicTypes.hasOwnProperty(type)) {
  17507. return cont(maybeop);
  17508. }
  17509. if (type == 'function') {
  17510. return cont(functiondef, maybeop);
  17511. }
  17512. if (type == 'class' || isTS && value == 'interface') {
  17513. cx.marked = 'keyword';
  17514. return cont(pushlex('form'), classExpression, poplex);
  17515. }
  17516. if (type == 'keyword c' || type == 'async') {
  17517. return cont(noComma ? expressionNoComma : expression);
  17518. }
  17519. if (type == '(') {
  17520. return cont(pushlex(')'), maybeexpression, expect(')'), poplex, maybeop);
  17521. }
  17522. if (type == 'operator' || type == 'spread') {
  17523. return cont(noComma ? expressionNoComma : expression);
  17524. }
  17525. if (type == '[') {
  17526. return cont(pushlex(']'), arrayLiteral, poplex, maybeop);
  17527. }
  17528. if (type == '{') {
  17529. return contCommasep(objprop, '}', null, maybeop);
  17530. }
  17531. if (type == 'quasi') {
  17532. return pass(quasi, maybeop);
  17533. }
  17534. if (type == 'new') {
  17535. return cont(maybeTarget(noComma));
  17536. }
  17537. if (type == 'import') {
  17538. return cont(expression);
  17539. }
  17540. return cont();
  17541. }
  17542. function maybeexpression(type) {
  17543. if (type.match(/[;\}\)\],]/)) {
  17544. return pass();
  17545. }
  17546. return pass(expression);
  17547. }
  17548. function maybeoperatorComma(type, value) {
  17549. if (type == ',') {
  17550. return cont(expression);
  17551. }
  17552. return maybeoperatorNoComma(type, value, false);
  17553. }
  17554. function maybeoperatorNoComma(type, value, noComma) {
  17555. var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
  17556. var expr = noComma == false ? expression : expressionNoComma;
  17557. if (type == '=>') {
  17558. return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
  17559. }
  17560. if (type == 'operator') {
  17561. if (/\+\+|--/.test(value) || isTS && value == '!') {
  17562. return cont(me);
  17563. }
  17564. if (isTS && value == '<' && cx.stream.match(/^([^>]|<.*?>)*>\s*\(/, false)) {
  17565. return cont(pushlex('>'), commasep(typeexpr, '>'), poplex, me);
  17566. }
  17567. if (value == '?') {
  17568. return cont(expression, expect(':'), expr);
  17569. }
  17570. return cont(expr);
  17571. }
  17572. if (type == 'quasi') {
  17573. return pass(quasi, me);
  17574. }
  17575. if (type == ';') {
  17576. return;
  17577. }
  17578. if (type == '(') {
  17579. return contCommasep(expressionNoComma, ')', 'call', me);
  17580. }
  17581. if (type == '.') {
  17582. return cont(property, me);
  17583. }
  17584. if (type == '[') {
  17585. return cont(pushlex(']'), maybeexpression, expect(']'), poplex, me);
  17586. }
  17587. if (isTS && value == 'as') {
  17588. cx.marked = 'keyword';
  17589. return cont(typeexpr, me);
  17590. }
  17591. if (type == 'regexp') {
  17592. cx.state.lastType = cx.marked = 'operator';
  17593. cx.stream.backUp(cx.stream.pos - cx.stream.start - 1);
  17594. return cont(expr);
  17595. }
  17596. }
  17597. function quasi(type, value) {
  17598. if (type != 'quasi') {
  17599. return pass();
  17600. }
  17601. if (value.slice(value.length - 2) != '${') {
  17602. return cont(quasi);
  17603. }
  17604. return cont(expression, continueQuasi);
  17605. }
  17606. function continueQuasi(type) {
  17607. if (type == '}') {
  17608. cx.marked = 'string-2';
  17609. cx.state.tokenize = tokenQuasi;
  17610. return cont(quasi);
  17611. }
  17612. }
  17613. function arrowBody(type) {
  17614. findFatArrow(cx.stream, cx.state);
  17615. return pass(type == '{' ? statement : expression);
  17616. }
  17617. function arrowBodyNoComma(type) {
  17618. findFatArrow(cx.stream, cx.state);
  17619. return pass(type == '{' ? statement : expressionNoComma);
  17620. }
  17621. function maybeTarget(noComma) {
  17622. return function (type) {
  17623. if (type == '.') {
  17624. return cont(noComma ? targetNoComma : target);
  17625. } else if (type == 'variable' && isTS) {
  17626. return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma);
  17627. } else {
  17628. return pass(noComma ? expressionNoComma : expression);
  17629. }
  17630. };
  17631. }
  17632. function target(_, value) {
  17633. if (value == 'target') {
  17634. cx.marked = 'keyword';
  17635. return cont(maybeoperatorComma);
  17636. }
  17637. }
  17638. function targetNoComma(_, value) {
  17639. if (value == 'target') {
  17640. cx.marked = 'keyword';
  17641. return cont(maybeoperatorNoComma);
  17642. }
  17643. }
  17644. function maybelabel(type) {
  17645. if (type == ':') {
  17646. return cont(poplex, statement);
  17647. }
  17648. return pass(maybeoperatorComma, expect(';'), poplex);
  17649. }
  17650. function property(type) {
  17651. if (type == 'variable') {
  17652. cx.marked = 'property';
  17653. return cont();
  17654. }
  17655. }
  17656. function objprop(type, value) {
  17657. if (type == 'async') {
  17658. cx.marked = 'property';
  17659. return cont(objprop);
  17660. } else if (type == 'variable' || cx.style == 'keyword') {
  17661. cx.marked = 'property';
  17662. if (value == 'get' || value == 'set') {
  17663. return cont(getterSetter);
  17664. }
  17665. var m; // Work around fat-arrow-detection complication for detecting typescript typed arrow params
  17666. if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false))) {
  17667. cx.state.fatArrowAt = cx.stream.pos + m[0].length;
  17668. }
  17669. return cont(afterprop);
  17670. } else if (type == 'number' || type == 'string') {
  17671. cx.marked = jsonldMode ? 'property' : cx.style + ' property';
  17672. return cont(afterprop);
  17673. } else if (type == 'jsonld-keyword') {
  17674. return cont(afterprop);
  17675. } else if (isTS && isModifier(value)) {
  17676. cx.marked = 'keyword';
  17677. return cont(objprop);
  17678. } else if (type == '[') {
  17679. return cont(expression, maybetype, expect(']'), afterprop);
  17680. } else if (type == 'spread') {
  17681. return cont(expressionNoComma, afterprop);
  17682. } else if (value == '*') {
  17683. cx.marked = 'keyword';
  17684. return cont(objprop);
  17685. } else if (type == ':') {
  17686. return pass(afterprop);
  17687. }
  17688. }
  17689. function getterSetter(type) {
  17690. if (type != 'variable') {
  17691. return pass(afterprop);
  17692. }
  17693. cx.marked = 'property';
  17694. return cont(functiondef);
  17695. }
  17696. function afterprop(type) {
  17697. if (type == ':') {
  17698. return cont(expressionNoComma);
  17699. }
  17700. if (type == '(') {
  17701. return pass(functiondef);
  17702. }
  17703. }
  17704. function commasep(what, end, sep) {
  17705. function proceed(type, value) {
  17706. if (sep ? sep.indexOf(type) > -1 : type == ',') {
  17707. var lex = cx.state.lexical;
  17708. if (lex.info == 'call') {
  17709. lex.pos = (lex.pos || 0) + 1;
  17710. }
  17711. return cont(function (type, value) {
  17712. if (type == end || value == end) {
  17713. return pass();
  17714. }
  17715. return pass(what);
  17716. }, proceed);
  17717. }
  17718. if (type == end || value == end) {
  17719. return cont();
  17720. }
  17721. if (sep && sep.indexOf(';') > -1) {
  17722. return pass(what);
  17723. }
  17724. return cont(expect(end));
  17725. }
  17726. return function (type, value) {
  17727. if (type == end || value == end) {
  17728. return cont();
  17729. }
  17730. return pass(what, proceed);
  17731. };
  17732. }
  17733. function contCommasep(what, end, info) {
  17734. for (var i = 3; i < arguments.length; i++) {
  17735. cx.cc.push(arguments[i]);
  17736. }
  17737. return cont(pushlex(end, info), commasep(what, end), poplex);
  17738. }
  17739. function block(type) {
  17740. if (type == '}') {
  17741. return cont();
  17742. }
  17743. return pass(statement, block);
  17744. }
  17745. function maybetype(type, value) {
  17746. if (isTS) {
  17747. if (type == ':') {
  17748. return cont(typeexpr);
  17749. }
  17750. if (value == '?') {
  17751. return cont(maybetype);
  17752. }
  17753. }
  17754. }
  17755. function maybetypeOrIn(type, value) {
  17756. if (isTS && (type == ':' || value == 'in')) {
  17757. return cont(typeexpr);
  17758. }
  17759. }
  17760. function mayberettype(type) {
  17761. if (isTS && type == ':') {
  17762. if (cx.stream.match(/^\s*\w+\s+is\b/, false)) {
  17763. return cont(expression, isKW, typeexpr);
  17764. } else {
  17765. return cont(typeexpr);
  17766. }
  17767. }
  17768. }
  17769. function isKW(_, value) {
  17770. if (value == 'is') {
  17771. cx.marked = 'keyword';
  17772. return cont();
  17773. }
  17774. }
  17775. function typeexpr(type, value) {
  17776. if (value == 'keyof' || value == 'typeof' || value == 'infer') {
  17777. cx.marked = 'keyword';
  17778. return cont(value == 'typeof' ? expressionNoComma : typeexpr);
  17779. }
  17780. if (type == 'variable' || value == 'void') {
  17781. cx.marked = 'type';
  17782. return cont(afterType);
  17783. }
  17784. if (value == '|' || value == '&') {
  17785. return cont(typeexpr);
  17786. }
  17787. if (type == 'string' || type == 'number' || type == 'atom') {
  17788. return cont(afterType);
  17789. }
  17790. if (type == '[') {
  17791. return cont(pushlex(']'), commasep(typeexpr, ']', ','), poplex, afterType);
  17792. }
  17793. if (type == '{') {
  17794. return cont(pushlex('}'), commasep(typeprop, '}', ',;'), poplex, afterType);
  17795. }
  17796. if (type == '(') {
  17797. return cont(commasep(typearg, ')'), maybeReturnType, afterType);
  17798. }
  17799. if (type == '<') {
  17800. return cont(commasep(typeexpr, '>'), typeexpr);
  17801. }
  17802. }
  17803. function maybeReturnType(type) {
  17804. if (type == '=>') {
  17805. return cont(typeexpr);
  17806. }
  17807. }
  17808. function typeprop(type, value) {
  17809. if (type == 'variable' || cx.style == 'keyword') {
  17810. cx.marked = 'property';
  17811. return cont(typeprop);
  17812. } else if (value == '?' || type == 'number' || type == 'string') {
  17813. return cont(typeprop);
  17814. } else if (type == ':') {
  17815. return cont(typeexpr);
  17816. } else if (type == '[') {
  17817. return cont(expect('variable'), maybetypeOrIn, expect(']'), typeprop);
  17818. } else if (type == '(') {
  17819. return pass(functiondecl, typeprop);
  17820. }
  17821. }
  17822. function typearg(type, value) {
  17823. if (type == 'variable' && cx.stream.match(/^\s*[?:]/, false) || value == '?') {
  17824. return cont(typearg);
  17825. }
  17826. if (type == ':') {
  17827. return cont(typeexpr);
  17828. }
  17829. if (type == 'spread') {
  17830. return cont(typearg);
  17831. }
  17832. return pass(typeexpr);
  17833. }
  17834. function afterType(type, value) {
  17835. if (value == '<') {
  17836. return cont(pushlex('>'), commasep(typeexpr, '>'), poplex, afterType);
  17837. }
  17838. if (value == '|' || type == '.' || value == '&') {
  17839. return cont(typeexpr);
  17840. }
  17841. if (type == '[') {
  17842. return cont(typeexpr, expect(']'), afterType);
  17843. }
  17844. if (value == 'extends' || value == 'implements') {
  17845. cx.marked = 'keyword';
  17846. return cont(typeexpr);
  17847. }
  17848. if (value == '?') {
  17849. return cont(typeexpr, expect(':'), typeexpr);
  17850. }
  17851. }
  17852. function maybeTypeArgs(_, value) {
  17853. if (value == '<') {
  17854. return cont(pushlex('>'), commasep(typeexpr, '>'), poplex, afterType);
  17855. }
  17856. }
  17857. function typeparam() {
  17858. return pass(typeexpr, maybeTypeDefault);
  17859. }
  17860. function maybeTypeDefault(_, value) {
  17861. if (value == '=') {
  17862. return cont(typeexpr);
  17863. }
  17864. }
  17865. function vardef(_, value) {
  17866. if (value == 'enum') {
  17867. cx.marked = 'keyword';
  17868. return cont(enumdef);
  17869. }
  17870. return pass(pattern, maybetype, maybeAssign, vardefCont);
  17871. }
  17872. function pattern(type, value) {
  17873. if (isTS && isModifier(value)) {
  17874. cx.marked = 'keyword';
  17875. return cont(pattern);
  17876. }
  17877. if (type == 'variable') {
  17878. register(value);
  17879. return cont();
  17880. }
  17881. if (type == 'spread') {
  17882. return cont(pattern);
  17883. }
  17884. if (type == '[') {
  17885. return contCommasep(eltpattern, ']');
  17886. }
  17887. if (type == '{') {
  17888. return contCommasep(proppattern, '}');
  17889. }
  17890. }
  17891. function proppattern(type, value) {
  17892. if (type == 'variable' && !cx.stream.match(/^\s*:/, false)) {
  17893. register(value);
  17894. return cont(maybeAssign);
  17895. }
  17896. if (type == 'variable') {
  17897. cx.marked = 'property';
  17898. }
  17899. if (type == 'spread') {
  17900. return cont(pattern);
  17901. }
  17902. if (type == '}') {
  17903. return pass();
  17904. }
  17905. if (type == '[') {
  17906. return cont(expression, expect(']'), expect(':'), proppattern);
  17907. }
  17908. return cont(expect(':'), pattern, maybeAssign);
  17909. }
  17910. function eltpattern() {
  17911. return pass(pattern, maybeAssign);
  17912. }
  17913. function maybeAssign(_type, value) {
  17914. if (value == '=') {
  17915. return cont(expressionNoComma);
  17916. }
  17917. }
  17918. function vardefCont(type) {
  17919. if (type == ',') {
  17920. return cont(vardef);
  17921. }
  17922. }
  17923. function maybeelse(type, value) {
  17924. if (type == 'keyword b' && value == 'else') {
  17925. return cont(pushlex('form', 'else'), statement, poplex);
  17926. }
  17927. }
  17928. function forspec(type, value) {
  17929. if (value == 'await') {
  17930. return cont(forspec);
  17931. }
  17932. if (type == '(') {
  17933. return cont(pushlex(')'), forspec1, poplex);
  17934. }
  17935. }
  17936. function forspec1(type) {
  17937. if (type == 'var') {
  17938. return cont(vardef, forspec2);
  17939. }
  17940. if (type == 'variable') {
  17941. return cont(forspec2);
  17942. }
  17943. return pass(forspec2);
  17944. }
  17945. function forspec2(type, value) {
  17946. if (type == ')') {
  17947. return cont();
  17948. }
  17949. if (type == ';') {
  17950. return cont(forspec2);
  17951. }
  17952. if (value == 'in' || value == 'of') {
  17953. cx.marked = 'keyword';
  17954. return cont(expression, forspec2);
  17955. }
  17956. return pass(expression, forspec2);
  17957. }
  17958. function functiondef(type, value) {
  17959. if (value == '*') {
  17960. cx.marked = 'keyword';
  17961. return cont(functiondef);
  17962. }
  17963. if (type == 'variable') {
  17964. register(value);
  17965. return cont(functiondef);
  17966. }
  17967. if (type == '(') {
  17968. return cont(pushcontext, pushlex(')'), commasep(funarg, ')'), poplex, mayberettype, statement, popcontext);
  17969. }
  17970. if (isTS && value == '<') {
  17971. return cont(pushlex('>'), commasep(typeparam, '>'), poplex, functiondef);
  17972. }
  17973. }
  17974. function functiondecl(type, value) {
  17975. if (value == '*') {
  17976. cx.marked = 'keyword';
  17977. return cont(functiondecl);
  17978. }
  17979. if (type == 'variable') {
  17980. register(value);
  17981. return cont(functiondecl);
  17982. }
  17983. if (type == '(') {
  17984. return cont(pushcontext, pushlex(')'), commasep(funarg, ')'), poplex, mayberettype, popcontext);
  17985. }
  17986. if (isTS && value == '<') {
  17987. return cont(pushlex('>'), commasep(typeparam, '>'), poplex, functiondecl);
  17988. }
  17989. }
  17990. function typename(type, value) {
  17991. if (type == 'keyword' || type == 'variable') {
  17992. cx.marked = 'type';
  17993. return cont(typename);
  17994. } else if (value == '<') {
  17995. return cont(pushlex('>'), commasep(typeparam, '>'), poplex);
  17996. }
  17997. }
  17998. function funarg(type, value) {
  17999. if (value == '@') {
  18000. cont(expression, funarg);
  18001. }
  18002. if (type == 'spread') {
  18003. return cont(funarg);
  18004. }
  18005. if (isTS && isModifier(value)) {
  18006. cx.marked = 'keyword';
  18007. return cont(funarg);
  18008. }
  18009. if (isTS && type == 'this') {
  18010. return cont(maybetype, maybeAssign);
  18011. }
  18012. return pass(pattern, maybetype, maybeAssign);
  18013. }
  18014. function classExpression(type, value) {
  18015. // Class expressions may have an optional name.
  18016. if (type == 'variable') {
  18017. return className(type, value);
  18018. }
  18019. return classNameAfter(type, value);
  18020. }
  18021. function className(type, value) {
  18022. if (type == 'variable') {
  18023. register(value);
  18024. return cont(classNameAfter);
  18025. }
  18026. }
  18027. function classNameAfter(type, value) {
  18028. if (value == '<') {
  18029. return cont(pushlex('>'), commasep(typeparam, '>'), poplex, classNameAfter);
  18030. }
  18031. if (value == 'extends' || value == 'implements' || isTS && type == ',') {
  18032. if (value == 'implements') {
  18033. cx.marked = 'keyword';
  18034. }
  18035. return cont(isTS ? typeexpr : expression, classNameAfter);
  18036. }
  18037. if (type == '{') {
  18038. return cont(pushlex('}'), classBody, poplex);
  18039. }
  18040. }
  18041. function classBody(type, value) {
  18042. if (type == 'async' || type == 'variable' && (value == 'static' || value == 'get' || value == 'set' || isTS && isModifier(value)) && cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false)) {
  18043. cx.marked = 'keyword';
  18044. return cont(classBody);
  18045. }
  18046. if (type == 'variable' || cx.style == 'keyword') {
  18047. cx.marked = 'property';
  18048. return cont(isTS ? classfield : functiondef, classBody);
  18049. }
  18050. if (type == 'number' || type == 'string') {
  18051. return cont(isTS ? classfield : functiondef, classBody);
  18052. }
  18053. if (type == '[') {
  18054. return cont(expression, maybetype, expect(']'), isTS ? classfield : functiondef, classBody);
  18055. }
  18056. if (value == '*') {
  18057. cx.marked = 'keyword';
  18058. return cont(classBody);
  18059. }
  18060. if (isTS && type == '(') {
  18061. return pass(functiondecl, classBody);
  18062. }
  18063. if (type == ';' || type == ',') {
  18064. return cont(classBody);
  18065. }
  18066. if (type == '}') {
  18067. return cont();
  18068. }
  18069. if (value == '@') {
  18070. return cont(expression, classBody);
  18071. }
  18072. }
  18073. function classfield(type, value) {
  18074. if (value == '?') {
  18075. return cont(classfield);
  18076. }
  18077. if (type == ':') {
  18078. return cont(typeexpr, maybeAssign);
  18079. }
  18080. if (value == '=') {
  18081. return cont(expressionNoComma);
  18082. }
  18083. var context = cx.state.lexical.prev,
  18084. isInterface = context && context.info == 'interface';
  18085. return pass(isInterface ? functiondecl : functiondef);
  18086. }
  18087. function afterExport(type, value) {
  18088. if (value == '*') {
  18089. cx.marked = 'keyword';
  18090. return cont(maybeFrom, expect(';'));
  18091. }
  18092. if (value == 'default') {
  18093. cx.marked = 'keyword';
  18094. return cont(expression, expect(';'));
  18095. }
  18096. if (type == '{') {
  18097. return cont(commasep(exportField, '}'), maybeFrom, expect(';'));
  18098. }
  18099. return pass(statement);
  18100. }
  18101. function exportField(type, value) {
  18102. if (value == 'as') {
  18103. cx.marked = 'keyword';
  18104. return cont(expect('variable'));
  18105. }
  18106. if (type == 'variable') {
  18107. return pass(expressionNoComma, exportField);
  18108. }
  18109. }
  18110. function afterImport(type) {
  18111. if (type == 'string') {
  18112. return cont();
  18113. }
  18114. if (type == '(') {
  18115. return pass(expression);
  18116. }
  18117. return pass(importSpec, maybeMoreImports, maybeFrom);
  18118. }
  18119. function importSpec(type, value) {
  18120. if (type == '{') {
  18121. return contCommasep(importSpec, '}');
  18122. }
  18123. if (type == 'variable') {
  18124. register(value);
  18125. }
  18126. if (value == '*') {
  18127. cx.marked = 'keyword';
  18128. }
  18129. return cont(maybeAs);
  18130. }
  18131. function maybeMoreImports(type) {
  18132. if (type == ',') {
  18133. return cont(importSpec, maybeMoreImports);
  18134. }
  18135. }
  18136. function maybeAs(_type, value) {
  18137. if (value == 'as') {
  18138. cx.marked = 'keyword';
  18139. return cont(importSpec);
  18140. }
  18141. }
  18142. function maybeFrom(_type, value) {
  18143. if (value == 'from') {
  18144. cx.marked = 'keyword';
  18145. return cont(expression);
  18146. }
  18147. }
  18148. function arrayLiteral(type) {
  18149. if (type == ']') {
  18150. return cont();
  18151. }
  18152. return pass(commasep(expressionNoComma, ']'));
  18153. }
  18154. function enumdef() {
  18155. return pass(pushlex('form'), pattern, expect('{'), pushlex('}'), commasep(enummember, '}'), poplex, poplex);
  18156. }
  18157. function enummember() {
  18158. return pass(pattern, maybeAssign);
  18159. }
  18160. function isContinuedStatement(state, textAfter) {
  18161. return state.lastType == 'operator' || state.lastType == ',' || isOperatorChar.test(textAfter.charAt(0)) || /[,.]/.test(textAfter.charAt(0));
  18162. }
  18163. function expressionAllowed(stream, state, backUp) {
  18164. return state.tokenize == tokenBase && /^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) || state.lastType == 'quasi' && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0)));
  18165. }
  18166. // Interface
  18167. return {
  18168. startState: function startState(basecolumn) {
  18169. var state = {
  18170. tokenize: tokenBase,
  18171. lastType: 'sof',
  18172. cc: [],
  18173. lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, 'block', false),
  18174. localVars: parserConfig.localVars,
  18175. context: parserConfig.localVars && new Context(null, null, false),
  18176. indented: basecolumn || 0
  18177. };
  18178. if (parserConfig.globalVars && _typeof(parserConfig.globalVars) === 'object') {
  18179. state.globalVars = parserConfig.globalVars;
  18180. }
  18181. return state;
  18182. },
  18183. token: function token(stream, state) {
  18184. if (stream.sol()) {
  18185. if (!state.lexical.hasOwnProperty('align')) {
  18186. state.lexical.align = false;
  18187. }
  18188. state.indented = stream.indentation();
  18189. findFatArrow(stream, state);
  18190. }
  18191. if (state.tokenize != tokenComment && stream.eatSpace()) {
  18192. return null;
  18193. }
  18194. var style = state.tokenize(stream, state);
  18195. if (type == 'comment') {
  18196. return style;
  18197. }
  18198. state.lastType = type == 'operator' && (content == '++' || content == '--') ? 'incdec' : type;
  18199. return parseJS(state, style, type, content, stream);
  18200. },
  18201. indent: function indent(state, textAfter) {
  18202. if (state.tokenize == tokenComment) {
  18203. return __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].Pass;
  18204. }
  18205. if (state.tokenize != tokenBase) {
  18206. return 0;
  18207. }
  18208. var firstChar = textAfter && textAfter.charAt(0),
  18209. lexical = state.lexical,
  18210. top;
  18211. // Kludge to prevent 'maybelse' from blocking lexical scope pops
  18212. if (!/^\s*else\b/.test(textAfter)) {
  18213. for (var i = state.cc.length - 1; i >= 0; --i) {
  18214. var c = state.cc[i];
  18215. if (c == poplex) {
  18216. lexical = lexical.prev;
  18217. } else if (c != maybeelse) {
  18218. break;
  18219. }
  18220. }
  18221. }
  18222. while ((lexical.type == 'stat' || lexical.type == 'form') && (firstChar == '}' || (top = state.cc[state.cc.length - 1]) && (top == maybeoperatorComma || top == maybeoperatorNoComma) && !/^[,\.=+\-*:?[\(]/.test(textAfter))) {
  18223. lexical = lexical.prev;
  18224. }
  18225. if (statementIndent && lexical.type == ')' && lexical.prev.type == 'stat') {
  18226. lexical = lexical.prev;
  18227. }
  18228. var type = lexical.type,
  18229. closing = firstChar == type;
  18230. if (type == 'vardef') {
  18231. return lexical.indented + (state.lastType == 'operator' || state.lastType == ',' ? lexical.info.length + 1 : 0);
  18232. } else if (type == 'form' && firstChar == '{') {
  18233. return lexical.indented;
  18234. } else if (type == 'form') {
  18235. return lexical.indented + indentUnit;
  18236. } else if (type == 'stat') {
  18237. return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
  18238. } else if (lexical.info == 'switch' && !closing && parserConfig.doubleIndentSwitch != false) {
  18239. return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
  18240. } else if (lexical.align) {
  18241. return lexical.column + (closing ? 0 : 1);
  18242. } else {
  18243. return lexical.indented + (closing ? 0 : indentUnit);
  18244. }
  18245. },
  18246. electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
  18247. blockCommentStart: jsonMode ? null : '/*',
  18248. blockCommentEnd: jsonMode ? null : '*/',
  18249. blockCommentContinue: jsonMode ? null : ' * ',
  18250. lineComment: jsonMode ? null : '//',
  18251. fold: 'brace',
  18252. closeBrackets: '()[]{}\'\'""``',
  18253. helperType: jsonMode ? 'json' : 'javascript',
  18254. jsonldMode: jsonldMode,
  18255. jsonMode: jsonMode,
  18256. expressionAllowed: expressionAllowed,
  18257. skipExpression: function skipExpression(state) {
  18258. var top = state.cc[state.cc.length - 1];
  18259. if (top == expression || top == expressionNoComma) {
  18260. state.cc.pop();
  18261. }
  18262. }
  18263. };
  18264. }
  18265. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].registerHelper('wordChars', 'javascript', /[\w$]/);
  18266. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('json', {
  18267. name: 'javascript',
  18268. json: true
  18269. });
  18270. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('typescript', {
  18271. name: 'javascript',
  18272. typescript: true
  18273. });
  18274. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('ts', {
  18275. name: 'javascript',
  18276. typescript: true
  18277. });
  18278. var languages = ['js', 'json', 'python', 'py', 'react', 'coffeescript', 'dart', 'go', 'jsx'];
  18279. languages.forEach(function (item) {
  18280. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME(item, 'javascript');
  18281. });
  18282. /***/ }),
  18283. /***/ 877:
  18284. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18285. "use strict";
  18286. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__(321);
  18287. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMode('markdown', function (cmCfg, modeCfg) {
  18288. var htmlMode = __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].getMode(cmCfg, 'text/html');
  18289. var htmlModeMissing = htmlMode.name == 'null';
  18290. function getMode(name) {
  18291. if (__WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].findModeByName) {
  18292. var found = __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].findModeByName(name);
  18293. if (found) {
  18294. name = found.mime || found.mimes[0];
  18295. }
  18296. }
  18297. var mode = __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].getMode(cmCfg, name);
  18298. return mode.name == 'null' ? null : mode;
  18299. }
  18300. // Should characters that affect highlighting be highlighted separate?
  18301. // Does not include characters that will be output (such as `1.` and `-` for lists)
  18302. if (modeCfg.highlightFormatting === undefined) {
  18303. modeCfg.highlightFormatting = false;
  18304. }
  18305. // Maximum number of nested blockquotes. Set to 0 for infinite nesting.
  18306. // Excess `>` will emit `error` token.
  18307. if (modeCfg.maxBlockquoteDepth === undefined) {
  18308. modeCfg.maxBlockquoteDepth = 0;
  18309. }
  18310. // Turn on task lists? ("- [ ] " and "- [x] ")
  18311. if (modeCfg.taskLists === undefined) {
  18312. modeCfg.taskLists = false;
  18313. }
  18314. // Turn on strikethrough syntax
  18315. if (modeCfg.strikethrough === undefined) {
  18316. modeCfg.strikethrough = false;
  18317. }
  18318. if (modeCfg.emoji === undefined) {
  18319. modeCfg.emoji = false;
  18320. }
  18321. if (modeCfg.fencedCodeBlockHighlighting === undefined) {
  18322. modeCfg.fencedCodeBlockHighlighting = true;
  18323. }
  18324. if (modeCfg.xml === undefined) {
  18325. modeCfg.xml = true;
  18326. }
  18327. // Allow token types to be overridden by user-provided token types.
  18328. if (modeCfg.tokenTypeOverrides === undefined) {
  18329. modeCfg.tokenTypeOverrides = {};
  18330. }
  18331. var tokenTypes = {
  18332. header: 'header',
  18333. code: 'comment',
  18334. quote: 'quote',
  18335. list1: 'variable-2',
  18336. list2: 'variable-3',
  18337. list3: 'keyword',
  18338. hr: 'hr',
  18339. image: 'image',
  18340. imageAltText: 'image-alt-text',
  18341. imageMarker: 'image-marker',
  18342. formatting: 'formatting',
  18343. linkInline: 'link',
  18344. linkEmail: 'link',
  18345. linkText: 'link',
  18346. linkHref: 'string',
  18347. em: 'em',
  18348. strong: 'strong',
  18349. strikethrough: 'strikethrough',
  18350. emoji: 'builtin'
  18351. };
  18352. for (var tokenType in tokenTypes) {
  18353. if (tokenTypes.hasOwnProperty(tokenType) && modeCfg.tokenTypeOverrides[tokenType]) {
  18354. tokenTypes[tokenType] = modeCfg.tokenTypeOverrides[tokenType];
  18355. }
  18356. }
  18357. var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/,
  18358. listRE = /^(?:[*\-+]|^[0-9]+([.)]))\s+/,
  18359. taskListRE = /^\[(x| )\](?=\s)/i,
  18360. // Must follow listRE
  18361. atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/,
  18362. setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/,
  18363. textRE = /^[^#!\[\]*_\\<>` "'(~:]+/,
  18364. fencedCodeRE = /^(~~~+|```+)[ \t]*([\w+#-]*)[^\n`]*$/,
  18365. linkDefRE = /^\s*\[[^\]]+?\]:.*$/,
  18366. // naive link-definition
  18367. punctuation = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,
  18368. expandedTab = ' '; // CommonMark specifies tab as 4 spaces
  18369. function switchInline(stream, state, f) {
  18370. state.f = state.inline = f;
  18371. return f(stream, state);
  18372. }
  18373. function switchBlock(stream, state, f) {
  18374. state.f = state.block = f;
  18375. return f(stream, state);
  18376. }
  18377. function lineIsEmpty(line) {
  18378. return !line || !/\S/.test(line.string);
  18379. }
  18380. // Blocks
  18381. function blankLine(state) {
  18382. // Reset linkTitle state
  18383. state.linkTitle = false;
  18384. state.linkHref = false;
  18385. state.linkText = false;
  18386. // Reset EM state
  18387. state.em = false;
  18388. // Reset STRONG state
  18389. state.strong = false;
  18390. // Reset strikethrough state
  18391. state.strikethrough = false;
  18392. // Reset state.quote
  18393. state.quote = 0;
  18394. // Reset state.indentedCode
  18395. state.indentedCode = false;
  18396. if (state.f == htmlBlock) {
  18397. var exit = htmlModeMissing;
  18398. if (!exit) {
  18399. var inner = __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].innerMode(htmlMode, state.htmlState);
  18400. exit = inner.mode.name == 'xml' && inner.state.tagStart === null && !inner.state.context && inner.state.tokenize.isInText;
  18401. }
  18402. if (exit) {
  18403. state.f = inlineNormal;
  18404. state.block = blockNormal;
  18405. state.htmlState = null;
  18406. }
  18407. }
  18408. // Reset state.trailingSpace
  18409. state.trailingSpace = 0;
  18410. state.trailingSpaceNewLine = false;
  18411. // Mark this line as blank
  18412. state.prevLine = state.thisLine;
  18413. state.thisLine = { stream: null };
  18414. return null;
  18415. }
  18416. function blockNormal(stream, state) {
  18417. var firstTokenOnLine = stream.column() === state.indentation;
  18418. var prevLineLineIsEmpty = lineIsEmpty(state.prevLine.stream);
  18419. var prevLineIsIndentedCode = state.indentedCode;
  18420. var prevLineIsHr = state.prevLine.hr;
  18421. var prevLineIsList = state.list !== false;
  18422. var maxNonCodeIndentation = (state.listStack[state.listStack.length - 1] || 0) + 3;
  18423. state.indentedCode = false;
  18424. var lineIndentation = state.indentation;
  18425. // compute once per line (on first token)
  18426. if (state.indentationDiff === null) {
  18427. state.indentationDiff = state.indentation;
  18428. if (prevLineIsList) {
  18429. state.list = null;
  18430. // While this list item's marker's indentation is less than the deepest
  18431. // list item's content's indentation,pop the deepest list item
  18432. // indentation off the stack, and update block indentation state
  18433. while (lineIndentation < state.listStack[state.listStack.length - 1]) {
  18434. state.listStack.pop();
  18435. if (state.listStack.length) {
  18436. state.indentation = state.listStack[state.listStack.length - 1];
  18437. // less than the first list's indent -> the line is no longer a list
  18438. } else {
  18439. state.list = false;
  18440. }
  18441. }
  18442. if (state.list !== false) {
  18443. state.indentationDiff = lineIndentation - state.listStack[state.listStack.length - 1];
  18444. }
  18445. }
  18446. }
  18447. // not comprehensive (currently only for setext detection purposes)
  18448. var allowsInlineContinuation = !prevLineLineIsEmpty && !prevLineIsHr && !state.prevLine.header && (!prevLineIsList || !prevLineIsIndentedCode) && !state.prevLine.fencedCodeEnd;
  18449. var isHr = (state.list === false || prevLineIsHr || prevLineLineIsEmpty) && state.indentation <= maxNonCodeIndentation && stream.match(hrRE);
  18450. var match = null;
  18451. if (state.indentationDiff >= 4 && (prevLineIsIndentedCode || state.prevLine.fencedCodeEnd || state.prevLine.header || prevLineLineIsEmpty)) {
  18452. stream.skipToEnd();
  18453. state.indentedCode = true;
  18454. return tokenTypes.code;
  18455. } else if (stream.eatSpace()) {
  18456. return null;
  18457. } else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(atxHeaderRE)) && match[1].length <= 6) {
  18458. state.quote = 0;
  18459. state.header = match[1].length;
  18460. state.thisLine.header = true;
  18461. if (modeCfg.highlightFormatting) {
  18462. state.formatting = 'header';
  18463. }
  18464. state.f = state.inline;
  18465. return getType(state);
  18466. } else if (state.indentation <= maxNonCodeIndentation && stream.eat('>')) {
  18467. state.quote = firstTokenOnLine ? 1 : state.quote + 1;
  18468. if (modeCfg.highlightFormatting) {
  18469. state.formatting = 'quote';
  18470. }
  18471. stream.eatSpace();
  18472. return getType(state);
  18473. } else if (!isHr && !state.setext && firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(listRE))) {
  18474. var listType = match[1] ? 'ol' : 'ul';
  18475. state.indentation = lineIndentation + stream.current().length;
  18476. state.list = true;
  18477. state.quote = 0;
  18478. // Add this list item's content's indentation to the stack
  18479. state.listStack.push(state.indentation);
  18480. // Reset inline styles which shouldn't propagate aross list items
  18481. state.em = false;
  18482. state.strong = false;
  18483. state.code = false;
  18484. state.strikethrough = false;
  18485. if (modeCfg.taskLists && stream.match(taskListRE, false)) {
  18486. state.taskList = true;
  18487. }
  18488. state.f = state.inline;
  18489. if (modeCfg.highlightFormatting) {
  18490. state.formatting = ['list', 'list-' + listType];
  18491. }
  18492. return getType(state);
  18493. } else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(fencedCodeRE, true))) {
  18494. state.quote = 0;
  18495. state.fencedEndRE = new RegExp(match[1] + '+ *$');
  18496. // try switching mode
  18497. state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2]);
  18498. if (state.localMode) {
  18499. state.localState = __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].startState(state.localMode);
  18500. }
  18501. state.f = state.block = local;
  18502. if (modeCfg.highlightFormatting) {
  18503. state.formatting = 'code-block';
  18504. }
  18505. state.code = -1;
  18506. return getType(state);
  18507. // SETEXT has lowest block-scope precedence after HR, so check it after
  18508. // the others (code, blockquote, list...)
  18509. } else if (
  18510. // if setext set, indicates line after ---/===
  18511. state.setext ||
  18512. // line before ---/===
  18513. (!allowsInlineContinuation || !prevLineIsList) && !state.quote && state.list === false && !state.code && !isHr && !linkDefRE.test(stream.string) && (match = stream.lookAhead(1)) && (match = match.match(setextHeaderRE))) {
  18514. if (!state.setext) {
  18515. state.header = match[0].charAt(0) == '=' ? 1 : 2;
  18516. state.setext = state.header;
  18517. } else {
  18518. state.header = state.setext;
  18519. // has no effect on type so we can reset it now
  18520. state.setext = 0;
  18521. stream.skipToEnd();
  18522. if (modeCfg.highlightFormatting) {
  18523. state.formatting = 'header';
  18524. }
  18525. }
  18526. state.thisLine.header = true;
  18527. state.f = state.inline;
  18528. return getType(state);
  18529. } else if (isHr) {
  18530. stream.skipToEnd();
  18531. state.hr = true;
  18532. state.thisLine.hr = true;
  18533. return tokenTypes.hr;
  18534. } else if (stream.peek() === '[') {
  18535. return switchInline(stream, state, footnoteLink);
  18536. }
  18537. return switchInline(stream, state, state.inline);
  18538. }
  18539. function htmlBlock(stream, state) {
  18540. var style = htmlMode.token(stream, state.htmlState);
  18541. if (!htmlModeMissing) {
  18542. var inner = __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].innerMode(htmlMode, state.htmlState);
  18543. if (inner.mode.name == 'xml' && inner.state.tagStart === null && !inner.state.context && inner.state.tokenize.isInText || state.md_inside && stream.current().indexOf('>') > -1) {
  18544. state.f = inlineNormal;
  18545. state.block = blockNormal;
  18546. state.htmlState = null;
  18547. }
  18548. }
  18549. return style;
  18550. }
  18551. function local(stream, state) {
  18552. var currListInd = state.listStack[state.listStack.length - 1] || 0;
  18553. var hasExitedList = state.indentation < currListInd;
  18554. var maxFencedEndInd = currListInd + 3;
  18555. if (state.fencedEndRE && state.indentation <= maxFencedEndInd && (hasExitedList || stream.match(state.fencedEndRE))) {
  18556. if (modeCfg.highlightFormatting) {
  18557. state.formatting = 'code-block';
  18558. }
  18559. var returnType;
  18560. if (!hasExitedList) {
  18561. returnType = getType(state);
  18562. }
  18563. state.localMode = state.localState = null;
  18564. state.block = blockNormal;
  18565. state.f = inlineNormal;
  18566. state.fencedEndRE = null;
  18567. state.code = 0;
  18568. state.thisLine.fencedCodeEnd = true;
  18569. if (hasExitedList) {
  18570. return switchBlock(stream, state, state.block);
  18571. }
  18572. return returnType;
  18573. } else if (state.localMode) {
  18574. return state.localMode.token(stream, state.localState);
  18575. } else {
  18576. stream.skipToEnd();
  18577. return tokenTypes.code;
  18578. }
  18579. }
  18580. // Inline
  18581. function getType(state) {
  18582. var styles = [];
  18583. if (state.formatting) {
  18584. styles.push(tokenTypes.formatting);
  18585. if (typeof state.formatting === 'string') {
  18586. state.formatting = [state.formatting];
  18587. }
  18588. for (var i = 0; i < state.formatting.length; i++) {
  18589. styles.push(tokenTypes.formatting + '-' + state.formatting[i]);
  18590. if (state.formatting[i] === 'header') {
  18591. styles.push(tokenTypes.formatting + '-' + state.formatting[i] + '-' + state.header);
  18592. }
  18593. // Add `formatting-quote` and `formatting-quote-#` for blockquotes
  18594. // Add `error` instead if the maximum blockquote nesting depth is passed
  18595. if (state.formatting[i] === 'quote') {
  18596. if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
  18597. styles.push(tokenTypes.formatting + '-' + state.formatting[i] + '-' + state.quote);
  18598. } else {
  18599. styles.push('error');
  18600. }
  18601. }
  18602. }
  18603. }
  18604. if (state.taskOpen) {
  18605. styles.push('meta');
  18606. return styles.length ? styles.join(' ') : null;
  18607. }
  18608. if (state.taskClosed) {
  18609. styles.push('property');
  18610. return styles.length ? styles.join(' ') : null;
  18611. }
  18612. if (state.linkHref) {
  18613. styles.push(tokenTypes.linkHref, 'url');
  18614. } else {
  18615. // Only apply inline styles to non-url text
  18616. if (state.strong) {
  18617. styles.push(tokenTypes.strong);
  18618. }
  18619. if (state.em) {
  18620. styles.push(tokenTypes.em);
  18621. }
  18622. if (state.strikethrough) {
  18623. styles.push(tokenTypes.strikethrough);
  18624. }
  18625. if (state.emoji) {
  18626. styles.push(tokenTypes.emoji);
  18627. }
  18628. if (state.linkText) {
  18629. styles.push(tokenTypes.linkText);
  18630. }
  18631. if (state.code) {
  18632. styles.push(tokenTypes.code);
  18633. }
  18634. if (state.image) {
  18635. styles.push(tokenTypes.image);
  18636. }
  18637. if (state.imageAltText) {
  18638. styles.push(tokenTypes.imageAltText, 'link');
  18639. }
  18640. if (state.imageMarker) {
  18641. styles.push(tokenTypes.imageMarker);
  18642. }
  18643. }
  18644. if (state.header) {
  18645. styles.push(tokenTypes.header, tokenTypes.header + '-' + state.header);
  18646. }
  18647. if (state.quote) {
  18648. styles.push(tokenTypes.quote);
  18649. // Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth
  18650. if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
  18651. styles.push(tokenTypes.quote + '-' + state.quote);
  18652. } else {
  18653. styles.push(tokenTypes.quote + '-' + modeCfg.maxBlockquoteDepth);
  18654. }
  18655. }
  18656. if (state.list !== false) {
  18657. var listMod = (state.listStack.length - 1) % 3;
  18658. if (!listMod) {
  18659. styles.push(tokenTypes.list1);
  18660. } else if (listMod === 1) {
  18661. styles.push(tokenTypes.list2);
  18662. } else {
  18663. styles.push(tokenTypes.list3);
  18664. }
  18665. }
  18666. if (state.trailingSpaceNewLine) {
  18667. styles.push('trailing-space-new-line');
  18668. } else if (state.trailingSpace) {
  18669. styles.push('trailing-space-' + (state.trailingSpace % 2 ? 'a' : 'b'));
  18670. }
  18671. return styles.length ? styles.join(' ') : null;
  18672. }
  18673. function handleText(stream, state) {
  18674. if (stream.match(textRE, true)) {
  18675. return getType(state);
  18676. }
  18677. return undefined;
  18678. }
  18679. function inlineNormal(stream, state) {
  18680. var style = state.text(stream, state);
  18681. if (typeof style !== 'undefined') {
  18682. return style;
  18683. }
  18684. if (state.list) {
  18685. // List marker (*, +, -, 1., etc)
  18686. state.list = null;
  18687. return getType(state);
  18688. }
  18689. if (state.taskList) {
  18690. var taskOpen = stream.match(taskListRE, true)[1] === ' ';
  18691. if (taskOpen) {
  18692. state.taskOpen = true;
  18693. } else {
  18694. state.taskClosed = true;
  18695. }
  18696. if (modeCfg.highlightFormatting) {
  18697. state.formatting = 'task';
  18698. }
  18699. state.taskList = false;
  18700. return getType(state);
  18701. }
  18702. state.taskOpen = false;
  18703. state.taskClosed = false;
  18704. if (state.header && stream.match(/^#+$/, true)) {
  18705. if (modeCfg.highlightFormatting) {
  18706. state.formatting = 'header';
  18707. }
  18708. return getType(state);
  18709. }
  18710. var ch = stream.next();
  18711. // Matches link titles present on next line
  18712. if (state.linkTitle) {
  18713. state.linkTitle = false;
  18714. var matchCh = ch;
  18715. if (ch === '(') {
  18716. matchCh = ')';
  18717. }
  18718. matchCh = String(matchCh).replace(/([.?*+^\[\]\\(){}|-])/g, '\\$1');
  18719. var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh;
  18720. if (stream.match(new RegExp(regex), true)) {
  18721. return tokenTypes.linkHref;
  18722. }
  18723. }
  18724. // If this block is changed, it may need to be updated in GFM mode
  18725. if (ch === '`') {
  18726. var previousFormatting = state.formatting;
  18727. if (modeCfg.highlightFormatting) {
  18728. state.formatting = 'code';
  18729. }
  18730. stream.eatWhile('`');
  18731. var count = stream.current().length;
  18732. if (state.code == 0 && (!state.quote || count == 1)) {
  18733. state.code = count;
  18734. return getType(state);
  18735. } else if (count == state.code) {
  18736. // Must be exact
  18737. var t = getType(state);
  18738. state.code = 0;
  18739. return t;
  18740. } else {
  18741. state.formatting = previousFormatting;
  18742. return getType(state);
  18743. }
  18744. } else if (state.code) {
  18745. return getType(state);
  18746. }
  18747. if (ch === '\\') {
  18748. stream.next();
  18749. if (modeCfg.highlightFormatting) {
  18750. var type = getType(state);
  18751. var formattingEscape = tokenTypes.formatting + '-escape';
  18752. return type ? type + ' ' + formattingEscape : formattingEscape;
  18753. }
  18754. }
  18755. if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
  18756. state.imageMarker = true;
  18757. state.image = true;
  18758. if (modeCfg.highlightFormatting) {
  18759. state.formatting = 'image';
  18760. }
  18761. return getType(state);
  18762. }
  18763. if (ch === '[' && state.imageMarker && stream.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/, false)) {
  18764. state.imageMarker = false;
  18765. state.imageAltText = true;
  18766. if (modeCfg.highlightFormatting) {
  18767. state.formatting = 'image';
  18768. }
  18769. return getType(state);
  18770. }
  18771. if (ch === ']' && state.imageAltText) {
  18772. if (modeCfg.highlightFormatting) {
  18773. state.formatting = 'image';
  18774. }
  18775. var type = getType(state);
  18776. state.imageAltText = false;
  18777. state.image = false;
  18778. state.inline = state.f = linkHref;
  18779. return type;
  18780. }
  18781. if (ch === '[' && !state.image) {
  18782. if (state.linkText && stream.match(/^.*?\]/)) {
  18783. return getType(state);
  18784. }
  18785. state.linkText = true;
  18786. if (modeCfg.highlightFormatting) {
  18787. state.formatting = 'link';
  18788. }
  18789. return getType(state);
  18790. }
  18791. if (ch === ']' && state.linkText) {
  18792. if (modeCfg.highlightFormatting) {
  18793. state.formatting = 'link';
  18794. }
  18795. var type = getType(state);
  18796. state.linkText = false;
  18797. state.inline = state.f = stream.match(/\(.*?\)| ?\[.*?\]/, false) ? linkHref : inlineNormal;
  18798. return type;
  18799. }
  18800. if (ch === '<' && stream.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, false)) {
  18801. state.f = state.inline = linkInline;
  18802. if (modeCfg.highlightFormatting) {
  18803. state.formatting = 'link';
  18804. }
  18805. var type = getType(state);
  18806. if (type) {
  18807. type += ' ';
  18808. } else {
  18809. type = '';
  18810. }
  18811. return type + tokenTypes.linkInline;
  18812. }
  18813. if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) {
  18814. state.f = state.inline = linkInline;
  18815. if (modeCfg.highlightFormatting) {
  18816. state.formatting = 'link';
  18817. }
  18818. var type = getType(state);
  18819. if (type) {
  18820. type += ' ';
  18821. } else {
  18822. type = '';
  18823. }
  18824. return type + tokenTypes.linkEmail;
  18825. }
  18826. if (modeCfg.xml && ch === '<' && stream.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i, false)) {
  18827. var end = stream.string.indexOf('>', stream.pos);
  18828. if (end != -1) {
  18829. var atts = stream.string.substring(stream.start, end);
  18830. if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) {
  18831. state.md_inside = true;
  18832. }
  18833. }
  18834. stream.backUp(1);
  18835. state.htmlState = __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].startState(htmlMode);
  18836. return switchBlock(stream, state, htmlBlock);
  18837. }
  18838. if (modeCfg.xml && ch === '<' && stream.match(/^\/\w*?>/)) {
  18839. state.md_inside = false;
  18840. return 'tag';
  18841. } else if (ch === '*' || ch === '_') {
  18842. var len = 1,
  18843. before = stream.pos == 1 ? ' ' : stream.string.charAt(stream.pos - 2);
  18844. while (len < 3 && stream.eat(ch)) {
  18845. len++;
  18846. }
  18847. var after = stream.peek() || ' ';
  18848. // See http://spec.commonmark.org/0.27/#emphasis-and-strong-emphasis
  18849. var leftFlanking = !/\s/.test(after) && (!punctuation.test(after) || /\s/.test(before) || punctuation.test(before));
  18850. var rightFlanking = !/\s/.test(before) && (!punctuation.test(before) || /\s/.test(after) || punctuation.test(after));
  18851. var setEm = null,
  18852. setStrong = null;
  18853. if (len % 2) {
  18854. // Em
  18855. if (!state.em && leftFlanking && (ch === '*' || !rightFlanking || punctuation.test(before))) {
  18856. setEm = true;
  18857. } else if (state.em == ch && rightFlanking && (ch === '*' || !leftFlanking || punctuation.test(after))) {
  18858. setEm = false;
  18859. }
  18860. }
  18861. if (len > 1) {
  18862. // Strong
  18863. if (!state.strong && leftFlanking && (ch === '*' || !rightFlanking || punctuation.test(before))) {
  18864. setStrong = true;
  18865. } else if (state.strong == ch && rightFlanking && (ch === '*' || !leftFlanking || punctuation.test(after))) {
  18866. setStrong = false;
  18867. }
  18868. }
  18869. if (setStrong != null || setEm != null) {
  18870. if (modeCfg.highlightFormatting) {
  18871. state.formatting = setEm == null ? 'strong' : setStrong == null ? 'em' : 'strong em';
  18872. }
  18873. if (setEm === true) {
  18874. state.em = ch;
  18875. }
  18876. if (setStrong === true) {
  18877. state.strong = ch;
  18878. }
  18879. var t = getType(state);
  18880. if (setEm === false) {
  18881. state.em = false;
  18882. }
  18883. if (setStrong === false) {
  18884. state.strong = false;
  18885. }
  18886. return t;
  18887. }
  18888. } else if (ch === ' ') {
  18889. if (stream.eat('*') || stream.eat('_')) {
  18890. // Probably surrounded by spaces
  18891. if (stream.peek() === ' ') {
  18892. // Surrounded by spaces, ignore
  18893. return getType(state);
  18894. } else {
  18895. // Not surrounded by spaces, back up pointer
  18896. stream.backUp(1);
  18897. }
  18898. }
  18899. }
  18900. if (modeCfg.strikethrough) {
  18901. if (ch === '~' && stream.eatWhile(ch)) {
  18902. if (state.strikethrough) {
  18903. // Remove strikethrough
  18904. if (modeCfg.highlightFormatting) {
  18905. state.formatting = 'strikethrough';
  18906. }
  18907. var t = getType(state);
  18908. state.strikethrough = false;
  18909. return t;
  18910. } else if (stream.match(/^[^\s]/, false)) {
  18911. // Add strikethrough
  18912. state.strikethrough = true;
  18913. if (modeCfg.highlightFormatting) {
  18914. state.formatting = 'strikethrough';
  18915. }
  18916. return getType(state);
  18917. }
  18918. } else if (ch === ' ') {
  18919. if (stream.match(/^~~/, true)) {
  18920. // Probably surrounded by space
  18921. if (stream.peek() === ' ') {
  18922. // Surrounded by spaces, ignore
  18923. return getType(state);
  18924. } else {
  18925. // Not surrounded by spaces, back up pointer
  18926. stream.backUp(2);
  18927. }
  18928. }
  18929. }
  18930. }
  18931. if (modeCfg.emoji && ch === ':' && stream.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)) {
  18932. state.emoji = true;
  18933. if (modeCfg.highlightFormatting) {
  18934. state.formatting = 'emoji';
  18935. }
  18936. var retType = getType(state);
  18937. state.emoji = false;
  18938. return retType;
  18939. }
  18940. if (ch === ' ') {
  18941. if (stream.match(/^ +$/, false)) {
  18942. state.trailingSpace++;
  18943. } else if (state.trailingSpace) {
  18944. state.trailingSpaceNewLine = true;
  18945. }
  18946. }
  18947. return getType(state);
  18948. }
  18949. function linkInline(stream, state) {
  18950. var ch = stream.next();
  18951. if (ch === '>') {
  18952. state.f = state.inline = inlineNormal;
  18953. if (modeCfg.highlightFormatting) {
  18954. state.formatting = 'link';
  18955. }
  18956. var type = getType(state);
  18957. if (type) {
  18958. type += ' ';
  18959. } else {
  18960. type = '';
  18961. }
  18962. return type + tokenTypes.linkInline;
  18963. }
  18964. stream.match(/^[^>]+/, true);
  18965. return tokenTypes.linkInline;
  18966. }
  18967. function linkHref(stream, state) {
  18968. // Check if space, and return NULL if so (to avoid marking the space)
  18969. if (stream.eatSpace()) {
  18970. return null;
  18971. }
  18972. var ch = stream.next();
  18973. if (ch === '(' || ch === '[') {
  18974. state.f = state.inline = getLinkHrefInside(ch === '(' ? ')' : ']');
  18975. if (modeCfg.highlightFormatting) {
  18976. state.formatting = 'link-string';
  18977. }
  18978. state.linkHref = true;
  18979. return getType(state);
  18980. }
  18981. return 'error';
  18982. }
  18983. var linkRE = {
  18984. ')': /^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,
  18985. ']': /^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/
  18986. };
  18987. function getLinkHrefInside(endChar) {
  18988. return function (stream, state) {
  18989. var ch = stream.next();
  18990. if (ch === endChar) {
  18991. state.f = state.inline = inlineNormal;
  18992. if (modeCfg.highlightFormatting) {
  18993. state.formatting = 'link-string';
  18994. }
  18995. var returnState = getType(state);
  18996. state.linkHref = false;
  18997. return returnState;
  18998. }
  18999. stream.match(linkRE[endChar]);
  19000. state.linkHref = true;
  19001. return getType(state);
  19002. };
  19003. }
  19004. function footnoteLink(stream, state) {
  19005. if (stream.match(/^([^\]\\]|\\.)*\]:/, false)) {
  19006. state.f = footnoteLinkInside;
  19007. stream.next(); // Consume [
  19008. if (modeCfg.highlightFormatting) {
  19009. state.formatting = 'link';
  19010. }
  19011. state.linkText = true;
  19012. return getType(state);
  19013. }
  19014. return switchInline(stream, state, inlineNormal);
  19015. }
  19016. function footnoteLinkInside(stream, state) {
  19017. if (stream.match(/^\]:/, true)) {
  19018. state.f = state.inline = footnoteUrl;
  19019. if (modeCfg.highlightFormatting) {
  19020. state.formatting = 'link';
  19021. }
  19022. var returnType = getType(state);
  19023. state.linkText = false;
  19024. return returnType;
  19025. }
  19026. stream.match(/^([^\]\\]|\\.)+/, true);
  19027. return tokenTypes.linkText;
  19028. }
  19029. function footnoteUrl(stream, state) {
  19030. // Check if space, and return NULL if so (to avoid marking the space)
  19031. if (stream.eatSpace()) {
  19032. return null;
  19033. }
  19034. // Match URL
  19035. stream.match(/^[^\s]+/, true);
  19036. // Check for link title
  19037. if (stream.peek() === undefined) {
  19038. // End of line, set flag to check next line
  19039. state.linkTitle = true;
  19040. } else {
  19041. // More content on line, check if link title
  19042. stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
  19043. }
  19044. state.f = state.inline = inlineNormal;
  19045. return tokenTypes.linkHref + ' url';
  19046. }
  19047. var mode = {
  19048. startState: function startState() {
  19049. return {
  19050. f: blockNormal,
  19051. prevLine: { stream: null },
  19052. thisLine: { stream: null },
  19053. block: blockNormal,
  19054. htmlState: null,
  19055. indentation: 0,
  19056. inline: inlineNormal,
  19057. text: handleText,
  19058. formatting: false,
  19059. linkText: false,
  19060. linkHref: false,
  19061. linkTitle: false,
  19062. code: 0,
  19063. em: false,
  19064. strong: false,
  19065. header: 0,
  19066. setext: 0,
  19067. hr: false,
  19068. taskList: false,
  19069. list: false,
  19070. listStack: [],
  19071. quote: 0,
  19072. trailingSpace: 0,
  19073. trailingSpaceNewLine: false,
  19074. strikethrough: false,
  19075. emoji: false,
  19076. fencedEndRE: null
  19077. };
  19078. },
  19079. copyState: function copyState(s) {
  19080. return {
  19081. f: s.f,
  19082. prevLine: s.prevLine,
  19083. thisLine: s.thisLine,
  19084. block: s.block,
  19085. htmlState: s.htmlState && __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].copyState(htmlMode, s.htmlState),
  19086. indentation: s.indentation,
  19087. localMode: s.localMode,
  19088. localState: s.localMode ? __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].copyState(s.localMode, s.localState) : null,
  19089. inline: s.inline,
  19090. text: s.text,
  19091. formatting: false,
  19092. linkText: s.linkText,
  19093. linkTitle: s.linkTitle,
  19094. linkHref: s.linkHref,
  19095. code: s.code,
  19096. em: s.em,
  19097. strong: s.strong,
  19098. strikethrough: s.strikethrough,
  19099. emoji: s.emoji,
  19100. header: s.header,
  19101. setext: s.setext,
  19102. hr: s.hr,
  19103. taskList: s.taskList,
  19104. list: s.list,
  19105. listStack: s.listStack.slice(0),
  19106. quote: s.quote,
  19107. indentedCode: s.indentedCode,
  19108. trailingSpace: s.trailingSpace,
  19109. trailingSpaceNewLine: s.trailingSpaceNewLine,
  19110. md_inside: s.md_inside,
  19111. fencedEndRE: s.fencedEndRE
  19112. };
  19113. },
  19114. token: function token(stream, state) {
  19115. // Reset state.formatting
  19116. state.formatting = false;
  19117. if (stream != state.thisLine.stream) {
  19118. state.header = 0;
  19119. state.hr = false;
  19120. if (stream.match(/^\s*$/, true)) {
  19121. blankLine(state);
  19122. return null;
  19123. }
  19124. state.prevLine = state.thisLine;
  19125. state.thisLine = { stream: stream };
  19126. // Reset state.taskList
  19127. state.taskList = false;
  19128. // Reset state.trailingSpace
  19129. state.trailingSpace = 0;
  19130. state.trailingSpaceNewLine = false;
  19131. if (!state.localState) {
  19132. state.f = state.block;
  19133. if (state.f != htmlBlock) {
  19134. var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, expandedTab).length;
  19135. state.indentation = indentation;
  19136. state.indentationDiff = null;
  19137. if (indentation > 0) {
  19138. return null;
  19139. }
  19140. }
  19141. }
  19142. }
  19143. return state.f(stream, state);
  19144. },
  19145. innerMode: function innerMode(state) {
  19146. if (state.block == htmlBlock) {
  19147. return { state: state.htmlState, mode: htmlMode };
  19148. }
  19149. if (state.localState) {
  19150. return { state: state.localState, mode: state.localMode };
  19151. }
  19152. return { state: state, mode: mode };
  19153. },
  19154. indent: function indent(state, textAfter, line) {
  19155. if (state.block == htmlBlock && htmlMode.indent) {
  19156. return htmlMode.indent(state.htmlState, textAfter, line);
  19157. }
  19158. if (state.localState && state.localMode.indent) {
  19159. return state.localMode.indent(state.localState, textAfter, line);
  19160. }
  19161. return __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].Pass;
  19162. },
  19163. blankLine: blankLine,
  19164. getType: getType,
  19165. blockCommentStart: '<!--',
  19166. blockCommentEnd: '-->',
  19167. closeBrackets: '()[]{}\'\'""``',
  19168. fold: 'markdown'
  19169. };
  19170. return mode;
  19171. }, 'xml');
  19172. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('text/src', 'markdown');
  19173. __WEBPACK_IMPORTED_MODULE_0__index__["a" /* default */].defineMIME('text/x-src', 'markdown');
  19174. /***/ }),
  19175. /***/ 878:
  19176. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19177. "use strict";
  19178. /* harmony default export */ __webpack_exports__["a"] = ({
  19179. tabSize: 4,
  19180. styleActiveLine: true,
  19181. lineNumbers: true,
  19182. lineWrapping: false,
  19183. line: true,
  19184. mode: 'text/x-src',
  19185. theme: 'default',
  19186. cursorHeight: 0.8,
  19187. lineWiseCopyCut: true
  19188. });
  19189. /***/ }),
  19190. /***/ 879:
  19191. /***/ (function(module, exports, __webpack_require__) {
  19192. // style-loader: Adds some css to the DOM by adding a <style> tag
  19193. // load the styles
  19194. var content = __webpack_require__(880);
  19195. if(typeof content === 'string') content = [[module.i, content, '']];
  19196. // Prepare cssTransformation
  19197. var transform;
  19198. var options = {}
  19199. options.transform = transform
  19200. // add the styles to the DOM
  19201. var update = __webpack_require__(50)(content, options);
  19202. if(content.locals) module.exports = content.locals;
  19203. // Hot Module Replacement
  19204. if(false) {
  19205. // When the styles change, update the <style> tags
  19206. if(!content.locals) {
  19207. module.hot.accept("!!../../../../../../../../../../node_modules/css-loader/index.js!./codemirror.css", function() {
  19208. var newContent = require("!!../../../../../../../../../../node_modules/css-loader/index.js!./codemirror.css");
  19209. if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
  19210. update(newContent);
  19211. });
  19212. }
  19213. // When the module is disposed, remove the <style> tags
  19214. module.hot.dispose(function() { update(); });
  19215. }
  19216. /***/ }),
  19217. /***/ 880:
  19218. /***/ (function(module, exports, __webpack_require__) {
  19219. exports = module.exports = __webpack_require__(0)(false);
  19220. // imports
  19221. // module
  19222. exports.push([module.i, "/* BASICS */\r\n\r\n.CodeMirror {\r\n height: 100%;\r\n color: black;\r\n direction: ltr;\r\n}\r\n\r\n/* PADDING */\r\n\r\n.CodeMirror-lines {\r\n padding: 4px 0;\r\n}\r\n\r\n.CodeMirror pre.CodeMirror-line,\r\n.CodeMirror pre.CodeMirror-line-like {\r\n padding: 0 4px;\r\n padding-left: 8px;\r\n}\r\n\r\n.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {\r\n background-color: white; /* The little square between H and V scrollbars */\r\n}\r\n\r\n/* GUTTER */\r\n\r\n.CodeMirror-gutters {\r\n border-right: 1px solid #ddd;\r\n background-color: #f7f7f7;\r\n white-space: nowrap;\r\n}\r\n\r\n.CodeMirror-linenumbers {\r\n}\r\n\r\n.CodeMirror-linenumber {\r\n padding: 0 5px!important;\r\n min-width: 20px;\r\n text-align: right;\r\n color: #999;\r\n white-space: nowrap;\r\n}\r\n\r\n.CodeMirror-guttermarker {\r\n color: black;\r\n}\r\n\r\n.CodeMirror-guttermarker-subtle {\r\n color: #999;\r\n}\r\n\r\n/* CURSOR */\r\n\r\n.CodeMirror-cursor {\r\n border-left: 1px solid black;\r\n border-right: none;\r\n width: 0;\r\n}\r\n\r\n/* Shown when moving in bi-directional text */\r\n.CodeMirror div.CodeMirror-secondarycursor {\r\n border-left: 1px solid silver;\r\n}\r\n\r\n.cm-fat-cursor .CodeMirror-cursor {\r\n width: auto;\r\n border: 0 !important;\r\n background: #7e7;\r\n}\r\n\r\n.cm-fat-cursor div.CodeMirror-cursors {\r\n z-index: 1;\r\n}\r\n\r\n.cm-fat-cursor-mark {\r\n background-color: rgba(20, 255, 20, 0.5);\r\n -webkit-animation: blink 1.06s steps(1) infinite;\r\n -moz-animation: blink 1.06s steps(1) infinite;\r\n animation: blink 1.06s steps(1) infinite;\r\n}\r\n\r\n.cm-animate-fat-cursor {\r\n width: auto;\r\n border: 0;\r\n -webkit-animation: blink 1.06s steps(1) infinite;\r\n -moz-animation: blink 1.06s steps(1) infinite;\r\n animation: blink 1.06s steps(1) infinite;\r\n background-color: #7e7;\r\n}\r\n\r\n@-moz-keyframes blink {\r\n 0% {\r\n }\r\n 50% {\r\n background-color: transparent;\r\n }\r\n 100% {\r\n }\r\n}\r\n\r\n@-webkit-keyframes blink {\r\n 0% {\r\n }\r\n 50% {\r\n background-color: transparent;\r\n }\r\n 100% {\r\n }\r\n}\r\n\r\n@keyframes blink {\r\n 0% {\r\n }\r\n 50% {\r\n background-color: transparent;\r\n }\r\n 100% {\r\n }\r\n}\r\n\r\n/* Can style cursor different in overwrite (non-insert) mode */\r\n.CodeMirror-overwrite .CodeMirror-cursor {\r\n}\r\n\r\n.cm-tab {\r\n display: inline-block;\r\n text-decoration: inherit;\r\n}\r\n\r\n.CodeMirror-rulers {\r\n position: absolute;\r\n left: 0;\r\n right: 0;\r\n top: -50px;\r\n bottom: 0;\r\n overflow: hidden;\r\n}\r\n\r\n.CodeMirror-ruler {\r\n border-left: 1px solid #ccc;\r\n top: 0;\r\n bottom: 0;\r\n position: absolute;\r\n}\r\n\r\n\r\n/* STOP */\r\n\r\n/* The rest of this file contains styles related to the mechanics of\r\n the src. You probably shouldn't touch them. */\r\n\r\n.CodeMirror {\r\n position: relative;\r\n overflow: hidden;\r\n background: white;\r\n}\r\n\r\n.CodeMirror-scroll {\r\n overflow: scroll !important; /* Things will break if this is overridden */\r\n /* 30px is the magic margin used to hide the element's real scrollbars */\r\n /* See overflow: hidden in .Index */\r\n margin-bottom: -30px;\r\n margin-right: -30px;\r\n padding-bottom: 30px;\r\n height: 100%;\r\n outline: none; /* Prevent dragging from highlighting the element */\r\n position: relative;\r\n}\r\n\r\n.CodeMirror-sizer {\r\n position: relative;\r\n border-right: 30px solid transparent;\r\n}\r\n\r\n/* The fake, visible scrollbars. Used to force redraw during scrolling\r\n before actual scrolling happens, thus preventing shaking and\r\n flickering artifacts. */\r\n.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {\r\n position: absolute;\r\n z-index: 6;\r\n display: none;\r\n}\r\n\r\n.CodeMirror-vscrollbar {\r\n right: 0;\r\n top: 0;\r\n overflow-x: hidden;\r\n overflow-y: scroll;\r\n}\r\n\r\n.CodeMirror-hscrollbar {\r\n bottom: 0;\r\n left: 0;\r\n overflow-y: hidden;\r\n overflow-x: scroll;\r\n}\r\n\r\n.CodeMirror-scrollbar-filler {\r\n right: 0;\r\n bottom: 0;\r\n}\r\n\r\n.CodeMirror-gutter-filler {\r\n left: 0;\r\n bottom: 0;\r\n}\r\n\r\n.CodeMirror-gutters {\r\n position: absolute;\r\n left: 0;\r\n top: 0;\r\n min-height: 100%;\r\n z-index: 3;\r\n}\r\n\r\n.CodeMirror-gutter {\r\n white-space: normal;\r\n height: 100%;\r\n display: inline-block;\r\n vertical-align: top;\r\n margin-bottom: -30px;\r\n}\r\n\r\n.CodeMirror-gutter-wrapper {\r\n position: absolute;\r\n z-index: 4;\r\n background: none !important;\r\n border: none !important;\r\n}\r\n\r\n.CodeMirror-gutter-background {\r\n position: absolute;\r\n top: 0;\r\n bottom: 0;\r\n z-index: 4;\r\n}\r\n\r\n.CodeMirror-gutter-elt {\r\n position: absolute;\r\n cursor: default;\r\n z-index: 4;\r\n}\r\n\r\n.CodeMirror-gutter-wrapper ::selection {\r\n background-color: transparent\r\n}\r\n\r\n.CodeMirror-gutter-wrapper ::-moz-selection {\r\n background-color: transparent\r\n}\r\n\r\n.CodeMirror-lines {\r\n cursor: text;\r\n min-height: 1px; /* prevents collapsing before first draw */\r\n}\r\n\r\n.CodeMirror pre.CodeMirror-line,\r\n.CodeMirror pre.CodeMirror-line-like {\r\n /* Reset some styles that the rest of the page might have set */\r\n -moz-border-radius: 0;\r\n -webkit-border-radius: 0;\r\n border-radius: 0;\r\n border-width: 0;\r\n background: transparent;\r\n font-family: inherit;\r\n font-size: inherit;\r\n margin: 0;\r\n white-space: pre;\r\n word-wrap: normal;\r\n line-height: inherit;\r\n color: inherit;\r\n z-index: 2;\r\n position: relative;\r\n overflow: visible;\r\n -webkit-tap-highlight-color: transparent;\r\n -webkit-font-variant-ligatures: contextual;\r\n font-variant-ligatures: contextual;\r\n}\r\n\r\n.CodeMirror-wrap pre.CodeMirror-line,\r\n.CodeMirror-wrap pre.CodeMirror-line-like {\r\n word-wrap: break-word;\r\n white-space: pre-wrap;\r\n word-break: normal;\r\n}\r\n\r\n.CodeMirror-linebackground {\r\n position: absolute;\r\n left: 0;\r\n right: 0;\r\n top: 0;\r\n bottom: 0;\r\n z-index: 0;\r\n}\r\n\r\n.CodeMirror-linewidget {\r\n position: relative;\r\n z-index: 2;\r\n padding: 0.1px; /* Force widget margins to stay inside of the container */\r\n}\r\n\r\n.CodeMirror-widget {\r\n}\r\n\r\n.CodeMirror-rtl pre {\r\n direction: rtl;\r\n}\r\n\r\n.CodeMirror-code {\r\n outline: none;\r\n}\r\n\r\n/* Force content-box sizing for the elements where we expect it */\r\n.CodeMirror-scroll,\r\n.CodeMirror-sizer,\r\n.CodeMirror-gutter,\r\n.CodeMirror-gutters,\r\n.CodeMirror-linenumber {\r\n -moz-box-sizing: content-box;\r\n box-sizing: content-box;\r\n}\r\n\r\n.CodeMirror-measure {\r\n position: absolute;\r\n width: 100%;\r\n height: 0;\r\n overflow: hidden;\r\n visibility: hidden;\r\n}\r\n\r\n.CodeMirror-cursor {\r\n position: absolute;\r\n pointer-events: none;\r\n}\r\n\r\n.CodeMirror-measure pre {\r\n position: static;\r\n}\r\n\r\ndiv.CodeMirror-cursors {\r\n visibility: hidden;\r\n position: relative;\r\n z-index: 3;\r\n}\r\n\r\ndiv.CodeMirror-dragcursors {\r\n visibility: visible;\r\n}\r\n\r\n.CodeMirror-focused div.CodeMirror-cursors {\r\n visibility: visible;\r\n}\r\n\r\n.CodeMirror-selected {\r\n background: #d9d9d9;\r\n}\r\n\r\n.CodeMirror-focused .CodeMirror-selected {\r\n background: #d7d4f0;\r\n}\r\n\r\n.CodeMirror-crosshair {\r\n cursor: crosshair;\r\n}\r\n\r\n.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection {\r\n background: #d7d4f0;\r\n}\r\n\r\n.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection {\r\n background: #d7d4f0;\r\n}\r\n\r\n.cm-searching {\r\n background-color: #ffa;\r\n background-color: rgba(255, 255, 0, .4);\r\n}\r\n\r\n/* Used to force a border model for a node */\r\n.cm-force-border {\r\n padding-right: .1px;\r\n}\r\n\r\n@media print {\r\n /* Hide the cursor when printing */\r\n .CodeMirror div.CodeMirror-cursors {\r\n visibility: hidden;\r\n }\r\n}\r\n\r\n/* See issue #2901 */\r\n.cm-tab-wrap-hack:after {\r\n content: '';\r\n}\r\n\r\n/* Help users use markselection to safely style text background */\r\nspan.CodeMirror-selectedtext {\r\n background: none;\r\n}\r\n\r\n\r\n.cm-negative {\r\n color: #d44;\r\n}\r\n\r\n.cm-positive {\r\n color: #292;\r\n}\r\n\r\n.cm-header, .cm-strong {\r\n font-weight: bold;\r\n}\r\n\r\n.cm-em {\r\n font-style: italic;\r\n}\r\n\r\n\r\n.cm-strikethrough {\r\n text-decoration: line-through;\r\n}\r\n\r\n.cm-invalidchar {\r\n color: #f00;\r\n}\r\n\r\n.CodeMirror-composing {\r\n border-bottom: 2px solid;\r\n}\r\n\r\n/* Default styles for common addons */\r\n\r\ndiv.CodeMirror span.CodeMirror-matchingbracket {\r\n color: #0b0;\r\n}\r\n\r\ndiv.CodeMirror span.CodeMirror-nonmatchingbracket {\r\n color: #a22;\r\n}\r\n\r\n.CodeMirror-matchingtag {\r\n background: rgba(255, 150, 0, .3);\r\n}\r\n\r\n.CodeMirror-activeline-background {\r\n background: #e8f2ff;\r\n}\r\n\r\n/* DEFAULT THEME */\r\n\r\n.cm-s-default.CodeMirror,\r\n.cm-s-default .CodeMirror-gutters {\r\n background-color: #282a36 !important;\r\n color: #f8f8f2 !important;\r\n border: none;\r\n font-family: Menlo, Consolas, \"Courier New\", Courier, FreeMono, monospace !important;\r\n\r\n}\r\n\r\n.cm-s-default * {\r\n line-height: 1.6 !important;\r\n font-size: 14px;\r\n font-family: Menlo, Consolas, \"Courier New\", Courier, FreeMono, monospace !important;\r\n color: #ccc;\r\n}\r\n\r\n.cm-s-default .CodeMirror-gutters {\r\n color: #282a36;\r\n}\r\n\r\n.cm-s-default .CodeMirror-cursor {\r\n border-left: solid thin #f8f8f0;\r\n}\r\n\r\n.cm-s-default .CodeMirror-selected {\r\n background: rgba(255, 255, 255, 0.10);\r\n}\r\n\r\n.cm-s-default .CodeMirror-line::selection,\r\n.cm-s-default .CodeMirror-line > span::selection,\r\n.cm-s-default .CodeMirror-line > span > span::selection {\r\n background: rgba(255, 255, 255, 0.10);\r\n}\r\n\r\n.cm-s-default .CodeMirror-line::-moz-selection,\r\n.cm-s-default .CodeMirror-line > span::-moz-selection,\r\n.cm-s-default .CodeMirror-line > span > span::-moz-selection {\r\n background: rgba(255, 255, 255, 0.10);\r\n}\r\n\r\n.cm-s-default span.cm-comment {\r\n color: #999;\r\n}\r\n\r\n.cm-s-default span.cm-string,\r\n.cm-s-default span.cm-string-2 {\r\n color: #ce9178;\r\n}\r\n\r\n.cm-s-default span.cm-number {\r\n color: #bd93f9;\r\n}\r\n\r\n.cm-s-default span.cm-variable {\r\n color: #61afef;\r\n}\r\n\r\n.cm-s-default span.cm-variable-2 {\r\n color: #61afef;\r\n}\r\n\r\n.cm-s-default span.cm-def {\r\n color: #e0e2e4;\r\n}\r\n\r\n.cm-s-default span.cm-operator {\r\n color: #e0e2e4;\r\n}\r\n\r\n.cm-s-default span.cm-keyword {\r\n color: #c678dd;\r\n}\r\n\r\n.cm-s-default span.cm-atom {\r\n color: #bd93f9;\r\n}\r\n\r\n.cm-s-default span.cm-meta {\r\n color: #f8f8f2;\r\n}\r\n\r\n.cm-s-default span.cm-tag {\r\n color: #569cd6;\r\n}\r\n\r\n.cm-s-default span.cm-attribute {\r\n color: #9cdcfe;\r\n}\r\n\r\n.cm-s-default span.cm-qualifier {\r\n color: #9cdcfe;\r\n}\r\n\r\n.cm-s-default span.cm-property {\r\n color: #dcdcaa;\r\n}\r\n\r\n.cm-s-default span.cm-builtin {\r\n color: #50fa7b;\r\n}\r\n\r\n.cm-s-default span.cm-variable-3,\r\n.cm-s-default span.cm-type {\r\n color: #ffb86c;\r\n}\r\n\r\n.cm-s-default .CodeMirror-activeline-background {\r\n background: rgba(255, 255, 255, 0.1);\r\n}\r\n\r\n.cm-s-default .CodeMirror-matchingbracket {\r\n text-decoration: underline;\r\n color: white !important;\r\n}\r\n\r\n.cm-s-default .cm-header {\r\n color: #fff;\r\n}\r\n\r\n.cm-s-default .CodeMirror-gutter {\r\n background: #22252b;\r\n padding-right: 2px;\r\n}\r\n\r\n.cm-link {\r\n text-decoration: underline;\r\n color: #569cd6;\r\n}\r\n.cm-url{\r\n color: #9cdcfe!important;\r\n}\r\n", ""]);
  19223. // exports
  19224. /***/ }),
  19225. /***/ 881:
  19226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19227. "use strict";
  19228. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils__ = __webpack_require__(882);
  19229. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__config_tools__ = __webpack_require__(883);
  19230. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  19231. /* harmony default export */ __webpack_exports__["a"] = ({
  19232. name: 'markdown',
  19233. props: {
  19234. value: {
  19235. type: [String, Number],
  19236. default: ''
  19237. },
  19238. theme: { // 默认主题
  19239. type: String,
  19240. default: 'light'
  19241. },
  19242. width: { // 初始化宽度
  19243. type: [Number, String],
  19244. default: 'auto'
  19245. },
  19246. height: { // 初始化高度
  19247. type: [Number, String],
  19248. default: 600
  19249. },
  19250. toolbars: { // 工具栏
  19251. type: Object,
  19252. default: function _default() {
  19253. return {};
  19254. }
  19255. },
  19256. bordered: { //是否有边框
  19257. type: Boolean,
  19258. default: true
  19259. },
  19260. autoSave: { // 是否自动保存
  19261. type: Boolean,
  19262. default: false
  19263. },
  19264. interval: { // 自动保存间隔 mm
  19265. type: Number,
  19266. default: 10000
  19267. },
  19268. exportFileName: { // 默认导出文件名称
  19269. type: String,
  19270. default: 'unnamed'
  19271. },
  19272. markedOptions: { //marked.js配置项
  19273. type: Object,
  19274. default: function _default() {
  19275. return {};
  19276. }
  19277. },
  19278. copyCode: { // 复制代码
  19279. type: Boolean,
  19280. default: true
  19281. },
  19282. copyBtnText: { // 复制代码按钮文字
  19283. type: String,
  19284. default: '复制代码'
  19285. },
  19286. isPreview: { //是否是预览模式
  19287. type: Boolean,
  19288. default: false
  19289. },
  19290. isCustomFullscreen: { //是否全部(自定义参数)
  19291. type: Boolean,
  19292. default: false
  19293. }
  19294. },
  19295. data: function data() {
  19296. return {
  19297. currentValue: '', // 输入框内容
  19298. timeoutId: null,
  19299. indexLenth: 1,
  19300. html: '', // 预览的html
  19301. preview: false, // 是否是预览状态
  19302. split: true, //分屏显示
  19303. fullscreen: false, // 是否是全屏
  19304. scrollSide: '', // 哪个半栏在滑动
  19305. lastInsert: '', //最后一次插入的内容
  19306. timerId: null, // 定时器id
  19307. themeName: '',
  19308. themeSlideDown: false,
  19309. imgSlideDown: false,
  19310. imgs: [],
  19311. scrolling: true, // 同步滚动
  19312. editorScrollHeight: 0,
  19313. previewImgModal: false,
  19314. previewImgSrc: '',
  19315. previewImgMode: ''
  19316. };
  19317. },
  19318. computed: {
  19319. tools: function tools() {
  19320. var _toolbars = this.toolbars,
  19321. toolbars = _toolbars === undefined ? {} : _toolbars;
  19322. return _extends({}, __WEBPACK_IMPORTED_MODULE_1__config_tools__["a" /* default */], toolbars);
  19323. }
  19324. },
  19325. methods: {
  19326. insertLink: function insertLink() {
  19327. // 插入链接
  19328. this.insertContent('\n[link](href)');
  19329. },
  19330. insertImage: function insertImage() {
  19331. // 插入图片
  19332. this.insertContent('\n![image](imgUrl)');
  19333. },
  19334. insertTable: function insertTable() {
  19335. // 插入表格
  19336. this.insertContent('\nheader 1 | header 2\n---|---\nrow 1 col 1 | row 1 col 2\nrow 2 col 1 | row 2 col 2\n\n');
  19337. },
  19338. handleSave: function handleSave() {
  19339. // 保存操作
  19340. var currentValue = this.currentValue,
  19341. themeName = this.themeName,
  19342. html = this.html;
  19343. this.$emit('on-save', {
  19344. theme: themeName,
  19345. value: currentValue,
  19346. html: html
  19347. });
  19348. },
  19349. toggleSlideDown: function toggleSlideDown() {
  19350. // 显示主题选项
  19351. this.slideDown = !this.slideDown;
  19352. },
  19353. setThemes: function setThemes(name) {
  19354. // 设置主题
  19355. this.themeName = name;
  19356. this.themeSlideDown = false;
  19357. this.$emit('on-theme-change', name);
  19358. },
  19359. exportFile: function exportFile() {
  19360. // 导出为.md格式
  19361. Object(__WEBPACK_IMPORTED_MODULE_0__utils__["a" /* saveFile */])(this.currentValue, this.exportFileName + '.md');
  19362. },
  19363. importFile: function importFile(e) {
  19364. var _this = this;
  19365. // 导入本地文件
  19366. var file = e.target.files[0];
  19367. if (!file) {
  19368. return;
  19369. }
  19370. var type = file.type;
  19371. if (!['text/markdown', 'text/src'].includes(type)) {
  19372. return;
  19373. }
  19374. var reader = new FileReader();
  19375. reader.readAsText(file, {
  19376. encoding: 'utf-8'
  19377. });
  19378. reader.onload = function () {
  19379. _this.currentValue = reader.result;
  19380. e.target.value = '';
  19381. if (_this.pro) {
  19382. // 专业版,手动set value
  19383. _this.editor.setOption('value', _this.currentValue);
  19384. }
  19385. };
  19386. reader.onerror = function (err) {
  19387. console.error(err);
  19388. };
  19389. },
  19390. handlePaste: function handlePaste(_, e) {
  19391. // 粘贴图片
  19392. var _e$clipboardData = e.clipboardData,
  19393. clipboardData = _e$clipboardData === undefined ? {} : _e$clipboardData;
  19394. var _clipboardData$types = clipboardData.types,
  19395. types = _clipboardData$types === undefined ? [] : _clipboardData$types,
  19396. items = clipboardData.items;
  19397. var item = null;
  19398. for (var i = 0; i < types.length; i++) {
  19399. if (types[i] === 'Files') {
  19400. item = items[i];
  19401. break;
  19402. }
  19403. }
  19404. if (item) {
  19405. var file = item.getAsFile();
  19406. if (/image/gi.test(file.type)) {
  19407. this.$emit('on-upload-image', file);
  19408. e.preventDefault();
  19409. }
  19410. }
  19411. },
  19412. mousescrollSide: function mousescrollSide(side) {
  19413. // 设置究竟是哪个半边在主动滑动
  19414. this.scrollSide = side;
  19415. },
  19416. addImageClickListener: function addImageClickListener() {
  19417. var _this2 = this;
  19418. // 监听查看大图
  19419. var _imgs = this.imgs,
  19420. imgs = _imgs === undefined ? [] : _imgs;
  19421. if (imgs.length > 0) {
  19422. for (var i = 0, len = imgs.length; i < len; i++) {
  19423. imgs[i].onclick = null;
  19424. }
  19425. }
  19426. setTimeout(function () {
  19427. _this2.imgs = _this2.$refs.preview.querySelectorAll('img');
  19428. var _loop = function _loop(_i, _len) {
  19429. _this2.imgs[_i].onclick = function () {
  19430. var src = _this2.imgs[_i].getAttribute('src');
  19431. _this2.previewImage(src);
  19432. };
  19433. };
  19434. for (var _i = 0, _len = _this2.imgs.length; _i < _len; _i++) {
  19435. _loop(_i, _len);
  19436. }
  19437. }, 600);
  19438. },
  19439. previewImage: function previewImage(src) {
  19440. var _this3 = this;
  19441. // 预览图片
  19442. var img = new Image();
  19443. img.src = src;
  19444. img.onload = function () {
  19445. var width = img.naturalWidth;
  19446. var height = img.naturalHeight;
  19447. if (height / width > 1.4) {
  19448. _this3.previewImgMode = 'horizontal';
  19449. } else {
  19450. _this3.previewImgMode = 'vertical';
  19451. }
  19452. _this3.previewImgSrc = src;
  19453. _this3.previewImgModal = true;
  19454. };
  19455. },
  19456. chooseImage: function chooseImage() {
  19457. var _this4 = this;
  19458. // 选择图片
  19459. var input = document.createElement('input');
  19460. input.type = 'file';
  19461. input.accept = 'image/*';
  19462. input.onchange = function () {
  19463. var files = input.files;
  19464. if (files[0]) {
  19465. _this4.$emit('on-upload-image', files[0]);
  19466. input.value = '';
  19467. }
  19468. };
  19469. input.click();
  19470. },
  19471. addCopyListener: function addCopyListener() {
  19472. var _this5 = this;
  19473. // 监听复制操作
  19474. setTimeout(function () {
  19475. var btns = document.querySelectorAll('.code-block .copy-code');
  19476. _this5.btns = btns;
  19477. var _loop2 = function _loop2(i, len) {
  19478. btns[i].onclick = function () {
  19479. var code = btns[i].parentNode.querySelectorAll('pre')[0].innerText;
  19480. var aux = document.createElement('input');
  19481. aux.setAttribute('value', code);
  19482. document.body.appendChild(aux);
  19483. aux.select();
  19484. document.execCommand('copy');
  19485. document.body.removeChild(aux);
  19486. _this5.$emit('on-copy', code);
  19487. };
  19488. };
  19489. for (var i = 0, len = btns.length; i < len; i++) {
  19490. _loop2(i, len);
  19491. }
  19492. }, 600);
  19493. },
  19494. /**
  19495. * 自定义事件
  19496. * @param act
  19497. */
  19498. onCustom: function onCustom(act) {
  19499. this.$emit('on-custom', act);
  19500. }
  19501. },
  19502. destroyed: function destroyed() {
  19503. // 销毁时清除定时器
  19504. clearInterval(this.timerId);
  19505. }
  19506. });
  19507. /***/ }),
  19508. /***/ 882:
  19509. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19510. "use strict";
  19511. /* harmony export (immutable) */ __webpack_exports__["a"] = saveFile;
  19512. /*
  19513. * 保存文件到本地
  19514. * */
  19515. function saveFile(fileData, name) {
  19516. var pom = document.createElement('a');
  19517. pom.setAttribute('href', 'data:text/plain;charset=UTF-8,' + encodeURIComponent(fileData));
  19518. pom.setAttribute('download', name);
  19519. pom.style.display = 'none';
  19520. if (document.createEvent) {
  19521. var event = document.createEvent('MouseEvents');
  19522. event.initEvent('click', true, true);
  19523. pom.dispatchEvent(event);
  19524. } else {
  19525. pom.click();
  19526. }
  19527. }
  19528. /***/ }),
  19529. /***/ 883:
  19530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19531. "use strict";
  19532. /*
  19533. * 默认头部菜单配置
  19534. * */
  19535. /* harmony default export */ __webpack_exports__["a"] = ({
  19536. strong: true,
  19537. italic: true,
  19538. overline: true,
  19539. h1: true,
  19540. h2: true,
  19541. h3: true,
  19542. h4: false,
  19543. h5: false,
  19544. h6: false,
  19545. hr: true,
  19546. quote: true,
  19547. ul: true,
  19548. ol: true,
  19549. code: true,
  19550. link: true,
  19551. image: true,
  19552. uploadImage: false,
  19553. custom_image: false,
  19554. custom_uploadImage: false,
  19555. custom_uploadFile: false,
  19556. table: true,
  19557. checked: true,
  19558. notChecked: true,
  19559. split: true,
  19560. preview: true,
  19561. fullscreen: true,
  19562. theme: true,
  19563. exportmd: true,
  19564. importmd: true,
  19565. save: false,
  19566. clear: false
  19567. });
  19568. /***/ }),
  19569. /***/ 884:
  19570. /***/ (function(module, exports, __webpack_require__) {
  19571. var render = function() {
  19572. var _vm = this
  19573. var _h = _vm.$createElement
  19574. var _c = _vm._self._c || _h
  19575. return _c(
  19576. "div",
  19577. {
  19578. ref: "markdown",
  19579. class:
  19580. "markdown " +
  19581. (_vm.fullscreen ? "fullscreen" : "") +
  19582. " " +
  19583. (_vm.bordered ? "border" : ""),
  19584. style: {
  19585. width: _vm.width + (typeof _vm.width === "string" ? "" : "px"),
  19586. height: _vm.height + (typeof _vm.height === "string" ? "" : "px")
  19587. }
  19588. },
  19589. [
  19590. _c(
  19591. "ul",
  19592. {
  19593. directives: [
  19594. {
  19595. name: "show",
  19596. rawName: "v-show",
  19597. value: !_vm.preview,
  19598. expression: "!preview"
  19599. }
  19600. ],
  19601. staticClass: "markdown-toolbars"
  19602. },
  19603. [
  19604. _c("li", [_vm._t("title")], 2),
  19605. _vm._v(" "),
  19606. _vm.tools.undo
  19607. ? _c("li", { attrs: { name: "撤销" } }, [
  19608. _c("span", {
  19609. staticClass: "iconfont icon-undo",
  19610. on: {
  19611. click: function($event) {
  19612. return _vm.editor.undo()
  19613. }
  19614. }
  19615. })
  19616. ])
  19617. : _vm._e(),
  19618. _vm._v(" "),
  19619. _vm.tools.redo
  19620. ? _c("li", { attrs: { name: "重做" }, on: { click: _vm.redo } }, [
  19621. _c("span", { staticClass: "iconfont icon-redo" })
  19622. ])
  19623. : _vm._e(),
  19624. _vm._v(" "),
  19625. _vm.tools.strong
  19626. ? _c("li", { attrs: { name: "粗体" } }, [
  19627. _c("span", {
  19628. staticClass: "iconfont icon-bold",
  19629. on: { click: _vm.insertStrong }
  19630. })
  19631. ])
  19632. : _vm._e(),
  19633. _vm._v(" "),
  19634. _vm.tools.italic
  19635. ? _c("li", { attrs: { name: "斜体" } }, [
  19636. _c("span", {
  19637. staticClass: "iconfont icon-italic",
  19638. on: { click: _vm.insertItalic }
  19639. })
  19640. ])
  19641. : _vm._e(),
  19642. _vm._v(" "),
  19643. _vm.tools.overline
  19644. ? _c("li", { attrs: { name: "删除线" } }, [
  19645. _c("span", {
  19646. staticClass: "iconfont icon-overline",
  19647. on: { click: _vm.insertOverline }
  19648. })
  19649. ])
  19650. : _vm._e(),
  19651. _vm._v(" "),
  19652. _vm.tools.overline
  19653. ? _c("li", { attrs: { name: "下划线" } }, [
  19654. _c("span", {
  19655. staticClass: "iconfont icon-under-line",
  19656. on: { click: _vm.insertUnderline }
  19657. })
  19658. ])
  19659. : _vm._e(),
  19660. _vm._v(" "),
  19661. _vm.tools.h1
  19662. ? _c("li", { attrs: { name: "标题1" } }, [
  19663. _c(
  19664. "span",
  19665. {
  19666. staticStyle: { "font-size": "16px" },
  19667. on: {
  19668. click: function($event) {
  19669. return _vm.insertTitle(1)
  19670. }
  19671. }
  19672. },
  19673. [_vm._v("h1")]
  19674. )
  19675. ])
  19676. : _vm._e(),
  19677. _vm._v(" "),
  19678. _vm.tools.h2
  19679. ? _c("li", { attrs: { name: "标题2" } }, [
  19680. _c(
  19681. "span",
  19682. {
  19683. staticStyle: { "font-size": "16px" },
  19684. on: {
  19685. click: function($event) {
  19686. return _vm.insertTitle(2)
  19687. }
  19688. }
  19689. },
  19690. [_vm._v("h2")]
  19691. )
  19692. ])
  19693. : _vm._e(),
  19694. _vm._v(" "),
  19695. _vm.tools.h3
  19696. ? _c("li", { attrs: { name: "标题3" } }, [
  19697. _c(
  19698. "span",
  19699. {
  19700. staticStyle: { "font-size": "16px" },
  19701. on: {
  19702. click: function($event) {
  19703. return _vm.insertTitle(3)
  19704. }
  19705. }
  19706. },
  19707. [_vm._v("h3")]
  19708. )
  19709. ])
  19710. : _vm._e(),
  19711. _vm._v(" "),
  19712. _vm.tools.h4
  19713. ? _c("li", { attrs: { name: "标题4" } }, [
  19714. _c(
  19715. "span",
  19716. {
  19717. staticStyle: { "font-size": "16px" },
  19718. on: {
  19719. click: function($event) {
  19720. return _vm.insertTitle(4)
  19721. }
  19722. }
  19723. },
  19724. [_vm._v("h4")]
  19725. )
  19726. ])
  19727. : _vm._e(),
  19728. _vm._v(" "),
  19729. _vm.tools.h5
  19730. ? _c("li", { attrs: { name: "标题5" } }, [
  19731. _c(
  19732. "span",
  19733. {
  19734. staticStyle: { "font-size": "16px" },
  19735. on: {
  19736. click: function($event) {
  19737. return _vm.insertTitle(5)
  19738. }
  19739. }
  19740. },
  19741. [_vm._v("h5")]
  19742. )
  19743. ])
  19744. : _vm._e(),
  19745. _vm._v(" "),
  19746. _vm.tools.h6
  19747. ? _c("li", { attrs: { name: "标题6" } }, [
  19748. _c(
  19749. "span",
  19750. {
  19751. staticStyle: { "font-size": "16px" },
  19752. on: {
  19753. click: function($event) {
  19754. return _vm.insertTitle(6)
  19755. }
  19756. }
  19757. },
  19758. [_vm._v("h6")]
  19759. )
  19760. ])
  19761. : _vm._e(),
  19762. _vm._v(" "),
  19763. _vm.tools.hr
  19764. ? _c("li", { attrs: { name: "分割线" } }, [
  19765. _c("span", {
  19766. staticClass: "iconfont icon-horizontal",
  19767. on: { click: _vm.insertLine }
  19768. })
  19769. ])
  19770. : _vm._e(),
  19771. _vm._v(" "),
  19772. _vm.tools.quote
  19773. ? _c("li", { attrs: { name: "引用" } }, [
  19774. _c("span", {
  19775. staticClass: "iconfont icon-quote",
  19776. staticStyle: { "font-size": "16px" },
  19777. on: { click: _vm.insertQuote }
  19778. })
  19779. ])
  19780. : _vm._e(),
  19781. _vm._v(" "),
  19782. _vm.tools.ul
  19783. ? _c("li", { attrs: { name: "无序列表" } }, [
  19784. _c("span", {
  19785. staticClass: "iconfont icon-ul",
  19786. on: { click: _vm.insertUl }
  19787. })
  19788. ])
  19789. : _vm._e(),
  19790. _vm._v(" "),
  19791. _vm.tools.ol
  19792. ? _c("li", { attrs: { name: "有序列表" } }, [
  19793. _c("span", {
  19794. staticClass: "iconfont icon-ol",
  19795. on: { click: _vm.insertOl }
  19796. })
  19797. ])
  19798. : _vm._e(),
  19799. _vm._v(" "),
  19800. _vm.tools.code
  19801. ? _c("li", { attrs: { name: "代码块" } }, [
  19802. _c("span", {
  19803. staticClass: "iconfont icon-code",
  19804. on: { click: _vm.insertCode }
  19805. })
  19806. ])
  19807. : _vm._e(),
  19808. _vm._v(" "),
  19809. _vm.tools.notChecked
  19810. ? _c("li", { attrs: { name: "未完成列表" } }, [
  19811. _c("span", {
  19812. staticClass: "iconfont icon-checked-false",
  19813. on: { click: _vm.insertNotFinished }
  19814. })
  19815. ])
  19816. : _vm._e(),
  19817. _vm._v(" "),
  19818. _vm.tools.checked
  19819. ? _c("li", { attrs: { name: "已完成列表" } }, [
  19820. _c("span", {
  19821. staticClass: "iconfont icon-checked",
  19822. on: { click: _vm.insertFinished }
  19823. })
  19824. ])
  19825. : _vm._e(),
  19826. _vm._v(" "),
  19827. _vm.tools.link
  19828. ? _c("li", { attrs: { name: "链接" } }, [
  19829. _c("span", {
  19830. staticClass: "iconfont icon-link",
  19831. on: { click: _vm.insertLink }
  19832. })
  19833. ])
  19834. : _vm._e(),
  19835. _vm._v(" "),
  19836. _vm.tools.image
  19837. ? _c("li", { attrs: { name: "图片" } }, [
  19838. _c("span", {
  19839. staticClass: "iconfont icon-img",
  19840. on: { click: _vm.insertImage }
  19841. })
  19842. ])
  19843. : _vm._e(),
  19844. _vm._v(" "),
  19845. _vm.tools.uploadImage
  19846. ? _c("li", { attrs: { name: "本地图片" } }, [
  19847. _c("span", {
  19848. staticClass: "iconfont icon-upload-img",
  19849. on: { click: _vm.chooseImage }
  19850. })
  19851. ])
  19852. : _vm._e(),
  19853. _vm._v(" "),
  19854. _vm.tools.custom_image
  19855. ? _c("li", { attrs: { name: "浏览图片" } }, [
  19856. _c("span", {
  19857. staticClass: "iconfont icon-img",
  19858. on: {
  19859. click: function($event) {
  19860. return _vm.onCustom("image-browse")
  19861. }
  19862. }
  19863. })
  19864. ])
  19865. : _vm._e(),
  19866. _vm._v(" "),
  19867. _vm.tools.custom_uploadImage
  19868. ? _c("li", { attrs: { name: "上传图片" } }, [
  19869. _c("span", {
  19870. staticClass: "iconfont icon-upload-img",
  19871. on: {
  19872. click: function($event) {
  19873. return _vm.onCustom("image-upload")
  19874. }
  19875. }
  19876. })
  19877. ])
  19878. : _vm._e(),
  19879. _vm._v(" "),
  19880. _vm.tools.custom_uploadFile
  19881. ? _c("li", { attrs: { name: "上传文件" } }, [
  19882. _c(
  19883. "span",
  19884. {
  19885. staticClass: "icon-svg",
  19886. on: {
  19887. click: function($event) {
  19888. return _vm.onCustom("file-upload")
  19889. }
  19890. }
  19891. },
  19892. [
  19893. _c(
  19894. "svg",
  19895. {
  19896. staticClass: "icon",
  19897. attrs: {
  19898. t: "1599285632421",
  19899. viewBox: "0 0 1024 1024",
  19900. version: "1.1",
  19901. xmlns: "http://www.w3.org/2000/svg",
  19902. "p-id": "45640",
  19903. width: "16",
  19904. height: "16"
  19905. }
  19906. },
  19907. [
  19908. _c("path", {
  19909. attrs: {
  19910. d:
  19911. "M127.519 892.879v-763.34h655.448V514.69h63.612V81.831c0-8.783-7.12-15.903-15.903-15.903H79.81c-8.783 0-15.903 7.12-15.903 15.903v858.757c0 8.783 7.12 15.903 15.903 15.903h493.993v-63.612H127.519z",
  19912. fill: "#999999",
  19913. "p-id": "45641"
  19914. }
  19915. }),
  19916. _c("path", {
  19917. attrs: {
  19918. d:
  19919. "M231.608 228.388h447.269V292H231.608zM231.608 384.409h447.269v63.612H231.608zM231.608 540.43h245.141v63.612H231.608zM231.608 696.451h245.141v63.612H231.608zM923.269 762.938L745.315 584.984c-3.545-3.545-8.34-5.074-12.966-4.596a15.931 15.931 0 0 0-9.848 4.616L544.586 762.918c-6.248 6.248-6.248 16.379 0 22.627l22.353 22.353c6.248 6.248 16.379 6.248 22.627 0l112.555-112.555v245.148c0 8.837 7.163 16 16 16h31.612c8.837 0 16-7.163 16-16V695.363l112.555 112.555c6.248 6.248 16.379 6.248 22.627 0l22.353-22.353c6.249-6.248 6.249-16.378 0.001-22.627z",
  19920. fill: "#999999",
  19921. "p-id": "45642"
  19922. }
  19923. })
  19924. ]
  19925. )
  19926. ]
  19927. )
  19928. ])
  19929. : _vm._e(),
  19930. _vm._v(" "),
  19931. _vm.tools.table
  19932. ? _c("li", { attrs: { name: "表格" } }, [
  19933. _c("span", {
  19934. staticClass: "iconfont icon-table",
  19935. on: { click: _vm.insertTable }
  19936. })
  19937. ])
  19938. : _vm._e(),
  19939. _vm._v(" "),
  19940. _vm.tools.theme
  19941. ? _c(
  19942. "li",
  19943. { staticClass: "shift-theme", attrs: { name: "代码块主题" } },
  19944. [
  19945. _c("div", [
  19946. _c("span", {
  19947. staticClass: "iconfont icon-theme",
  19948. on: {
  19949. click: function($event) {
  19950. _vm.themeSlideDown = !_vm.themeSlideDown
  19951. }
  19952. }
  19953. }),
  19954. _vm._v(" "),
  19955. _c(
  19956. "ul",
  19957. {
  19958. class: { active: _vm.themeSlideDown },
  19959. on: {
  19960. mouseleave: function($event) {
  19961. _vm.themeSlideDown = false
  19962. }
  19963. }
  19964. },
  19965. [
  19966. _c(
  19967. "li",
  19968. {
  19969. on: {
  19970. click: function($event) {
  19971. return _vm.setThemes("light")
  19972. }
  19973. }
  19974. },
  19975. [_vm._v("Light")]
  19976. ),
  19977. _vm._v(" "),
  19978. _c(
  19979. "li",
  19980. {
  19981. on: {
  19982. click: function($event) {
  19983. return _vm.setThemes("dark")
  19984. }
  19985. }
  19986. },
  19987. [_vm._v("VS Code")]
  19988. ),
  19989. _vm._v(" "),
  19990. _c(
  19991. "li",
  19992. {
  19993. on: {
  19994. click: function($event) {
  19995. return _vm.setThemes("oneDark")
  19996. }
  19997. }
  19998. },
  19999. [_vm._v("Atom OneDark")]
  20000. ),
  20001. _vm._v(" "),
  20002. _c(
  20003. "li",
  20004. {
  20005. on: {
  20006. click: function($event) {
  20007. return _vm.setThemes("gitHub")
  20008. }
  20009. }
  20010. },
  20011. [_vm._v("GitHub")]
  20012. )
  20013. ]
  20014. )
  20015. ])
  20016. ]
  20017. )
  20018. : _vm._e(),
  20019. _vm._v(" "),
  20020. _c(
  20021. "li",
  20022. {
  20023. directives: [
  20024. {
  20025. name: "show",
  20026. rawName: "v-show",
  20027. value: _vm.tools.importmd,
  20028. expression: "tools.importmd"
  20029. }
  20030. ],
  20031. staticClass: "import-file",
  20032. attrs: { name: "导入文件" }
  20033. },
  20034. [
  20035. _c("span", {
  20036. staticClass: "iconfont icon-daoru",
  20037. on: { click: _vm.importFile }
  20038. }),
  20039. _vm._v(" "),
  20040. _c("input", {
  20041. attrs: { type: "file", accept: "text/markdown" },
  20042. on: {
  20043. change: function($event) {
  20044. return _vm.importFile($event)
  20045. }
  20046. }
  20047. })
  20048. ]
  20049. ),
  20050. _vm._v(" "),
  20051. _c(
  20052. "li",
  20053. {
  20054. directives: [
  20055. {
  20056. name: "show",
  20057. rawName: "v-show",
  20058. value: _vm.tools.exportmd,
  20059. expression: "tools.exportmd"
  20060. }
  20061. ],
  20062. attrs: { name: "保存到本地" }
  20063. },
  20064. [
  20065. _c("span", {
  20066. staticClass: "iconfont icon-download",
  20067. on: { click: _vm.exportFile }
  20068. })
  20069. ]
  20070. ),
  20071. _vm._v(" "),
  20072. _vm.tools.split && _vm.split
  20073. ? _c("li", { attrs: { name: "全屏编辑" } }, [
  20074. _c("span", {
  20075. staticClass: "iconfont icon-md",
  20076. on: {
  20077. click: function($event) {
  20078. _vm.split = false
  20079. }
  20080. }
  20081. })
  20082. ])
  20083. : _vm._e(),
  20084. _vm._v(" "),
  20085. _vm.tools.split && !_vm.split
  20086. ? _c("li", { attrs: { name: "分屏显示" } }, [
  20087. _c("span", {
  20088. staticClass: "iconfont icon-group",
  20089. on: {
  20090. click: function($event) {
  20091. _vm.split = true
  20092. }
  20093. }
  20094. })
  20095. ])
  20096. : _vm._e(),
  20097. _vm._v(" "),
  20098. _vm.tools.preview
  20099. ? _c("li", { attrs: { name: "预览" } }, [
  20100. _c("span", {
  20101. staticClass: "iconfont icon-preview",
  20102. on: {
  20103. click: function($event) {
  20104. _vm.preview = true
  20105. }
  20106. }
  20107. })
  20108. ])
  20109. : _vm._e(),
  20110. _vm._v(" "),
  20111. _vm.tools.clear
  20112. ? _c(
  20113. "li",
  20114. {
  20115. attrs: { name: "清空" },
  20116. on: {
  20117. click: function($event) {
  20118. _vm.value = ""
  20119. }
  20120. }
  20121. },
  20122. [_c("span", { staticClass: "iconfont icon-clear" })]
  20123. )
  20124. : _vm._e(),
  20125. _vm._v(" "),
  20126. _vm.tools.save
  20127. ? _c(
  20128. "li",
  20129. { attrs: { name: "保存" }, on: { click: _vm.handleSave } },
  20130. [_c("span", { staticClass: "iconfont icon-save" })]
  20131. )
  20132. : _vm._e(),
  20133. _vm._v(" "),
  20134. _c(
  20135. "li",
  20136. { attrs: { name: _vm.scrolling ? "同步滚动:开" : "同步滚动:关" } },
  20137. [
  20138. _c("span", {
  20139. directives: [
  20140. {
  20141. name: "show",
  20142. rawName: "v-show",
  20143. value: _vm.scrolling,
  20144. expression: "scrolling"
  20145. }
  20146. ],
  20147. staticClass: "iconfont icon-on",
  20148. on: {
  20149. click: function($event) {
  20150. _vm.scrolling = !_vm.scrolling
  20151. }
  20152. }
  20153. }),
  20154. _vm._v(" "),
  20155. _c("span", {
  20156. directives: [
  20157. {
  20158. name: "show",
  20159. rawName: "v-show",
  20160. value: !_vm.scrolling,
  20161. expression: "!scrolling"
  20162. }
  20163. ],
  20164. staticClass: "iconfont icon-off",
  20165. on: {
  20166. click: function($event) {
  20167. _vm.scrolling = !_vm.scrolling
  20168. }
  20169. }
  20170. })
  20171. ]
  20172. ),
  20173. _vm._v(" "),
  20174. _c(
  20175. "li",
  20176. {
  20177. attrs: { name: "html转markdown" },
  20178. on: {
  20179. click: function($event) {
  20180. return _vm.onCustom("html2md")
  20181. }
  20182. }
  20183. },
  20184. [
  20185. _c(
  20186. "span",
  20187. {
  20188. staticStyle: {
  20189. width: "auto",
  20190. "font-size": "14px",
  20191. padding: "0 6px"
  20192. }
  20193. },
  20194. [_vm._v("HTML2MD")]
  20195. )
  20196. ]
  20197. ),
  20198. _vm._v(" "),
  20199. _c("li", { staticClass: "empty" }),
  20200. _vm._v(" "),
  20201. _vm.tools.fullscreen && !_vm.fullscreen
  20202. ? _c("li", { attrs: { name: "全屏" } }, [
  20203. _c("span", {
  20204. staticClass: "iconfont icon-fullscreen",
  20205. on: {
  20206. click: function($event) {
  20207. _vm.fullscreen = !_vm.fullscreen
  20208. }
  20209. }
  20210. })
  20211. ])
  20212. : _vm._e(),
  20213. _vm._v(" "),
  20214. _vm.tools.fullscreen && _vm.fullscreen
  20215. ? _c("li", { attrs: { name: "退出全屏" } }, [
  20216. _c("span", {
  20217. staticClass: "iconfont icon-quite",
  20218. on: {
  20219. click: function($event) {
  20220. _vm.fullscreen = !_vm.fullscreen
  20221. }
  20222. }
  20223. })
  20224. ])
  20225. : _vm._e(),
  20226. _vm._v(" "),
  20227. _vm.tools.custom_fullscreen && !_vm.isCustomFullscreen
  20228. ? _c("li", { attrs: { name: "全屏" } }, [
  20229. _c("span", {
  20230. staticClass: "iconfont icon-fullscreen",
  20231. on: {
  20232. click: function($event) {
  20233. return _vm.onCustom("fullscreen")
  20234. }
  20235. }
  20236. })
  20237. ])
  20238. : _vm._e(),
  20239. _vm._v(" "),
  20240. _vm.tools.custom_fullscreen && _vm.isCustomFullscreen
  20241. ? _c("li", { attrs: { name: "退出全屏" } }, [
  20242. _c("span", {
  20243. staticClass: "iconfont icon-quite",
  20244. on: {
  20245. click: function($event) {
  20246. return _vm.onCustom("fullscreen")
  20247. }
  20248. }
  20249. })
  20250. ])
  20251. : _vm._e()
  20252. ]
  20253. ),
  20254. _vm._v(" "),
  20255. _c(
  20256. "div",
  20257. {
  20258. directives: [
  20259. {
  20260. name: "show",
  20261. rawName: "v-show",
  20262. value: _vm.preview && !_vm.isPreview,
  20263. expression: "preview && !isPreview"
  20264. }
  20265. ],
  20266. staticClass: "close-preview",
  20267. on: {
  20268. click: function($event) {
  20269. _vm.preview = false
  20270. }
  20271. }
  20272. },
  20273. [_c("span", { staticClass: "iconfont icon-close" })]
  20274. ),
  20275. _vm._v(" "),
  20276. _c(
  20277. "div",
  20278. {
  20279. staticClass: "markdown-content",
  20280. style: { background: _vm.preview ? "#fff" : "" }
  20281. },
  20282. [
  20283. _c("div", {
  20284. directives: [
  20285. {
  20286. name: "show",
  20287. rawName: "v-show",
  20288. value: !_vm.preview,
  20289. expression: "!preview"
  20290. }
  20291. ],
  20292. ref: "codemirror",
  20293. staticClass: "codemirror",
  20294. on: {
  20295. mouseenter: function($event) {
  20296. return _vm.mousescrollSide("left")
  20297. }
  20298. }
  20299. }),
  20300. _vm._v(" "),
  20301. _c(
  20302. "div",
  20303. {
  20304. directives: [
  20305. {
  20306. name: "show",
  20307. rawName: "v-show",
  20308. value: _vm.preview ? _vm.preview : _vm.split,
  20309. expression: "preview ? preview : split"
  20310. }
  20311. ],
  20312. ref: "preview",
  20313. class: "markdown-preview " + ("markdown-theme-" + _vm.themeName),
  20314. on: {
  20315. scroll: _vm.previewScroll,
  20316. mouseenter: function($event) {
  20317. return _vm.mousescrollSide("right")
  20318. }
  20319. }
  20320. },
  20321. [
  20322. _c("div", {
  20323. ref: "previewInner",
  20324. domProps: { innerHTML: _vm._s(_vm.html) }
  20325. })
  20326. ]
  20327. )
  20328. ]
  20329. ),
  20330. _vm._v(" "),
  20331. _c(
  20332. "div",
  20333. { class: ["preview-img", _vm.previewImgModal ? "active" : ""] },
  20334. [
  20335. _c("span", {
  20336. staticClass: "close icon-close iconfont",
  20337. on: {
  20338. click: function($event) {
  20339. _vm.previewImgModal = false
  20340. }
  20341. }
  20342. }),
  20343. _vm._v(" "),
  20344. _c("img", {
  20345. class: [_vm.previewImgMode],
  20346. attrs: { src: _vm.previewImgSrc, alt: "" }
  20347. })
  20348. ]
  20349. )
  20350. ]
  20351. )
  20352. }
  20353. var staticRenderFns = []
  20354. render._withStripped = true
  20355. module.exports = { render: render, staticRenderFns: staticRenderFns }
  20356. if (false) {
  20357. module.hot.accept()
  20358. if (module.hot.data) {
  20359. require("vue-hot-reload-api") .rerender("data-v-e13e76c6", module.exports)
  20360. }
  20361. }
  20362. /***/ }),
  20363. /***/ 885:
  20364. /***/ (function(module, exports, __webpack_require__) {
  20365. var render = function() {
  20366. var _vm = this
  20367. var _h = _vm.$createElement
  20368. var _c = _vm._self._c || _h
  20369. return _c(
  20370. "div",
  20371. [
  20372. _c(
  20373. "div",
  20374. { staticClass: "mdeditor-box" },
  20375. [
  20376. _c("MarkdownPro", {
  20377. ref: "md1",
  20378. attrs: {
  20379. height: _vm.height,
  20380. toolbars: _vm.toolbars,
  20381. "is-custom-fullscreen": _vm.transfer
  20382. },
  20383. on: {
  20384. "on-custom": _vm.customClick,
  20385. "on-upload-image": _vm.handleUploadImageUpload
  20386. },
  20387. model: {
  20388. value: _vm.content,
  20389. callback: function($$v) {
  20390. _vm.content = $$v
  20391. },
  20392. expression: "content"
  20393. }
  20394. }),
  20395. _vm._v(" "),
  20396. _c("ImgUpload", {
  20397. ref: "myUpload",
  20398. staticClass: "upload-control",
  20399. attrs: { type: "callback", uploadIng: _vm.uploadIng, num: "50" },
  20400. on: {
  20401. "update:uploadIng": function($event) {
  20402. _vm.uploadIng = $event
  20403. },
  20404. "update:upload-ing": function($event) {
  20405. _vm.uploadIng = $event
  20406. },
  20407. "on-callback": _vm.editorImage
  20408. }
  20409. }),
  20410. _vm._v(" "),
  20411. _c("Upload", {
  20412. ref: "fileUpload",
  20413. staticClass: "upload-control",
  20414. attrs: {
  20415. name: "files",
  20416. action: _vm.actionUrl,
  20417. data: _vm.params,
  20418. multiple: "",
  20419. format: _vm.uploadFormat,
  20420. "show-upload-list": false,
  20421. "max-size": _vm.maxSize,
  20422. "on-progress": _vm.handleProgress,
  20423. "on-success": _vm.handleSuccess,
  20424. "on-error": _vm.handleError,
  20425. "on-format-error": _vm.handleFormatError,
  20426. "on-exceeded-size": _vm.handleMaxSize,
  20427. "before-upload": _vm.handleBeforeUpload
  20428. }
  20429. })
  20430. ],
  20431. 1
  20432. ),
  20433. _vm._v(" "),
  20434. _vm.uploadIng > 0
  20435. ? _c(
  20436. "Spin",
  20437. { attrs: { fix: "" } },
  20438. [
  20439. _c("Icon", {
  20440. staticClass: "upload-control-spin-icon-load",
  20441. attrs: { type: "ios-loading" }
  20442. }),
  20443. _vm._v(" "),
  20444. _c("div", [_vm._v(_vm._s(_vm.$L("正在上传文件...")))])
  20445. ],
  20446. 1
  20447. )
  20448. : _vm._e(),
  20449. _vm._v(" "),
  20450. _c(
  20451. "Modal",
  20452. {
  20453. staticClass: "mdeditor-transfer",
  20454. attrs: {
  20455. "footer-hide": "",
  20456. fullscreen: "",
  20457. transfer: "",
  20458. closable: false
  20459. },
  20460. model: {
  20461. value: _vm.transfer,
  20462. callback: function($$v) {
  20463. _vm.transfer = $$v
  20464. },
  20465. expression: "transfer"
  20466. }
  20467. },
  20468. [
  20469. _c(
  20470. "div",
  20471. { staticClass: "mdeditor-transfer-body" },
  20472. [
  20473. _vm.transfer
  20474. ? _c("MarkdownPro", {
  20475. ref: "md2",
  20476. attrs: {
  20477. toolbars: _vm.toolbars,
  20478. "is-custom-fullscreen": _vm.transfer,
  20479. height: "100%"
  20480. },
  20481. on: { "on-custom": _vm.customClick },
  20482. model: {
  20483. value: _vm.content,
  20484. callback: function($$v) {
  20485. _vm.content = $$v
  20486. },
  20487. expression: "content"
  20488. }
  20489. })
  20490. : _vm._e()
  20491. ],
  20492. 1
  20493. ),
  20494. _vm._v(" "),
  20495. _vm.uploadIng > 0
  20496. ? _c(
  20497. "Spin",
  20498. { attrs: { fix: "" } },
  20499. [
  20500. _c("Icon", {
  20501. staticClass: "upload-control-spin-icon-load",
  20502. attrs: { type: "ios-loading" }
  20503. }),
  20504. _vm._v(" "),
  20505. _c("div", [_vm._v(_vm._s(_vm.$L("正在上传文件...")))])
  20506. ],
  20507. 1
  20508. )
  20509. : _vm._e()
  20510. ],
  20511. 1
  20512. ),
  20513. _vm._v(" "),
  20514. _c(
  20515. "Modal",
  20516. {
  20517. attrs: {
  20518. title: "html转markdown",
  20519. okText: "转换成markdown",
  20520. width: "680",
  20521. "class-name": "simple-modal",
  20522. transfer: ""
  20523. },
  20524. on: { "on-ok": _vm.htmlOk },
  20525. model: {
  20526. value: _vm.html2md,
  20527. callback: function($$v) {
  20528. _vm.html2md = $$v
  20529. },
  20530. expression: "html2md"
  20531. }
  20532. },
  20533. [
  20534. _c("Input", {
  20535. attrs: {
  20536. type: "textarea",
  20537. rows: 14,
  20538. placeholder: "请输入html代码..."
  20539. },
  20540. model: {
  20541. value: _vm.htmlValue,
  20542. callback: function($$v) {
  20543. _vm.htmlValue = $$v
  20544. },
  20545. expression: "htmlValue"
  20546. }
  20547. })
  20548. ],
  20549. 1
  20550. )
  20551. ],
  20552. 1
  20553. )
  20554. }
  20555. var staticRenderFns = []
  20556. render._withStripped = true
  20557. module.exports = { render: render, staticRenderFns: staticRenderFns }
  20558. if (false) {
  20559. module.hot.accept()
  20560. if (module.hot.data) {
  20561. require("vue-hot-reload-api") .rerender("data-v-ca28cc48", module.exports)
  20562. }
  20563. }
  20564. /***/ })
  20565. });