richtext.js 424 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591
  1. /*
  2. @license
  3. dhtmlxRichtext v.1.1.1 GPL
  4. This software is covered by GPL license.
  5. To use it in non-GPL project, you need obtain Commercial or Enterprise license
  6. Please contact sales@dhtmlx.com. Usage without proper license is prohibited.
  7. (c) Dinamenta, UAB.
  8. */
  9. if (window.dhx){ window.dhx_legacy = dhx; delete window.dhx; }(function webpackUniversalModuleDefinition(root, factory) {
  10. if(typeof exports === 'object' && typeof module === 'object')
  11. module.exports = factory();
  12. else if(typeof define === 'function' && define.amd)
  13. define([], factory);
  14. else if(typeof exports === 'object')
  15. exports["dhx"] = factory();
  16. else
  17. root["dhx"] = factory();
  18. })(window, function() {
  19. return /******/ (function(modules) { // webpackBootstrap
  20. /******/ // The module cache
  21. /******/ var installedModules = {};
  22. /******/
  23. /******/ // The require function
  24. /******/ function __webpack_require__(moduleId) {
  25. /******/
  26. /******/ // Check if module is in cache
  27. /******/ if(installedModules[moduleId]) {
  28. /******/ return installedModules[moduleId].exports;
  29. /******/ }
  30. /******/ // Create a new module (and put it into the cache)
  31. /******/ var module = installedModules[moduleId] = {
  32. /******/ i: moduleId,
  33. /******/ l: false,
  34. /******/ exports: {}
  35. /******/ };
  36. /******/
  37. /******/ // Execute the module function
  38. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  39. /******/
  40. /******/ // Flag the module as loaded
  41. /******/ module.l = true;
  42. /******/
  43. /******/ // Return the exports of the module
  44. /******/ return module.exports;
  45. /******/ }
  46. /******/
  47. /******/
  48. /******/ // expose the modules object (__webpack_modules__)
  49. /******/ __webpack_require__.m = modules;
  50. /******/
  51. /******/ // expose the module cache
  52. /******/ __webpack_require__.c = installedModules;
  53. /******/
  54. /******/ // define getter function for harmony exports
  55. /******/ __webpack_require__.d = function(exports, name, getter) {
  56. /******/ if(!__webpack_require__.o(exports, name)) {
  57. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  58. /******/ }
  59. /******/ };
  60. /******/
  61. /******/ // define __esModule on exports
  62. /******/ __webpack_require__.r = function(exports) {
  63. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  64. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  65. /******/ }
  66. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  67. /******/ };
  68. /******/
  69. /******/ // create a fake namespace object
  70. /******/ // mode & 1: value is a module id, require it
  71. /******/ // mode & 2: merge all properties of value into the ns
  72. /******/ // mode & 4: return value when already ns object
  73. /******/ // mode & 8|1: behave like require
  74. /******/ __webpack_require__.t = function(value, mode) {
  75. /******/ if(mode & 1) value = __webpack_require__(value);
  76. /******/ if(mode & 8) return value;
  77. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  78. /******/ var ns = Object.create(null);
  79. /******/ __webpack_require__.r(ns);
  80. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  81. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  82. /******/ return ns;
  83. /******/ };
  84. /******/
  85. /******/ // getDefaultExport function for compatibility with non-harmony modules
  86. /******/ __webpack_require__.n = function(module) {
  87. /******/ var getter = module && module.__esModule ?
  88. /******/ function getDefault() { return module['default']; } :
  89. /******/ function getModuleExports() { return module; };
  90. /******/ __webpack_require__.d(getter, 'a', getter);
  91. /******/ return getter;
  92. /******/ };
  93. /******/
  94. /******/ // Object.prototype.hasOwnProperty.call
  95. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  96. /******/
  97. /******/ // __webpack_public_path__
  98. /******/ __webpack_require__.p = "/codebase/";
  99. /******/
  100. /******/
  101. /******/ // Load entry module and return exports
  102. /******/ return __webpack_require__(__webpack_require__.s = 36);
  103. /******/ })
  104. /************************************************************************/
  105. /******/ ([
  106. /* 0 */
  107. /***/ (function(module, exports, __webpack_require__) {
  108. "use strict";
  109. Object.defineProperty(exports, "__esModule", { value: true });
  110. var dom = __webpack_require__(39);
  111. exports.el = dom.defineElement;
  112. exports.sv = dom.defineSvgElement;
  113. exports.view = dom.defineView;
  114. exports.create = dom.createView;
  115. exports.inject = dom.injectView;
  116. function disableHelp() {
  117. dom.DEVMODE.mutations = false;
  118. dom.DEVMODE.warnings = false;
  119. dom.DEVMODE.verbose = false;
  120. dom.DEVMODE.UNKEYED_INPUT = false;
  121. }
  122. exports.disableHelp = disableHelp;
  123. function resizer(handler) {
  124. var resize = window.ResizeObserver;
  125. var activeHandler = function (node) {
  126. var height = node.el.offsetHeight;
  127. var width = node.el.offsetWidth;
  128. handler(width, height);
  129. };
  130. if (resize) {
  131. return exports.el("div.dhx-resize-observer", {
  132. _hooks: {
  133. didInsert: function (node) {
  134. new resize(function () { return activeHandler(node); }).observe(node.el);
  135. }
  136. }
  137. });
  138. }
  139. return exports.el("iframe.dhx-resize-observer", {
  140. _hooks: {
  141. didInsert: function (node) {
  142. node.el.contentWindow.onresize = function () { return activeHandler(node); };
  143. activeHandler(node);
  144. }
  145. }
  146. });
  147. }
  148. exports.resizer = resizer;
  149. /***/ }),
  150. /* 1 */
  151. /***/ (function(module, exports, __webpack_require__) {
  152. "use strict";
  153. var __assign = (this && this.__assign) || Object.assign || function(t) {
  154. for (var s, i = 1, n = arguments.length; i < n; i++) {
  155. s = arguments[i];
  156. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  157. t[p] = s[p];
  158. }
  159. return t;
  160. };
  161. Object.defineProperty(exports, "__esModule", { value: true });
  162. __webpack_require__(40);
  163. function toNode(node) {
  164. if (typeof node === "string") {
  165. node = (document.getElementById(node) || document.querySelector(node));
  166. }
  167. return node || document.body;
  168. }
  169. exports.toNode = toNode;
  170. function eventHandler(prepare, hash) {
  171. var keys = Object.keys(hash);
  172. return function (ev) {
  173. var data = prepare(ev);
  174. var node = ev.target;
  175. while (node) {
  176. var cssstring = node.getAttribute ? (node.getAttribute("class") || "") : "";
  177. if (cssstring.length) {
  178. var css = cssstring.split(" ");
  179. for (var j = 0; j < keys.length; j++) {
  180. if (css.indexOf(keys[j]) > -1) {
  181. return hash[keys[j]](ev, data);
  182. }
  183. }
  184. }
  185. node = node.parentNode;
  186. }
  187. return true;
  188. };
  189. }
  190. exports.eventHandler = eventHandler;
  191. function locate(target, attr) {
  192. if (attr === void 0) { attr = "dhx_id"; }
  193. var node = locateNode(target, attr);
  194. return node ? node.getAttribute(attr) : "";
  195. }
  196. exports.locate = locate;
  197. function locateNode(target, attr) {
  198. if (attr === void 0) { attr = "dhx_id"; }
  199. if (target instanceof Event) {
  200. target = target.target;
  201. }
  202. while (target) {
  203. if (target.getAttribute && target.getAttribute(attr)) {
  204. return target;
  205. }
  206. target = target.parentNode;
  207. }
  208. }
  209. exports.locateNode = locateNode;
  210. function getBox(elem) {
  211. var box = elem.getBoundingClientRect();
  212. var body = document.body;
  213. var scrollTop = window.pageYOffset || body.scrollTop;
  214. var scrollLeft = window.pageXOffset || body.scrollLeft;
  215. var top = box.top + scrollTop;
  216. var left = box.left + scrollLeft;
  217. var right = body.offsetWidth - box.right;
  218. var bottom = body.offsetHeight - box.bottom;
  219. var width = box.right - box.left;
  220. var height = box.bottom - box.top;
  221. return { top: top, left: left, right: right, bottom: bottom, width: width, height: height };
  222. }
  223. exports.getBox = getBox;
  224. var scrollWidth = -1;
  225. function getScrollbarWidth() {
  226. if (scrollWidth > -1) {
  227. return scrollWidth;
  228. }
  229. var scrollDiv = document.createElement("div");
  230. document.body.appendChild(scrollDiv);
  231. scrollDiv.style.cssText = "position: absolute;left: -99999px;overflow:scroll;width: 100px;height: 100px;";
  232. scrollWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
  233. document.body.removeChild(scrollDiv);
  234. return scrollWidth;
  235. }
  236. exports.getScrollbarWidth = getScrollbarWidth;
  237. function fitPosition(node, config) {
  238. return calculatePosition(getRealPosition(node), config);
  239. }
  240. exports.fitPosition = fitPosition;
  241. function isIE() {
  242. var ua = window.navigator.userAgent;
  243. return ua.indexOf("MSIE ") > -1 || ua.indexOf("Trident/") > -1;
  244. }
  245. exports.isIE = isIE;
  246. function getRealPosition(node) {
  247. var rects = node.getBoundingClientRect();
  248. return {
  249. left: rects.left + window.pageXOffset,
  250. right: rects.right + window.pageXOffset,
  251. top: rects.top + window.pageYOffset,
  252. bottom: rects.bottom + window.pageYOffset
  253. };
  254. }
  255. exports.getRealPosition = getRealPosition;
  256. var Position;
  257. (function (Position) {
  258. Position["left"] = "left";
  259. Position["right"] = "right";
  260. Position["bottom"] = "bottom";
  261. Position["top"] = "top";
  262. })(Position = exports.Position || (exports.Position = {}));
  263. function calculatePosition(pos, config) {
  264. var _a = config.mode === Position.bottom || config.mode === Position.top ?
  265. placeBottomOrTop(pos, config) :
  266. placeRightOrLeft(pos, config), left = _a.left, top = _a.top;
  267. return {
  268. left: left + "px",
  269. top: top + "px",
  270. minWidth: config.width + "px",
  271. position: "absolute"
  272. };
  273. }
  274. exports.calculatePosition = calculatePosition;
  275. function getWindowBorders() {
  276. return {
  277. rightBorder: window.pageXOffset + window.innerWidth,
  278. bottomBorder: window.pageYOffset + window.innerHeight
  279. };
  280. }
  281. function horizontalCentering(pos, width, rightBorder) {
  282. var nodeWidth = pos.right - pos.left;
  283. var diff = (width - nodeWidth) / 2;
  284. var left = pos.left - diff;
  285. var right = pos.right + diff;
  286. if (left >= 0 && right <= rightBorder) {
  287. return left;
  288. }
  289. if (left < 0) {
  290. return 0;
  291. }
  292. return rightBorder - width;
  293. }
  294. function verticalCentering(pos, height, bottomBorder) {
  295. var nodeHeight = pos.bottom - pos.top;
  296. var diff = (height - nodeHeight) / 2;
  297. var top = pos.top - diff;
  298. var bottom = pos.bottom + diff;
  299. if (top >= 0 && bottom <= bottomBorder) {
  300. return top;
  301. }
  302. if (top < 0) {
  303. return 0;
  304. }
  305. return bottomBorder - height;
  306. }
  307. function placeBottomOrTop(pos, config) {
  308. var _a = getWindowBorders(), rightBorder = _a.rightBorder, bottomBorder = _a.bottomBorder;
  309. var left;
  310. var top;
  311. var bottomDiff = bottomBorder - pos.bottom - config.height;
  312. var topDiff = pos.top - config.height;
  313. if (config.mode === Position.bottom) {
  314. if (bottomDiff >= 0) {
  315. top = pos.bottom;
  316. }
  317. else if (topDiff >= 0) {
  318. top = topDiff;
  319. }
  320. }
  321. else {
  322. if (topDiff >= 0) {
  323. top = topDiff;
  324. }
  325. else if (bottomDiff >= 0) {
  326. top = pos.bottom;
  327. }
  328. }
  329. if (bottomDiff < 0 && topDiff < 0) {
  330. if (config.auto) {
  331. return placeRightOrLeft(pos, __assign({}, config, { mode: Position.right, auto: false }));
  332. }
  333. top = bottomDiff > topDiff ? pos.bottom : topDiff;
  334. }
  335. if (config.centering) {
  336. left = horizontalCentering(pos, config.width, rightBorder);
  337. }
  338. else {
  339. var leftDiff = rightBorder - pos.left - config.width;
  340. var rightDiff = pos.right - config.width;
  341. if (leftDiff >= 0) {
  342. left = pos.left;
  343. }
  344. else if (rightDiff >= 0) {
  345. left = rightDiff;
  346. }
  347. else {
  348. left = rightDiff > leftDiff ? pos.left : rightDiff;
  349. }
  350. }
  351. return { left: left, top: top };
  352. }
  353. function placeRightOrLeft(pos, config) {
  354. var _a = getWindowBorders(), rightBorder = _a.rightBorder, bottomBorder = _a.bottomBorder;
  355. var left;
  356. var top;
  357. var rightDiff = rightBorder - pos.right - config.width;
  358. var leftDiff = pos.left - config.width;
  359. if (config.mode === Position.right) {
  360. if (rightDiff >= 0) {
  361. left = pos.right;
  362. }
  363. else if (leftDiff >= 0) {
  364. left = leftDiff;
  365. }
  366. }
  367. else {
  368. if (leftDiff >= 0) {
  369. left = leftDiff;
  370. }
  371. else if (rightDiff >= 0) {
  372. left = pos.right;
  373. }
  374. }
  375. if (leftDiff < 0 && rightDiff < 0) {
  376. if (config.auto) {
  377. return placeRightOrLeft(pos, __assign({}, config, { mode: Position.bottom, auto: false }));
  378. }
  379. left = leftDiff > rightDiff ? leftDiff : pos.right;
  380. }
  381. if (config.centering) {
  382. top = verticalCentering(pos, config.width, rightBorder);
  383. }
  384. else {
  385. var bottomDiff = pos.bottom - config.height;
  386. var topDiff = bottomBorder - pos.top - config.height;
  387. if (topDiff >= 0) {
  388. top = pos.top;
  389. }
  390. else if (bottomDiff > 0) {
  391. top = bottomDiff;
  392. }
  393. else {
  394. top = bottomDiff > topDiff ? bottomDiff : pos.top;
  395. }
  396. }
  397. return { left: left, top: top };
  398. }
  399. /***/ }),
  400. /* 2 */
  401. /***/ (function(module, exports, __webpack_require__) {
  402. "use strict";
  403. Object.defineProperty(exports, "__esModule", { value: true });
  404. var Modifier;
  405. (function (Modifier) {
  406. Modifier[Modifier["none"] = 0] = "none";
  407. // block mods
  408. Modifier["style"] = "style";
  409. Modifier["align"] = "align";
  410. Modifier["blockquote"] = "blockquote";
  411. // text mods
  412. Modifier["bold"] = "bold";
  413. Modifier["italic"] = "italic";
  414. Modifier["strike"] = "strike";
  415. Modifier["fontSize"] = "font-size";
  416. Modifier["fontFamily"] = "font-family";
  417. Modifier["underline"] = "underline";
  418. Modifier["color"] = "color";
  419. Modifier["background"] = "background";
  420. Modifier["link"] = "link";
  421. })(Modifier = exports.Modifier || (exports.Modifier = {}));
  422. var Action;
  423. (function (Action) {
  424. Action["add"] = "add";
  425. Action["innerAdd"] = "innerAdd";
  426. Action["remove"] = "remove";
  427. Action["update"] = "update";
  428. Action["undo"] = "undo";
  429. Action["paste"] = "paste";
  430. Action["copy"] = "copy";
  431. Action["cut"] = "cut";
  432. Action["redo"] = "redo";
  433. Action["clear"] = "clear";
  434. Action["parse"] = "parse";
  435. Action["selectAll"] = "selectAll";
  436. })(Action = exports.Action || (exports.Action = {}));
  437. var RTEToolbarBlock;
  438. (function (RTEToolbarBlock) {
  439. RTEToolbarBlock["default"] = "default";
  440. RTEToolbarBlock["undo"] = "undo";
  441. RTEToolbarBlock["style"] = "style";
  442. RTEToolbarBlock["decoration"] = "decoration";
  443. RTEToolbarBlock["color"] = "colors";
  444. RTEToolbarBlock["align"] = "align";
  445. RTEToolbarBlock["link"] = "link";
  446. RTEToolbarBlock["clear"] = "clear";
  447. RTEToolbarBlock["fullscreen"] = "fullscreen";
  448. RTEToolbarBlock["stats"] = "stats";
  449. })(RTEToolbarBlock = exports.RTEToolbarBlock || (exports.RTEToolbarBlock = {}));
  450. var RichTextEvents;
  451. (function (RichTextEvents) {
  452. RichTextEvents["change"] = "change";
  453. RichTextEvents["action"] = "action";
  454. RichTextEvents["selectionChange"] = "selectionchange";
  455. RichTextEvents["selectionRefresh"] = "selectionrefresh";
  456. RichTextEvents["showLinkEditor"] = "showlinkeditor";
  457. RichTextEvents["compositionStart"] = "compositionstart";
  458. RichTextEvents["compositionUpdate"] = "compositionupdate";
  459. RichTextEvents["compositionEnd"] = "compositionend";
  460. })(RichTextEvents = exports.RichTextEvents || (exports.RichTextEvents = {}));
  461. /***/ }),
  462. /* 3 */
  463. /***/ (function(module, exports, __webpack_require__) {
  464. "use strict";
  465. Object.defineProperty(exports, "__esModule", { value: true });
  466. var counter = (new Date()).valueOf();
  467. function uid() {
  468. return "u" + (counter++);
  469. }
  470. exports.uid = uid;
  471. function extend(target, source, deep) {
  472. if (deep === void 0) { deep = true; }
  473. if (source) {
  474. for (var key in source) {
  475. var sobj = source[key];
  476. var tobj = target[key];
  477. if (deep && typeof tobj === "object" && !(tobj instanceof Date) && !(tobj instanceof Array)) {
  478. extend(tobj, sobj);
  479. }
  480. else {
  481. target[key] = sobj;
  482. }
  483. }
  484. }
  485. return target;
  486. }
  487. exports.extend = extend;
  488. function copy(source) {
  489. var result = {};
  490. for (var key in source) {
  491. result[key] = source[key];
  492. }
  493. return result;
  494. }
  495. exports.copy = copy;
  496. function naturalSort(arr) {
  497. return arr.sort(function (a, b) {
  498. var nn = typeof a === "string" ? a.localeCompare(b) : a - b;
  499. return nn;
  500. });
  501. }
  502. exports.naturalSort = naturalSort;
  503. function findIndex(arr, predicate) {
  504. var len = arr.length;
  505. for (var i = 0; i < len; i++) {
  506. if (predicate(arr[i])) {
  507. return i;
  508. }
  509. }
  510. return -1;
  511. }
  512. exports.findIndex = findIndex;
  513. function isEqualString(from, to) {
  514. if (from.length > to.length) {
  515. return false;
  516. }
  517. for (var i = 0; i < from.length; i++) {
  518. if (from[i].toLowerCase() !== to[i].toLowerCase()) {
  519. return false;
  520. }
  521. }
  522. return true;
  523. }
  524. exports.isEqualString = isEqualString;
  525. function singleOuterClick(fn) {
  526. var click = function (e) {
  527. if (fn(e)) {
  528. document.removeEventListener("click", click);
  529. }
  530. };
  531. document.addEventListener("click", click);
  532. }
  533. exports.singleOuterClick = singleOuterClick;
  534. /***/ }),
  535. /* 4 */
  536. /***/ (function(module, exports, __webpack_require__) {
  537. "use strict";
  538. Object.defineProperty(exports, "__esModule", { value: true });
  539. function getTextHash(blockIndex, textIndex) {
  540. return blockIndex + "_" + textIndex;
  541. }
  542. exports.getTextHash = getTextHash;
  543. function getLinkRefer() {
  544. var index = 0;
  545. return function () { return "link_ref_" + index++; };
  546. }
  547. exports.getLinkRefer = getLinkRefer;
  548. function hashToInfo(hash) {
  549. if (hash === void 0) { hash = ""; }
  550. if (!hash) {
  551. return [];
  552. }
  553. return hash.split("_").map(function (val) { return parseInt(val, 10); });
  554. }
  555. exports.hashToInfo = hashToInfo;
  556. function actionIdToModifierValue(id) {
  557. return id.split("-").pop();
  558. }
  559. exports.actionIdToModifierValue = actionIdToModifierValue;
  560. function textColor(color) {
  561. return "<span class=\"dxi dhx_button__icon dxi-format-color-text dhx_richtext__text-color\" style=\"border-color: " + color + ";\"></span>";
  562. }
  563. exports.textColor = textColor;
  564. function textSelectColor(color) {
  565. return "<span class=\"dxi dhx_button__icon dxi-format-color-fill dhx_richtext__background-color\" style=\"border-color: " + color + ";\"></span>";
  566. }
  567. exports.textSelectColor = textSelectColor;
  568. function isObject(target) {
  569. return target !== null && typeof target === "object" && !(target instanceof Date);
  570. }
  571. function isEqual(source, target, deep) {
  572. if (deep === void 0) { deep = false; }
  573. var sourceKeys = Object.keys(source);
  574. var targetKeys = Object.keys(target);
  575. if (sourceKeys.length !== targetKeys.length) {
  576. return false;
  577. }
  578. for (var _i = 0, sourceKeys_1 = sourceKeys; _i < sourceKeys_1.length; _i++) {
  579. var prop = sourceKeys_1[_i];
  580. if (deep && isObject(source[prop]) && isObject(target[prop])) {
  581. if (!isEqual(source[prop], target[prop], deep)) {
  582. return false;
  583. }
  584. }
  585. else if (source[prop] !== target[prop]) {
  586. return false;
  587. }
  588. }
  589. return true;
  590. }
  591. exports.isEqual = isEqual;
  592. function copyWithout(obj, forbidden) {
  593. var target = {};
  594. for (var key in obj) {
  595. if (!forbidden.hasOwnProperty(key)) {
  596. target[key] = obj[key];
  597. }
  598. }
  599. return target;
  600. }
  601. exports.copyWithout = copyWithout;
  602. function startsWith(str, pattern) {
  603. if (str.length < pattern.length) {
  604. return false;
  605. }
  606. for (var i = 0; i < pattern.length; i++) {
  607. if (str[i] !== pattern[i]) {
  608. return false;
  609. }
  610. }
  611. return true;
  612. }
  613. exports.startsWith = startsWith;
  614. /***/ }),
  615. /* 5 */
  616. /***/ (function(module, exports, __webpack_require__) {
  617. "use strict";
  618. Object.defineProperty(exports, "__esModule", { value: true });
  619. var _a;
  620. var ts_toolbar_1 = __webpack_require__(21);
  621. var other_1 = __webpack_require__(4);
  622. var en_1 = __webpack_require__(11);
  623. var types_1 = __webpack_require__(2);
  624. function getToolbarData(toolbarBlocks, defaultStyle) {
  625. var _a;
  626. var blocks = (_a = {},
  627. _a[types_1.RTEToolbarBlock.undo] = [
  628. {
  629. id: "undo",
  630. tooltip: en_1.default.undo,
  631. type: ts_toolbar_1.ItemType.button,
  632. icon: "dxi-undo",
  633. multiClick: true,
  634. $disabled: true
  635. },
  636. {
  637. id: "redo",
  638. tooltip: en_1.default.redo,
  639. type: ts_toolbar_1.ItemType.button,
  640. icon: "dxi-redo",
  641. multiClick: true,
  642. $disabled: true
  643. }
  644. ],
  645. _a[types_1.RTEToolbarBlock.style] = [
  646. {
  647. id: types_1.Modifier.fontFamily,
  648. value: defaultStyle[types_1.Modifier.fontFamily],
  649. tooltip: en_1.default.selectFontFamily,
  650. css: "dhx_richtext__dropdown dhx_richtext__dropdown--force_max-width dhx_richtext__dropdown--mw_50",
  651. type: ts_toolbar_1.ItemType.button,
  652. items: createToolbarFonts()
  653. },
  654. {
  655. id: types_1.Modifier.fontSize,
  656. value: defaultStyle[types_1.Modifier.fontSize],
  657. tooltip: en_1.default.selectFontSize,
  658. css: "dhx_richtext__dropdown dhx_richtext__dropdown--force_max-width dhx_richtext__dropdown--mw_35",
  659. type: ts_toolbar_1.ItemType.button,
  660. items: createToolbarFontSizes()
  661. },
  662. {
  663. id: types_1.Modifier.style,
  664. tooltip: en_1.default.selectFormat,
  665. value: en_1.default[defaultStyle[types_1.Modifier.style]],
  666. css: "dhx_richtext__dropdown dhx_richtext__dropdown--force_max-width dhx_richtext__dropdown--mw_75",
  667. type: ts_toolbar_1.ItemType.button,
  668. items: [
  669. {
  670. id: "style-p",
  671. value: en_1.default.p
  672. },
  673. {
  674. id: "style-h1",
  675. css: "dhx_richtext__menu-text--h1",
  676. value: en_1.default.h1
  677. },
  678. {
  679. id: "style-h2",
  680. css: "dhx_richtext__menu-text--h2",
  681. value: en_1.default.h2
  682. },
  683. {
  684. id: "style-h3",
  685. css: "dhx_richtext__menu-text--h3",
  686. value: en_1.default.h3
  687. },
  688. {
  689. id: "style-h4",
  690. css: "dhx_richtext__menu-text--h4",
  691. value: en_1.default.h4
  692. },
  693. {
  694. id: "style-h5",
  695. css: "dhx_richtext__menu-text--h5",
  696. value: en_1.default.h5
  697. },
  698. {
  699. id: "style-h6",
  700. css: "dhx_richtext__menu-text--h6",
  701. value: en_1.default.h6
  702. }
  703. ]
  704. },
  705. {
  706. id: types_1.Modifier.blockquote,
  707. tooltip: en_1.default.blockquote,
  708. active: defaultStyle[types_1.Modifier.blockquote],
  709. type: ts_toolbar_1.ItemType.button,
  710. icon: "dxi-format-quote-open"
  711. }
  712. ],
  713. _a[types_1.RTEToolbarBlock.color] = [
  714. {
  715. id: types_1.Modifier.color,
  716. tooltip: en_1.default.selectTextColor,
  717. type: ts_toolbar_1.ItemType.customHTMLButton,
  718. css: "dhx_toolbar__button dhx_toolbar-button dhx_toolbar-button--icon ",
  719. html: other_1.textColor(defaultStyle[types_1.Modifier.color])
  720. },
  721. {
  722. id: types_1.Modifier.background,
  723. tooltip: en_1.default.selectTextBackground,
  724. type: ts_toolbar_1.ItemType.customHTMLButton,
  725. css: "dhx_toolbar__button dhx_toolbar-button dhx_toolbar-button--icon ",
  726. html: other_1.textSelectColor(defaultStyle[types_1.Modifier.background]),
  727. }
  728. ],
  729. _a[types_1.RTEToolbarBlock.decoration] = [
  730. {
  731. id: types_1.Modifier.bold,
  732. tooltip: en_1.default.markBold,
  733. icon: "dxi-format-bold",
  734. type: ts_toolbar_1.ItemType.button,
  735. hotkey: "ctrl+b",
  736. active: defaultStyle[types_1.Modifier.bold]
  737. },
  738. {
  739. id: types_1.Modifier.italic,
  740. tooltip: en_1.default.markItalic,
  741. icon: "dxi-format-italic",
  742. type: ts_toolbar_1.ItemType.button,
  743. hotkey: "ctrl+i",
  744. active: defaultStyle[types_1.Modifier.italic]
  745. },
  746. {
  747. id: types_1.Modifier.strike,
  748. tooltip: en_1.default.markStrike,
  749. icon: "dxi-format-strikethrough",
  750. type: ts_toolbar_1.ItemType.button,
  751. active: defaultStyle[types_1.Modifier.strike]
  752. },
  753. {
  754. id: types_1.Modifier.underline,
  755. tooltip: en_1.default.markUnderline,
  756. icon: "dxi-format-underline",
  757. type: ts_toolbar_1.ItemType.button,
  758. hotkey: "ctrl+u",
  759. active: defaultStyle[types_1.Modifier.underline]
  760. }
  761. ],
  762. _a[types_1.RTEToolbarBlock.align] = [
  763. {
  764. id: "align-left",
  765. tooltip: en_1.default.alignLeft,
  766. type: ts_toolbar_1.ItemType.button,
  767. icon: "dxi-format-align-left",
  768. active: defaultStyle[types_1.Modifier.align] === "left"
  769. },
  770. {
  771. id: "align-center",
  772. tooltip: en_1.default.alignCenter,
  773. type: ts_toolbar_1.ItemType.button,
  774. icon: "dxi-format-align-center",
  775. active: defaultStyle[types_1.Modifier.align] === "center"
  776. },
  777. {
  778. id: "align-right",
  779. tooltip: en_1.default.alignRight,
  780. type: ts_toolbar_1.ItemType.button,
  781. icon: "dxi-format-align-right",
  782. active: defaultStyle[types_1.Modifier.align] === "right"
  783. }
  784. ],
  785. _a[types_1.RTEToolbarBlock.link] = [
  786. {
  787. id: types_1.Modifier.link,
  788. tooltip: en_1.default.addLink,
  789. type: ts_toolbar_1.ItemType.button,
  790. icon: "dxi-link-variant"
  791. }
  792. ],
  793. _a[types_1.RTEToolbarBlock.clear] = [
  794. {
  795. id: "clear-style",
  796. tooltip: en_1.default.clearFormat,
  797. type: ts_toolbar_1.ItemType.button,
  798. icon: "dxi-eraser"
  799. }
  800. ],
  801. _a[types_1.RTEToolbarBlock.stats] = [
  802. {
  803. id: "stats",
  804. tooltip: en_1.default.stats,
  805. type: ts_toolbar_1.ItemType.button,
  806. icon: "dxi-information-outline"
  807. }
  808. ],
  809. _a[types_1.RTEToolbarBlock.fullscreen] = [
  810. {
  811. id: "fullscreen",
  812. $fullscreen: false,
  813. tooltip: en_1.default.fullscreen,
  814. type: ts_toolbar_1.ItemType.button,
  815. icon: "dxi-arrow-expand"
  816. }
  817. ],
  818. _a);
  819. var result = toolbarBlocks.reduce(function (config, block, i) {
  820. config.push.apply(config, blocks[block]);
  821. if (i !== toolbarBlocks.length - 1) {
  822. config.push({ type: ts_toolbar_1.ItemType.separator });
  823. }
  824. return config;
  825. }, []);
  826. return result;
  827. }
  828. exports.getToolbarData = getToolbarData;
  829. function createToolbarFontSizes() {
  830. var res = [];
  831. for (var fontSize in exports.fontSizes) {
  832. var value = parseInt(fontSize, 10);
  833. res.push({
  834. id: "font-size-" + value,
  835. value: fontSize
  836. });
  837. }
  838. return res;
  839. }
  840. function createToolbarFonts() {
  841. var res = [];
  842. for (var font in exports.fonts) {
  843. res.push({
  844. id: "font-" + font,
  845. value: font
  846. });
  847. }
  848. return res;
  849. }
  850. exports.fonts = {
  851. "Roboto": true,
  852. "Arial": true,
  853. "Georgia": true,
  854. "Tahoma": true,
  855. "Times New Roman": true,
  856. "Verdana": true
  857. };
  858. exports.fontSizes = {
  859. "12px": true,
  860. "14px": true,
  861. "16px": true,
  862. "18px": true,
  863. "20px": true,
  864. "24px": true,
  865. "28px": true,
  866. "32px": true,
  867. "36px": true
  868. };
  869. exports.emptyStyle = {};
  870. exports.defaultBlocks = [
  871. types_1.RTEToolbarBlock.undo,
  872. types_1.RTEToolbarBlock.style,
  873. types_1.RTEToolbarBlock.decoration,
  874. types_1.RTEToolbarBlock.color,
  875. types_1.RTEToolbarBlock.align,
  876. types_1.RTEToolbarBlock.link
  877. ];
  878. exports.defaultFontSizeByBlock = {
  879. p: "14px",
  880. h1: "36px",
  881. h2: "32px",
  882. h3: "28px",
  883. h4: "24px",
  884. h5: "20px",
  885. h6: "16px"
  886. };
  887. exports.defaultDiffrentStyle = (_a = {},
  888. _a[types_1.Modifier.fontSize] = "",
  889. _a[types_1.Modifier.fontFamily] = "",
  890. _a[types_1.Modifier.style] = "",
  891. _a[types_1.Modifier.bold] = false,
  892. _a[types_1.Modifier.underline] = false,
  893. _a[types_1.Modifier.bold] = false,
  894. _a[types_1.Modifier.italic] = false,
  895. _a[types_1.Modifier.strike] = false,
  896. _a[types_1.Modifier.color] = "#4c4c4c",
  897. _a[types_1.Modifier.background] = "#FFFFFF",
  898. _a[types_1.Modifier.align] = false,
  899. _a);
  900. /***/ }),
  901. /* 6 */
  902. /***/ (function(module, exports, __webpack_require__) {
  903. "use strict";
  904. Object.defineProperty(exports, "__esModule", { value: true });
  905. var dom_1 = __webpack_require__(0);
  906. function getCss(item) {
  907. var className = "";
  908. if (item.active) {
  909. className += " dhx_toolbar-button--active";
  910. }
  911. if (item.css) {
  912. if (Array.isArray(item.css)) {
  913. className += item.css.join(" ");
  914. }
  915. else {
  916. className += " " + item.css;
  917. }
  918. }
  919. return className;
  920. }
  921. exports.getCss = getCss;
  922. function getIconButtonClass(item) {
  923. var className = !item.value && item.icon && "dhx_toolbar-button--icon " || "";
  924. return className;
  925. }
  926. exports.getIconButtonClass = getIconButtonClass;
  927. function counter(item) {
  928. if (item.count) {
  929. return dom_1.el(".dhx_toolbar-counter", parseInt(item.count, 10) > 99 ? "99+" : item.count);
  930. }
  931. }
  932. exports.counter = counter;
  933. function icon(iconName, type) {
  934. if (iconName === void 0) { iconName = ""; }
  935. if (iconName.slice(0, 3) === "dxi") {
  936. iconName = "dxi " + iconName;
  937. }
  938. return dom_1.el("span", {
  939. class: "dhx_" + type + "__icon " + iconName
  940. });
  941. }
  942. exports.icon = icon;
  943. /***/ }),
  944. /* 7 */
  945. /***/ (function(module, exports, __webpack_require__) {
  946. "use strict";
  947. Object.defineProperty(exports, "__esModule", { value: true });
  948. var EventSystem = /** @class */ (function () {
  949. function EventSystem(context) {
  950. this.events = {};
  951. this.context = context || this;
  952. }
  953. EventSystem.prototype.on = function (name, callback, context) {
  954. var event = name.toLowerCase();
  955. this.events[event] = this.events[event] || [];
  956. this.events[event].push({ callback: callback, context: context || this.context });
  957. };
  958. EventSystem.prototype.detach = function (name, context) {
  959. var event = name.toLowerCase();
  960. var eStack = this.events[event];
  961. if (context) {
  962. for (var i = eStack.length - 1; i >= 0; i--) {
  963. if (eStack[i].context === context) {
  964. eStack.splice(i, 1);
  965. }
  966. }
  967. }
  968. else {
  969. this.events[event] = [];
  970. }
  971. };
  972. EventSystem.prototype.fire = function (name, args) {
  973. if (typeof args === "undefined") {
  974. args = [];
  975. }
  976. var event = name.toLowerCase();
  977. if (this.events[event]) {
  978. var res = this.events[event].map(function (e) { return e.callback.apply(e.context, args); });
  979. return res.indexOf(false) < 0;
  980. }
  981. return true;
  982. };
  983. return EventSystem;
  984. }());
  985. exports.EventSystem = EventSystem;
  986. function EventsMixin(obj) {
  987. obj = obj || {};
  988. var eventSystem = new EventSystem(obj);
  989. obj.detachEvent = eventSystem.detach.bind(eventSystem);
  990. obj.attachEvent = eventSystem.on.bind(eventSystem);
  991. obj.callEvent = eventSystem.fire.bind(eventSystem);
  992. }
  993. exports.EventsMixin = EventsMixin;
  994. /***/ }),
  995. /* 8 */
  996. /***/ (function(module, exports, __webpack_require__) {
  997. "use strict";
  998. Object.defineProperty(exports, "__esModule", { value: true });
  999. var core_1 = __webpack_require__(3);
  1000. var html_1 = __webpack_require__(1);
  1001. var View = /** @class */ (function () {
  1002. function View(_container, config) {
  1003. this._uid = core_1.uid();
  1004. this.config = config || {};
  1005. }
  1006. View.prototype.mount = function (container, vnode) {
  1007. if (vnode) {
  1008. this._view = vnode;
  1009. }
  1010. if (container && this._view && this._view.mount) {
  1011. // init view inside of HTML container
  1012. this._container = html_1.toNode(container);
  1013. if (this._container.tagName) {
  1014. this._view.mount(this._container);
  1015. }
  1016. else if (this._container.attach) {
  1017. this._container.attach(this);
  1018. }
  1019. }
  1020. };
  1021. View.prototype.getRootView = function () {
  1022. return this._view;
  1023. };
  1024. View.prototype.paint = function () {
  1025. if (this._view && ( // was mounted
  1026. this._view.node || // already rendered node
  1027. this._container)) { // not rendered, but has container
  1028. this._doNotRepaint = false;
  1029. this._view.redraw();
  1030. }
  1031. };
  1032. return View;
  1033. }());
  1034. exports.View = View;
  1035. /***/ }),
  1036. /* 9 */
  1037. /***/ (function(module, exports, __webpack_require__) {
  1038. "use strict";
  1039. Object.defineProperty(exports, "__esModule", { value: true });
  1040. var types_1 = __webpack_require__(12);
  1041. exports.DataEvents = types_1.DataEvents;
  1042. exports.DragBehaviour = types_1.DragBehaviour;
  1043. exports.DragMode = types_1.DragMode;
  1044. var TreeFilterType;
  1045. (function (TreeFilterType) {
  1046. TreeFilterType[TreeFilterType["all"] = 1] = "all";
  1047. TreeFilterType[TreeFilterType["specific"] = 2] = "specific";
  1048. TreeFilterType[TreeFilterType["leafs"] = 3] = "leafs";
  1049. })(TreeFilterType = exports.TreeFilterType || (exports.TreeFilterType = {}));
  1050. /***/ }),
  1051. /* 10 */
  1052. /***/ (function(module, exports, __webpack_require__) {
  1053. "use strict";
  1054. Object.defineProperty(exports, "__esModule", { value: true });
  1055. var dataproxy_1 = __webpack_require__(15);
  1056. var CsvDriver_1 = __webpack_require__(24);
  1057. var JsonDriver_1 = __webpack_require__(25);
  1058. function isEqualObj(a, b) {
  1059. for (var key in a) {
  1060. if (a[key] !== b[key]) {
  1061. return false;
  1062. }
  1063. }
  1064. return true;
  1065. }
  1066. exports.isEqualObj = isEqualObj;
  1067. function naturalCompare(a, b) {
  1068. var ax = [];
  1069. var bx = [];
  1070. a.replace(/(\d+)|(\D+)/g, function (_, $1, $2) { ax.push([$1 || Infinity, $2 || ""]); });
  1071. b.replace(/(\d+)|(\D+)/g, function (_, $1, $2) { bx.push([$1 || Infinity, $2 || ""]); });
  1072. while (ax.length && bx.length) {
  1073. var an = ax.shift();
  1074. var bn = bx.shift();
  1075. var nn = (an[0] - bn[0]) || an[1].localeCompare(bn[1]);
  1076. if (nn) {
  1077. return nn;
  1078. }
  1079. }
  1080. return ax.length - bx.length;
  1081. }
  1082. exports.naturalCompare = naturalCompare;
  1083. function findByConf(item, conf) {
  1084. if (typeof conf === "function") {
  1085. if (conf.call(this, item)) {
  1086. return item;
  1087. }
  1088. }
  1089. else if (conf.by && conf.match) {
  1090. if (item[conf.by] === conf.match) {
  1091. return item;
  1092. }
  1093. }
  1094. }
  1095. exports.findByConf = findByConf;
  1096. function isDebug() {
  1097. var dhx = window.dhx;
  1098. if (typeof dhx !== "undefined") {
  1099. return typeof (dhx.debug) !== "undefined" && dhx.debug;
  1100. }
  1101. // return typeof DHX_DEBUG_MODE !== "undefined" && DHX_DEBUG_MODE;
  1102. }
  1103. exports.isDebug = isDebug;
  1104. function dhxWarning(msg) {
  1105. // tslint:disable-next-line:no-console
  1106. console.warn(msg);
  1107. }
  1108. exports.dhxWarning = dhxWarning;
  1109. function dhxError(msg) {
  1110. throw new Error(msg);
  1111. }
  1112. exports.dhxError = dhxError;
  1113. function toProxy(proxy) {
  1114. var type = typeof proxy;
  1115. if (type === "string") {
  1116. return new dataproxy_1.DataProxy(proxy);
  1117. }
  1118. else if (type === "object") {
  1119. return proxy;
  1120. }
  1121. }
  1122. exports.toProxy = toProxy;
  1123. function toDataDriver(driver) {
  1124. var type = typeof driver;
  1125. if (type === "string") {
  1126. switch (driver) {
  1127. case "csv":
  1128. return new CsvDriver_1.CsvDriver();
  1129. case "json":
  1130. return new JsonDriver_1.JsonDriver();
  1131. default:
  1132. // tslint:disable-next-line:no-console
  1133. console.warn("incorrect driver type", driver);
  1134. break;
  1135. }
  1136. }
  1137. else if (typeof driver === "object") {
  1138. return driver;
  1139. }
  1140. }
  1141. exports.toDataDriver = toDataDriver;
  1142. /***/ }),
  1143. /* 11 */
  1144. /***/ (function(module, exports, __webpack_require__) {
  1145. "use strict";
  1146. Object.defineProperty(exports, "__esModule", { value: true });
  1147. var locale = {
  1148. apply: "Apply",
  1149. undo: "Undo",
  1150. redo: "Redo",
  1151. selectFontFamily: "Font",
  1152. selectFontSize: "Font size",
  1153. selectFormat: "Style",
  1154. selectTextColor: "Text color",
  1155. selectTextBackground: "Background color",
  1156. markBold: "Bold",
  1157. markItalic: "Italic",
  1158. markStrike: "Strike",
  1159. markUnderline: "Underline",
  1160. alignLeft: "Align left",
  1161. alignCenter: "Align center",
  1162. alignRight: "Align right",
  1163. addLink: "Add link",
  1164. clearFormat: "Clear formatting",
  1165. fullscreen: "Fullscreen",
  1166. stats: "Statistics",
  1167. removeLink: "Remove link",
  1168. edit: "Edit",
  1169. h1: "Heading 1",
  1170. h2: "Heading 2",
  1171. h3: "Heading 3",
  1172. h4: "Heading 4",
  1173. h5: "Heading 5",
  1174. h6: "Heading 6",
  1175. p: "Normal text",
  1176. blockquote: "Block quote",
  1177. chars: "chars",
  1178. charsExlSpace: "Characters without spaces",
  1179. words: "words",
  1180. };
  1181. exports.default = locale;
  1182. /***/ }),
  1183. /* 12 */
  1184. /***/ (function(module, exports, __webpack_require__) {
  1185. "use strict";
  1186. Object.defineProperty(exports, "__esModule", { value: true });
  1187. var DataEvents;
  1188. (function (DataEvents) {
  1189. DataEvents["afterAdd"] = "afteradd";
  1190. DataEvents["beforeAdd"] = "beforeadd";
  1191. DataEvents["removeAll"] = "removeall";
  1192. DataEvents["beforeRemove"] = "beforeremove";
  1193. DataEvents["afterRemove"] = "afterremove";
  1194. DataEvents["change"] = "change";
  1195. DataEvents["load"] = "load";
  1196. })(DataEvents = exports.DataEvents || (exports.DataEvents = {}));
  1197. var DragEvents;
  1198. (function (DragEvents) {
  1199. DragEvents["beforeDrag"] = "beforedrag";
  1200. DragEvents["beforeDrop"] = "beforeDrop";
  1201. DragEvents["dragStart"] = "dragstart";
  1202. DragEvents["dragEnd"] = "dragend";
  1203. DragEvents["canDrop"] = "candrop";
  1204. DragEvents["cancelDrop"] = "canceldrop";
  1205. DragEvents["dropComplete"] = "dropcomplete";
  1206. DragEvents["dragOut"] = "dragOut";
  1207. DragEvents["dragIn"] = "dragIn";
  1208. })(DragEvents = exports.DragEvents || (exports.DragEvents = {}));
  1209. var DragMode;
  1210. (function (DragMode) {
  1211. DragMode["target"] = "target";
  1212. DragMode["both"] = "both";
  1213. DragMode["source"] = "source";
  1214. })(DragMode = exports.DragMode || (exports.DragMode = {}));
  1215. var DragBehaviour;
  1216. (function (DragBehaviour) {
  1217. DragBehaviour["child"] = "child";
  1218. DragBehaviour["sibling"] = "sibling";
  1219. DragBehaviour["complex"] = "complex";
  1220. })(DragBehaviour = exports.DragBehaviour || (exports.DragBehaviour = {}));
  1221. var SelectionEvents;
  1222. (function (SelectionEvents) {
  1223. SelectionEvents["beforeUnSelect"] = "beforeunselect";
  1224. SelectionEvents["afterUnSelect"] = "afterunselect";
  1225. SelectionEvents["beforeSelect"] = "beforeselect";
  1226. SelectionEvents["afterSelect"] = "afterselect";
  1227. })(SelectionEvents = exports.SelectionEvents || (exports.SelectionEvents = {}));
  1228. /***/ }),
  1229. /* 13 */
  1230. /***/ (function(module, exports, __webpack_require__) {
  1231. /* WEBPACK VAR INJECTION */(function(global, setImmediate) {(function () {
  1232. global = this
  1233. var queueId = 1
  1234. var queue = {}
  1235. var isRunningTask = false
  1236. if (!global.setImmediate)
  1237. global.addEventListener('message', function (e) {
  1238. if (e.source == global){
  1239. if (isRunningTask)
  1240. nextTick(queue[e.data])
  1241. else {
  1242. isRunningTask = true
  1243. try {
  1244. queue[e.data]()
  1245. } catch (e) {}
  1246. delete queue[e.data]
  1247. isRunningTask = false
  1248. }
  1249. }
  1250. })
  1251. function nextTick(fn) {
  1252. if (global.setImmediate) setImmediate(fn)
  1253. // if inside of web worker
  1254. else if (global.importScripts) setTimeout(fn)
  1255. else {
  1256. queueId++
  1257. queue[queueId] = fn
  1258. global.postMessage(queueId, '*')
  1259. }
  1260. }
  1261. Deferred.resolve = function (value) {
  1262. if (!(this._d == 1))
  1263. throw TypeError()
  1264. if (value instanceof Deferred)
  1265. return value
  1266. return new Deferred(function (resolve) {
  1267. resolve(value)
  1268. })
  1269. }
  1270. Deferred.reject = function (value) {
  1271. if (!(this._d == 1))
  1272. throw TypeError()
  1273. return new Deferred(function (resolve, reject) {
  1274. reject(value)
  1275. })
  1276. }
  1277. Deferred.all = function (arr) {
  1278. if (!(this._d == 1))
  1279. throw TypeError()
  1280. if (!(arr instanceof Array))
  1281. return Deferred.reject(TypeError())
  1282. var d = new Deferred()
  1283. function done(e, v) {
  1284. if (v)
  1285. return d.resolve(v)
  1286. if (e)
  1287. return d.reject(e)
  1288. var unresolved = arr.reduce(function (cnt, v) {
  1289. if (v && v.then)
  1290. return cnt + 1
  1291. return cnt
  1292. }, 0)
  1293. if(unresolved == 0)
  1294. d.resolve(arr)
  1295. arr.map(function (v, i) {
  1296. if (v && v.then)
  1297. v.then(function (r) {
  1298. arr[i] = r
  1299. done()
  1300. return r
  1301. }, done)
  1302. })
  1303. }
  1304. done()
  1305. return d
  1306. }
  1307. Deferred.race = function (arr) {
  1308. if (!(this._d == 1))
  1309. throw TypeError()
  1310. if (!(arr instanceof Array))
  1311. return Deferred.reject(TypeError())
  1312. if (arr.length == 0)
  1313. return new Deferred()
  1314. var d = new Deferred()
  1315. function done(e, v) {
  1316. if (v)
  1317. return d.resolve(v)
  1318. if (e)
  1319. return d.reject(e)
  1320. var unresolved = arr.reduce(function (cnt, v) {
  1321. if (v && v.then)
  1322. return cnt + 1
  1323. return cnt
  1324. }, 0)
  1325. if(unresolved == 0)
  1326. d.resolve(arr)
  1327. arr.map(function (v, i) {
  1328. if (v && v.then)
  1329. v.then(function (r) {
  1330. done(null, r)
  1331. }, done)
  1332. })
  1333. }
  1334. done()
  1335. return d
  1336. }
  1337. Deferred._d = 1
  1338. /**
  1339. * @constructor
  1340. */
  1341. function Deferred(resolver) {
  1342. 'use strict'
  1343. if (typeof resolver != 'function' && resolver != undefined)
  1344. throw TypeError()
  1345. if (typeof this != 'object' || (this && this.then))
  1346. throw TypeError()
  1347. // states
  1348. // 0: pending
  1349. // 1: resolving
  1350. // 2: rejecting
  1351. // 3: resolved
  1352. // 4: rejected
  1353. var self = this,
  1354. state = 0,
  1355. val = 0,
  1356. next = [],
  1357. fn, er;
  1358. self['promise'] = self
  1359. self['resolve'] = function (v) {
  1360. fn = self.fn
  1361. er = self.er
  1362. if (!state) {
  1363. val = v
  1364. state = 1
  1365. nextTick(fire)
  1366. }
  1367. return self
  1368. }
  1369. self['reject'] = function (v) {
  1370. fn = self.fn
  1371. er = self.er
  1372. if (!state) {
  1373. val = v
  1374. state = 2
  1375. nextTick(fire)
  1376. }
  1377. return self
  1378. }
  1379. self['_d'] = 1
  1380. self['then'] = function (_fn, _er) {
  1381. if (!(this._d == 1))
  1382. throw TypeError()
  1383. var d = new Deferred()
  1384. d.fn = _fn
  1385. d.er = _er
  1386. if (state == 3) {
  1387. d.resolve(val)
  1388. }
  1389. else if (state == 4) {
  1390. d.reject(val)
  1391. }
  1392. else {
  1393. next.push(d)
  1394. }
  1395. return d
  1396. }
  1397. self['catch'] = function (_er) {
  1398. return self['then'](null, _er)
  1399. }
  1400. var finish = function (type) {
  1401. state = type || 4
  1402. next.map(function (p) {
  1403. state == 3 && p.resolve(val) || p.reject(val)
  1404. })
  1405. }
  1406. try {
  1407. if (typeof resolver == 'function')
  1408. resolver(self['resolve'], self['reject'])
  1409. } catch (e) {
  1410. self['reject'](e)
  1411. }
  1412. return self
  1413. // ref : reference to 'then' function
  1414. // cb, ec, cn : successCallback, failureCallback, notThennableCallback
  1415. function thennable (ref, cb, ec, cn) {
  1416. // Promises can be rejected with other promises, which should pass through
  1417. if (state == 2) {
  1418. return cn()
  1419. }
  1420. if ((typeof val == 'object' || typeof val == 'function') && typeof ref == 'function') {
  1421. try {
  1422. // cnt protects against abuse calls from spec checker
  1423. var cnt = 0
  1424. ref.call(val, function (v) {
  1425. if (cnt++) return
  1426. val = v
  1427. cb()
  1428. }, function (v) {
  1429. if (cnt++) return
  1430. val = v
  1431. ec()
  1432. })
  1433. } catch (e) {
  1434. val = e
  1435. ec()
  1436. }
  1437. } else {
  1438. cn()
  1439. }
  1440. };
  1441. function fire() {
  1442. // check if it's a thenable
  1443. var ref;
  1444. try {
  1445. ref = val && val.then
  1446. } catch (e) {
  1447. val = e
  1448. state = 2
  1449. return fire()
  1450. }
  1451. thennable(ref, function () {
  1452. state = 1
  1453. fire()
  1454. }, function () {
  1455. state = 2
  1456. fire()
  1457. }, function () {
  1458. try {
  1459. if (state == 1 && typeof fn == 'function') {
  1460. val = fn(val)
  1461. }
  1462. else if (state == 2 && typeof er == 'function') {
  1463. val = er(val)
  1464. state = 1
  1465. }
  1466. } catch (e) {
  1467. val = e
  1468. return finish()
  1469. }
  1470. if (val == self) {
  1471. val = TypeError()
  1472. finish()
  1473. } else thennable(ref, function () {
  1474. finish(3)
  1475. }, finish, function () {
  1476. finish(state == 1 && 3)
  1477. })
  1478. })
  1479. }
  1480. }
  1481. // Export our library object, either for node.js or as a globally scoped variable
  1482. if (true) {
  1483. module['exports'] = Deferred
  1484. } else {}
  1485. })()
  1486. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(14), __webpack_require__(49).setImmediate))
  1487. /***/ }),
  1488. /* 14 */
  1489. /***/ (function(module, exports) {
  1490. var g;
  1491. // This works in non-strict mode
  1492. g = (function() {
  1493. return this;
  1494. })();
  1495. try {
  1496. // This works if eval is allowed (see CSP)
  1497. g = g || new Function("return this")();
  1498. } catch (e) {
  1499. // This works if the window reference is available
  1500. if (typeof window === "object") g = window;
  1501. }
  1502. // g can still be undefined, but nothing to do about it...
  1503. // We return undefined, instead of nothing here, so it's
  1504. // easier to handle this case. if(!global) { ...}
  1505. module.exports = g;
  1506. /***/ }),
  1507. /* 15 */
  1508. /***/ (function(module, exports, __webpack_require__) {
  1509. "use strict";
  1510. /* WEBPACK VAR INJECTION */(function(Promise) {
  1511. Object.defineProperty(exports, "__esModule", { value: true });
  1512. var DataProxy = /** @class */ (function () {
  1513. function DataProxy(url) {
  1514. this.url = url;
  1515. }
  1516. DataProxy.prototype.load = function () {
  1517. return this._ajax(this.url);
  1518. };
  1519. DataProxy.prototype.save = function (data, mode) {
  1520. var modes = {
  1521. insert: "POST",
  1522. delete: "DELETE",
  1523. update: "POST"
  1524. };
  1525. return this._ajax(this.url, data, modes[mode] || "POST");
  1526. };
  1527. DataProxy.prototype._ajax = function (url, data, method) {
  1528. if (method === void 0) { method = "GET"; }
  1529. return new Promise(function (resolve, reject) {
  1530. var xhr = new XMLHttpRequest();
  1531. xhr.onload = function () {
  1532. if (xhr.status >= 200 && xhr.status < 300) {
  1533. resolve(xhr.response || xhr.responseText);
  1534. }
  1535. else {
  1536. reject({
  1537. status: xhr.status,
  1538. statusText: xhr.statusText
  1539. });
  1540. }
  1541. };
  1542. xhr.onerror = function () {
  1543. reject({
  1544. status: xhr.status,
  1545. statusText: xhr.statusText
  1546. });
  1547. };
  1548. xhr.open(method, url);
  1549. xhr.setRequestHeader("Content-Type", "application/json");
  1550. switch (method) {
  1551. case "POST":
  1552. case "DELETE":
  1553. case "PUT":
  1554. xhr.send(JSON.stringify(data));
  1555. break;
  1556. case "GET":
  1557. xhr.send();
  1558. break;
  1559. default:
  1560. xhr.send();
  1561. break;
  1562. }
  1563. });
  1564. };
  1565. return DataProxy;
  1566. }());
  1567. exports.DataProxy = DataProxy;
  1568. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(13)))
  1569. /***/ }),
  1570. /* 16 */
  1571. /***/ (function(module, exports, __webpack_require__) {
  1572. "use strict";
  1573. Object.defineProperty(exports, "__esModule", { value: true });
  1574. var types_1 = __webpack_require__(12);
  1575. exports.DataEvents = types_1.DataEvents;
  1576. var ItemType;
  1577. (function (ItemType) {
  1578. ItemType["button"] = "button";
  1579. ItemType["dhxButton"] = "dhxButton";
  1580. ItemType["imageButton"] = "imageButton";
  1581. ItemType["selectButton"] = "selectButton";
  1582. ItemType["input"] = "input";
  1583. ItemType["separator"] = "separator";
  1584. ItemType["text"] = "text";
  1585. ItemType["spacer"] = "spacer";
  1586. ItemType["menuItem"] = "menuItem";
  1587. ItemType["block"] = "block";
  1588. ItemType["customHTMLButton"] = "customButton";
  1589. })(ItemType = exports.ItemType || (exports.ItemType = {}));
  1590. var NavigationBarEvents;
  1591. (function (NavigationBarEvents) {
  1592. NavigationBarEvents["inputCreated"] = "inputcreated";
  1593. NavigationBarEvents["click"] = "click";
  1594. NavigationBarEvents["openMenu"] = "openmenu";
  1595. })(NavigationBarEvents = exports.NavigationBarEvents || (exports.NavigationBarEvents = {}));
  1596. var NavigationType;
  1597. (function (NavigationType) {
  1598. NavigationType["pointer"] = "pointer";
  1599. NavigationType["click"] = "click";
  1600. })(NavigationType = exports.NavigationType || (exports.NavigationType = {}));
  1601. /***/ }),
  1602. /* 17 */
  1603. /***/ (function(module, exports, __webpack_require__) {
  1604. "use strict";
  1605. var __extends = (this && this.__extends) || (function () {
  1606. var extendStatics = Object.setPrototypeOf ||
  1607. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1608. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1609. return function (d, b) {
  1610. extendStatics(d, b);
  1611. function __() { this.constructor = d; }
  1612. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1613. };
  1614. })();
  1615. var __assign = (this && this.__assign) || Object.assign || function(t) {
  1616. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1617. s = arguments[i];
  1618. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  1619. t[p] = s[p];
  1620. }
  1621. return t;
  1622. };
  1623. Object.defineProperty(exports, "__esModule", { value: true });
  1624. var core_1 = __webpack_require__(3);
  1625. var dom_1 = __webpack_require__(0);
  1626. var events_1 = __webpack_require__(7);
  1627. var html_1 = __webpack_require__(1);
  1628. var Keymanager_1 = __webpack_require__(46);
  1629. var view_1 = __webpack_require__(8);
  1630. var ts_data_1 = __webpack_require__(47);
  1631. var itemfactory_1 = __webpack_require__(27);
  1632. var types_1 = __webpack_require__(16);
  1633. var MenuBase = /** @class */ (function (_super) {
  1634. __extends(MenuBase, _super);
  1635. function MenuBase(element, config) {
  1636. var _this = _super.call(this, element, core_1.extend({}, config)) || this;
  1637. _this._isContextMenu = false;
  1638. _this._documentHaveListener = false;
  1639. _this._rootItem = {};
  1640. _this.events = new events_1.EventSystem();
  1641. _this.data = new ts_data_1.TreeCollection({}, _this.events);
  1642. _this._documentClick = function (e) {
  1643. if (html_1.locate(e, "dhx_widget_id") !== _this._uid && _this._documentHaveListener) {
  1644. document.removeEventListener("click", _this._documentClick);
  1645. _this._documentHaveListener = false;
  1646. _this._close();
  1647. }
  1648. };
  1649. _this._currentRoot = _this.data.getRoot();
  1650. _this._factory = itemfactory_1.createFactory(types_1.ItemType.menuItem);
  1651. _this._init();
  1652. _this._initHandlers();
  1653. _this._initEvents();
  1654. return _this;
  1655. }
  1656. MenuBase.prototype.paint = function () {
  1657. _super.prototype.paint.call(this);
  1658. this._vpopups.redraw();
  1659. };
  1660. MenuBase.prototype.disable = function (ids) {
  1661. this._setProp(ids, "$disabled", true);
  1662. };
  1663. MenuBase.prototype.enable = function (ids) {
  1664. this._setProp(ids, "$disabled", false);
  1665. };
  1666. MenuBase.prototype.show = function (ids) {
  1667. this._setProp(ids, "$hidden", false);
  1668. };
  1669. MenuBase.prototype.hide = function (ids) {
  1670. this._setProp(ids, "$hidden", true);
  1671. };
  1672. MenuBase.prototype.destructor = function () {
  1673. Keymanager_1.keyManager.removeHotKey(null, this);
  1674. };
  1675. MenuBase.prototype._close = function () {
  1676. if (this.config.navigationType === types_1.NavigationType.click) {
  1677. this._isActive = false;
  1678. }
  1679. clearTimeout(this._currentTimeout);
  1680. this._activeMenu = null;
  1681. this.paint();
  1682. };
  1683. MenuBase.prototype._init = function () {
  1684. var _this = this;
  1685. var render = function () { return dom_1.el("div", __assign({ dhx_widget_id: _this._uid, class: "menu-popups" + (_this._isContextMenu ? " context-menu" : "") }, _this._handlers), _this._drawPopups()); };
  1686. this._vpopups = dom_1.create({
  1687. render: render
  1688. });
  1689. this._vpopups.mount(document.body);
  1690. };
  1691. MenuBase.prototype._initHandlers = function () {
  1692. var _this = this;
  1693. /*
  1694. for navigation type click:
  1695. first click open menu, _isActive = true
  1696. after navigation use mousemove
  1697. can be closed after outer click or menu leaf item click
  1698. */
  1699. this._isActive = this.config.navigationType !== types_1.NavigationType.click;
  1700. this._handlers = {
  1701. onmousemove: function (e) {
  1702. if (!_this._isActive) {
  1703. return;
  1704. }
  1705. var elem = html_1.locateNode(e);
  1706. if (!elem) {
  1707. _this._activeItemChange(null);
  1708. return;
  1709. }
  1710. var id = elem.getAttribute("dhx_id");
  1711. if (_this._activeMenu !== id) {
  1712. _this._activeMenu = id;
  1713. if (_this.data.haveItems(id)) {
  1714. var position = html_1.getRealPosition(elem);
  1715. _this.data.update(id, { $position: position }, false);
  1716. }
  1717. _this._activeItemChange(id);
  1718. }
  1719. },
  1720. onmouseleave: function () {
  1721. if (_this.config.navigationType !== types_1.NavigationType.click) { // maybe all time when mouse leave close menu
  1722. _this._activeItemChange(null);
  1723. }
  1724. },
  1725. onclick: function (e) {
  1726. var element = html_1.locateNode(e);
  1727. if (!element) {
  1728. return;
  1729. }
  1730. var id = element.getAttribute("dhx_id");
  1731. var item = _this.data.getItem(id);
  1732. if (item.multiClick) {
  1733. return;
  1734. }
  1735. if (_this.data.haveItems(id)) {
  1736. if (id === _this._currentRoot) {
  1737. _this._close();
  1738. return;
  1739. }
  1740. if (!_this._isActive) {
  1741. _this._isActive = true;
  1742. }
  1743. _this._setRoot(id);
  1744. _this._activeMenu = id;
  1745. var position = html_1.getRealPosition(element);
  1746. _this.data.update(id, { $position: position }, false);
  1747. _this._activeItemChange(id);
  1748. }
  1749. else {
  1750. switch (item.type) {
  1751. case types_1.ItemType.input:
  1752. case types_1.ItemType.text:
  1753. break;
  1754. case types_1.ItemType.menuItem:
  1755. case types_1.ItemType.selectButton:
  1756. _this._onMenuItemClick(id, e);
  1757. break;
  1758. case types_1.ItemType.imageButton:
  1759. case types_1.ItemType.dhxButton:
  1760. case types_1.ItemType.button:
  1761. case types_1.ItemType.customHTMLButton:
  1762. if (item.twoState) {
  1763. _this.data.update(item.id, { active: !item.active });
  1764. }
  1765. _this.events.fire(types_1.NavigationBarEvents.click, [id, e]);
  1766. // missed break for trigger close
  1767. default:
  1768. _this._close();
  1769. }
  1770. }
  1771. },
  1772. onmousedown: function (e) {
  1773. var element = html_1.locateNode(e);
  1774. if (!element) {
  1775. return;
  1776. }
  1777. var id = element.getAttribute("dhx_id");
  1778. var item = _this.data.getItem(id);
  1779. if (!item.multiClick) {
  1780. return;
  1781. }
  1782. var fireTime = 365;
  1783. var timeout;
  1784. var fireAction = function () {
  1785. _this.events.fire(types_1.NavigationBarEvents.click, [id, e]);
  1786. if (fireTime > 50) {
  1787. fireTime -= 55;
  1788. }
  1789. timeout = setTimeout(fireAction, fireTime);
  1790. };
  1791. var mouseup = function () {
  1792. clearTimeout(timeout);
  1793. document.removeEventListener("mouseup", mouseup);
  1794. };
  1795. fireAction();
  1796. document.addEventListener("mouseup", mouseup);
  1797. }
  1798. };
  1799. };
  1800. MenuBase.prototype._initEvents = function () {
  1801. var _this = this;
  1802. var timeout = null;
  1803. this.data.events.on(types_1.DataEvents.change, function () {
  1804. _this.paint();
  1805. if (timeout) {
  1806. clearTimeout(timeout);
  1807. }
  1808. timeout = setTimeout(function () {
  1809. _this._normalizeData();
  1810. _this._resetHotkeys();
  1811. timeout = null;
  1812. _this.paint();
  1813. }, 100);
  1814. });
  1815. this.events.on(types_1.NavigationBarEvents.click, function (id) {
  1816. var item = _this.data.getItem(id);
  1817. var parent = _this.data.getItem(item.parent);
  1818. if (parent && parent.type === types_1.ItemType.selectButton) {
  1819. _this.data.update(item.parent, { value: item.value, icon: item.icon });
  1820. }
  1821. if (item.group) {
  1822. var group = _this._groups[item.group];
  1823. if (group.active) {
  1824. _this.data.update(group.active, { active: false });
  1825. }
  1826. group.active = item.id;
  1827. _this.data.update(item.id, { active: true });
  1828. }
  1829. });
  1830. };
  1831. MenuBase.prototype._drawPopups = function () {
  1832. var _this = this;
  1833. var id = this._activeMenu;
  1834. if (!this._isContextMenu && !id) {
  1835. return null;
  1836. }
  1837. var root = this._currentRoot;
  1838. if (this._isContextMenu && !this._activePosition) {
  1839. return null;
  1840. }
  1841. var parentIds = this._getParents(id, root);
  1842. return parentIds.map(function (itemId) {
  1843. if (!_this.data.haveItems(itemId)) {
  1844. return null;
  1845. }
  1846. var item = _this.data.getItem(itemId) || _this._rootItem; // for root item
  1847. return dom_1.el("ul", {
  1848. class: "dhx_menu",
  1849. _key: itemId,
  1850. _hooks: {
  1851. didInsert: function (vnode) {
  1852. var _a = vnode.el.getBoundingClientRect(), width = _a.width, height = _a.height;
  1853. var position = _this._isContextMenu && _this._activePosition && itemId === root ? _this._activePosition : item.$position;
  1854. var mode = _this._getMode(item, root, position === _this._activePosition);
  1855. var style = html_1.calculatePosition(position, { mode: mode, width: width, height: height });
  1856. item.$style = style;
  1857. vnode.patch({ style: style });
  1858. }
  1859. },
  1860. tabindex: 0,
  1861. style: item.$style || {
  1862. position: "absolute"
  1863. }
  1864. }, _this._drawMenuItems(itemId));
  1865. }).reverse();
  1866. };
  1867. MenuBase.prototype._onMenuItemClick = function (id, e) {
  1868. var item = this.data.getItem(id);
  1869. if (item.$disabled) {
  1870. return;
  1871. }
  1872. if (item.twoState) {
  1873. this.data.update(item.id, { active: !item.active });
  1874. }
  1875. this.events.fire(types_1.NavigationBarEvents.click, [id, e]);
  1876. this._close();
  1877. };
  1878. MenuBase.prototype._activeItemChange = function (id) {
  1879. var _this = this;
  1880. if (id && !this._documentHaveListener) {
  1881. this._listenOuterClick();
  1882. }
  1883. if (id && this.data.haveItems(id)) {
  1884. this.events.fire(types_1.NavigationBarEvents.openMenu);
  1885. this._activeMenu = id;
  1886. clearTimeout(this._currentTimeout);
  1887. this.paint();
  1888. }
  1889. else {
  1890. this._activeMenu = id;
  1891. clearTimeout(this._currentTimeout);
  1892. this._currentTimeout = setTimeout(function () { return _this.paint(); }, 400);
  1893. }
  1894. };
  1895. MenuBase.prototype._resetHotkeys = function () {
  1896. var _this = this;
  1897. Keymanager_1.keyManager.removeHotKey(null, this);
  1898. this.data.map(function (item) {
  1899. if (item.hotkey) {
  1900. Keymanager_1.keyManager.addHotKey(item.hotkey, function () { return _this._onMenuItemClick(item.id, null); }, _this);
  1901. }
  1902. });
  1903. };
  1904. MenuBase.prototype._listenOuterClick = function () {
  1905. document.addEventListener("click", this._documentClick);
  1906. this._documentHaveListener = true;
  1907. };
  1908. MenuBase.prototype._getMode = function (item, root, _active) {
  1909. if (_active === void 0) { _active = false; }
  1910. return item.parent === root ? "bottom" : "right";
  1911. };
  1912. MenuBase.prototype._drawMenuItems = function (id) {
  1913. var _this = this;
  1914. return this.data.map(function (item) { return _this._factory(item, _this.events); }, id, false);
  1915. };
  1916. MenuBase.prototype._normalizeData = function () {
  1917. var _this = this;
  1918. var root = this.data.getRoot();
  1919. var groups = {};
  1920. this.data.eachChild(root, function (item) {
  1921. if (_this.data.haveItems(item.id) && item.parent !== _this.data.getRoot()) {
  1922. item.$openIcon = "right";
  1923. }
  1924. if (item.group) {
  1925. addInGroups(groups, item);
  1926. }
  1927. }, true);
  1928. this._groups = groups;
  1929. };
  1930. MenuBase.prototype._setRoot = function (_id) {
  1931. return; // need only for toolbar
  1932. };
  1933. MenuBase.prototype._getParents = function (id, root) {
  1934. var parentIds = [];
  1935. var afterRoot = false;
  1936. var currentItem = this.data.getItem(id);
  1937. var disabled = currentItem && currentItem.$disabled;
  1938. this.data.eachParent(id, function (item) {
  1939. if (item.id === root) {
  1940. parentIds.push(item.id);
  1941. afterRoot = true;
  1942. }
  1943. else if (!afterRoot) {
  1944. parentIds.push(item.id);
  1945. }
  1946. }, !disabled);
  1947. if (this._isContextMenu && this._activePosition) {
  1948. parentIds.push(root);
  1949. }
  1950. return parentIds;
  1951. };
  1952. MenuBase.prototype._setProp = function (id, key, value) {
  1953. var _this = this;
  1954. var _a;
  1955. if (Array.isArray(id)) {
  1956. id.forEach(function (itemId) {
  1957. var _a;
  1958. return _this.data.update(itemId, (_a = {}, _a[key] = value, _a));
  1959. });
  1960. }
  1961. else {
  1962. this.data.update(id, (_a = {}, _a[key] = value, _a));
  1963. }
  1964. };
  1965. return MenuBase;
  1966. }(view_1.View));
  1967. exports.MenuBase = MenuBase;
  1968. function addInGroups(groups, item) {
  1969. if (groups[item.group]) {
  1970. if (item.active) {
  1971. groups[item.group].active = item.id;
  1972. }
  1973. groups[item.group].elements.push(item.id);
  1974. }
  1975. else {
  1976. groups[item.group] = {
  1977. active: item.active ? item.id : null,
  1978. elements: [item.id]
  1979. };
  1980. }
  1981. }
  1982. /***/ }),
  1983. /* 18 */
  1984. /***/ (function(module, exports, __webpack_require__) {
  1985. "use strict";
  1986. function __export(m) {
  1987. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1988. }
  1989. Object.defineProperty(exports, "__esModule", { value: true });
  1990. __export(__webpack_require__(71));
  1991. __export(__webpack_require__(30));
  1992. /***/ }),
  1993. /* 19 */
  1994. /***/ (function(module, exports, __webpack_require__) {
  1995. "use strict";
  1996. Object.defineProperty(exports, "__esModule", { value: true });
  1997. var dom_1 = __webpack_require__(0);
  1998. var constants_1 = __webpack_require__(5);
  1999. var types_1 = __webpack_require__(2);
  2000. function calcTextNodeStyle(modifiers) {
  2001. var style = {};
  2002. for (var key in modifiers) {
  2003. if (!modifiers[key]) {
  2004. continue;
  2005. }
  2006. switch (key) {
  2007. case types_1.Modifier.bold:
  2008. style["font-weight"] = "bold";
  2009. break;
  2010. case types_1.Modifier.italic:
  2011. style["font-style"] = "italic";
  2012. break;
  2013. case types_1.Modifier.underline:
  2014. if (style["text-decoration"]) {
  2015. style["text-decoration"] += " underline";
  2016. }
  2017. else {
  2018. style["text-decoration"] = "underline";
  2019. }
  2020. break;
  2021. case types_1.Modifier.strike:
  2022. if (style["text-decoration"]) {
  2023. style["text-decoration"] += " line-through";
  2024. }
  2025. else {
  2026. style["text-decoration"] = "line-through";
  2027. }
  2028. break;
  2029. case types_1.Modifier.color:
  2030. style.color = modifiers[key];
  2031. break;
  2032. case types_1.Modifier.background:
  2033. style.background = modifiers[key];
  2034. break;
  2035. case types_1.Modifier.fontFamily:
  2036. style["font-family"] = modifiers[key];
  2037. break;
  2038. case types_1.Modifier.fontSize:
  2039. style["font-size"] = modifiers[key];
  2040. break;
  2041. }
  2042. }
  2043. return style;
  2044. }
  2045. exports.calcTextNodeStyle = calcTextNodeStyle;
  2046. function calcBlockStyle(modifiers) {
  2047. var style = {};
  2048. for (var key in modifiers) {
  2049. if (!modifiers[key]) {
  2050. continue;
  2051. }
  2052. switch (key) {
  2053. case types_1.Modifier.align:
  2054. style["text-align"] = modifiers[key];
  2055. }
  2056. }
  2057. return style;
  2058. }
  2059. exports.calcBlockStyle = calcBlockStyle;
  2060. function blockStyleToTag(style) {
  2061. if (style[types_1.Modifier.style]) {
  2062. return style[types_1.Modifier.style];
  2063. }
  2064. return "p";
  2065. }
  2066. exports.blockStyleToTag = blockStyleToTag;
  2067. function blockquoteWrapper(style, blockIndex) {
  2068. if (style[types_1.Modifier.blockquote]) {
  2069. return function () {
  2070. var args = [];
  2071. for (var _i = 0; _i < arguments.length; _i++) {
  2072. args[_i] = arguments[_i];
  2073. }
  2074. return dom_1.el("blockquote", {
  2075. dhx_offset: blockIndex,
  2076. }, [dom_1.el.apply(void 0, args)]);
  2077. };
  2078. }
  2079. return function () {
  2080. var args = [];
  2081. for (var _i = 0; _i < arguments.length; _i++) {
  2082. args[_i] = arguments[_i];
  2083. }
  2084. return dom_1.el.apply(void 0, args);
  2085. };
  2086. }
  2087. exports.blockquoteWrapper = blockquoteWrapper;
  2088. function getComputedNodeStyle(textNode, block, defaultModifiers) {
  2089. var computed = {};
  2090. for (var key in textNode.style) {
  2091. computed[key] = textNode.style[key];
  2092. }
  2093. if (!computed[types_1.Modifier.fontSize]) {
  2094. if (block.style[types_1.Modifier.style] && block.style[types_1.Modifier.style] !== "p") {
  2095. computed[types_1.Modifier.fontSize] = constants_1.defaultFontSizeByBlock[block.style[types_1.Modifier.style]];
  2096. }
  2097. else {
  2098. computed[types_1.Modifier.fontSize] = defaultModifiers[types_1.Modifier.fontSize];
  2099. }
  2100. }
  2101. if (!computed[types_1.Modifier.fontFamily]) {
  2102. computed[types_1.Modifier.fontFamily] = defaultModifiers[types_1.Modifier.fontFamily];
  2103. }
  2104. return computed;
  2105. }
  2106. exports.getComputedNodeStyle = getComputedNodeStyle;
  2107. function getComputedBlockStyle(block, defaultModifiers) {
  2108. var computed = {};
  2109. for (var key in block.style) {
  2110. computed[key] = block.style[key];
  2111. }
  2112. if (!computed[types_1.Modifier.style]) {
  2113. computed[types_1.Modifier.style] = defaultModifiers[types_1.Modifier.style];
  2114. }
  2115. if (!computed[types_1.Modifier.align]) {
  2116. computed[types_1.Modifier.align] = defaultModifiers[types_1.Modifier.align];
  2117. }
  2118. if (!computed[types_1.Modifier.blockquote]) {
  2119. computed[types_1.Modifier.blockquote] = defaultModifiers[types_1.Modifier.blockquote];
  2120. }
  2121. return computed;
  2122. }
  2123. exports.getComputedBlockStyle = getComputedBlockStyle;
  2124. function isEmptyBlockStyle(style) {
  2125. return !style[types_1.Modifier.blockquote] && !style[types_1.Modifier.align];
  2126. }
  2127. exports.isEmptyBlockStyle = isEmptyBlockStyle;
  2128. /***/ }),
  2129. /* 20 */
  2130. /***/ (function(module, exports, __webpack_require__) {
  2131. "use strict";
  2132. Object.defineProperty(exports, "__esModule", { value: true });
  2133. var constants_1 = __webpack_require__(5);
  2134. var RemoveTextResult;
  2135. (function (RemoveTextResult) {
  2136. RemoveTextResult[RemoveTextResult["textIsEmpty"] = 0] = "textIsEmpty";
  2137. RemoveTextResult[RemoveTextResult["complete"] = 1] = "complete";
  2138. RemoveTextResult[RemoveTextResult["nullTextLength"] = 2] = "nullTextLength";
  2139. RemoveTextResult[RemoveTextResult["forceRemovePrevious"] = 3] = "forceRemovePrevious";
  2140. RemoveTextResult[RemoveTextResult["forceRemoveNext"] = 4] = "forceRemoveNext";
  2141. })(RemoveTextResult = exports.RemoveTextResult || (exports.RemoveTextResult = {}));
  2142. var TextNode = /** @class */ (function () {
  2143. function TextNode(text, style) {
  2144. this.text = text;
  2145. this.style = style || constants_1.emptyStyle;
  2146. }
  2147. TextNode.prototype.isEmpty = function () {
  2148. return this.text.length === 0;
  2149. };
  2150. TextNode.prototype.insert = function (data, offset) {
  2151. this.text = this.text.slice(0, offset) + data + this.text.slice(offset);
  2152. };
  2153. TextNode.prototype.remove = function (offset, prev) {
  2154. if (this.isEmpty()) {
  2155. return RemoveTextResult.textIsEmpty;
  2156. }
  2157. if (offset === 0 && prev) {
  2158. return RemoveTextResult.forceRemovePrevious;
  2159. }
  2160. if (offset === this.text.length && !prev) {
  2161. return RemoveTextResult.forceRemoveNext;
  2162. }
  2163. if (prev) {
  2164. this.text = this.text.slice(0, offset - 1) + this.text.slice(offset);
  2165. }
  2166. else {
  2167. this.text = this.text.slice(0, offset) + this.text.slice(offset + 1);
  2168. }
  2169. if (this.text.length === 0) {
  2170. return RemoveTextResult.nullTextLength;
  2171. }
  2172. return RemoveTextResult.complete;
  2173. };
  2174. return TextNode;
  2175. }());
  2176. exports.TextNode = TextNode;
  2177. /***/ }),
  2178. /* 21 */
  2179. /***/ (function(module, exports, __webpack_require__) {
  2180. "use strict";
  2181. function __export(m) {
  2182. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  2183. }
  2184. Object.defineProperty(exports, "__esModule", { value: true });
  2185. __export(__webpack_require__(44));
  2186. var ts_menu_1 = __webpack_require__(22);
  2187. exports.ItemType = ts_menu_1.ItemType;
  2188. exports.NavigationBarEvents = ts_menu_1.NavigationBarEvents;
  2189. /***/ }),
  2190. /* 22 */
  2191. /***/ (function(module, exports, __webpack_require__) {
  2192. "use strict";
  2193. function __export(m) {
  2194. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  2195. }
  2196. Object.defineProperty(exports, "__esModule", { value: true });
  2197. __export(__webpack_require__(45));
  2198. __export(__webpack_require__(65));
  2199. __export(__webpack_require__(17));
  2200. __export(__webpack_require__(27));
  2201. __export(__webpack_require__(16));
  2202. /***/ }),
  2203. /* 23 */
  2204. /***/ (function(module, exports, __webpack_require__) {
  2205. "use strict";
  2206. var __assign = (this && this.__assign) || Object.assign || function(t) {
  2207. for (var s, i = 1, n = arguments.length; i < n; i++) {
  2208. s = arguments[i];
  2209. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  2210. t[p] = s[p];
  2211. }
  2212. return t;
  2213. };
  2214. Object.defineProperty(exports, "__esModule", { value: true });
  2215. var events_1 = __webpack_require__(7);
  2216. var loader_1 = __webpack_require__(48);
  2217. var sort_1 = __webpack_require__(52);
  2218. var dataproxy_1 = __webpack_require__(15);
  2219. var helpers_1 = __webpack_require__(10);
  2220. var types_1 = __webpack_require__(9);
  2221. var core_1 = __webpack_require__(3);
  2222. var DataCollection = /** @class */ (function () {
  2223. function DataCollection(config, events) {
  2224. this.config = config || {};
  2225. this._order = [];
  2226. this._pull = {};
  2227. this._changes = { order: [] };
  2228. this._initOrder = null;
  2229. this._sort = new sort_1.Sort();
  2230. this._loader = new loader_1.Loader(this, this._changes);
  2231. this.events = events || new events_1.EventSystem(this);
  2232. }
  2233. DataCollection.prototype.add = function (obj, index) {
  2234. if (!this.events.fire(types_1.DataEvents.beforeAdd, [obj])) {
  2235. return;
  2236. }
  2237. var id = this._addCore(obj, index);
  2238. this._onChange("add", obj.id, obj);
  2239. this.events.fire(types_1.DataEvents.afterAdd, [obj]);
  2240. return id;
  2241. };
  2242. DataCollection.prototype.remove = function (id) {
  2243. var obj = this._pull[id];
  2244. if (obj) {
  2245. if (!this.events.fire(types_1.DataEvents.beforeRemove, [obj])) {
  2246. return;
  2247. }
  2248. this._removeCore(obj.id);
  2249. this._onChange("remove", id, obj);
  2250. }
  2251. this.events.fire(types_1.DataEvents.afterRemove, [obj]);
  2252. };
  2253. DataCollection.prototype.removeAll = function () {
  2254. this._removeAll();
  2255. this.events.fire(types_1.DataEvents.removeAll);
  2256. this.events.fire(types_1.DataEvents.change);
  2257. };
  2258. DataCollection.prototype.exists = function (id) {
  2259. return !!this._pull[id];
  2260. };
  2261. DataCollection.prototype.getNearId = function (id) {
  2262. var item = this._pull[id];
  2263. if (!item) {
  2264. return this._order[0].id || "";
  2265. }
  2266. };
  2267. DataCollection.prototype.getItem = function (id) {
  2268. return this._pull[id];
  2269. };
  2270. DataCollection.prototype.update = function (id, obj, silent) {
  2271. var item = this.getItem(id);
  2272. if (item) {
  2273. if (helpers_1.isEqualObj(obj, item)) {
  2274. return;
  2275. }
  2276. if (obj.id && id !== obj.id) {
  2277. helpers_1.dhxWarning("this method doesn't allow change id");
  2278. if (helpers_1.isDebug()) {
  2279. // tslint:disable-next-line:no-debugger
  2280. debugger;
  2281. }
  2282. }
  2283. else {
  2284. core_1.extend(this._pull[id], obj, false);
  2285. if (this.config.update) {
  2286. this.config.update(this._pull[id]);
  2287. }
  2288. if (!silent) {
  2289. this._onChange("update", id, this._pull[id]);
  2290. }
  2291. }
  2292. }
  2293. else {
  2294. helpers_1.dhxWarning("item not found");
  2295. }
  2296. };
  2297. DataCollection.prototype.getIndex = function (id) {
  2298. var res = core_1.findIndex(this._order, function (item) { return item.id === id; });
  2299. if (this._pull[id] && res >= 0) {
  2300. return res;
  2301. }
  2302. return -1;
  2303. };
  2304. DataCollection.prototype.getId = function (index) {
  2305. if (!this._order[index]) {
  2306. return;
  2307. }
  2308. return this._order[index].id;
  2309. };
  2310. DataCollection.prototype.getLength = function () {
  2311. return this._order.length;
  2312. };
  2313. DataCollection.prototype.filter = function (rule, config) {
  2314. var _this = this;
  2315. config = core_1.extend({
  2316. add: false,
  2317. multiple: true
  2318. }, config);
  2319. if (!config.add) {
  2320. this._order = this._initOrder || this._order;
  2321. this._initOrder = null;
  2322. }
  2323. this._filters = this._filters || {};
  2324. if (!config.multiple || !rule) {
  2325. this._filters = {};
  2326. }
  2327. if (rule) {
  2328. if (typeof rule === "function") {
  2329. var f = "_";
  2330. this._filters[f] = {
  2331. match: f,
  2332. compare: rule
  2333. };
  2334. }
  2335. else {
  2336. if (!rule.match) {
  2337. delete this._filters[rule.by];
  2338. }
  2339. else {
  2340. rule.compare = rule.compare || (function (val, match) { return val === match; });
  2341. this._filters[rule.by] = rule;
  2342. }
  2343. }
  2344. var fOrder = this._order.filter(function (item) {
  2345. return Object.keys(_this._filters).every(function (key) {
  2346. return item[key] ?
  2347. _this._filters[key].compare(item[key], _this._filters[key].match, item)
  2348. : _this._filters[key].compare(item);
  2349. });
  2350. });
  2351. if (!this._initOrder) {
  2352. this._initOrder = this._order;
  2353. this._order = fOrder;
  2354. }
  2355. }
  2356. this.events.fire(types_1.DataEvents.change);
  2357. };
  2358. DataCollection.prototype.find = function (conf) {
  2359. for (var key in this._pull) {
  2360. var res = helpers_1.findByConf(this._pull[key], conf);
  2361. if (res) {
  2362. return res;
  2363. }
  2364. }
  2365. return null;
  2366. };
  2367. DataCollection.prototype.findAll = function (conf) {
  2368. var res = [];
  2369. for (var key in this._pull) {
  2370. var item = helpers_1.findByConf(this._pull[key], conf);
  2371. if (item) {
  2372. res.push(item);
  2373. }
  2374. }
  2375. return res;
  2376. };
  2377. DataCollection.prototype.sort = function (by) {
  2378. this._sort.sort(this._order, by);
  2379. if (this._initOrder && this._initOrder.length) {
  2380. this._sort.sort(this._initOrder, by);
  2381. }
  2382. this.events.fire(types_1.DataEvents.change);
  2383. };
  2384. DataCollection.prototype.copy = function (id, index, target, targetId) {
  2385. if (!this.exists(id)) {
  2386. return null;
  2387. }
  2388. var newid = core_1.uid();
  2389. if (target) {
  2390. if (targetId) {
  2391. target.add(__assign({}, this.getItem(id)), index, targetId);
  2392. return;
  2393. }
  2394. if (target.exists(id)) {
  2395. target.add(__assign({}, this.getItem(id), { id: newid }), index);
  2396. return newid;
  2397. }
  2398. else {
  2399. target.add(this.getItem(id), index);
  2400. return id;
  2401. }
  2402. }
  2403. this.add(__assign({}, this.getItem(id), { id: newid }), index);
  2404. return newid;
  2405. };
  2406. DataCollection.prototype.move = function (id, index, target, targetId) {
  2407. if (target && target !== this && this.exists(id)) {
  2408. var item = this.getItem(id);
  2409. if (target.exists(id)) {
  2410. item.id = core_1.uid();
  2411. }
  2412. if (targetId) {
  2413. item.parent = targetId;
  2414. }
  2415. target.add(item, index);
  2416. // remove data from original collection
  2417. this.remove(item.id);
  2418. return item.id;
  2419. }
  2420. if (this.getIndex(id) === index) {
  2421. return null;
  2422. }
  2423. // move other elements
  2424. var spliced = this._order.splice(this.getIndex(id), 1)[0];
  2425. if (index === -1) {
  2426. index = this._order.length;
  2427. }
  2428. this._order.splice(index, 0, spliced);
  2429. this.events.fire(types_1.DataEvents.change); // if target not this, it trigger add and remove
  2430. return id;
  2431. };
  2432. DataCollection.prototype.load = function (url, driver) {
  2433. if (typeof url === "string") {
  2434. url = new dataproxy_1.DataProxy(url);
  2435. }
  2436. return this._loader.load(url, driver);
  2437. };
  2438. DataCollection.prototype.parse = function (data, driver) {
  2439. this._removeAll();
  2440. return this._loader.parse(data, driver);
  2441. };
  2442. DataCollection.prototype.$parse = function (data) {
  2443. var apx = this.config.approximate;
  2444. if (apx) {
  2445. data = this._approximate(data, apx.value, apx.maxNum);
  2446. }
  2447. this._parse_data(data);
  2448. this.events.fire(types_1.DataEvents.change);
  2449. this.events.fire(types_1.DataEvents.load);
  2450. };
  2451. DataCollection.prototype.save = function (url) {
  2452. this._loader.save(url);
  2453. };
  2454. // todo: loop through the array and check saved statuses
  2455. DataCollection.prototype.isSaved = function () {
  2456. return !this._changes.order.length; // todo: bad solution, errors and holded elments are missed...
  2457. };
  2458. DataCollection.prototype.map = function (cb) {
  2459. var result = [];
  2460. for (var i = 0; i < this._order.length; i++) {
  2461. result.push(cb.call(this, this._order[i], i));
  2462. }
  2463. return result;
  2464. };
  2465. DataCollection.prototype.mapRange = function (from, to, cb) {
  2466. if (from < 0) {
  2467. from = 0;
  2468. }
  2469. if (to > this._order.length - 1) {
  2470. to = this._order.length - 1;
  2471. }
  2472. var result = [];
  2473. for (var i = from; i <= to; i++) {
  2474. result.push(cb.call(this, this._order[i], i));
  2475. }
  2476. return result;
  2477. };
  2478. DataCollection.prototype.reduce = function (cb, acc) {
  2479. for (var i = 0; i < this._order.length; i++) {
  2480. acc = cb.call(this, acc, this._order[i], i);
  2481. }
  2482. return acc;
  2483. };
  2484. DataCollection.prototype.serialize = function () {
  2485. return this.map(function (item) {
  2486. var newItem = __assign({}, item);
  2487. Object.keys(newItem).forEach(function (key) {
  2488. if (key[0] === "$") {
  2489. delete newItem[key];
  2490. }
  2491. });
  2492. return newItem;
  2493. });
  2494. };
  2495. DataCollection.prototype.getInitialData = function () {
  2496. return this._initOrder;
  2497. };
  2498. DataCollection.prototype._removeAll = function () {
  2499. this._pull = {};
  2500. this._order = [];
  2501. this._changes.order = [];
  2502. this._initOrder = null;
  2503. };
  2504. DataCollection.prototype._addCore = function (obj, index) {
  2505. if (this.config.init) {
  2506. obj = this.config.init(obj);
  2507. }
  2508. obj.id = obj.id ? obj.id.toString() : core_1.uid();
  2509. if (this._pull[obj.id]) {
  2510. helpers_1.dhxError("Item already exist");
  2511. }
  2512. // todo: not ideal solution
  2513. if (this._initOrder && this._initOrder.length) {
  2514. this._addToOrder(this._initOrder, obj, index);
  2515. }
  2516. this._addToOrder(this._order, obj, index);
  2517. return obj.id;
  2518. };
  2519. DataCollection.prototype._removeCore = function (id) {
  2520. if (this.getIndex(id) >= 0) {
  2521. this._order = this._order.filter(function (el) { return el.id !== id; });
  2522. delete this._pull[id];
  2523. }
  2524. if (this._initOrder && this._initOrder.length) {
  2525. this._initOrder = this._initOrder.filter(function (el) { return el.id !== id; });
  2526. }
  2527. };
  2528. DataCollection.prototype._parse_data = function (data) {
  2529. var index = this._order.length;
  2530. if (this.config.prep) {
  2531. data = this.config.prep(data);
  2532. }
  2533. for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {
  2534. var obj = data_1[_i];
  2535. if (this.config.init) {
  2536. obj = this.config.init(obj);
  2537. }
  2538. obj.id = (obj.id || obj.id === 0) ? obj.id : core_1.uid();
  2539. this._pull[obj.id] = obj;
  2540. this._order[index++] = obj;
  2541. }
  2542. };
  2543. DataCollection.prototype._approximate = function (data, values, maxNum) {
  2544. var len = data.length;
  2545. var vlen = values.length;
  2546. var rlen = Math.floor(len / maxNum);
  2547. var newData = Array(Math.ceil(len / rlen));
  2548. var index = 0;
  2549. for (var i = 0; i < len; i += rlen) {
  2550. var newItem = core_1.copy(data[i]);
  2551. var end = Math.min(len, i + rlen);
  2552. for (var j = 0; j < vlen; j++) {
  2553. var sum = 0;
  2554. for (var z = i; z < end; z++) {
  2555. sum += data[z][values[j]];
  2556. }
  2557. newItem[values[j]] = sum / (end - i);
  2558. }
  2559. newData[index++] = newItem;
  2560. }
  2561. return newData;
  2562. };
  2563. DataCollection.prototype._onChange = function (status, id, obj) {
  2564. for (var _i = 0, _a = this._changes.order; _i < _a.length; _i++) {
  2565. var item = _a[_i];
  2566. // update pending item if previous state is "saving" or if item not saved yet
  2567. if (item.id === id && !item.saving) {
  2568. // update item
  2569. if (item.error) {
  2570. item.error = false;
  2571. }
  2572. item = __assign({}, item, { obj: obj, status: status });
  2573. this.events.fire(types_1.DataEvents.change, [id, status, obj]);
  2574. return;
  2575. }
  2576. }
  2577. this._changes.order.push({ id: id, status: status, obj: __assign({}, obj), saving: false });
  2578. this.events.fire(types_1.DataEvents.change, [id, status, obj]);
  2579. };
  2580. DataCollection.prototype._addToOrder = function (array, obj, index) {
  2581. if (index >= 0 && array[index]) {
  2582. this._pull[obj.id] = obj;
  2583. array.splice(index, 0, obj);
  2584. }
  2585. else {
  2586. this._pull[obj.id] = obj;
  2587. array.push(obj);
  2588. }
  2589. };
  2590. return DataCollection;
  2591. }());
  2592. exports.DataCollection = DataCollection;
  2593. /***/ }),
  2594. /* 24 */
  2595. /***/ (function(module, exports, __webpack_require__) {
  2596. "use strict";
  2597. var __assign = (this && this.__assign) || Object.assign || function(t) {
  2598. for (var s, i = 1, n = arguments.length; i < n; i++) {
  2599. s = arguments[i];
  2600. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  2601. t[p] = s[p];
  2602. }
  2603. return t;
  2604. };
  2605. Object.defineProperty(exports, "__esModule", { value: true });
  2606. var CsvDriver = /** @class */ (function () {
  2607. function CsvDriver(config) {
  2608. if (config === void 0) { config = {}; }
  2609. var initConfig = {
  2610. skipHeader: 0,
  2611. nameByHeader: false,
  2612. row: "\n",
  2613. column: ",",
  2614. };
  2615. this.config = __assign({}, initConfig, config);
  2616. if (this.config.nameByHeader) {
  2617. this.config.skipHeader = 1;
  2618. }
  2619. }
  2620. CsvDriver.prototype.getFields = function (row, headers) {
  2621. var parts = row.trim().split(this.config.column);
  2622. var obj = {};
  2623. for (var i = 0; i < parts.length; i++) {
  2624. obj[headers ? headers[i] : i + 1] = parts[i];
  2625. }
  2626. return obj;
  2627. };
  2628. CsvDriver.prototype.getRows = function (data) {
  2629. return data.trim().split(this.config.row);
  2630. };
  2631. CsvDriver.prototype.toJsonArray = function (data) {
  2632. var _this = this;
  2633. var rows = this.getRows(data);
  2634. var names = this.config.names;
  2635. if (this.config.skipHeader) {
  2636. var top_1 = rows.splice(0, this.config.skipHeader);
  2637. if (this.config.nameByHeader) {
  2638. names = top_1[0].trim().split(this.config.column);
  2639. }
  2640. }
  2641. return rows.map(function (row) { return _this.getFields(row, names); });
  2642. };
  2643. return CsvDriver;
  2644. }());
  2645. exports.CsvDriver = CsvDriver;
  2646. /***/ }),
  2647. /* 25 */
  2648. /***/ (function(module, exports, __webpack_require__) {
  2649. "use strict";
  2650. Object.defineProperty(exports, "__esModule", { value: true });
  2651. var JsonDriver = /** @class */ (function () {
  2652. function JsonDriver() {
  2653. }
  2654. JsonDriver.prototype.toJsonArray = function (data) {
  2655. return this.getRows(data);
  2656. };
  2657. JsonDriver.prototype.getFields = function (row) {
  2658. return row;
  2659. };
  2660. JsonDriver.prototype.getRows = function (data) {
  2661. return typeof data === "string" ? JSON.parse(data) : data;
  2662. };
  2663. return JsonDriver;
  2664. }());
  2665. exports.JsonDriver = JsonDriver;
  2666. /***/ }),
  2667. /* 26 */
  2668. /***/ (function(module, exports, __webpack_require__) {
  2669. "use strict";
  2670. var __extends = (this && this.__extends) || (function () {
  2671. var extendStatics = Object.setPrototypeOf ||
  2672. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2673. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2674. return function (d, b) {
  2675. extendStatics(d, b);
  2676. function __() { this.constructor = d; }
  2677. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2678. };
  2679. })();
  2680. var __assign = (this && this.__assign) || Object.assign || function(t) {
  2681. for (var s, i = 1, n = arguments.length; i < n; i++) {
  2682. s = arguments[i];
  2683. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  2684. t[p] = s[p];
  2685. }
  2686. return t;
  2687. };
  2688. Object.defineProperty(exports, "__esModule", { value: true });
  2689. var core_1 = __webpack_require__(3);
  2690. var datacollection_1 = __webpack_require__(23);
  2691. var dataproxy_1 = __webpack_require__(15);
  2692. var helpers_1 = __webpack_require__(10);
  2693. var types_1 = __webpack_require__(9);
  2694. function addToOrder(store, obj, parent, index) {
  2695. if (index !== undefined && index !== -1 && store[parent] && store[parent][index]) {
  2696. store[parent].splice(index, 0, obj);
  2697. }
  2698. else {
  2699. if (!store[parent]) {
  2700. store[parent] = [];
  2701. }
  2702. store[parent].push(obj);
  2703. }
  2704. }
  2705. var TreeCollection = /** @class */ (function (_super) {
  2706. __extends(TreeCollection, _super);
  2707. function TreeCollection(config, events) {
  2708. var _a;
  2709. var _this = _super.call(this, config, events) || this;
  2710. var root = _this._root = "_ROOT_" + core_1.uid();
  2711. _this._childs = (_a = {}, _a[root] = [], _a);
  2712. _this._initChilds = null;
  2713. return _this;
  2714. }
  2715. TreeCollection.prototype.add = function (obj, index, parent) {
  2716. if (index === void 0) { index = -1; }
  2717. if (parent === void 0) { parent = this._root; }
  2718. if (typeof obj !== "object") {
  2719. obj = {
  2720. value: obj
  2721. };
  2722. }
  2723. obj.parent = obj.parent ? obj.parent.toString() : parent;
  2724. var id = _super.prototype.add.call(this, obj, index);
  2725. if (Array.isArray(obj.items)) {
  2726. for (var _i = 0, _a = obj.items; _i < _a.length; _i++) {
  2727. var item = _a[_i];
  2728. this.add(item, -1, obj.id);
  2729. }
  2730. }
  2731. return id;
  2732. };
  2733. TreeCollection.prototype.getRoot = function () {
  2734. return this._root;
  2735. };
  2736. TreeCollection.prototype.getParent = function (id, asObj) {
  2737. if (asObj === void 0) { asObj = false; }
  2738. if (!this._pull[id]) {
  2739. return null;
  2740. }
  2741. var parent = this._pull[id].parent;
  2742. return asObj ? this._pull[parent] : parent;
  2743. };
  2744. TreeCollection.prototype.getItems = function (id) {
  2745. if (this._childs && this._childs[id]) {
  2746. return this._childs[id];
  2747. }
  2748. return [];
  2749. };
  2750. TreeCollection.prototype.getLength = function (id) {
  2751. if (id === void 0) { id = this._root; }
  2752. if (!this._childs[id]) {
  2753. return null;
  2754. }
  2755. return this._childs[id].length;
  2756. };
  2757. TreeCollection.prototype.removeAll = function (id) {
  2758. var _a;
  2759. if (id) {
  2760. var childs = this._childs[id].slice();
  2761. for (var _i = 0, childs_1 = childs; _i < childs_1.length; _i++) {
  2762. var child = childs_1[_i];
  2763. this.remove(child.id);
  2764. }
  2765. }
  2766. else {
  2767. _super.prototype.removeAll.call(this);
  2768. var root = this._root;
  2769. this._initChilds = null;
  2770. this._childs = (_a = {}, _a[root] = [], _a);
  2771. }
  2772. };
  2773. TreeCollection.prototype.getIndex = function (id) {
  2774. var parent = this.getParent(id);
  2775. if (!parent || !this._childs[parent]) {
  2776. return -1;
  2777. }
  2778. return core_1.findIndex(this._childs[parent], function (item) { return item.id === id; });
  2779. };
  2780. TreeCollection.prototype.sort = function (conf) {
  2781. var childs = this._childs;
  2782. for (var key in childs) {
  2783. this._sort.sort(childs[key], conf);
  2784. }
  2785. this.events.fire(types_1.DataEvents.change);
  2786. };
  2787. TreeCollection.prototype.map = function (cb, parent, direct) {
  2788. if (parent === void 0) { parent = this._root; }
  2789. if (direct === void 0) { direct = true; }
  2790. var result = [];
  2791. if (!this.haveItems(parent)) {
  2792. return result;
  2793. }
  2794. for (var i = 0; i < this._childs[parent].length; i++) {
  2795. result.push(cb.call(this, this._childs[parent][i], i));
  2796. if (direct) {
  2797. var childResult = this.map(cb, this._childs[parent][i].id, direct);
  2798. result = result.concat(childResult);
  2799. }
  2800. }
  2801. return result;
  2802. };
  2803. TreeCollection.prototype.filter = function (conf) {
  2804. if (!conf) {
  2805. this.restoreOrder();
  2806. return;
  2807. }
  2808. if (!this._initChilds) {
  2809. this._initChilds = this._childs;
  2810. }
  2811. conf.type = conf.type || types_1.TreeFilterType.all;
  2812. var newChilds = {};
  2813. this._recursiveFilter(conf, this._root, 0, newChilds);
  2814. this._childs = newChilds;
  2815. this.events.fire(types_1.DataEvents.change);
  2816. };
  2817. TreeCollection.prototype.restoreOrder = function () {
  2818. if (this._initChilds) {
  2819. this._childs = this._initChilds;
  2820. this._initChilds = null;
  2821. }
  2822. this.events.fire(types_1.DataEvents.change);
  2823. };
  2824. TreeCollection.prototype.copy = function (id, index, target, targetId) {
  2825. if (target === void 0) { target = this; }
  2826. if (targetId === void 0) { targetId = this._root; }
  2827. if (!this.exists(id)) {
  2828. return null;
  2829. }
  2830. var currentChilds = this._childs[id];
  2831. if (target === this && !this.canCopy(id, targetId)) {
  2832. return null;
  2833. }
  2834. if (!(target instanceof TreeCollection)) { // copy to datacollection
  2835. target.add(this._pull[id]);
  2836. return;
  2837. }
  2838. if (this.exists(id)) {
  2839. var item = __assign({}, this.getItem(id));
  2840. if (target.exists(id)) {
  2841. item.id = core_1.uid();
  2842. }
  2843. else {
  2844. item.id = id;
  2845. }
  2846. item.parent = targetId;
  2847. target.add(item, index);
  2848. id = item.id;
  2849. }
  2850. if (currentChilds) {
  2851. for (var _i = 0, currentChilds_1 = currentChilds; _i < currentChilds_1.length; _i++) {
  2852. var child = currentChilds_1[_i];
  2853. var childId = child.id;
  2854. var childIndex = this.getIndex(childId);
  2855. this.copy(childId, childIndex, target, id);
  2856. }
  2857. }
  2858. return id;
  2859. };
  2860. TreeCollection.prototype.move = function (id, index, target, targetId) {
  2861. if (target === void 0) { target = this; }
  2862. if (targetId === void 0) { targetId = this._root; }
  2863. if (!this.exists(id)) {
  2864. return null;
  2865. }
  2866. if (target !== this) {
  2867. if (!(target instanceof TreeCollection)) { // move to datacollection
  2868. target.add(this._pull[id]);
  2869. this.remove(id);
  2870. return;
  2871. }
  2872. var returnId = this.copy(id, index, target, targetId);
  2873. this.remove(id);
  2874. return returnId;
  2875. }
  2876. // move inside
  2877. if (!this.canCopy(id, targetId)) {
  2878. return null;
  2879. }
  2880. var parent = this.getParent(id);
  2881. var parentIndex = this.getIndex(id);
  2882. // get item from parent array and move to target array
  2883. var spliced = this._childs[parent].splice(parentIndex, 1)[0];
  2884. spliced.parent = targetId; // need for next moving, ... not best solution, may be full method for get item
  2885. if (!this._childs[parent].length) {
  2886. delete this._childs[parent];
  2887. }
  2888. if (!this.haveItems(targetId)) {
  2889. this._childs[targetId] = [];
  2890. }
  2891. if (index === -1) {
  2892. index = this._childs[targetId].push(spliced);
  2893. }
  2894. else {
  2895. this._childs[targetId].splice(index, 0, spliced);
  2896. }
  2897. this.events.fire(types_1.DataEvents.change);
  2898. return id;
  2899. };
  2900. TreeCollection.prototype.eachChild = function (id, cb, direct, checkItem) {
  2901. if (direct === void 0) { direct = true; }
  2902. if (checkItem === void 0) { checkItem = function () { return true; }; }
  2903. if (!this.haveItems(id)) {
  2904. return;
  2905. }
  2906. for (var i = 0; i < this._childs[id].length; i++) {
  2907. cb.call(this, this._childs[id][i], i);
  2908. if (direct && checkItem(this._childs[id][i])) {
  2909. this.eachChild(this._childs[id][i].id, cb, direct, checkItem);
  2910. }
  2911. }
  2912. };
  2913. TreeCollection.prototype.getNearId = function (id) {
  2914. return id; // for selection
  2915. };
  2916. TreeCollection.prototype.loadItems = function (id, driver) {
  2917. var _this = this;
  2918. if (driver === void 0) { driver = "json"; }
  2919. var url = this.config.autoload + "?id=" + id;
  2920. var proxy = new dataproxy_1.DataProxy(url);
  2921. proxy.load().then(function (data) {
  2922. driver = helpers_1.toDataDriver(driver);
  2923. data = driver.toJsonArray(data);
  2924. _this._parse_data(data, id);
  2925. _this.events.fire(types_1.DataEvents.change);
  2926. });
  2927. };
  2928. TreeCollection.prototype.refreshItems = function (id, driver) {
  2929. if (driver === void 0) { driver = "json"; }
  2930. this.removeAll(id);
  2931. this.loadItems(id, driver);
  2932. };
  2933. TreeCollection.prototype.eachParent = function (id, cb, self) {
  2934. if (self === void 0) { self = false; }
  2935. var item = this.getItem(id);
  2936. if (!item) {
  2937. return;
  2938. }
  2939. if (self) {
  2940. cb.call(this, item);
  2941. }
  2942. if (item.parent === this._root) {
  2943. return;
  2944. }
  2945. var parent = this.getItem(item.parent);
  2946. cb.call(this, parent);
  2947. this.eachParent(item.parent, cb);
  2948. };
  2949. TreeCollection.prototype.haveItems = function (id) {
  2950. return id in this._childs;
  2951. };
  2952. TreeCollection.prototype.canCopy = function (id, target) {
  2953. if (id === target) {
  2954. return false;
  2955. }
  2956. var canCopy = true;
  2957. this.eachParent(target, function (item) { return item.id === id ? canCopy = false : null; }); // locate return string
  2958. return canCopy;
  2959. };
  2960. TreeCollection.prototype.serialize = function (fn) {
  2961. return this._serialize(this._root, fn);
  2962. };
  2963. TreeCollection.prototype.getId = function (index, parent) {
  2964. if (parent === void 0) { parent = this._root; }
  2965. if (!this._childs[parent] || !this._childs[parent][index]) {
  2966. return;
  2967. }
  2968. return this._childs[parent][index].id;
  2969. };
  2970. TreeCollection.prototype._removeAll = function (id) {
  2971. var _a;
  2972. if (id) {
  2973. var childs = this._childs[id].slice();
  2974. for (var _i = 0, childs_2 = childs; _i < childs_2.length; _i++) {
  2975. var child = childs_2[_i];
  2976. this.remove(child.id);
  2977. }
  2978. }
  2979. else {
  2980. _super.prototype._removeAll.call(this);
  2981. var root = this._root;
  2982. this._initChilds = null;
  2983. this._childs = (_a = {}, _a[root] = [], _a);
  2984. }
  2985. };
  2986. TreeCollection.prototype._removeCore = function (id) {
  2987. if (this._pull[id]) {
  2988. var parent_1 = this.getParent(id);
  2989. this._childs[parent_1] = this._childs[parent_1].filter(function (item) { return item.id !== id; });
  2990. if (parent_1 !== this._root && !this._childs[parent_1].length) {
  2991. delete this._childs[parent_1];
  2992. }
  2993. if (this._initChilds && this._initChilds[parent_1]) {
  2994. this._initChilds[parent_1] = this._initChilds[parent_1].filter(function (item) { return item.id !== id; });
  2995. if (parent_1 !== this._root && !this._initChilds[parent_1].length) {
  2996. delete this._initChilds[parent_1];
  2997. }
  2998. }
  2999. this._fastDeleteChilds(this._childs, id);
  3000. if (this._initChilds) {
  3001. this._fastDeleteChilds(this._initChilds, id);
  3002. }
  3003. }
  3004. };
  3005. TreeCollection.prototype._addToOrder = function (_order, obj, index) {
  3006. var childs = this._childs;
  3007. var initChilds = this._initChilds;
  3008. var parent = obj.parent;
  3009. this._pull[obj.id] = obj;
  3010. addToOrder(childs, obj, parent, index);
  3011. if (initChilds) {
  3012. addToOrder(initChilds, obj, parent, index);
  3013. }
  3014. };
  3015. TreeCollection.prototype._parse_data = function (data, parent) {
  3016. if (parent === void 0) { parent = this._root; }
  3017. for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {
  3018. var obj = data_1[_i];
  3019. if (this.config.init) {
  3020. obj = this.config.init(obj);
  3021. }
  3022. if (typeof obj !== "object") {
  3023. obj = {
  3024. value: obj
  3025. };
  3026. }
  3027. obj.id = obj.id ? obj.id.toString() : core_1.uid();
  3028. obj.parent = obj.parent ? obj.parent.toString() : parent;
  3029. this._pull[obj.id] = obj;
  3030. if (!this._childs[obj.parent]) {
  3031. this._childs[obj.parent] = [];
  3032. }
  3033. this._childs[obj.parent].push(obj);
  3034. if (obj.items && obj.items instanceof Object) {
  3035. this._parse_data(obj.items, obj.id);
  3036. }
  3037. }
  3038. };
  3039. TreeCollection.prototype._fastDeleteChilds = function (target, id) {
  3040. if (this._pull[id]) {
  3041. delete this._pull[id];
  3042. }
  3043. if (!target[id]) {
  3044. return;
  3045. }
  3046. for (var i = 0; i < target[id].length; i++) {
  3047. this._fastDeleteChilds(target, target[id][i].id);
  3048. }
  3049. delete target[id];
  3050. };
  3051. TreeCollection.prototype._recursiveFilter = function (conf, current, level, newChilds) {
  3052. var _this = this;
  3053. var childs = this._childs[current];
  3054. if (!childs) {
  3055. return;
  3056. }
  3057. var condition = function (item) {
  3058. switch (conf.type) {
  3059. case types_1.TreeFilterType.all: {
  3060. return true;
  3061. }
  3062. case types_1.TreeFilterType.specific: {
  3063. return level === conf.specific;
  3064. }
  3065. case types_1.TreeFilterType.leafs: {
  3066. return !_this.haveItems(item.id);
  3067. }
  3068. }
  3069. };
  3070. if (conf.by && conf.match) {
  3071. var customRule = function (item) { return !condition(item) || item[conf.by].toString().toLowerCase().indexOf(conf.match.toString().toLowerCase()) !== -1; };
  3072. newChilds[current] = childs.filter(customRule);
  3073. }
  3074. else if (conf.rule && typeof conf.rule === "function") {
  3075. var customRule = function (item) { return !condition(item) || conf.rule(item); };
  3076. var filtered = childs.filter(customRule);
  3077. if (filtered.length) {
  3078. newChilds[current] = filtered;
  3079. }
  3080. }
  3081. for (var _i = 0, childs_3 = childs; _i < childs_3.length; _i++) {
  3082. var child = childs_3[_i];
  3083. this._recursiveFilter(conf, child.id, level + 1, newChilds);
  3084. }
  3085. };
  3086. TreeCollection.prototype._serialize = function (parent, fn) {
  3087. var _this = this;
  3088. if (parent === void 0) { parent = this._root; }
  3089. return this.map(function (item) {
  3090. var itemCopy = {};
  3091. for (var key in item) {
  3092. if (key === "parent" || key === "childs") {
  3093. continue;
  3094. }
  3095. itemCopy[key] = item[key];
  3096. }
  3097. if (fn) {
  3098. itemCopy = fn(itemCopy);
  3099. }
  3100. if (_this.haveItems(item.id)) {
  3101. itemCopy.childs = _this._serialize(item.id, fn);
  3102. }
  3103. return itemCopy;
  3104. }, parent, false);
  3105. };
  3106. return TreeCollection;
  3107. }(datacollection_1.DataCollection));
  3108. exports.TreeCollection = TreeCollection;
  3109. /***/ }),
  3110. /* 27 */
  3111. /***/ (function(module, exports, __webpack_require__) {
  3112. "use strict";
  3113. Object.defineProperty(exports, "__esModule", { value: true });
  3114. var button_1 = __webpack_require__(56);
  3115. var customHTMLButton_1 = __webpack_require__(57);
  3116. var dhxButton_1 = __webpack_require__(58);
  3117. var imageButton_1 = __webpack_require__(59);
  3118. var input_1 = __webpack_require__(60);
  3119. var menuItem_1 = __webpack_require__(61);
  3120. var separator_1 = __webpack_require__(62);
  3121. var spacer_1 = __webpack_require__(63);
  3122. var text_1 = __webpack_require__(64);
  3123. var types_1 = __webpack_require__(16);
  3124. function itemfactory(item, events) {
  3125. if (item.$hidden) {
  3126. return null;
  3127. }
  3128. switch (item.type) {
  3129. case types_1.ItemType.button:
  3130. return button_1.button(item);
  3131. case types_1.ItemType.text:
  3132. return text_1.text(item);
  3133. case types_1.ItemType.separator:
  3134. return separator_1.separator(item);
  3135. case types_1.ItemType.spacer:
  3136. return spacer_1.spacer(item);
  3137. case types_1.ItemType.input:
  3138. return input_1.input(item, events);
  3139. case types_1.ItemType.imageButton:
  3140. return imageButton_1.imageButton(item);
  3141. case types_1.ItemType.selectButton:
  3142. case types_1.ItemType.menuItem:
  3143. return menuItem_1.menuItem(item);
  3144. case types_1.ItemType.dhxButton:
  3145. return dhxButton_1.dhxButton(item);
  3146. case types_1.ItemType.customHTMLButton:
  3147. return customHTMLButton_1.customHTMLButton(item);
  3148. case types_1.ItemType.block:
  3149. default:
  3150. throw new Error("unknown item type " + item.type);
  3151. }
  3152. }
  3153. exports.itemfactory = itemfactory;
  3154. function createFactory(defaultType, forbiddenTypes) {
  3155. if (forbiddenTypes === void 0) { forbiddenTypes = []; }
  3156. var forbidden = {};
  3157. forbiddenTypes.forEach(function (type) { return forbidden[type] = true; });
  3158. return function (item, events) {
  3159. item.type = item.type || defaultType;
  3160. if (forbidden[item.type]) {
  3161. item.type = defaultType;
  3162. }
  3163. return itemfactory(item, events);
  3164. };
  3165. }
  3166. exports.createFactory = createFactory;
  3167. /***/ }),
  3168. /* 28 */
  3169. /***/ (function(module, exports, __webpack_require__) {
  3170. "use strict";
  3171. function __export(m) {
  3172. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  3173. }
  3174. Object.defineProperty(exports, "__esModule", { value: true });
  3175. __export(__webpack_require__(29));
  3176. __export(__webpack_require__(66));
  3177. __export(__webpack_require__(68));
  3178. /***/ }),
  3179. /* 29 */
  3180. /***/ (function(module, exports, __webpack_require__) {
  3181. "use strict";
  3182. Object.defineProperty(exports, "__esModule", { value: true });
  3183. var html_1 = __webpack_require__(1);
  3184. var Position;
  3185. (function (Position) {
  3186. Position["right"] = "right";
  3187. Position["bottom"] = "bottom";
  3188. Position["center"] = "center";
  3189. })(Position = exports.Position || (exports.Position = {}));
  3190. var MessageContainerPosition;
  3191. (function (MessageContainerPosition) {
  3192. MessageContainerPosition["topLeft"] = "top-left";
  3193. MessageContainerPosition["topRight"] = "top-right";
  3194. MessageContainerPosition["bottomLeft"] = "bottom-left";
  3195. MessageContainerPosition["bottomRight"] = "bottom-right";
  3196. })(MessageContainerPosition = exports.MessageContainerPosition || (exports.MessageContainerPosition = {}));
  3197. var nodeTimeout = new WeakMap();
  3198. var containers = new Map();
  3199. function onExpire(node, fromClick) {
  3200. if (fromClick) {
  3201. clearTimeout(nodeTimeout.get(node));
  3202. }
  3203. var parent = node.parentNode.parentNode;
  3204. var _a = containers.get(parent), stack = _a.stack, container = _a.container;
  3205. var index = stack.indexOf(node);
  3206. if (index !== -1) {
  3207. container.removeChild(node);
  3208. stack.splice(index, 1);
  3209. if (stack.length === 0) {
  3210. parent.removeChild(container);
  3211. }
  3212. return;
  3213. }
  3214. }
  3215. function message(props) {
  3216. if (typeof props === "string") {
  3217. props = { text: props };
  3218. }
  3219. var messageBox = document.createElement("div");
  3220. messageBox.className = "dhx_message " + (props.css || "");
  3221. messageBox.innerHTML = "<span class=\"dhx_message__text\">" + props.text + "</span>\n\t<span class=\"dhx_message__icon dxi " + props.icon + "\"></span>";
  3222. var parent = props.node ? html_1.toNode(props.node) : document.body;
  3223. var position = getComputedStyle(parent).position;
  3224. if (position === "static") {
  3225. parent.style.position = "relative";
  3226. }
  3227. if (!containers.has(parent)) {
  3228. var messageContainer = document.createElement("div");
  3229. messageContainer.className = "dhx-message-container " +
  3230. (props.position ? "dhx-message-container--" + props.position : "dhx-message-container--top-right") +
  3231. (parent === document.body ? " dhx-message-container--in-body" : "");
  3232. containers.set(parent, {
  3233. stack: [],
  3234. container: messageContainer
  3235. });
  3236. }
  3237. var _a = containers.get(parent), stack = _a.stack, container = _a.container;
  3238. if (stack.length === 0) {
  3239. parent.appendChild(container);
  3240. }
  3241. stack.push(messageBox);
  3242. container.appendChild(messageBox);
  3243. if (props.expire) {
  3244. var timeout = setTimeout(function () { return onExpire(messageBox); }, props.expire);
  3245. nodeTimeout.set(messageBox, timeout);
  3246. }
  3247. messageBox.onclick = function () { return onExpire(messageBox, true); };
  3248. }
  3249. exports.message = message;
  3250. /***/ }),
  3251. /* 30 */
  3252. /***/ (function(module, exports, __webpack_require__) {
  3253. "use strict";
  3254. Object.defineProperty(exports, "__esModule", { value: true });
  3255. var PopupEvents;
  3256. (function (PopupEvents) {
  3257. PopupEvents["beforeHide"] = "beforehide";
  3258. PopupEvents["beforeShow"] = "beforeshow";
  3259. PopupEvents["afterHide"] = "afterhide";
  3260. PopupEvents["afterShow"] = "aftershow";
  3261. })(PopupEvents = exports.PopupEvents || (exports.PopupEvents = {}));
  3262. /***/ }),
  3263. /* 31 */
  3264. /***/ (function(module, exports, __webpack_require__) {
  3265. "use strict";
  3266. Object.defineProperty(exports, "__esModule", { value: true });
  3267. var types_1 = __webpack_require__(2);
  3268. var Key;
  3269. (function (Key) {
  3270. Key[Key["backspace"] = 8] = "backspace";
  3271. Key[Key["enter"] = 13] = "enter";
  3272. Key[Key["tab"] = 9] = "tab";
  3273. Key[Key["esc"] = 27] = "esc";
  3274. Key[Key["space"] = 32] = "space";
  3275. Key[Key["left"] = 37] = "left";
  3276. Key[Key["up"] = 38] = "up";
  3277. Key[Key["right"] = 39] = "right";
  3278. Key[Key["down"] = 40] = "down";
  3279. Key[Key["insert"] = 45] = "insert";
  3280. Key[Key["del"] = 46] = "del";
  3281. Key[Key["ctrl"] = 17] = "ctrl";
  3282. Key[Key["a"] = 65] = "a";
  3283. Key[Key["b"] = 66] = "b";
  3284. Key[Key["c"] = 67] = "c";
  3285. Key[Key["s"] = 83] = "s";
  3286. Key[Key["u"] = 85] = "u";
  3287. Key[Key["v"] = 86] = "v";
  3288. Key[Key["x"] = 88] = "x";
  3289. Key[Key["y"] = 89] = "y";
  3290. Key[Key["z"] = 90] = "z";
  3291. Key[Key["i"] = 73] = "i";
  3292. })(Key = exports.Key || (exports.Key = {}));
  3293. function keyToOperation(e) {
  3294. if (e.shiftKey && e.which === Key.enter) {
  3295. e.preventDefault();
  3296. return {
  3297. action: types_1.Action.add,
  3298. data: "\n"
  3299. };
  3300. }
  3301. switch (e.which) {
  3302. case Key.insert:
  3303. e.preventDefault();
  3304. return;
  3305. case Key.left:
  3306. case Key.right:
  3307. case Key.down:
  3308. case Key.up:
  3309. return;
  3310. case Key.backspace:
  3311. e.preventDefault();
  3312. return {
  3313. action: types_1.Action.remove,
  3314. data: true
  3315. };
  3316. case Key.del:
  3317. e.preventDefault();
  3318. return {
  3319. action: types_1.Action.remove,
  3320. data: false
  3321. };
  3322. case Key.space:
  3323. e.preventDefault();
  3324. return {
  3325. action: types_1.Action.add,
  3326. data: " "
  3327. };
  3328. case Key.enter:
  3329. e.preventDefault();
  3330. return {
  3331. action: types_1.Action.add,
  3332. data: { newBlock: true }
  3333. };
  3334. }
  3335. if (e.ctrlKey || e.metaKey) {
  3336. return ctrlKey(e);
  3337. }
  3338. var char = e.key;
  3339. if (char.length > 1 || e.altKey) {
  3340. return;
  3341. }
  3342. e.preventDefault();
  3343. return {
  3344. action: types_1.Action.add,
  3345. data: char
  3346. };
  3347. }
  3348. exports.keyToOperation = keyToOperation;
  3349. function ctrlKey(e) {
  3350. var key = e.which;
  3351. switch (key) {
  3352. case Key.z:
  3353. return {
  3354. action: e.shiftKey ? types_1.Action.redo : types_1.Action.undo
  3355. };
  3356. case Key.y:
  3357. return {
  3358. action: types_1.Action.redo
  3359. };
  3360. case Key.a:
  3361. return {
  3362. action: types_1.Action.selectAll
  3363. };
  3364. case Key.v:
  3365. case Key.x:
  3366. case Key.c:
  3367. return;
  3368. case Key.u:
  3369. case Key.i:
  3370. case Key.b:
  3371. e.preventDefault();
  3372. return;
  3373. }
  3374. return;
  3375. }
  3376. /***/ }),
  3377. /* 32 */
  3378. /***/ (function(module, exports, __webpack_require__) {
  3379. "use strict";
  3380. Object.defineProperty(exports, "__esModule", { value: true });
  3381. var dom_1 = __webpack_require__(0);
  3382. var en_1 = __webpack_require__(11);
  3383. function charsExlSpace(text) {
  3384. return text.replace(/[\n ]/g, "").length;
  3385. }
  3386. function chars(text) {
  3387. return text.replace(/[\n]/g, "").length;
  3388. }
  3389. function words(text) {
  3390. return text.split(/[\n !.?,:;]+/g).filter(function (word) { return word.length > 0; }).length;
  3391. }
  3392. var defaultStats = {
  3393. words: words,
  3394. chars: chars,
  3395. charsExlSpace: charsExlSpace
  3396. };
  3397. function getStats(text, customStats) {
  3398. if (customStats) {
  3399. var stats = {};
  3400. for (var _i = 0, customStats_1 = customStats; _i < customStats_1.length; _i++) {
  3401. var _a = customStats_1[_i], cb = _a.cb, name_1 = _a.name;
  3402. if (typeof cb === "function") {
  3403. stats[name_1] = cb(text);
  3404. }
  3405. else if (!cb && name_1 in defaultStats) {
  3406. stats[name_1] = defaultStats[name_1](text);
  3407. }
  3408. else if (typeof cb === "string" && cb in defaultStats) {
  3409. stats[name_1] = defaultStats[cb](text);
  3410. }
  3411. }
  3412. return stats;
  3413. }
  3414. return {
  3415. chars: defaultStats.chars(text),
  3416. words: defaultStats.words(text),
  3417. charsExlSpace: defaultStats.charsExlSpace(text)
  3418. };
  3419. }
  3420. exports.getStats = getStats;
  3421. function getDefaultRenderStat() {
  3422. return [
  3423. { name: "chars" },
  3424. { name: "charsExlSpace" },
  3425. { name: "words" }
  3426. ];
  3427. }
  3428. function statsRenderer(stats, statSequence) {
  3429. if (statSequence === void 0) { statSequence = getDefaultRenderStat(); }
  3430. return function () { return dom_1.el("ul.dhx_richtext-stat", statSequence.map(function (stat) {
  3431. return dom_1.el("li.dhx_richtext-stat__item", [
  3432. dom_1.el("span.dhx_richtext-stat__name", en_1.default[stat.name] || stat.name),
  3433. dom_1.el("span.dhx_richtext-stat__value", stats[stat.name])
  3434. ]);
  3435. })); };
  3436. }
  3437. exports.statsRenderer = statsRenderer;
  3438. /***/ }),
  3439. /* 33 */
  3440. /***/ (function(module, exports, __webpack_require__) {
  3441. "use strict";
  3442. Object.defineProperty(exports, "__esModule", { value: true });
  3443. var ColorpickerEvents;
  3444. (function (ColorpickerEvents) {
  3445. ColorpickerEvents["colorChange"] = "colorChange";
  3446. })(ColorpickerEvents = exports.ColorpickerEvents || (exports.ColorpickerEvents = {}));
  3447. /***/ }),
  3448. /* 34 */
  3449. /***/ (function(module, exports, __webpack_require__) {
  3450. "use strict";
  3451. Object.defineProperty(exports, "__esModule", { value: true });
  3452. var constants_1 = __webpack_require__(5);
  3453. var other_1 = __webpack_require__(4);
  3454. var TextNode_1 = __webpack_require__(20);
  3455. var SplitResult;
  3456. (function (SplitResult) {
  3457. SplitResult[SplitResult["invalidNode"] = 0] = "invalidNode";
  3458. SplitResult[SplitResult["offsetStart"] = 1] = "offsetStart";
  3459. SplitResult[SplitResult["offsetEnd"] = 2] = "offsetEnd";
  3460. SplitResult[SplitResult["complete"] = 3] = "complete";
  3461. })(SplitResult = exports.SplitResult || (exports.SplitResult = {}));
  3462. var Block = /** @class */ (function () {
  3463. function Block(textNodes, style) {
  3464. this.style = style || constants_1.emptyStyle;
  3465. if (!textNodes || textNodes.length === 0) {
  3466. this.clear();
  3467. }
  3468. else {
  3469. this.textNodes = textNodes;
  3470. }
  3471. }
  3472. Block.prototype.clear = function () {
  3473. this.textNodes = [new TextNode_1.TextNode("", constants_1.emptyStyle)];
  3474. };
  3475. Block.prototype.isEmpty = function () {
  3476. return this.textNodes.length === 1 && this.textNodes[0].isEmpty();
  3477. };
  3478. Block.prototype.splitTextNode = function (index, offset) {
  3479. var textNode = this.textNodes[index];
  3480. if (!textNode) {
  3481. return SplitResult.invalidNode;
  3482. }
  3483. if (offset === 0) {
  3484. return SplitResult.offsetStart;
  3485. }
  3486. if (offset >= textNode.text.length) {
  3487. return SplitResult.offsetEnd;
  3488. }
  3489. var text = textNode.text.slice(0, offset);
  3490. var newText = textNode.text.slice(offset);
  3491. var newTextNode = new TextNode_1.TextNode(newText, textNode.style);
  3492. textNode.text = text;
  3493. this.textNodes.splice(index + 1, 0, newTextNode);
  3494. return SplitResult.complete;
  3495. };
  3496. Block.prototype.removeNodes = function (index, left) {
  3497. // for right selection -> remove from 0 to index
  3498. // for left selection -> remove from index to end
  3499. if (left) {
  3500. if (index === 0) {
  3501. return true;
  3502. }
  3503. this.textNodes = this.textNodes.slice(0, index);
  3504. return false;
  3505. }
  3506. if (index === this.textNodes.length - 1) {
  3507. return true;
  3508. }
  3509. this.textNodes = this.textNodes.slice(index + 1);
  3510. return false;
  3511. };
  3512. Block.prototype.offsetToNodePosition = function (offset) {
  3513. if (offset === 0) {
  3514. return {
  3515. textIndex: 0,
  3516. offset: 0
  3517. };
  3518. }
  3519. var textNodes = this.textNodes;
  3520. for (var i = 0; i < textNodes.length; i++) {
  3521. var len = textNodes[i].text.length;
  3522. if (offset <= len) {
  3523. return {
  3524. textIndex: i,
  3525. offset: offset
  3526. };
  3527. }
  3528. offset -= len;
  3529. }
  3530. };
  3531. Block.prototype.nodePositionToOffset = function (textIndex, offset) {
  3532. for (var i = 0; i < textIndex; i++) {
  3533. offset += this.textNodes[i].text.length;
  3534. }
  3535. return offset;
  3536. };
  3537. Block.prototype.getBlockEnd = function () {
  3538. return {
  3539. textIndex: this.textNodes.length - 1,
  3540. offset: this.textNodes[this.textNodes.length - 1].text.length
  3541. };
  3542. };
  3543. Block.prototype.balance = function () {
  3544. var textNodes = this.textNodes;
  3545. var len = textNodes.length;
  3546. var index = 1;
  3547. while (index < textNodes.length) {
  3548. if (other_1.isEqual(textNodes[index - 1].style, textNodes[index].style)) {
  3549. textNodes[index - 1].text += textNodes[index].text;
  3550. textNodes.splice(index, 1);
  3551. }
  3552. else {
  3553. index++;
  3554. }
  3555. }
  3556. return len !== textNodes.length;
  3557. };
  3558. return Block;
  3559. }());
  3560. exports.Block = Block;
  3561. /***/ }),
  3562. /* 35 */
  3563. /***/ (function(module, exports, __webpack_require__) {
  3564. "use strict";
  3565. Object.defineProperty(exports, "__esModule", { value: true });
  3566. var types_1 = __webpack_require__(2);
  3567. function serializer(blocks) {
  3568. return blocks.reduce(function (result, block) { return result + serializeBlock(block); }, "");
  3569. }
  3570. exports.serializer = serializer;
  3571. function serializeBlock(block) {
  3572. var inline = "";
  3573. var style = block.style, textNodes = block.textNodes;
  3574. var tags = [];
  3575. if (block.style[types_1.Modifier.blockquote]) {
  3576. tags.push("blockquote");
  3577. }
  3578. tags.push(style[types_1.Modifier.style] || "p");
  3579. var align = style[types_1.Modifier.align] ? "text-align: " + style[types_1.Modifier.align] + ";" : "";
  3580. if (textNodes.length === 1 && !textNodes[0].style[types_1.Modifier.link]) {
  3581. var res = serializeTextNode(textNodes[0], true);
  3582. tags.push.apply(tags, res.tags);
  3583. var textInline = res.inline;
  3584. if (textInline || align) {
  3585. inline = " style=\"" + textInline + align + "\"";
  3586. }
  3587. return tagWithContent(tags, inline, res.text);
  3588. }
  3589. if (align) {
  3590. inline = " style=\"" + align + "\"";
  3591. }
  3592. return tagWithContent(tags, inline, serializeTextNodes(textNodes));
  3593. }
  3594. function serializeTextNode(textNode, raw) {
  3595. if (raw === void 0) { raw = false; }
  3596. var style = textNode.style, text = textNode.text;
  3597. var tags = [];
  3598. if (style[types_1.Modifier.underline]) {
  3599. tags.push("u");
  3600. }
  3601. if (style[types_1.Modifier.strike]) {
  3602. tags.push("s");
  3603. }
  3604. if (style[types_1.Modifier.bold]) {
  3605. tags.push("strong");
  3606. }
  3607. if (style[types_1.Modifier.italic]) {
  3608. tags.push("i");
  3609. }
  3610. if (raw) {
  3611. return {
  3612. tags: tags,
  3613. inline: textInlineStyle(style, true),
  3614. text: processText(text)
  3615. };
  3616. }
  3617. var inlineStyle = textInlineStyle(style);
  3618. if (inlineStyle && tags.length === 0) {
  3619. tags.push("span");
  3620. }
  3621. return tagWithContent(tags, inlineStyle, processText(text));
  3622. }
  3623. function serializeTextNodes(textNodes) {
  3624. var res = "";
  3625. var linkContent = "";
  3626. var linkText = "";
  3627. var prevLink;
  3628. for (var _i = 0, textNodes_1 = textNodes; _i < textNodes_1.length; _i++) {
  3629. var textNode = textNodes_1[_i];
  3630. if (textNode.style.link) {
  3631. if (prevLink === textNode.style.link) {
  3632. linkContent += serializeTextNode(textNode);
  3633. linkText += textNode.text.replace(/\"/g, "'");
  3634. }
  3635. else {
  3636. linkContent = serializeTextNode(textNode);
  3637. linkText = textNode.text.replace(/\"/g, "'");
  3638. }
  3639. }
  3640. else {
  3641. if (prevLink) {
  3642. res += tagWithContent(["a"], " href=\"" + prevLink + "\" title=\"" + linkText + "\"", linkContent);
  3643. }
  3644. res += serializeTextNode(textNode);
  3645. }
  3646. prevLink = textNode.style.link;
  3647. }
  3648. if (prevLink) {
  3649. res += tagWithContent(["a"], " href=\"" + prevLink + "\" title=\"" + linkText + "\"", linkContent);
  3650. }
  3651. return res;
  3652. }
  3653. function textInlineStyle(style, raw) {
  3654. if (raw === void 0) { raw = false; }
  3655. var inline = "";
  3656. for (var key in style) {
  3657. switch (key) {
  3658. case types_1.Modifier.background:
  3659. inline += "background: " + style[key] + ";";
  3660. break;
  3661. case types_1.Modifier.color:
  3662. inline += "color: " + style[key] + ";";
  3663. break;
  3664. case types_1.Modifier.fontFamily:
  3665. inline += "font-family: " + style[key] + ";";
  3666. break;
  3667. case types_1.Modifier.fontSize:
  3668. inline += "font-size: " + style[key] + ";";
  3669. break;
  3670. }
  3671. }
  3672. if (raw) {
  3673. return inline;
  3674. }
  3675. if (inline) {
  3676. return " style=\"" + inline + "\"";
  3677. }
  3678. return "";
  3679. }
  3680. function tagWithContent(tags, inlineStyle, content) {
  3681. if (tags.length === 0 && content.trim() === "") {
  3682. tags.push("span");
  3683. }
  3684. var openTags = tags.reduce(function (res, tag, i) { return res + (i === 0 ? "<" + tag + inlineStyle + ">" : "<" + tag + ">"); }, "");
  3685. var closeTags = tags.reduceRight(function (res, tag) { return res + ("</" + tag + ">"); }, "");
  3686. return openTags + content + closeTags;
  3687. }
  3688. function repeatStr(str, count) {
  3689. var res = "";
  3690. while (count--) {
  3691. res += str;
  3692. }
  3693. return res;
  3694. }
  3695. function processText(text) {
  3696. return text
  3697. .replace(/</g, "&lt;")
  3698. .replace(/>/g, "&gt;")
  3699. .replace(/\n/g, "<br>")
  3700. .replace(/[ ]{2,}/g, function (match) { return " " + repeatStr("&nbsp;", match.length - 1); });
  3701. }
  3702. /***/ }),
  3703. /* 36 */
  3704. /***/ (function(module, exports, __webpack_require__) {
  3705. "use strict";
  3706. Object.defineProperty(exports, "__esModule", { value: true });
  3707. __webpack_require__(37);
  3708. var Richtext_1 = __webpack_require__(38);
  3709. exports.Richtext = Richtext_1.Richtext;
  3710. var en_1 = __webpack_require__(11);
  3711. var w = window;
  3712. exports.i18n = (w.dhx && w.dhx.i18n) ? w.dhx.i18 : {};
  3713. exports.i18n.setLocale = function (component, value) {
  3714. var target = exports.i18n[component];
  3715. for (var key in value) {
  3716. target[key] = value[key];
  3717. }
  3718. };
  3719. exports.i18n.richtext = exports.i18n.richtext || en_1.default;
  3720. /***/ }),
  3721. /* 37 */
  3722. /***/ (function(module, exports, __webpack_require__) {
  3723. // extracted by mini-css-extract-plugin
  3724. /***/ }),
  3725. /* 38 */
  3726. /***/ (function(module, exports, __webpack_require__) {
  3727. "use strict";
  3728. var __extends = (this && this.__extends) || (function () {
  3729. var extendStatics = Object.setPrototypeOf ||
  3730. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3731. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3732. return function (d, b) {
  3733. extendStatics(d, b);
  3734. function __() { this.constructor = d; }
  3735. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3736. };
  3737. })();
  3738. var __assign = (this && this.__assign) || Object.assign || function(t) {
  3739. for (var s, i = 1, n = arguments.length; i < n; i++) {
  3740. s = arguments[i];
  3741. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  3742. t[p] = s[p];
  3743. }
  3744. return t;
  3745. };
  3746. Object.defineProperty(exports, "__esModule", { value: true });
  3747. var core_1 = __webpack_require__(3);
  3748. var dom_1 = __webpack_require__(0);
  3749. var events_1 = __webpack_require__(7);
  3750. var html_1 = __webpack_require__(1);
  3751. var view_1 = __webpack_require__(8);
  3752. var ts_layout_1 = __webpack_require__(41);
  3753. var constants_1 = __webpack_require__(5);
  3754. var composition_1 = __webpack_require__(69);
  3755. var link_1 = __webpack_require__(70);
  3756. var other_1 = __webpack_require__(4);
  3757. var scroll_1 = __webpack_require__(72);
  3758. var statistics_1 = __webpack_require__(32);
  3759. var styles_1 = __webpack_require__(19);
  3760. var toolbar_1 = __webpack_require__(73);
  3761. var keyhandler_1 = __webpack_require__(31);
  3762. var Editor_1 = __webpack_require__(79);
  3763. var types_1 = __webpack_require__(2);
  3764. var Richtext = /** @class */ (function (_super) {
  3765. __extends(Richtext, _super);
  3766. function Richtext(container, config) {
  3767. var _a;
  3768. var _this = _super.call(this, container, core_1.extend({
  3769. mode: "classic",
  3770. toolbarBlocks: [
  3771. types_1.RTEToolbarBlock.undo,
  3772. types_1.RTEToolbarBlock.style,
  3773. types_1.RTEToolbarBlock.decoration,
  3774. types_1.RTEToolbarBlock.color,
  3775. types_1.RTEToolbarBlock.align,
  3776. types_1.RTEToolbarBlock.link
  3777. // RTEToolbarBlock.clear,
  3778. // RTEToolbarBlock.fullscreen
  3779. ]
  3780. }, config)) || this;
  3781. var defaultBlockIndex = _this.config.toolbarBlocks.indexOf(types_1.RTEToolbarBlock.default);
  3782. if (defaultBlockIndex !== -1) {
  3783. (_a = _this.config.toolbarBlocks).splice.apply(_a, [defaultBlockIndex, 1].concat(constants_1.defaultBlocks));
  3784. }
  3785. _this._initContainer = html_1.toNode(container);
  3786. _this.events = new events_1.EventSystem();
  3787. var getRootView = function () { return _this.getRootView(); };
  3788. _this._composition = {
  3789. active: false,
  3790. initSelection: null
  3791. };
  3792. _this._compositionEventsDestructor = composition_1.listenCompositionEvents(_this.events, function () { return _this._editor.selection.isActive(); });
  3793. _this._editor = new Editor_1.Editor({
  3794. events: _this.events,
  3795. uid: _this._uid,
  3796. getRootView: getRootView,
  3797. repaint: function () { return _this.paint(); }
  3798. });
  3799. _this._toolbarHelper = new toolbar_1.RichTextToolbarHelper(_this, _this._editor);
  3800. _this.toolbar = _this._toolbarHelper.toolbar;
  3801. _this._linkEditor = new link_1.LinkEditor(null, {
  3802. events: _this.events,
  3803. editor: _this._editor,
  3804. getRootView: getRootView
  3805. });
  3806. _this._initHandlers();
  3807. _this._initUI(_this._initContainer);
  3808. _this._initEvents();
  3809. return _this;
  3810. }
  3811. Richtext.prototype.setValue = function (value, mode) {
  3812. if (mode === void 0) { mode = "html"; }
  3813. this.events.fire(types_1.RichTextEvents.action, [types_1.Action.parse, { value: value, mode: mode }, false]);
  3814. };
  3815. Richtext.prototype.getValue = function (mode) {
  3816. if (mode === void 0) { mode = "html"; }
  3817. return this._editor.serialize(mode);
  3818. };
  3819. Richtext.prototype.getStats = function (selection) {
  3820. var text = selection ? this._editor.selection.getSelectedText() : this.getValue("text");
  3821. return statistics_1.getStats(text, this.config.customStats);
  3822. };
  3823. Richtext.prototype.destructor = function () {
  3824. this._compositionEventsDestructor();
  3825. this._editor.selection.destructor();
  3826. this.toolbar.destructor();
  3827. this._layout.getRootView().unmount();
  3828. };
  3829. Richtext.prototype.fullScreen = function () {
  3830. if (this.toolbar.data.exists("fullscreen")) {
  3831. this.toolbar.data.update("fullscreen", {
  3832. icon: "dxi-arrow-collapse",
  3833. $fullscreen: true
  3834. });
  3835. }
  3836. document.body.classList.add("dhx_richtext--fullscreen", "dhx_widget--fullscreen");
  3837. var view = this._layout.getRootView();
  3838. view.mount(document.body);
  3839. };
  3840. Richtext.prototype.exitFullScreen = function () {
  3841. if (this.toolbar.data.exists("fullscreen")) {
  3842. this.toolbar.data.update("fullscreen", {
  3843. icon: "dxi-arrow-expand",
  3844. $fullscreen: false
  3845. });
  3846. }
  3847. document.body.classList.remove("dhx_richtext--fullscreen", "dhx_widget--fullscreen");
  3848. var view = this._layout.getRootView();
  3849. view.mount(this._initContainer);
  3850. };
  3851. Richtext.prototype.getEditorAPI = function () {
  3852. var _this = this;
  3853. return {
  3854. getSelection: function () { return _this._editor.selection.get(); },
  3855. setSelection: function (selection) {
  3856. _this._editor.selection.set(selection);
  3857. _this._restoreFocus();
  3858. },
  3859. getPosition: function (selection) { return _this._editor.selection.getPosition(selection); },
  3860. getModel: function () { return _this._editor.blocks.map(function (block) { return ({
  3861. style: __assign({}, block.style),
  3862. textNodes: block.textNodes.map(function (textNode) { return ({
  3863. style: __assign({}, textNode.style),
  3864. text: textNode.text
  3865. }); })
  3866. }); }); },
  3867. setModel: function (blocks, selection) {
  3868. _this.events.fire(types_1.RichTextEvents.action, [types_1.Action.parse, { value: blocks, mode: "inner" }, false]);
  3869. if (selection) {
  3870. _this._editor.selection.set(selection);
  3871. }
  3872. },
  3873. add: function (config, selection) {
  3874. if (selection) {
  3875. _this._editor.selection.set(selection);
  3876. }
  3877. _this.events.fire(types_1.RichTextEvents.action, [types_1.Action.innerAdd, config, true]);
  3878. },
  3879. remove: function (selection) {
  3880. if (selection) {
  3881. _this._editor.selection.set(selection);
  3882. }
  3883. _this.events.fire(types_1.RichTextEvents.action, [types_1.Action.remove, true, true]);
  3884. },
  3885. update: function (config, selection) {
  3886. if (selection) {
  3887. _this._editor.selection.set(selection);
  3888. }
  3889. _this.events.fire(types_1.RichTextEvents.action, [types_1.Action.update, {
  3890. modifier: config.modifier,
  3891. modifierValue: config.value
  3892. }]);
  3893. }
  3894. };
  3895. };
  3896. Richtext.prototype._initUI = function (container) {
  3897. var _this = this;
  3898. var layout = this._layout = new ts_layout_1.Layout(container, {
  3899. css: "dhx_richtext" + " dhx_richtext--mode_" + this.config.mode,
  3900. cols: [{
  3901. css: "dhx_toolbar__height-holder",
  3902. rows: [
  3903. { id: "toolbar", on: { click: function () { return _this._restoreFocus(); } }, css: "dhx_richtext__toolbar-holder" },
  3904. { id: "editor", css: "dhx_richtext__editor-holder" }
  3905. ]
  3906. }]
  3907. });
  3908. this.mount(null, dom_1.create({
  3909. render: function () { return _this._draw(); },
  3910. hooks: {
  3911. didRedraw: function () {
  3912. if (_this._editor.selection.isActive()) {
  3913. var isUpdated = _this._editor.selection.update();
  3914. if (!isUpdated) {
  3915. _this._restoreFocus();
  3916. }
  3917. }
  3918. }
  3919. }
  3920. }));
  3921. layout.cell("editor").attach(this);
  3922. layout.cell("toolbar").attach(this.toolbar);
  3923. };
  3924. Richtext.prototype._initHandlers = function () {
  3925. var _this = this;
  3926. this._handlers = {
  3927. onkeydown: function (e) {
  3928. if (_this._composition.active || (_this._linkEditor.isVisible() && !_this._editor.selection.isActive())) {
  3929. return;
  3930. }
  3931. var operation = keyhandler_1.keyToOperation(e);
  3932. if (!operation) {
  3933. return;
  3934. }
  3935. _this.events.fire(types_1.RichTextEvents.action, [operation.action, operation.data]);
  3936. },
  3937. onpaste: function (e) {
  3938. _this.events.fire(types_1.RichTextEvents.action, [types_1.Action.paste, e, false]);
  3939. },
  3940. oncut: function (e) {
  3941. _this.events.fire(types_1.RichTextEvents.action, [types_1.Action.cut, e, false]);
  3942. },
  3943. oncopy: function (e) {
  3944. _this.events.fire(types_1.RichTextEvents.action, [types_1.Action.copy, e, false]);
  3945. },
  3946. ondrop: function (e) {
  3947. e.preventDefault();
  3948. },
  3949. ondragstart: function (e) {
  3950. e.preventDefault();
  3951. }
  3952. };
  3953. };
  3954. Richtext.prototype._initEvents = function () {
  3955. var _this = this;
  3956. this.events.on(types_1.RichTextEvents.selectionRefresh, function () { return _this._scrollHelper.update(); });
  3957. this.events.on(types_1.RichTextEvents.action, function (action, data, restoreFocus) {
  3958. var isChanged = _this._editor.manager.execute({ action: action, data: data });
  3959. if (isChanged) {
  3960. _this.events.fire(types_1.RichTextEvents.change, [action, _this._editor.manager.canUndo(), _this._editor.manager.canRedo()]);
  3961. _this.paint();
  3962. }
  3963. if (restoreFocus) {
  3964. _this._restoreFocus();
  3965. }
  3966. });
  3967. this.events.on(types_1.RichTextEvents.compositionStart, function () {
  3968. _this._composition.active = true;
  3969. _this._composition.initSelection = _this._editor.selection.get();
  3970. });
  3971. this.events.on(types_1.RichTextEvents.compositionEnd, function (data) {
  3972. _this._editor.selection.set(_this._composition.initSelection);
  3973. _this.events.fire(types_1.RichTextEvents.action, [types_1.Action.add, data, true]);
  3974. _this._composition.active = false;
  3975. _this._composition.initSelection = null;
  3976. });
  3977. };
  3978. Richtext.prototype._restoreFocus = function () {
  3979. var _this = this;
  3980. if (this._restoreFocusTimeout) {
  3981. clearTimeout(this._restoreFocusTimeout);
  3982. }
  3983. this._restoreFocusTimeout = setTimeout(function () {
  3984. _this._scrollHelper.saveScrollTop();
  3985. _this.getRootView().refs.editor.el.focus();
  3986. _this._scrollHelper.restoreScrollTop();
  3987. var isUpdated = _this._editor.selection.refresh();
  3988. _this._restoreFocusTimeout = null;
  3989. if (!isUpdated) {
  3990. _this._restoreFocus();
  3991. }
  3992. }, 25);
  3993. };
  3994. Richtext.prototype._draw = function () {
  3995. var _this = this;
  3996. var currentLinkRef = this._linkEditor.getCurrentLinkRef();
  3997. var linkRefer = other_1.getLinkRefer();
  3998. var currentLink = null;
  3999. var currentLinkArr = [];
  4000. return dom_1.el(".dhx_richtext__overflow-wrapper", {
  4001. _hooks: this.config.mode === "document" && {
  4002. didInsert: function (node) {
  4003. _this._scrollHelper = scroll_1.createScrollHelper(node.el);
  4004. }
  4005. }
  4006. }, [
  4007. dom_1.el(".dhx_richtext__editor.dhx_richtext-editor", __assign({ "dhx_widget_id": this._uid, "_ref": "editor", "contentEditable": "true", "role": "textbox", "data-gramm": "false", "spellcheck": "false", "_hooks": this.config.mode !== "document" && {
  4008. didInsert: function (node) {
  4009. _this._scrollHelper = scroll_1.createScrollHelper(node.el);
  4010. }
  4011. } }, this._handlers), this._editor.blocks.map(function (block, blockIndex) {
  4012. if (currentLinkArr.length) {
  4013. currentLinkArr = [];
  4014. currentLink = null;
  4015. }
  4016. return styles_1.blockquoteWrapper(block.style, blockIndex)(styles_1.blockStyleToTag(block.style), {
  4017. style: styles_1.calcBlockStyle(block.style),
  4018. dhx_offset: blockIndex
  4019. }, block.textNodes.map(function (textNode, textIndex) {
  4020. var hash = other_1.getTextHash(blockIndex, textIndex);
  4021. var isLastBlockNode = textIndex === block.textNodes.length - 1;
  4022. if (textNode.style.link) {
  4023. if (currentLink !== textNode.style.link) {
  4024. currentLinkArr = [_this._renderTextNode(textNode, hash, isLastBlockNode)];
  4025. currentLink = textNode.style.link;
  4026. var linkRef = linkRefer();
  4027. return dom_1.el("a", {
  4028. href: textNode.style.link,
  4029. class: linkRef === currentLinkRef ? "dhx--link_edited" : "",
  4030. _ref: linkRef
  4031. }, currentLinkArr);
  4032. }
  4033. else {
  4034. currentLinkArr.push(_this._renderTextNode(textNode, hash, isLastBlockNode));
  4035. return;
  4036. }
  4037. }
  4038. currentLink = textNode.style.link;
  4039. return _this._renderTextNode(textNode, hash, isLastBlockNode);
  4040. }));
  4041. }))
  4042. ]);
  4043. };
  4044. Richtext.prototype._renderTextNode = function (textNode, hash, isLastBlockNode) {
  4045. var text = textNode.text;
  4046. var lastSymbolIsGap = text[text.length - 1] === "\n" && isLastBlockNode;
  4047. return dom_1.el("span", {
  4048. _ref: hash,
  4049. dhx_offset: hash,
  4050. style: styles_1.calcTextNodeStyle(textNode.style)
  4051. }, text.length === 0 ? [dom_1.el("br")] : lastSymbolIsGap ? [text + "\n"] : text);
  4052. };
  4053. return Richtext;
  4054. }(view_1.View));
  4055. exports.Richtext = Richtext;
  4056. /***/ }),
  4057. /* 39 */
  4058. /***/ (function(module, exports, __webpack_require__) {
  4059. /**
  4060. * Copyright (c) 2017, Leon Sorokin
  4061. * All rights reserved. (MIT Licensed)
  4062. *
  4063. * domvm.js (DOM ViewModel)
  4064. * A thin, fast, dependency-free vdom view layer
  4065. * @preserve https://github.com/leeoniya/domvm (v3.2.6, micro build)
  4066. */
  4067. (function (global, factory) {
  4068. true ? module.exports = factory() :
  4069. undefined;
  4070. }(this, (function () { 'use strict';
  4071. // NOTE: if adding a new *VNode* type, make it < COMMENT and renumber rest.
  4072. // There are some places that test <= COMMENT to assert if node is a VNode
  4073. // VNode types
  4074. var ELEMENT = 1;
  4075. var TEXT = 2;
  4076. var COMMENT = 3;
  4077. // placeholder types
  4078. var VVIEW = 4;
  4079. var VMODEL = 5;
  4080. var ENV_DOM = typeof window !== "undefined";
  4081. var win = ENV_DOM ? window : {};
  4082. var rAF = win.requestAnimationFrame;
  4083. var emptyObj = {};
  4084. function noop() {}
  4085. var isArr = Array.isArray;
  4086. function isSet(val) {
  4087. return val != null;
  4088. }
  4089. function isPlainObj(val) {
  4090. return val != null && val.constructor === Object; // && typeof val === "object"
  4091. }
  4092. function insertArr(targ, arr, pos, rem) {
  4093. targ.splice.apply(targ, [pos, rem].concat(arr));
  4094. }
  4095. function isVal(val) {
  4096. var t = typeof val;
  4097. return t === "string" || t === "number";
  4098. }
  4099. function isFunc(val) {
  4100. return typeof val === "function";
  4101. }
  4102. function isProm(val) {
  4103. return typeof val === "object" && isFunc(val.then);
  4104. }
  4105. function assignObj(targ) {
  4106. var args = arguments;
  4107. for (var i = 1; i < args.length; i++)
  4108. { for (var k in args[i])
  4109. { targ[k] = args[i][k]; } }
  4110. return targ;
  4111. }
  4112. // export const defProp = Object.defineProperty;
  4113. function deepSet(targ, path, val) {
  4114. var seg;
  4115. while (seg = path.shift()) {
  4116. if (path.length === 0)
  4117. { targ[seg] = val; }
  4118. else
  4119. { targ[seg] = targ = targ[seg] || {}; }
  4120. }
  4121. }
  4122. /*
  4123. export function deepUnset(targ, path) {
  4124. var seg;
  4125. while (seg = path.shift()) {
  4126. if (path.length === 0)
  4127. targ[seg] = val;
  4128. else
  4129. targ[seg] = targ = targ[seg] || {};
  4130. }
  4131. }
  4132. */
  4133. function sliceArgs(args, offs) {
  4134. var arr = [];
  4135. for (var i = offs; i < args.length; i++)
  4136. { arr.push(args[i]); }
  4137. return arr;
  4138. }
  4139. function cmpObj(a, b) {
  4140. for (var i in a)
  4141. { if (a[i] !== b[i])
  4142. { return false; } }
  4143. return true;
  4144. }
  4145. function cmpArr(a, b) {
  4146. var alen = a.length;
  4147. if (b.length !== alen)
  4148. { return false; }
  4149. for (var i = 0; i < alen; i++)
  4150. { if (a[i] !== b[i])
  4151. { return false; } }
  4152. return true;
  4153. }
  4154. // https://github.com/darsain/raft
  4155. // rAF throttler, aggregates multiple repeated redraw calls within single animframe
  4156. function raft(fn) {
  4157. if (!rAF)
  4158. { return fn; }
  4159. var id, ctx, args;
  4160. function call() {
  4161. id = 0;
  4162. fn.apply(ctx, args);
  4163. }
  4164. return function() {
  4165. ctx = this;
  4166. args = arguments;
  4167. if (!id) { id = rAF(call); }
  4168. };
  4169. }
  4170. function curry(fn, args, ctx) {
  4171. return function() {
  4172. return fn.apply(ctx, args);
  4173. };
  4174. }
  4175. /*
  4176. export function prop(val, cb, ctx, args) {
  4177. return function(newVal, execCb) {
  4178. if (newVal !== undefined && newVal !== val) {
  4179. val = newVal;
  4180. execCb !== false && isFunc(cb) && cb.apply(ctx, args);
  4181. }
  4182. return val;
  4183. };
  4184. }
  4185. */
  4186. /*
  4187. // adapted from https://github.com/Olical/binary-search
  4188. export function binaryKeySearch(list, item) {
  4189. var min = 0;
  4190. var max = list.length - 1;
  4191. var guess;
  4192. var bitwise = (max <= 2147483647) ? true : false;
  4193. if (bitwise) {
  4194. while (min <= max) {
  4195. guess = (min + max) >> 1;
  4196. if (list[guess].key === item) { return guess; }
  4197. else {
  4198. if (list[guess].key < item) { min = guess + 1; }
  4199. else { max = guess - 1; }
  4200. }
  4201. }
  4202. } else {
  4203. while (min <= max) {
  4204. guess = Math.floor((min + max) / 2);
  4205. if (list[guess].key === item) { return guess; }
  4206. else {
  4207. if (list[guess].key < item) { min = guess + 1; }
  4208. else { max = guess - 1; }
  4209. }
  4210. }
  4211. }
  4212. return -1;
  4213. }
  4214. */
  4215. // https://en.wikipedia.org/wiki/Longest_increasing_subsequence
  4216. // impl borrowed from https://github.com/ivijs/ivi
  4217. function longestIncreasingSubsequence(a) {
  4218. var p = a.slice();
  4219. var result = [];
  4220. result.push(0);
  4221. var u;
  4222. var v;
  4223. for (var i = 0, il = a.length; i < il; ++i) {
  4224. var j = result[result.length - 1];
  4225. if (a[j] < a[i]) {
  4226. p[i] = j;
  4227. result.push(i);
  4228. continue;
  4229. }
  4230. u = 0;
  4231. v = result.length - 1;
  4232. while (u < v) {
  4233. var c = ((u + v) / 2) | 0;
  4234. if (a[result[c]] < a[i]) {
  4235. u = c + 1;
  4236. } else {
  4237. v = c;
  4238. }
  4239. }
  4240. if (a[i] < a[result[u]]) {
  4241. if (u > 0) {
  4242. p[i] = result[u - 1];
  4243. }
  4244. result[u] = i;
  4245. }
  4246. }
  4247. u = result.length;
  4248. v = result[u - 1];
  4249. while (u-- > 0) {
  4250. result[u] = v;
  4251. v = p[v];
  4252. }
  4253. return result;
  4254. }
  4255. // based on https://github.com/Olical/binary-search
  4256. function binaryFindLarger(item, list) {
  4257. var min = 0;
  4258. var max = list.length - 1;
  4259. var guess;
  4260. var bitwise = (max <= 2147483647) ? true : false;
  4261. if (bitwise) {
  4262. while (min <= max) {
  4263. guess = (min + max) >> 1;
  4264. if (list[guess] === item) { return guess; }
  4265. else {
  4266. if (list[guess] < item) { min = guess + 1; }
  4267. else { max = guess - 1; }
  4268. }
  4269. }
  4270. } else {
  4271. while (min <= max) {
  4272. guess = Math.floor((min + max) / 2);
  4273. if (list[guess] === item) { return guess; }
  4274. else {
  4275. if (list[guess] < item) { min = guess + 1; }
  4276. else { max = guess - 1; }
  4277. }
  4278. }
  4279. }
  4280. return (min == list.length) ? null : min;
  4281. // return -1;
  4282. }
  4283. function isEvProp(name) {
  4284. return name[0] === "o" && name[1] === "n";
  4285. }
  4286. function isSplProp(name) {
  4287. return name[0] === "_";
  4288. }
  4289. function isStyleProp(name) {
  4290. return name === "style";
  4291. }
  4292. function repaint(node) {
  4293. node && node.el && node.el.offsetHeight;
  4294. }
  4295. function isHydrated(vm) {
  4296. return vm.node != null && vm.node.el != null;
  4297. }
  4298. // tests interactive props where real val should be compared
  4299. function isDynProp(tag, attr) {
  4300. // switch (tag) {
  4301. // case "input":
  4302. // case "textarea":
  4303. // case "select":
  4304. // case "option":
  4305. switch (attr) {
  4306. case "value":
  4307. case "checked":
  4308. case "selected":
  4309. // case "selectedIndex":
  4310. return true;
  4311. }
  4312. // }
  4313. return false;
  4314. }
  4315. function getVm(n) {
  4316. n = n || emptyObj;
  4317. while (n.vm == null && n.parent)
  4318. { n = n.parent; }
  4319. return n.vm;
  4320. }
  4321. function VNode() {}
  4322. var VNodeProto = VNode.prototype = {
  4323. constructor: VNode,
  4324. type: null,
  4325. vm: null,
  4326. // all this stuff can just live in attrs (as defined) just have getters here for it
  4327. key: null,
  4328. ref: null,
  4329. data: null,
  4330. hooks: null,
  4331. ns: null,
  4332. el: null,
  4333. tag: null,
  4334. attrs: null,
  4335. body: null,
  4336. flags: 0,
  4337. _class: null,
  4338. _diff: null,
  4339. // pending removal on promise resolution
  4340. _dead: false,
  4341. // part of longest increasing subsequence?
  4342. _lis: false,
  4343. idx: null,
  4344. parent: null,
  4345. /*
  4346. // break out into optional fluent module
  4347. key: function(val) { this.key = val; return this; },
  4348. ref: function(val) { this.ref = val; return this; }, // deep refs
  4349. data: function(val) { this.data = val; return this; },
  4350. hooks: function(val) { this.hooks = val; return this; }, // h("div").hooks()
  4351. html: function(val) { this.html = true; return this.body(val); },
  4352. body: function(val) { this.body = val; return this; },
  4353. */
  4354. };
  4355. function defineText(body) {
  4356. var node = new VNode;
  4357. node.type = TEXT;
  4358. node.body = body;
  4359. return node;
  4360. }
  4361. // creates a one-shot self-ending stream that redraws target vm
  4362. // TODO: if it's already registered by any parent vm, then ignore to avoid simultaneous parent & child refresh
  4363. var tagCache = {};
  4364. var RE_ATTRS = /\[(\w+)(?:=(\w+))?\]/g;
  4365. function cssTag(raw) {
  4366. {
  4367. var cached = tagCache[raw];
  4368. if (cached == null) {
  4369. var tag, id, cls, attr;
  4370. tagCache[raw] = cached = {
  4371. tag: (tag = raw.match( /^[-\w]+/)) ? tag[0] : "div",
  4372. id: (id = raw.match( /#([-\w]+)/)) ? id[1] : null,
  4373. class: (cls = raw.match(/\.([-\w.]+)/)) ? cls[1].replace(/\./g, " ") : null,
  4374. attrs: null,
  4375. };
  4376. while (attr = RE_ATTRS.exec(raw)) {
  4377. if (cached.attrs == null)
  4378. { cached.attrs = {}; }
  4379. cached.attrs[attr[1]] = attr[2] || "";
  4380. }
  4381. }
  4382. return cached;
  4383. }
  4384. }
  4385. // (de)optimization flags
  4386. // forces slow bottom-up removeChild to fire deep willRemove/willUnmount hooks,
  4387. var DEEP_REMOVE = 1;
  4388. // prevents inserting/removing/reordering of children
  4389. var FIXED_BODY = 2;
  4390. // enables fast keyed lookup of children via binary search, expects homogeneous keyed body
  4391. var KEYED_LIST = 4;
  4392. // indicates an vnode match/diff/recycler function for body
  4393. var LAZY_LIST = 8;
  4394. function initElementNode(tag, attrs, body, flags) {
  4395. var node = new VNode;
  4396. node.type = ELEMENT;
  4397. if (isSet(flags))
  4398. { node.flags = flags; }
  4399. node.attrs = attrs;
  4400. var parsed = cssTag(tag);
  4401. node.tag = parsed.tag;
  4402. // meh, weak assertion, will fail for id=0, etc.
  4403. if (parsed.id || parsed.class || parsed.attrs) {
  4404. var p = node.attrs || {};
  4405. if (parsed.id && !isSet(p.id))
  4406. { p.id = parsed.id; }
  4407. if (parsed.class) {
  4408. node._class = parsed.class; // static class
  4409. p.class = parsed.class + (isSet(p.class) ? (" " + p.class) : "");
  4410. }
  4411. if (parsed.attrs) {
  4412. for (var key in parsed.attrs)
  4413. { if (!isSet(p[key]))
  4414. { p[key] = parsed.attrs[key]; } }
  4415. }
  4416. // if (node.attrs !== p)
  4417. node.attrs = p;
  4418. }
  4419. var mergedAttrs = node.attrs;
  4420. if (isSet(mergedAttrs)) {
  4421. if (isSet(mergedAttrs._key))
  4422. { node.key = mergedAttrs._key; }
  4423. if (isSet(mergedAttrs._ref))
  4424. { node.ref = mergedAttrs._ref; }
  4425. if (isSet(mergedAttrs._hooks))
  4426. { node.hooks = mergedAttrs._hooks; }
  4427. if (isSet(mergedAttrs._data))
  4428. { node.data = mergedAttrs._data; }
  4429. if (isSet(mergedAttrs._flags))
  4430. { node.flags = mergedAttrs._flags; }
  4431. if (!isSet(node.key)) {
  4432. if (isSet(node.ref))
  4433. { node.key = node.ref; }
  4434. else if (isSet(mergedAttrs.id))
  4435. { node.key = mergedAttrs.id; }
  4436. else if (isSet(mergedAttrs.name))
  4437. { node.key = mergedAttrs.name + (mergedAttrs.type === "radio" || mergedAttrs.type === "checkbox" ? mergedAttrs.value : ""); }
  4438. }
  4439. }
  4440. if (body != null)
  4441. { node.body = body; }
  4442. return node;
  4443. }
  4444. function setRef(vm, name, node) {
  4445. var path = ["refs"].concat(name.split("."));
  4446. deepSet(vm, path, node);
  4447. }
  4448. function setDeepRemove(node) {
  4449. while (node = node.parent)
  4450. { node.flags |= DEEP_REMOVE; }
  4451. }
  4452. // vnew, vold
  4453. function preProc(vnew, parent, idx, ownVm) {
  4454. if (vnew.type === VMODEL || vnew.type === VVIEW)
  4455. { return; }
  4456. vnew.parent = parent;
  4457. vnew.idx = idx;
  4458. vnew.vm = ownVm;
  4459. if (vnew.ref != null)
  4460. { setRef(getVm(vnew), vnew.ref, vnew); }
  4461. var nh = vnew.hooks,
  4462. vh = ownVm && ownVm.hooks;
  4463. if (nh && (nh.willRemove || nh.didRemove) ||
  4464. vh && (vh.willUnmount || vh.didUnmount))
  4465. { setDeepRemove(vnew); }
  4466. if (isArr(vnew.body))
  4467. { preProcBody(vnew); }
  4468. else {}
  4469. }
  4470. function preProcBody(vnew) {
  4471. var body = vnew.body;
  4472. for (var i = 0; i < body.length; i++) {
  4473. var node2 = body[i];
  4474. // remove false/null/undefined
  4475. if (node2 === false || node2 == null)
  4476. { body.splice(i--, 1); }
  4477. // flatten arrays
  4478. else if (isArr(node2)) {
  4479. insertArr(body, node2, i--, 1);
  4480. }
  4481. else {
  4482. if (node2.type == null)
  4483. { body[i] = node2 = defineText(""+node2); }
  4484. if (node2.type === TEXT) {
  4485. // remove empty text nodes
  4486. if (node2.body == null || node2.body === "")
  4487. { body.splice(i--, 1); }
  4488. // merge with previous text node
  4489. else if (i > 0 && body[i-1].type === TEXT) {
  4490. body[i-1].body += node2.body;
  4491. body.splice(i--, 1);
  4492. }
  4493. else
  4494. { preProc(node2, vnew, i, null); }
  4495. }
  4496. else
  4497. { preProc(node2, vnew, i, null); }
  4498. }
  4499. }
  4500. }
  4501. var unitlessProps = {
  4502. animationIterationCount: true,
  4503. boxFlex: true,
  4504. boxFlexGroup: true,
  4505. boxOrdinalGroup: true,
  4506. columnCount: true,
  4507. flex: true,
  4508. flexGrow: true,
  4509. flexPositive: true,
  4510. flexShrink: true,
  4511. flexNegative: true,
  4512. flexOrder: true,
  4513. gridRow: true,
  4514. gridColumn: true,
  4515. order: true,
  4516. lineClamp: true,
  4517. borderImageOutset: true,
  4518. borderImageSlice: true,
  4519. borderImageWidth: true,
  4520. fontWeight: true,
  4521. lineHeight: true,
  4522. opacity: true,
  4523. orphans: true,
  4524. tabSize: true,
  4525. widows: true,
  4526. zIndex: true,
  4527. zoom: true,
  4528. fillOpacity: true,
  4529. floodOpacity: true,
  4530. stopOpacity: true,
  4531. strokeDasharray: true,
  4532. strokeDashoffset: true,
  4533. strokeMiterlimit: true,
  4534. strokeOpacity: true,
  4535. strokeWidth: true
  4536. };
  4537. function autoPx(name, val) {
  4538. {
  4539. // typeof val === 'number' is faster but fails for numeric strings
  4540. return !isNaN(val) && !unitlessProps[name] ? (val + "px") : val;
  4541. }
  4542. }
  4543. // assumes if styles exist both are objects or both are strings
  4544. function patchStyle(n, o) {
  4545. var ns = (n.attrs || emptyObj).style;
  4546. var os = o ? (o.attrs || emptyObj).style : null;
  4547. // replace or remove in full
  4548. if (ns == null || isVal(ns))
  4549. { n.el.style.cssText = ns; }
  4550. else {
  4551. for (var nn in ns) {
  4552. var nv = ns[nn];
  4553. if (os == null || nv != null && nv !== os[nn])
  4554. { n.el.style[nn] = autoPx(nn, nv); }
  4555. }
  4556. // clean old
  4557. if (os) {
  4558. for (var on in os) {
  4559. if (ns[on] == null)
  4560. { n.el.style[on] = ""; }
  4561. }
  4562. }
  4563. }
  4564. }
  4565. var didQueue = [];
  4566. function fireHook(hooks, name, o, n, immediate) {
  4567. if (hooks != null) {
  4568. var fn = o.hooks[name];
  4569. if (fn) {
  4570. if (name[0] === "d" && name[1] === "i" && name[2] === "d") { // did*
  4571. // console.log(name + " should queue till repaint", o, n);
  4572. immediate ? repaint(o.parent) && fn(o, n) : didQueue.push([fn, o, n]);
  4573. }
  4574. else { // will*
  4575. // console.log(name + " may delay by promise", o, n);
  4576. return fn(o, n); // or pass done() resolver
  4577. }
  4578. }
  4579. }
  4580. }
  4581. function drainDidHooks(vm) {
  4582. if (didQueue.length) {
  4583. repaint(vm.node);
  4584. var item;
  4585. while (item = didQueue.shift())
  4586. { item[0](item[1], item[2]); }
  4587. }
  4588. }
  4589. var doc = ENV_DOM ? document : null;
  4590. function closestVNode(el) {
  4591. while (el._node == null)
  4592. { el = el.parentNode; }
  4593. return el._node;
  4594. }
  4595. function createElement(tag, ns) {
  4596. if (ns != null)
  4597. { return doc.createElementNS(ns, tag); }
  4598. return doc.createElement(tag);
  4599. }
  4600. function createTextNode(body) {
  4601. return doc.createTextNode(body);
  4602. }
  4603. function createComment(body) {
  4604. return doc.createComment(body);
  4605. }
  4606. // ? removes if !recycled
  4607. function nextSib(sib) {
  4608. return sib.nextSibling;
  4609. }
  4610. // ? removes if !recycled
  4611. function prevSib(sib) {
  4612. return sib.previousSibling;
  4613. }
  4614. // TODO: this should collect all deep proms from all hooks and return Promise.all()
  4615. function deepNotifyRemove(node) {
  4616. var vm = node.vm;
  4617. var wuRes = vm != null && fireHook(vm.hooks, "willUnmount", vm, vm.data);
  4618. var wrRes = fireHook(node.hooks, "willRemove", node);
  4619. if ((node.flags & DEEP_REMOVE) === DEEP_REMOVE && isArr(node.body)) {
  4620. for (var i = 0; i < node.body.length; i++)
  4621. { deepNotifyRemove(node.body[i]); }
  4622. }
  4623. return wuRes || wrRes;
  4624. }
  4625. function _removeChild(parEl, el, immediate) {
  4626. var node = el._node, vm = node.vm;
  4627. if (isArr(node.body)) {
  4628. if ((node.flags & DEEP_REMOVE) === DEEP_REMOVE) {
  4629. for (var i = 0; i < node.body.length; i++)
  4630. { _removeChild(el, node.body[i].el); }
  4631. }
  4632. else
  4633. { deepUnref(node); }
  4634. }
  4635. delete el._node;
  4636. parEl.removeChild(el);
  4637. fireHook(node.hooks, "didRemove", node, null, immediate);
  4638. if (vm != null) {
  4639. fireHook(vm.hooks, "didUnmount", vm, vm.data, immediate);
  4640. vm.node = null;
  4641. }
  4642. }
  4643. // todo: should delay parent unmount() by returning res prom?
  4644. function removeChild(parEl, el) {
  4645. var node = el._node;
  4646. // already marked for removal
  4647. if (node._dead) { return; }
  4648. var res = deepNotifyRemove(node);
  4649. if (res != null && isProm(res)) {
  4650. node._dead = true;
  4651. res.then(curry(_removeChild, [parEl, el, true]));
  4652. }
  4653. else
  4654. { _removeChild(parEl, el); }
  4655. }
  4656. function deepUnref(node) {
  4657. var obody = node.body;
  4658. for (var i = 0; i < obody.length; i++) {
  4659. var o2 = obody[i];
  4660. delete o2.el._node;
  4661. if (o2.vm != null)
  4662. { o2.vm.node = null; }
  4663. if (isArr(o2.body))
  4664. { deepUnref(o2); }
  4665. }
  4666. }
  4667. function clearChildren(parent) {
  4668. var parEl = parent.el;
  4669. if ((parent.flags & DEEP_REMOVE) === 0) {
  4670. isArr(parent.body) && deepUnref(parent);
  4671. parEl.textContent = null;
  4672. }
  4673. else {
  4674. var el = parEl.firstChild;
  4675. do {
  4676. var next = nextSib(el);
  4677. removeChild(parEl, el);
  4678. } while (el = next);
  4679. }
  4680. }
  4681. // todo: hooks
  4682. function insertBefore(parEl, el, refEl) {
  4683. var node = el._node, inDom = el.parentNode != null;
  4684. // el === refEl is asserted as a no-op insert called to fire hooks
  4685. var vm = (el === refEl || !inDom) ? node.vm : null;
  4686. if (vm != null)
  4687. { fireHook(vm.hooks, "willMount", vm, vm.data); }
  4688. fireHook(node.hooks, inDom ? "willReinsert" : "willInsert", node);
  4689. parEl.insertBefore(el, refEl);
  4690. fireHook(node.hooks, inDom ? "didReinsert" : "didInsert", node);
  4691. if (vm != null)
  4692. { fireHook(vm.hooks, "didMount", vm, vm.data); }
  4693. }
  4694. function insertAfter(parEl, el, refEl) {
  4695. insertBefore(parEl, el, refEl ? nextSib(refEl) : null);
  4696. }
  4697. var onemit = {};
  4698. function emitCfg(cfg) {
  4699. assignObj(onemit, cfg);
  4700. }
  4701. function emit(evName) {
  4702. var targ = this,
  4703. src = targ;
  4704. var args = sliceArgs(arguments, 1).concat(src, src.data);
  4705. do {
  4706. var evs = targ.onemit;
  4707. var fn = evs ? evs[evName] : null;
  4708. if (fn) {
  4709. fn.apply(targ, args);
  4710. break;
  4711. }
  4712. } while (targ = targ.parent());
  4713. if (onemit[evName])
  4714. { onemit[evName].apply(targ, args); }
  4715. }
  4716. var onevent = noop;
  4717. function config(newCfg) {
  4718. onevent = newCfg.onevent || onevent;
  4719. {
  4720. if (newCfg.onemit)
  4721. { emitCfg(newCfg.onemit); }
  4722. }
  4723. }
  4724. function bindEv(el, type, fn) {
  4725. el[type] = fn;
  4726. }
  4727. function exec(fn, args, e, node, vm) {
  4728. var out = fn.apply(vm, args.concat([e, node, vm, vm.data]));
  4729. // should these respect out === false?
  4730. vm.onevent(e, node, vm, vm.data, args);
  4731. onevent.call(null, e, node, vm, vm.data, args);
  4732. if (out === false) {
  4733. e.preventDefault();
  4734. e.stopPropagation();
  4735. }
  4736. }
  4737. function handle(e) {
  4738. var node = closestVNode(e.target);
  4739. var vm = getVm(node);
  4740. var evDef = e.currentTarget._node.attrs["on" + e.type], fn, args;
  4741. if (isArr(evDef)) {
  4742. fn = evDef[0];
  4743. args = evDef.slice(1);
  4744. exec(fn, args, e, node, vm);
  4745. }
  4746. else {
  4747. for (var sel in evDef) {
  4748. if (e.target.matches(sel)) {
  4749. var evDef2 = evDef[sel];
  4750. if (isArr(evDef2)) {
  4751. fn = evDef2[0];
  4752. args = evDef2.slice(1);
  4753. }
  4754. else {
  4755. fn = evDef2;
  4756. args = [];
  4757. }
  4758. exec(fn, args, e, node, vm);
  4759. }
  4760. }
  4761. }
  4762. }
  4763. function patchEvent(node, name, nval, oval) {
  4764. if (nval === oval)
  4765. { return; }
  4766. var el = node.el;
  4767. if (nval == null || isFunc(nval))
  4768. { bindEv(el, name, nval); }
  4769. else if (oval == null)
  4770. { bindEv(el, name, handle); }
  4771. }
  4772. function remAttr(node, name, asProp) {
  4773. if (name[0] === ".") {
  4774. name = name.substr(1);
  4775. asProp = true;
  4776. }
  4777. if (asProp)
  4778. { node.el[name] = ""; }
  4779. else
  4780. { node.el.removeAttribute(name); }
  4781. }
  4782. // setAttr
  4783. // diff, ".", "on*", bool vals, skip _*, value/checked/selected selectedIndex
  4784. function setAttr(node, name, val, asProp, initial) {
  4785. var el = node.el;
  4786. if (val == null)
  4787. { !initial && remAttr(node, name, false); } // will also removeAttr of style: null
  4788. else if (node.ns != null)
  4789. { el.setAttribute(name, val); }
  4790. else if (name === "class")
  4791. { el.className = val; }
  4792. else if (name === "id" || typeof val === "boolean" || asProp)
  4793. { el[name] = val; }
  4794. else if (name[0] === ".")
  4795. { el[name.substr(1)] = val; }
  4796. else
  4797. { el.setAttribute(name, val); }
  4798. }
  4799. function patchAttrs(vnode, donor, initial) {
  4800. var nattrs = vnode.attrs || emptyObj;
  4801. var oattrs = donor.attrs || emptyObj;
  4802. if (nattrs === oattrs) {
  4803. }
  4804. else {
  4805. for (var key in nattrs) {
  4806. var nval = nattrs[key];
  4807. var isDyn = isDynProp(vnode.tag, key);
  4808. var oval = isDyn ? vnode.el[key] : oattrs[key];
  4809. if (nval === oval) {}
  4810. else if (isStyleProp(key))
  4811. { patchStyle(vnode, donor); }
  4812. else if (isSplProp(key)) {}
  4813. else if (isEvProp(key))
  4814. { patchEvent(vnode, key, nval, oval); }
  4815. else
  4816. { setAttr(vnode, key, nval, isDyn, initial); }
  4817. }
  4818. // TODO: bench style.cssText = "" vs removeAttribute("style")
  4819. for (var key in oattrs) {
  4820. !(key in nattrs) &&
  4821. !isSplProp(key) &&
  4822. remAttr(vnode, key, isDynProp(vnode.tag, key) || isEvProp(key));
  4823. }
  4824. }
  4825. }
  4826. function createView(view, data, key, opts) {
  4827. if (view.type === VVIEW) {
  4828. data = view.data;
  4829. key = view.key;
  4830. opts = view.opts;
  4831. view = view.view;
  4832. }
  4833. return new ViewModel(view, data, key, opts);
  4834. }
  4835. //import { XML_NS, XLINK_NS } from './defineSvgElement';
  4836. function hydrateBody(vnode) {
  4837. for (var i = 0; i < vnode.body.length; i++) {
  4838. var vnode2 = vnode.body[i];
  4839. var type2 = vnode2.type;
  4840. // ELEMENT,TEXT,COMMENT
  4841. if (type2 <= COMMENT)
  4842. { insertBefore(vnode.el, hydrate(vnode2)); } // vnode.el.appendChild(hydrate(vnode2))
  4843. else if (type2 === VVIEW) {
  4844. var vm = createView(vnode2.view, vnode2.data, vnode2.key, vnode2.opts)._redraw(vnode, i, false); // todo: handle new data updates
  4845. type2 = vm.node.type;
  4846. insertBefore(vnode.el, hydrate(vm.node));
  4847. }
  4848. else if (type2 === VMODEL) {
  4849. var vm = vnode2.vm;
  4850. vm._redraw(vnode, i); // , false
  4851. type2 = vm.node.type;
  4852. insertBefore(vnode.el, vm.node.el); // , hydrate(vm.node)
  4853. }
  4854. }
  4855. }
  4856. // TODO: DRY this out. reusing normal patch here negatively affects V8's JIT
  4857. function hydrate(vnode, withEl) {
  4858. if (vnode.el == null) {
  4859. if (vnode.type === ELEMENT) {
  4860. vnode.el = withEl || createElement(vnode.tag, vnode.ns);
  4861. // if (vnode.tag === "svg")
  4862. // vnode.el.setAttributeNS(XML_NS, 'xmlns:xlink', XLINK_NS);
  4863. if (vnode.attrs != null)
  4864. { patchAttrs(vnode, emptyObj, true); }
  4865. if ((vnode.flags & LAZY_LIST) === LAZY_LIST) // vnode.body instanceof LazyList
  4866. { vnode.body.body(vnode); }
  4867. if (isArr(vnode.body))
  4868. { hydrateBody(vnode); }
  4869. else if (vnode.body != null && vnode.body !== "")
  4870. { vnode.el.textContent = vnode.body; }
  4871. }
  4872. else if (vnode.type === TEXT)
  4873. { vnode.el = withEl || createTextNode(vnode.body); }
  4874. else if (vnode.type === COMMENT)
  4875. { vnode.el = withEl || createComment(vnode.body); }
  4876. }
  4877. vnode.el._node = vnode;
  4878. return vnode.el;
  4879. }
  4880. // prevent GCC from inlining some large funcs (which negatively affects Chrome's JIT)
  4881. //window.syncChildren = syncChildren;
  4882. window.lisMove = lisMove;
  4883. function nextNode(node, body) {
  4884. return body[node.idx + 1];
  4885. }
  4886. function prevNode(node, body) {
  4887. return body[node.idx - 1];
  4888. }
  4889. function parentNode(node) {
  4890. return node.parent;
  4891. }
  4892. var BREAK = 1;
  4893. var BREAK_ALL = 2;
  4894. function syncDir(advSib, advNode, insert, sibName, nodeName, invSibName, invNodeName, invInsert) {
  4895. return function(node, parEl, body, state, convTest, lis) {
  4896. var sibNode, tmpSib;
  4897. if (state[sibName] != null) {
  4898. // skip dom elements not created by domvm
  4899. if ((sibNode = state[sibName]._node) == null) {
  4900. state[sibName] = advSib(state[sibName]);
  4901. return;
  4902. }
  4903. if (parentNode(sibNode) !== node) {
  4904. tmpSib = advSib(state[sibName]);
  4905. sibNode.vm != null ? sibNode.vm.unmount(true) : removeChild(parEl, state[sibName]);
  4906. state[sibName] = tmpSib;
  4907. return;
  4908. }
  4909. }
  4910. if (state[nodeName] == convTest)
  4911. { return BREAK_ALL; }
  4912. else if (state[nodeName].el == null) {
  4913. insert(parEl, hydrate(state[nodeName]), state[sibName]); // should lis be updated here?
  4914. state[nodeName] = advNode(state[nodeName], body); // also need to advance sib?
  4915. }
  4916. else if (state[nodeName].el === state[sibName]) {
  4917. state[nodeName] = advNode(state[nodeName], body);
  4918. state[sibName] = advSib(state[sibName]);
  4919. }
  4920. // head->tail or tail->head
  4921. else if (!lis && sibNode === state[invNodeName]) {
  4922. tmpSib = state[sibName];
  4923. state[sibName] = advSib(tmpSib);
  4924. invInsert(parEl, tmpSib, state[invSibName]);
  4925. state[invSibName] = tmpSib;
  4926. }
  4927. else {
  4928. if (lis && state[sibName] != null)
  4929. { return lisMove(advSib, advNode, insert, sibName, nodeName, parEl, body, sibNode, state); }
  4930. return BREAK;
  4931. }
  4932. };
  4933. }
  4934. function lisMove(advSib, advNode, insert, sibName, nodeName, parEl, body, sibNode, state) {
  4935. if (sibNode._lis) {
  4936. insert(parEl, state[nodeName].el, state[sibName]);
  4937. state[nodeName] = advNode(state[nodeName], body);
  4938. }
  4939. else {
  4940. // find closest tomb
  4941. var t = binaryFindLarger(sibNode.idx, state.tombs);
  4942. sibNode._lis = true;
  4943. var tmpSib = advSib(state[sibName]);
  4944. insert(parEl, state[sibName], t != null ? body[state.tombs[t]].el : t);
  4945. if (t == null)
  4946. { state.tombs.push(sibNode.idx); }
  4947. else
  4948. { state.tombs.splice(t, 0, sibNode.idx); }
  4949. state[sibName] = tmpSib;
  4950. }
  4951. }
  4952. var syncLft = syncDir(nextSib, nextNode, insertBefore, "lftSib", "lftNode", "rgtSib", "rgtNode", insertAfter);
  4953. var syncRgt = syncDir(prevSib, prevNode, insertAfter, "rgtSib", "rgtNode", "lftSib", "lftNode", insertBefore);
  4954. function syncChildren(node, donor) {
  4955. var obody = donor.body,
  4956. parEl = node.el,
  4957. body = node.body,
  4958. state = {
  4959. lftNode: body[0],
  4960. rgtNode: body[body.length - 1],
  4961. lftSib: ((obody)[0] || emptyObj).el,
  4962. rgtSib: (obody[obody.length - 1] || emptyObj).el,
  4963. };
  4964. converge:
  4965. while (1) {
  4966. // from_left:
  4967. while (1) {
  4968. var l = syncLft(node, parEl, body, state, null, false);
  4969. if (l === BREAK) { break; }
  4970. if (l === BREAK_ALL) { break converge; }
  4971. }
  4972. // from_right:
  4973. while (1) {
  4974. var r = syncRgt(node, parEl, body, state, state.lftNode, false);
  4975. if (r === BREAK) { break; }
  4976. if (r === BREAK_ALL) { break converge; }
  4977. }
  4978. sortDOM(node, parEl, body, state);
  4979. break;
  4980. }
  4981. }
  4982. // TODO: also use the state.rgtSib and state.rgtNode bounds, plus reduce LIS range
  4983. function sortDOM(node, parEl, body, state) {
  4984. var kids = Array.prototype.slice.call(parEl.childNodes);
  4985. var domIdxs = [];
  4986. for (var k = 0; k < kids.length; k++) {
  4987. var n = kids[k]._node;
  4988. if (n.parent === node)
  4989. { domIdxs.push(n.idx); }
  4990. }
  4991. // list of non-movable vnode indices (already in correct order in old dom)
  4992. var tombs = longestIncreasingSubsequence(domIdxs).map(function (i) { return domIdxs[i]; });
  4993. for (var i = 0; i < tombs.length; i++)
  4994. { body[tombs[i]]._lis = true; }
  4995. state.tombs = tombs;
  4996. while (1) {
  4997. var r = syncLft(node, parEl, body, state, null, true);
  4998. if (r === BREAK_ALL) { break; }
  4999. }
  5000. }
  5001. function alreadyAdopted(vnode) {
  5002. return vnode.el._node.parent !== vnode.parent;
  5003. }
  5004. function takeSeqIndex(n, obody, fromIdx) {
  5005. return obody[fromIdx];
  5006. }
  5007. function findSeqThorough(n, obody, fromIdx) { // pre-tested isView?
  5008. for (; fromIdx < obody.length; fromIdx++) {
  5009. var o = obody[fromIdx];
  5010. if (o.vm != null) {
  5011. // match by key & viewFn || vm
  5012. if (n.type === VVIEW && o.vm.view === n.view && o.vm.key === n.key || n.type === VMODEL && o.vm === n.vm)
  5013. { return o; }
  5014. }
  5015. else if (!alreadyAdopted(o) && n.tag === o.tag && n.type === o.type && n.key === o.key && (n.flags & ~DEEP_REMOVE) === (o.flags & ~DEEP_REMOVE))
  5016. { return o; }
  5017. }
  5018. return null;
  5019. }
  5020. function findHashKeyed(n, obody, fromIdx) {
  5021. return obody[obody._keys[n.key]];
  5022. }
  5023. /*
  5024. // list must be a sorted list of vnodes by key
  5025. function findBinKeyed(n, list) {
  5026. var idx = binaryKeySearch(list, n.key);
  5027. return idx > -1 ? list[idx] : null;
  5028. }
  5029. */
  5030. // have it handle initial hydrate? !donor?
  5031. // types (and tags if ELEM) are assumed the same, and donor exists
  5032. function patch(vnode, donor) {
  5033. fireHook(donor.hooks, "willRecycle", donor, vnode);
  5034. var el = vnode.el = donor.el;
  5035. var obody = donor.body;
  5036. var nbody = vnode.body;
  5037. el._node = vnode;
  5038. // "" => ""
  5039. if (vnode.type === TEXT && nbody !== obody) {
  5040. el.nodeValue = nbody;
  5041. return;
  5042. }
  5043. if (vnode.attrs != null || donor.attrs != null)
  5044. { patchAttrs(vnode, donor, false); }
  5045. // patch events
  5046. var oldIsArr = isArr(obody);
  5047. var newIsArr = isArr(nbody);
  5048. var lazyList = (vnode.flags & LAZY_LIST) === LAZY_LIST;
  5049. // var nonEqNewBody = nbody != null && nbody !== obody;
  5050. if (oldIsArr) {
  5051. // [] => []
  5052. if (newIsArr || lazyList)
  5053. { patchChildren(vnode, donor); }
  5054. // [] => "" | null
  5055. else if (nbody !== obody) {
  5056. if (nbody != null)
  5057. { el.textContent = nbody; }
  5058. else
  5059. { clearChildren(donor); }
  5060. }
  5061. }
  5062. else {
  5063. // "" | null => []
  5064. if (newIsArr) {
  5065. clearChildren(donor);
  5066. hydrateBody(vnode);
  5067. }
  5068. // "" | null => "" | null
  5069. else if (nbody !== obody) {
  5070. if (el.firstChild)
  5071. { el.firstChild.nodeValue = nbody; }
  5072. else
  5073. { el.textContent = nbody; }
  5074. }
  5075. }
  5076. fireHook(donor.hooks, "didRecycle", donor, vnode);
  5077. }
  5078. // larger qtys of KEYED_LIST children will use binary search
  5079. //const SEQ_FAILS_MAX = 100;
  5080. // TODO: modify vtree matcher to work similar to dom reconciler for keyed from left -> from right -> head/tail -> binary
  5081. // fall back to binary if after failing nri - nli > SEQ_FAILS_MAX
  5082. // while-advance non-keyed fromIdx
  5083. // [] => []
  5084. function patchChildren(vnode, donor) {
  5085. var nbody = vnode.body,
  5086. nlen = nbody.length,
  5087. obody = donor.body,
  5088. olen = obody.length,
  5089. isLazy = (vnode.flags & LAZY_LIST) === LAZY_LIST,
  5090. isFixed = (vnode.flags & FIXED_BODY) === FIXED_BODY,
  5091. isKeyed = (vnode.flags & KEYED_LIST) === KEYED_LIST,
  5092. domSync = !isFixed && vnode.type === ELEMENT,
  5093. doFind = true,
  5094. find = (
  5095. isKeyed ? findHashKeyed : // keyed lists/lazyLists
  5096. isFixed || isLazy ? takeSeqIndex : // unkeyed lazyLists and FIXED_BODY
  5097. findSeqThorough // more complex stuff
  5098. );
  5099. if (isKeyed) {
  5100. var keys = {};
  5101. for (var i = 0; i < obody.length; i++)
  5102. { keys[obody[i].key] = i; }
  5103. obody._keys = keys;
  5104. }
  5105. if (domSync && nlen === 0) {
  5106. clearChildren(donor);
  5107. if (isLazy)
  5108. { vnode.body = []; } // nbody.tpl(all);
  5109. return;
  5110. }
  5111. var donor2,
  5112. node2,
  5113. foundIdx,
  5114. patched = 0,
  5115. everNonseq = false,
  5116. fromIdx = 0; // first unrecycled node (search head)
  5117. if (isLazy) {
  5118. var fnode2 = {key: null};
  5119. var nbodyNew = Array(nlen);
  5120. }
  5121. for (var i = 0; i < nlen; i++) {
  5122. if (isLazy) {
  5123. var remake = false;
  5124. var diffRes = null;
  5125. if (doFind) {
  5126. if (isKeyed)
  5127. { fnode2.key = nbody.key(i); }
  5128. donor2 = find(fnode2, obody, fromIdx);
  5129. }
  5130. if (donor2 != null) {
  5131. foundIdx = donor2.idx;
  5132. diffRes = nbody.diff(i, donor2);
  5133. // diff returns same, so cheaply adopt vnode without patching
  5134. if (diffRes === true) {
  5135. node2 = donor2;
  5136. node2.parent = vnode;
  5137. node2.idx = i;
  5138. node2._lis = false;
  5139. }
  5140. // diff returns new diffVals, so generate new vnode & patch
  5141. else
  5142. { remake = true; }
  5143. }
  5144. else
  5145. { remake = true; }
  5146. if (remake) {
  5147. node2 = nbody.tpl(i); // what if this is a VVIEW, VMODEL, injected element?
  5148. preProc(node2, vnode, i);
  5149. node2._diff = diffRes != null ? diffRes : nbody.diff(i);
  5150. if (donor2 != null)
  5151. { patch(node2, donor2); }
  5152. }
  5153. else {
  5154. // TODO: flag tmp FIXED_BODY on unchanged nodes?
  5155. // domSync = true; if any idx changes or new nodes added/removed
  5156. }
  5157. nbodyNew[i] = node2;
  5158. }
  5159. else {
  5160. var node2 = nbody[i];
  5161. var type2 = node2.type;
  5162. // ELEMENT,TEXT,COMMENT
  5163. if (type2 <= COMMENT) {
  5164. if (donor2 = doFind && find(node2, obody, fromIdx)) {
  5165. patch(node2, donor2);
  5166. foundIdx = donor2.idx;
  5167. }
  5168. }
  5169. else if (type2 === VVIEW) {
  5170. if (donor2 = doFind && find(node2, obody, fromIdx)) { // update/moveTo
  5171. foundIdx = donor2.idx;
  5172. var vm = donor2.vm._update(node2.data, vnode, i); // withDOM
  5173. }
  5174. else
  5175. { var vm = createView(node2.view, node2.data, node2.key, node2.opts)._redraw(vnode, i, false); } // createView, no dom (will be handled by sync below)
  5176. type2 = vm.node.type;
  5177. }
  5178. else if (type2 === VMODEL) {
  5179. // if the injected vm has never been rendered, this vm._update() serves as the
  5180. // initial vtree creator, but must avoid hydrating (creating .el) because syncChildren()
  5181. // which is responsible for mounting below (and optionally hydrating), tests .el presence
  5182. // to determine if hydration & mounting are needed
  5183. var withDOM = isHydrated(node2.vm);
  5184. var vm = node2.vm._update(node2.data, vnode, i, withDOM);
  5185. type2 = vm.node.type;
  5186. }
  5187. }
  5188. // found donor & during a sequential search ...at search head
  5189. if (!isKeyed && donor2 != null) {
  5190. if (foundIdx === fromIdx) {
  5191. // advance head
  5192. fromIdx++;
  5193. // if all old vnodes adopted and more exist, stop searching
  5194. if (fromIdx === olen && nlen > olen) {
  5195. // short-circuit find, allow loop just create/init rest
  5196. donor2 = null;
  5197. doFind = false;
  5198. }
  5199. }
  5200. else
  5201. { everNonseq = true; }
  5202. if (olen > 100 && everNonseq && ++patched % 10 === 0)
  5203. { while (fromIdx < olen && alreadyAdopted(obody[fromIdx]))
  5204. { fromIdx++; } }
  5205. }
  5206. }
  5207. // replace List w/ new body
  5208. if (isLazy)
  5209. { vnode.body = nbodyNew; }
  5210. domSync && syncChildren(vnode, donor);
  5211. }
  5212. // view + key serve as the vm's unique identity
  5213. function ViewModel(view, data, key, opts) {
  5214. var vm = this;
  5215. vm.view = view;
  5216. vm.data = data;
  5217. vm.key = key;
  5218. if (opts) {
  5219. vm.opts = opts;
  5220. vm.config(opts);
  5221. }
  5222. var out = isPlainObj(view) ? view : view.call(vm, vm, data, key, opts);
  5223. if (isFunc(out))
  5224. { vm.render = out; }
  5225. else {
  5226. vm.render = out.render;
  5227. vm.config(out);
  5228. }
  5229. // these must be wrapped here since they're debounced per view
  5230. vm._redrawAsync = raft(function (_) { return vm.redraw(true); });
  5231. vm._updateAsync = raft(function (newData) { return vm.update(newData, true); });
  5232. vm.init && vm.init.call(vm, vm, vm.data, vm.key, opts);
  5233. }
  5234. var ViewModelProto = ViewModel.prototype = {
  5235. constructor: ViewModel,
  5236. _diff: null, // diff cache
  5237. init: null,
  5238. view: null,
  5239. key: null,
  5240. data: null,
  5241. state: null,
  5242. api: null,
  5243. opts: null,
  5244. node: null,
  5245. hooks: null,
  5246. onevent: noop,
  5247. refs: null,
  5248. render: null,
  5249. mount: mount,
  5250. unmount: unmount,
  5251. config: function(opts) {
  5252. var t = this;
  5253. if (opts.init)
  5254. { t.init = opts.init; }
  5255. if (opts.diff)
  5256. { t.diff = opts.diff; }
  5257. if (opts.onevent)
  5258. { t.onevent = opts.onevent; }
  5259. // maybe invert assignment order?
  5260. if (opts.hooks)
  5261. { t.hooks = assignObj(t.hooks || {}, opts.hooks); }
  5262. {
  5263. if (opts.onemit)
  5264. { t.onemit = assignObj(t.onemit || {}, opts.onemit); }
  5265. }
  5266. },
  5267. parent: function() {
  5268. return getVm(this.node.parent);
  5269. },
  5270. root: function() {
  5271. var p = this.node;
  5272. while (p.parent)
  5273. { p = p.parent; }
  5274. return p.vm;
  5275. },
  5276. redraw: function(sync) {
  5277. var vm = this;
  5278. sync ? vm._redraw(null, null, isHydrated(vm)) : vm._redrawAsync();
  5279. return vm;
  5280. },
  5281. update: function(newData, sync) {
  5282. var vm = this;
  5283. sync ? vm._update(newData, null, null, isHydrated(vm)) : vm._updateAsync(newData);
  5284. return vm;
  5285. },
  5286. _update: updateSync,
  5287. _redraw: redrawSync,
  5288. _redrawAsync: null,
  5289. _updateAsync: null,
  5290. };
  5291. function mount(el, isRoot) {
  5292. var vm = this;
  5293. if (isRoot) {
  5294. clearChildren({el: el, flags: 0});
  5295. vm._redraw(null, null, false);
  5296. // if placeholder node doesnt match root tag
  5297. if (el.nodeName.toLowerCase() !== vm.node.tag) {
  5298. hydrate(vm.node);
  5299. insertBefore(el.parentNode, vm.node.el, el);
  5300. el.parentNode.removeChild(el);
  5301. }
  5302. else
  5303. { insertBefore(el.parentNode, hydrate(vm.node, el), el); }
  5304. }
  5305. else {
  5306. vm._redraw(null, null);
  5307. if (el)
  5308. { insertBefore(el, vm.node.el); }
  5309. }
  5310. if (el)
  5311. { drainDidHooks(vm); }
  5312. return vm;
  5313. }
  5314. // asSub means this was called from a sub-routine, so don't drain did* hook queue
  5315. function unmount(asSub) {
  5316. var vm = this;
  5317. var node = vm.node;
  5318. var parEl = node.el.parentNode;
  5319. // edge bug: this could also be willRemove promise-delayed; should .then() or something to make sure hooks fire in order
  5320. removeChild(parEl, node.el);
  5321. if (!asSub)
  5322. { drainDidHooks(vm); }
  5323. }
  5324. function reParent(vm, vold, newParent, newIdx) {
  5325. if (newParent != null) {
  5326. newParent.body[newIdx] = vold;
  5327. vold.idx = newIdx;
  5328. vold.parent = newParent;
  5329. vold._lis = false;
  5330. }
  5331. return vm;
  5332. }
  5333. function redrawSync(newParent, newIdx, withDOM) {
  5334. var isRedrawRoot = newParent == null;
  5335. var vm = this;
  5336. var isMounted = vm.node && vm.node.el && vm.node.el.parentNode;
  5337. var vold = vm.node, oldDiff, newDiff;
  5338. if (vm.diff != null) {
  5339. oldDiff = vm._diff;
  5340. vm._diff = newDiff = vm.diff(vm, vm.data);
  5341. if (vold != null) {
  5342. var cmpFn = isArr(oldDiff) ? cmpArr : cmpObj;
  5343. var isSame = oldDiff === newDiff || cmpFn(oldDiff, newDiff);
  5344. if (isSame)
  5345. { return reParent(vm, vold, newParent, newIdx); }
  5346. }
  5347. }
  5348. isMounted && fireHook(vm.hooks, "willRedraw", vm, vm.data);
  5349. var vnew = vm.render.call(vm, vm, vm.data, oldDiff, newDiff);
  5350. if (vnew === vold)
  5351. { return reParent(vm, vold, newParent, newIdx); }
  5352. // todo: test result of willRedraw hooks before clearing refs
  5353. vm.refs = null;
  5354. // always assign vm key to root vnode (this is a de-opt)
  5355. if (vm.key != null && vnew.key !== vm.key)
  5356. { vnew.key = vm.key; }
  5357. vm.node = vnew;
  5358. if (newParent) {
  5359. preProc(vnew, newParent, newIdx, vm);
  5360. newParent.body[newIdx] = vnew;
  5361. }
  5362. else if (vold && vold.parent) {
  5363. preProc(vnew, vold.parent, vold.idx, vm);
  5364. vold.parent.body[vold.idx] = vnew;
  5365. }
  5366. else
  5367. { preProc(vnew, null, null, vm); }
  5368. if (withDOM !== false) {
  5369. if (vold) {
  5370. // root node replacement
  5371. if (vold.tag !== vnew.tag || vold.key !== vnew.key) {
  5372. // hack to prevent the replacement from triggering mount/unmount
  5373. vold.vm = vnew.vm = null;
  5374. var parEl = vold.el.parentNode;
  5375. var refEl = nextSib(vold.el);
  5376. removeChild(parEl, vold.el);
  5377. insertBefore(parEl, hydrate(vnew), refEl);
  5378. // another hack that allows any higher-level syncChildren to set
  5379. // reconciliation bounds using a live node
  5380. vold.el = vnew.el;
  5381. // restore
  5382. vnew.vm = vm;
  5383. }
  5384. else
  5385. { patch(vnew, vold); }
  5386. }
  5387. else
  5388. { hydrate(vnew); }
  5389. }
  5390. isMounted && fireHook(vm.hooks, "didRedraw", vm, vm.data);
  5391. if (isRedrawRoot && isMounted)
  5392. { drainDidHooks(vm); }
  5393. return vm;
  5394. }
  5395. // this also doubles as moveTo
  5396. // TODO? @withRedraw (prevent redraw from firing)
  5397. function updateSync(newData, newParent, newIdx, withDOM) {
  5398. var vm = this;
  5399. if (newData != null) {
  5400. if (vm.data !== newData) {
  5401. fireHook(vm.hooks, "willUpdate", vm, newData);
  5402. vm.data = newData;
  5403. }
  5404. }
  5405. return vm._redraw(newParent, newIdx, withDOM);
  5406. }
  5407. function defineElement(tag, arg1, arg2, flags) {
  5408. var attrs, body;
  5409. if (arg2 == null) {
  5410. if (isPlainObj(arg1))
  5411. { attrs = arg1; }
  5412. else
  5413. { body = arg1; }
  5414. }
  5415. else {
  5416. attrs = arg1;
  5417. body = arg2;
  5418. }
  5419. return initElementNode(tag, attrs, body, flags);
  5420. }
  5421. //export const XML_NS = "http://www.w3.org/2000/xmlns/";
  5422. var SVG_NS = "http://www.w3.org/2000/svg";
  5423. function defineSvgElement(tag, arg1, arg2, flags) {
  5424. var n = defineElement(tag, arg1, arg2, flags);
  5425. n.ns = SVG_NS;
  5426. return n;
  5427. }
  5428. function defineComment(body) {
  5429. var node = new VNode;
  5430. node.type = COMMENT;
  5431. node.body = body;
  5432. return node;
  5433. }
  5434. // placeholder for declared views
  5435. function VView(view, data, key, opts) {
  5436. this.view = view;
  5437. this.data = data;
  5438. this.key = key;
  5439. this.opts = opts;
  5440. }
  5441. VView.prototype = {
  5442. constructor: VView,
  5443. type: VVIEW,
  5444. view: null,
  5445. data: null,
  5446. key: null,
  5447. opts: null,
  5448. };
  5449. function defineView(view, data, key, opts) {
  5450. return new VView(view, data, key, opts);
  5451. }
  5452. // placeholder for injected ViewModels
  5453. function VModel(vm) {
  5454. this.vm = vm;
  5455. }
  5456. VModel.prototype = {
  5457. constructor: VModel,
  5458. type: VMODEL,
  5459. vm: null,
  5460. };
  5461. function injectView(vm) {
  5462. // if (vm.node == null)
  5463. // vm._redraw(null, null, false);
  5464. // return vm.node;
  5465. return new VModel(vm);
  5466. }
  5467. function injectElement(el) {
  5468. var node = new VNode;
  5469. node.type = ELEMENT;
  5470. node.el = node.key = el;
  5471. return node;
  5472. }
  5473. function lazyList(items, cfg) {
  5474. var len = items.length;
  5475. var self = {
  5476. items: items,
  5477. length: len,
  5478. // defaults to returning item identity (or position?)
  5479. key: function(i) {
  5480. return cfg.key(items[i], i);
  5481. },
  5482. // default returns 0?
  5483. diff: function(i, donor) {
  5484. var newVals = cfg.diff(items[i], i);
  5485. if (donor == null)
  5486. { return newVals; }
  5487. var oldVals = donor._diff;
  5488. var same = newVals === oldVals || isArr(oldVals) ? cmpArr(newVals, oldVals) : cmpObj(newVals, oldVals);
  5489. return same || newVals;
  5490. },
  5491. tpl: function(i) {
  5492. return cfg.tpl(items[i], i);
  5493. },
  5494. map: function(tpl) {
  5495. cfg.tpl = tpl;
  5496. return self;
  5497. },
  5498. body: function(vnode) {
  5499. var nbody = Array(len);
  5500. for (var i = 0; i < len; i++) {
  5501. var vnode2 = self.tpl(i);
  5502. // if ((vnode.flags & KEYED_LIST) === KEYED_LIST && self. != null)
  5503. // vnode2.key = getKey(item);
  5504. vnode2._diff = self.diff(i); // holds oldVals for cmp
  5505. nbody[i] = vnode2;
  5506. // run preproc pass (should this be just preProc in above loop?) bench
  5507. preProc(vnode2, vnode, i);
  5508. }
  5509. // replace List with generated body
  5510. vnode.body = nbody;
  5511. }
  5512. };
  5513. return self;
  5514. }
  5515. var nano = {
  5516. config: config,
  5517. ViewModel: ViewModel,
  5518. VNode: VNode,
  5519. createView: createView,
  5520. defineElement: defineElement,
  5521. defineSvgElement: defineSvgElement,
  5522. defineText: defineText,
  5523. defineComment: defineComment,
  5524. defineView: defineView,
  5525. injectView: injectView,
  5526. injectElement: injectElement,
  5527. lazyList: lazyList,
  5528. FIXED_BODY: FIXED_BODY,
  5529. DEEP_REMOVE: DEEP_REMOVE,
  5530. KEYED_LIST: KEYED_LIST,
  5531. LAZY_LIST: LAZY_LIST,
  5532. };
  5533. function protoPatch(n, doRepaint) {
  5534. patch$1(this, n, doRepaint);
  5535. }
  5536. // newNode can be either {class: style: } or full new VNode
  5537. // will/didPatch hooks?
  5538. function patch$1(o, n, doRepaint) {
  5539. if (n.type != null) {
  5540. // no full patching of view roots, just use redraw!
  5541. if (o.vm != null)
  5542. { return; }
  5543. preProc(n, o.parent, o.idx, null);
  5544. o.parent.body[o.idx] = n;
  5545. patch(n, o);
  5546. doRepaint && repaint(n);
  5547. drainDidHooks(getVm(n));
  5548. }
  5549. else {
  5550. // TODO: re-establish refs
  5551. // shallow-clone target
  5552. var donor = Object.create(o);
  5553. // fixate orig attrs
  5554. donor.attrs = assignObj({}, o.attrs);
  5555. // assign new attrs into live targ node
  5556. var oattrs = assignObj(o.attrs, n);
  5557. // prepend any fixed shorthand class
  5558. if (o._class != null) {
  5559. var aclass = oattrs.class;
  5560. oattrs.class = aclass != null && aclass !== "" ? o._class + " " + aclass : o._class;
  5561. }
  5562. patchAttrs(o, donor);
  5563. doRepaint && repaint(o);
  5564. }
  5565. }
  5566. VNodeProto.patch = protoPatch;
  5567. function nextSubVms(n, accum) {
  5568. var body = n.body;
  5569. if (isArr(body)) {
  5570. for (var i = 0; i < body.length; i++) {
  5571. var n2 = body[i];
  5572. if (n2.vm != null)
  5573. { accum.push(n2.vm); }
  5574. else
  5575. { nextSubVms(n2, accum); }
  5576. }
  5577. }
  5578. return accum;
  5579. }
  5580. function defineElementSpread(tag) {
  5581. var args = arguments;
  5582. var len = args.length;
  5583. var body, attrs;
  5584. if (len > 1) {
  5585. var bodyIdx = 1;
  5586. if (isPlainObj(args[1])) {
  5587. attrs = args[1];
  5588. bodyIdx = 2;
  5589. }
  5590. if (len === bodyIdx + 1 && (isVal(args[bodyIdx]) || isArr(args[bodyIdx]) || attrs && (attrs._flags & LAZY_LIST) === LAZY_LIST))
  5591. { body = args[bodyIdx]; }
  5592. else
  5593. { body = sliceArgs(args, bodyIdx); }
  5594. }
  5595. return initElementNode(tag, attrs, body);
  5596. }
  5597. function defineSvgElementSpread() {
  5598. var n = defineElementSpread.apply(null, arguments);
  5599. n.ns = SVG_NS;
  5600. return n;
  5601. }
  5602. ViewModelProto.emit = emit;
  5603. ViewModelProto.onemit = null;
  5604. ViewModelProto.body = function() {
  5605. return nextSubVms(this.node, []);
  5606. };
  5607. nano.defineElementSpread = defineElementSpread;
  5608. nano.defineSvgElementSpread = defineSvgElementSpread;
  5609. return nano;
  5610. })));
  5611. //# sourceMappingURL=domvm.micro.js.map
  5612. /***/ }),
  5613. /* 40 */
  5614. /***/ (function(module, exports) {
  5615. if (Element && !Element.prototype.matches) {
  5616. var proto = Element.prototype;
  5617. proto.matches = proto.matchesSelector ||
  5618. proto.mozMatchesSelector || proto.msMatchesSelector ||
  5619. proto.oMatchesSelector || proto.webkitMatchesSelector;
  5620. }
  5621. /***/ }),
  5622. /* 41 */
  5623. /***/ (function(module, exports, __webpack_require__) {
  5624. "use strict";
  5625. function __export(m) {
  5626. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  5627. }
  5628. Object.defineProperty(exports, "__esModule", { value: true });
  5629. __export(__webpack_require__(42));
  5630. /***/ }),
  5631. /* 42 */
  5632. /***/ (function(module, exports, __webpack_require__) {
  5633. "use strict";
  5634. var __extends = (this && this.__extends) || (function () {
  5635. var extendStatics = Object.setPrototypeOf ||
  5636. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5637. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5638. return function (d, b) {
  5639. extendStatics(d, b);
  5640. function __() { this.constructor = d; }
  5641. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5642. };
  5643. })();
  5644. Object.defineProperty(exports, "__esModule", { value: true });
  5645. var Cell_1 = __webpack_require__(43);
  5646. var dom_1 = __webpack_require__(0);
  5647. var Layout = /** @class */ (function (_super) {
  5648. __extends(Layout, _super);
  5649. function Layout(parent, config) {
  5650. var _this = _super.call(this, parent, config) || this;
  5651. // root layout
  5652. _this._root = _this.config.parent || _this;
  5653. _this._all = {};
  5654. _this._parseConfig();
  5655. if (_this.config.views) {
  5656. _this.config.activeView = _this.config.activeView || _this._cells[0].id;
  5657. _this._isViewLayout = true;
  5658. }
  5659. if (!config.parent) {
  5660. var view = dom_1.create({ render: function () { return _this.toVDOM(); } }, _this);
  5661. _this.mount(parent, view);
  5662. }
  5663. return _this;
  5664. }
  5665. Layout.prototype.cell = function (id) {
  5666. // FIXME
  5667. return this._root._all[id];
  5668. };
  5669. Layout.prototype.toVDOM = function () {
  5670. if (this._isViewLayout) {
  5671. var roots = [this.cell(this.config.activeView).toVDOM()];
  5672. return _super.prototype.toVDOM.call(this, roots);
  5673. }
  5674. var nodes = [];
  5675. this._cells.forEach(function (cell) {
  5676. var node = cell.toVDOM();
  5677. if (Array.isArray(node)) {
  5678. nodes = nodes.concat(node);
  5679. }
  5680. else {
  5681. nodes.push(node);
  5682. }
  5683. });
  5684. return _super.prototype.toVDOM.call(this, nodes);
  5685. };
  5686. Layout.prototype.removeCell = function (id) {
  5687. var root = (this.config.parent || this);
  5688. if (root !== this) {
  5689. return root.removeCell(id);
  5690. }
  5691. // this === root layout
  5692. var view = this.cell(id);
  5693. if (view) {
  5694. var parent_1 = view.getParent();
  5695. delete this._all[id];
  5696. parent_1._cells = parent_1._cells.filter(function (cell) { return cell.id !== id; });
  5697. parent_1.paint();
  5698. }
  5699. };
  5700. Layout.prototype.addCell = function (config, index) {
  5701. if (index === void 0) { index = -1; }
  5702. var view = this._createCell(config);
  5703. if (index < 0) {
  5704. index = this._cells.length + index + 1;
  5705. }
  5706. this._cells.splice(index, 0, view);
  5707. this.paint();
  5708. };
  5709. Layout.prototype.getId = function (index) {
  5710. if (index < 0) {
  5711. index = this._cells.length + index;
  5712. }
  5713. return this._cells[index] ? this._cells[index].id : undefined;
  5714. };
  5715. Layout.prototype.getRefs = function (name) {
  5716. return this._root.getRootView().refs[name];
  5717. };
  5718. Layout.prototype._getCss = function (content) {
  5719. if (content) {
  5720. return (this._xLayout ? " dhx_layout-columns" : " dhx_layout-rows");
  5721. }
  5722. else {
  5723. return (this.config.parent ? _super.prototype._getCss.call(this) : "dhx_widget dhx_layout") +
  5724. (this.config.full
  5725. ? (!this.config.parent
  5726. ? " dhx_layout-cell"
  5727. : "")
  5728. : (this._xLayout ? " dhx_layout-columns" : " dhx_layout-rows"));
  5729. }
  5730. };
  5731. Layout.prototype._parseConfig = function () {
  5732. var _this = this;
  5733. var config = this.config;
  5734. var cells = config.rows || config.cols || config.views;
  5735. this._xLayout = !config.rows;
  5736. this._cells = cells.map(function (a) { return _this._createCell(a); });
  5737. };
  5738. Layout.prototype._createCell = function (cell) {
  5739. var view;
  5740. if (cell.rows || cell.cols || cell.views) {
  5741. cell.parent = this._root;
  5742. view = new Layout(this, cell);
  5743. }
  5744. else {
  5745. view = new Cell_1.Cell(this, cell);
  5746. }
  5747. // FIxME
  5748. this._root._all[view.id] = view;
  5749. return view;
  5750. };
  5751. return Layout;
  5752. }(Cell_1.Cell));
  5753. exports.Layout = Layout;
  5754. /***/ }),
  5755. /* 43 */
  5756. /***/ (function(module, exports, __webpack_require__) {
  5757. "use strict";
  5758. var __extends = (this && this.__extends) || (function () {
  5759. var extendStatics = Object.setPrototypeOf ||
  5760. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5761. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5762. return function (d, b) {
  5763. extendStatics(d, b);
  5764. function __() { this.constructor = d; }
  5765. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5766. };
  5767. })();
  5768. var __assign = (this && this.__assign) || Object.assign || function(t) {
  5769. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5770. s = arguments[i];
  5771. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  5772. t[p] = s[p];
  5773. }
  5774. return t;
  5775. };
  5776. Object.defineProperty(exports, "__esModule", { value: true });
  5777. var core_1 = __webpack_require__(3);
  5778. var dom_1 = __webpack_require__(0);
  5779. var view_1 = __webpack_require__(8);
  5780. var resizeMode;
  5781. (function (resizeMode) {
  5782. resizeMode[resizeMode["unknown"] = 0] = "unknown";
  5783. resizeMode[resizeMode["percents"] = 1] = "percents";
  5784. resizeMode[resizeMode["pixels"] = 2] = "pixels";
  5785. resizeMode[resizeMode["mixedpx1"] = 3] = "mixedpx1";
  5786. resizeMode[resizeMode["mixedpx2"] = 4] = "mixedpx2";
  5787. resizeMode[resizeMode["mixedperc1"] = 5] = "mixedperc1";
  5788. resizeMode[resizeMode["mixedperc2"] = 6] = "mixedperc2";
  5789. })(resizeMode || (resizeMode = {}));
  5790. function getResizeMode(dir, conf1, conf2) {
  5791. var field = dir ? "width" : "height";
  5792. var is1perc = conf1[field] && conf1[field].indexOf("%") !== -1;
  5793. var is2perc = conf2[field] && conf2[field].indexOf("%") !== -1;
  5794. var is1px = conf1[field] && conf1[field].indexOf("px") !== -1;
  5795. var is2px = conf2[field] && conf2[field].indexOf("px") !== -1;
  5796. if (is1perc && is2perc) {
  5797. return resizeMode.percents;
  5798. }
  5799. if (is1px && is2px) {
  5800. return resizeMode.pixels;
  5801. }
  5802. if (is1px && !is2px) {
  5803. return resizeMode.mixedpx1;
  5804. }
  5805. if (is2px && !is1px) {
  5806. return resizeMode.mixedpx2;
  5807. }
  5808. if (is1perc) {
  5809. return resizeMode.mixedperc1;
  5810. }
  5811. if (is2perc) {
  5812. return resizeMode.mixedperc2;
  5813. }
  5814. return resizeMode.unknown;
  5815. }
  5816. function getBlockRange(block1, block2, isXLayout) {
  5817. if (isXLayout === void 0) { isXLayout = true; }
  5818. if (isXLayout) {
  5819. return {
  5820. min: block1.left + window.pageXOffset,
  5821. max: block2.right + window.pageXOffset
  5822. };
  5823. }
  5824. return {
  5825. min: block1.top + window.pageYOffset,
  5826. max: block2.bottom + window.pageYOffset
  5827. };
  5828. }
  5829. var Cell = /** @class */ (function (_super) {
  5830. __extends(Cell, _super);
  5831. function Cell(parent, config) {
  5832. var _this = _super.call(this, parent, config) || this;
  5833. var p = parent;
  5834. if (p && p.isVisible) {
  5835. _this._parent = p;
  5836. }
  5837. _this.config.full = _this.config.full === undefined ? Boolean(_this.config.header || _this.config.footer) : _this.config.full;
  5838. _this._initHandlers();
  5839. _this.id = _this.config.id || core_1.uid();
  5840. return _this;
  5841. }
  5842. Cell.prototype.paint = function () {
  5843. if (this.isVisible()) {
  5844. var view = this.getRootView();
  5845. if (view) {
  5846. view.redraw();
  5847. }
  5848. else {
  5849. this._parent.paint();
  5850. }
  5851. }
  5852. };
  5853. Cell.prototype.isVisible = function () {
  5854. // top level node
  5855. if (!this._parent) {
  5856. if (this._container && this._container.tagName) {
  5857. return true;
  5858. }
  5859. return false;
  5860. }
  5861. // check active view in case of multiview
  5862. var active = this._parent.config.activeView;
  5863. if (active && active !== this.id) {
  5864. return false;
  5865. }
  5866. // check that all parents of the cell are visible as well
  5867. return !this.config.hidden && (!this._parent || this._parent.isVisible());
  5868. };
  5869. Cell.prototype.hide = function () {
  5870. this.config.hidden = true;
  5871. if (this._parent && this._parent.paint) {
  5872. this._parent.paint();
  5873. }
  5874. };
  5875. Cell.prototype.show = function () {
  5876. if (this._parent && this._parent.config.activeView) {
  5877. this._parent.config.activeView = this.id;
  5878. }
  5879. else {
  5880. this.config.hidden = false;
  5881. }
  5882. if (this._parent && !this._parent.isVisible()) {
  5883. this._parent.show();
  5884. }
  5885. this.paint();
  5886. };
  5887. Cell.prototype.getParent = function () {
  5888. return this._parent;
  5889. };
  5890. Cell.prototype.destructor = function () {
  5891. this.config = null;
  5892. };
  5893. Cell.prototype.getWidget = function () {
  5894. return this._ui;
  5895. };
  5896. Cell.prototype.getCellView = function () {
  5897. return this._parent && this._parent.getRefs(this._uid);
  5898. };
  5899. Cell.prototype.attach = function (name, config) {
  5900. if (typeof name === "object") {
  5901. name._container = this;
  5902. this._ui = name;
  5903. }
  5904. else if (typeof name === "string") {
  5905. this._ui = new window.dhx[name](null, config);
  5906. }
  5907. else if (typeof name === "function") {
  5908. if (name.prototype instanceof view_1.View) {
  5909. this._ui = new name(null, config);
  5910. }
  5911. else {
  5912. this._ui = {
  5913. getRootView: function () {
  5914. return name(config);
  5915. }
  5916. };
  5917. }
  5918. }
  5919. this.paint();
  5920. return this._ui;
  5921. };
  5922. Cell.prototype.toVDOM = function (nodes) {
  5923. var _a;
  5924. var conf = this.config;
  5925. if (conf.hidden) {
  5926. return;
  5927. }
  5928. var style = this._calculateStyle();
  5929. var kids;
  5930. if (this.config.html) {
  5931. kids = [dom_1.el(".dhx_inner-html-content", { ".innerHTML": this.config.html })];
  5932. }
  5933. else if (this._ui) {
  5934. var view = this._ui.getRootView();
  5935. if (view.render) {
  5936. view = dom_1.inject(view);
  5937. }
  5938. kids = [view];
  5939. }
  5940. else {
  5941. kids = nodes || null;
  5942. }
  5943. var resizer = this.config.canResize && !this._isLastCell() ?
  5944. dom_1.el(".dhx_layout-resizer." + (this._isXDirection() ? "dhx_layout-resizer--x" : "dhx_layout-resizer--y"), __assign({}, this._resizerHandlers, { _ref: "resizer_" + this._uid }), [dom_1.el("span.dhx_layout-resizer__icon", {
  5945. class: "dxi " + (this._isXDirection() ? "dxi-dots-vertical" : "dxi-dots-horizontal")
  5946. })]) : null;
  5947. var handlers = {};
  5948. if (this.config.on) {
  5949. for (var key in this.config.on) {
  5950. handlers["on" + key] = this.config.on[key];
  5951. }
  5952. }
  5953. var cell = dom_1.el("div", __assign((_a = { _key: this._uid, style: style, _ref: this._uid, id: this.config.id || this._uid }, _a["aria-labelledby"] = this.config.id ? "tab-content-" + this.config.id : null, _a), handlers, { class: "" + this._getCss(false) + (this.config.css ? " " + this.config.css : "") }), this.config.full ? [
  5954. this.config.header ? dom_1.el("div", {
  5955. class: "dhx_layout-cell-header" +
  5956. ("" + (this.config.collapsed ? " dhx_layout-cell-header--collapsed" : "")) +
  5957. ("" + (this.config.canCollapse ? " dhx_layout-cell-header--collapseble" : "")),
  5958. onclick: this._handlers.collapse
  5959. }, [
  5960. this.config.headerIcon && dom_1.el("span.dhx_layout-cell-header__icon.dxi." + this.config.headerIcon),
  5961. dom_1.el(".dhx_layout-cell-header__title", this.config.header),
  5962. this.config.canCollapse ? dom_1.el("div.dhx_layout-cell-header__collapse-icon", {
  5963. "tabindex": "0",
  5964. "role": "button",
  5965. "aria-label": "collapse",
  5966. "class": "dxi dxi-chevron-down"
  5967. }) : null,
  5968. ]) : null,
  5969. !this.config.collapsed ? dom_1.el("div", {
  5970. class: "dhx_layout-cell--content" + this._getCss(true),
  5971. }, kids) : null,
  5972. ] : kids);
  5973. return resizer ? [
  5974. cell,
  5975. resizer
  5976. ] : cell;
  5977. };
  5978. Cell.prototype._getCss = function (content) {
  5979. return "dhx_layout-cell ";
  5980. };
  5981. Cell.prototype._initHandlers = function () {
  5982. var _this = this;
  5983. var blockOpts = {
  5984. left: null,
  5985. top: null,
  5986. isActive: false,
  5987. range: null,
  5988. xLayout: null,
  5989. nextCell: null,
  5990. size: null,
  5991. resizerLength: null,
  5992. mode: null,
  5993. percentsum: null
  5994. };
  5995. var mouseUp = function () {
  5996. blockOpts.isActive = false;
  5997. document.body.classList.remove("dhx_no-select");
  5998. document.removeEventListener("mouseup", mouseUp);
  5999. document.removeEventListener("mousemove", mouseMove);
  6000. };
  6001. var mouseMove = function (e) {
  6002. if (!blockOpts.isActive || blockOpts.mode === resizeMode.unknown) {
  6003. return;
  6004. }
  6005. var newValue = blockOpts.xLayout ? e.x - blockOpts.range.min - window.pageXOffset :
  6006. e.y - blockOpts.range.min - window.pageYOffset;
  6007. var prop = blockOpts.xLayout ? "width" : "height";
  6008. if (newValue < 0) {
  6009. newValue = blockOpts.resizerLength / 2;
  6010. }
  6011. else if (newValue > blockOpts.size) {
  6012. newValue = blockOpts.size - blockOpts.resizerLength;
  6013. }
  6014. switch (blockOpts.mode) {
  6015. case resizeMode.pixels:
  6016. _this.config[prop] = newValue - blockOpts.resizerLength / 2 + "px";
  6017. blockOpts.nextCell.config[prop] = blockOpts.size - newValue - blockOpts.resizerLength / 2 + "px";
  6018. break;
  6019. case resizeMode.mixedpx1:
  6020. _this.config[prop] = newValue - blockOpts.resizerLength / 2 + "px";
  6021. break;
  6022. case resizeMode.mixedpx2:
  6023. blockOpts.nextCell.config[prop] = blockOpts.size - newValue - blockOpts.resizerLength / 2 + "px";
  6024. break;
  6025. case resizeMode.percents:
  6026. _this.config[prop] = newValue / blockOpts.size * blockOpts.percentsum + "%";
  6027. blockOpts.nextCell.config[prop] = (blockOpts.size - newValue) / blockOpts.size * blockOpts.percentsum + "%";
  6028. break;
  6029. case resizeMode.mixedperc1:
  6030. _this.config[prop] = newValue / blockOpts.size * blockOpts.percentsum + "%";
  6031. break;
  6032. case resizeMode.mixedperc2:
  6033. blockOpts.nextCell.config[prop] = (blockOpts.size - newValue) / blockOpts.size * blockOpts.percentsum + "%";
  6034. break;
  6035. }
  6036. _this.paint();
  6037. };
  6038. this._handlers = {
  6039. collapse: function () {
  6040. if (!_this.config.canCollapse) {
  6041. return;
  6042. }
  6043. _this.config.collapsed = !_this.config.collapsed;
  6044. _this.paint();
  6045. }
  6046. };
  6047. this._resizerHandlers = {
  6048. onmousedown: function (e) {
  6049. if (e.which === 3) {
  6050. return;
  6051. }
  6052. if (blockOpts.isActive) {
  6053. mouseUp();
  6054. }
  6055. document.body.classList.add("dhx_no-select");
  6056. var block = _this.getCellView();
  6057. var nextCell = _this._getNextCell();
  6058. var nextBlock = nextCell.getCellView();
  6059. var resizerBlock = _this._getResizerView();
  6060. var blockOffsets = block.el.getBoundingClientRect();
  6061. var resizerOffsets = resizerBlock.el.getBoundingClientRect();
  6062. var nextBlockOffsets = nextBlock.el.getBoundingClientRect();
  6063. blockOpts.xLayout = _this._isXDirection();
  6064. blockOpts.left = blockOffsets.left + window.pageXOffset;
  6065. blockOpts.top = blockOffsets.top + window.pageYOffset;
  6066. blockOpts.range = getBlockRange(blockOffsets, nextBlockOffsets, blockOpts.xLayout);
  6067. blockOpts.size = blockOpts.range.max - blockOpts.range.min;
  6068. blockOpts.isActive = true;
  6069. blockOpts.nextCell = nextCell;
  6070. blockOpts.resizerLength = blockOpts.xLayout ? resizerOffsets.width : resizerOffsets.height;
  6071. blockOpts.mode = getResizeMode(blockOpts.xLayout, _this.config, nextCell.config);
  6072. if (blockOpts.mode === resizeMode.percents) {
  6073. var field = blockOpts.xLayout ? "width" : "height";
  6074. blockOpts.percentsum = parseFloat(_this.config[field]) + parseFloat(nextCell.config[field]);
  6075. }
  6076. if (blockOpts.mode === resizeMode.mixedperc1) {
  6077. var field = blockOpts.xLayout ? "width" : "height";
  6078. blockOpts.percentsum = 1 / (blockOffsets[field] / (blockOpts.size - blockOpts.resizerLength)) * parseFloat(_this.config[field]);
  6079. }
  6080. if (blockOpts.mode === resizeMode.mixedperc2) {
  6081. var field = blockOpts.xLayout ? "width" : "height";
  6082. blockOpts.percentsum = 1 / (nextBlockOffsets[field] / (blockOpts.size - blockOpts.resizerLength)) * parseFloat(nextCell.config[field]);
  6083. }
  6084. document.addEventListener("mouseup", mouseUp);
  6085. document.addEventListener("mousemove", mouseMove);
  6086. },
  6087. ondragstart: function (e) { return e.preventDefault(); }
  6088. };
  6089. };
  6090. Cell.prototype._isLastCell = function () {
  6091. var parent = this._parent;
  6092. return parent && parent._cells.indexOf(this) === parent._cells.length - 1;
  6093. };
  6094. Cell.prototype._getNextCell = function () {
  6095. var parent = this._parent;
  6096. var index = parent._cells.indexOf(this);
  6097. return parent._cells[index + 1];
  6098. };
  6099. Cell.prototype._getResizerView = function () {
  6100. return this._parent.getRefs("resizer_" + this._uid);
  6101. };
  6102. Cell.prototype._isXDirection = function () {
  6103. return this._parent && this._parent._xLayout;
  6104. };
  6105. Cell.prototype._calculateStyle = function () {
  6106. var conf = this.config;
  6107. var style = {};
  6108. if (this._isXDirection()) {
  6109. if (this.config.width !== undefined) {
  6110. style.flexBasis = conf.width;
  6111. }
  6112. if (conf.height !== undefined) {
  6113. style.height = conf.height;
  6114. }
  6115. }
  6116. else {
  6117. if (this.config.height !== undefined) {
  6118. style.flexBasis = conf.height;
  6119. }
  6120. if (conf.width !== undefined) {
  6121. style.width = conf.width;
  6122. }
  6123. }
  6124. return style;
  6125. };
  6126. return Cell;
  6127. }(view_1.View));
  6128. exports.Cell = Cell;
  6129. /***/ }),
  6130. /* 44 */
  6131. /***/ (function(module, exports, __webpack_require__) {
  6132. "use strict";
  6133. var __extends = (this && this.__extends) || (function () {
  6134. var extendStatics = Object.setPrototypeOf ||
  6135. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6136. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6137. return function (d, b) {
  6138. extendStatics(d, b);
  6139. function __() { this.constructor = d; }
  6140. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6141. };
  6142. })();
  6143. Object.defineProperty(exports, "__esModule", { value: true });
  6144. var core_1 = __webpack_require__(3);
  6145. var dom_1 = __webpack_require__(0);
  6146. var html_1 = __webpack_require__(1);
  6147. var ts_menu_1 = __webpack_require__(22);
  6148. var ts_message_1 = __webpack_require__(28);
  6149. function addInGroups(groups, item) {
  6150. if (groups[item.group]) {
  6151. if (item.active) {
  6152. groups[item.group].active = item.id;
  6153. }
  6154. groups[item.group].elements.push(item.id);
  6155. }
  6156. else {
  6157. groups[item.group] = {
  6158. active: item.active ? item.id : null,
  6159. elements: [item.id]
  6160. };
  6161. }
  6162. }
  6163. var Toolbar = /** @class */ (function (_super) {
  6164. __extends(Toolbar, _super);
  6165. function Toolbar(element, config) {
  6166. var _this = _super.call(this, element, core_1.extend({
  6167. navigationType: "click"
  6168. }, config)) || this;
  6169. _this._listeners = {
  6170. input: function (e) {
  6171. var id = html_1.locate(e);
  6172. _this.data.update(id, { value: e.target.value });
  6173. },
  6174. tooltip: function (e) {
  6175. var elem = html_1.locateNode(e);
  6176. if (!elem) {
  6177. return;
  6178. }
  6179. var id = elem.getAttribute("dhx_id");
  6180. var item = _this.data.getItem(id);
  6181. if (item.tooltip) {
  6182. ts_message_1.tooltip(item.tooltip, {
  6183. node: elem,
  6184. position: ts_message_1.Position.bottom
  6185. });
  6186. }
  6187. }
  6188. };
  6189. _this._currentRoot = null;
  6190. _this._factory = ts_menu_1.createFactory(ts_menu_1.ItemType.button);
  6191. var render = function () { return _this._draw(); };
  6192. _this.mount(element, dom_1.create({ render: render }));
  6193. return _this;
  6194. }
  6195. Toolbar.prototype.getValues = function () {
  6196. var state = {};
  6197. this.data.eachChild(this.data.getRoot(), function (item) {
  6198. if (item.twoState) {
  6199. state[item.id] = item.active;
  6200. }
  6201. else if (item.type === ts_menu_1.ItemType.input) {
  6202. state[item.id] = item.value;
  6203. }
  6204. }, false);
  6205. for (var key in this._groups) {
  6206. if (this._groups[key].active) {
  6207. state[key] = this._groups[key].active;
  6208. }
  6209. }
  6210. return state;
  6211. };
  6212. Toolbar.prototype.setValues = function (state) {
  6213. for (var key in state) {
  6214. if (this._groups[key]) {
  6215. if (this._groups[key].active) {
  6216. this.data.update(this._groups[key].active, { active: false });
  6217. this._groups[key].active = state[key];
  6218. this.data.update(state[key], { active: true });
  6219. }
  6220. }
  6221. else {
  6222. var item = this.data.getItem(key);
  6223. if (item.type === ts_menu_1.ItemType.input) {
  6224. this.data.update(key, { value: state[key] });
  6225. }
  6226. else {
  6227. this.data.update(key, { active: state[key] });
  6228. }
  6229. }
  6230. }
  6231. };
  6232. Toolbar.prototype._draw = function () {
  6233. var _this = this;
  6234. return dom_1.el("nav.dhx_toolbar.dhx_widget" + (this.config.css ? "." + this.config.css : ""), [
  6235. dom_1.el("ul.dhx_toolbar__list", {
  6236. dhx_widget_id: this._uid,
  6237. tabindex: 0,
  6238. onclick: this._handlers.onclick,
  6239. onmousedown: this._handlers.onmousedown,
  6240. oninput: this._listeners.input,
  6241. onmouseover: this._listeners.tooltip,
  6242. _hooks: {
  6243. didInsert: function (node) {
  6244. node.el.addEventListener("keyup", function (e) {
  6245. if (e.which !== 9) {
  6246. return;
  6247. }
  6248. var elem = html_1.locateNode(document.activeElement);
  6249. if (!elem) {
  6250. return;
  6251. }
  6252. var id = elem.getAttribute("dhx_id");
  6253. var item = _this.data.getItem(id);
  6254. if (item.tooltip) {
  6255. ts_message_1.tooltip(item.tooltip, {
  6256. node: elem,
  6257. position: ts_message_1.Position.bottom,
  6258. force: true
  6259. });
  6260. }
  6261. }, true);
  6262. }
  6263. }
  6264. }, this.data.map(function (item) { return _this._factory(item, _this.events); }, this.data.getRoot(), false))
  6265. ]);
  6266. };
  6267. Toolbar.prototype._getMode = function (item, root) {
  6268. return item.id === root ? "bottom" : "right";
  6269. };
  6270. Toolbar.prototype._close = function () {
  6271. this._activePosition = null;
  6272. this._currentRoot = null;
  6273. _super.prototype._close.call(this);
  6274. };
  6275. Toolbar.prototype._normalizeData = function () {
  6276. var _this = this;
  6277. var root = this.data.getRoot();
  6278. var groups = {};
  6279. this.data.eachChild(root, function (item) {
  6280. if (item.type === ts_menu_1.ItemType.separator) {
  6281. item.$menuSeparator = item.parent !== _this.data.getRoot();
  6282. }
  6283. if (_this.data.haveItems(item.id)) {
  6284. _this.data.eachChild(item.id, function (child) { return child.type = child.type || ts_menu_1.ItemType.menuItem; }, false);
  6285. if (item.parent !== root) {
  6286. item.$openIcon = "right";
  6287. }
  6288. else {
  6289. item.$openIcon = "bot";
  6290. }
  6291. }
  6292. if (item.group) {
  6293. addInGroups(groups, item);
  6294. }
  6295. }, true);
  6296. this._groups = groups;
  6297. };
  6298. Toolbar.prototype._setRoot = function (id) {
  6299. if (this.data.getParent(id) === this.data.getRoot()) {
  6300. this._currentRoot = id;
  6301. }
  6302. };
  6303. return Toolbar;
  6304. }(ts_menu_1.MenuBase));
  6305. exports.Toolbar = Toolbar;
  6306. /***/ }),
  6307. /* 45 */
  6308. /***/ (function(module, exports, __webpack_require__) {
  6309. "use strict";
  6310. var __extends = (this && this.__extends) || (function () {
  6311. var extendStatics = Object.setPrototypeOf ||
  6312. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6313. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6314. return function (d, b) {
  6315. extendStatics(d, b);
  6316. function __() { this.constructor = d; }
  6317. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6318. };
  6319. })();
  6320. Object.defineProperty(exports, "__esModule", { value: true });
  6321. var html_1 = __webpack_require__(1);
  6322. var MenuBase_1 = __webpack_require__(17);
  6323. var ContextMenu = /** @class */ (function (_super) {
  6324. __extends(ContextMenu, _super);
  6325. function ContextMenu() {
  6326. var _this = _super !== null && _super.apply(this, arguments) || this;
  6327. _this._isContextMenu = true;
  6328. return _this;
  6329. }
  6330. ContextMenu.prototype.showAt = function (elem, showAt) {
  6331. if (showAt === void 0) { showAt = "bottom"; }
  6332. if (elem instanceof MouseEvent) {
  6333. this._changeActivePosition({
  6334. left: window.pageXOffset + elem.x + 1,
  6335. right: window.pageXOffset + elem.x + 1,
  6336. top: window.pageYOffset + elem.y,
  6337. bottom: window.pageYOffset + elem.y
  6338. }, showAt);
  6339. }
  6340. else {
  6341. var node = html_1.toNode(elem);
  6342. this._changeActivePosition(html_1.getRealPosition(node), showAt);
  6343. }
  6344. };
  6345. ContextMenu.prototype._close = function () {
  6346. this._activeMenu = null;
  6347. this._changeActivePosition(null, null);
  6348. };
  6349. ContextMenu.prototype._normalizeData = function () {
  6350. var _this = this;
  6351. var root = this.data.getRoot();
  6352. this.data.eachChild(root, function (item) {
  6353. if (_this.data.haveItems(item.id)) {
  6354. item.$openIcon = "right";
  6355. }
  6356. }, true);
  6357. };
  6358. ContextMenu.prototype._getMode = function (_item, _root, active) {
  6359. return active ? this._mode : "right";
  6360. };
  6361. ContextMenu.prototype._changeActivePosition = function (position, mode) {
  6362. this._activePosition = position;
  6363. this._mode = mode;
  6364. this._listenOuterClick();
  6365. this.paint();
  6366. };
  6367. return ContextMenu;
  6368. }(MenuBase_1.MenuBase));
  6369. exports.ContextMenu = ContextMenu;
  6370. /***/ }),
  6371. /* 46 */
  6372. /***/ (function(module, exports, __webpack_require__) {
  6373. "use strict";
  6374. Object.defineProperty(exports, "__esModule", { value: true });
  6375. function getHotKeyCode(code) {
  6376. var matches = code.toLowerCase().match(/\w+/g);
  6377. var comp = 0;
  6378. var key = "";
  6379. for (var i = 0; i < matches.length; i++) {
  6380. var check = matches[i];
  6381. if (check === "ctrl") {
  6382. comp += 4;
  6383. }
  6384. else if (check === "shift") {
  6385. comp += 2;
  6386. }
  6387. else if (check === "alt") {
  6388. comp += 1;
  6389. }
  6390. else {
  6391. key = check;
  6392. }
  6393. }
  6394. return comp + key;
  6395. }
  6396. var KeyManager = /** @class */ (function () {
  6397. function KeyManager() {
  6398. var _this = this;
  6399. this._keysStorage = {};
  6400. document.addEventListener("keydown", function (e) {
  6401. var comp = (e.ctrlKey || e.metaKey ? 4 : 0) + (e.shiftKey ? 2 : 0) + (e.altKey ? 1 : 0);
  6402. var key;
  6403. if ((e.which >= 48 && e.which <= 57) || (e.which >= 65 && e.which <= 90)) { // A-Z 0-9
  6404. key = String.fromCharCode(e.which);
  6405. }
  6406. else {
  6407. key = e.key;
  6408. }
  6409. var code = comp + key.toLowerCase();
  6410. var actions = _this._keysStorage[code];
  6411. if (actions) {
  6412. for (var i = 0; i < actions.length; i++) {
  6413. actions[i].handler(e);
  6414. }
  6415. }
  6416. });
  6417. }
  6418. KeyManager.prototype.addHotKey = function (key, handler, scope) {
  6419. var code = getHotKeyCode(key);
  6420. if (!this._keysStorage[code]) {
  6421. this._keysStorage[code] = [];
  6422. }
  6423. this._keysStorage[code].push({
  6424. handler: handler,
  6425. scope: scope
  6426. });
  6427. };
  6428. KeyManager.prototype.removeHotKey = function (key, scope) {
  6429. var keyStorage = this._keysStorage;
  6430. if (key) {
  6431. var code = getHotKeyCode(key);
  6432. delete keyStorage[code];
  6433. }
  6434. if (scope) {
  6435. for (var code in keyStorage) {
  6436. var toDelete = []; // items index to delete
  6437. for (var i = 0; i < keyStorage[code].length; i++) {
  6438. if (keyStorage[code][i].scope === scope) {
  6439. toDelete.push(i);
  6440. }
  6441. }
  6442. if (keyStorage[code].length === toDelete.length) {
  6443. delete keyStorage[code];
  6444. }
  6445. else {
  6446. for (var i = toDelete.length - 1; i >= 0; i--) { // begin from last coz splice change other index
  6447. keyStorage[code].splice(toDelete[i], 1);
  6448. }
  6449. }
  6450. }
  6451. }
  6452. };
  6453. KeyManager.prototype.exist = function (key) {
  6454. var code = getHotKeyCode(key);
  6455. return !!this._keysStorage[code];
  6456. };
  6457. return KeyManager;
  6458. }());
  6459. exports.keyManager = new KeyManager();
  6460. function addHotkeys(handlers, beforeCall) {
  6461. var context = new Date();
  6462. var wrapHandler = function (handler) { return function (e) {
  6463. if (beforeCall && beforeCall() === false) {
  6464. return;
  6465. }
  6466. handler(e);
  6467. }; };
  6468. for (var key in handlers) {
  6469. exports.keyManager.addHotKey(key, wrapHandler(handlers[key]), context);
  6470. }
  6471. return function () { return exports.keyManager.removeHotKey(undefined, context); };
  6472. }
  6473. exports.addHotkeys = addHotkeys;
  6474. /***/ }),
  6475. /* 47 */
  6476. /***/ (function(module, exports, __webpack_require__) {
  6477. "use strict";
  6478. function __export(m) {
  6479. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6480. }
  6481. Object.defineProperty(exports, "__esModule", { value: true });
  6482. __export(__webpack_require__(9));
  6483. __export(__webpack_require__(23));
  6484. __export(__webpack_require__(26));
  6485. __export(__webpack_require__(53));
  6486. __export(__webpack_require__(15));
  6487. __export(__webpack_require__(10));
  6488. __export(__webpack_require__(24));
  6489. __export(__webpack_require__(25));
  6490. __export(__webpack_require__(55));
  6491. /***/ }),
  6492. /* 48 */
  6493. /***/ (function(module, exports, __webpack_require__) {
  6494. "use strict";
  6495. /* WEBPACK VAR INJECTION */(function(Promise) {
  6496. Object.defineProperty(exports, "__esModule", { value: true });
  6497. var helpers_1 = __webpack_require__(10);
  6498. var Loader = /** @class */ (function () {
  6499. function Loader(parent, changes) {
  6500. this._parent = parent;
  6501. this._changes = changes; // todo: [dirty] mutation
  6502. }
  6503. Loader.prototype.load = function (url, driver) {
  6504. var _this = this;
  6505. return this._parent.loadData = url.load().then(function (data) {
  6506. _this._parent.removeAll();
  6507. _this.parse(data, driver);
  6508. });
  6509. };
  6510. Loader.prototype.parse = function (data, driver) {
  6511. if (driver === void 0) { driver = "json"; }
  6512. driver = helpers_1.toDataDriver(driver);
  6513. data = driver.toJsonArray(data);
  6514. this._parent.$parse(data);
  6515. };
  6516. Loader.prototype.save = function (url) {
  6517. var _this = this;
  6518. var _loop_1 = function (el) {
  6519. if (el.saving || el.pending) {
  6520. helpers_1.dhxWarning("item is saving");
  6521. }
  6522. else {
  6523. var prevEl_1 = this_1._findPrevState(el.id);
  6524. if (prevEl_1 && prevEl_1.saving) {
  6525. var pending = new Promise(function (res, rej) {
  6526. prevEl_1.promise.then(function () {
  6527. el.pending = false;
  6528. res(_this._setPromise(el, url));
  6529. }).catch(function (err) {
  6530. _this._removeFromOrder(prevEl_1);
  6531. _this._setPromise(el, url);
  6532. helpers_1.dhxWarning(err);
  6533. rej(err);
  6534. });
  6535. });
  6536. this_1._addToChain(pending);
  6537. el.pending = true;
  6538. }
  6539. else {
  6540. this_1._setPromise(el, url);
  6541. }
  6542. }
  6543. };
  6544. var this_1 = this;
  6545. for (var _i = 0, _a = this._changes.order; _i < _a.length; _i++) {
  6546. var el = _a[_i];
  6547. _loop_1(el);
  6548. }
  6549. this._parent.saveData.then(function () {
  6550. _this._saving = false;
  6551. });
  6552. };
  6553. Loader.prototype._setPromise = function (el, url) {
  6554. var _this = this;
  6555. el.promise = url.save(el.obj, el.status);
  6556. el.promise.then(function () {
  6557. _this._removeFromOrder(el);
  6558. }).catch(function (err) {
  6559. el.saving = false;
  6560. el.error = true;
  6561. helpers_1.dhxError(err);
  6562. });
  6563. el.saving = true;
  6564. this._saving = true;
  6565. this._addToChain(el.promise);
  6566. return el.promise;
  6567. };
  6568. Loader.prototype._addToChain = function (promise) {
  6569. // tslint:disable-next-line:prefer-conditional-expression
  6570. if (this._parent.saveData && this._saving) {
  6571. this._parent.saveData = this._parent.saveData.then(function () { return promise; });
  6572. }
  6573. else {
  6574. this._parent.saveData = promise;
  6575. }
  6576. };
  6577. Loader.prototype._findPrevState = function (id) {
  6578. for (var _i = 0, _a = this._changes.order; _i < _a.length; _i++) {
  6579. var el = _a[_i];
  6580. if (el.id === id) {
  6581. return el;
  6582. }
  6583. }
  6584. return null;
  6585. };
  6586. Loader.prototype._removeFromOrder = function (el) {
  6587. this._changes.order = this._changes.order.filter(function (item) { return !helpers_1.isEqualObj(item, el); });
  6588. };
  6589. return Loader;
  6590. }());
  6591. exports.Loader = Loader;
  6592. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(13)))
  6593. /***/ }),
  6594. /* 49 */
  6595. /***/ (function(module, exports, __webpack_require__) {
  6596. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  6597. (typeof self !== "undefined" && self) ||
  6598. window;
  6599. var apply = Function.prototype.apply;
  6600. // DOM APIs, for completeness
  6601. exports.setTimeout = function() {
  6602. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  6603. };
  6604. exports.setInterval = function() {
  6605. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  6606. };
  6607. exports.clearTimeout =
  6608. exports.clearInterval = function(timeout) {
  6609. if (timeout) {
  6610. timeout.close();
  6611. }
  6612. };
  6613. function Timeout(id, clearFn) {
  6614. this._id = id;
  6615. this._clearFn = clearFn;
  6616. }
  6617. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  6618. Timeout.prototype.close = function() {
  6619. this._clearFn.call(scope, this._id);
  6620. };
  6621. // Does not start the time, just sets up the members needed.
  6622. exports.enroll = function(item, msecs) {
  6623. clearTimeout(item._idleTimeoutId);
  6624. item._idleTimeout = msecs;
  6625. };
  6626. exports.unenroll = function(item) {
  6627. clearTimeout(item._idleTimeoutId);
  6628. item._idleTimeout = -1;
  6629. };
  6630. exports._unrefActive = exports.active = function(item) {
  6631. clearTimeout(item._idleTimeoutId);
  6632. var msecs = item._idleTimeout;
  6633. if (msecs >= 0) {
  6634. item._idleTimeoutId = setTimeout(function onTimeout() {
  6635. if (item._onTimeout)
  6636. item._onTimeout();
  6637. }, msecs);
  6638. }
  6639. };
  6640. // setimmediate attaches itself to the global object
  6641. __webpack_require__(50);
  6642. // On some exotic environments, it's not clear which object `setimmediate` was
  6643. // able to install onto. Search each possibility in the same order as the
  6644. // `setimmediate` library.
  6645. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  6646. (typeof global !== "undefined" && global.setImmediate) ||
  6647. (this && this.setImmediate);
  6648. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  6649. (typeof global !== "undefined" && global.clearImmediate) ||
  6650. (this && this.clearImmediate);
  6651. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(14)))
  6652. /***/ }),
  6653. /* 50 */
  6654. /***/ (function(module, exports, __webpack_require__) {
  6655. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  6656. "use strict";
  6657. if (global.setImmediate) {
  6658. return;
  6659. }
  6660. var nextHandle = 1; // Spec says greater than zero
  6661. var tasksByHandle = {};
  6662. var currentlyRunningATask = false;
  6663. var doc = global.document;
  6664. var registerImmediate;
  6665. function setImmediate(callback) {
  6666. // Callback can either be a function or a string
  6667. if (typeof callback !== "function") {
  6668. callback = new Function("" + callback);
  6669. }
  6670. // Copy function arguments
  6671. var args = new Array(arguments.length - 1);
  6672. for (var i = 0; i < args.length; i++) {
  6673. args[i] = arguments[i + 1];
  6674. }
  6675. // Store and register the task
  6676. var task = { callback: callback, args: args };
  6677. tasksByHandle[nextHandle] = task;
  6678. registerImmediate(nextHandle);
  6679. return nextHandle++;
  6680. }
  6681. function clearImmediate(handle) {
  6682. delete tasksByHandle[handle];
  6683. }
  6684. function run(task) {
  6685. var callback = task.callback;
  6686. var args = task.args;
  6687. switch (args.length) {
  6688. case 0:
  6689. callback();
  6690. break;
  6691. case 1:
  6692. callback(args[0]);
  6693. break;
  6694. case 2:
  6695. callback(args[0], args[1]);
  6696. break;
  6697. case 3:
  6698. callback(args[0], args[1], args[2]);
  6699. break;
  6700. default:
  6701. callback.apply(undefined, args);
  6702. break;
  6703. }
  6704. }
  6705. function runIfPresent(handle) {
  6706. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  6707. // So if we're currently running a task, we'll need to delay this invocation.
  6708. if (currentlyRunningATask) {
  6709. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  6710. // "too much recursion" error.
  6711. setTimeout(runIfPresent, 0, handle);
  6712. } else {
  6713. var task = tasksByHandle[handle];
  6714. if (task) {
  6715. currentlyRunningATask = true;
  6716. try {
  6717. run(task);
  6718. } finally {
  6719. clearImmediate(handle);
  6720. currentlyRunningATask = false;
  6721. }
  6722. }
  6723. }
  6724. }
  6725. function installNextTickImplementation() {
  6726. registerImmediate = function(handle) {
  6727. process.nextTick(function () { runIfPresent(handle); });
  6728. };
  6729. }
  6730. function canUsePostMessage() {
  6731. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  6732. // where `global.postMessage` means something completely different and can't be used for this purpose.
  6733. if (global.postMessage && !global.importScripts) {
  6734. var postMessageIsAsynchronous = true;
  6735. var oldOnMessage = global.onmessage;
  6736. global.onmessage = function() {
  6737. postMessageIsAsynchronous = false;
  6738. };
  6739. global.postMessage("", "*");
  6740. global.onmessage = oldOnMessage;
  6741. return postMessageIsAsynchronous;
  6742. }
  6743. }
  6744. function installPostMessageImplementation() {
  6745. // Installs an event handler on `global` for the `message` event: see
  6746. // * https://developer.mozilla.org/en/DOM/window.postMessage
  6747. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  6748. var messagePrefix = "setImmediate$" + Math.random() + "$";
  6749. var onGlobalMessage = function(event) {
  6750. if (event.source === global &&
  6751. typeof event.data === "string" &&
  6752. event.data.indexOf(messagePrefix) === 0) {
  6753. runIfPresent(+event.data.slice(messagePrefix.length));
  6754. }
  6755. };
  6756. if (global.addEventListener) {
  6757. global.addEventListener("message", onGlobalMessage, false);
  6758. } else {
  6759. global.attachEvent("onmessage", onGlobalMessage);
  6760. }
  6761. registerImmediate = function(handle) {
  6762. global.postMessage(messagePrefix + handle, "*");
  6763. };
  6764. }
  6765. function installMessageChannelImplementation() {
  6766. var channel = new MessageChannel();
  6767. channel.port1.onmessage = function(event) {
  6768. var handle = event.data;
  6769. runIfPresent(handle);
  6770. };
  6771. registerImmediate = function(handle) {
  6772. channel.port2.postMessage(handle);
  6773. };
  6774. }
  6775. function installReadyStateChangeImplementation() {
  6776. var html = doc.documentElement;
  6777. registerImmediate = function(handle) {
  6778. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  6779. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  6780. var script = doc.createElement("script");
  6781. script.onreadystatechange = function () {
  6782. runIfPresent(handle);
  6783. script.onreadystatechange = null;
  6784. html.removeChild(script);
  6785. script = null;
  6786. };
  6787. html.appendChild(script);
  6788. };
  6789. }
  6790. function installSetTimeoutImplementation() {
  6791. registerImmediate = function(handle) {
  6792. setTimeout(runIfPresent, 0, handle);
  6793. };
  6794. }
  6795. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  6796. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  6797. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  6798. // Don't get fooled by e.g. browserify environments.
  6799. if ({}.toString.call(global.process) === "[object process]") {
  6800. // For Node.js before 0.9
  6801. installNextTickImplementation();
  6802. } else if (canUsePostMessage()) {
  6803. // For non-IE10 modern browsers
  6804. installPostMessageImplementation();
  6805. } else if (global.MessageChannel) {
  6806. // For web workers, where supported
  6807. installMessageChannelImplementation();
  6808. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  6809. // For IE 6–8
  6810. installReadyStateChangeImplementation();
  6811. } else {
  6812. // For older browsers
  6813. installSetTimeoutImplementation();
  6814. }
  6815. attachTo.setImmediate = setImmediate;
  6816. attachTo.clearImmediate = clearImmediate;
  6817. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  6818. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(14), __webpack_require__(51)))
  6819. /***/ }),
  6820. /* 51 */
  6821. /***/ (function(module, exports) {
  6822. // shim for using process in browser
  6823. var process = module.exports = {};
  6824. // cached from whatever global is present so that test runners that stub it
  6825. // don't break things. But we need to wrap it in a try catch in case it is
  6826. // wrapped in strict mode code which doesn't define any globals. It's inside a
  6827. // function because try/catches deoptimize in certain engines.
  6828. var cachedSetTimeout;
  6829. var cachedClearTimeout;
  6830. function defaultSetTimout() {
  6831. throw new Error('setTimeout has not been defined');
  6832. }
  6833. function defaultClearTimeout () {
  6834. throw new Error('clearTimeout has not been defined');
  6835. }
  6836. (function () {
  6837. try {
  6838. if (typeof setTimeout === 'function') {
  6839. cachedSetTimeout = setTimeout;
  6840. } else {
  6841. cachedSetTimeout = defaultSetTimout;
  6842. }
  6843. } catch (e) {
  6844. cachedSetTimeout = defaultSetTimout;
  6845. }
  6846. try {
  6847. if (typeof clearTimeout === 'function') {
  6848. cachedClearTimeout = clearTimeout;
  6849. } else {
  6850. cachedClearTimeout = defaultClearTimeout;
  6851. }
  6852. } catch (e) {
  6853. cachedClearTimeout = defaultClearTimeout;
  6854. }
  6855. } ())
  6856. function runTimeout(fun) {
  6857. if (cachedSetTimeout === setTimeout) {
  6858. //normal enviroments in sane situations
  6859. return setTimeout(fun, 0);
  6860. }
  6861. // if setTimeout wasn't available but was latter defined
  6862. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  6863. cachedSetTimeout = setTimeout;
  6864. return setTimeout(fun, 0);
  6865. }
  6866. try {
  6867. // when when somebody has screwed with setTimeout but no I.E. maddness
  6868. return cachedSetTimeout(fun, 0);
  6869. } catch(e){
  6870. try {
  6871. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  6872. return cachedSetTimeout.call(null, fun, 0);
  6873. } catch(e){
  6874. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  6875. return cachedSetTimeout.call(this, fun, 0);
  6876. }
  6877. }
  6878. }
  6879. function runClearTimeout(marker) {
  6880. if (cachedClearTimeout === clearTimeout) {
  6881. //normal enviroments in sane situations
  6882. return clearTimeout(marker);
  6883. }
  6884. // if clearTimeout wasn't available but was latter defined
  6885. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  6886. cachedClearTimeout = clearTimeout;
  6887. return clearTimeout(marker);
  6888. }
  6889. try {
  6890. // when when somebody has screwed with setTimeout but no I.E. maddness
  6891. return cachedClearTimeout(marker);
  6892. } catch (e){
  6893. try {
  6894. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  6895. return cachedClearTimeout.call(null, marker);
  6896. } catch (e){
  6897. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  6898. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  6899. return cachedClearTimeout.call(this, marker);
  6900. }
  6901. }
  6902. }
  6903. var queue = [];
  6904. var draining = false;
  6905. var currentQueue;
  6906. var queueIndex = -1;
  6907. function cleanUpNextTick() {
  6908. if (!draining || !currentQueue) {
  6909. return;
  6910. }
  6911. draining = false;
  6912. if (currentQueue.length) {
  6913. queue = currentQueue.concat(queue);
  6914. } else {
  6915. queueIndex = -1;
  6916. }
  6917. if (queue.length) {
  6918. drainQueue();
  6919. }
  6920. }
  6921. function drainQueue() {
  6922. if (draining) {
  6923. return;
  6924. }
  6925. var timeout = runTimeout(cleanUpNextTick);
  6926. draining = true;
  6927. var len = queue.length;
  6928. while(len) {
  6929. currentQueue = queue;
  6930. queue = [];
  6931. while (++queueIndex < len) {
  6932. if (currentQueue) {
  6933. currentQueue[queueIndex].run();
  6934. }
  6935. }
  6936. queueIndex = -1;
  6937. len = queue.length;
  6938. }
  6939. currentQueue = null;
  6940. draining = false;
  6941. runClearTimeout(timeout);
  6942. }
  6943. process.nextTick = function (fun) {
  6944. var args = new Array(arguments.length - 1);
  6945. if (arguments.length > 1) {
  6946. for (var i = 1; i < arguments.length; i++) {
  6947. args[i - 1] = arguments[i];
  6948. }
  6949. }
  6950. queue.push(new Item(fun, args));
  6951. if (queue.length === 1 && !draining) {
  6952. runTimeout(drainQueue);
  6953. }
  6954. };
  6955. // v8 likes predictible objects
  6956. function Item(fun, array) {
  6957. this.fun = fun;
  6958. this.array = array;
  6959. }
  6960. Item.prototype.run = function () {
  6961. this.fun.apply(null, this.array);
  6962. };
  6963. process.title = 'browser';
  6964. process.browser = true;
  6965. process.env = {};
  6966. process.argv = [];
  6967. process.version = ''; // empty string to avoid regexp issues
  6968. process.versions = {};
  6969. function noop() {}
  6970. process.on = noop;
  6971. process.addListener = noop;
  6972. process.once = noop;
  6973. process.off = noop;
  6974. process.removeListener = noop;
  6975. process.removeAllListeners = noop;
  6976. process.emit = noop;
  6977. process.prependListener = noop;
  6978. process.prependOnceListener = noop;
  6979. process.listeners = function (name) { return [] }
  6980. process.binding = function (name) {
  6981. throw new Error('process.binding is not supported');
  6982. };
  6983. process.cwd = function () { return '/' };
  6984. process.chdir = function (dir) {
  6985. throw new Error('process.chdir is not supported');
  6986. };
  6987. process.umask = function() { return 0; };
  6988. /***/ }),
  6989. /* 52 */
  6990. /***/ (function(module, exports, __webpack_require__) {
  6991. "use strict";
  6992. Object.defineProperty(exports, "__esModule", { value: true });
  6993. var helpers_1 = __webpack_require__(10);
  6994. var Sort = /** @class */ (function () {
  6995. function Sort() {
  6996. }
  6997. Sort.prototype.sort = function (array, by) {
  6998. var _this = this;
  6999. if (by.rule && typeof by.rule === "function") {
  7000. this._sort(array, by);
  7001. }
  7002. else if (by.by) {
  7003. by.rule = function (a, b) {
  7004. var aa = _this._checkVal(by.as, a[by.by]);
  7005. var bb = _this._checkVal(by.as, b[by.by]);
  7006. return helpers_1.naturalCompare(aa.toString(), bb.toString()); // didnt work with numbers
  7007. };
  7008. this._sort(array, by);
  7009. }
  7010. };
  7011. Sort.prototype._checkVal = function (method, val) {
  7012. return method ? method.call(this, val) : val;
  7013. };
  7014. Sort.prototype._sort = function (arr, conf) {
  7015. var _this = this;
  7016. var dir = {
  7017. asc: 1,
  7018. desc: -1
  7019. };
  7020. return arr.sort(function (a, b) {
  7021. return conf.rule.call(_this, a, b) * (dir[conf.dir] || dir.asc);
  7022. });
  7023. };
  7024. return Sort;
  7025. }());
  7026. exports.Sort = Sort;
  7027. /***/ }),
  7028. /* 53 */
  7029. /***/ (function(module, exports, __webpack_require__) {
  7030. "use strict";
  7031. Object.defineProperty(exports, "__esModule", { value: true });
  7032. var html_1 = __webpack_require__(1);
  7033. var types_1 = __webpack_require__(12);
  7034. var CollectionStore_1 = __webpack_require__(54);
  7035. var treecollection_1 = __webpack_require__(26);
  7036. var types_2 = __webpack_require__(9);
  7037. var DropPosition;
  7038. (function (DropPosition) {
  7039. DropPosition[DropPosition["top"] = 0] = "top";
  7040. DropPosition[DropPosition["bot"] = 1] = "bot";
  7041. DropPosition[DropPosition["in"] = 2] = "in";
  7042. })(DropPosition || (DropPosition = {}));
  7043. function getPosition(e) {
  7044. var y = e.clientY;
  7045. var element = html_1.locateNode(e);
  7046. if (!element) {
  7047. return null;
  7048. }
  7049. var treeLine = element.childNodes[0];
  7050. var _a = treeLine.getBoundingClientRect(), top = _a.top, height = _a.height;
  7051. return (y - top) / height;
  7052. }
  7053. function dragEventContent(item) {
  7054. var ghost = document.createElement("div");
  7055. ghost.textContent = item.value || item.text;
  7056. ghost.className = "dhx_drag-ghost";
  7057. ghost.style.pointerEvents = "none";
  7058. return ghost;
  7059. }
  7060. var DragManager = /** @class */ (function () {
  7061. function DragManager() {
  7062. var _this = this;
  7063. this._transferData = {};
  7064. this._canMove = true;
  7065. this._ghostTopPadding = -17;
  7066. this._onMouseMove = function (e) {
  7067. if (!_this._transferData.id) {
  7068. return;
  7069. }
  7070. var pageX = e.pageX, pageY = e.pageY;
  7071. if (!_this._transferData.ghost) {
  7072. if (Math.abs(_this._transferData.x - pageX) < 3 && Math.abs(_this._transferData.y - pageY) < 3) {
  7073. return;
  7074. }
  7075. else {
  7076. var ghost = _this._onDragStart(_this._transferData.id, _this._transferData.targetId);
  7077. if (!ghost) {
  7078. _this._endDrop();
  7079. return;
  7080. }
  7081. else {
  7082. _this._transferData.ghost = ghost;
  7083. document.body.appendChild(_this._transferData.ghost);
  7084. }
  7085. }
  7086. }
  7087. _this._moveGhost(pageX, pageY);
  7088. _this._onDrag(e);
  7089. };
  7090. this._onMouseUp = function () {
  7091. if (!_this._transferData.x) {
  7092. return;
  7093. }
  7094. if (_this._transferData.ghost) {
  7095. _this._removeGhost();
  7096. _this._onDrop();
  7097. }
  7098. else {
  7099. _this._endDrop();
  7100. }
  7101. document.removeEventListener("mousemove", _this._onMouseMove);
  7102. document.removeEventListener("mouseup", _this._onMouseUp);
  7103. };
  7104. }
  7105. DragManager.prototype.setItem = function (id, item, config) {
  7106. CollectionStore_1.collectionStore.setItem(id, item, config);
  7107. };
  7108. DragManager.prototype.onMouseDown = function (e) {
  7109. if (e.which !== 1) {
  7110. return;
  7111. }
  7112. document.addEventListener("mousemove", this._onMouseMove);
  7113. document.addEventListener("mouseup", this._onMouseUp);
  7114. var id = html_1.locate(e, "dhx_id");
  7115. var targetId = html_1.locate(e, "dhx_collection_id");
  7116. if (id && targetId) {
  7117. this._transferData.x = e.x;
  7118. this._transferData.y = e.y;
  7119. this._transferData.targetId = targetId;
  7120. this._transferData.id = id;
  7121. }
  7122. };
  7123. DragManager.prototype._moveGhost = function (x, y) {
  7124. if (this._transferData.ghost) {
  7125. var width = this._transferData.ghost.offsetWidth / 2;
  7126. this._transferData.ghost.style.left = x - width + "px";
  7127. this._transferData.ghost.style.top = y + this._ghostTopPadding + "px";
  7128. }
  7129. };
  7130. DragManager.prototype._removeGhost = function () {
  7131. document.body.removeChild(this._transferData.ghost);
  7132. };
  7133. DragManager.prototype._onDrop = function () {
  7134. if (!this._canMove) {
  7135. this._endDrop();
  7136. return;
  7137. }
  7138. var target = CollectionStore_1.collectionStore.getItem(this._lastCollectionId);
  7139. var config = CollectionStore_1.collectionStore.getItemConfig(this._lastCollectionId);
  7140. if (!target || config.mode === types_2.DragMode.source) {
  7141. this._endDrop();
  7142. return;
  7143. }
  7144. var to = {
  7145. id: this._lastId,
  7146. target: target
  7147. };
  7148. var from = {
  7149. id: this._transferData.id,
  7150. target: this._transferData.target
  7151. };
  7152. if (from.target.events.fire(types_1.DragEvents.beforeDrop, [from, to])) {
  7153. this._move(from, to);
  7154. to.target.events.fire(types_1.DragEvents.dropComplete, [to.id, this._transferData.dropPosition]);
  7155. }
  7156. this._endDrop();
  7157. };
  7158. DragManager.prototype._onDragStart = function (id, targetId) {
  7159. var target = CollectionStore_1.collectionStore.getItem(targetId);
  7160. var config = CollectionStore_1.collectionStore.getItemConfig(targetId);
  7161. if (config.dragMode === types_2.DragMode.target) {
  7162. return null;
  7163. }
  7164. var item = target.data.getItem(id);
  7165. target.events.fire(types_1.DragEvents.dragStart);
  7166. var ghost = dragEventContent(item);
  7167. var ans = target.events.fire(types_1.DragEvents.beforeDrag, [item, ghost]);
  7168. if (!ans || !id) {
  7169. return null;
  7170. }
  7171. this._toggleTextSelection(true);
  7172. this._transferData.target = target;
  7173. this._transferData.dragConfig = config;
  7174. return ghost;
  7175. };
  7176. DragManager.prototype._onDrag = function (e) {
  7177. var x = e.x, y = e.y;
  7178. var element = document.elementFromPoint(x, y);
  7179. var id = html_1.locate(element, "dhx_id");
  7180. if (!id) {
  7181. this._cancelCanDrop();
  7182. return;
  7183. }
  7184. var collectionId = html_1.locate(element, "dhx_collection_id");
  7185. if (this._transferData.dragConfig.behaviour === types_2.DragBehaviour.complex) {
  7186. var pos = getPosition(e);
  7187. if (pos <= 0.25) {
  7188. this._transferData.dropPosition = DropPosition.top;
  7189. }
  7190. else if (pos >= 0.75) {
  7191. this._transferData.dropPosition = DropPosition.bot;
  7192. }
  7193. else {
  7194. this._transferData.dropPosition = DropPosition.in;
  7195. }
  7196. }
  7197. else if (this._lastId === id && this._lastCollectionId === collectionId) {
  7198. return;
  7199. }
  7200. var eventArgs;
  7201. var from;
  7202. var targetTo;
  7203. if ((!id || !collectionId) && this._canMove) {
  7204. this._cancelCanDrop();
  7205. return;
  7206. }
  7207. else {
  7208. from = {
  7209. id: this._transferData.id,
  7210. target: this._transferData.target
  7211. };
  7212. targetTo = CollectionStore_1.collectionStore.getItem(collectionId);
  7213. eventArgs = [from, {
  7214. id: id,
  7215. target: targetTo
  7216. }];
  7217. from.target.events.fire(types_1.DragEvents.dragOut, eventArgs);
  7218. }
  7219. if (collectionId !== this._transferData.targetId || !(from.target.data instanceof treecollection_1.TreeCollection) ||
  7220. (from.target.data instanceof treecollection_1.TreeCollection && from.target.data.canCopy(from.id, id))) {
  7221. // handle cursor or something, can drop
  7222. this._cancelCanDrop(); // clear last
  7223. this._lastId = id;
  7224. this._lastCollectionId = collectionId;
  7225. eventArgs.push(this._transferData.dropPosition);
  7226. var canMove = from.target.events.fire(types_1.DragEvents.dragIn, eventArgs);
  7227. if (canMove) {
  7228. this._canDrop();
  7229. }
  7230. }
  7231. else {
  7232. this._cancelCanDrop();
  7233. }
  7234. };
  7235. DragManager.prototype._move = function (from, to) {
  7236. var fromData = from.target.data;
  7237. var toData = to.target.data;
  7238. var index = 0;
  7239. var targetId = to.id;
  7240. var behaviour = this._transferData.dragConfig.behaviour;
  7241. switch (behaviour) {
  7242. case types_2.DragBehaviour.child:
  7243. break;
  7244. case types_2.DragBehaviour.sibling:
  7245. targetId = toData.getParent(targetId);
  7246. index = toData.getIndex(to.id) + 1;
  7247. break;
  7248. case types_2.DragBehaviour.complex:
  7249. var dropPosition = this._transferData.dropPosition;
  7250. if (dropPosition === DropPosition.top) {
  7251. targetId = toData.getParent(targetId);
  7252. index = toData.getIndex(to.id);
  7253. }
  7254. else if (dropPosition === DropPosition.bot) {
  7255. targetId = toData.getParent(targetId);
  7256. index = toData.getIndex(to.id) + 1;
  7257. }
  7258. break;
  7259. }
  7260. if (this._transferData.dragConfig.copy) {
  7261. fromData.copy(from.id, index, toData, targetId);
  7262. }
  7263. else {
  7264. fromData.move(from.id, index, toData, targetId);
  7265. }
  7266. };
  7267. DragManager.prototype._endDrop = function () {
  7268. this._toggleTextSelection(false);
  7269. if (this._transferData.target) {
  7270. this._transferData.target.events.fire(types_1.DragEvents.dragEnd);
  7271. }
  7272. this._cancelCanDrop();
  7273. this._canMove = true;
  7274. this._transferData = {};
  7275. this._lastId = null;
  7276. this._lastCollectionId = null;
  7277. };
  7278. DragManager.prototype._cancelCanDrop = function () {
  7279. this._canMove = false;
  7280. var collection = CollectionStore_1.collectionStore.getItem(this._lastCollectionId);
  7281. if (collection && this._lastId) {
  7282. collection.events.fire(types_1.DragEvents.cancelDrop, [this._lastId]);
  7283. }
  7284. };
  7285. DragManager.prototype._canDrop = function () {
  7286. this._canMove = true;
  7287. var collection = CollectionStore_1.collectionStore.getItem(this._lastCollectionId);
  7288. if (collection && this._lastId) {
  7289. collection.events.fire(types_1.DragEvents.canDrop, [this._lastId, this._transferData.dropPosition]);
  7290. }
  7291. };
  7292. DragManager.prototype._toggleTextSelection = function (add) {
  7293. if (add) {
  7294. document.body.classList.add("dhx_no-select");
  7295. }
  7296. else {
  7297. document.body.classList.remove("dhx_no-select");
  7298. }
  7299. };
  7300. return DragManager;
  7301. }());
  7302. exports.dragManager = new DragManager();
  7303. /***/ }),
  7304. /* 54 */
  7305. /***/ (function(module, exports, __webpack_require__) {
  7306. "use strict";
  7307. Object.defineProperty(exports, "__esModule", { value: true });
  7308. var CollectionStore = /** @class */ (function () {
  7309. function CollectionStore() {
  7310. this._store = {};
  7311. }
  7312. CollectionStore.prototype.setItem = function (id, target, config) {
  7313. this._store[id] = {
  7314. target: target,
  7315. config: config
  7316. };
  7317. };
  7318. CollectionStore.prototype.getItem = function (id) {
  7319. if (!this._store[id]) {
  7320. return null;
  7321. }
  7322. return this._store[id].target;
  7323. };
  7324. CollectionStore.prototype.getItemConfig = function (id) {
  7325. if (!this._store[id]) {
  7326. return null;
  7327. }
  7328. return this._store[id].config;
  7329. };
  7330. return CollectionStore;
  7331. }());
  7332. exports.collectionStore = new CollectionStore();
  7333. /***/ }),
  7334. /* 55 */
  7335. /***/ (function(module, exports, __webpack_require__) {
  7336. "use strict";
  7337. Object.defineProperty(exports, "__esModule", { value: true });
  7338. var events_1 = __webpack_require__(7);
  7339. var types_1 = __webpack_require__(12);
  7340. var types_2 = __webpack_require__(9);
  7341. var Selection = /** @class */ (function () {
  7342. function Selection(_config, data, events) {
  7343. var _this = this;
  7344. this.events = events || (new events_1.EventSystem());
  7345. this._data = data;
  7346. this._data.events.on(types_2.DataEvents.removeAll, function () {
  7347. _this._selected = null;
  7348. });
  7349. this._data.events.on(types_2.DataEvents.change, function () {
  7350. if (_this._selected) {
  7351. var near = _this._data.getNearId(_this._selected);
  7352. if (near !== _this._selected) {
  7353. _this._selected = null;
  7354. if (near) {
  7355. _this.add(near);
  7356. }
  7357. }
  7358. }
  7359. });
  7360. }
  7361. Selection.prototype.getId = function () {
  7362. return this._selected;
  7363. };
  7364. Selection.prototype.getItem = function () {
  7365. if (this._selected) {
  7366. return this._data.getItem(this._selected);
  7367. }
  7368. return null;
  7369. };
  7370. Selection.prototype.remove = function (id) {
  7371. id = id || this._selected;
  7372. if (!id) {
  7373. return true;
  7374. }
  7375. if (this.events.fire(types_1.SelectionEvents.beforeUnSelect, [id])) {
  7376. this._data.update(id, { $selected: false });
  7377. this._selected = null;
  7378. this.events.fire(types_1.SelectionEvents.afterUnSelect, [id]);
  7379. return true;
  7380. }
  7381. return false;
  7382. };
  7383. Selection.prototype.add = function (id) {
  7384. if (this._selected === id) {
  7385. return;
  7386. }
  7387. this.remove();
  7388. if (this.events.fire(types_1.SelectionEvents.beforeSelect, [id])) {
  7389. this._selected = id;
  7390. this._data.update(id, { $selected: true });
  7391. this.events.fire(types_1.SelectionEvents.afterSelect, [id]);
  7392. }
  7393. };
  7394. return Selection;
  7395. }());
  7396. exports.Selection = Selection;
  7397. /***/ }),
  7398. /* 56 */
  7399. /***/ (function(module, exports, __webpack_require__) {
  7400. "use strict";
  7401. Object.defineProperty(exports, "__esModule", { value: true });
  7402. var dom_1 = __webpack_require__(0);
  7403. var helpers_1 = __webpack_require__(6);
  7404. function button(item) {
  7405. var className = "dhx_toolbar-button dhx_button dhx_toolbar__button ";
  7406. return dom_1.el("li.dhx_toolbar__item", [
  7407. dom_1.el("button", {
  7408. class: className + helpers_1.getIconButtonClass(item) + helpers_1.getCss(item),
  7409. dhx_id: item.id,
  7410. disabled: item.$disabled
  7411. }, [
  7412. helpers_1.counter(item),
  7413. item.icon ? helpers_1.icon(item.icon, "button") : null,
  7414. // item.value ? el("span.dhx_button__text", item.value) : null,
  7415. dom_1.el("span.dhx_button__text", item.value),
  7416. item.$openIcon ? dom_1.el("span.dhx_button__icon.dhx_button__icon--menu-down.dxi.dxi-menu-down") : null
  7417. ])
  7418. ]);
  7419. }
  7420. exports.button = button;
  7421. /***/ }),
  7422. /* 57 */
  7423. /***/ (function(module, exports, __webpack_require__) {
  7424. "use strict";
  7425. Object.defineProperty(exports, "__esModule", { value: true });
  7426. var dom_1 = __webpack_require__(0);
  7427. var helpers_1 = __webpack_require__(6);
  7428. function customHTMLButton(item) {
  7429. return dom_1.el("li.dhx_toolbar__item", [
  7430. dom_1.el("button", {
  7431. class: "dhx_button dhx_toolbar__button--custom_html" + helpers_1.getCss(item),
  7432. dhx_id: item.id
  7433. }, [
  7434. helpers_1.counter(item),
  7435. dom_1.el(".dhx_toolbar-button__html-wrapper", {
  7436. ".innerHTML": item.html
  7437. }),
  7438. item.value ? dom_1.el("span.dhx_button__text", item.value) : null
  7439. ])
  7440. ]);
  7441. }
  7442. exports.customHTMLButton = customHTMLButton;
  7443. /***/ }),
  7444. /* 58 */
  7445. /***/ (function(module, exports, __webpack_require__) {
  7446. "use strict";
  7447. Object.defineProperty(exports, "__esModule", { value: true });
  7448. var dom_1 = __webpack_require__(0);
  7449. var helpers_1 = __webpack_require__(6);
  7450. function dhxButton(item) {
  7451. return dom_1.el("li.dhx_toolbar__item", [
  7452. dom_1.el("button", {
  7453. class: "dhx_button dhx_toolbar__button" + helpers_1.getCss(item) + (!item.value && item.icon ? " dhx_button--icon" : ""),
  7454. dhx_id: item.id,
  7455. disabled: item.$disabled
  7456. }, [
  7457. helpers_1.counter(item),
  7458. item.icon ? helpers_1.icon(item.icon, "button") : null,
  7459. item.value ? dom_1.el("span.dhx_button__text", item.value) : null,
  7460. item.$openIcon ? dom_1.el("span.dhx_button__icon.dhx_button__icon--menu-down.dxi.dxi-menu-down") : null
  7461. ])
  7462. ]);
  7463. }
  7464. exports.dhxButton = dhxButton;
  7465. /***/ }),
  7466. /* 59 */
  7467. /***/ (function(module, exports, __webpack_require__) {
  7468. "use strict";
  7469. Object.defineProperty(exports, "__esModule", { value: true });
  7470. var dom_1 = __webpack_require__(0);
  7471. var helpers_1 = __webpack_require__(6);
  7472. function imageButton(item) {
  7473. return dom_1.el("li.dhx_toolbar__item", [
  7474. dom_1.el("button", {
  7475. class: "dhx_button dhx_toolbar__button dhx_toolbar-img-button" + helpers_1.getCss(item),
  7476. dhx_id: item.id
  7477. }, [
  7478. helpers_1.counter(item),
  7479. dom_1.el("div.dhx_toolbar-img-button__text", item.value),
  7480. dom_1.el("img.dhx_toolbar-img-button__image", {
  7481. src: item.src
  7482. }),
  7483. ])
  7484. ]);
  7485. }
  7486. exports.imageButton = imageButton;
  7487. /***/ }),
  7488. /* 60 */
  7489. /***/ (function(module, exports, __webpack_require__) {
  7490. "use strict";
  7491. Object.defineProperty(exports, "__esModule", { value: true });
  7492. var dom_1 = __webpack_require__(0);
  7493. var types_1 = __webpack_require__(16);
  7494. var helpers_1 = __webpack_require__(6);
  7495. function input(item, events) {
  7496. return dom_1.el("li.dhx_toolbar__item", {}, [
  7497. dom_1.el(".dhx_form-group.dhx_form-group--no-message-holder.dhx_form-group--label_sr", {
  7498. class: helpers_1.getCss(item) + item.icon
  7499. }, [
  7500. dom_1.el("input.dhx_input", {
  7501. placeholder: item.placeholder,
  7502. value: item.value,
  7503. dhx_id: item.id,
  7504. style: {
  7505. width: item.width ? item.width : null
  7506. },
  7507. _hooks: {
  7508. didInsert: function (node) {
  7509. if (events) {
  7510. events.fire(types_1.NavigationBarEvents.inputCreated, [item.id, node.el]);
  7511. }
  7512. }
  7513. },
  7514. _key: item.id
  7515. }),
  7516. dom_1.el("label.dhx_label", { for: item.id }, item.label),
  7517. dom_1.el(".input-animation")
  7518. ]),
  7519. ]);
  7520. }
  7521. exports.input = input;
  7522. /***/ }),
  7523. /* 61 */
  7524. /***/ (function(module, exports, __webpack_require__) {
  7525. "use strict";
  7526. Object.defineProperty(exports, "__esModule", { value: true });
  7527. var dom_1 = __webpack_require__(0);
  7528. var helpers_1 = __webpack_require__(6);
  7529. function menuItem(item) {
  7530. return dom_1.el("li.dhx_menu__item", [
  7531. dom_1.el("button", {
  7532. class: "dhx_menu__button dhx_button dhx_button--type_link dhx_button--color_secondary dhx_button--width_full" + helpers_1.getCss(item),
  7533. dhx_id: item.id,
  7534. }, [
  7535. item.icon ? helpers_1.icon(item.icon, "menu") : null,
  7536. item.value ? dom_1.el("span.dhx_menu__text", item.value) : null,
  7537. item.$openIcon ? dom_1.el("span.dhx_menu__icon.dhx_menu__icon--submenu.dxi.dxi-menu-right") : null,
  7538. item.hotkey ? dom_1.el("span.span.dhx_menu__hotkey", item.hotkey) : null
  7539. ])
  7540. ]);
  7541. }
  7542. exports.menuItem = menuItem;
  7543. /***/ }),
  7544. /* 62 */
  7545. /***/ (function(module, exports, __webpack_require__) {
  7546. "use strict";
  7547. Object.defineProperty(exports, "__esModule", { value: true });
  7548. var dom_1 = __webpack_require__(0);
  7549. function separator(item) {
  7550. var className = item.$menuSeparator
  7551. ? "dhx_menu__item dhx_menu__separator"
  7552. : "dhx_toolbar__item dhx_toolbar__separator";
  7553. return dom_1.el("li", {
  7554. "class": className,
  7555. "aria-hidden": "true"
  7556. });
  7557. }
  7558. exports.separator = separator;
  7559. /***/ }),
  7560. /* 63 */
  7561. /***/ (function(module, exports, __webpack_require__) {
  7562. "use strict";
  7563. Object.defineProperty(exports, "__esModule", { value: true });
  7564. var dom_1 = __webpack_require__(0);
  7565. function spacer(_item) {
  7566. return dom_1.el("li", {
  7567. "class": "dhx_toolbar__item dhx_toolbar__spacer",
  7568. "aria-hidden": "true"
  7569. });
  7570. }
  7571. exports.spacer = spacer;
  7572. /***/ }),
  7573. /* 64 */
  7574. /***/ (function(module, exports, __webpack_require__) {
  7575. "use strict";
  7576. Object.defineProperty(exports, "__esModule", { value: true });
  7577. var dom_1 = __webpack_require__(0);
  7578. var helpers_1 = __webpack_require__(6);
  7579. function text(item) {
  7580. return dom_1.el("li.dhx_toolbar__item", [dom_1.el("span", {
  7581. class: "dhx_toolbar__text" + helpers_1.getCss(item)
  7582. }, item.value)]);
  7583. }
  7584. exports.text = text;
  7585. /***/ }),
  7586. /* 65 */
  7587. /***/ (function(module, exports, __webpack_require__) {
  7588. "use strict";
  7589. var __extends = (this && this.__extends) || (function () {
  7590. var extendStatics = Object.setPrototypeOf ||
  7591. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  7592. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7593. return function (d, b) {
  7594. extendStatics(d, b);
  7595. function __() { this.constructor = d; }
  7596. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7597. };
  7598. })();
  7599. var __assign = (this && this.__assign) || Object.assign || function(t) {
  7600. for (var s, i = 1, n = arguments.length; i < n; i++) {
  7601. s = arguments[i];
  7602. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  7603. t[p] = s[p];
  7604. }
  7605. return t;
  7606. };
  7607. Object.defineProperty(exports, "__esModule", { value: true });
  7608. var dom_1 = __webpack_require__(0);
  7609. var MenuBase_1 = __webpack_require__(17);
  7610. var Menu = /** @class */ (function (_super) {
  7611. __extends(Menu, _super);
  7612. function Menu(element, config) {
  7613. var _this = _super.call(this, element, config) || this;
  7614. var render = function () { return _this._draw(); };
  7615. _this.mount(element, dom_1.create({ render: render }));
  7616. return _this;
  7617. }
  7618. Menu.prototype._draw = function () {
  7619. return dom_1.el("div", __assign({ dhx_widget_id: this._uid, class: "main-menu" }, this._handlers), this._drawMenuItems(this.data.getRoot()));
  7620. };
  7621. return Menu;
  7622. }(MenuBase_1.MenuBase));
  7623. exports.Menu = Menu;
  7624. /***/ }),
  7625. /* 66 */
  7626. /***/ (function(module, exports, __webpack_require__) {
  7627. "use strict";
  7628. /* WEBPACK VAR INJECTION */(function(Promise) {
  7629. Object.defineProperty(exports, "__esModule", { value: true });
  7630. var en_1 = __webpack_require__(67);
  7631. function blockKeys(e) {
  7632. var active = document.activeElement;
  7633. if (!active.classList.contains("dhx_alert__confirm-reject") && !active.classList.contains("dhx_alert__confirm-aply")) {
  7634. e.preventDefault();
  7635. }
  7636. }
  7637. function blockScreen(css) {
  7638. var blocker = document.createElement("div");
  7639. blocker.className = "dhx_alert__overlay " + (css || "");
  7640. document.body.appendChild(blocker);
  7641. document.addEventListener("keydown", blockKeys);
  7642. return function () {
  7643. document.body.removeChild(blocker);
  7644. document.removeEventListener("keydown", blockKeys);
  7645. };
  7646. }
  7647. exports.blockScreen = blockScreen;
  7648. function alert(props) {
  7649. var apply = props.buttons && props.buttons[0] ? props.buttons[0] : en_1.default.apply;
  7650. var unblock = blockScreen(props.blockerCss);
  7651. return new Promise(function (res) {
  7652. var alertBox = document.createElement("div");
  7653. alertBox.className = "dhx_alert " + (props.css || "");
  7654. alertBox.innerHTML = "\n\t\t\t<div class=\"dhx_alert__header\">\n\t\t\t\t" + props.header + "\n\t\t\t</div>\n\t\t\t<div class=\"dhx_alert__content\">" + props.text + "</div>\n\t\t\t<div class=\"dhx_alert__footer " + (props.buttonsAlignment ? ("dhx_alert__footer--" + props.buttonsAlignment) : "") + "\">\n\t\t\t\t<button class=\"dhx_alert__apply-button dhx_button dhx_button--type_flat dhx_button--color_primary dhx_button--size_medium\">" + apply + "</button>\n\t\t\t</div>";
  7655. document.body.appendChild(alertBox);
  7656. alertBox.querySelector(".dhx_alert__apply-button").focus();
  7657. alertBox.querySelector("button").addEventListener("click", function () {
  7658. unblock();
  7659. document.body.removeChild(alertBox);
  7660. res(true);
  7661. });
  7662. });
  7663. }
  7664. exports.alert = alert;
  7665. function confirm(props) {
  7666. var apply = props.buttons && props.buttons[1] ? props.buttons[1] : en_1.default.apply;
  7667. var reject = props.buttons && props.buttons[0] ? props.buttons[0] : en_1.default.reject;
  7668. var unblock = blockScreen(props.blockerCss);
  7669. return new Promise(function (res) {
  7670. var answer = function (val) {
  7671. unblock();
  7672. confirmBox.removeEventListener("click", clickHandler);
  7673. document.body.removeChild(confirmBox);
  7674. res(val);
  7675. };
  7676. var confirmBox = document.createElement("div");
  7677. confirmBox.className = "dhx_alert dhx_alert--confirm" + (props.css || "");
  7678. confirmBox.innerHTML = "\n\t\t\t<div class=\"dhx_alert__header\">\n\t\t\t\t" + props.header + "\n\t\t\t</div>\n\t\t\t<div class=\"dhx_alert__content\">" + props.text + "</div>\n\t\t\t<div class=\"dhx_alert__footer " + (props.buttonsAlignment ? ("dhx_alert__footer--" + props.buttonsAlignment) : "") + "\">\n\t\t\t\t<button class=\"dhx_alert__confirm-reject dhx_button dhx_button--type_link dhx_button--color_primary dhx_button--size_medium\">" + reject + "</button>\n\t\t\t\t<button class=\"dhx_alert__confirm-aply dhx_button dhx_button--type_flat dhx_button--color_primary dhx_button--size_medium\">" + apply + "</button>\n\t\t\t</div>";
  7679. document.body.appendChild(confirmBox);
  7680. confirmBox.querySelector(".dhx_alert__confirm-reject").focus();
  7681. var clickHandler = function (e) {
  7682. if (e.target.tagName === "BUTTON") {
  7683. answer(e.target.classList.contains("dhx_alert__confirm-aply"));
  7684. }
  7685. };
  7686. confirmBox.addEventListener("click", clickHandler);
  7687. });
  7688. }
  7689. exports.confirm = confirm;
  7690. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(13)))
  7691. /***/ }),
  7692. /* 67 */
  7693. /***/ (function(module, exports, __webpack_require__) {
  7694. "use strict";
  7695. Object.defineProperty(exports, "__esModule", { value: true });
  7696. var locale = {
  7697. apply: "apply",
  7698. reject: "reject"
  7699. };
  7700. exports.default = locale;
  7701. /***/ }),
  7702. /* 68 */
  7703. /***/ (function(module, exports, __webpack_require__) {
  7704. "use strict";
  7705. Object.defineProperty(exports, "__esModule", { value: true });
  7706. var html_1 = __webpack_require__(1);
  7707. var message_1 = __webpack_require__(29);
  7708. var SHOW_DELAY = 750;
  7709. var HIDE_DELAY = 200;
  7710. var RealPosition;
  7711. (function (RealPosition) {
  7712. RealPosition["left"] = "left";
  7713. RealPosition["right"] = "right";
  7714. RealPosition["top"] = "top";
  7715. RealPosition["bottom"] = "bottom";
  7716. RealPosition["center"] = "center";
  7717. })(RealPosition = exports.RealPosition || (exports.RealPosition = {}));
  7718. function findPosition(targetRect, position, width, height) {
  7719. var margin = 8; // margin top/bot, left/right
  7720. var pos;
  7721. var left;
  7722. var top;
  7723. switch (position) {
  7724. case message_1.Position.center:
  7725. left = targetRect.left + window.pageXOffset + (targetRect.width - width) / 2;
  7726. if (left + margin < window.pageXOffset) {
  7727. left = targetRect.left + window.pageXOffset;
  7728. }
  7729. top = targetRect.top + window.pageYOffset + (targetRect.height - height) / 2;
  7730. pos = RealPosition.center;
  7731. return { left: left, top: top, pos: pos };
  7732. case message_1.Position.right:
  7733. pos = RealPosition.right;
  7734. left = targetRect.right + window.pageXOffset;
  7735. if (left + width + margin > window.innerWidth + window.pageXOffset) { // set left
  7736. left = window.pageXOffset + targetRect.left - width;
  7737. pos = RealPosition.left;
  7738. }
  7739. top = window.pageYOffset + targetRect.top + (targetRect.height - height) / 2;
  7740. return { left: left, top: top, pos: pos };
  7741. case message_1.Position.bottom:
  7742. left = window.pageXOffset + targetRect.left + (targetRect.width - width) / 2;
  7743. if (left + width > window.innerWidth + window.pageXOffset) {
  7744. left = window.innerWidth + window.pageXOffset - width;
  7745. }
  7746. else if (left < 0) {
  7747. left = 0;
  7748. }
  7749. pos = RealPosition.bottom;
  7750. top = window.pageYOffset + targetRect.bottom;
  7751. if (top + height + margin > window.innerHeight + window.pageYOffset) { // set top
  7752. top = window.pageYOffset + targetRect.top - height;
  7753. pos = RealPosition.top;
  7754. }
  7755. return { left: left, top: top, pos: pos };
  7756. }
  7757. }
  7758. exports.findPosition = findPosition;
  7759. // tooltip init
  7760. var tooltipBox = document.createElement("div");
  7761. var tooltipText = document.createElement("span");
  7762. tooltipText.className = "dhx_tooltip__text";
  7763. tooltipBox.appendChild(tooltipText);
  7764. tooltipBox.style.position = "absolute";
  7765. var lastNode = null;
  7766. var isActive = false;
  7767. var hideTimeout = null;
  7768. var showTimeout = null;
  7769. var activeListenersDestructor;
  7770. function showTooltip(node, text, position, css, force) {
  7771. if (force === void 0) { force = false; }
  7772. var rects = node.getBoundingClientRect();
  7773. tooltipText.textContent = text;
  7774. document.body.appendChild(tooltipBox);
  7775. tooltipBox.className = "dhx_tooltip" + (force ? " dhx_tooltip--forced" : "");
  7776. var _a = tooltipBox.getBoundingClientRect(), width = _a.width, height = _a.height;
  7777. var _b = findPosition(rects, position, width, height), left = _b.left, top = _b.top, pos = _b.pos;
  7778. switch (pos) {
  7779. case RealPosition.bottom:
  7780. tooltipBox.style.left = left + "px";
  7781. tooltipBox.style.top = top + "px";
  7782. break;
  7783. case RealPosition.top:
  7784. tooltipBox.style.left = left + "px";
  7785. tooltipBox.style.top = top + "px";
  7786. break;
  7787. case RealPosition.left:
  7788. tooltipBox.style.left = left + "px";
  7789. tooltipBox.style.top = top + "px";
  7790. break;
  7791. case RealPosition.right:
  7792. tooltipBox.style.left = left + "px";
  7793. tooltipBox.style.top = top + "px";
  7794. break;
  7795. case RealPosition.center:
  7796. tooltipBox.style.left = left + "px";
  7797. tooltipBox.style.top = top + "px";
  7798. break;
  7799. }
  7800. tooltipBox.className += " dhx_tooltip--" + pos + " " + (css || "");
  7801. isActive = true;
  7802. if (!force) {
  7803. setTimeout(function () {
  7804. tooltipBox.className += " dhx_tooltip--animate";
  7805. });
  7806. }
  7807. }
  7808. function hideTooltip() {
  7809. if (lastNode) {
  7810. hideTimeout = setTimeout(function () {
  7811. document.body.removeChild(tooltipBox);
  7812. isActive = false;
  7813. hideTimeout = null;
  7814. }, HIDE_DELAY);
  7815. }
  7816. }
  7817. function addListeners(node, text, position, css, force) {
  7818. if (force === void 0) { force = false; }
  7819. if (!force) {
  7820. showTimeout = setTimeout(function () {
  7821. showTooltip(node, text, position, css);
  7822. }, SHOW_DELAY);
  7823. }
  7824. var hide = function () {
  7825. if (isActive) {
  7826. hideTooltip();
  7827. }
  7828. clearTimeout(showTimeout);
  7829. node.removeEventListener("mouseleave", hide);
  7830. node.removeEventListener("blur", hide);
  7831. document.removeEventListener("mousedown", hide);
  7832. lastNode = null;
  7833. activeListenersDestructor = null;
  7834. };
  7835. if (force) {
  7836. showTooltip(node, text, position, css, force);
  7837. }
  7838. node.addEventListener("mouseleave", hide);
  7839. node.addEventListener("blur", hide);
  7840. document.addEventListener("mousedown", hide);
  7841. activeListenersDestructor = hide;
  7842. }
  7843. // default
  7844. function tooltip(text, config) {
  7845. var node = html_1.toNode(config.node);
  7846. if (node === lastNode) {
  7847. return;
  7848. }
  7849. if (activeListenersDestructor) {
  7850. activeListenersDestructor();
  7851. activeListenersDestructor = null;
  7852. }
  7853. lastNode = node;
  7854. if (hideTimeout) {
  7855. clearTimeout(hideTimeout);
  7856. hideTimeout = null;
  7857. addListeners(node, text, config.position, config.css, true);
  7858. }
  7859. else {
  7860. addListeners(node, text, config.position || message_1.Position.bottom, config.css, config.force);
  7861. }
  7862. }
  7863. exports.tooltip = tooltip;
  7864. function enableTooltip() {
  7865. document.addEventListener("mousemove", _mousemove);
  7866. }
  7867. exports.enableTooltip = enableTooltip;
  7868. function disableTooltip() {
  7869. document.removeEventListener("mousemove", _mousemove);
  7870. }
  7871. exports.disableTooltip = disableTooltip;
  7872. function _mousemove(e) {
  7873. var node = html_1.locateNode(e, "dhx_tooltip_text");
  7874. if (!node) {
  7875. return;
  7876. }
  7877. tooltip(node.getAttribute("dhx_tooltip_text"), {
  7878. position: node.getAttribute("dhx_tooltip_position") || message_1.Position.bottom,
  7879. node: node
  7880. });
  7881. }
  7882. /***/ }),
  7883. /* 69 */
  7884. /***/ (function(module, exports, __webpack_require__) {
  7885. "use strict";
  7886. Object.defineProperty(exports, "__esModule", { value: true });
  7887. var types_1 = __webpack_require__(2);
  7888. function listenCompositionEvents(events, isActive) {
  7889. var compositionStart = function (e) {
  7890. if (isActive()) {
  7891. events.fire(types_1.RichTextEvents.compositionStart);
  7892. }
  7893. };
  7894. var compositionEnd = function (e) {
  7895. if (isActive()) {
  7896. events.fire(types_1.RichTextEvents.compositionEnd, [e.data]);
  7897. }
  7898. };
  7899. var compositionUpdate = function (e) {
  7900. if (isActive()) {
  7901. events.fire(types_1.RichTextEvents.compositionUpdate, [e.data]);
  7902. }
  7903. };
  7904. document.addEventListener("compositionstart", compositionStart);
  7905. document.addEventListener("compositionend", compositionEnd);
  7906. document.addEventListener("compositionupdate", compositionUpdate);
  7907. return function () {
  7908. document.removeEventListener("compositionstart", compositionStart);
  7909. document.removeEventListener("compositionend", compositionEnd);
  7910. document.removeEventListener("compositionupdate", compositionUpdate);
  7911. };
  7912. }
  7913. exports.listenCompositionEvents = listenCompositionEvents;
  7914. /***/ }),
  7915. /* 70 */
  7916. /***/ (function(module, exports, __webpack_require__) {
  7917. "use strict";
  7918. var __extends = (this && this.__extends) || (function () {
  7919. var extendStatics = Object.setPrototypeOf ||
  7920. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  7921. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7922. return function (d, b) {
  7923. extendStatics(d, b);
  7924. function __() { this.constructor = d; }
  7925. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7926. };
  7927. })();
  7928. var __assign = (this && this.__assign) || Object.assign || function(t) {
  7929. for (var s, i = 1, n = arguments.length; i < n; i++) {
  7930. s = arguments[i];
  7931. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  7932. t[p] = s[p];
  7933. }
  7934. return t;
  7935. };
  7936. Object.defineProperty(exports, "__esModule", { value: true });
  7937. var dom_1 = __webpack_require__(0);
  7938. var html_1 = __webpack_require__(1);
  7939. var view_1 = __webpack_require__(8);
  7940. var ts_message_1 = __webpack_require__(28);
  7941. var ts_popup_1 = __webpack_require__(18);
  7942. var keyhandler_1 = __webpack_require__(31);
  7943. var en_1 = __webpack_require__(11);
  7944. var types_1 = __webpack_require__(2);
  7945. var other_1 = __webpack_require__(4);
  7946. var LinkEditor = /** @class */ (function (_super) {
  7947. __extends(LinkEditor, _super);
  7948. function LinkEditor(container, config) {
  7949. var _this = _super.call(this, container, config) || this;
  7950. _this._events = config.events;
  7951. _this._editor = config.editor;
  7952. _this._getParentView = config.getRootView;
  7953. _this._popup = new ts_popup_1.Popup();
  7954. _this._initEvents();
  7955. _this._handlers = {
  7956. onclick: {
  7957. ".dhx_richtext-linkeditor--handler_apply": function () { return _this._apply(); },
  7958. ".dhx_richtext-linkeditor--handler_unlink, .dhx_richtext-linkeditor--handler_unlink *": function () {
  7959. _this._events.fire(types_1.RichTextEvents.action, [
  7960. types_1.Action.update,
  7961. {
  7962. modifier: types_1.Modifier.link,
  7963. modifierValue: undefined
  7964. },
  7965. true
  7966. ]);
  7967. _this._popup.hide();
  7968. },
  7969. ".dhx_richtext-linkeditor--handler_edit, .dhx_richtext-linkeditor--handler_edit *": function () {
  7970. _this._editMode = true;
  7971. _this.paint();
  7972. setTimeout(function () { return _this.focus(); }, 10);
  7973. }
  7974. },
  7975. onmouseover: function (e) {
  7976. var node = html_1.locateNode(e, "dhx_id");
  7977. if (node) {
  7978. ts_message_1.tooltip(en_1.default[node.getAttribute("dhx_id")], {
  7979. node: node,
  7980. position: ts_message_1.Position.bottom
  7981. });
  7982. }
  7983. },
  7984. oninput: function (e) {
  7985. var value = e.target.value;
  7986. if (e.target.classList.contains("link-input")) {
  7987. if (!_this._link && value) {
  7988. _this._link = value;
  7989. _this.paint();
  7990. }
  7991. else if (!value) {
  7992. _this._link = value;
  7993. _this.paint();
  7994. }
  7995. else {
  7996. _this._link = value;
  7997. }
  7998. }
  7999. else {
  8000. _this._text = value;
  8001. }
  8002. },
  8003. onkeydown: function (e) {
  8004. if (e.which === keyhandler_1.Key.enter && _this._link) {
  8005. _this._apply();
  8006. }
  8007. if (e.which === keyhandler_1.Key.esc) {
  8008. _this._popup.hide();
  8009. }
  8010. }
  8011. };
  8012. _this.mount(null, dom_1.create({ render: function () { return _this._draw(); } }));
  8013. _this._popup.attach(_this);
  8014. return _this;
  8015. }
  8016. LinkEditor.prototype.isVisible = function () {
  8017. return this._popup.isVisible();
  8018. };
  8019. LinkEditor.prototype.show = function (node, mode) {
  8020. var _this = this;
  8021. this._popup.show(node, { mode: mode, centering: true });
  8022. setTimeout(function () { return _this.focus(); }, 10);
  8023. };
  8024. LinkEditor.prototype.hide = function () {
  8025. this._popup.hide();
  8026. };
  8027. LinkEditor.prototype.get = function () {
  8028. return {
  8029. link: this._link,
  8030. text: this._text
  8031. };
  8032. };
  8033. LinkEditor.prototype.getCurrentLinkRef = function () {
  8034. return this._currentLinkRef;
  8035. };
  8036. LinkEditor.prototype.set = function (link, text) {
  8037. this._editMode = !link;
  8038. this._link = link || "";
  8039. this._text = text || "";
  8040. this._initText = this._text;
  8041. this.paint();
  8042. };
  8043. LinkEditor.prototype.focus = function () {
  8044. var refs = this.getRootView().refs;
  8045. if (refs && refs.linkInput) {
  8046. refs.linkInput.el.focus();
  8047. }
  8048. };
  8049. LinkEditor.prototype._destroyCurrentLinkRef = function () {
  8050. if (this._currentLinkRef) {
  8051. this._getParentView().refs[this._currentLinkRef].patch({ class: "" });
  8052. this._currentLinkRef = null;
  8053. }
  8054. };
  8055. LinkEditor.prototype._initEvents = function () {
  8056. var _this = this;
  8057. this._popup.events.on(ts_popup_1.PopupEvents.beforeHide, function (outer, e) { return !outer || !_this._getParentView().node.el.contains(e.target); });
  8058. this._popup.events.on(ts_popup_1.PopupEvents.afterHide, function () { return _this._destroyCurrentLinkRef(); });
  8059. this._popup.events.on(ts_popup_1.PopupEvents.afterShow, function () {
  8060. var left = _this._editor.selection.get().left;
  8061. var key = other_1.getTextHash(left.blockIndex, left.textIndex);
  8062. var parentView = _this._getParentView();
  8063. var vnode = parentView.refs[key];
  8064. vnode.parent.patch({ class: "dhx--link_edited" });
  8065. _this._currentLinkRef = vnode.parent.ref;
  8066. });
  8067. this._events.on(types_1.RichTextEvents.selectionChange, function (_a) {
  8068. var range = _a.range, left = _a.left;
  8069. var textNode = _this._editor.blocks[left.blockIndex].textNodes[left.textIndex];
  8070. if (_this.isVisible()) {
  8071. _this.hide();
  8072. }
  8073. if (textNode.style.link && !range) {
  8074. _this._show();
  8075. }
  8076. });
  8077. this._events.on(types_1.RichTextEvents.showLinkEditor, function () { return _this._show(); });
  8078. this._events.on(types_1.RichTextEvents.change, function () {
  8079. if (_this.isVisible()) {
  8080. var _a = _this._editor.selection.get(), left = _a.left, range = _a.range;
  8081. var textNode = _this._editor.blocks[left.blockIndex].textNodes[left.textIndex];
  8082. if (!textNode.style.link || range) {
  8083. _this.hide();
  8084. }
  8085. else {
  8086. var _b = _this._editor.getLinkInfo(), link = _b.link, text = _b.text;
  8087. _this.set(link, text);
  8088. }
  8089. }
  8090. });
  8091. };
  8092. LinkEditor.prototype._draw = function () {
  8093. return dom_1.el(".dhx_richtext-linkeditor " + (this._drawViewMode() ? ".dhx_richtext-linkeditor--mode_view" : ""), __assign({}, this._handlers), this._editMode ? this._drawEditMode() : this._drawViewMode());
  8094. };
  8095. LinkEditor.prototype._drawEditMode = function () {
  8096. return [
  8097. dom_1.el(".dhx_richtext-linkeditor__inputs", [
  8098. dom_1.el(".dhx_form-group.dhx_form-group--type_inline.dhx_richtext-linkeditor__input", [
  8099. dom_1.el(".dhx_label", "Text"),
  8100. dom_1.el("input.dhx_input.text-input", {
  8101. value: this._text,
  8102. _key: "textInput",
  8103. _ref: "textInput"
  8104. }),
  8105. ]),
  8106. dom_1.el(".dhx_form-group.dhx_form-group--type_inline.dhx_richtext-linkeditor__input", [
  8107. dom_1.el(".dhx_label", "Link"),
  8108. dom_1.el("input.dhx_input.link-input", {
  8109. value: this._link,
  8110. _key: "linkInput",
  8111. _ref: "linkInput"
  8112. }),
  8113. ])
  8114. ]),
  8115. dom_1.el(".dhx_richtext-linkeditor__controls", [
  8116. dom_1.el("button.dhx_richtext-linkeditor--handler_apply.dhx_button.dhx_button--size_medium.dhx_button--type_flat.dhx_button--color_primary", {
  8117. disabled: !this._link,
  8118. }, en_1.default.apply)
  8119. ])
  8120. ];
  8121. };
  8122. LinkEditor.prototype._drawViewMode = function () {
  8123. return [
  8124. dom_1.el("a.dhx_richtext-linkeditor__link", { href: this._link, target: "_blank" }, this._link),
  8125. dom_1.el(".dhx_richtext-linkeditor__controls", [
  8126. dom_1.el("button.dhx_richtext-linkeditor--handler_edit.dhx_button.dhx_button--icon.dhx_button--size_medium.dhx_button--type_link.dhx_button--color_secondary", {
  8127. dhx_id: "edit"
  8128. }, [
  8129. dom_1.el("span.dhx_button__icon.dxi.dxi-pencil")
  8130. ]),
  8131. dom_1.el("button.dhx_richtext-linkeditor--handler_unlink.dhx_button.dhx_button--icon.dhx_button--size_medium.dhx_button--type_link.dhx_button--color_secondary", {
  8132. dhx_id: "removeLink"
  8133. }, [
  8134. dom_1.el("span.dhx_button__icon.dxi.dxi-link-variant-off")
  8135. ]),
  8136. ])
  8137. ];
  8138. };
  8139. LinkEditor.prototype._modifyLink = function (value) {
  8140. if (value[0] === "#") {
  8141. return value;
  8142. }
  8143. if (value.slice(0, 4).toLowerCase() === "http") {
  8144. return value;
  8145. }
  8146. return "http://" + value;
  8147. };
  8148. LinkEditor.prototype._apply = function () {
  8149. var link = this._modifyLink(this._link);
  8150. var text = this._text;
  8151. var isEmptyText = !text.trim();
  8152. var isTextChanged = this._initText !== this._text;
  8153. if (isTextChanged || isEmptyText) {
  8154. this._editor.updateLinkText(isEmptyText ? link : text);
  8155. }
  8156. if (link) {
  8157. this._events.fire(types_1.RichTextEvents.action, [
  8158. types_1.Action.update,
  8159. {
  8160. modifier: types_1.Modifier.link,
  8161. modifierValue: link
  8162. },
  8163. true
  8164. ]);
  8165. }
  8166. this.hide();
  8167. };
  8168. LinkEditor.prototype._show = function () {
  8169. var _a = this._editor.getLinkInfo(), link = _a.link, text = _a.text;
  8170. var left = this._editor.selection.get().left;
  8171. var key = other_1.getTextHash(left.blockIndex, left.textIndex);
  8172. var parentView = this._getParentView();
  8173. var vnode = parentView.refs[key];
  8174. if (!link) { // case for add new link
  8175. this.set(null, this._editor.selection.getSelectedText());
  8176. this.show(vnode.el, ts_message_1.Position.bottom);
  8177. }
  8178. else { // link already exists
  8179. if (vnode.parent.ref === this._currentLinkRef) { // this link already in focus
  8180. return;
  8181. }
  8182. this.set(link, text);
  8183. this.show(vnode.parent.el, ts_message_1.Position.bottom);
  8184. }
  8185. };
  8186. return LinkEditor;
  8187. }(view_1.View));
  8188. exports.LinkEditor = LinkEditor;
  8189. /***/ }),
  8190. /* 71 */
  8191. /***/ (function(module, exports, __webpack_require__) {
  8192. "use strict";
  8193. var __extends = (this && this.__extends) || (function () {
  8194. var extendStatics = Object.setPrototypeOf ||
  8195. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  8196. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  8197. return function (d, b) {
  8198. extendStatics(d, b);
  8199. function __() { this.constructor = d; }
  8200. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8201. };
  8202. })();
  8203. var __assign = (this && this.__assign) || Object.assign || function(t) {
  8204. for (var s, i = 1, n = arguments.length; i < n; i++) {
  8205. s = arguments[i];
  8206. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  8207. t[p] = s[p];
  8208. }
  8209. return t;
  8210. };
  8211. Object.defineProperty(exports, "__esModule", { value: true });
  8212. var core_1 = __webpack_require__(3);
  8213. var dom_1 = __webpack_require__(0);
  8214. var events_1 = __webpack_require__(7);
  8215. var html_1 = __webpack_require__(1);
  8216. var view_1 = __webpack_require__(8);
  8217. var types_1 = __webpack_require__(30);
  8218. var Popup = /** @class */ (function (_super) {
  8219. __extends(Popup, _super);
  8220. function Popup(config) {
  8221. if (config === void 0) { config = {}; }
  8222. var _this = _super.call(this, null, core_1.extend({}, config)) || this;
  8223. var popup = _this._popup = document.createElement("div");
  8224. // [todo] remove one of "popup" classes
  8225. popup.className = "dhx_popup dhx_widget";
  8226. popup.style.position = "absolute";
  8227. _this.mount(popup, dom_1.create({
  8228. render: function () { return _this.toVDOM(); }
  8229. }));
  8230. _this.events = config.events || new events_1.EventSystem();
  8231. _this._isActive = false;
  8232. return _this;
  8233. }
  8234. Popup.prototype.show = function (node, config, attached) {
  8235. var _this = this;
  8236. if (config === void 0) { config = {}; }
  8237. if (this.events.fire(types_1.PopupEvents.beforeShow) === false) {
  8238. return;
  8239. }
  8240. if (this._isActive) {
  8241. this._setPopupSize(node, config);
  8242. return;
  8243. }
  8244. if (attached) {
  8245. this.attach(attached);
  8246. }
  8247. setTimeout(function () {
  8248. document.body.appendChild(_this._popup);
  8249. _this._setPopupSize(node, config);
  8250. _this._isActive = true;
  8251. _this.events.fire(types_1.PopupEvents.afterShow);
  8252. _this._outerClickDestructor = _this._detectOuterClick(node);
  8253. });
  8254. };
  8255. Popup.prototype.hide = function () {
  8256. this._hide(false, null);
  8257. };
  8258. Popup.prototype.isVisible = function () {
  8259. return this._isActive;
  8260. };
  8261. Popup.prototype.attach = function (name, config) {
  8262. this._html = null;
  8263. if (typeof name === "object") {
  8264. this._ui = name;
  8265. }
  8266. else if (typeof name === "string") {
  8267. this._ui = new window.dhx[name](null, config);
  8268. }
  8269. else if (typeof name === "function") {
  8270. if (name.prototype instanceof view_1.View) {
  8271. this._ui = new name(null, config);
  8272. }
  8273. else {
  8274. this._ui = {
  8275. getRootView: function () {
  8276. return name(config);
  8277. }
  8278. };
  8279. }
  8280. }
  8281. this.paint();
  8282. return this._ui;
  8283. };
  8284. Popup.prototype.attachHTML = function (html) {
  8285. this._html = html;
  8286. this.paint();
  8287. };
  8288. Popup.prototype.getWidget = function () {
  8289. return this._ui;
  8290. };
  8291. Popup.prototype.getContainer = function () {
  8292. return this.getRootView().refs.content.el;
  8293. };
  8294. Popup.prototype.toVDOM = function () {
  8295. var view;
  8296. if (this._html) {
  8297. view = dom_1.el(".dhx_popup__inner-html-content", {
  8298. ".innerHTML": this._html
  8299. });
  8300. }
  8301. else {
  8302. view = this._ui ? this._ui.getRootView() : null;
  8303. if (view && view.render) {
  8304. view = dom_1.inject(view);
  8305. }
  8306. }
  8307. return dom_1.el("div", {
  8308. class: "dhx_popup-content " + (this.config.css || ""),
  8309. _key: this._uid,
  8310. _ref: "content"
  8311. }, [view]);
  8312. };
  8313. Popup.prototype._setPopupSize = function (node, config) {
  8314. var _this = this;
  8315. var _a = this._popup.getBoundingClientRect(), width = _a.width, height = _a.height;
  8316. if (width === 0 || height === 0) {
  8317. if (this._timeout) {
  8318. clearTimeout(this._timeout);
  8319. }
  8320. this._timeout = setTimeout(function () {
  8321. if (!_this._isActive) {
  8322. return;
  8323. }
  8324. _this._setPopupSize(node, config);
  8325. _this._timeout = null;
  8326. });
  8327. }
  8328. var _b = html_1.fitPosition(node, __assign({}, config, { width: width, height: height })), left = _b.left, top = _b.top;
  8329. this._popup.style.left = left;
  8330. this._popup.style.top = top;
  8331. };
  8332. Popup.prototype._detectOuterClick = function (node) {
  8333. var _this = this;
  8334. var outerClick = function (e) {
  8335. var target = e.target;
  8336. while (target) {
  8337. if (target === node || target === _this._popup) {
  8338. return;
  8339. }
  8340. target = target.parentNode;
  8341. }
  8342. if (_this._hide(true, e)) {
  8343. document.removeEventListener("click", outerClick);
  8344. }
  8345. };
  8346. document.addEventListener("click", outerClick);
  8347. return function () { return document.removeEventListener("click", outerClick); };
  8348. };
  8349. Popup.prototype._hide = function (fromOuterClick, e) {
  8350. if (this._isActive) {
  8351. if (this.events.fire(types_1.PopupEvents.beforeHide, [fromOuterClick, e]) === false) {
  8352. return false;
  8353. }
  8354. document.body.removeChild(this._popup);
  8355. this._isActive = false;
  8356. if (this._outerClickDestructor) {
  8357. this._outerClickDestructor();
  8358. this._outerClickDestructor = null;
  8359. }
  8360. this.events.fire(types_1.PopupEvents.afterHide);
  8361. return true;
  8362. }
  8363. };
  8364. return Popup;
  8365. }(view_1.View));
  8366. exports.Popup = Popup;
  8367. /***/ }),
  8368. /* 72 */
  8369. /***/ (function(module, exports, __webpack_require__) {
  8370. "use strict";
  8371. Object.defineProperty(exports, "__esModule", { value: true });
  8372. function createScrollHelper(element) {
  8373. var scrollHeight = element.scrollHeight;
  8374. var scrollTop = element.scrollTop;
  8375. return {
  8376. update: function () {
  8377. var newScrollHeight = element.scrollHeight;
  8378. if (newScrollHeight > scrollHeight) {
  8379. element.scrollTop += newScrollHeight - scrollHeight;
  8380. }
  8381. scrollHeight = newScrollHeight;
  8382. },
  8383. saveScrollTop: function () {
  8384. scrollTop = element.scrollTop;
  8385. },
  8386. restoreScrollTop: function () {
  8387. element.scrollTop = scrollTop;
  8388. }
  8389. };
  8390. }
  8391. exports.createScrollHelper = createScrollHelper;
  8392. /***/ }),
  8393. /* 73 */
  8394. /***/ (function(module, exports, __webpack_require__) {
  8395. "use strict";
  8396. var __assign = (this && this.__assign) || Object.assign || function(t) {
  8397. for (var s, i = 1, n = arguments.length; i < n; i++) {
  8398. s = arguments[i];
  8399. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  8400. t[p] = s[p];
  8401. }
  8402. return t;
  8403. };
  8404. Object.defineProperty(exports, "__esModule", { value: true });
  8405. var _a;
  8406. var ts_colorpicker_1 = __webpack_require__(74);
  8407. var html_1 = __webpack_require__(1);
  8408. var ts_popup_1 = __webpack_require__(18);
  8409. var ts_toolbar_1 = __webpack_require__(21);
  8410. var constants_1 = __webpack_require__(5);
  8411. var other_1 = __webpack_require__(4);
  8412. var en_1 = __webpack_require__(11);
  8413. var types_1 = __webpack_require__(2);
  8414. var statistics_1 = __webpack_require__(32);
  8415. var styles_1 = __webpack_require__(19);
  8416. // move to richtext config
  8417. var defaultStyle = (_a = {},
  8418. // textnode style
  8419. _a[types_1.Modifier.fontFamily] = "Roboto",
  8420. _a[types_1.Modifier.fontSize] = "14px",
  8421. _a[types_1.Modifier.color] = "#4D4D4D",
  8422. _a[types_1.Modifier.background] = "#FFFFFF",
  8423. _a[types_1.Modifier.bold] = false,
  8424. _a[types_1.Modifier.italic] = false,
  8425. _a[types_1.Modifier.strike] = false,
  8426. _a[types_1.Modifier.underline] = false,
  8427. // block style
  8428. _a[types_1.Modifier.style] = "p",
  8429. _a[types_1.Modifier.blockquote] = false,
  8430. _a[types_1.Modifier.align] = "left",
  8431. _a);
  8432. var RichTextToolbarHelper = /** @class */ (function () {
  8433. function RichTextToolbarHelper(parent, editor) {
  8434. var _this = this;
  8435. this._parent = parent;
  8436. this._editor = editor;
  8437. this.colorpicker = new ts_colorpicker_1.Colorpicker();
  8438. this._statsPopup = new ts_popup_1.Popup();
  8439. this._parent.events.on(types_1.RichTextEvents.change, function () {
  8440. if (_this._statsPopup.isVisible()) {
  8441. _this._statsPopup.hide();
  8442. }
  8443. });
  8444. var toolbarBlocks = parent.config.toolbarBlocks;
  8445. this.toolbar = new ts_toolbar_1.Toolbar(null, { css: "dhx_toolbar--bordered.dhx_toolbar--bg_gray" });
  8446. this.toolbar.data.parse(constants_1.getToolbarData(toolbarBlocks, defaultStyle));
  8447. this._defaultToolbarState = {};
  8448. for (var _i = 0, toolbarBlocks_1 = toolbarBlocks; _i < toolbarBlocks_1.length; _i++) {
  8449. var block = toolbarBlocks_1[_i];
  8450. switch (block) {
  8451. case types_1.RTEToolbarBlock.align:
  8452. this._defaultToolbarState[types_1.Modifier.align] = defaultStyle[types_1.Modifier.align];
  8453. break;
  8454. case types_1.RTEToolbarBlock.color:
  8455. this._defaultToolbarState[types_1.Modifier.color] = defaultStyle[types_1.Modifier.color];
  8456. this._defaultToolbarState[types_1.Modifier.background] = defaultStyle[types_1.Modifier.background];
  8457. break;
  8458. case types_1.RTEToolbarBlock.decoration:
  8459. this._defaultToolbarState[types_1.Modifier.bold] = defaultStyle[types_1.Modifier.bold];
  8460. this._defaultToolbarState[types_1.Modifier.italic] = defaultStyle[types_1.Modifier.italic];
  8461. this._defaultToolbarState[types_1.Modifier.underline] = defaultStyle[types_1.Modifier.underline];
  8462. this._defaultToolbarState[types_1.Modifier.strike] = defaultStyle[types_1.Modifier.strike];
  8463. break;
  8464. case types_1.RTEToolbarBlock.style:
  8465. this._defaultToolbarState[types_1.Modifier.style] = defaultStyle[types_1.Modifier.style];
  8466. this._defaultToolbarState[types_1.Modifier.fontFamily] = defaultStyle[types_1.Modifier.fontFamily];
  8467. this._defaultToolbarState[types_1.Modifier.fontSize] = defaultStyle[types_1.Modifier.fontSize];
  8468. this._defaultToolbarState[types_1.Modifier.blockquote] = defaultStyle[types_1.Modifier.blockquote];
  8469. break;
  8470. }
  8471. }
  8472. this._initEvents();
  8473. }
  8474. RichTextToolbarHelper.prototype._initEvents = function () {
  8475. var _this = this;
  8476. this._parent.events.on(types_1.RichTextEvents.selectionChange, function () {
  8477. _this._updateState();
  8478. });
  8479. this._parent.events.on(types_1.RichTextEvents.change, function (action, canUndo, canRedo) {
  8480. if (_this._parent.config.toolbarBlocks.indexOf(types_1.RTEToolbarBlock.undo) !== -1) {
  8481. _this._updateUndoRedoState(canUndo, canRedo);
  8482. }
  8483. if (action !== types_1.Action.update) {
  8484. _this._updateState();
  8485. }
  8486. });
  8487. this.colorpicker.events.on(ts_colorpicker_1.ColorpickerEvents.colorChange, function (color) {
  8488. _this._parent.events.fire(types_1.RichTextEvents.action, [
  8489. types_1.Action.update,
  8490. {
  8491. modifier: _this._colorpickerTarget,
  8492. modifierValue: color
  8493. },
  8494. true
  8495. ]);
  8496. _this.toolbar.data.update(_this._colorpickerTarget, {
  8497. html: _this._colorpickerTarget === types_1.Modifier.color ? other_1.textColor(color) : other_1.textSelectColor(color)
  8498. });
  8499. });
  8500. this.toolbar.events.on(ts_toolbar_1.NavigationBarEvents.click, function (id, e) { return _this._toolbarAction(id, e); });
  8501. };
  8502. RichTextToolbarHelper.prototype._toolbarAction = function (id, e) {
  8503. var item = this.toolbar.data.getItem(id);
  8504. var active = !item.active;
  8505. switch (id) {
  8506. case "bold":
  8507. this._parent.events.fire(types_1.RichTextEvents.action, [
  8508. types_1.Action.update,
  8509. {
  8510. modifier: types_1.Modifier.bold,
  8511. modifierValue: active
  8512. },
  8513. true
  8514. ]);
  8515. this.toolbar.data.update("bold", { active: active });
  8516. break;
  8517. case "underline":
  8518. this._parent.events.fire(types_1.RichTextEvents.action, [
  8519. types_1.Action.update,
  8520. {
  8521. modifier: types_1.Modifier.underline,
  8522. modifierValue: active
  8523. },
  8524. true
  8525. ]);
  8526. this.toolbar.data.update("underline", { active: active });
  8527. break;
  8528. case "italic":
  8529. this._parent.events.fire(types_1.RichTextEvents.action, [
  8530. types_1.Action.update,
  8531. {
  8532. modifier: types_1.Modifier.italic,
  8533. modifierValue: active
  8534. },
  8535. true
  8536. ]);
  8537. this.toolbar.data.update("italic", { active: active });
  8538. break;
  8539. case "strike":
  8540. this._parent.events.fire(types_1.RichTextEvents.action, [
  8541. types_1.Action.update,
  8542. {
  8543. modifier: types_1.Modifier.strike,
  8544. modifierValue: active
  8545. },
  8546. true
  8547. ]);
  8548. this.toolbar.data.update("strike", { active: active });
  8549. break;
  8550. case "color":
  8551. case "background":
  8552. this._colorpickerTarget = id === types_1.Modifier.background ? types_1.Modifier.background : types_1.Modifier.color;
  8553. var currentColor = this._getColorState(this._colorpickerTarget);
  8554. this.colorpicker.setValue(currentColor);
  8555. this.colorpicker.paint();
  8556. this.colorpicker.show(html_1.locateNode(e.target, "dhx_id"), html_1.Position.bottom);
  8557. break;
  8558. case "link":
  8559. e.stopPropagation();
  8560. this._parent.events.fire(types_1.RichTextEvents.showLinkEditor);
  8561. break;
  8562. case "redo":
  8563. this._parent.events.fire(types_1.RichTextEvents.action, [types_1.Action.redo, null, true]);
  8564. break;
  8565. case "undo":
  8566. this._parent.events.fire(types_1.RichTextEvents.action, [types_1.Action.undo, null, true]);
  8567. break;
  8568. case "clear-style":
  8569. this._parent.events.fire(types_1.RichTextEvents.action, [types_1.Action.clear, null, true]);
  8570. break;
  8571. case "blockquote":
  8572. this._parent.events.fire(types_1.RichTextEvents.action, [
  8573. types_1.Action.update,
  8574. {
  8575. modifier: types_1.Modifier.blockquote,
  8576. modifierValue: active
  8577. },
  8578. true
  8579. ]);
  8580. this.toolbar.data.update("blockquote", { active: active });
  8581. break;
  8582. case "fullscreen":
  8583. if (item.$fullscreen) {
  8584. this._parent.exitFullScreen();
  8585. }
  8586. else {
  8587. this._parent.fullScreen();
  8588. }
  8589. break;
  8590. case "stats":
  8591. var node = html_1.locateNode(e);
  8592. var isRange = this._editor.selection.get().range;
  8593. this._statsPopup.attach(statistics_1.statsRenderer(this._parent.getStats(isRange), this._parent.config.customStats));
  8594. this._statsPopup.show(node, { mode: html_1.Position.bottom, centering: true });
  8595. break;
  8596. default:
  8597. var modifierValue = other_1.actionIdToModifierValue(id);
  8598. switch (true) {
  8599. case other_1.startsWith(id, "font-size"):
  8600. this._parent.events.fire(types_1.RichTextEvents.action, [
  8601. types_1.Action.update,
  8602. {
  8603. modifier: types_1.Modifier.fontSize,
  8604. modifierValue: modifierValue + "px"
  8605. },
  8606. true
  8607. ]);
  8608. this.toolbar.data.update(types_1.Modifier.fontSize, { value: modifierValue + "px" });
  8609. break;
  8610. case other_1.startsWith(id, "align"):
  8611. this._parent.events.fire(types_1.RichTextEvents.action, [
  8612. types_1.Action.update,
  8613. {
  8614. modifier: types_1.Modifier.align,
  8615. modifierValue: modifierValue
  8616. },
  8617. true
  8618. ]);
  8619. this.toolbar.data.update("align-left", { active: modifierValue === "left" });
  8620. this.toolbar.data.update("align-right", { active: modifierValue === "right" });
  8621. this.toolbar.data.update("align-center", { active: modifierValue === "center" });
  8622. break;
  8623. case other_1.startsWith(id, "style"):
  8624. this._parent.events.fire(types_1.RichTextEvents.action, [
  8625. types_1.Action.update,
  8626. {
  8627. modifier: types_1.Modifier.style,
  8628. modifierValue: modifierValue
  8629. },
  8630. true
  8631. ]);
  8632. this.toolbar.data.update(types_1.Modifier.style, { value: en_1.default[modifierValue] });
  8633. break;
  8634. case other_1.startsWith(id, "font"):
  8635. this._parent.events.fire(types_1.RichTextEvents.action, [
  8636. types_1.Action.update,
  8637. {
  8638. modifier: types_1.Modifier.fontFamily,
  8639. modifierValue: other_1.actionIdToModifierValue(id)
  8640. },
  8641. true
  8642. ]);
  8643. this.toolbar.data.update(types_1.Modifier.fontFamily, { value: modifierValue });
  8644. break;
  8645. }
  8646. }
  8647. };
  8648. RichTextToolbarHelper.prototype._updateState = function () {
  8649. var modifiers = this._getCommonModifiers();
  8650. for (var key in modifiers) {
  8651. switch (key) {
  8652. // block modifiers
  8653. case types_1.Modifier.align:
  8654. this.toolbar.data.update("align-left", { active: modifiers[key] === "left" });
  8655. this.toolbar.data.update("align-right", { active: modifiers[key] === "right" });
  8656. this.toolbar.data.update("align-center", { active: modifiers[key] === "center" });
  8657. break;
  8658. case types_1.Modifier.style:
  8659. if (this._parent.config.toolbarBlocks.indexOf(types_1.RTEToolbarBlock.style) !== -1) {
  8660. this.toolbar.data.update(key, { value: en_1.default[modifiers[key]] });
  8661. }
  8662. break;
  8663. case types_1.Modifier.blockquote:
  8664. this.toolbar.data.update("blockquote", { active: modifiers[key] });
  8665. break;
  8666. // text modifiers
  8667. case types_1.Modifier.color:
  8668. this.toolbar.data.update(key, {
  8669. html: other_1.textColor(modifiers[key])
  8670. });
  8671. break;
  8672. case types_1.Modifier.background:
  8673. this.toolbar.data.update(key, {
  8674. html: other_1.textSelectColor(modifiers[key])
  8675. });
  8676. break;
  8677. case types_1.Modifier.fontFamily:
  8678. case types_1.Modifier.fontSize:
  8679. this.toolbar.data.update(key, { value: modifiers[key] });
  8680. break;
  8681. case types_1.Modifier.italic:
  8682. case types_1.Modifier.bold:
  8683. case types_1.Modifier.underline:
  8684. case types_1.Modifier.strike:
  8685. this.toolbar.data.update(key, { active: modifiers[key] });
  8686. break;
  8687. }
  8688. }
  8689. };
  8690. RichTextToolbarHelper.prototype._updateUndoRedoState = function (canUndo, canRedo) {
  8691. if (canUndo) {
  8692. this.toolbar.enable("undo");
  8693. }
  8694. else {
  8695. this.toolbar.disable("undo");
  8696. }
  8697. if (canRedo) {
  8698. this.toolbar.enable("redo");
  8699. }
  8700. else {
  8701. this.toolbar.disable("redo");
  8702. }
  8703. };
  8704. RichTextToolbarHelper.prototype._getCommonModifiers = function () {
  8705. var _this = this;
  8706. var commonTextStyle;
  8707. var commonBlockStyle;
  8708. this._editor.eachSelectedNode(function (node, block) {
  8709. if (!commonTextStyle) {
  8710. commonTextStyle = styles_1.getComputedNodeStyle(node, block, _this._defaultToolbarState);
  8711. return;
  8712. }
  8713. var style = styles_1.getComputedNodeStyle(node, block, _this._defaultToolbarState);
  8714. for (var key in commonTextStyle) {
  8715. if (commonTextStyle[key] !== style[key]) {
  8716. delete commonTextStyle[key];
  8717. }
  8718. }
  8719. });
  8720. this._editor.eachSelectedBlock(function (block) {
  8721. if (!commonBlockStyle) {
  8722. commonBlockStyle = styles_1.getComputedBlockStyle(block, _this._defaultToolbarState);
  8723. return;
  8724. }
  8725. var style = styles_1.getComputedBlockStyle(block, _this._defaultToolbarState);
  8726. for (var key in commonBlockStyle) {
  8727. if (commonBlockStyle[key] !== style[key]) {
  8728. delete commonBlockStyle[key];
  8729. }
  8730. }
  8731. });
  8732. return __assign({}, constants_1.defaultDiffrentStyle, commonBlockStyle, commonTextStyle);
  8733. };
  8734. RichTextToolbarHelper.prototype._getColorState = function (modifier) {
  8735. var defaultColor = defaultStyle[modifier];
  8736. var isSame = true;
  8737. var initColor;
  8738. this._editor.eachSelectedNode(function (node) {
  8739. var color = node.style[modifier] || defaultColor;
  8740. if (!initColor) {
  8741. initColor = color;
  8742. }
  8743. else {
  8744. isSame = isSame && initColor === color;
  8745. }
  8746. });
  8747. return isSame ? initColor : defaultColor;
  8748. };
  8749. return RichTextToolbarHelper;
  8750. }());
  8751. exports.RichTextToolbarHelper = RichTextToolbarHelper;
  8752. /***/ }),
  8753. /* 74 */
  8754. /***/ (function(module, exports, __webpack_require__) {
  8755. "use strict";
  8756. function __export(m) {
  8757. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  8758. }
  8759. Object.defineProperty(exports, "__esModule", { value: true });
  8760. __export(__webpack_require__(75));
  8761. __export(__webpack_require__(33));
  8762. /***/ }),
  8763. /* 75 */
  8764. /***/ (function(module, exports, __webpack_require__) {
  8765. "use strict";
  8766. var __extends = (this && this.__extends) || (function () {
  8767. var extendStatics = Object.setPrototypeOf ||
  8768. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  8769. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  8770. return function (d, b) {
  8771. extendStatics(d, b);
  8772. function __() { this.constructor = d; }
  8773. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8774. };
  8775. })();
  8776. Object.defineProperty(exports, "__esModule", { value: true });
  8777. var dom_1 = __webpack_require__(0);
  8778. var events_1 = __webpack_require__(7);
  8779. var html_1 = __webpack_require__(1);
  8780. var view_1 = __webpack_require__(8);
  8781. var ts_popup_1 = __webpack_require__(18);
  8782. var core_1 = __webpack_require__(3);
  8783. var colorHelpers_1 = __webpack_require__(76);
  8784. var colors_1 = __webpack_require__(77);
  8785. var en_1 = __webpack_require__(78);
  8786. var types_1 = __webpack_require__(33);
  8787. var Colorpicker = /** @class */ (function (_super) {
  8788. __extends(Colorpicker, _super);
  8789. function Colorpicker(config) {
  8790. var _this = _super.call(this, null, config) || this;
  8791. _this._handleGripMove = function (e) {
  8792. var paletteRect = _this.getRootView().refs.picker_palette.el.getBoundingClientRect();
  8793. var top = e.clientY - paletteRect.top;
  8794. var left = e.clientX - paletteRect.left;
  8795. _this._calculatePaletteGrip(top, left);
  8796. _this.paint();
  8797. };
  8798. _this._handleRangeMove = function (e) {
  8799. var rangeRect = _this.getRootView().refs.hue_range.el.getBoundingClientRect();
  8800. var rangeGripWidth = 3;
  8801. var left = e.clientX - rangeRect.left - rangeGripWidth;
  8802. _this._calculateRangeGrip(left);
  8803. _this.paint();
  8804. };
  8805. _this.config = core_1.extend({
  8806. css: "",
  8807. customColors: true
  8808. }, _this.config);
  8809. _this._popup = new ts_popup_1.Popup({
  8810. css: " dhx_colorpicker-popup " + _this.config.css
  8811. });
  8812. _this.events = new events_1.EventSystem(_this);
  8813. _this._pickerState = {
  8814. hsv: { h: 0, s: 1, v: 1 },
  8815. currentView: "palette",
  8816. customColors: [],
  8817. customHex: ""
  8818. };
  8819. _this._handlers = {
  8820. click: {
  8821. ".dhx_palette__cell": _this._onColorClick.bind(_this)
  8822. },
  8823. mousedown: function (e) {
  8824. var name = html_1.locate(e);
  8825. _this._pickerState.customHex = "";
  8826. var target = _this.getRootView().refs[name].el.getBoundingClientRect();
  8827. if (name === "picker_palette") {
  8828. _this._calculatePaletteGrip(e.clientY - target.top, e.clientX - target.left);
  8829. }
  8830. else {
  8831. _this._calculateRangeGrip(e.clientX - target.left);
  8832. }
  8833. var handler = name === "picker_palette" ? _this._handleGripMove : _this._handleRangeMove;
  8834. document.addEventListener("mousemove", handler);
  8835. document.addEventListener("mouseup", function () {
  8836. document.removeEventListener("mousemove", handler);
  8837. });
  8838. _this.paint();
  8839. },
  8840. buttonsClick: function (button) {
  8841. _this._pickerState.currentView = "palette";
  8842. _this.paint();
  8843. if (button === "cancel") {
  8844. return;
  8845. }
  8846. if (button === "apply" && _this._pickerState.customColors.indexOf(_this._pickerState.background) === -1) {
  8847. _this._pickerState.customColors.push(_this._pickerState.background);
  8848. }
  8849. _this._selected = _this._pickerState.background;
  8850. _this.events.fire(types_1.ColorpickerEvents.colorChange, [_this._selected]);
  8851. setTimeout(function () {
  8852. _this._popup.hide();
  8853. }, 1);
  8854. },
  8855. customColorClick: function () {
  8856. _this._pickerState.currentView = "picker";
  8857. _this.paint();
  8858. },
  8859. oninput: function (e) {
  8860. if (_this._inputTimeout) {
  8861. clearTimeout(_this._inputTimeout);
  8862. }
  8863. _this._inputTimeout = setTimeout(function () {
  8864. var val = e.target.value;
  8865. if (val.indexOf("#") === -1) {
  8866. val = "#" + val;
  8867. }
  8868. _this._pickerState.customHex = val;
  8869. if (colorHelpers_1.isHex(val)) {
  8870. _this._pickerState.hsv = colorHelpers_1.HexToHSV(val);
  8871. _this.paint();
  8872. }
  8873. }, 100);
  8874. },
  8875. contextmenu: {
  8876. ".dhx_palette__cell": function (e, node) {
  8877. e.preventDefault();
  8878. var color = _this._pickerState.customColors.indexOf(node.data.color);
  8879. if (color !== -1) {
  8880. _this._pickerState.customColors.splice(color, 1);
  8881. }
  8882. _this.paint();
  8883. return;
  8884. }
  8885. }
  8886. };
  8887. _this._popup.events.on(ts_popup_1.PopupEvents.afterHide, function () {
  8888. _this._pickerState.currentView = "palette";
  8889. });
  8890. var view = dom_1.create({ render: function () { return _this._getContent(); } });
  8891. _this.mount(_this._popup, view);
  8892. return _this;
  8893. }
  8894. Colorpicker.prototype.setValue = function (value) {
  8895. this._selected = value || null;
  8896. };
  8897. Colorpicker.prototype.getValue = function () {
  8898. return this._selected;
  8899. };
  8900. Colorpicker.prototype.show = function (node, side) {
  8901. if (side === void 0) { side = "bottom"; }
  8902. this._popup.show(html_1.toNode(node), { mode: side, centering: true });
  8903. this.paint();
  8904. };
  8905. Colorpicker.prototype.hide = function () {
  8906. this._popup.hide();
  8907. };
  8908. Colorpicker.prototype._calculatePaletteGrip = function (top, left) {
  8909. var paletteRect = this.getRootView().refs.picker_palette.el.getBoundingClientRect();
  8910. var bottom = paletteRect.height;
  8911. var right = paletteRect.width;
  8912. top = top < 0 ? 0 : top > bottom ? bottom : top;
  8913. left = left < 0 ? 0 : left > right ? right : left;
  8914. var pLeft = Math.round(left / (right / 100));
  8915. var pTop = 100 - Math.round(top / (bottom / 100));
  8916. this._pickerState.hsv.s = pLeft / 100;
  8917. this._pickerState.hsv.v = pTop / 100;
  8918. };
  8919. Colorpicker.prototype._calculateRangeGrip = function (left) {
  8920. var rangeBox = this.getRootView().refs.hue_range.el.getBoundingClientRect();
  8921. var right = rangeBox.width;
  8922. left = left < 0 ? 0 : left > right ? right : left;
  8923. this._pickerState.rangeLeft = left;
  8924. this._pickerState.hsv.h = Math.round(360 * (left / right));
  8925. };
  8926. Colorpicker.prototype._getCells = function (colors, cellClass) {
  8927. var _this = this;
  8928. if (cellClass === void 0) { cellClass = ""; }
  8929. return colors.reduce(function (cells, color) {
  8930. var selected = _this._selected === color ? "dhx_palette__cell--selected" : "";
  8931. cells.push(dom_1.el(".dhx_palette__cell", {
  8932. class: selected + " " + cellClass,
  8933. _data: { color: color },
  8934. style: "background:" + color
  8935. }));
  8936. return cells;
  8937. }, []);
  8938. };
  8939. Colorpicker.prototype._onColorClick = function (_ev, node) {
  8940. this._selected = node.data.color;
  8941. this.events.fire(types_1.ColorpickerEvents.colorChange, [this._selected]);
  8942. this._popup.hide();
  8943. };
  8944. Colorpicker.prototype._getGrayShades = function () {
  8945. return dom_1.el(".dhx_palette__row", this._getCells(colors_1.grayShades));
  8946. };
  8947. Colorpicker.prototype._getPalette = function () {
  8948. var _this = this;
  8949. return colors_1.palette.reduce(function (total, row) {
  8950. total.push(dom_1.el(".dhx_palette__col", _this._getCells(row.colors)));
  8951. return total;
  8952. }, []);
  8953. };
  8954. Colorpicker.prototype._getPicker = function () {
  8955. var rgb = colorHelpers_1.HSVtoRGB(this._pickerState.hsv);
  8956. this._pickerState.background = colorHelpers_1.RGBToHex(rgb);
  8957. var currentBackground = colorHelpers_1.RGBToHex(colorHelpers_1.HSVtoRGB({ h: this._pickerState.hsv.h, s: 1, v: 1 }));
  8958. var root = this.getRootView();
  8959. var box = root.refs ?
  8960. root.refs.picker_palette.el.getBoundingClientRect()
  8961. : { height: 200, width: 218, x: 0, y: 0 };
  8962. var height = box.height - 2;
  8963. var width = box.width - 2;
  8964. var gripTop = (height - this._pickerState.hsv.v * height) - 4;
  8965. var gripLeft = (this._pickerState.hsv.s * width) - 4;
  8966. var rangeWidth = box.width - 6;
  8967. var rangeGripLeft = rangeWidth - ((360 - this._pickerState.hsv.h) / 360) * rangeWidth;
  8968. var inputValue = this._pickerState.customHex ?
  8969. this._pickerState.customHex.replace("#", "")
  8970. : this._pickerState.background.replace("#", "");
  8971. return dom_1.el(".dhx_colorpicker-picker", {}, [
  8972. dom_1.el(".dhx_colorpicker-picker__palette", {
  8973. style: {
  8974. height: 132,
  8975. background: currentBackground
  8976. },
  8977. onmousedown: this._handlers.mousedown,
  8978. dhx_id: "picker_palette",
  8979. _ref: "picker_palette"
  8980. }, [
  8981. dom_1.el(".dhx_palette_grip", {
  8982. style: {
  8983. top: gripTop,
  8984. left: gripLeft
  8985. }
  8986. })
  8987. ]),
  8988. dom_1.el(".dhx_colorpicker-hue-range", {
  8989. style: { height: 16 },
  8990. onmousedown: this._handlers.mousedown,
  8991. dhx_id: "hue_range",
  8992. _key: "hue_range",
  8993. _ref: "hue_range"
  8994. }, [
  8995. dom_1.el(".dhx_colorpicker-hue-range__grip", { style: { left: rangeGripLeft } })
  8996. ]),
  8997. dom_1.el(".dhx_colorpicker-value", [
  8998. dom_1.el(".dhx_colorpicker-value__color", { style: { background: this._pickerState.background } }),
  8999. dom_1.el(".dhx_colorpicker-value__input-wrapper", [
  9000. dom_1.el("input", {
  9001. class: "dhx_colorpicker-value__input",
  9002. value: inputValue,
  9003. oninput: this._handlers.oninput,
  9004. maxlength: "7",
  9005. _key: "hex_input"
  9006. })
  9007. ])
  9008. ]),
  9009. dom_1.el(".dhx_colorpicker-picker__buttons", [
  9010. dom_1.el("button", {
  9011. class: "dhx_button dhx_button--size_medium dhx_button--type_link dhx_button--color_primary",
  9012. onclick: [this._handlers.buttonsClick, "cancel"]
  9013. }, en_1.default.cancel),
  9014. dom_1.el("button", {
  9015. class: "dhx_button dhx_button--size_medium dhx_button--type_flat dhx_button--color_primary",
  9016. onclick: [this._handlers.buttonsClick, "apply"]
  9017. }, en_1.default.select)
  9018. ])
  9019. ]);
  9020. };
  9021. Colorpicker.prototype._getContent = function () {
  9022. var view = this._pickerState.currentView === "palette" ? [
  9023. this._getGrayShades()
  9024. ].concat((this._getPalette()), [
  9025. this.config.customColors && dom_1.el(".dhx_colorpicker-custom-colors", [
  9026. dom_1.el(".dhx_colorpicker-custom-colors__header", [
  9027. en_1.default.customColors,
  9028. dom_1.el("span.dhx_colorpicker-custom-colors__hint", " (" + en_1.default.rightClickToDelete + ")")
  9029. ]),
  9030. dom_1.el(".dhx_palette--custom.dhx_palette__row", this._getCells(this._pickerState.customColors, "dhx_custom-color__cell").concat([
  9031. dom_1.el(".dhx_colorpicker-custom-colors__picker", { class: "dxi dxi-plus", onclick: this._handlers.customColorClick })
  9032. ]))
  9033. ]),
  9034. ]) :
  9035. [this._getPicker()];
  9036. return dom_1.el(".dhx_colorpicker", [
  9037. dom_1.el(".dhx_palette", {
  9038. onclick: this._handlers.click,
  9039. oncontextmenu: this._handlers.contextmenu
  9040. }, view)
  9041. ]);
  9042. };
  9043. return Colorpicker;
  9044. }(view_1.View));
  9045. exports.Colorpicker = Colorpicker;
  9046. /***/ }),
  9047. /* 76 */
  9048. /***/ (function(module, exports, __webpack_require__) {
  9049. "use strict";
  9050. Object.defineProperty(exports, "__esModule", { value: true });
  9051. function HSVtoRGB(hsv) {
  9052. var rgb = { r: 0, g: 0, b: 0 };
  9053. var h = hsv.h / 60;
  9054. var s = hsv.s;
  9055. var v = hsv.v;
  9056. var i = Math.floor(h) % 6;
  9057. var f = h - Math.floor(h);
  9058. var p = 255 * v * (1 - s);
  9059. var q = 255 * v * (1 - (s * f));
  9060. var t = 255 * v * (1 - (s * (1 - f)));
  9061. v *= 255;
  9062. switch (i) {
  9063. case 0:
  9064. rgb.r = v;
  9065. rgb.g = t;
  9066. rgb.b = p;
  9067. break;
  9068. case 1:
  9069. rgb.r = q;
  9070. rgb.g = v;
  9071. rgb.b = p;
  9072. break;
  9073. case 2:
  9074. rgb.r = p;
  9075. rgb.g = v;
  9076. rgb.b = t;
  9077. break;
  9078. case 3:
  9079. rgb.r = p;
  9080. rgb.g = q;
  9081. rgb.b = v;
  9082. break;
  9083. case 4:
  9084. rgb.r = t;
  9085. rgb.g = p;
  9086. rgb.b = v;
  9087. break;
  9088. case 5:
  9089. rgb.r = v;
  9090. rgb.g = p;
  9091. rgb.b = q;
  9092. break;
  9093. }
  9094. for (var key in rgb) {
  9095. rgb[key] = Math.round(rgb[key]);
  9096. }
  9097. return rgb;
  9098. }
  9099. exports.HSVtoRGB = HSVtoRGB;
  9100. function RGBToHex(rgb) {
  9101. return Object.keys(rgb).reduce(function (hex, c) {
  9102. var h = rgb[c].toString(16).toUpperCase();
  9103. h = h.length === 1 ? "0" + h : h;
  9104. return hex += h;
  9105. }, "#");
  9106. }
  9107. exports.RGBToHex = RGBToHex;
  9108. function HexToRGB(hex) {
  9109. var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
  9110. hex = hex.replace(shorthandRegex, function (_m, r, g, b) {
  9111. return r + r + g + g + b + b;
  9112. });
  9113. var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  9114. return result ? {
  9115. r: parseInt(result[1], 16),
  9116. g: parseInt(result[2], 16),
  9117. b: parseInt(result[3], 16)
  9118. } : null;
  9119. }
  9120. exports.HexToRGB = HexToRGB;
  9121. function RGBToHSV(rgb) {
  9122. var h;
  9123. var s;
  9124. var r = rgb.r / 255;
  9125. var g = rgb.g / 255;
  9126. var b = rgb.b / 255;
  9127. var v = Math.max(r, g, b);
  9128. var diff = v - Math.min(r, g, b);
  9129. var diffc = function (c) {
  9130. return (v - c) / 6 / diff + 1 / 2;
  9131. };
  9132. if (diff === 0) {
  9133. h = s = 0;
  9134. }
  9135. else {
  9136. s = diff / v;
  9137. var rdif = diffc(r);
  9138. var gdif = diffc(g);
  9139. var bdif = diffc(b);
  9140. if (r === v) {
  9141. h = bdif - gdif;
  9142. }
  9143. else if (g === v) {
  9144. h = (1 / 3) + rdif - bdif;
  9145. }
  9146. else if (b === v) {
  9147. h = (2 / 3) + gdif - rdif;
  9148. }
  9149. if (h < 0) {
  9150. h += 1;
  9151. }
  9152. else if (h > 1) {
  9153. h -= 1;
  9154. }
  9155. }
  9156. return {
  9157. h: Math.floor(h * 360),
  9158. s: s,
  9159. v: v
  9160. };
  9161. }
  9162. exports.RGBToHSV = RGBToHSV;
  9163. function HexToHSV(hex) {
  9164. return RGBToHSV(HexToRGB(hex));
  9165. }
  9166. exports.HexToHSV = HexToHSV;
  9167. function isHex(hex) {
  9168. return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(hex);
  9169. }
  9170. exports.isHex = isHex;
  9171. /***/ }),
  9172. /* 77 */
  9173. /***/ (function(module, exports, __webpack_require__) {
  9174. "use strict";
  9175. Object.defineProperty(exports, "__esModule", { value: true });
  9176. exports.grayShades = [
  9177. "#000000",
  9178. "#4C4C4C",
  9179. "#666666",
  9180. "#808080",
  9181. "#999999",
  9182. "#B3B3B3",
  9183. "#CCCCCC",
  9184. "#E6E6E6",
  9185. "#F2F2F2",
  9186. "#FFFFFF"
  9187. ];
  9188. exports.palette = [{
  9189. colors: [
  9190. "#D4DAE4",
  9191. "#B0B8CD",
  9192. "#949DB1",
  9193. "#727A8C",
  9194. "#5E6677",
  9195. "#3F4757",
  9196. "#1D2534"
  9197. ]
  9198. },
  9199. {
  9200. colors: [
  9201. "#FFCDD2",
  9202. "#FE9998",
  9203. "#F35C4E",
  9204. "#E94633",
  9205. "#D73C2D",
  9206. "#CA3626",
  9207. "#BB2B1A"
  9208. ]
  9209. },
  9210. {
  9211. colors: [
  9212. "#F9E6AD",
  9213. "#F4D679",
  9214. "#EDB90F",
  9215. "#EAA100",
  9216. "#EA8F00",
  9217. "#EA7E00",
  9218. "#EA5D00"
  9219. ]
  9220. },
  9221. {
  9222. colors: [
  9223. "#BCE4CE",
  9224. "#90D2AF",
  9225. "#33B579",
  9226. "#36955F",
  9227. "#247346",
  9228. "#1D5B38",
  9229. "#17492D"
  9230. ]
  9231. },
  9232. {
  9233. colors: [
  9234. "#BDF0E9",
  9235. "#92E7DC",
  9236. "#02D7C5",
  9237. "#11B3A5",
  9238. "#018B80",
  9239. "#026B60",
  9240. "#024F43"
  9241. ]
  9242. },
  9243. {
  9244. colors: [
  9245. "#B3E5FC",
  9246. "#81D4FA",
  9247. "#29B6F6",
  9248. "#039BE5",
  9249. "#0288D1",
  9250. "#0277BD",
  9251. "#01579B"
  9252. ]
  9253. },
  9254. {
  9255. colors: [
  9256. "#AEC1FF",
  9257. "#88A3F9",
  9258. "#5874CD",
  9259. "#2349AE",
  9260. "#163FA2",
  9261. "#083596",
  9262. "#002381"
  9263. ]
  9264. },
  9265. {
  9266. colors: [
  9267. "#C5C0DA",
  9268. "#9F97C1",
  9269. "#7E6BAD",
  9270. "#584A8F",
  9271. "#4F4083",
  9272. "#473776",
  9273. "#3A265F"
  9274. ]
  9275. },
  9276. {
  9277. colors: [
  9278. "#D6BDCC",
  9279. "#C492AC",
  9280. "#A9537C",
  9281. "#963A64",
  9282. "#81355A",
  9283. "#6E3051",
  9284. "#4C2640"
  9285. ]
  9286. },
  9287. {
  9288. colors: [
  9289. "#D2C5C1",
  9290. "#B4A09A",
  9291. "#826358",
  9292. "#624339",
  9293. "#5D4037",
  9294. "#4E342E",
  9295. "#3E2723"
  9296. ]
  9297. }
  9298. ];
  9299. /***/ }),
  9300. /* 78 */
  9301. /***/ (function(module, exports, __webpack_require__) {
  9302. "use strict";
  9303. Object.defineProperty(exports, "__esModule", { value: true });
  9304. var en = {
  9305. cancel: "Cancel",
  9306. select: "Select",
  9307. rightClickToDelete: "Right click to delete",
  9308. customColors: "Custom colors"
  9309. };
  9310. exports.default = en;
  9311. /***/ }),
  9312. /* 79 */
  9313. /***/ (function(module, exports, __webpack_require__) {
  9314. "use strict";
  9315. var __assign = (this && this.__assign) || Object.assign || function(t) {
  9316. for (var s, i = 1, n = arguments.length; i < n; i++) {
  9317. s = arguments[i];
  9318. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  9319. t[p] = s[p];
  9320. }
  9321. return t;
  9322. };
  9323. Object.defineProperty(exports, "__esModule", { value: true });
  9324. var constants_1 = __webpack_require__(5);
  9325. var markdown_1 = __webpack_require__(80);
  9326. var minimizer_1 = __webpack_require__(81);
  9327. var other_1 = __webpack_require__(4);
  9328. var parser_1 = __webpack_require__(82);
  9329. var serializer_1 = __webpack_require__(35);
  9330. var Manager_1 = __webpack_require__(84);
  9331. var types_1 = __webpack_require__(2);
  9332. var SelectionHelper_1 = __webpack_require__(86);
  9333. var Block_1 = __webpack_require__(34);
  9334. var TextNode_1 = __webpack_require__(20);
  9335. var styles_1 = __webpack_require__(19);
  9336. var Editor = /** @class */ (function () {
  9337. function Editor(_a) {
  9338. var events = _a.events, uid = _a.uid, getRootView = _a.getRootView, repaint = _a.repaint;
  9339. var _this = this;
  9340. this.getTextElement = function (blockIndex, textIndex) {
  9341. var id = other_1.getTextHash(blockIndex, textIndex);
  9342. var rootView = _this._getRootView();
  9343. return rootView.refs && rootView.refs[id] && rootView.refs[id].el && rootView.refs[id].el.childNodes[0];
  9344. };
  9345. this._events = events;
  9346. this._repaint = repaint;
  9347. this._getRootView = getRootView;
  9348. this.selection = new SelectionHelper_1.SelectionHelper(this, uid, events);
  9349. this.clear();
  9350. this.manager = new Manager_1.Manager(this);
  9351. this._events.on(types_1.RichTextEvents.change, function (action) {
  9352. if (action !== types_1.Action.update) {
  9353. _this._tempNode = null;
  9354. }
  9355. });
  9356. this._events.on(types_1.RichTextEvents.selectionChange, function () {
  9357. _this._tempNode = null;
  9358. });
  9359. }
  9360. Editor.prototype.clear = function () {
  9361. this.blocks = [new Block_1.Block([new TextNode_1.TextNode("", constants_1.emptyStyle)])];
  9362. this.selection.clear();
  9363. };
  9364. Editor.prototype.getState = function () {
  9365. return JSON.stringify({
  9366. b: this.blocks.map(function (block) { return ({
  9367. s: minimizer_1.minimizeBlockStyle(block.style),
  9368. n: block.textNodes.map(function (textNode) { return ({
  9369. s: minimizer_1.minimizeTextNodeStyle(textNode.style),
  9370. t: textNode.text
  9371. }); })
  9372. }); }),
  9373. s: this.selection.getCompact()
  9374. });
  9375. };
  9376. Editor.prototype.setState = function (state) {
  9377. var raw = JSON.parse(state);
  9378. this.blocks = raw.b.map(function (_a) {
  9379. var s = _a.s, n = _a.n;
  9380. var textNodes = n.map(function (node) { return new TextNode_1.TextNode(node.t, minimizer_1.textNodeStyleFromMinimize(node.s)); });
  9381. var block = new Block_1.Block(textNodes, minimizer_1.blockStyleFromMinimize(s));
  9382. return block;
  9383. });
  9384. this.selection.setCompact(raw.s);
  9385. };
  9386. Editor.prototype.parse = function (value, mode) {
  9387. if (mode === void 0) { mode = "html"; }
  9388. if (mode === "html" || mode === "markdown") {
  9389. var blocks = parser_1.parser(value, mode);
  9390. this.blocks = blocks;
  9391. }
  9392. else {
  9393. this.blocks = value.map(function (block) { return new Block_1.Block(block.textNodes.map(function (textNode) { return new TextNode_1.TextNode(textNode.text, textNode.style); }), block.style); });
  9394. }
  9395. this.selection.set({
  9396. range: false,
  9397. left: __assign({ blockIndex: this.blocks.length - 1 }, this.blocks[this.blocks.length - 1].getBlockEnd())
  9398. });
  9399. return true;
  9400. };
  9401. Editor.prototype.serialize = function (mode) {
  9402. if (mode === void 0) { mode = "html"; }
  9403. this.balance();
  9404. if (mode === "markdown") {
  9405. return markdown_1.markdownSerializer(this.blocks);
  9406. }
  9407. if (mode === "html") {
  9408. return serializer_1.serializer(this.blocks);
  9409. }
  9410. if (mode === "text") {
  9411. return this.blocks.reduce(function (blockText, block, i) { return blockText + (i > 0 ? "\n" : "") +
  9412. block.textNodes.reduce(function (text, textNode) { return text + textNode.text; }, ""); }, "");
  9413. }
  9414. };
  9415. Editor.prototype.removeBlock = function (index) {
  9416. this.blocks.splice(index, 1);
  9417. if (this.blocks.length === 0) {
  9418. this.clear();
  9419. }
  9420. };
  9421. Editor.prototype.insertBlock = function () {
  9422. this._splitCarret();
  9423. var _a = this.selection.get(), range = _a.range, left = _a.left;
  9424. if (range) {
  9425. return;
  9426. }
  9427. var currentLineNodes = this.blocks[left.blockIndex].textNodes;
  9428. var nextLineNodes = currentLineNodes.splice(left.textIndex + (left.offset ? 1 : 0), Infinity); // Infinity to remove all after left
  9429. var nextLineBlockStyle = this.blocks[left.blockIndex].style;
  9430. if (nextLineNodes.length === 0) {
  9431. var style = this.blocks[left.blockIndex].textNodes[left.textIndex].style;
  9432. nextLineNodes = [new TextNode_1.TextNode("", other_1.copyWithout(style, { link: true }))];
  9433. nextLineBlockStyle = other_1.copyWithout(nextLineBlockStyle, { blockquote: true, style: true });
  9434. nextLineBlockStyle[types_1.Modifier.style] = "p";
  9435. }
  9436. else {
  9437. var link = currentLineNodes[currentLineNodes.length - 1] && currentLineNodes[currentLineNodes.length - 1].style.link;
  9438. if (link) {
  9439. for (var _i = 0, nextLineNodes_1 = nextLineNodes; _i < nextLineNodes_1.length; _i++) {
  9440. var textNode = nextLineNodes_1[_i];
  9441. if (textNode.style.link === link) {
  9442. textNode.style = other_1.copyWithout(textNode.style, { link: true });
  9443. }
  9444. else {
  9445. break;
  9446. }
  9447. }
  9448. }
  9449. }
  9450. if (currentLineNodes.length === 0) {
  9451. this.blocks[left.blockIndex].clear();
  9452. }
  9453. var block = new Block_1.Block(nextLineNodes, nextLineBlockStyle);
  9454. this.blocks.splice(left.blockIndex + 1, 0, block);
  9455. this.selection.set({
  9456. range: range,
  9457. left: {
  9458. offset: 0,
  9459. textIndex: 0,
  9460. blockIndex: left.blockIndex + 1
  9461. }
  9462. });
  9463. };
  9464. Editor.prototype.eachSelectedNode = function (fn) {
  9465. var _a = this.selection.get(), range = _a.range, left = _a.left, right = _a.right;
  9466. if (range) {
  9467. for (var i = left.blockIndex; i <= right.blockIndex; i++) {
  9468. var startNode = 0;
  9469. var endNode = this.blocks[i].textNodes.length - 1;
  9470. if (i === left.blockIndex) {
  9471. startNode = left.textIndex;
  9472. }
  9473. if (i === right.blockIndex) {
  9474. endNode = right.textIndex;
  9475. }
  9476. for (var j = startNode; j <= endNode; j++) {
  9477. fn(this.blocks[i].textNodes[j], this.blocks[i]);
  9478. }
  9479. }
  9480. }
  9481. else {
  9482. if (left) {
  9483. fn(this.blocks[left.blockIndex].textNodes[left.textIndex], this.blocks[left.blockIndex]);
  9484. }
  9485. }
  9486. };
  9487. Editor.prototype.eachSelectedBlock = function (fn) {
  9488. var _a = this.selection.get(), range = _a.range, left = _a.left, right = _a.right;
  9489. if (range) {
  9490. for (var i = left.blockIndex; i <= right.blockIndex; i++) {
  9491. fn(this.blocks[i], i);
  9492. }
  9493. }
  9494. else {
  9495. fn(this.blocks[left.blockIndex]);
  9496. }
  9497. };
  9498. Editor.prototype.copy = function () {
  9499. var range = this.selection.get().range;
  9500. if (!range) {
  9501. return false;
  9502. }
  9503. this._splitRange();
  9504. var editorContent = [];
  9505. var raw = "";
  9506. var _a = this.selection.get(), left = _a.left, right = _a.right;
  9507. this.eachSelectedBlock(function (block, index) {
  9508. var startIndex = 0;
  9509. var endIndex = block.textNodes.length - 1;
  9510. var textNodes = [];
  9511. editorContent.push({
  9512. style: block.style,
  9513. textNodes: textNodes
  9514. });
  9515. if (index === left.blockIndex) {
  9516. startIndex = left.textIndex;
  9517. }
  9518. if (index === right.blockIndex) {
  9519. endIndex = right.textIndex;
  9520. }
  9521. for (var i = startIndex; i <= endIndex; i++) {
  9522. var textNode = block.textNodes[i];
  9523. textNodes.push({
  9524. style: textNode.style,
  9525. text: textNode.text
  9526. });
  9527. raw += textNode.text;
  9528. }
  9529. if (index < right.blockIndex) {
  9530. raw += "\n";
  9531. }
  9532. });
  9533. return {
  9534. content: editorContent,
  9535. raw: raw
  9536. };
  9537. };
  9538. Editor.prototype.cut = function () {
  9539. var result = this.copy();
  9540. this._splitRange();
  9541. this._removeRange();
  9542. return result;
  9543. };
  9544. Editor.prototype.paste = function (value, mode) {
  9545. if (mode === void 0) { mode = "text"; }
  9546. var _a, _b, _c;
  9547. if (mode === "text") {
  9548. return this.add(value);
  9549. }
  9550. else {
  9551. var range = this.selection.get().range;
  9552. if (range) {
  9553. this._splitRange();
  9554. this._removeRange();
  9555. }
  9556. var left = this.selection.get().left;
  9557. var _d = mode === "inner" ? JSON.parse(value) : parser_1.parser(value, "html"), firstBlock = _d[0], blocks = _d.slice(1);
  9558. var lastLineIndex = void 0;
  9559. if (this.blocks[left.blockIndex].isEmpty()) { // destroy empty node
  9560. this.blocks[left.blockIndex].textNodes = [];
  9561. this.blocks[left.blockIndex].style = firstBlock.style;
  9562. }
  9563. else { // split node before paste
  9564. var splitResult = this.blocks[left.blockIndex].splitTextNode(left.textIndex, left.offset);
  9565. switch (splitResult) {
  9566. case Block_1.SplitResult.offsetStart:
  9567. lastLineIndex = left.textIndex;
  9568. break;
  9569. case Block_1.SplitResult.offsetEnd:
  9570. case Block_1.SplitResult.complete:
  9571. lastLineIndex = left.textIndex + 1;
  9572. break;
  9573. }
  9574. }
  9575. var currentLineNodes = void 0;
  9576. var lastLineNodes = void 0;
  9577. if (lastLineIndex > 0) {
  9578. currentLineNodes = this.blocks[left.blockIndex].textNodes.slice(0, lastLineIndex);
  9579. lastLineNodes = this.blocks[left.blockIndex].textNodes.slice(lastLineIndex, Infinity);
  9580. }
  9581. else {
  9582. currentLineNodes = [];
  9583. lastLineNodes = this.blocks[left.blockIndex].textNodes;
  9584. }
  9585. for (var _i = 0, _e = firstBlock.textNodes; _i < _e.length; _i++) {
  9586. var textNode = _e[_i];
  9587. currentLineNodes.push(new TextNode_1.TextNode(textNode.text, textNode.style));
  9588. }
  9589. this.blocks[left.blockIndex].textNodes = currentLineNodes;
  9590. if (blocks.length) {
  9591. var newBlocks = blocks.map(function (block) { return new Block_1.Block(block.textNodes.map(function (node) { return new TextNode_1.TextNode(node.text, node.style); }), block.style); });
  9592. (_a = this.blocks).splice.apply(_a, [left.blockIndex + 1, 0].concat(newBlocks));
  9593. var blockEnd = this.blocks[left.blockIndex + blocks.length].getBlockEnd();
  9594. (_b = this.blocks[left.blockIndex + blocks.length].textNodes).push.apply(_b, lastLineNodes);
  9595. this.selection.set({
  9596. range: false,
  9597. left: __assign({ blockIndex: left.blockIndex + blocks.length }, blockEnd)
  9598. });
  9599. }
  9600. else {
  9601. var blockEnd = this.blocks[left.blockIndex].getBlockEnd();
  9602. (_c = this.blocks[left.blockIndex].textNodes).push.apply(_c, lastLineNodes);
  9603. this.selection.set({
  9604. range: false,
  9605. left: __assign({ blockIndex: left.blockIndex }, blockEnd)
  9606. });
  9607. }
  9608. return true;
  9609. }
  9610. };
  9611. Editor.prototype.add = function (data) {
  9612. var range = this.selection.get().range;
  9613. if (range) {
  9614. this._splitRange();
  9615. this._removeRange();
  9616. }
  9617. if (data.newBlock) {
  9618. this.insertBlock();
  9619. return true;
  9620. }
  9621. var _a = this.selection.get().left, offset = _a.offset, blockIndex = _a.blockIndex, textIndex = _a.textIndex;
  9622. if (this._tempNode && this._tempNode.offset === offset &&
  9623. this._tempNode.blockIndex === blockIndex && this._tempNode.textIndex === textIndex) {
  9624. return this._createNodeFromTemp(data);
  9625. }
  9626. var textNodes = this.blocks[blockIndex].textNodes;
  9627. var textNode = textNodes[textIndex];
  9628. if (textNode.style.link && textNode.text.length === offset && (!textNodes[textIndex + 1] || !textNodes[textIndex + 1].style.link)) {
  9629. var newTextNode = new TextNode_1.TextNode(data, other_1.copyWithout(textNode.style, { link: true }));
  9630. textNodes.splice(textIndex + 1, 0, newTextNode);
  9631. this.selection.set({
  9632. range: false,
  9633. left: {
  9634. offset: data.length,
  9635. blockIndex: blockIndex,
  9636. textIndex: textIndex + 1
  9637. }
  9638. });
  9639. }
  9640. else if (textNode.style.link && offset === 0) {
  9641. var newTextNode = new TextNode_1.TextNode(data, other_1.copyWithout(textNode.style, { link: true }));
  9642. textNodes.splice(textIndex, 0, newTextNode);
  9643. this.selection.set({
  9644. range: false,
  9645. left: {
  9646. offset: data.length,
  9647. blockIndex: blockIndex,
  9648. textIndex: textIndex
  9649. }
  9650. });
  9651. }
  9652. else {
  9653. textNodes[textIndex].insert(data, offset);
  9654. this.selection.set({
  9655. range: false,
  9656. left: {
  9657. offset: offset + data.length,
  9658. blockIndex: blockIndex,
  9659. textIndex: textIndex
  9660. }
  9661. });
  9662. }
  9663. return true;
  9664. };
  9665. Editor.prototype.remove = function (prev) {
  9666. var range = this.selection.get().range;
  9667. if (range) {
  9668. this._splitRange();
  9669. this._removeRange();
  9670. return true;
  9671. }
  9672. else {
  9673. return this._removeSymbol(prev);
  9674. }
  9675. };
  9676. Editor.prototype.update = function (_a) {
  9677. var modifier = _a.modifier, modifierValue = _a.modifierValue;
  9678. var _b = this.selection.get(), range = _b.range, left = _b.left;
  9679. switch (modifier) {
  9680. // block modifiers
  9681. case types_1.Modifier.align:
  9682. case types_1.Modifier.style:
  9683. case types_1.Modifier.blockquote:
  9684. this.eachSelectedBlock(function (block) {
  9685. var _a;
  9686. block.style = __assign({}, block.style, (_a = {}, _a[modifier] = modifierValue, _a));
  9687. if (modifier === types_1.Modifier.style && modifierValue !== "p") {
  9688. block.textNodes.forEach(function (textNode) {
  9689. var _a;
  9690. textNode.style = other_1.copyWithout(textNode.style, (_a = {}, _a[types_1.Modifier.fontSize] = true, _a));
  9691. });
  9692. }
  9693. });
  9694. return true;
  9695. // text modifers
  9696. case types_1.Modifier.strike:
  9697. case types_1.Modifier.underline:
  9698. case types_1.Modifier.italic:
  9699. case types_1.Modifier.bold:
  9700. case types_1.Modifier.color:
  9701. case types_1.Modifier.background:
  9702. case types_1.Modifier.fontFamily:
  9703. case types_1.Modifier.fontSize:
  9704. if (!range) {
  9705. this._createTempTextNode({ modifier: modifier, modifierValue: modifierValue });
  9706. return false;
  9707. }
  9708. this._splitRange();
  9709. this.eachSelectedNode(function (node) {
  9710. var _a;
  9711. node.style = __assign({}, node.style, (_a = {}, _a[modifier] = modifierValue, _a));
  9712. });
  9713. return true;
  9714. case types_1.Modifier.link:
  9715. var leftTextNode = this.blocks[left.blockIndex].textNodes[left.textIndex];
  9716. if (modifier === undefined || leftTextNode.style.link !== undefined) {
  9717. this._eachLink(function (node) {
  9718. var _a;
  9719. node.style = __assign({}, node.style, (_a = {}, _a[modifier] = modifierValue, _a));
  9720. });
  9721. }
  9722. else {
  9723. if (range) {
  9724. this._splitRange();
  9725. }
  9726. this.eachSelectedNode(function (node) {
  9727. var _a;
  9728. node.style = __assign({}, node.style, (_a = {}, _a[modifier] = modifierValue, _a));
  9729. });
  9730. }
  9731. return true;
  9732. }
  9733. };
  9734. Editor.prototype.clearStyles = function () {
  9735. if (!this.selection.get().range) {
  9736. return false;
  9737. }
  9738. this._splitRange();
  9739. this.eachSelectedNode(function (node) {
  9740. node.style = constants_1.emptyStyle;
  9741. });
  9742. return true;
  9743. };
  9744. Editor.prototype.balance = function () {
  9745. var _a = this.selection.get(), left = _a.left, right = _a.right, range = _a.range;
  9746. var leftOffset = this.blocks[left.blockIndex].nodePositionToOffset(left.textIndex, left.offset);
  9747. var rightOffset;
  9748. if (range) {
  9749. rightOffset = this.blocks[right.blockIndex].nodePositionToOffset(right.textIndex, right.offset);
  9750. }
  9751. var notChanged = true;
  9752. this.blocks.forEach(function (block) {
  9753. if (block.balance()) {
  9754. notChanged = false;
  9755. }
  9756. });
  9757. if (notChanged) {
  9758. return;
  9759. }
  9760. this.selection.set({
  9761. range: range,
  9762. left: __assign({ blockIndex: left.blockIndex }, this.blocks[left.blockIndex].offsetToNodePosition(leftOffset)),
  9763. right: rightOffset && __assign({ blockIndex: right.blockIndex }, this.blocks[right.blockIndex].offsetToNodePosition(rightOffset))
  9764. });
  9765. this._repaint();
  9766. };
  9767. Editor.prototype.getLinkInfo = function () {
  9768. var text = "";
  9769. var link;
  9770. this._eachLink(function (textNode) {
  9771. text += textNode.text;
  9772. link = textNode.style.link;
  9773. });
  9774. return { text: text, link: link };
  9775. };
  9776. Editor.prototype.updateLinkText = function (text) {
  9777. var _a = this.selection.get(), left = _a.left, range = _a.range;
  9778. var textNodes = this.blocks[left.blockIndex].textNodes;
  9779. var link = textNodes[left.textIndex].style.link;
  9780. var textNode = new TextNode_1.TextNode(text, {});
  9781. if (link) {
  9782. var linkLeftIndex = left.textIndex;
  9783. var linkRightIndex = left.textIndex;
  9784. while (textNodes[linkLeftIndex - 1] && textNodes[linkLeftIndex - 1].style.link === link) {
  9785. linkLeftIndex--;
  9786. }
  9787. while (textNodes[linkRightIndex + 1] && textNodes[linkRightIndex + 1].style.link === link) {
  9788. linkRightIndex++;
  9789. }
  9790. textNodes.splice(linkLeftIndex, linkRightIndex - linkLeftIndex + 1, textNode);
  9791. this.selection.set({
  9792. range: true,
  9793. left: {
  9794. blockIndex: left.blockIndex,
  9795. textIndex: linkLeftIndex,
  9796. offset: 0
  9797. },
  9798. right: {
  9799. blockIndex: left.blockIndex,
  9800. textIndex: linkLeftIndex,
  9801. offset: text.length
  9802. }
  9803. });
  9804. }
  9805. else {
  9806. if (range) {
  9807. this._splitRange();
  9808. this._removeRange();
  9809. var _b = this.selection.get().left, blockIndex = _b.blockIndex, textIndex = _b.textIndex;
  9810. this.blocks[blockIndex].textNodes.splice(textIndex + 1, 0, textNode);
  9811. this.selection.set({
  9812. range: true,
  9813. left: {
  9814. blockIndex: blockIndex,
  9815. textIndex: textIndex + 1,
  9816. offset: 0
  9817. },
  9818. right: {
  9819. blockIndex: blockIndex,
  9820. textIndex: textIndex + 1,
  9821. offset: text.length
  9822. }
  9823. });
  9824. }
  9825. else {
  9826. var index = void 0;
  9827. if (this.blocks[left.blockIndex].isEmpty()) {
  9828. textNodes.splice(0, 1);
  9829. index = 0;
  9830. }
  9831. else {
  9832. var splitResult = this.blocks[left.blockIndex].splitTextNode(left.textIndex, left.offset);
  9833. index = splitResult === Block_1.SplitResult.offsetStart ? left.textIndex : left.textIndex + 1;
  9834. }
  9835. textNodes.splice(index, 0, textNode);
  9836. this.selection.set({
  9837. range: true,
  9838. left: {
  9839. blockIndex: left.blockIndex,
  9840. textIndex: index,
  9841. offset: 0
  9842. },
  9843. right: {
  9844. blockIndex: left.blockIndex,
  9845. textIndex: index,
  9846. offset: text.length
  9847. }
  9848. });
  9849. }
  9850. }
  9851. };
  9852. Editor.prototype._splitRange = function () {
  9853. // left selection must have offset = 0
  9854. // right selection must have offset = end of textnode
  9855. var _a = this.selection.get(), range = _a.range, left = _a.left, right = _a.right;
  9856. if (!range) {
  9857. return;
  9858. }
  9859. // 1 - left and right are single text node
  9860. if (left.blockIndex === right.blockIndex && left.textIndex === right.textIndex) {
  9861. var rightTextIndex = left.textIndex;
  9862. var rightOffset = right.offset;
  9863. var leftSplitResult = this.blocks[left.blockIndex].splitTextNode(left.textIndex, left.offset);
  9864. // in this case left cant return SplitResult.offsetEnd coz this textNode has right
  9865. // if node was splited need to update right text index and right offset
  9866. if (leftSplitResult === Block_1.SplitResult.complete) {
  9867. rightTextIndex += 1;
  9868. rightOffset -= left.offset;
  9869. }
  9870. this.blocks[right.blockIndex].splitTextNode(rightTextIndex, rightOffset);
  9871. var selection = {
  9872. range: range,
  9873. left: { blockIndex: left.blockIndex, textIndex: rightTextIndex, offset: 0 },
  9874. right: { blockIndex: right.blockIndex, textIndex: rightTextIndex, offset: rightOffset }
  9875. };
  9876. this.selection.set(selection);
  9877. return;
  9878. }
  9879. // 2 - left and right located in one block, so left split can move right position
  9880. if (left.blockIndex === right.blockIndex) {
  9881. var leftTextIndex = left.textIndex;
  9882. var rightTextIndex = right.textIndex;
  9883. var leftSplitResult = this.blocks[left.blockIndex].splitTextNode(leftTextIndex, left.offset);
  9884. // move selection to next node
  9885. if (leftSplitResult === Block_1.SplitResult.offsetEnd) {
  9886. leftTextIndex += 1;
  9887. }
  9888. // move selection to next node and update right position
  9889. if (leftSplitResult === Block_1.SplitResult.complete) {
  9890. rightTextIndex += 1;
  9891. leftTextIndex += 1;
  9892. }
  9893. this.blocks[right.blockIndex].splitTextNode(rightTextIndex, right.offset);
  9894. var selection = {
  9895. range: range,
  9896. left: { blockIndex: left.blockIndex, textIndex: leftTextIndex, offset: 0 },
  9897. right: { blockIndex: right.blockIndex, textIndex: rightTextIndex, offset: right.offset }
  9898. };
  9899. this.selection.set(selection);
  9900. return;
  9901. }
  9902. // 3 - left and right located in diffrent blocks
  9903. if (left.blockIndex !== right.blockIndex) {
  9904. var leftTextIndex = left.textIndex;
  9905. var leftBlockIndex = left.blockIndex;
  9906. var leftSplitResult = this.blocks[left.blockIndex].splitTextNode(left.textIndex, left.offset);
  9907. this.blocks[right.blockIndex].splitTextNode(right.textIndex, right.offset);
  9908. if (leftSplitResult === Block_1.SplitResult.offsetEnd) {
  9909. // if this textnode have next node
  9910. if (this.blocks[leftBlockIndex].textNodes[leftTextIndex + 1]) {
  9911. leftTextIndex += 1;
  9912. }
  9913. else {
  9914. leftTextIndex = 0;
  9915. leftBlockIndex += 1;
  9916. }
  9917. }
  9918. if (leftSplitResult === Block_1.SplitResult.complete) {
  9919. leftTextIndex += 1;
  9920. }
  9921. var selection = {
  9922. range: range,
  9923. left: { blockIndex: leftBlockIndex, textIndex: leftTextIndex, offset: 0 },
  9924. right: { blockIndex: right.blockIndex, textIndex: right.textIndex, offset: right.offset }
  9925. };
  9926. this.selection.set(selection);
  9927. }
  9928. };
  9929. Editor.prototype._splitCarret = function () {
  9930. // need for split block into text nodes
  9931. var _a = this.selection.get(), range = _a.range, left = _a.left;
  9932. if (range) {
  9933. return;
  9934. }
  9935. var splitResult = this.blocks[left.blockIndex].splitTextNode(left.textIndex, left.offset);
  9936. if (splitResult === Block_1.SplitResult.complete) {
  9937. var selection = {
  9938. range: range,
  9939. left: {
  9940. blockIndex: left.blockIndex,
  9941. textIndex: left.textIndex + 1,
  9942. offset: 0
  9943. }
  9944. };
  9945. this.selection.set(selection);
  9946. }
  9947. };
  9948. Editor.prototype._removeRange = function () {
  9949. var _a;
  9950. // call only after splitRange
  9951. var _b = this.selection.get(), left = _b.left, right = _b.right;
  9952. if (!right) {
  9953. return;
  9954. }
  9955. if (this.selection.isFull()) {
  9956. this.clear();
  9957. return;
  9958. }
  9959. if (left.blockIndex === right.blockIndex) {
  9960. // selection contains full block
  9961. if (left.textIndex === 0 && right.textIndex === this.blocks[right.blockIndex].textNodes.length - 1) {
  9962. this.blocks[left.blockIndex].clear();
  9963. this.selection.set({
  9964. range: false,
  9965. left: __assign({}, left, { offset: 0 })
  9966. });
  9967. }
  9968. else {
  9969. this.blocks[left.blockIndex].textNodes.splice(left.textIndex, right.textIndex - left.textIndex + 1);
  9970. if (left.textIndex === 0) {
  9971. this.selection.set({
  9972. range: false,
  9973. left: {
  9974. blockIndex: left.blockIndex,
  9975. textIndex: 0,
  9976. offset: 0
  9977. }
  9978. });
  9979. }
  9980. else {
  9981. this.selection.set({
  9982. range: false,
  9983. left: {
  9984. blockIndex: left.blockIndex,
  9985. textIndex: left.textIndex - 1,
  9986. offset: this.blocks[left.blockIndex].textNodes[left.textIndex - 1].text.length
  9987. }
  9988. });
  9989. }
  9990. }
  9991. }
  9992. else {
  9993. var isFullLeftRemove = this.blocks[left.blockIndex].removeNodes(left.textIndex, true);
  9994. var isFullRightRemove = this.blocks[right.blockIndex].removeNodes(right.textIndex, false);
  9995. var leftBlockEnd = this.blocks[left.blockIndex].getBlockEnd();
  9996. switch (true) {
  9997. case isFullLeftRemove && isFullRightRemove:
  9998. this.blocks[left.blockIndex].clear();
  9999. break;
  10000. case isFullLeftRemove && !isFullRightRemove:
  10001. this.blocks[left.blockIndex].textNodes = this.blocks[right.blockIndex].textNodes;
  10002. break;
  10003. case !isFullLeftRemove && !isFullRightRemove:
  10004. (_a = this.blocks[left.blockIndex].textNodes).push.apply(_a, this.blocks[right.blockIndex].textNodes);
  10005. break;
  10006. case !isFullLeftRemove && isFullRightRemove:
  10007. break;
  10008. }
  10009. for (var i = right.blockIndex; i > left.blockIndex; i--) {
  10010. this.removeBlock(i); // FIX
  10011. }
  10012. if (isFullLeftRemove) {
  10013. this.selection.set({
  10014. range: false,
  10015. left: {
  10016. blockIndex: left.blockIndex,
  10017. textIndex: left.textIndex,
  10018. offset: 0
  10019. }
  10020. });
  10021. }
  10022. else {
  10023. this.selection.set({
  10024. range: false,
  10025. left: __assign({ blockIndex: left.blockIndex }, leftBlockEnd)
  10026. });
  10027. }
  10028. }
  10029. };
  10030. Editor.prototype._removeSymbol = function (prev) {
  10031. var _a = this.selection.get().left, offset = _a.offset, blockIndex = _a.blockIndex, textIndex = _a.textIndex;
  10032. var selection = {
  10033. range: false,
  10034. left: { offset: offset, blockIndex: blockIndex, textIndex: textIndex }
  10035. };
  10036. var blockEnd = this.blocks[blockIndex].getBlockEnd();
  10037. var textNodes = this.blocks[blockIndex].textNodes;
  10038. var textNode = textNodes[textIndex];
  10039. var repeat = false;
  10040. switch (true) {
  10041. case this.blocks[blockIndex].isEmpty():
  10042. if (blockIndex === 0 && prev) {
  10043. if (!styles_1.isEmptyBlockStyle(this.blocks[0].style)) {
  10044. this.blocks[0].style = constants_1.emptyStyle;
  10045. return true;
  10046. }
  10047. return false;
  10048. }
  10049. if (!prev && !this.blocks[blockIndex + 1]) {
  10050. return false;
  10051. }
  10052. this.removeBlock(blockIndex);
  10053. if (blockIndex === 0) {
  10054. selection.left.offset = 0;
  10055. selection.left.textIndex = 0;
  10056. }
  10057. else {
  10058. if (prev) {
  10059. selection.left = __assign({ blockIndex: blockIndex - 1 }, this.blocks[blockIndex - 1].getBlockEnd());
  10060. }
  10061. }
  10062. break;
  10063. case offset === 0 && textIndex === 0 && prev: // move all nodes of this block to previous
  10064. if (blockIndex === 0) {
  10065. return false;
  10066. }
  10067. if (this.blocks[blockIndex - 1].isEmpty()) {
  10068. this.blocks[blockIndex - 1].textNodes = textNodes;
  10069. this.removeBlock(blockIndex);
  10070. selection.left = {
  10071. blockIndex: blockIndex - 1,
  10072. textIndex: 0,
  10073. offset: 0
  10074. };
  10075. }
  10076. else {
  10077. var previousBlockEnd = this.blocks[blockIndex - 1].getBlockEnd();
  10078. this.blocks[blockIndex - 1].textNodes = this.blocks[blockIndex - 1].textNodes.concat(textNodes);
  10079. this.removeBlock(blockIndex);
  10080. selection.left = __assign({ blockIndex: blockIndex - 1 }, previousBlockEnd);
  10081. }
  10082. break;
  10083. case blockEnd.offset === offset && blockEnd.textIndex === textIndex && !prev: // move all nodes of next block to this block
  10084. var nextBlock = this.blocks[blockIndex + 1];
  10085. if (!nextBlock) {
  10086. return;
  10087. }
  10088. if (nextBlock.isEmpty()) {
  10089. this.removeBlock(blockIndex + 1);
  10090. return true;
  10091. }
  10092. this.blocks[blockIndex].textNodes = this.blocks[blockIndex].textNodes.concat(nextBlock.textNodes);
  10093. this.removeBlock(blockIndex + 1);
  10094. break;
  10095. default:
  10096. var removeResult = textNode.remove(offset, prev);
  10097. switch (removeResult) {
  10098. case TextNode_1.RemoveTextResult.nullTextLength:
  10099. if (textNodes.length > 1) {
  10100. textNodes.splice(textIndex, 1);
  10101. if (textIndex === 0) {
  10102. selection.left = {
  10103. blockIndex: blockIndex,
  10104. textIndex: 0,
  10105. offset: 0
  10106. };
  10107. }
  10108. else {
  10109. selection.left = {
  10110. blockIndex: blockIndex,
  10111. textIndex: textIndex - 1,
  10112. offset: textNodes[textIndex - 1].text.length
  10113. };
  10114. }
  10115. }
  10116. else {
  10117. textNode.style = constants_1.emptyStyle;
  10118. selection.left = {
  10119. textIndex: textIndex,
  10120. blockIndex: blockIndex,
  10121. offset: 0
  10122. };
  10123. }
  10124. break;
  10125. case TextNode_1.RemoveTextResult.complete:
  10126. if (prev) {
  10127. selection.left = {
  10128. blockIndex: blockIndex,
  10129. textIndex: textIndex,
  10130. offset: offset - 1
  10131. };
  10132. }
  10133. break;
  10134. case TextNode_1.RemoveTextResult.forceRemoveNext:
  10135. selection.left = {
  10136. blockIndex: blockIndex,
  10137. textIndex: textIndex + 1,
  10138. offset: 0
  10139. };
  10140. repeat = true;
  10141. break;
  10142. case TextNode_1.RemoveTextResult.forceRemovePrevious:
  10143. selection.left = {
  10144. blockIndex: blockIndex,
  10145. textIndex: textIndex - 1,
  10146. offset: textNodes[textIndex - 1].text.length
  10147. };
  10148. repeat = true;
  10149. break;
  10150. }
  10151. }
  10152. this.selection.set(selection);
  10153. if (repeat) {
  10154. return this._removeSymbol(prev);
  10155. }
  10156. return true;
  10157. };
  10158. Editor.prototype._eachLink = function (fn) {
  10159. var left = this.selection.get().left;
  10160. var link = this.blocks[left.blockIndex].textNodes[left.textIndex].style.link;
  10161. if (!link) {
  10162. return;
  10163. }
  10164. var block = this.blocks[left.blockIndex];
  10165. var textNodes = block.textNodes;
  10166. var linkNodes = [];
  10167. for (var i = left.textIndex; i >= 0; i--) {
  10168. if (textNodes[i].style.link !== link) {
  10169. break;
  10170. }
  10171. linkNodes.unshift(textNodes[i]);
  10172. }
  10173. for (var i = left.textIndex + 1; i < textNodes.length; i++) {
  10174. if (textNodes[i].style.link !== link) {
  10175. break;
  10176. }
  10177. linkNodes.push(textNodes[i]);
  10178. }
  10179. linkNodes.forEach(fn);
  10180. };
  10181. Editor.prototype._createTempTextNode = function (_a) {
  10182. var modifier = _a.modifier, modifierValue = _a.modifierValue;
  10183. var _b;
  10184. var _c = this.selection.get().left, offset = _c.offset, blockIndex = _c.blockIndex, textIndex = _c.textIndex;
  10185. var nodeStyle;
  10186. if (this._tempNode && this._tempNode.offset === offset &&
  10187. this._tempNode.blockIndex === blockIndex && this._tempNode.textIndex === textIndex) {
  10188. nodeStyle = this._tempNode.style;
  10189. }
  10190. else {
  10191. nodeStyle = this.blocks[blockIndex].textNodes[textIndex].style;
  10192. }
  10193. var tempStyle = __assign({}, nodeStyle, (_b = {}, _b[modifier] = modifierValue, _b));
  10194. var textNodes = this.blocks[blockIndex].textNodes;
  10195. if (tempStyle.link && (!textNodes[textIndex + 1] || !textNodes[textIndex + 1].style.link)) {
  10196. delete tempStyle.link;
  10197. }
  10198. this._tempNode = {
  10199. style: tempStyle,
  10200. blockIndex: blockIndex,
  10201. textIndex: textIndex,
  10202. offset: offset
  10203. };
  10204. };
  10205. Editor.prototype._createNodeFromTemp = function (data) {
  10206. var _a = this._tempNode, style = _a.style, blockIndex = _a.blockIndex, textIndex = _a.textIndex, offset = _a.offset;
  10207. var splitResult = this.blocks[blockIndex].splitTextNode(textIndex, offset);
  10208. var newTextIndex = splitResult === Block_1.SplitResult.offsetStart ? textIndex : textIndex + 1;
  10209. var textNode = new TextNode_1.TextNode(data, style);
  10210. if (this.blocks[blockIndex].isEmpty()) {
  10211. this.blocks[blockIndex].textNodes = [textNode];
  10212. }
  10213. else {
  10214. this.blocks[blockIndex].textNodes.splice(newTextIndex, 0, textNode);
  10215. }
  10216. this.selection.set({
  10217. range: false,
  10218. left: {
  10219. blockIndex: blockIndex,
  10220. textIndex: newTextIndex,
  10221. offset: data.length
  10222. }
  10223. });
  10224. this._tempNode = null;
  10225. return true;
  10226. };
  10227. return Editor;
  10228. }());
  10229. exports.Editor = Editor;
  10230. /***/ }),
  10231. /* 80 */
  10232. /***/ (function(module, exports, __webpack_require__) {
  10233. "use strict";
  10234. Object.defineProperty(exports, "__esModule", { value: true });
  10235. var types_1 = __webpack_require__(2);
  10236. function markdownSerializer(blocks) {
  10237. return blocks.reduce(function (res, block, i) { return res + (i ? "\n\n" : "") + blockPrefix(block) + serializeBlockContent(block); }, "");
  10238. }
  10239. exports.markdownSerializer = markdownSerializer;
  10240. function blockPrefix(block) {
  10241. switch (block.style[types_1.Modifier.style]) {
  10242. case "h1":
  10243. return "# ";
  10244. case "h2":
  10245. return "## ";
  10246. case "h3":
  10247. return "### ";
  10248. case "h4":
  10249. return "#### ";
  10250. case "h5":
  10251. return "##### ";
  10252. case "h6":
  10253. return "###### ";
  10254. default:
  10255. return "";
  10256. }
  10257. }
  10258. function serializeBlockContent(block) {
  10259. var result = "";
  10260. var textNodes = block.textNodes;
  10261. var group = [];
  10262. var currentLink;
  10263. for (var _i = 0, textNodes_1 = textNodes; _i < textNodes_1.length; _i++) {
  10264. var textNode = textNodes_1[_i];
  10265. if (textNode.style.link) {
  10266. if (currentLink === textNode.style.link) {
  10267. group.push(textNode);
  10268. }
  10269. else {
  10270. if (group.length) {
  10271. result += serializeGroup(group, currentLink);
  10272. }
  10273. group = [textNode];
  10274. }
  10275. }
  10276. else {
  10277. if (currentLink) {
  10278. if (group.length) {
  10279. result += serializeGroup(group, currentLink);
  10280. }
  10281. group = [textNode];
  10282. }
  10283. else {
  10284. group.push(textNode);
  10285. }
  10286. }
  10287. currentLink = textNode.style.link;
  10288. }
  10289. result += serializeGroup(group, currentLink);
  10290. return result;
  10291. }
  10292. var Decorator;
  10293. (function (Decorator) {
  10294. Decorator["bold"] = "**";
  10295. Decorator["italic"] = "*";
  10296. // strike = "~~"
  10297. })(Decorator || (Decorator = {}));
  10298. function serializeGroup(textNodes, link) {
  10299. var result = "";
  10300. var prevDecorators = [];
  10301. for (var _i = 0, textNodes_2 = textNodes; _i < textNodes_2.length; _i++) {
  10302. var textNode = textNodes_2[_i];
  10303. var currentDecorators = [];
  10304. var style = textNode.style;
  10305. if (style[types_1.Modifier.bold]) {
  10306. currentDecorators.push(Decorator.bold);
  10307. }
  10308. if (style[types_1.Modifier.italic]) {
  10309. currentDecorators.push(Decorator.italic);
  10310. }
  10311. var dif = decoratorsDif(prevDecorators, currentDecorators);
  10312. result += dif.join("") + textNode.text;
  10313. prevDecorators = currentDecorators;
  10314. }
  10315. result += prevDecorators.join("");
  10316. if (link) {
  10317. result = "[" + result + "](" + link + ")";
  10318. }
  10319. return result;
  10320. }
  10321. function decoratorsDif(prev, current) {
  10322. var open = current.filter(function (decorator) { return prev.indexOf(decorator) === -1; });
  10323. var close = prev.filter(function (decorator) { return current.indexOf(decorator) === -1; });
  10324. return open.concat(close);
  10325. }
  10326. /***/ }),
  10327. /* 81 */
  10328. /***/ (function(module, exports, __webpack_require__) {
  10329. "use strict";
  10330. Object.defineProperty(exports, "__esModule", { value: true });
  10331. var types_1 = __webpack_require__(2);
  10332. function minimizeTextNodeStyle(style) {
  10333. var formatting = style[types_1.Modifier.bold] | style[types_1.Modifier.italic] << 1 | style[types_1.Modifier.underline] << 2 | style[types_1.Modifier.strike] << 3;
  10334. var minimal = {};
  10335. if (formatting !== 0) {
  10336. minimal.f = formatting;
  10337. }
  10338. if (style[types_1.Modifier.fontSize]) {
  10339. minimal.s = parseInt(style[types_1.Modifier.fontSize], 10);
  10340. }
  10341. if (style[types_1.Modifier.fontFamily]) {
  10342. minimal.t = style[types_1.Modifier.fontFamily];
  10343. }
  10344. if (style[types_1.Modifier.color]) {
  10345. minimal.c = style[types_1.Modifier.color];
  10346. }
  10347. if (style[types_1.Modifier.background]) {
  10348. minimal.b = style[types_1.Modifier.background];
  10349. }
  10350. if (style[types_1.Modifier.link]) {
  10351. minimal.a = style[types_1.Modifier.link];
  10352. }
  10353. return minimal;
  10354. }
  10355. exports.minimizeTextNodeStyle = minimizeTextNodeStyle;
  10356. function textNodeStyleFromMinimize(minimal) {
  10357. var result = {};
  10358. if (minimal.f) {
  10359. if (minimal.f & 1) {
  10360. result[types_1.Modifier.bold] = true;
  10361. }
  10362. if (minimal.f & 2) {
  10363. result[types_1.Modifier.italic] = true;
  10364. }
  10365. if (minimal.f & 4) {
  10366. result[types_1.Modifier.underline] = true;
  10367. }
  10368. if (minimal.f & 8) {
  10369. result[types_1.Modifier.strike] = true;
  10370. }
  10371. }
  10372. if (minimal.s) {
  10373. result[types_1.Modifier.fontSize] = minimal.s + "px";
  10374. }
  10375. if (minimal.t) {
  10376. result[types_1.Modifier.fontFamily] = minimal.t;
  10377. }
  10378. if (minimal.c) {
  10379. result[types_1.Modifier.color] = minimal.c;
  10380. }
  10381. if (minimal.b) {
  10382. result[types_1.Modifier.background] = minimal.b;
  10383. }
  10384. if (minimal.a) {
  10385. result[types_1.Modifier.link] = minimal.a;
  10386. }
  10387. return result;
  10388. }
  10389. exports.textNodeStyleFromMinimize = textNodeStyleFromMinimize;
  10390. var alignToNumber = {
  10391. left: 1,
  10392. center: 2,
  10393. right: 3
  10394. };
  10395. var numberToAlign = {
  10396. 1: "left",
  10397. 2: "center",
  10398. 3: "right"
  10399. };
  10400. var styleToNumber = {
  10401. h1: 1,
  10402. h2: 2,
  10403. h3: 3,
  10404. h4: 4,
  10405. h5: 5,
  10406. h6: 6
  10407. };
  10408. var numberToStyle = {
  10409. 1: "h1",
  10410. 2: "h2",
  10411. 3: "h3",
  10412. 4: "h4",
  10413. 5: "h5",
  10414. 6: "h6"
  10415. };
  10416. function minimizeBlockStyle(style) {
  10417. var minimal = {};
  10418. if (style[types_1.Modifier.blockquote]) {
  10419. minimal.b = 1;
  10420. }
  10421. if (style[types_1.Modifier.style]) {
  10422. var value = styleToNumber[style[types_1.Modifier.style]];
  10423. if (value) {
  10424. minimal.s = value;
  10425. }
  10426. }
  10427. if (style[types_1.Modifier.align]) {
  10428. minimal.a = alignToNumber[style[types_1.Modifier.align]];
  10429. }
  10430. return minimal;
  10431. }
  10432. exports.minimizeBlockStyle = minimizeBlockStyle;
  10433. function blockStyleFromMinimize(minimal) {
  10434. var result = {};
  10435. if (minimal.a) {
  10436. result[types_1.Modifier.align] = numberToAlign[minimal.a];
  10437. }
  10438. if (minimal.b) {
  10439. result[types_1.Modifier.blockquote] = true;
  10440. }
  10441. result[types_1.Modifier.style] = numberToStyle[minimal.s] || "p";
  10442. return result;
  10443. }
  10444. exports.blockStyleFromMinimize = blockStyleFromMinimize;
  10445. /***/ }),
  10446. /* 82 */
  10447. /***/ (function(module, exports, __webpack_require__) {
  10448. "use strict";
  10449. var __assign = (this && this.__assign) || Object.assign || function(t) {
  10450. for (var s, i = 1, n = arguments.length; i < n; i++) {
  10451. s = arguments[i];
  10452. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  10453. t[p] = s[p];
  10454. }
  10455. return t;
  10456. };
  10457. Object.defineProperty(exports, "__esModule", { value: true });
  10458. var marked = __webpack_require__(83);
  10459. var constants_1 = __webpack_require__(5);
  10460. var Block_1 = __webpack_require__(34);
  10461. var TextNode_1 = __webpack_require__(20);
  10462. var types_1 = __webpack_require__(2);
  10463. function parser(str, mode) {
  10464. if (mode === void 0) { mode = "html"; }
  10465. var _a;
  10466. if (mode === "markdown") {
  10467. str = marked(str);
  10468. }
  10469. var htmlElement = document.createElement("div");
  10470. htmlElement.innerHTML = str.replace(/<br\s*[\/]?>/g, "\n");
  10471. var blocks = [];
  10472. parseBlocks(htmlElement, blocks);
  10473. if (blocks.length === 0) {
  10474. var style = __assign((_a = {}, _a[types_1.Modifier.style] = blockTags[htmlElement.nodeName] || "p", _a), getBlockStyle(htmlElement));
  10475. var textNodes = [];
  10476. parseTextNodes(htmlElement, textNodes);
  10477. var block = new Block_1.Block(textNodes, style);
  10478. return [block];
  10479. }
  10480. return blocks;
  10481. }
  10482. exports.parser = parser;
  10483. var blockTags = {
  10484. P: "p",
  10485. H1: "h1",
  10486. H2: "h2",
  10487. H3: "h3",
  10488. H4: "h4",
  10489. H5: "h5",
  10490. H6: "h6"
  10491. };
  10492. function parseBlocks(htmlElement, blocks, style) {
  10493. if (style === void 0) { style = {}; }
  10494. var _a;
  10495. style = __assign({}, style, getBlockStyle(htmlElement));
  10496. if (blockTags[htmlElement.nodeName]) {
  10497. var textNodes = [];
  10498. parseTextNodes(htmlElement, textNodes);
  10499. var block = new Block_1.Block(textNodes, __assign({}, style, (_a = {}, _a[types_1.Modifier.style] = blockTags[htmlElement.nodeName], _a)));
  10500. blocks.push(block);
  10501. return;
  10502. }
  10503. var childs = htmlElement.childNodes;
  10504. for (var i = 0; i < childs.length; i++) {
  10505. parseBlocks(childs[i], blocks, style);
  10506. }
  10507. }
  10508. function tagToStyle(htmlElement) {
  10509. var _a, _b, _c, _d, _e;
  10510. switch (htmlElement.nodeName) {
  10511. case "B":
  10512. case "STRONG":
  10513. return _a = {},
  10514. _a[types_1.Modifier.bold] = true,
  10515. _a;
  10516. case "I":
  10517. case "EM":
  10518. return _b = {},
  10519. _b[types_1.Modifier.italic] = true,
  10520. _b;
  10521. case "U":
  10522. return _c = {},
  10523. _c[types_1.Modifier.underline] = true,
  10524. _c;
  10525. case "STRIKE":
  10526. case "S":
  10527. return _d = {},
  10528. _d[types_1.Modifier.strike] = true,
  10529. _d;
  10530. case "A":
  10531. return _e = {},
  10532. _e[types_1.Modifier.link] = htmlElement.href,
  10533. _e;
  10534. default:
  10535. return {};
  10536. }
  10537. }
  10538. function parseTextNodes(htmlElement, textNodes, style) {
  10539. if (style === void 0) { style = {}; }
  10540. if (htmlElement.nodeType === htmlElement.TEXT_NODE) {
  10541. var text = htmlElement.textContent
  10542. .replace(/&nbsp;/g, " ")
  10543. .replace(/&lt;/g, "<")
  10544. .replace(/&gt;/g, ">");
  10545. if (text.replace(/\n/g, "").length === 0) { // ignore empty nodes: TODO fix
  10546. return;
  10547. }
  10548. var textNode = new TextNode_1.TextNode(text, style);
  10549. textNodes.push(textNode);
  10550. return;
  10551. }
  10552. var elementStyle = {};
  10553. var _a = htmlElement.style || {}, fontSize = _a.fontSize, fontWeight = _a.fontWeight, fontFamily = _a.fontFamily, color = _a.color, background = _a.background, backgroundColor = _a.backgroundColor, textDecoration = _a.textDecoration, fontStyle = _a.fontStyle;
  10554. var tagStyle = tagToStyle(htmlElement);
  10555. if (fontSize) {
  10556. elementStyle[types_1.Modifier.fontSize] = constants_1.fontSizes[fontSize] ? fontSize : "14px";
  10557. }
  10558. if (fontWeight) {
  10559. elementStyle[types_1.Modifier.bold] = fontWeight === "bold" || parseInt(fontWeight, 10) >= 600;
  10560. }
  10561. if (fontFamily) {
  10562. elementStyle[types_1.Modifier.fontFamily] = constants_1.fonts[fontFamily] ? fontFamily : "Roboto";
  10563. }
  10564. if (color) {
  10565. elementStyle[types_1.Modifier.color] = color;
  10566. }
  10567. if (background || backgroundColor) {
  10568. elementStyle[types_1.Modifier.background] = background || backgroundColor;
  10569. }
  10570. if (textDecoration === "underline") {
  10571. elementStyle[types_1.Modifier.underline] = true;
  10572. }
  10573. if (textDecoration === "line-through") {
  10574. elementStyle[types_1.Modifier.strike] = true;
  10575. }
  10576. if (fontStyle) {
  10577. elementStyle[types_1.Modifier.italic] = fontStyle === "italic";
  10578. }
  10579. var fullStyle = __assign({}, style, tagStyle, elementStyle);
  10580. var childs = htmlElement.childNodes;
  10581. for (var i = 0; i < childs.length; i++) {
  10582. parseTextNodes(childs[i], textNodes, fullStyle);
  10583. }
  10584. }
  10585. function getBlockStyle(htmlElement) {
  10586. if (!htmlElement || !htmlElement.style) {
  10587. return {};
  10588. }
  10589. var style = {};
  10590. if (htmlElement.style.textAlign) {
  10591. style[types_1.Modifier.align] = htmlElement.style.textAlign;
  10592. }
  10593. if (htmlElement.nodeName === "BLOCKQUOTE") {
  10594. style[types_1.Modifier.blockquote] = true;
  10595. }
  10596. return style;
  10597. }
  10598. /***/ }),
  10599. /* 83 */
  10600. /***/ (function(module, exports, __webpack_require__) {
  10601. /* WEBPACK VAR INJECTION */(function(global) {/**
  10602. * marked - a markdown parser
  10603. * Copyright (c) 2011-2018, Christopher Jeffrey. (MIT Licensed)
  10604. * https://github.com/markedjs/marked
  10605. */
  10606. ;(function(root) {
  10607. 'use strict';
  10608. /**
  10609. * Block-Level Grammar
  10610. */
  10611. var block = {
  10612. newline: /^\n+/,
  10613. code: /^( {4}[^\n]+\n*)+/,
  10614. fences: noop,
  10615. hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
  10616. heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
  10617. nptable: noop,
  10618. blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
  10619. list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
  10620. html: '^ {0,3}(?:' // optional indentation
  10621. + '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
  10622. + '|comment[^\\n]*(\\n+|$)' // (2)
  10623. + '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
  10624. + '|<![A-Z][\\s\\S]*?>\\n*' // (4)
  10625. + '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' // (5)
  10626. + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
  10627. + '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
  10628. + '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
  10629. + ')',
  10630. def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
  10631. table: noop,
  10632. lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
  10633. paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)*)/,
  10634. text: /^[^\n]+/
  10635. };
  10636. block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
  10637. block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
  10638. block.def = edit(block.def)
  10639. .replace('label', block._label)
  10640. .replace('title', block._title)
  10641. .getRegex();
  10642. block.bullet = /(?:[*+-]|\d+\.)/;
  10643. block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
  10644. block.item = edit(block.item, 'gm')
  10645. .replace(/bull/g, block.bullet)
  10646. .getRegex();
  10647. block.list = edit(block.list)
  10648. .replace(/bull/g, block.bullet)
  10649. .replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
  10650. .replace('def', '\\n+(?=' + block.def.source + ')')
  10651. .getRegex();
  10652. block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
  10653. + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
  10654. + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
  10655. + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
  10656. + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
  10657. + '|track|ul';
  10658. block._comment = /<!--(?!-?>)[\s\S]*?-->/;
  10659. block.html = edit(block.html, 'i')
  10660. .replace('comment', block._comment)
  10661. .replace('tag', block._tag)
  10662. .replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
  10663. .getRegex();
  10664. block.paragraph = edit(block.paragraph)
  10665. .replace('hr', block.hr)
  10666. .replace('heading', block.heading)
  10667. .replace('lheading', block.lheading)
  10668. .replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
  10669. .getRegex();
  10670. block.blockquote = edit(block.blockquote)
  10671. .replace('paragraph', block.paragraph)
  10672. .getRegex();
  10673. /**
  10674. * Normal Block Grammar
  10675. */
  10676. block.normal = merge({}, block);
  10677. /**
  10678. * GFM Block Grammar
  10679. */
  10680. block.gfm = merge({}, block.normal, {
  10681. fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,
  10682. paragraph: /^/,
  10683. heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
  10684. });
  10685. block.gfm.paragraph = edit(block.paragraph)
  10686. .replace('(?!', '(?!'
  10687. + block.gfm.fences.source.replace('\\1', '\\2') + '|'
  10688. + block.list.source.replace('\\1', '\\3') + '|')
  10689. .getRegex();
  10690. /**
  10691. * GFM + Tables Block Grammar
  10692. */
  10693. block.tables = merge({}, block.gfm, {
  10694. nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,
  10695. table: /^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/
  10696. });
  10697. /**
  10698. * Pedantic grammar
  10699. */
  10700. block.pedantic = merge({}, block.normal, {
  10701. html: edit(
  10702. '^ *(?:comment *(?:\\n|\\s*$)'
  10703. + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
  10704. + '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
  10705. .replace('comment', block._comment)
  10706. .replace(/tag/g, '(?!(?:'
  10707. + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
  10708. + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
  10709. + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
  10710. .getRegex(),
  10711. def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/
  10712. });
  10713. /**
  10714. * Block Lexer
  10715. */
  10716. function Lexer(options) {
  10717. this.tokens = [];
  10718. this.tokens.links = Object.create(null);
  10719. this.options = options || marked.defaults;
  10720. this.rules = block.normal;
  10721. if (this.options.pedantic) {
  10722. this.rules = block.pedantic;
  10723. } else if (this.options.gfm) {
  10724. if (this.options.tables) {
  10725. this.rules = block.tables;
  10726. } else {
  10727. this.rules = block.gfm;
  10728. }
  10729. }
  10730. }
  10731. /**
  10732. * Expose Block Rules
  10733. */
  10734. Lexer.rules = block;
  10735. /**
  10736. * Static Lex Method
  10737. */
  10738. Lexer.lex = function(src, options) {
  10739. var lexer = new Lexer(options);
  10740. return lexer.lex(src);
  10741. };
  10742. /**
  10743. * Preprocessing
  10744. */
  10745. Lexer.prototype.lex = function(src) {
  10746. src = src
  10747. .replace(/\r\n|\r/g, '\n')
  10748. .replace(/\t/g, ' ')
  10749. .replace(/\u00a0/g, ' ')
  10750. .replace(/\u2424/g, '\n');
  10751. return this.token(src, true);
  10752. };
  10753. /**
  10754. * Lexing
  10755. */
  10756. Lexer.prototype.token = function(src, top) {
  10757. src = src.replace(/^ +$/gm, '');
  10758. var next,
  10759. loose,
  10760. cap,
  10761. bull,
  10762. b,
  10763. item,
  10764. listStart,
  10765. listItems,
  10766. t,
  10767. space,
  10768. i,
  10769. tag,
  10770. l,
  10771. isordered,
  10772. istask,
  10773. ischecked;
  10774. while (src) {
  10775. // newline
  10776. if (cap = this.rules.newline.exec(src)) {
  10777. src = src.substring(cap[0].length);
  10778. if (cap[0].length > 1) {
  10779. this.tokens.push({
  10780. type: 'space'
  10781. });
  10782. }
  10783. }
  10784. // code
  10785. if (cap = this.rules.code.exec(src)) {
  10786. src = src.substring(cap[0].length);
  10787. cap = cap[0].replace(/^ {4}/gm, '');
  10788. this.tokens.push({
  10789. type: 'code',
  10790. text: !this.options.pedantic
  10791. ? rtrim(cap, '\n')
  10792. : cap
  10793. });
  10794. continue;
  10795. }
  10796. // fences (gfm)
  10797. if (cap = this.rules.fences.exec(src)) {
  10798. src = src.substring(cap[0].length);
  10799. this.tokens.push({
  10800. type: 'code',
  10801. lang: cap[2],
  10802. text: cap[3] || ''
  10803. });
  10804. continue;
  10805. }
  10806. // heading
  10807. if (cap = this.rules.heading.exec(src)) {
  10808. src = src.substring(cap[0].length);
  10809. this.tokens.push({
  10810. type: 'heading',
  10811. depth: cap[1].length,
  10812. text: cap[2]
  10813. });
  10814. continue;
  10815. }
  10816. // table no leading pipe (gfm)
  10817. if (top && (cap = this.rules.nptable.exec(src))) {
  10818. item = {
  10819. type: 'table',
  10820. header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
  10821. align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
  10822. cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
  10823. };
  10824. if (item.header.length === item.align.length) {
  10825. src = src.substring(cap[0].length);
  10826. for (i = 0; i < item.align.length; i++) {
  10827. if (/^ *-+: *$/.test(item.align[i])) {
  10828. item.align[i] = 'right';
  10829. } else if (/^ *:-+: *$/.test(item.align[i])) {
  10830. item.align[i] = 'center';
  10831. } else if (/^ *:-+ *$/.test(item.align[i])) {
  10832. item.align[i] = 'left';
  10833. } else {
  10834. item.align[i] = null;
  10835. }
  10836. }
  10837. for (i = 0; i < item.cells.length; i++) {
  10838. item.cells[i] = splitCells(item.cells[i], item.header.length);
  10839. }
  10840. this.tokens.push(item);
  10841. continue;
  10842. }
  10843. }
  10844. // hr
  10845. if (cap = this.rules.hr.exec(src)) {
  10846. src = src.substring(cap[0].length);
  10847. this.tokens.push({
  10848. type: 'hr'
  10849. });
  10850. continue;
  10851. }
  10852. // blockquote
  10853. if (cap = this.rules.blockquote.exec(src)) {
  10854. src = src.substring(cap[0].length);
  10855. this.tokens.push({
  10856. type: 'blockquote_start'
  10857. });
  10858. cap = cap[0].replace(/^ *> ?/gm, '');
  10859. // Pass `top` to keep the current
  10860. // "toplevel" state. This is exactly
  10861. // how markdown.pl works.
  10862. this.token(cap, top);
  10863. this.tokens.push({
  10864. type: 'blockquote_end'
  10865. });
  10866. continue;
  10867. }
  10868. // list
  10869. if (cap = this.rules.list.exec(src)) {
  10870. src = src.substring(cap[0].length);
  10871. bull = cap[2];
  10872. isordered = bull.length > 1;
  10873. listStart = {
  10874. type: 'list_start',
  10875. ordered: isordered,
  10876. start: isordered ? +bull : '',
  10877. loose: false
  10878. };
  10879. this.tokens.push(listStart);
  10880. // Get each top-level item.
  10881. cap = cap[0].match(this.rules.item);
  10882. listItems = [];
  10883. next = false;
  10884. l = cap.length;
  10885. i = 0;
  10886. for (; i < l; i++) {
  10887. item = cap[i];
  10888. // Remove the list item's bullet
  10889. // so it is seen as the next token.
  10890. space = item.length;
  10891. item = item.replace(/^ *([*+-]|\d+\.) +/, '');
  10892. // Outdent whatever the
  10893. // list item contains. Hacky.
  10894. if (~item.indexOf('\n ')) {
  10895. space -= item.length;
  10896. item = !this.options.pedantic
  10897. ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
  10898. : item.replace(/^ {1,4}/gm, '');
  10899. }
  10900. // Determine whether the next list item belongs here.
  10901. // Backpedal if it does not belong in this list.
  10902. if (this.options.smartLists && i !== l - 1) {
  10903. b = block.bullet.exec(cap[i + 1])[0];
  10904. if (bull !== b && !(bull.length > 1 && b.length > 1)) {
  10905. src = cap.slice(i + 1).join('\n') + src;
  10906. i = l - 1;
  10907. }
  10908. }
  10909. // Determine whether item is loose or not.
  10910. // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
  10911. // for discount behavior.
  10912. loose = next || /\n\n(?!\s*$)/.test(item);
  10913. if (i !== l - 1) {
  10914. next = item.charAt(item.length - 1) === '\n';
  10915. if (!loose) loose = next;
  10916. }
  10917. if (loose) {
  10918. listStart.loose = true;
  10919. }
  10920. // Check for task list items
  10921. istask = /^\[[ xX]\] /.test(item);
  10922. ischecked = undefined;
  10923. if (istask) {
  10924. ischecked = item[1] !== ' ';
  10925. item = item.replace(/^\[[ xX]\] +/, '');
  10926. }
  10927. t = {
  10928. type: 'list_item_start',
  10929. task: istask,
  10930. checked: ischecked,
  10931. loose: loose
  10932. };
  10933. listItems.push(t);
  10934. this.tokens.push(t);
  10935. // Recurse.
  10936. this.token(item, false);
  10937. this.tokens.push({
  10938. type: 'list_item_end'
  10939. });
  10940. }
  10941. if (listStart.loose) {
  10942. l = listItems.length;
  10943. i = 0;
  10944. for (; i < l; i++) {
  10945. listItems[i].loose = true;
  10946. }
  10947. }
  10948. this.tokens.push({
  10949. type: 'list_end'
  10950. });
  10951. continue;
  10952. }
  10953. // html
  10954. if (cap = this.rules.html.exec(src)) {
  10955. src = src.substring(cap[0].length);
  10956. this.tokens.push({
  10957. type: this.options.sanitize
  10958. ? 'paragraph'
  10959. : 'html',
  10960. pre: !this.options.sanitizer
  10961. && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
  10962. text: cap[0]
  10963. });
  10964. continue;
  10965. }
  10966. // def
  10967. if (top && (cap = this.rules.def.exec(src))) {
  10968. src = src.substring(cap[0].length);
  10969. if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
  10970. tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
  10971. if (!this.tokens.links[tag]) {
  10972. this.tokens.links[tag] = {
  10973. href: cap[2],
  10974. title: cap[3]
  10975. };
  10976. }
  10977. continue;
  10978. }
  10979. // table (gfm)
  10980. if (top && (cap = this.rules.table.exec(src))) {
  10981. item = {
  10982. type: 'table',
  10983. header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
  10984. align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
  10985. cells: cap[3] ? cap[3].replace(/(?: *\| *)?\n$/, '').split('\n') : []
  10986. };
  10987. if (item.header.length === item.align.length) {
  10988. src = src.substring(cap[0].length);
  10989. for (i = 0; i < item.align.length; i++) {
  10990. if (/^ *-+: *$/.test(item.align[i])) {
  10991. item.align[i] = 'right';
  10992. } else if (/^ *:-+: *$/.test(item.align[i])) {
  10993. item.align[i] = 'center';
  10994. } else if (/^ *:-+ *$/.test(item.align[i])) {
  10995. item.align[i] = 'left';
  10996. } else {
  10997. item.align[i] = null;
  10998. }
  10999. }
  11000. for (i = 0; i < item.cells.length; i++) {
  11001. item.cells[i] = splitCells(
  11002. item.cells[i].replace(/^ *\| *| *\| *$/g, ''),
  11003. item.header.length);
  11004. }
  11005. this.tokens.push(item);
  11006. continue;
  11007. }
  11008. }
  11009. // lheading
  11010. if (cap = this.rules.lheading.exec(src)) {
  11011. src = src.substring(cap[0].length);
  11012. this.tokens.push({
  11013. type: 'heading',
  11014. depth: cap[2] === '=' ? 1 : 2,
  11015. text: cap[1]
  11016. });
  11017. continue;
  11018. }
  11019. // top-level paragraph
  11020. if (top && (cap = this.rules.paragraph.exec(src))) {
  11021. src = src.substring(cap[0].length);
  11022. this.tokens.push({
  11023. type: 'paragraph',
  11024. text: cap[1].charAt(cap[1].length - 1) === '\n'
  11025. ? cap[1].slice(0, -1)
  11026. : cap[1]
  11027. });
  11028. continue;
  11029. }
  11030. // text
  11031. if (cap = this.rules.text.exec(src)) {
  11032. // Top-level should never reach here.
  11033. src = src.substring(cap[0].length);
  11034. this.tokens.push({
  11035. type: 'text',
  11036. text: cap[0]
  11037. });
  11038. continue;
  11039. }
  11040. if (src) {
  11041. throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
  11042. }
  11043. }
  11044. return this.tokens;
  11045. };
  11046. /**
  11047. * Inline-Level Grammar
  11048. */
  11049. var inline = {
  11050. escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
  11051. autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
  11052. url: noop,
  11053. tag: '^comment'
  11054. + '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
  11055. + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
  11056. + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
  11057. + '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
  11058. + '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>', // CDATA section
  11059. link: /^!?\[(label)\]\(href(?:\s+(title))?\s*\)/,
  11060. reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
  11061. nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
  11062. strong: /^__([^\s])__(?!_)|^\*\*([^\s])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
  11063. em: /^_([^\s_])_(?!_)|^\*([^\s*"<\[])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_|[^\s.])|^_([^\s_][\s\S]*?[^\s])_(?!_|[^\s.])|^\*([^\s"<\[][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,
  11064. code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
  11065. br: /^( {2,}|\\)\n(?!\s*$)/,
  11066. del: noop,
  11067. text: /^(`+|[^`])[\s\S]*?(?=[\\<!\[`*]|\b_| {2,}\n|$)/
  11068. };
  11069. inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
  11070. inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
  11071. 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])?)+(?![-_])/;
  11072. inline.autolink = edit(inline.autolink)
  11073. .replace('scheme', inline._scheme)
  11074. .replace('email', inline._email)
  11075. .getRegex();
  11076. inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
  11077. inline.tag = edit(inline.tag)
  11078. .replace('comment', block._comment)
  11079. .replace('attribute', inline._attribute)
  11080. .getRegex();
  11081. inline._label = /(?:\[[^\[\]]*\]|\\[\[\]]?|`[^`]*`|[^\[\]\\])*?/;
  11082. inline._href = /\s*(<(?:\\[<>]?|[^\s<>\\])*>|(?:\\[()]?|\([^\s\x00-\x1f\\]*\)|[^\s\x00-\x1f()\\])*?)/;
  11083. inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
  11084. inline.link = edit(inline.link)
  11085. .replace('label', inline._label)
  11086. .replace('href', inline._href)
  11087. .replace('title', inline._title)
  11088. .getRegex();
  11089. inline.reflink = edit(inline.reflink)
  11090. .replace('label', inline._label)
  11091. .getRegex();
  11092. /**
  11093. * Normal Inline Grammar
  11094. */
  11095. inline.normal = merge({}, inline);
  11096. /**
  11097. * Pedantic Inline Grammar
  11098. */
  11099. inline.pedantic = merge({}, inline.normal, {
  11100. strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
  11101. em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
  11102. link: edit(/^!?\[(label)\]\((.*?)\)/)
  11103. .replace('label', inline._label)
  11104. .getRegex(),
  11105. reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
  11106. .replace('label', inline._label)
  11107. .getRegex()
  11108. });
  11109. /**
  11110. * GFM Inline Grammar
  11111. */
  11112. inline.gfm = merge({}, inline.normal, {
  11113. escape: edit(inline.escape).replace('])', '~|])').getRegex(),
  11114. _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
  11115. url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
  11116. _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
  11117. del: /^~+(?=\S)([\s\S]*?\S)~+/,
  11118. text: edit(inline.text)
  11119. .replace(']|', '~]|')
  11120. .replace('|$', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|$')
  11121. .getRegex()
  11122. });
  11123. inline.gfm.url = edit(inline.gfm.url)
  11124. .replace('email', inline.gfm._extended_email)
  11125. .getRegex();
  11126. /**
  11127. * GFM + Line Breaks Inline Grammar
  11128. */
  11129. inline.breaks = merge({}, inline.gfm, {
  11130. br: edit(inline.br).replace('{2,}', '*').getRegex(),
  11131. text: edit(inline.gfm.text).replace('{2,}', '*').getRegex()
  11132. });
  11133. /**
  11134. * Inline Lexer & Compiler
  11135. */
  11136. function InlineLexer(links, options) {
  11137. this.options = options || marked.defaults;
  11138. this.links = links;
  11139. this.rules = inline.normal;
  11140. this.renderer = this.options.renderer || new Renderer();
  11141. this.renderer.options = this.options;
  11142. if (!this.links) {
  11143. throw new Error('Tokens array requires a `links` property.');
  11144. }
  11145. if (this.options.pedantic) {
  11146. this.rules = inline.pedantic;
  11147. } else if (this.options.gfm) {
  11148. if (this.options.breaks) {
  11149. this.rules = inline.breaks;
  11150. } else {
  11151. this.rules = inline.gfm;
  11152. }
  11153. }
  11154. }
  11155. /**
  11156. * Expose Inline Rules
  11157. */
  11158. InlineLexer.rules = inline;
  11159. /**
  11160. * Static Lexing/Compiling Method
  11161. */
  11162. InlineLexer.output = function(src, links, options) {
  11163. var inline = new InlineLexer(links, options);
  11164. return inline.output(src);
  11165. };
  11166. /**
  11167. * Lexing/Compiling
  11168. */
  11169. InlineLexer.prototype.output = function(src) {
  11170. var out = '',
  11171. link,
  11172. text,
  11173. href,
  11174. title,
  11175. cap,
  11176. prevCapZero;
  11177. while (src) {
  11178. // escape
  11179. if (cap = this.rules.escape.exec(src)) {
  11180. src = src.substring(cap[0].length);
  11181. out += cap[1];
  11182. continue;
  11183. }
  11184. // autolink
  11185. if (cap = this.rules.autolink.exec(src)) {
  11186. src = src.substring(cap[0].length);
  11187. if (cap[2] === '@') {
  11188. text = escape(this.mangle(cap[1]));
  11189. href = 'mailto:' + text;
  11190. } else {
  11191. text = escape(cap[1]);
  11192. href = text;
  11193. }
  11194. out += this.renderer.link(href, null, text);
  11195. continue;
  11196. }
  11197. // url (gfm)
  11198. if (!this.inLink && (cap = this.rules.url.exec(src))) {
  11199. if (cap[2] === '@') {
  11200. text = escape(cap[0]);
  11201. href = 'mailto:' + text;
  11202. } else {
  11203. // do extended autolink path validation
  11204. do {
  11205. prevCapZero = cap[0];
  11206. cap[0] = this.rules._backpedal.exec(cap[0])[0];
  11207. } while (prevCapZero !== cap[0]);
  11208. text = escape(cap[0]);
  11209. if (cap[1] === 'www.') {
  11210. href = 'http://' + text;
  11211. } else {
  11212. href = text;
  11213. }
  11214. }
  11215. src = src.substring(cap[0].length);
  11216. out += this.renderer.link(href, null, text);
  11217. continue;
  11218. }
  11219. // tag
  11220. if (cap = this.rules.tag.exec(src)) {
  11221. if (!this.inLink && /^<a /i.test(cap[0])) {
  11222. this.inLink = true;
  11223. } else if (this.inLink && /^<\/a>/i.test(cap[0])) {
  11224. this.inLink = false;
  11225. }
  11226. if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
  11227. this.inRawBlock = true;
  11228. } else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
  11229. this.inRawBlock = false;
  11230. }
  11231. src = src.substring(cap[0].length);
  11232. out += this.options.sanitize
  11233. ? this.options.sanitizer
  11234. ? this.options.sanitizer(cap[0])
  11235. : escape(cap[0])
  11236. : cap[0];
  11237. continue;
  11238. }
  11239. // link
  11240. if (cap = this.rules.link.exec(src)) {
  11241. src = src.substring(cap[0].length);
  11242. this.inLink = true;
  11243. href = cap[2];
  11244. if (this.options.pedantic) {
  11245. link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
  11246. if (link) {
  11247. href = link[1];
  11248. title = link[3];
  11249. } else {
  11250. title = '';
  11251. }
  11252. } else {
  11253. title = cap[3] ? cap[3].slice(1, -1) : '';
  11254. }
  11255. href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
  11256. out += this.outputLink(cap, {
  11257. href: InlineLexer.escapes(href),
  11258. title: InlineLexer.escapes(title)
  11259. });
  11260. this.inLink = false;
  11261. continue;
  11262. }
  11263. // reflink, nolink
  11264. if ((cap = this.rules.reflink.exec(src))
  11265. || (cap = this.rules.nolink.exec(src))) {
  11266. src = src.substring(cap[0].length);
  11267. link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
  11268. link = this.links[link.toLowerCase()];
  11269. if (!link || !link.href) {
  11270. out += cap[0].charAt(0);
  11271. src = cap[0].substring(1) + src;
  11272. continue;
  11273. }
  11274. this.inLink = true;
  11275. out += this.outputLink(cap, link);
  11276. this.inLink = false;
  11277. continue;
  11278. }
  11279. // strong
  11280. if (cap = this.rules.strong.exec(src)) {
  11281. src = src.substring(cap[0].length);
  11282. out += this.renderer.strong(this.output(cap[4] || cap[3] || cap[2] || cap[1]));
  11283. continue;
  11284. }
  11285. // em
  11286. if (cap = this.rules.em.exec(src)) {
  11287. src = src.substring(cap[0].length);
  11288. out += this.renderer.em(this.output(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1]));
  11289. continue;
  11290. }
  11291. // code
  11292. if (cap = this.rules.code.exec(src)) {
  11293. src = src.substring(cap[0].length);
  11294. out += this.renderer.codespan(escape(cap[2].trim(), true));
  11295. continue;
  11296. }
  11297. // br
  11298. if (cap = this.rules.br.exec(src)) {
  11299. src = src.substring(cap[0].length);
  11300. out += this.renderer.br();
  11301. continue;
  11302. }
  11303. // del (gfm)
  11304. if (cap = this.rules.del.exec(src)) {
  11305. src = src.substring(cap[0].length);
  11306. out += this.renderer.del(this.output(cap[1]));
  11307. continue;
  11308. }
  11309. // text
  11310. if (cap = this.rules.text.exec(src)) {
  11311. src = src.substring(cap[0].length);
  11312. if (this.inRawBlock) {
  11313. out += this.renderer.text(cap[0]);
  11314. } else {
  11315. out += this.renderer.text(escape(this.smartypants(cap[0])));
  11316. }
  11317. continue;
  11318. }
  11319. if (src) {
  11320. throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
  11321. }
  11322. }
  11323. return out;
  11324. };
  11325. InlineLexer.escapes = function(text) {
  11326. return text ? text.replace(InlineLexer.rules._escapes, '$1') : text;
  11327. };
  11328. /**
  11329. * Compile Link
  11330. */
  11331. InlineLexer.prototype.outputLink = function(cap, link) {
  11332. var href = link.href,
  11333. title = link.title ? escape(link.title) : null;
  11334. return cap[0].charAt(0) !== '!'
  11335. ? this.renderer.link(href, title, this.output(cap[1]))
  11336. : this.renderer.image(href, title, escape(cap[1]));
  11337. };
  11338. /**
  11339. * Smartypants Transformations
  11340. */
  11341. InlineLexer.prototype.smartypants = function(text) {
  11342. if (!this.options.smartypants) return text;
  11343. return text
  11344. // em-dashes
  11345. .replace(/---/g, '\u2014')
  11346. // en-dashes
  11347. .replace(/--/g, '\u2013')
  11348. // opening singles
  11349. .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
  11350. // closing singles & apostrophes
  11351. .replace(/'/g, '\u2019')
  11352. // opening doubles
  11353. .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
  11354. // closing doubles
  11355. .replace(/"/g, '\u201d')
  11356. // ellipses
  11357. .replace(/\.{3}/g, '\u2026');
  11358. };
  11359. /**
  11360. * Mangle Links
  11361. */
  11362. InlineLexer.prototype.mangle = function(text) {
  11363. if (!this.options.mangle) return text;
  11364. var out = '',
  11365. l = text.length,
  11366. i = 0,
  11367. ch;
  11368. for (; i < l; i++) {
  11369. ch = text.charCodeAt(i);
  11370. if (Math.random() > 0.5) {
  11371. ch = 'x' + ch.toString(16);
  11372. }
  11373. out += '&#' + ch + ';';
  11374. }
  11375. return out;
  11376. };
  11377. /**
  11378. * Renderer
  11379. */
  11380. function Renderer(options) {
  11381. this.options = options || marked.defaults;
  11382. }
  11383. Renderer.prototype.code = function(code, lang, escaped) {
  11384. if (this.options.highlight) {
  11385. var out = this.options.highlight(code, lang);
  11386. if (out != null && out !== code) {
  11387. escaped = true;
  11388. code = out;
  11389. }
  11390. }
  11391. if (!lang) {
  11392. return '<pre><code>'
  11393. + (escaped ? code : escape(code, true))
  11394. + '</code></pre>';
  11395. }
  11396. return '<pre><code class="'
  11397. + this.options.langPrefix
  11398. + escape(lang, true)
  11399. + '">'
  11400. + (escaped ? code : escape(code, true))
  11401. + '</code></pre>\n';
  11402. };
  11403. Renderer.prototype.blockquote = function(quote) {
  11404. return '<blockquote>\n' + quote + '</blockquote>\n';
  11405. };
  11406. Renderer.prototype.html = function(html) {
  11407. return html;
  11408. };
  11409. Renderer.prototype.heading = function(text, level, raw) {
  11410. if (this.options.headerIds) {
  11411. return '<h'
  11412. + level
  11413. + ' id="'
  11414. + this.options.headerPrefix
  11415. + raw.toLowerCase().replace(/[^\w]+/g, '-')
  11416. + '">'
  11417. + text
  11418. + '</h'
  11419. + level
  11420. + '>\n';
  11421. }
  11422. // ignore IDs
  11423. return '<h' + level + '>' + text + '</h' + level + '>\n';
  11424. };
  11425. Renderer.prototype.hr = function() {
  11426. return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
  11427. };
  11428. Renderer.prototype.list = function(body, ordered, start) {
  11429. var type = ordered ? 'ol' : 'ul',
  11430. startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
  11431. return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
  11432. };
  11433. Renderer.prototype.listitem = function(text) {
  11434. return '<li>' + text + '</li>\n';
  11435. };
  11436. Renderer.prototype.checkbox = function(checked) {
  11437. return '<input '
  11438. + (checked ? 'checked="" ' : '')
  11439. + 'disabled="" type="checkbox"'
  11440. + (this.options.xhtml ? ' /' : '')
  11441. + '> ';
  11442. };
  11443. Renderer.prototype.paragraph = function(text) {
  11444. return '<p>' + text + '</p>\n';
  11445. };
  11446. Renderer.prototype.table = function(header, body) {
  11447. if (body) body = '<tbody>' + body + '</tbody>';
  11448. return '<table>\n'
  11449. + '<thead>\n'
  11450. + header
  11451. + '</thead>\n'
  11452. + body
  11453. + '</table>\n';
  11454. };
  11455. Renderer.prototype.tablerow = function(content) {
  11456. return '<tr>\n' + content + '</tr>\n';
  11457. };
  11458. Renderer.prototype.tablecell = function(content, flags) {
  11459. var type = flags.header ? 'th' : 'td';
  11460. var tag = flags.align
  11461. ? '<' + type + ' align="' + flags.align + '">'
  11462. : '<' + type + '>';
  11463. return tag + content + '</' + type + '>\n';
  11464. };
  11465. // span level renderer
  11466. Renderer.prototype.strong = function(text) {
  11467. return '<strong>' + text + '</strong>';
  11468. };
  11469. Renderer.prototype.em = function(text) {
  11470. return '<em>' + text + '</em>';
  11471. };
  11472. Renderer.prototype.codespan = function(text) {
  11473. return '<code>' + text + '</code>';
  11474. };
  11475. Renderer.prototype.br = function() {
  11476. return this.options.xhtml ? '<br/>' : '<br>';
  11477. };
  11478. Renderer.prototype.del = function(text) {
  11479. return '<del>' + text + '</del>';
  11480. };
  11481. Renderer.prototype.link = function(href, title, text) {
  11482. href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
  11483. if (href === null) {
  11484. return text;
  11485. }
  11486. var out = '<a href="' + escape(href) + '"';
  11487. if (title) {
  11488. out += ' title="' + title + '"';
  11489. }
  11490. out += '>' + text + '</a>';
  11491. return out;
  11492. };
  11493. Renderer.prototype.image = function(href, title, text) {
  11494. href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
  11495. if (href === null) {
  11496. return text;
  11497. }
  11498. var out = '<img src="' + href + '" alt="' + text + '"';
  11499. if (title) {
  11500. out += ' title="' + title + '"';
  11501. }
  11502. out += this.options.xhtml ? '/>' : '>';
  11503. return out;
  11504. };
  11505. Renderer.prototype.text = function(text) {
  11506. return text;
  11507. };
  11508. /**
  11509. * TextRenderer
  11510. * returns only the textual part of the token
  11511. */
  11512. function TextRenderer() {}
  11513. // no need for block level renderers
  11514. TextRenderer.prototype.strong =
  11515. TextRenderer.prototype.em =
  11516. TextRenderer.prototype.codespan =
  11517. TextRenderer.prototype.del =
  11518. TextRenderer.prototype.text = function (text) {
  11519. return text;
  11520. };
  11521. TextRenderer.prototype.link =
  11522. TextRenderer.prototype.image = function(href, title, text) {
  11523. return '' + text;
  11524. };
  11525. TextRenderer.prototype.br = function() {
  11526. return '';
  11527. };
  11528. /**
  11529. * Parsing & Compiling
  11530. */
  11531. function Parser(options) {
  11532. this.tokens = [];
  11533. this.token = null;
  11534. this.options = options || marked.defaults;
  11535. this.options.renderer = this.options.renderer || new Renderer();
  11536. this.renderer = this.options.renderer;
  11537. this.renderer.options = this.options;
  11538. }
  11539. /**
  11540. * Static Parse Method
  11541. */
  11542. Parser.parse = function(src, options) {
  11543. var parser = new Parser(options);
  11544. return parser.parse(src);
  11545. };
  11546. /**
  11547. * Parse Loop
  11548. */
  11549. Parser.prototype.parse = function(src) {
  11550. this.inline = new InlineLexer(src.links, this.options);
  11551. // use an InlineLexer with a TextRenderer to extract pure text
  11552. this.inlineText = new InlineLexer(
  11553. src.links,
  11554. merge({}, this.options, {renderer: new TextRenderer()})
  11555. );
  11556. this.tokens = src.reverse();
  11557. var out = '';
  11558. while (this.next()) {
  11559. out += this.tok();
  11560. }
  11561. return out;
  11562. };
  11563. /**
  11564. * Next Token
  11565. */
  11566. Parser.prototype.next = function() {
  11567. return this.token = this.tokens.pop();
  11568. };
  11569. /**
  11570. * Preview Next Token
  11571. */
  11572. Parser.prototype.peek = function() {
  11573. return this.tokens[this.tokens.length - 1] || 0;
  11574. };
  11575. /**
  11576. * Parse Text Tokens
  11577. */
  11578. Parser.prototype.parseText = function() {
  11579. var body = this.token.text;
  11580. while (this.peek().type === 'text') {
  11581. body += '\n' + this.next().text;
  11582. }
  11583. return this.inline.output(body);
  11584. };
  11585. /**
  11586. * Parse Current Token
  11587. */
  11588. Parser.prototype.tok = function() {
  11589. switch (this.token.type) {
  11590. case 'space': {
  11591. return '';
  11592. }
  11593. case 'hr': {
  11594. return this.renderer.hr();
  11595. }
  11596. case 'heading': {
  11597. return this.renderer.heading(
  11598. this.inline.output(this.token.text),
  11599. this.token.depth,
  11600. unescape(this.inlineText.output(this.token.text)));
  11601. }
  11602. case 'code': {
  11603. return this.renderer.code(this.token.text,
  11604. this.token.lang,
  11605. this.token.escaped);
  11606. }
  11607. case 'table': {
  11608. var header = '',
  11609. body = '',
  11610. i,
  11611. row,
  11612. cell,
  11613. j;
  11614. // header
  11615. cell = '';
  11616. for (i = 0; i < this.token.header.length; i++) {
  11617. cell += this.renderer.tablecell(
  11618. this.inline.output(this.token.header[i]),
  11619. { header: true, align: this.token.align[i] }
  11620. );
  11621. }
  11622. header += this.renderer.tablerow(cell);
  11623. for (i = 0; i < this.token.cells.length; i++) {
  11624. row = this.token.cells[i];
  11625. cell = '';
  11626. for (j = 0; j < row.length; j++) {
  11627. cell += this.renderer.tablecell(
  11628. this.inline.output(row[j]),
  11629. { header: false, align: this.token.align[j] }
  11630. );
  11631. }
  11632. body += this.renderer.tablerow(cell);
  11633. }
  11634. return this.renderer.table(header, body);
  11635. }
  11636. case 'blockquote_start': {
  11637. body = '';
  11638. while (this.next().type !== 'blockquote_end') {
  11639. body += this.tok();
  11640. }
  11641. return this.renderer.blockquote(body);
  11642. }
  11643. case 'list_start': {
  11644. body = '';
  11645. var ordered = this.token.ordered,
  11646. start = this.token.start;
  11647. while (this.next().type !== 'list_end') {
  11648. body += this.tok();
  11649. }
  11650. return this.renderer.list(body, ordered, start);
  11651. }
  11652. case 'list_item_start': {
  11653. body = '';
  11654. var loose = this.token.loose;
  11655. if (this.token.task) {
  11656. body += this.renderer.checkbox(this.token.checked);
  11657. }
  11658. while (this.next().type !== 'list_item_end') {
  11659. body += !loose && this.token.type === 'text'
  11660. ? this.parseText()
  11661. : this.tok();
  11662. }
  11663. return this.renderer.listitem(body);
  11664. }
  11665. case 'html': {
  11666. // TODO parse inline content if parameter markdown=1
  11667. return this.renderer.html(this.token.text);
  11668. }
  11669. case 'paragraph': {
  11670. return this.renderer.paragraph(this.inline.output(this.token.text));
  11671. }
  11672. case 'text': {
  11673. return this.renderer.paragraph(this.parseText());
  11674. }
  11675. }
  11676. };
  11677. /**
  11678. * Helpers
  11679. */
  11680. function escape(html, encode) {
  11681. if (encode) {
  11682. if (escape.escapeTest.test(html)) {
  11683. return html.replace(escape.escapeReplace, function (ch) { return escape.replacements[ch]; });
  11684. }
  11685. } else {
  11686. if (escape.escapeTestNoEncode.test(html)) {
  11687. return html.replace(escape.escapeReplaceNoEncode, function (ch) { return escape.replacements[ch]; });
  11688. }
  11689. }
  11690. return html;
  11691. }
  11692. escape.escapeTest = /[&<>"']/;
  11693. escape.escapeReplace = /[&<>"']/g;
  11694. escape.replacements = {
  11695. '&': '&amp;',
  11696. '<': '&lt;',
  11697. '>': '&gt;',
  11698. '"': '&quot;',
  11699. "'": '&#39;'
  11700. };
  11701. escape.escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
  11702. escape.escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
  11703. function unescape(html) {
  11704. // explicitly match decimal, hex, and named HTML entities
  11705. return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function(_, n) {
  11706. n = n.toLowerCase();
  11707. if (n === 'colon') return ':';
  11708. if (n.charAt(0) === '#') {
  11709. return n.charAt(1) === 'x'
  11710. ? String.fromCharCode(parseInt(n.substring(2), 16))
  11711. : String.fromCharCode(+n.substring(1));
  11712. }
  11713. return '';
  11714. });
  11715. }
  11716. function edit(regex, opt) {
  11717. regex = regex.source || regex;
  11718. opt = opt || '';
  11719. return {
  11720. replace: function(name, val) {
  11721. val = val.source || val;
  11722. val = val.replace(/(^|[^\[])\^/g, '$1');
  11723. regex = regex.replace(name, val);
  11724. return this;
  11725. },
  11726. getRegex: function() {
  11727. return new RegExp(regex, opt);
  11728. }
  11729. };
  11730. }
  11731. function cleanUrl(sanitize, base, href) {
  11732. if (sanitize) {
  11733. try {
  11734. var prot = decodeURIComponent(unescape(href))
  11735. .replace(/[^\w:]/g, '')
  11736. .toLowerCase();
  11737. } catch (e) {
  11738. return null;
  11739. }
  11740. if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
  11741. return null;
  11742. }
  11743. }
  11744. if (base && !originIndependentUrl.test(href)) {
  11745. href = resolveUrl(base, href);
  11746. }
  11747. try {
  11748. href = encodeURI(href).replace(/%25/g, '%');
  11749. } catch (e) {
  11750. return null;
  11751. }
  11752. return href;
  11753. }
  11754. function resolveUrl(base, href) {
  11755. if (!baseUrls[' ' + base]) {
  11756. // we can ignore everything in base after the last slash of its path component,
  11757. // but we might need to add _that_
  11758. // https://tools.ietf.org/html/rfc3986#section-3
  11759. if (/^[^:]+:\/*[^/]*$/.test(base)) {
  11760. baseUrls[' ' + base] = base + '/';
  11761. } else {
  11762. baseUrls[' ' + base] = rtrim(base, '/', true);
  11763. }
  11764. }
  11765. base = baseUrls[' ' + base];
  11766. if (href.slice(0, 2) === '//') {
  11767. return base.replace(/:[\s\S]*/, ':') + href;
  11768. } else if (href.charAt(0) === '/') {
  11769. return base.replace(/(:\/*[^/]*)[\s\S]*/, '$1') + href;
  11770. } else {
  11771. return base + href;
  11772. }
  11773. }
  11774. var baseUrls = {};
  11775. var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
  11776. function noop() {}
  11777. noop.exec = noop;
  11778. function merge(obj) {
  11779. var i = 1,
  11780. target,
  11781. key;
  11782. for (; i < arguments.length; i++) {
  11783. target = arguments[i];
  11784. for (key in target) {
  11785. if (Object.prototype.hasOwnProperty.call(target, key)) {
  11786. obj[key] = target[key];
  11787. }
  11788. }
  11789. }
  11790. return obj;
  11791. }
  11792. function splitCells(tableRow, count) {
  11793. // ensure that every cell-delimiting pipe has a space
  11794. // before it to distinguish it from an escaped pipe
  11795. var row = tableRow.replace(/\|/g, function (match, offset, str) {
  11796. var escaped = false,
  11797. curr = offset;
  11798. while (--curr >= 0 && str[curr] === '\\') escaped = !escaped;
  11799. if (escaped) {
  11800. // odd number of slashes means | is escaped
  11801. // so we leave it alone
  11802. return '|';
  11803. } else {
  11804. // add space before unescaped |
  11805. return ' |';
  11806. }
  11807. }),
  11808. cells = row.split(/ \|/),
  11809. i = 0;
  11810. if (cells.length > count) {
  11811. cells.splice(count);
  11812. } else {
  11813. while (cells.length < count) cells.push('');
  11814. }
  11815. for (; i < cells.length; i++) {
  11816. // leading or trailing whitespace is ignored per the gfm spec
  11817. cells[i] = cells[i].trim().replace(/\\\|/g, '|');
  11818. }
  11819. return cells;
  11820. }
  11821. // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
  11822. // /c*$/ is vulnerable to REDOS.
  11823. // invert: Remove suffix of non-c chars instead. Default falsey.
  11824. function rtrim(str, c, invert) {
  11825. if (str.length === 0) {
  11826. return '';
  11827. }
  11828. // Length of suffix matching the invert condition.
  11829. var suffLen = 0;
  11830. // Step left until we fail to match the invert condition.
  11831. while (suffLen < str.length) {
  11832. var currChar = str.charAt(str.length - suffLen - 1);
  11833. if (currChar === c && !invert) {
  11834. suffLen++;
  11835. } else if (currChar !== c && invert) {
  11836. suffLen++;
  11837. } else {
  11838. break;
  11839. }
  11840. }
  11841. return str.substr(0, str.length - suffLen);
  11842. }
  11843. /**
  11844. * Marked
  11845. */
  11846. function marked(src, opt, callback) {
  11847. // throw error in case of non string input
  11848. if (typeof src === 'undefined' || src === null) {
  11849. throw new Error('marked(): input parameter is undefined or null');
  11850. }
  11851. if (typeof src !== 'string') {
  11852. throw new Error('marked(): input parameter is of type '
  11853. + Object.prototype.toString.call(src) + ', string expected');
  11854. }
  11855. if (callback || typeof opt === 'function') {
  11856. if (!callback) {
  11857. callback = opt;
  11858. opt = null;
  11859. }
  11860. opt = merge({}, marked.defaults, opt || {});
  11861. var highlight = opt.highlight,
  11862. tokens,
  11863. pending,
  11864. i = 0;
  11865. try {
  11866. tokens = Lexer.lex(src, opt);
  11867. } catch (e) {
  11868. return callback(e);
  11869. }
  11870. pending = tokens.length;
  11871. var done = function(err) {
  11872. if (err) {
  11873. opt.highlight = highlight;
  11874. return callback(err);
  11875. }
  11876. var out;
  11877. try {
  11878. out = Parser.parse(tokens, opt);
  11879. } catch (e) {
  11880. err = e;
  11881. }
  11882. opt.highlight = highlight;
  11883. return err
  11884. ? callback(err)
  11885. : callback(null, out);
  11886. };
  11887. if (!highlight || highlight.length < 3) {
  11888. return done();
  11889. }
  11890. delete opt.highlight;
  11891. if (!pending) return done();
  11892. for (; i < tokens.length; i++) {
  11893. (function(token) {
  11894. if (token.type !== 'code') {
  11895. return --pending || done();
  11896. }
  11897. return highlight(token.text, token.lang, function(err, code) {
  11898. if (err) return done(err);
  11899. if (code == null || code === token.text) {
  11900. return --pending || done();
  11901. }
  11902. token.text = code;
  11903. token.escaped = true;
  11904. --pending || done();
  11905. });
  11906. })(tokens[i]);
  11907. }
  11908. return;
  11909. }
  11910. try {
  11911. if (opt) opt = merge({}, marked.defaults, opt);
  11912. return Parser.parse(Lexer.lex(src, opt), opt);
  11913. } catch (e) {
  11914. e.message += '\nPlease report this to https://github.com/markedjs/marked.';
  11915. if ((opt || marked.defaults).silent) {
  11916. return '<p>An error occurred:</p><pre>'
  11917. + escape(e.message + '', true)
  11918. + '</pre>';
  11919. }
  11920. throw e;
  11921. }
  11922. }
  11923. /**
  11924. * Options
  11925. */
  11926. marked.options =
  11927. marked.setOptions = function(opt) {
  11928. merge(marked.defaults, opt);
  11929. return marked;
  11930. };
  11931. marked.getDefaults = function () {
  11932. return {
  11933. baseUrl: null,
  11934. breaks: false,
  11935. gfm: true,
  11936. headerIds: true,
  11937. headerPrefix: '',
  11938. highlight: null,
  11939. langPrefix: 'language-',
  11940. mangle: true,
  11941. pedantic: false,
  11942. renderer: new Renderer(),
  11943. sanitize: false,
  11944. sanitizer: null,
  11945. silent: false,
  11946. smartLists: false,
  11947. smartypants: false,
  11948. tables: true,
  11949. xhtml: false
  11950. };
  11951. };
  11952. marked.defaults = marked.getDefaults();
  11953. /**
  11954. * Expose
  11955. */
  11956. marked.Parser = Parser;
  11957. marked.parser = Parser.parse;
  11958. marked.Renderer = Renderer;
  11959. marked.TextRenderer = TextRenderer;
  11960. marked.Lexer = Lexer;
  11961. marked.lexer = Lexer.lex;
  11962. marked.InlineLexer = InlineLexer;
  11963. marked.inlineLexer = InlineLexer.output;
  11964. marked.parse = marked;
  11965. if (true) {
  11966. module.exports = marked;
  11967. } else {}
  11968. })(this || (typeof window !== 'undefined' ? window : global));
  11969. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(14)))
  11970. /***/ }),
  11971. /* 84 */
  11972. /***/ (function(module, exports, __webpack_require__) {
  11973. "use strict";
  11974. Object.defineProperty(exports, "__esModule", { value: true });
  11975. var buffer_1 = __webpack_require__(85);
  11976. var types_1 = __webpack_require__(2);
  11977. var INACTION_DELAY = 5000;
  11978. var Manager = /** @class */ (function () {
  11979. function Manager(editor) {
  11980. this._editor = editor;
  11981. this.clearChanges();
  11982. this._buffer = new buffer_1.TextBuffer(this._editor);
  11983. }
  11984. Manager.prototype.execute = function (operation) {
  11985. var _this = this;
  11986. if (this._inactionTimer) {
  11987. clearTimeout(this._inactionTimer);
  11988. this._inactionTimer = null;
  11989. }
  11990. this._inactionTimer = setTimeout(function () {
  11991. if (_this._editor.selection.isActive()) { // if editor not in focus it can call some unexpected behaviour
  11992. _this._editor.balance();
  11993. }
  11994. _this._inactionTimer = null;
  11995. }, INACTION_DELAY);
  11996. var result;
  11997. switch (operation.action) {
  11998. case types_1.Action.parse:
  11999. result = this._editor.parse(operation.data.value, operation.data.mode);
  12000. this.clearChanges();
  12001. return true;
  12002. case types_1.Action.add:
  12003. result = this._editor.add(operation.data);
  12004. break;
  12005. case types_1.Action.innerAdd:
  12006. if (typeof operation.data === "string") {
  12007. result = this._editor.add(operation.data);
  12008. }
  12009. else {
  12010. var _a = operation.data, data = _a.data, type = _a.type;
  12011. switch (type) {
  12012. case "text":
  12013. result = this._editor.add(data);
  12014. break;
  12015. case "full":
  12016. result = this._editor.paste(JSON.stringify(data), "inner");
  12017. break;
  12018. case "textnode":
  12019. // tricky
  12020. result = this._editor.paste(JSON.stringify([{
  12021. textNodes: [data],
  12022. style: {}
  12023. }]), "inner");
  12024. break;
  12025. }
  12026. }
  12027. break;
  12028. case types_1.Action.remove:
  12029. result = this._editor.remove(operation.data);
  12030. break;
  12031. case types_1.Action.update:
  12032. result = this._editor.update(operation.data);
  12033. break;
  12034. case types_1.Action.clear:
  12035. result = this._editor.clearStyles();
  12036. break;
  12037. case types_1.Action.paste:
  12038. result = this._buffer.paste(operation.data);
  12039. break;
  12040. case types_1.Action.cut:
  12041. result = this._buffer.cut(operation.data);
  12042. break;
  12043. case types_1.Action.copy:
  12044. this._buffer.copy(operation.data); // it split nodes, need to update view
  12045. return true;
  12046. case types_1.Action.selectAll:
  12047. break;
  12048. }
  12049. if (result) {
  12050. this._change();
  12051. return true;
  12052. }
  12053. if (operation.action === types_1.Action.undo) {
  12054. return this.undo();
  12055. }
  12056. if (operation.action === types_1.Action.redo) {
  12057. return this.redo();
  12058. }
  12059. return false;
  12060. };
  12061. Manager.prototype.canUndo = function () {
  12062. return this._changes.prev !== null;
  12063. };
  12064. Manager.prototype.canRedo = function () {
  12065. return this._changes.next !== null;
  12066. };
  12067. Manager.prototype.undo = function () {
  12068. var change = this._changes.prev;
  12069. if (change) {
  12070. this._editor.setState(change.state);
  12071. this._changes = change;
  12072. return true;
  12073. }
  12074. return false;
  12075. };
  12076. Manager.prototype.redo = function () {
  12077. var change = this._changes.next;
  12078. if (change) {
  12079. this._editor.setState(change.state);
  12080. this._changes = change;
  12081. return true;
  12082. }
  12083. return false;
  12084. };
  12085. Manager.prototype.clearChanges = function () {
  12086. this._changes = {
  12087. prev: null,
  12088. next: null,
  12089. state: this._editor.getState()
  12090. };
  12091. };
  12092. Manager.prototype._change = function () {
  12093. var newChange = {
  12094. prev: this._changes,
  12095. next: null,
  12096. state: this._editor.getState()
  12097. };
  12098. this._changes.next = newChange;
  12099. this._changes = newChange;
  12100. };
  12101. return Manager;
  12102. }());
  12103. exports.Manager = Manager;
  12104. /***/ }),
  12105. /* 85 */
  12106. /***/ (function(module, exports, __webpack_require__) {
  12107. "use strict";
  12108. Object.defineProperty(exports, "__esModule", { value: true });
  12109. var serializer_1 = __webpack_require__(35);
  12110. var TextBuffer = /** @class */ (function () {
  12111. function TextBuffer(editor) {
  12112. this._editor = editor;
  12113. }
  12114. TextBuffer.prototype.copy = function (event) {
  12115. event.preventDefault();
  12116. var result = this._editor.copy();
  12117. return this._setBuffer(event, result);
  12118. };
  12119. TextBuffer.prototype.cut = function (event) {
  12120. event.preventDefault();
  12121. var result = this._editor.cut();
  12122. return this._setBuffer(event, result);
  12123. };
  12124. TextBuffer.prototype.paste = function (event) {
  12125. event.preventDefault();
  12126. var text;
  12127. if (event.clipboardData) {
  12128. text = event.clipboardData.getData("text/plain");
  12129. }
  12130. else {
  12131. text = window.clipboardData.getData("text");
  12132. }
  12133. if (text === this._rawText) {
  12134. return this._editor.paste(this._editorContent, "inner");
  12135. }
  12136. else {
  12137. var htmlData = eventHTMLData(event);
  12138. if (htmlData) {
  12139. return this._editor.paste(htmlData, "html");
  12140. }
  12141. return this._editor.paste(text, "text");
  12142. }
  12143. };
  12144. TextBuffer.prototype._setBuffer = function (event, result) {
  12145. if (!result) {
  12146. return false;
  12147. }
  12148. this._rawText = result.raw;
  12149. this._editorContent = JSON.stringify(result.content);
  12150. if (event.clipboardData) {
  12151. event.clipboardData.setData("text/plain", result.raw);
  12152. event.clipboardData.setData("text/html", serializer_1.serializer(result.content));
  12153. }
  12154. else {
  12155. window.clipboardData.setData("text", result.raw);
  12156. }
  12157. return true;
  12158. };
  12159. return TextBuffer;
  12160. }());
  12161. exports.TextBuffer = TextBuffer;
  12162. function eventHTMLData(e) {
  12163. if (!e.clipboardData) {
  12164. return;
  12165. }
  12166. if (e.clipboardData.types.indexOf("text/html") !== -1) {
  12167. return e.clipboardData.getData("text/html");
  12168. }
  12169. }
  12170. /***/ }),
  12171. /* 86 */
  12172. /***/ (function(module, exports, __webpack_require__) {
  12173. "use strict";
  12174. /* WEBPACK VAR INJECTION */(function(Promise) {
  12175. var __assign = (this && this.__assign) || Object.assign || function(t) {
  12176. for (var s, i = 1, n = arguments.length; i < n; i++) {
  12177. s = arguments[i];
  12178. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  12179. t[p] = s[p];
  12180. }
  12181. return t;
  12182. };
  12183. Object.defineProperty(exports, "__esModule", { value: true });
  12184. var html_1 = __webpack_require__(1);
  12185. var other_1 = __webpack_require__(4);
  12186. var selection_1 = __webpack_require__(87);
  12187. var types_1 = __webpack_require__(2);
  12188. var SelectionHelper = /** @class */ (function () {
  12189. function SelectionHelper(editor, uid, events) {
  12190. var _this = this;
  12191. this._selectionChange = function () {
  12192. var isActive = _this.isActive();
  12193. if (isActive) {
  12194. _this._selectedText = window.getSelection().toString();
  12195. if (_this._ignoreSelection) {
  12196. return;
  12197. }
  12198. var state = selection_1.stateFromDom(_this._editor);
  12199. if (other_1.isEqual(state, _this._state, true)) {
  12200. return;
  12201. }
  12202. _this._state = state;
  12203. _this._events.fire(types_1.RichTextEvents.selectionChange, [state]);
  12204. }
  12205. };
  12206. this._events = events;
  12207. this._uid = uid;
  12208. this._editor = editor;
  12209. this.clear();
  12210. this._initEvents();
  12211. }
  12212. SelectionHelper.prototype.clear = function () {
  12213. this._state = {
  12214. range: false,
  12215. left: {
  12216. blockIndex: 0,
  12217. textIndex: 0,
  12218. offset: 0
  12219. }
  12220. };
  12221. this._waitUpdate = true;
  12222. };
  12223. SelectionHelper.prototype.set = function (state) {
  12224. this._state = state;
  12225. this._waitUpdate = true;
  12226. };
  12227. SelectionHelper.prototype.get = function () {
  12228. return this._state;
  12229. };
  12230. SelectionHelper.prototype.getCompact = function () {
  12231. var state = this._state;
  12232. var compact = [[state.left.blockIndex, state.left.textIndex, state.left.offset]];
  12233. if (this._state.range) {
  12234. compact.push([state.right.blockIndex, state.right.textIndex, state.right.offset]);
  12235. }
  12236. return compact;
  12237. };
  12238. SelectionHelper.prototype.setCompact = function (compact) {
  12239. var state = {
  12240. left: {
  12241. blockIndex: compact[0][0],
  12242. textIndex: compact[0][1],
  12243. offset: compact[0][2]
  12244. },
  12245. range: compact.length === 2
  12246. };
  12247. if (state.range) {
  12248. state.right = {
  12249. blockIndex: compact[1][0],
  12250. textIndex: compact[1][1],
  12251. offset: compact[1][2]
  12252. };
  12253. }
  12254. this.set(state);
  12255. };
  12256. SelectionHelper.prototype.getPosition = function (selection) {
  12257. var _this = this;
  12258. return new Promise(function (res) {
  12259. if (!_this._waitUpdate) {
  12260. var range = _this._createRange(selection);
  12261. res(getPositionFromRange(range));
  12262. }
  12263. var ctx = new Date();
  12264. _this._events.on(types_1.RichTextEvents.selectionRefresh, function () {
  12265. _this._events.detach(types_1.RichTextEvents.selectionRefresh, ctx);
  12266. var range = _this._createRange(selection);
  12267. res(getPositionFromRange(range));
  12268. }, ctx);
  12269. });
  12270. };
  12271. SelectionHelper.prototype.destructor = function () {
  12272. document.removeEventListener("selectionchange", this._selectionChange);
  12273. };
  12274. SelectionHelper.prototype.isActive = function () {
  12275. var anchorNode = window.getSelection().anchorNode;
  12276. return html_1.locate(anchorNode, "dhx_widget_id") === this._uid;
  12277. };
  12278. SelectionHelper.prototype.isFull = function () {
  12279. var _a = this._state, left = _a.left, right = _a.right, range = _a.range;
  12280. if (!range) {
  12281. return false;
  12282. }
  12283. var last = this._editor.blocks.length - 1;
  12284. var end = this._editor.blocks[last].getBlockEnd();
  12285. return left.blockIndex === 0 && left.textIndex === 0 && left.offset === 0 && right.blockIndex === last && right.textIndex === end.textIndex && right.offset === end.offset;
  12286. };
  12287. SelectionHelper.prototype.update = function () {
  12288. if (!this._waitUpdate) {
  12289. return true;
  12290. }
  12291. return this.refresh();
  12292. };
  12293. SelectionHelper.prototype.getSelectedText = function () {
  12294. return this._selectedText;
  12295. };
  12296. SelectionHelper.prototype.selectAll = function () {
  12297. var blocks = this._editor.blocks;
  12298. this._state = {
  12299. range: true,
  12300. left: {
  12301. blockIndex: 0,
  12302. textIndex: 0,
  12303. offset: 0
  12304. },
  12305. right: __assign({ blockIndex: blocks.length - 1 }, blocks[blocks.length - 1].getBlockEnd())
  12306. };
  12307. };
  12308. SelectionHelper.prototype.refresh = function () {
  12309. var _this = this;
  12310. var _a = this._state, left = _a.left, right = _a.right, range = _a.range;
  12311. var selection = window.getSelection();
  12312. if (!selection) {
  12313. return false;
  12314. }
  12315. if (this._ignoreSelectionTimeout) {
  12316. clearTimeout(this._ignoreSelectionTimeout);
  12317. }
  12318. this._ignoreSelection = true;
  12319. this._ignoreSelectionTimeout = setTimeout(function () {
  12320. _this._ignoreSelection = false;
  12321. _this._ignoreSelectionTimeout = null;
  12322. }, 5);
  12323. var selectionRange;
  12324. if (selection.rangeCount > 0) {
  12325. selectionRange = selection.getRangeAt(0);
  12326. selection.removeAllRanges();
  12327. }
  12328. else {
  12329. selectionRange = document.createRange();
  12330. }
  12331. var startNode = this._editor.getTextElement(left.blockIndex, left.textIndex);
  12332. if (!startNode) {
  12333. return false;
  12334. }
  12335. var endNode;
  12336. selectionRange.setStart(startNode, Math.min(left.offset, startNode.length));
  12337. if (range) {
  12338. endNode = this._editor.getTextElement(right.blockIndex, right.textIndex);
  12339. if (!endNode) {
  12340. return false;
  12341. }
  12342. selectionRange.setEnd(endNode, Math.min(right.offset, endNode.length));
  12343. }
  12344. else {
  12345. selectionRange.setEnd(startNode, Math.min(left.offset, startNode.length));
  12346. }
  12347. selection.addRange(selectionRange);
  12348. this._waitUpdate = false;
  12349. this._events.fire(types_1.RichTextEvents.selectionRefresh, []);
  12350. return true;
  12351. };
  12352. SelectionHelper.prototype._initEvents = function () {
  12353. document.addEventListener("selectionchange", this._selectionChange);
  12354. };
  12355. SelectionHelper.prototype._createRange = function (selection) {
  12356. var left = selection.left, right = selection.right;
  12357. var range = document.createRange();
  12358. var startNode = this._editor.getTextElement(left.blockIndex, left.textIndex);
  12359. range.setStart(startNode, left.offset);
  12360. if (selection.range) {
  12361. var endNode = this._editor.getTextElement(right.blockIndex, right.textIndex);
  12362. range.setEnd(endNode, right.offset);
  12363. }
  12364. else {
  12365. range.setEnd(startNode, left.offset);
  12366. }
  12367. return range;
  12368. };
  12369. return SelectionHelper;
  12370. }());
  12371. exports.SelectionHelper = SelectionHelper;
  12372. function getPositionFromRange(range) {
  12373. var pos = {};
  12374. var rect = range.getBoundingClientRect();
  12375. if (rect.height === 0) {
  12376. rect = range.getClientRects()[0];
  12377. }
  12378. pos.xStart = rect.left + window.pageXOffset;
  12379. pos.yStart = rect.top + window.pageYOffset;
  12380. range.collapse(false);
  12381. rect = range.getClientRects()[0];
  12382. pos.xEnd = rect.left + window.pageXOffset;
  12383. pos.yEnd = rect.top + window.pageYOffset;
  12384. return pos;
  12385. }
  12386. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(13)))
  12387. /***/ }),
  12388. /* 87 */
  12389. /***/ (function(module, exports, __webpack_require__) {
  12390. "use strict";
  12391. var __assign = (this && this.__assign) || Object.assign || function(t) {
  12392. for (var s, i = 1, n = arguments.length; i < n; i++) {
  12393. s = arguments[i];
  12394. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  12395. t[p] = s[p];
  12396. }
  12397. return t;
  12398. };
  12399. Object.defineProperty(exports, "__esModule", { value: true });
  12400. var html_1 = __webpack_require__(1);
  12401. var other_1 = __webpack_require__(4);
  12402. function stateFromDom(editor) {
  12403. var _a, _b;
  12404. var _c = window.getSelection(), anchorNode = _c.anchorNode, anchorOffset = _c.anchorOffset, focusNode = _c.focusNode, focusOffset = _c.focusOffset, isCollapsed = _c.isCollapsed;
  12405. var leftNode = anchorNode;
  12406. var rightNode = focusNode;
  12407. var leftOffset = anchorOffset;
  12408. var rightOffset = focusOffset;
  12409. if (isSelectionBackwards()) {
  12410. _a = [rightNode, leftNode], leftNode = _a[0], rightNode = _a[1];
  12411. _b = [rightOffset, leftOffset], leftOffset = _b[0], rightOffset = _b[1];
  12412. }
  12413. var leftKey = html_1.locate(leftNode, "dhx_offset");
  12414. var rightKey = html_1.locate(rightNode, "dhx_offset");
  12415. var leftInfo = other_1.hashToInfo(leftKey);
  12416. var rightInfo = other_1.hashToInfo(rightKey);
  12417. var left;
  12418. var right;
  12419. if (leftInfo.length === 2) {
  12420. if (leftNode.nodeType === 3) {
  12421. left = {
  12422. blockIndex: leftInfo[0],
  12423. textIndex: leftInfo[1],
  12424. offset: leftOffset
  12425. };
  12426. }
  12427. else {
  12428. left = {
  12429. blockIndex: leftInfo[0],
  12430. textIndex: leftInfo[1],
  12431. offset: editor.blocks[leftInfo[0]].textNodes[leftInfo[1]].text.length
  12432. };
  12433. }
  12434. }
  12435. else if (leftInfo.length === 1) {
  12436. if (editor.blocks[leftInfo[0]].textNodes[leftOffset]) {
  12437. left = {
  12438. blockIndex: leftInfo[0],
  12439. textIndex: leftOffset,
  12440. offset: 0
  12441. };
  12442. }
  12443. else {
  12444. left = {
  12445. blockIndex: leftInfo[0],
  12446. textIndex: leftOffset - 1,
  12447. offset: editor.blocks[leftInfo[0]].textNodes[leftOffset - 1].text.length
  12448. };
  12449. }
  12450. }
  12451. else {
  12452. left = {
  12453. blockIndex: leftOffset,
  12454. textIndex: 0,
  12455. offset: 0
  12456. };
  12457. }
  12458. if (isCollapsed) {
  12459. return {
  12460. range: false,
  12461. left: left
  12462. };
  12463. }
  12464. if (rightInfo.length === 2) {
  12465. if (rightNode.nodeType === 3) {
  12466. right = {
  12467. blockIndex: rightInfo[0],
  12468. textIndex: rightInfo[1],
  12469. offset: rightOffset
  12470. };
  12471. }
  12472. else {
  12473. right = {
  12474. blockIndex: rightInfo[0],
  12475. textIndex: rightInfo[1],
  12476. offset: editor.blocks[rightInfo[0]].textNodes[rightInfo[1]].text.length
  12477. };
  12478. }
  12479. }
  12480. else if (rightInfo.length === 1) {
  12481. if (rightOffset === 0) {
  12482. right = __assign({ blockIndex: rightInfo[0] - 1 }, editor.blocks[rightInfo[0] - 1].getBlockEnd());
  12483. }
  12484. else {
  12485. right = {
  12486. blockIndex: rightInfo[0],
  12487. textIndex: rightOffset - 1,
  12488. offset: editor.blocks[rightInfo[0]].textNodes[rightOffset - 1].text.length
  12489. };
  12490. }
  12491. }
  12492. else {
  12493. right = __assign({ blockIndex: rightOffset - 1 }, editor.blocks[rightOffset - 1].getBlockEnd());
  12494. }
  12495. return {
  12496. left: left,
  12497. right: right,
  12498. range: true
  12499. };
  12500. }
  12501. exports.stateFromDom = stateFromDom;
  12502. // range end cannot be set before range start, so if selection backwards range be collapsed
  12503. function isSelectionBackwards() {
  12504. var _a = window.getSelection(), anchorNode = _a.anchorNode, focusNode = _a.focusNode, anchorOffset = _a.anchorOffset, focusOffset = _a.focusOffset;
  12505. var range = document.createRange();
  12506. range.setStart(anchorNode, anchorOffset);
  12507. range.setEnd(focusNode, focusOffset);
  12508. return range.collapsed;
  12509. }
  12510. /***/ })
  12511. /******/ ]);
  12512. });if (window.dhx_legacy) { if (window.dhx){ for (var key in dhx) dhx_legacy[key] = dhx[key]; } window.dhx = dhx_legacy; delete window.dhx_legacy; }