quill.js 429 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562
  1. /*!
  2. * Quill Editor v1.3.7
  3. * https://quilljs.com/
  4. * Copyright (c) 2014, Jason Chen
  5. * Copyright (c) 2013, salesforce.com
  6. */
  7. (function webpackUniversalModuleDefinition(root, factory) {
  8. if(typeof exports === 'object' && typeof module === 'object')
  9. module.exports = factory();
  10. else if(typeof define === 'function' && define.amd)
  11. define([], factory);
  12. else if(typeof exports === 'object')
  13. exports["Quill"] = factory();
  14. else
  15. root["Quill"] = factory();
  16. })(typeof self !== 'undefined' ? self : this, function() {
  17. return /******/ (function(modules) { // webpackBootstrap
  18. /******/ // The module cache
  19. /******/ var installedModules = {};
  20. /******/
  21. /******/ // The require function
  22. /******/ function __webpack_require__(moduleId) {
  23. /******/
  24. /******/ // Check if module is in cache
  25. /******/ if(installedModules[moduleId]) {
  26. /******/ return installedModules[moduleId].exports;
  27. /******/ }
  28. /******/ // Create a new module (and put it into the cache)
  29. /******/ var module = installedModules[moduleId] = {
  30. /******/ i: moduleId,
  31. /******/ l: false,
  32. /******/ exports: {}
  33. /******/ };
  34. /******/
  35. /******/ // Execute the module function
  36. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  37. /******/
  38. /******/ // Flag the module as loaded
  39. /******/ module.l = true;
  40. /******/
  41. /******/ // Return the exports of the module
  42. /******/ return module.exports;
  43. /******/ }
  44. /******/
  45. /******/
  46. /******/ // expose the modules object (__webpack_modules__)
  47. /******/ __webpack_require__.m = modules;
  48. /******/
  49. /******/ // expose the module cache
  50. /******/ __webpack_require__.c = installedModules;
  51. /******/
  52. /******/ // define getter function for harmony exports
  53. /******/ __webpack_require__.d = function(exports, name, getter) {
  54. /******/ if(!__webpack_require__.o(exports, name)) {
  55. /******/ Object.defineProperty(exports, name, {
  56. /******/ configurable: false,
  57. /******/ enumerable: true,
  58. /******/ get: getter
  59. /******/ });
  60. /******/ }
  61. /******/ };
  62. /******/
  63. /******/ // getDefaultExport function for compatibility with non-harmony modules
  64. /******/ __webpack_require__.n = function(module) {
  65. /******/ var getter = module && module.__esModule ?
  66. /******/ function getDefault() { return module['default']; } :
  67. /******/ function getModuleExports() { return module; };
  68. /******/ __webpack_require__.d(getter, 'a', getter);
  69. /******/ return getter;
  70. /******/ };
  71. /******/
  72. /******/ // Object.prototype.hasOwnProperty.call
  73. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  74. /******/
  75. /******/ // __webpack_public_path__
  76. /******/ __webpack_require__.p = "";
  77. /******/
  78. /******/ // Load entry module and return exports
  79. /******/ return __webpack_require__(__webpack_require__.s = 109);
  80. /******/ })
  81. /************************************************************************/
  82. /******/ ([
  83. /* 0 */
  84. /***/ (function(module, exports, __webpack_require__) {
  85. "use strict";
  86. Object.defineProperty(exports, "__esModule", { value: true });
  87. var container_1 = __webpack_require__(17);
  88. var format_1 = __webpack_require__(18);
  89. var leaf_1 = __webpack_require__(19);
  90. var scroll_1 = __webpack_require__(45);
  91. var inline_1 = __webpack_require__(46);
  92. var block_1 = __webpack_require__(47);
  93. var embed_1 = __webpack_require__(48);
  94. var text_1 = __webpack_require__(49);
  95. var attributor_1 = __webpack_require__(12);
  96. var class_1 = __webpack_require__(32);
  97. var style_1 = __webpack_require__(33);
  98. var store_1 = __webpack_require__(31);
  99. var Registry = __webpack_require__(1);
  100. var Parchment = {
  101. Scope: Registry.Scope,
  102. create: Registry.create,
  103. find: Registry.find,
  104. query: Registry.query,
  105. register: Registry.register,
  106. Container: container_1.default,
  107. Format: format_1.default,
  108. Leaf: leaf_1.default,
  109. Embed: embed_1.default,
  110. Scroll: scroll_1.default,
  111. Block: block_1.default,
  112. Inline: inline_1.default,
  113. Text: text_1.default,
  114. Attributor: {
  115. Attribute: attributor_1.default,
  116. Class: class_1.default,
  117. Style: style_1.default,
  118. Store: store_1.default,
  119. },
  120. };
  121. exports.default = Parchment;
  122. /***/ }),
  123. /* 1 */
  124. /***/ (function(module, exports, __webpack_require__) {
  125. "use strict";
  126. var __extends = (this && this.__extends) || (function () {
  127. var extendStatics = Object.setPrototypeOf ||
  128. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  129. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  130. return function (d, b) {
  131. extendStatics(d, b);
  132. function __() { this.constructor = d; }
  133. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  134. };
  135. })();
  136. Object.defineProperty(exports, "__esModule", { value: true });
  137. var ParchmentError = /** @class */ (function (_super) {
  138. __extends(ParchmentError, _super);
  139. function ParchmentError(message) {
  140. var _this = this;
  141. message = '[Parchment] ' + message;
  142. _this = _super.call(this, message) || this;
  143. _this.message = message;
  144. _this.name = _this.constructor.name;
  145. return _this;
  146. }
  147. return ParchmentError;
  148. }(Error));
  149. exports.ParchmentError = ParchmentError;
  150. var attributes = {};
  151. var classes = {};
  152. var tags = {};
  153. var types = {};
  154. exports.DATA_KEY = '__blot';
  155. var Scope;
  156. (function (Scope) {
  157. Scope[Scope["TYPE"] = 3] = "TYPE";
  158. Scope[Scope["LEVEL"] = 12] = "LEVEL";
  159. Scope[Scope["ATTRIBUTE"] = 13] = "ATTRIBUTE";
  160. Scope[Scope["BLOT"] = 14] = "BLOT";
  161. Scope[Scope["INLINE"] = 7] = "INLINE";
  162. Scope[Scope["BLOCK"] = 11] = "BLOCK";
  163. Scope[Scope["BLOCK_BLOT"] = 10] = "BLOCK_BLOT";
  164. Scope[Scope["INLINE_BLOT"] = 6] = "INLINE_BLOT";
  165. Scope[Scope["BLOCK_ATTRIBUTE"] = 9] = "BLOCK_ATTRIBUTE";
  166. Scope[Scope["INLINE_ATTRIBUTE"] = 5] = "INLINE_ATTRIBUTE";
  167. Scope[Scope["ANY"] = 15] = "ANY";
  168. })(Scope = exports.Scope || (exports.Scope = {}));
  169. function create(input, value) {
  170. var match = query(input);
  171. if (match == null) {
  172. throw new ParchmentError("Unable to create " + input + " blot");
  173. }
  174. var BlotClass = match;
  175. var node =
  176. // @ts-ignore
  177. input instanceof Node || input['nodeType'] === Node.TEXT_NODE ? input : BlotClass.create(value);
  178. return new BlotClass(node, value);
  179. }
  180. exports.create = create;
  181. function find(node, bubble) {
  182. if (bubble === void 0) { bubble = false; }
  183. if (node == null)
  184. return null;
  185. // @ts-ignore
  186. if (node[exports.DATA_KEY] != null)
  187. return node[exports.DATA_KEY].blot;
  188. if (bubble)
  189. return find(node.parentNode, bubble);
  190. return null;
  191. }
  192. exports.find = find;
  193. function query(query, scope) {
  194. if (scope === void 0) { scope = Scope.ANY; }
  195. var match;
  196. if (typeof query === 'string') {
  197. match = types[query] || attributes[query];
  198. // @ts-ignore
  199. }
  200. else if (query instanceof Text || query['nodeType'] === Node.TEXT_NODE) {
  201. match = types['text'];
  202. }
  203. else if (typeof query === 'number') {
  204. if (query & Scope.LEVEL & Scope.BLOCK) {
  205. match = types['block'];
  206. }
  207. else if (query & Scope.LEVEL & Scope.INLINE) {
  208. match = types['inline'];
  209. }
  210. }
  211. else if (query instanceof HTMLElement) {
  212. var names = (query.getAttribute('class') || '').split(/\s+/);
  213. for (var i in names) {
  214. match = classes[names[i]];
  215. if (match)
  216. break;
  217. }
  218. match = match || tags[query.tagName];
  219. }
  220. if (match == null)
  221. return null;
  222. // @ts-ignore
  223. if (scope & Scope.LEVEL & match.scope && scope & Scope.TYPE & match.scope)
  224. return match;
  225. return null;
  226. }
  227. exports.query = query;
  228. function register() {
  229. var Definitions = [];
  230. for (var _i = 0; _i < arguments.length; _i++) {
  231. Definitions[_i] = arguments[_i];
  232. }
  233. if (Definitions.length > 1) {
  234. return Definitions.map(function (d) {
  235. return register(d);
  236. });
  237. }
  238. var Definition = Definitions[0];
  239. if (typeof Definition.blotName !== 'string' && typeof Definition.attrName !== 'string') {
  240. throw new ParchmentError('Invalid definition');
  241. }
  242. else if (Definition.blotName === 'abstract') {
  243. throw new ParchmentError('Cannot register abstract class');
  244. }
  245. types[Definition.blotName || Definition.attrName] = Definition;
  246. if (typeof Definition.keyName === 'string') {
  247. attributes[Definition.keyName] = Definition;
  248. }
  249. else {
  250. if (Definition.className != null) {
  251. classes[Definition.className] = Definition;
  252. }
  253. if (Definition.tagName != null) {
  254. if (Array.isArray(Definition.tagName)) {
  255. Definition.tagName = Definition.tagName.map(function (tagName) {
  256. return tagName.toUpperCase();
  257. });
  258. }
  259. else {
  260. Definition.tagName = Definition.tagName.toUpperCase();
  261. }
  262. var tagNames = Array.isArray(Definition.tagName) ? Definition.tagName : [Definition.tagName];
  263. tagNames.forEach(function (tag) {
  264. if (tags[tag] == null || Definition.className == null) {
  265. tags[tag] = Definition;
  266. }
  267. });
  268. }
  269. }
  270. return Definition;
  271. }
  272. exports.register = register;
  273. /***/ }),
  274. /* 2 */
  275. /***/ (function(module, exports, __webpack_require__) {
  276. var diff = __webpack_require__(51);
  277. var equal = __webpack_require__(11);
  278. var extend = __webpack_require__(3);
  279. var op = __webpack_require__(20);
  280. var NULL_CHARACTER = String.fromCharCode(0); // Placeholder char for embed in diff()
  281. var Delta = function (ops) {
  282. // Assume we are given a well formed ops
  283. if (Array.isArray(ops)) {
  284. this.ops = ops;
  285. } else if (ops != null && Array.isArray(ops.ops)) {
  286. this.ops = ops.ops;
  287. } else {
  288. this.ops = [];
  289. }
  290. };
  291. Delta.prototype.insert = function (text, attributes) {
  292. var newOp = {};
  293. if (text.length === 0) return this;
  294. newOp.insert = text;
  295. if (attributes != null && typeof attributes === 'object' && Object.keys(attributes).length > 0) {
  296. newOp.attributes = attributes;
  297. }
  298. return this.push(newOp);
  299. };
  300. Delta.prototype['delete'] = function (length) {
  301. if (length <= 0) return this;
  302. return this.push({ 'delete': length });
  303. };
  304. Delta.prototype.retain = function (length, attributes) {
  305. if (length <= 0) return this;
  306. var newOp = { retain: length };
  307. if (attributes != null && typeof attributes === 'object' && Object.keys(attributes).length > 0) {
  308. newOp.attributes = attributes;
  309. }
  310. return this.push(newOp);
  311. };
  312. Delta.prototype.push = function (newOp) {
  313. var index = this.ops.length;
  314. var lastOp = this.ops[index - 1];
  315. newOp = extend(true, {}, newOp);
  316. if (typeof lastOp === 'object') {
  317. if (typeof newOp['delete'] === 'number' && typeof lastOp['delete'] === 'number') {
  318. this.ops[index - 1] = { 'delete': lastOp['delete'] + newOp['delete'] };
  319. return this;
  320. }
  321. // Since it does not matter if we insert before or after deleting at the same index,
  322. // always prefer to insert first
  323. if (typeof lastOp['delete'] === 'number' && newOp.insert != null) {
  324. index -= 1;
  325. lastOp = this.ops[index - 1];
  326. if (typeof lastOp !== 'object') {
  327. this.ops.unshift(newOp);
  328. return this;
  329. }
  330. }
  331. if (equal(newOp.attributes, lastOp.attributes)) {
  332. if (typeof newOp.insert === 'string' && typeof lastOp.insert === 'string') {
  333. this.ops[index - 1] = { insert: lastOp.insert + newOp.insert };
  334. if (typeof newOp.attributes === 'object') this.ops[index - 1].attributes = newOp.attributes
  335. return this;
  336. } else if (typeof newOp.retain === 'number' && typeof lastOp.retain === 'number') {
  337. this.ops[index - 1] = { retain: lastOp.retain + newOp.retain };
  338. if (typeof newOp.attributes === 'object') this.ops[index - 1].attributes = newOp.attributes
  339. return this;
  340. }
  341. }
  342. }
  343. if (index === this.ops.length) {
  344. this.ops.push(newOp);
  345. } else {
  346. this.ops.splice(index, 0, newOp);
  347. }
  348. return this;
  349. };
  350. Delta.prototype.chop = function () {
  351. var lastOp = this.ops[this.ops.length - 1];
  352. if (lastOp && lastOp.retain && !lastOp.attributes) {
  353. this.ops.pop();
  354. }
  355. return this;
  356. };
  357. Delta.prototype.filter = function (predicate) {
  358. return this.ops.filter(predicate);
  359. };
  360. Delta.prototype.forEach = function (predicate) {
  361. this.ops.forEach(predicate);
  362. };
  363. Delta.prototype.map = function (predicate) {
  364. return this.ops.map(predicate);
  365. };
  366. Delta.prototype.partition = function (predicate) {
  367. var passed = [], failed = [];
  368. this.forEach(function(op) {
  369. var target = predicate(op) ? passed : failed;
  370. target.push(op);
  371. });
  372. return [passed, failed];
  373. };
  374. Delta.prototype.reduce = function (predicate, initial) {
  375. return this.ops.reduce(predicate, initial);
  376. };
  377. Delta.prototype.changeLength = function () {
  378. return this.reduce(function (length, elem) {
  379. if (elem.insert) {
  380. return length + op.length(elem);
  381. } else if (elem.delete) {
  382. return length - elem.delete;
  383. }
  384. return length;
  385. }, 0);
  386. };
  387. Delta.prototype.length = function () {
  388. return this.reduce(function (length, elem) {
  389. return length + op.length(elem);
  390. }, 0);
  391. };
  392. Delta.prototype.slice = function (start, end) {
  393. start = start || 0;
  394. if (typeof end !== 'number') end = Infinity;
  395. var ops = [];
  396. var iter = op.iterator(this.ops);
  397. var index = 0;
  398. while (index < end && iter.hasNext()) {
  399. var nextOp;
  400. if (index < start) {
  401. nextOp = iter.next(start - index);
  402. } else {
  403. nextOp = iter.next(end - index);
  404. ops.push(nextOp);
  405. }
  406. index += op.length(nextOp);
  407. }
  408. return new Delta(ops);
  409. };
  410. Delta.prototype.compose = function (other) {
  411. var thisIter = op.iterator(this.ops);
  412. var otherIter = op.iterator(other.ops);
  413. var ops = [];
  414. var firstOther = otherIter.peek();
  415. if (firstOther != null && typeof firstOther.retain === 'number' && firstOther.attributes == null) {
  416. var firstLeft = firstOther.retain;
  417. while (thisIter.peekType() === 'insert' && thisIter.peekLength() <= firstLeft) {
  418. firstLeft -= thisIter.peekLength();
  419. ops.push(thisIter.next());
  420. }
  421. if (firstOther.retain - firstLeft > 0) {
  422. otherIter.next(firstOther.retain - firstLeft);
  423. }
  424. }
  425. var delta = new Delta(ops);
  426. while (thisIter.hasNext() || otherIter.hasNext()) {
  427. if (otherIter.peekType() === 'insert') {
  428. delta.push(otherIter.next());
  429. } else if (thisIter.peekType() === 'delete') {
  430. delta.push(thisIter.next());
  431. } else {
  432. var length = Math.min(thisIter.peekLength(), otherIter.peekLength());
  433. var thisOp = thisIter.next(length);
  434. var otherOp = otherIter.next(length);
  435. if (typeof otherOp.retain === 'number') {
  436. var newOp = {};
  437. if (typeof thisOp.retain === 'number') {
  438. newOp.retain = length;
  439. } else {
  440. newOp.insert = thisOp.insert;
  441. }
  442. // Preserve null when composing with a retain, otherwise remove it for inserts
  443. var attributes = op.attributes.compose(thisOp.attributes, otherOp.attributes, typeof thisOp.retain === 'number');
  444. if (attributes) newOp.attributes = attributes;
  445. delta.push(newOp);
  446. // Optimization if rest of other is just retain
  447. if (!otherIter.hasNext() && equal(delta.ops[delta.ops.length - 1], newOp)) {
  448. var rest = new Delta(thisIter.rest());
  449. return delta.concat(rest).chop();
  450. }
  451. // Other op should be delete, we could be an insert or retain
  452. // Insert + delete cancels out
  453. } else if (typeof otherOp['delete'] === 'number' && typeof thisOp.retain === 'number') {
  454. delta.push(otherOp);
  455. }
  456. }
  457. }
  458. return delta.chop();
  459. };
  460. Delta.prototype.concat = function (other) {
  461. var delta = new Delta(this.ops.slice());
  462. if (other.ops.length > 0) {
  463. delta.push(other.ops[0]);
  464. delta.ops = delta.ops.concat(other.ops.slice(1));
  465. }
  466. return delta;
  467. };
  468. Delta.prototype.diff = function (other, index) {
  469. if (this.ops === other.ops) {
  470. return new Delta();
  471. }
  472. var strings = [this, other].map(function (delta) {
  473. return delta.map(function (op) {
  474. if (op.insert != null) {
  475. return typeof op.insert === 'string' ? op.insert : NULL_CHARACTER;
  476. }
  477. var prep = (delta === other) ? 'on' : 'with';
  478. throw new Error('diff() called ' + prep + ' non-document');
  479. }).join('');
  480. });
  481. var delta = new Delta();
  482. var diffResult = diff(strings[0], strings[1], index);
  483. var thisIter = op.iterator(this.ops);
  484. var otherIter = op.iterator(other.ops);
  485. diffResult.forEach(function (component) {
  486. var length = component[1].length;
  487. while (length > 0) {
  488. var opLength = 0;
  489. switch (component[0]) {
  490. case diff.INSERT:
  491. opLength = Math.min(otherIter.peekLength(), length);
  492. delta.push(otherIter.next(opLength));
  493. break;
  494. case diff.DELETE:
  495. opLength = Math.min(length, thisIter.peekLength());
  496. thisIter.next(opLength);
  497. delta['delete'](opLength);
  498. break;
  499. case diff.EQUAL:
  500. opLength = Math.min(thisIter.peekLength(), otherIter.peekLength(), length);
  501. var thisOp = thisIter.next(opLength);
  502. var otherOp = otherIter.next(opLength);
  503. if (equal(thisOp.insert, otherOp.insert)) {
  504. delta.retain(opLength, op.attributes.diff(thisOp.attributes, otherOp.attributes));
  505. } else {
  506. delta.push(otherOp)['delete'](opLength);
  507. }
  508. break;
  509. }
  510. length -= opLength;
  511. }
  512. });
  513. return delta.chop();
  514. };
  515. Delta.prototype.eachLine = function (predicate, newline) {
  516. newline = newline || '\n';
  517. var iter = op.iterator(this.ops);
  518. var line = new Delta();
  519. var i = 0;
  520. while (iter.hasNext()) {
  521. if (iter.peekType() !== 'insert') return;
  522. var thisOp = iter.peek();
  523. var start = op.length(thisOp) - iter.peekLength();
  524. var index = typeof thisOp.insert === 'string' ?
  525. thisOp.insert.indexOf(newline, start) - start : -1;
  526. if (index < 0) {
  527. line.push(iter.next());
  528. } else if (index > 0) {
  529. line.push(iter.next(index));
  530. } else {
  531. if (predicate(line, iter.next(1).attributes || {}, i) === false) {
  532. return;
  533. }
  534. i += 1;
  535. line = new Delta();
  536. }
  537. }
  538. if (line.length() > 0) {
  539. predicate(line, {}, i);
  540. }
  541. };
  542. Delta.prototype.transform = function (other, priority) {
  543. priority = !!priority;
  544. if (typeof other === 'number') {
  545. return this.transformPosition(other, priority);
  546. }
  547. var thisIter = op.iterator(this.ops);
  548. var otherIter = op.iterator(other.ops);
  549. var delta = new Delta();
  550. while (thisIter.hasNext() || otherIter.hasNext()) {
  551. if (thisIter.peekType() === 'insert' && (priority || otherIter.peekType() !== 'insert')) {
  552. delta.retain(op.length(thisIter.next()));
  553. } else if (otherIter.peekType() === 'insert') {
  554. delta.push(otherIter.next());
  555. } else {
  556. var length = Math.min(thisIter.peekLength(), otherIter.peekLength());
  557. var thisOp = thisIter.next(length);
  558. var otherOp = otherIter.next(length);
  559. if (thisOp['delete']) {
  560. // Our delete either makes their delete redundant or removes their retain
  561. continue;
  562. } else if (otherOp['delete']) {
  563. delta.push(otherOp);
  564. } else {
  565. // We retain either their retain or insert
  566. delta.retain(length, op.attributes.transform(thisOp.attributes, otherOp.attributes, priority));
  567. }
  568. }
  569. }
  570. return delta.chop();
  571. };
  572. Delta.prototype.transformPosition = function (index, priority) {
  573. priority = !!priority;
  574. var thisIter = op.iterator(this.ops);
  575. var offset = 0;
  576. while (thisIter.hasNext() && offset <= index) {
  577. var length = thisIter.peekLength();
  578. var nextType = thisIter.peekType();
  579. thisIter.next();
  580. if (nextType === 'delete') {
  581. index -= Math.min(length, index - offset);
  582. continue;
  583. } else if (nextType === 'insert' && (offset < index || !priority)) {
  584. index += length;
  585. }
  586. offset += length;
  587. }
  588. return index;
  589. };
  590. module.exports = Delta;
  591. /***/ }),
  592. /* 3 */
  593. /***/ (function(module, exports) {
  594. 'use strict';
  595. var hasOwn = Object.prototype.hasOwnProperty;
  596. var toStr = Object.prototype.toString;
  597. var defineProperty = Object.defineProperty;
  598. var gOPD = Object.getOwnPropertyDescriptor;
  599. var isArray = function isArray(arr) {
  600. if (typeof Array.isArray === 'function') {
  601. return Array.isArray(arr);
  602. }
  603. return toStr.call(arr) === '[object Array]';
  604. };
  605. var isPlainObject = function isPlainObject(obj) {
  606. if (!obj || toStr.call(obj) !== '[object Object]') {
  607. return false;
  608. }
  609. var hasOwnConstructor = hasOwn.call(obj, 'constructor');
  610. var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
  611. // Not own constructor property must be Object
  612. if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
  613. return false;
  614. }
  615. // Own properties are enumerated firstly, so to speed up,
  616. // if last one is own, then all properties are own.
  617. var key;
  618. for (key in obj) { /**/ }
  619. return typeof key === 'undefined' || hasOwn.call(obj, key);
  620. };
  621. // If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target
  622. var setProperty = function setProperty(target, options) {
  623. if (defineProperty && options.name === '__proto__') {
  624. defineProperty(target, options.name, {
  625. enumerable: true,
  626. configurable: true,
  627. value: options.newValue,
  628. writable: true
  629. });
  630. } else {
  631. target[options.name] = options.newValue;
  632. }
  633. };
  634. // Return undefined instead of __proto__ if '__proto__' is not an own property
  635. var getProperty = function getProperty(obj, name) {
  636. if (name === '__proto__') {
  637. if (!hasOwn.call(obj, name)) {
  638. return void 0;
  639. } else if (gOPD) {
  640. // In early versions of node, obj['__proto__'] is buggy when obj has
  641. // __proto__ as an own property. Object.getOwnPropertyDescriptor() works.
  642. return gOPD(obj, name).value;
  643. }
  644. }
  645. return obj[name];
  646. };
  647. module.exports = function extend() {
  648. var options, name, src, copy, copyIsArray, clone;
  649. var target = arguments[0];
  650. var i = 1;
  651. var length = arguments.length;
  652. var deep = false;
  653. // Handle a deep copy situation
  654. if (typeof target === 'boolean') {
  655. deep = target;
  656. target = arguments[1] || {};
  657. // skip the boolean and the target
  658. i = 2;
  659. }
  660. if (target == null || (typeof target !== 'object' && typeof target !== 'function')) {
  661. target = {};
  662. }
  663. for (; i < length; ++i) {
  664. options = arguments[i];
  665. // Only deal with non-null/undefined values
  666. if (options != null) {
  667. // Extend the base object
  668. for (name in options) {
  669. src = getProperty(target, name);
  670. copy = getProperty(options, name);
  671. // Prevent never-ending loop
  672. if (target !== copy) {
  673. // Recurse if we're merging plain objects or arrays
  674. if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
  675. if (copyIsArray) {
  676. copyIsArray = false;
  677. clone = src && isArray(src) ? src : [];
  678. } else {
  679. clone = src && isPlainObject(src) ? src : {};
  680. }
  681. // Never move original objects, clone them
  682. setProperty(target, { name: name, newValue: extend(deep, clone, copy) });
  683. // Don't bring in undefined values
  684. } else if (typeof copy !== 'undefined') {
  685. setProperty(target, { name: name, newValue: copy });
  686. }
  687. }
  688. }
  689. }
  690. }
  691. // Return the modified object
  692. return target;
  693. };
  694. /***/ }),
  695. /* 4 */
  696. /***/ (function(module, exports, __webpack_require__) {
  697. "use strict";
  698. Object.defineProperty(exports, "__esModule", {
  699. value: true
  700. });
  701. exports.default = exports.BlockEmbed = exports.bubbleFormats = undefined;
  702. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  703. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  704. var _extend = __webpack_require__(3);
  705. var _extend2 = _interopRequireDefault(_extend);
  706. var _quillDelta = __webpack_require__(2);
  707. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  708. var _parchment = __webpack_require__(0);
  709. var _parchment2 = _interopRequireDefault(_parchment);
  710. var _break = __webpack_require__(16);
  711. var _break2 = _interopRequireDefault(_break);
  712. var _inline = __webpack_require__(6);
  713. var _inline2 = _interopRequireDefault(_inline);
  714. var _text = __webpack_require__(7);
  715. var _text2 = _interopRequireDefault(_text);
  716. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  717. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  718. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  719. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  720. var NEWLINE_LENGTH = 1;
  721. var BlockEmbed = function (_Parchment$Embed) {
  722. _inherits(BlockEmbed, _Parchment$Embed);
  723. function BlockEmbed() {
  724. _classCallCheck(this, BlockEmbed);
  725. return _possibleConstructorReturn(this, (BlockEmbed.__proto__ || Object.getPrototypeOf(BlockEmbed)).apply(this, arguments));
  726. }
  727. _createClass(BlockEmbed, [{
  728. key: 'attach',
  729. value: function attach() {
  730. _get(BlockEmbed.prototype.__proto__ || Object.getPrototypeOf(BlockEmbed.prototype), 'attach', this).call(this);
  731. this.attributes = new _parchment2.default.Attributor.Store(this.domNode);
  732. }
  733. }, {
  734. key: 'delta',
  735. value: function delta() {
  736. return new _quillDelta2.default().insert(this.value(), (0, _extend2.default)(this.formats(), this.attributes.values()));
  737. }
  738. }, {
  739. key: 'format',
  740. value: function format(name, value) {
  741. var attribute = _parchment2.default.query(name, _parchment2.default.Scope.BLOCK_ATTRIBUTE);
  742. if (attribute != null) {
  743. this.attributes.attribute(attribute, value);
  744. }
  745. }
  746. }, {
  747. key: 'formatAt',
  748. value: function formatAt(index, length, name, value) {
  749. this.format(name, value);
  750. }
  751. }, {
  752. key: 'insertAt',
  753. value: function insertAt(index, value, def) {
  754. if (typeof value === 'string' && value.endsWith('\n')) {
  755. var block = _parchment2.default.create(Block.blotName);
  756. this.parent.insertBefore(block, index === 0 ? this : this.next);
  757. block.insertAt(0, value.slice(0, -1));
  758. } else {
  759. _get(BlockEmbed.prototype.__proto__ || Object.getPrototypeOf(BlockEmbed.prototype), 'insertAt', this).call(this, index, value, def);
  760. }
  761. }
  762. }]);
  763. return BlockEmbed;
  764. }(_parchment2.default.Embed);
  765. BlockEmbed.scope = _parchment2.default.Scope.BLOCK_BLOT;
  766. // It is important for cursor behavior BlockEmbeds use tags that are block level elements
  767. var Block = function (_Parchment$Block) {
  768. _inherits(Block, _Parchment$Block);
  769. function Block(domNode) {
  770. _classCallCheck(this, Block);
  771. var _this2 = _possibleConstructorReturn(this, (Block.__proto__ || Object.getPrototypeOf(Block)).call(this, domNode));
  772. _this2.cache = {};
  773. return _this2;
  774. }
  775. _createClass(Block, [{
  776. key: 'delta',
  777. value: function delta() {
  778. if (this.cache.delta == null) {
  779. this.cache.delta = this.descendants(_parchment2.default.Leaf).reduce(function (delta, leaf) {
  780. if (leaf.length() === 0) {
  781. return delta;
  782. } else {
  783. return delta.insert(leaf.value(), bubbleFormats(leaf));
  784. }
  785. }, new _quillDelta2.default()).insert('\n', bubbleFormats(this));
  786. }
  787. return this.cache.delta;
  788. }
  789. }, {
  790. key: 'deleteAt',
  791. value: function deleteAt(index, length) {
  792. _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'deleteAt', this).call(this, index, length);
  793. this.cache = {};
  794. }
  795. }, {
  796. key: 'formatAt',
  797. value: function formatAt(index, length, name, value) {
  798. if (length <= 0) return;
  799. if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK)) {
  800. if (index + length === this.length()) {
  801. this.format(name, value);
  802. }
  803. } else {
  804. _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'formatAt', this).call(this, index, Math.min(length, this.length() - index - 1), name, value);
  805. }
  806. this.cache = {};
  807. }
  808. }, {
  809. key: 'insertAt',
  810. value: function insertAt(index, value, def) {
  811. if (def != null) return _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'insertAt', this).call(this, index, value, def);
  812. if (value.length === 0) return;
  813. var lines = value.split('\n');
  814. var text = lines.shift();
  815. if (text.length > 0) {
  816. if (index < this.length() - 1 || this.children.tail == null) {
  817. _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'insertAt', this).call(this, Math.min(index, this.length() - 1), text);
  818. } else {
  819. this.children.tail.insertAt(this.children.tail.length(), text);
  820. }
  821. this.cache = {};
  822. }
  823. var block = this;
  824. lines.reduce(function (index, line) {
  825. block = block.split(index, true);
  826. block.insertAt(0, line);
  827. return line.length;
  828. }, index + text.length);
  829. }
  830. }, {
  831. key: 'insertBefore',
  832. value: function insertBefore(blot, ref) {
  833. var head = this.children.head;
  834. _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'insertBefore', this).call(this, blot, ref);
  835. if (head instanceof _break2.default) {
  836. head.remove();
  837. }
  838. this.cache = {};
  839. }
  840. }, {
  841. key: 'length',
  842. value: function length() {
  843. if (this.cache.length == null) {
  844. this.cache.length = _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'length', this).call(this) + NEWLINE_LENGTH;
  845. }
  846. return this.cache.length;
  847. }
  848. }, {
  849. key: 'moveChildren',
  850. value: function moveChildren(target, ref) {
  851. _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'moveChildren', this).call(this, target, ref);
  852. this.cache = {};
  853. }
  854. }, {
  855. key: 'optimize',
  856. value: function optimize(context) {
  857. _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'optimize', this).call(this, context);
  858. this.cache = {};
  859. }
  860. }, {
  861. key: 'path',
  862. value: function path(index) {
  863. return _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'path', this).call(this, index, true);
  864. }
  865. }, {
  866. key: 'removeChild',
  867. value: function removeChild(child) {
  868. _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'removeChild', this).call(this, child);
  869. this.cache = {};
  870. }
  871. }, {
  872. key: 'split',
  873. value: function split(index) {
  874. var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  875. if (force && (index === 0 || index >= this.length() - NEWLINE_LENGTH)) {
  876. var clone = this.clone();
  877. if (index === 0) {
  878. this.parent.insertBefore(clone, this);
  879. return this;
  880. } else {
  881. this.parent.insertBefore(clone, this.next);
  882. return clone;
  883. }
  884. } else {
  885. var next = _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'split', this).call(this, index, force);
  886. this.cache = {};
  887. return next;
  888. }
  889. }
  890. }]);
  891. return Block;
  892. }(_parchment2.default.Block);
  893. Block.blotName = 'block';
  894. Block.tagName = 'P';
  895. Block.defaultChild = 'break';
  896. Block.allowedChildren = [_inline2.default, _parchment2.default.Embed, _text2.default];
  897. function bubbleFormats(blot) {
  898. var formats = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  899. if (blot == null) return formats;
  900. if (typeof blot.formats === 'function') {
  901. formats = (0, _extend2.default)(formats, blot.formats());
  902. }
  903. if (blot.parent == null || blot.parent.blotName == 'scroll' || blot.parent.statics.scope !== blot.statics.scope) {
  904. return formats;
  905. }
  906. return bubbleFormats(blot.parent, formats);
  907. }
  908. exports.bubbleFormats = bubbleFormats;
  909. exports.BlockEmbed = BlockEmbed;
  910. exports.default = Block;
  911. /***/ }),
  912. /* 5 */
  913. /***/ (function(module, exports, __webpack_require__) {
  914. "use strict";
  915. Object.defineProperty(exports, "__esModule", {
  916. value: true
  917. });
  918. exports.default = exports.overload = exports.expandConfig = undefined;
  919. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  920. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  921. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  922. __webpack_require__(50);
  923. var _quillDelta = __webpack_require__(2);
  924. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  925. var _editor = __webpack_require__(14);
  926. var _editor2 = _interopRequireDefault(_editor);
  927. var _emitter3 = __webpack_require__(8);
  928. var _emitter4 = _interopRequireDefault(_emitter3);
  929. var _module = __webpack_require__(9);
  930. var _module2 = _interopRequireDefault(_module);
  931. var _parchment = __webpack_require__(0);
  932. var _parchment2 = _interopRequireDefault(_parchment);
  933. var _selection = __webpack_require__(15);
  934. var _selection2 = _interopRequireDefault(_selection);
  935. var _extend = __webpack_require__(3);
  936. var _extend2 = _interopRequireDefault(_extend);
  937. var _logger = __webpack_require__(10);
  938. var _logger2 = _interopRequireDefault(_logger);
  939. var _theme = __webpack_require__(34);
  940. var _theme2 = _interopRequireDefault(_theme);
  941. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  942. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  943. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  944. var debug = (0, _logger2.default)('quill');
  945. var Quill = function () {
  946. _createClass(Quill, null, [{
  947. key: 'debug',
  948. value: function debug(limit) {
  949. if (limit === true) {
  950. limit = 'log';
  951. }
  952. _logger2.default.level(limit);
  953. }
  954. }, {
  955. key: 'find',
  956. value: function find(node) {
  957. return node.__quill || _parchment2.default.find(node);
  958. }
  959. }, {
  960. key: 'import',
  961. value: function _import(name) {
  962. if (this.imports[name] == null) {
  963. debug.error('Cannot import ' + name + '. Are you sure it was registered?');
  964. }
  965. return this.imports[name];
  966. }
  967. }, {
  968. key: 'register',
  969. value: function register(path, target) {
  970. var _this = this;
  971. var overwrite = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  972. if (typeof path !== 'string') {
  973. var name = path.attrName || path.blotName;
  974. if (typeof name === 'string') {
  975. // register(Blot | Attributor, overwrite)
  976. this.register('formats/' + name, path, target);
  977. } else {
  978. Object.keys(path).forEach(function (key) {
  979. _this.register(key, path[key], target);
  980. });
  981. }
  982. } else {
  983. if (this.imports[path] != null && !overwrite) {
  984. debug.warn('Overwriting ' + path + ' with', target);
  985. }
  986. this.imports[path] = target;
  987. if ((path.startsWith('blots/') || path.startsWith('formats/')) && target.blotName !== 'abstract') {
  988. _parchment2.default.register(target);
  989. } else if (path.startsWith('modules') && typeof target.register === 'function') {
  990. target.register();
  991. }
  992. }
  993. }
  994. }]);
  995. function Quill(container) {
  996. var _this2 = this;
  997. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  998. _classCallCheck(this, Quill);
  999. this.options = expandConfig(container, options);
  1000. this.container = this.options.container;
  1001. if (this.container == null) {
  1002. return debug.error('Invalid Quill container', container);
  1003. }
  1004. if (this.options.debug) {
  1005. Quill.debug(this.options.debug);
  1006. }
  1007. var html = this.container.innerHTML.trim();
  1008. this.container.classList.add('ql-container');
  1009. this.container.innerHTML = '';
  1010. this.container.__quill = this;
  1011. this.root = this.addContainer('ql-editor');
  1012. this.root.classList.add('ql-blank');
  1013. this.root.setAttribute('data-gramm', false);
  1014. this.scrollingContainer = this.options.scrollingContainer || this.root;
  1015. this.emitter = new _emitter4.default();
  1016. this.scroll = _parchment2.default.create(this.root, {
  1017. emitter: this.emitter,
  1018. whitelist: this.options.formats
  1019. });
  1020. this.editor = new _editor2.default(this.scroll);
  1021. this.selection = new _selection2.default(this.scroll, this.emitter);
  1022. this.theme = new this.options.theme(this, this.options);
  1023. this.keyboard = this.theme.addModule('keyboard');
  1024. this.clipboard = this.theme.addModule('clipboard');
  1025. this.history = this.theme.addModule('history');
  1026. this.theme.init();
  1027. this.emitter.on(_emitter4.default.events.EDITOR_CHANGE, function (type) {
  1028. if (type === _emitter4.default.events.TEXT_CHANGE) {
  1029. _this2.root.classList.toggle('ql-blank', _this2.editor.isBlank());
  1030. }
  1031. });
  1032. this.emitter.on(_emitter4.default.events.SCROLL_UPDATE, function (source, mutations) {
  1033. var range = _this2.selection.lastRange;
  1034. var index = range && range.length === 0 ? range.index : undefined;
  1035. modify.call(_this2, function () {
  1036. return _this2.editor.update(null, mutations, index);
  1037. }, source);
  1038. });
  1039. var contents = this.clipboard.convert('<div class=\'ql-editor\' style="white-space: normal;">' + html + '<p><br></p></div>');
  1040. this.setContents(contents);
  1041. this.history.clear();
  1042. if (this.options.placeholder) {
  1043. this.root.setAttribute('data-placeholder', this.options.placeholder);
  1044. }
  1045. if (this.options.readOnly) {
  1046. this.disable();
  1047. }
  1048. }
  1049. _createClass(Quill, [{
  1050. key: 'addContainer',
  1051. value: function addContainer(container) {
  1052. var refNode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1053. if (typeof container === 'string') {
  1054. var className = container;
  1055. container = document.createElement('div');
  1056. container.classList.add(className);
  1057. }
  1058. this.container.insertBefore(container, refNode);
  1059. return container;
  1060. }
  1061. }, {
  1062. key: 'blur',
  1063. value: function blur() {
  1064. this.selection.setRange(null);
  1065. }
  1066. }, {
  1067. key: 'deleteText',
  1068. value: function deleteText(index, length, source) {
  1069. var _this3 = this;
  1070. var _overload = overload(index, length, source);
  1071. var _overload2 = _slicedToArray(_overload, 4);
  1072. index = _overload2[0];
  1073. length = _overload2[1];
  1074. source = _overload2[3];
  1075. return modify.call(this, function () {
  1076. return _this3.editor.deleteText(index, length);
  1077. }, source, index, -1 * length);
  1078. }
  1079. }, {
  1080. key: 'disable',
  1081. value: function disable() {
  1082. this.enable(false);
  1083. }
  1084. }, {
  1085. key: 'enable',
  1086. value: function enable() {
  1087. var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  1088. this.scroll.enable(enabled);
  1089. this.container.classList.toggle('ql-disabled', !enabled);
  1090. }
  1091. }, {
  1092. key: 'focus',
  1093. value: function focus() {
  1094. var scrollTop = this.scrollingContainer.scrollTop;
  1095. this.selection.focus();
  1096. this.scrollingContainer.scrollTop = scrollTop;
  1097. this.scrollIntoView();
  1098. }
  1099. }, {
  1100. key: 'format',
  1101. value: function format(name, value) {
  1102. var _this4 = this;
  1103. var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _emitter4.default.sources.API;
  1104. return modify.call(this, function () {
  1105. var range = _this4.getSelection(true);
  1106. var change = new _quillDelta2.default();
  1107. if (range == null) {
  1108. return change;
  1109. } else if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK)) {
  1110. change = _this4.editor.formatLine(range.index, range.length, _defineProperty({}, name, value));
  1111. } else if (range.length === 0) {
  1112. _this4.selection.format(name, value);
  1113. return change;
  1114. } else {
  1115. change = _this4.editor.formatText(range.index, range.length, _defineProperty({}, name, value));
  1116. }
  1117. _this4.setSelection(range, _emitter4.default.sources.SILENT);
  1118. return change;
  1119. }, source);
  1120. }
  1121. }, {
  1122. key: 'formatLine',
  1123. value: function formatLine(index, length, name, value, source) {
  1124. var _this5 = this;
  1125. var formats = void 0;
  1126. var _overload3 = overload(index, length, name, value, source);
  1127. var _overload4 = _slicedToArray(_overload3, 4);
  1128. index = _overload4[0];
  1129. length = _overload4[1];
  1130. formats = _overload4[2];
  1131. source = _overload4[3];
  1132. return modify.call(this, function () {
  1133. return _this5.editor.formatLine(index, length, formats);
  1134. }, source, index, 0);
  1135. }
  1136. }, {
  1137. key: 'formatText',
  1138. value: function formatText(index, length, name, value, source) {
  1139. var _this6 = this;
  1140. var formats = void 0;
  1141. var _overload5 = overload(index, length, name, value, source);
  1142. var _overload6 = _slicedToArray(_overload5, 4);
  1143. index = _overload6[0];
  1144. length = _overload6[1];
  1145. formats = _overload6[2];
  1146. source = _overload6[3];
  1147. return modify.call(this, function () {
  1148. return _this6.editor.formatText(index, length, formats);
  1149. }, source, index, 0);
  1150. }
  1151. }, {
  1152. key: 'getBounds',
  1153. value: function getBounds(index) {
  1154. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  1155. var bounds = void 0;
  1156. if (typeof index === 'number') {
  1157. bounds = this.selection.getBounds(index, length);
  1158. } else {
  1159. bounds = this.selection.getBounds(index.index, index.length);
  1160. }
  1161. var containerBounds = this.container.getBoundingClientRect();
  1162. return {
  1163. bottom: bounds.bottom - containerBounds.top,
  1164. height: bounds.height,
  1165. left: bounds.left - containerBounds.left,
  1166. right: bounds.right - containerBounds.left,
  1167. top: bounds.top - containerBounds.top,
  1168. width: bounds.width
  1169. };
  1170. }
  1171. }, {
  1172. key: 'getContents',
  1173. value: function getContents() {
  1174. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1175. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getLength() - index;
  1176. var _overload7 = overload(index, length);
  1177. var _overload8 = _slicedToArray(_overload7, 2);
  1178. index = _overload8[0];
  1179. length = _overload8[1];
  1180. return this.editor.getContents(index, length);
  1181. }
  1182. }, {
  1183. key: 'getFormat',
  1184. value: function getFormat() {
  1185. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getSelection(true);
  1186. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  1187. if (typeof index === 'number') {
  1188. return this.editor.getFormat(index, length);
  1189. } else {
  1190. return this.editor.getFormat(index.index, index.length);
  1191. }
  1192. }
  1193. }, {
  1194. key: 'getIndex',
  1195. value: function getIndex(blot) {
  1196. return blot.offset(this.scroll);
  1197. }
  1198. }, {
  1199. key: 'getLength',
  1200. value: function getLength() {
  1201. return this.scroll.length();
  1202. }
  1203. }, {
  1204. key: 'getLeaf',
  1205. value: function getLeaf(index) {
  1206. return this.scroll.leaf(index);
  1207. }
  1208. }, {
  1209. key: 'getLine',
  1210. value: function getLine(index) {
  1211. return this.scroll.line(index);
  1212. }
  1213. }, {
  1214. key: 'getLines',
  1215. value: function getLines() {
  1216. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1217. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_VALUE;
  1218. if (typeof index !== 'number') {
  1219. return this.scroll.lines(index.index, index.length);
  1220. } else {
  1221. return this.scroll.lines(index, length);
  1222. }
  1223. }
  1224. }, {
  1225. key: 'getModule',
  1226. value: function getModule(name) {
  1227. return this.theme.modules[name];
  1228. }
  1229. }, {
  1230. key: 'getSelection',
  1231. value: function getSelection() {
  1232. var focus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1233. if (focus) this.focus();
  1234. this.update(); // Make sure we access getRange with editor in consistent state
  1235. return this.selection.getRange()[0];
  1236. }
  1237. }, {
  1238. key: 'getText',
  1239. value: function getText() {
  1240. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1241. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getLength() - index;
  1242. var _overload9 = overload(index, length);
  1243. var _overload10 = _slicedToArray(_overload9, 2);
  1244. index = _overload10[0];
  1245. length = _overload10[1];
  1246. return this.editor.getText(index, length);
  1247. }
  1248. }, {
  1249. key: 'hasFocus',
  1250. value: function hasFocus() {
  1251. return this.selection.hasFocus();
  1252. }
  1253. }, {
  1254. key: 'insertEmbed',
  1255. value: function insertEmbed(index, embed, value) {
  1256. var _this7 = this;
  1257. var source = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Quill.sources.API;
  1258. return modify.call(this, function () {
  1259. return _this7.editor.insertEmbed(index, embed, value);
  1260. }, source, index);
  1261. }
  1262. }, {
  1263. key: 'insertText',
  1264. value: function insertText(index, text, name, value, source) {
  1265. var _this8 = this;
  1266. var formats = void 0;
  1267. var _overload11 = overload(index, 0, name, value, source);
  1268. var _overload12 = _slicedToArray(_overload11, 4);
  1269. index = _overload12[0];
  1270. formats = _overload12[2];
  1271. source = _overload12[3];
  1272. return modify.call(this, function () {
  1273. return _this8.editor.insertText(index, text, formats);
  1274. }, source, index, text.length);
  1275. }
  1276. }, {
  1277. key: 'isEnabled',
  1278. value: function isEnabled() {
  1279. return !this.container.classList.contains('ql-disabled');
  1280. }
  1281. }, {
  1282. key: 'off',
  1283. value: function off() {
  1284. return this.emitter.off.apply(this.emitter, arguments);
  1285. }
  1286. }, {
  1287. key: 'on',
  1288. value: function on() {
  1289. return this.emitter.on.apply(this.emitter, arguments);
  1290. }
  1291. }, {
  1292. key: 'once',
  1293. value: function once() {
  1294. return this.emitter.once.apply(this.emitter, arguments);
  1295. }
  1296. }, {
  1297. key: 'pasteHTML',
  1298. value: function pasteHTML(index, html, source) {
  1299. this.clipboard.dangerouslyPasteHTML(index, html, source);
  1300. }
  1301. }, {
  1302. key: 'removeFormat',
  1303. value: function removeFormat(index, length, source) {
  1304. var _this9 = this;
  1305. var _overload13 = overload(index, length, source);
  1306. var _overload14 = _slicedToArray(_overload13, 4);
  1307. index = _overload14[0];
  1308. length = _overload14[1];
  1309. source = _overload14[3];
  1310. return modify.call(this, function () {
  1311. return _this9.editor.removeFormat(index, length);
  1312. }, source, index);
  1313. }
  1314. }, {
  1315. key: 'scrollIntoView',
  1316. value: function scrollIntoView() {
  1317. this.selection.scrollIntoView(this.scrollingContainer);
  1318. }
  1319. }, {
  1320. key: 'setContents',
  1321. value: function setContents(delta) {
  1322. var _this10 = this;
  1323. var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter4.default.sources.API;
  1324. return modify.call(this, function () {
  1325. delta = new _quillDelta2.default(delta);
  1326. var length = _this10.getLength();
  1327. var deleted = _this10.editor.deleteText(0, length);
  1328. var applied = _this10.editor.applyDelta(delta);
  1329. var lastOp = applied.ops[applied.ops.length - 1];
  1330. if (lastOp != null && typeof lastOp.insert === 'string' && lastOp.insert[lastOp.insert.length - 1] === '\n') {
  1331. _this10.editor.deleteText(_this10.getLength() - 1, 1);
  1332. applied.delete(1);
  1333. }
  1334. var ret = deleted.compose(applied);
  1335. return ret;
  1336. }, source);
  1337. }
  1338. }, {
  1339. key: 'setSelection',
  1340. value: function setSelection(index, length, source) {
  1341. if (index == null) {
  1342. this.selection.setRange(null, length || Quill.sources.API);
  1343. } else {
  1344. var _overload15 = overload(index, length, source);
  1345. var _overload16 = _slicedToArray(_overload15, 4);
  1346. index = _overload16[0];
  1347. length = _overload16[1];
  1348. source = _overload16[3];
  1349. this.selection.setRange(new _selection.Range(index, length), source);
  1350. if (source !== _emitter4.default.sources.SILENT) {
  1351. this.selection.scrollIntoView(this.scrollingContainer);
  1352. }
  1353. }
  1354. }
  1355. }, {
  1356. key: 'setText',
  1357. value: function setText(text) {
  1358. var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter4.default.sources.API;
  1359. var delta = new _quillDelta2.default().insert(text);
  1360. return this.setContents(delta, source);
  1361. }
  1362. }, {
  1363. key: 'update',
  1364. value: function update() {
  1365. var source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _emitter4.default.sources.USER;
  1366. var change = this.scroll.update(source); // Will update selection before selection.update() does if text changes
  1367. this.selection.update(source);
  1368. return change;
  1369. }
  1370. }, {
  1371. key: 'updateContents',
  1372. value: function updateContents(delta) {
  1373. var _this11 = this;
  1374. var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter4.default.sources.API;
  1375. return modify.call(this, function () {
  1376. delta = new _quillDelta2.default(delta);
  1377. return _this11.editor.applyDelta(delta, source);
  1378. }, source, true);
  1379. }
  1380. }]);
  1381. return Quill;
  1382. }();
  1383. Quill.DEFAULTS = {
  1384. bounds: null,
  1385. formats: null,
  1386. modules: {},
  1387. placeholder: '',
  1388. readOnly: false,
  1389. scrollingContainer: null,
  1390. strict: true,
  1391. theme: 'default'
  1392. };
  1393. Quill.events = _emitter4.default.events;
  1394. Quill.sources = _emitter4.default.sources;
  1395. // eslint-disable-next-line no-undef
  1396. Quill.version = false ? 'dev' : "1.3.7";
  1397. Quill.imports = {
  1398. 'delta': _quillDelta2.default,
  1399. 'parchment': _parchment2.default,
  1400. 'core/module': _module2.default,
  1401. 'core/theme': _theme2.default
  1402. };
  1403. function expandConfig(container, userConfig) {
  1404. userConfig = (0, _extend2.default)(true, {
  1405. container: container,
  1406. modules: {
  1407. clipboard: true,
  1408. keyboard: true,
  1409. history: true
  1410. }
  1411. }, userConfig);
  1412. if (!userConfig.theme || userConfig.theme === Quill.DEFAULTS.theme) {
  1413. userConfig.theme = _theme2.default;
  1414. } else {
  1415. userConfig.theme = Quill.import('themes/' + userConfig.theme);
  1416. if (userConfig.theme == null) {
  1417. throw new Error('Invalid theme ' + userConfig.theme + '. Did you register it?');
  1418. }
  1419. }
  1420. var themeConfig = (0, _extend2.default)(true, {}, userConfig.theme.DEFAULTS);
  1421. [themeConfig, userConfig].forEach(function (config) {
  1422. config.modules = config.modules || {};
  1423. Object.keys(config.modules).forEach(function (module) {
  1424. if (config.modules[module] === true) {
  1425. config.modules[module] = {};
  1426. }
  1427. });
  1428. });
  1429. var moduleNames = Object.keys(themeConfig.modules).concat(Object.keys(userConfig.modules));
  1430. var moduleConfig = moduleNames.reduce(function (config, name) {
  1431. var moduleClass = Quill.import('modules/' + name);
  1432. if (moduleClass == null) {
  1433. debug.error('Cannot load ' + name + ' module. Are you sure you registered it?');
  1434. } else {
  1435. config[name] = moduleClass.DEFAULTS || {};
  1436. }
  1437. return config;
  1438. }, {});
  1439. // Special case toolbar shorthand
  1440. if (userConfig.modules != null && userConfig.modules.toolbar && userConfig.modules.toolbar.constructor !== Object) {
  1441. userConfig.modules.toolbar = {
  1442. container: userConfig.modules.toolbar
  1443. };
  1444. }
  1445. userConfig = (0, _extend2.default)(true, {}, Quill.DEFAULTS, { modules: moduleConfig }, themeConfig, userConfig);
  1446. ['bounds', 'container', 'scrollingContainer'].forEach(function (key) {
  1447. if (typeof userConfig[key] === 'string') {
  1448. userConfig[key] = document.querySelector(userConfig[key]);
  1449. }
  1450. });
  1451. userConfig.modules = Object.keys(userConfig.modules).reduce(function (config, name) {
  1452. if (userConfig.modules[name]) {
  1453. config[name] = userConfig.modules[name];
  1454. }
  1455. return config;
  1456. }, {});
  1457. return userConfig;
  1458. }
  1459. // Handle selection preservation and TEXT_CHANGE emission
  1460. // common to modification APIs
  1461. function modify(modifier, source, index, shift) {
  1462. if (this.options.strict && !this.isEnabled() && source === _emitter4.default.sources.USER) {
  1463. return new _quillDelta2.default();
  1464. }
  1465. var range = index == null ? null : this.getSelection();
  1466. var oldDelta = this.editor.delta;
  1467. var change = modifier();
  1468. if (range != null) {
  1469. if (index === true) index = range.index;
  1470. if (shift == null) {
  1471. range = shiftRange(range, change, source);
  1472. } else if (shift !== 0) {
  1473. range = shiftRange(range, index, shift, source);
  1474. }
  1475. this.setSelection(range, _emitter4.default.sources.SILENT);
  1476. }
  1477. if (change.length() > 0) {
  1478. var _emitter;
  1479. var args = [_emitter4.default.events.TEXT_CHANGE, change, oldDelta, source];
  1480. (_emitter = this.emitter).emit.apply(_emitter, [_emitter4.default.events.EDITOR_CHANGE].concat(args));
  1481. if (source !== _emitter4.default.sources.SILENT) {
  1482. var _emitter2;
  1483. (_emitter2 = this.emitter).emit.apply(_emitter2, args);
  1484. }
  1485. }
  1486. return change;
  1487. }
  1488. function overload(index, length, name, value, source) {
  1489. var formats = {};
  1490. if (typeof index.index === 'number' && typeof index.length === 'number') {
  1491. // Allow for throwaway end (used by insertText/insertEmbed)
  1492. if (typeof length !== 'number') {
  1493. source = value, value = name, name = length, length = index.length, index = index.index;
  1494. } else {
  1495. length = index.length, index = index.index;
  1496. }
  1497. } else if (typeof length !== 'number') {
  1498. source = value, value = name, name = length, length = 0;
  1499. }
  1500. // Handle format being object, two format name/value strings or excluded
  1501. if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') {
  1502. formats = name;
  1503. source = value;
  1504. } else if (typeof name === 'string') {
  1505. if (value != null) {
  1506. formats[name] = value;
  1507. } else {
  1508. source = name;
  1509. }
  1510. }
  1511. // Handle optional source
  1512. source = source || _emitter4.default.sources.API;
  1513. return [index, length, formats, source];
  1514. }
  1515. function shiftRange(range, index, length, source) {
  1516. if (range == null) return null;
  1517. var start = void 0,
  1518. end = void 0;
  1519. if (index instanceof _quillDelta2.default) {
  1520. var _map = [range.index, range.index + range.length].map(function (pos) {
  1521. return index.transformPosition(pos, source !== _emitter4.default.sources.USER);
  1522. });
  1523. var _map2 = _slicedToArray(_map, 2);
  1524. start = _map2[0];
  1525. end = _map2[1];
  1526. } else {
  1527. var _map3 = [range.index, range.index + range.length].map(function (pos) {
  1528. if (pos < index || pos === index && source === _emitter4.default.sources.USER) return pos;
  1529. if (length >= 0) {
  1530. return pos + length;
  1531. } else {
  1532. return Math.max(index, pos + length);
  1533. }
  1534. });
  1535. var _map4 = _slicedToArray(_map3, 2);
  1536. start = _map4[0];
  1537. end = _map4[1];
  1538. }
  1539. return new _selection.Range(start, end - start);
  1540. }
  1541. exports.expandConfig = expandConfig;
  1542. exports.overload = overload;
  1543. exports.default = Quill;
  1544. /***/ }),
  1545. /* 6 */
  1546. /***/ (function(module, exports, __webpack_require__) {
  1547. "use strict";
  1548. Object.defineProperty(exports, "__esModule", {
  1549. value: true
  1550. });
  1551. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1552. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  1553. var _text = __webpack_require__(7);
  1554. var _text2 = _interopRequireDefault(_text);
  1555. var _parchment = __webpack_require__(0);
  1556. var _parchment2 = _interopRequireDefault(_parchment);
  1557. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1558. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1559. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1560. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1561. var Inline = function (_Parchment$Inline) {
  1562. _inherits(Inline, _Parchment$Inline);
  1563. function Inline() {
  1564. _classCallCheck(this, Inline);
  1565. return _possibleConstructorReturn(this, (Inline.__proto__ || Object.getPrototypeOf(Inline)).apply(this, arguments));
  1566. }
  1567. _createClass(Inline, [{
  1568. key: 'formatAt',
  1569. value: function formatAt(index, length, name, value) {
  1570. if (Inline.compare(this.statics.blotName, name) < 0 && _parchment2.default.query(name, _parchment2.default.Scope.BLOT)) {
  1571. var blot = this.isolate(index, length);
  1572. if (value) {
  1573. blot.wrap(name, value);
  1574. }
  1575. } else {
  1576. _get(Inline.prototype.__proto__ || Object.getPrototypeOf(Inline.prototype), 'formatAt', this).call(this, index, length, name, value);
  1577. }
  1578. }
  1579. }, {
  1580. key: 'optimize',
  1581. value: function optimize(context) {
  1582. _get(Inline.prototype.__proto__ || Object.getPrototypeOf(Inline.prototype), 'optimize', this).call(this, context);
  1583. if (this.parent instanceof Inline && Inline.compare(this.statics.blotName, this.parent.statics.blotName) > 0) {
  1584. var parent = this.parent.isolate(this.offset(), this.length());
  1585. this.moveChildren(parent);
  1586. parent.wrap(this);
  1587. }
  1588. }
  1589. }], [{
  1590. key: 'compare',
  1591. value: function compare(self, other) {
  1592. var selfIndex = Inline.order.indexOf(self);
  1593. var otherIndex = Inline.order.indexOf(other);
  1594. if (selfIndex >= 0 || otherIndex >= 0) {
  1595. return selfIndex - otherIndex;
  1596. } else if (self === other) {
  1597. return 0;
  1598. } else if (self < other) {
  1599. return -1;
  1600. } else {
  1601. return 1;
  1602. }
  1603. }
  1604. }]);
  1605. return Inline;
  1606. }(_parchment2.default.Inline);
  1607. Inline.allowedChildren = [Inline, _parchment2.default.Embed, _text2.default];
  1608. // Lower index means deeper in the DOM tree, since not found (-1) is for embeds
  1609. Inline.order = ['cursor', 'inline', // Must be lower
  1610. 'underline', 'strike', 'italic', 'bold', 'script', 'link', 'code' // Must be higher
  1611. ];
  1612. exports.default = Inline;
  1613. /***/ }),
  1614. /* 7 */
  1615. /***/ (function(module, exports, __webpack_require__) {
  1616. "use strict";
  1617. Object.defineProperty(exports, "__esModule", {
  1618. value: true
  1619. });
  1620. var _parchment = __webpack_require__(0);
  1621. var _parchment2 = _interopRequireDefault(_parchment);
  1622. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1623. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1624. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1625. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1626. var TextBlot = function (_Parchment$Text) {
  1627. _inherits(TextBlot, _Parchment$Text);
  1628. function TextBlot() {
  1629. _classCallCheck(this, TextBlot);
  1630. return _possibleConstructorReturn(this, (TextBlot.__proto__ || Object.getPrototypeOf(TextBlot)).apply(this, arguments));
  1631. }
  1632. return TextBlot;
  1633. }(_parchment2.default.Text);
  1634. exports.default = TextBlot;
  1635. /***/ }),
  1636. /* 8 */
  1637. /***/ (function(module, exports, __webpack_require__) {
  1638. "use strict";
  1639. Object.defineProperty(exports, "__esModule", {
  1640. value: true
  1641. });
  1642. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1643. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  1644. var _eventemitter = __webpack_require__(54);
  1645. var _eventemitter2 = _interopRequireDefault(_eventemitter);
  1646. var _logger = __webpack_require__(10);
  1647. var _logger2 = _interopRequireDefault(_logger);
  1648. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1649. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1650. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1651. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1652. var debug = (0, _logger2.default)('quill:events');
  1653. var EVENTS = ['selectionchange', 'mousedown', 'mouseup', 'click'];
  1654. EVENTS.forEach(function (eventName) {
  1655. document.addEventListener(eventName, function () {
  1656. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  1657. args[_key] = arguments[_key];
  1658. }
  1659. [].slice.call(document.querySelectorAll('.ql-container')).forEach(function (node) {
  1660. // TODO use WeakMap
  1661. if (node.__quill && node.__quill.emitter) {
  1662. var _node$__quill$emitter;
  1663. (_node$__quill$emitter = node.__quill.emitter).handleDOM.apply(_node$__quill$emitter, args);
  1664. }
  1665. });
  1666. });
  1667. });
  1668. var Emitter = function (_EventEmitter) {
  1669. _inherits(Emitter, _EventEmitter);
  1670. function Emitter() {
  1671. _classCallCheck(this, Emitter);
  1672. var _this = _possibleConstructorReturn(this, (Emitter.__proto__ || Object.getPrototypeOf(Emitter)).call(this));
  1673. _this.listeners = {};
  1674. _this.on('error', debug.error);
  1675. return _this;
  1676. }
  1677. _createClass(Emitter, [{
  1678. key: 'emit',
  1679. value: function emit() {
  1680. debug.log.apply(debug, arguments);
  1681. _get(Emitter.prototype.__proto__ || Object.getPrototypeOf(Emitter.prototype), 'emit', this).apply(this, arguments);
  1682. }
  1683. }, {
  1684. key: 'handleDOM',
  1685. value: function handleDOM(event) {
  1686. for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  1687. args[_key2 - 1] = arguments[_key2];
  1688. }
  1689. (this.listeners[event.type] || []).forEach(function (_ref) {
  1690. var node = _ref.node,
  1691. handler = _ref.handler;
  1692. if (event.target === node || node.contains(event.target)) {
  1693. handler.apply(undefined, [event].concat(args));
  1694. }
  1695. });
  1696. }
  1697. }, {
  1698. key: 'listenDOM',
  1699. value: function listenDOM(eventName, node, handler) {
  1700. if (!this.listeners[eventName]) {
  1701. this.listeners[eventName] = [];
  1702. }
  1703. this.listeners[eventName].push({ node: node, handler: handler });
  1704. }
  1705. }]);
  1706. return Emitter;
  1707. }(_eventemitter2.default);
  1708. Emitter.events = {
  1709. EDITOR_CHANGE: 'editor-change',
  1710. SCROLL_BEFORE_UPDATE: 'scroll-before-update',
  1711. SCROLL_OPTIMIZE: 'scroll-optimize',
  1712. SCROLL_UPDATE: 'scroll-update',
  1713. SELECTION_CHANGE: 'selection-change',
  1714. TEXT_CHANGE: 'text-change'
  1715. };
  1716. Emitter.sources = {
  1717. API: 'api',
  1718. SILENT: 'silent',
  1719. USER: 'user'
  1720. };
  1721. exports.default = Emitter;
  1722. /***/ }),
  1723. /* 9 */
  1724. /***/ (function(module, exports, __webpack_require__) {
  1725. "use strict";
  1726. Object.defineProperty(exports, "__esModule", {
  1727. value: true
  1728. });
  1729. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1730. var Module = function Module(quill) {
  1731. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1732. _classCallCheck(this, Module);
  1733. this.quill = quill;
  1734. this.options = options;
  1735. };
  1736. Module.DEFAULTS = {};
  1737. exports.default = Module;
  1738. /***/ }),
  1739. /* 10 */
  1740. /***/ (function(module, exports, __webpack_require__) {
  1741. "use strict";
  1742. Object.defineProperty(exports, "__esModule", {
  1743. value: true
  1744. });
  1745. var levels = ['error', 'warn', 'log', 'info'];
  1746. var level = 'warn';
  1747. function debug(method) {
  1748. if (levels.indexOf(method) <= levels.indexOf(level)) {
  1749. var _console;
  1750. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1751. args[_key - 1] = arguments[_key];
  1752. }
  1753. (_console = console)[method].apply(_console, args); // eslint-disable-line no-console
  1754. }
  1755. }
  1756. function namespace(ns) {
  1757. return levels.reduce(function (logger, method) {
  1758. logger[method] = debug.bind(console, method, ns);
  1759. return logger;
  1760. }, {});
  1761. }
  1762. debug.level = namespace.level = function (newLevel) {
  1763. level = newLevel;
  1764. };
  1765. exports.default = namespace;
  1766. /***/ }),
  1767. /* 11 */
  1768. /***/ (function(module, exports, __webpack_require__) {
  1769. var pSlice = Array.prototype.slice;
  1770. var objectKeys = __webpack_require__(52);
  1771. var isArguments = __webpack_require__(53);
  1772. var deepEqual = module.exports = function (actual, expected, opts) {
  1773. if (!opts) opts = {};
  1774. // 7.1. All identical values are equivalent, as determined by ===.
  1775. if (actual === expected) {
  1776. return true;
  1777. } else if (actual instanceof Date && expected instanceof Date) {
  1778. return actual.getTime() === expected.getTime();
  1779. // 7.3. Other pairs that do not both pass typeof value == 'object',
  1780. // equivalence is determined by ==.
  1781. } else if (!actual || !expected || typeof actual != 'object' && typeof expected != 'object') {
  1782. return opts.strict ? actual === expected : actual == expected;
  1783. // 7.4. For all other Object pairs, including Array objects, equivalence is
  1784. // determined by having the same number of owned properties (as verified
  1785. // with Object.prototype.hasOwnProperty.call), the same set of keys
  1786. // (although not necessarily the same order), equivalent values for every
  1787. // corresponding key, and an identical 'prototype' property. Note: this
  1788. // accounts for both named and indexed properties on Arrays.
  1789. } else {
  1790. return objEquiv(actual, expected, opts);
  1791. }
  1792. }
  1793. function isUndefinedOrNull(value) {
  1794. return value === null || value === undefined;
  1795. }
  1796. function isBuffer (x) {
  1797. if (!x || typeof x !== 'object' || typeof x.length !== 'number') return false;
  1798. if (typeof x.copy !== 'function' || typeof x.slice !== 'function') {
  1799. return false;
  1800. }
  1801. if (x.length > 0 && typeof x[0] !== 'number') return false;
  1802. return true;
  1803. }
  1804. function objEquiv(a, b, opts) {
  1805. var i, key;
  1806. if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
  1807. return false;
  1808. // an identical 'prototype' property.
  1809. if (a.prototype !== b.prototype) return false;
  1810. //~~~I've managed to break Object.keys through screwy arguments passing.
  1811. // Converting to array solves the problem.
  1812. if (isArguments(a)) {
  1813. if (!isArguments(b)) {
  1814. return false;
  1815. }
  1816. a = pSlice.call(a);
  1817. b = pSlice.call(b);
  1818. return deepEqual(a, b, opts);
  1819. }
  1820. if (isBuffer(a)) {
  1821. if (!isBuffer(b)) {
  1822. return false;
  1823. }
  1824. if (a.length !== b.length) return false;
  1825. for (i = 0; i < a.length; i++) {
  1826. if (a[i] !== b[i]) return false;
  1827. }
  1828. return true;
  1829. }
  1830. try {
  1831. var ka = objectKeys(a),
  1832. kb = objectKeys(b);
  1833. } catch (e) {//happens when one is a string literal and the other isn't
  1834. return false;
  1835. }
  1836. // having the same number of owned properties (keys incorporates
  1837. // hasOwnProperty)
  1838. if (ka.length != kb.length)
  1839. return false;
  1840. //the same set of keys (although not necessarily the same order),
  1841. ka.sort();
  1842. kb.sort();
  1843. //~~~cheap key test
  1844. for (i = ka.length - 1; i >= 0; i--) {
  1845. if (ka[i] != kb[i])
  1846. return false;
  1847. }
  1848. //equivalent values for every corresponding key, and
  1849. //~~~possibly expensive deep test
  1850. for (i = ka.length - 1; i >= 0; i--) {
  1851. key = ka[i];
  1852. if (!deepEqual(a[key], b[key], opts)) return false;
  1853. }
  1854. return typeof a === typeof b;
  1855. }
  1856. /***/ }),
  1857. /* 12 */
  1858. /***/ (function(module, exports, __webpack_require__) {
  1859. "use strict";
  1860. Object.defineProperty(exports, "__esModule", { value: true });
  1861. var Registry = __webpack_require__(1);
  1862. var Attributor = /** @class */ (function () {
  1863. function Attributor(attrName, keyName, options) {
  1864. if (options === void 0) { options = {}; }
  1865. this.attrName = attrName;
  1866. this.keyName = keyName;
  1867. var attributeBit = Registry.Scope.TYPE & Registry.Scope.ATTRIBUTE;
  1868. if (options.scope != null) {
  1869. // Ignore type bits, force attribute bit
  1870. this.scope = (options.scope & Registry.Scope.LEVEL) | attributeBit;
  1871. }
  1872. else {
  1873. this.scope = Registry.Scope.ATTRIBUTE;
  1874. }
  1875. if (options.whitelist != null)
  1876. this.whitelist = options.whitelist;
  1877. }
  1878. Attributor.keys = function (node) {
  1879. return [].map.call(node.attributes, function (item) {
  1880. return item.name;
  1881. });
  1882. };
  1883. Attributor.prototype.add = function (node, value) {
  1884. if (!this.canAdd(node, value))
  1885. return false;
  1886. node.setAttribute(this.keyName, value);
  1887. return true;
  1888. };
  1889. Attributor.prototype.canAdd = function (node, value) {
  1890. var match = Registry.query(node, Registry.Scope.BLOT & (this.scope | Registry.Scope.TYPE));
  1891. if (match == null)
  1892. return false;
  1893. if (this.whitelist == null)
  1894. return true;
  1895. if (typeof value === 'string') {
  1896. return this.whitelist.indexOf(value.replace(/["']/g, '')) > -1;
  1897. }
  1898. else {
  1899. return this.whitelist.indexOf(value) > -1;
  1900. }
  1901. };
  1902. Attributor.prototype.remove = function (node) {
  1903. node.removeAttribute(this.keyName);
  1904. };
  1905. Attributor.prototype.value = function (node) {
  1906. var value = node.getAttribute(this.keyName);
  1907. if (this.canAdd(node, value) && value) {
  1908. return value;
  1909. }
  1910. return '';
  1911. };
  1912. return Attributor;
  1913. }());
  1914. exports.default = Attributor;
  1915. /***/ }),
  1916. /* 13 */
  1917. /***/ (function(module, exports, __webpack_require__) {
  1918. "use strict";
  1919. Object.defineProperty(exports, "__esModule", {
  1920. value: true
  1921. });
  1922. exports.default = exports.Code = undefined;
  1923. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  1924. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1925. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  1926. var _quillDelta = __webpack_require__(2);
  1927. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  1928. var _parchment = __webpack_require__(0);
  1929. var _parchment2 = _interopRequireDefault(_parchment);
  1930. var _block = __webpack_require__(4);
  1931. var _block2 = _interopRequireDefault(_block);
  1932. var _inline = __webpack_require__(6);
  1933. var _inline2 = _interopRequireDefault(_inline);
  1934. var _text = __webpack_require__(7);
  1935. var _text2 = _interopRequireDefault(_text);
  1936. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1937. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1938. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1939. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1940. var Code = function (_Inline) {
  1941. _inherits(Code, _Inline);
  1942. function Code() {
  1943. _classCallCheck(this, Code);
  1944. return _possibleConstructorReturn(this, (Code.__proto__ || Object.getPrototypeOf(Code)).apply(this, arguments));
  1945. }
  1946. return Code;
  1947. }(_inline2.default);
  1948. Code.blotName = 'code';
  1949. Code.tagName = 'CODE';
  1950. var CodeBlock = function (_Block) {
  1951. _inherits(CodeBlock, _Block);
  1952. function CodeBlock() {
  1953. _classCallCheck(this, CodeBlock);
  1954. return _possibleConstructorReturn(this, (CodeBlock.__proto__ || Object.getPrototypeOf(CodeBlock)).apply(this, arguments));
  1955. }
  1956. _createClass(CodeBlock, [{
  1957. key: 'delta',
  1958. value: function delta() {
  1959. var _this3 = this;
  1960. var text = this.domNode.textContent;
  1961. if (text.endsWith('\n')) {
  1962. // Should always be true
  1963. text = text.slice(0, -1);
  1964. }
  1965. return text.split('\n').reduce(function (delta, frag) {
  1966. return delta.insert(frag).insert('\n', _this3.formats());
  1967. }, new _quillDelta2.default());
  1968. }
  1969. }, {
  1970. key: 'format',
  1971. value: function format(name, value) {
  1972. if (name === this.statics.blotName && value) return;
  1973. var _descendant = this.descendant(_text2.default, this.length() - 1),
  1974. _descendant2 = _slicedToArray(_descendant, 1),
  1975. text = _descendant2[0];
  1976. if (text != null) {
  1977. text.deleteAt(text.length() - 1, 1);
  1978. }
  1979. _get(CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), 'format', this).call(this, name, value);
  1980. }
  1981. }, {
  1982. key: 'formatAt',
  1983. value: function formatAt(index, length, name, value) {
  1984. if (length === 0) return;
  1985. if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK) == null || name === this.statics.blotName && value === this.statics.formats(this.domNode)) {
  1986. return;
  1987. }
  1988. var nextNewline = this.newlineIndex(index);
  1989. if (nextNewline < 0 || nextNewline >= index + length) return;
  1990. var prevNewline = this.newlineIndex(index, true) + 1;
  1991. var isolateLength = nextNewline - prevNewline + 1;
  1992. var blot = this.isolate(prevNewline, isolateLength);
  1993. var next = blot.next;
  1994. blot.format(name, value);
  1995. if (next instanceof CodeBlock) {
  1996. next.formatAt(0, index - prevNewline + length - isolateLength, name, value);
  1997. }
  1998. }
  1999. }, {
  2000. key: 'insertAt',
  2001. value: function insertAt(index, value, def) {
  2002. if (def != null) return;
  2003. var _descendant3 = this.descendant(_text2.default, index),
  2004. _descendant4 = _slicedToArray(_descendant3, 2),
  2005. text = _descendant4[0],
  2006. offset = _descendant4[1];
  2007. text.insertAt(offset, value);
  2008. }
  2009. }, {
  2010. key: 'length',
  2011. value: function length() {
  2012. var length = this.domNode.textContent.length;
  2013. if (!this.domNode.textContent.endsWith('\n')) {
  2014. return length + 1;
  2015. }
  2016. return length;
  2017. }
  2018. }, {
  2019. key: 'newlineIndex',
  2020. value: function newlineIndex(searchIndex) {
  2021. var reverse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2022. if (!reverse) {
  2023. var offset = this.domNode.textContent.slice(searchIndex).indexOf('\n');
  2024. return offset > -1 ? searchIndex + offset : -1;
  2025. } else {
  2026. return this.domNode.textContent.slice(0, searchIndex).lastIndexOf('\n');
  2027. }
  2028. }
  2029. }, {
  2030. key: 'optimize',
  2031. value: function optimize(context) {
  2032. if (!this.domNode.textContent.endsWith('\n')) {
  2033. this.appendChild(_parchment2.default.create('text', '\n'));
  2034. }
  2035. _get(CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), 'optimize', this).call(this, context);
  2036. var next = this.next;
  2037. if (next != null && next.prev === this && next.statics.blotName === this.statics.blotName && this.statics.formats(this.domNode) === next.statics.formats(next.domNode)) {
  2038. next.optimize(context);
  2039. next.moveChildren(this);
  2040. next.remove();
  2041. }
  2042. }
  2043. }, {
  2044. key: 'replace',
  2045. value: function replace(target) {
  2046. _get(CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), 'replace', this).call(this, target);
  2047. [].slice.call(this.domNode.querySelectorAll('*')).forEach(function (node) {
  2048. var blot = _parchment2.default.find(node);
  2049. if (blot == null) {
  2050. node.parentNode.removeChild(node);
  2051. } else if (blot instanceof _parchment2.default.Embed) {
  2052. blot.remove();
  2053. } else {
  2054. blot.unwrap();
  2055. }
  2056. });
  2057. }
  2058. }], [{
  2059. key: 'create',
  2060. value: function create(value) {
  2061. var domNode = _get(CodeBlock.__proto__ || Object.getPrototypeOf(CodeBlock), 'create', this).call(this, value);
  2062. domNode.setAttribute('spellcheck', false);
  2063. return domNode;
  2064. }
  2065. }, {
  2066. key: 'formats',
  2067. value: function formats() {
  2068. return true;
  2069. }
  2070. }]);
  2071. return CodeBlock;
  2072. }(_block2.default);
  2073. CodeBlock.blotName = 'code-block';
  2074. CodeBlock.tagName = 'PRE';
  2075. CodeBlock.TAB = ' ';
  2076. exports.Code = Code;
  2077. exports.default = CodeBlock;
  2078. /***/ }),
  2079. /* 14 */
  2080. /***/ (function(module, exports, __webpack_require__) {
  2081. "use strict";
  2082. Object.defineProperty(exports, "__esModule", {
  2083. value: true
  2084. });
  2085. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  2086. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  2087. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2088. var _quillDelta = __webpack_require__(2);
  2089. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  2090. var _op = __webpack_require__(20);
  2091. var _op2 = _interopRequireDefault(_op);
  2092. var _parchment = __webpack_require__(0);
  2093. var _parchment2 = _interopRequireDefault(_parchment);
  2094. var _code = __webpack_require__(13);
  2095. var _code2 = _interopRequireDefault(_code);
  2096. var _cursor = __webpack_require__(24);
  2097. var _cursor2 = _interopRequireDefault(_cursor);
  2098. var _block = __webpack_require__(4);
  2099. var _block2 = _interopRequireDefault(_block);
  2100. var _break = __webpack_require__(16);
  2101. var _break2 = _interopRequireDefault(_break);
  2102. var _clone = __webpack_require__(21);
  2103. var _clone2 = _interopRequireDefault(_clone);
  2104. var _deepEqual = __webpack_require__(11);
  2105. var _deepEqual2 = _interopRequireDefault(_deepEqual);
  2106. var _extend = __webpack_require__(3);
  2107. var _extend2 = _interopRequireDefault(_extend);
  2108. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2109. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  2110. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2111. var ASCII = /^[ -~]*$/;
  2112. var Editor = function () {
  2113. function Editor(scroll) {
  2114. _classCallCheck(this, Editor);
  2115. this.scroll = scroll;
  2116. this.delta = this.getDelta();
  2117. }
  2118. _createClass(Editor, [{
  2119. key: 'applyDelta',
  2120. value: function applyDelta(delta) {
  2121. var _this = this;
  2122. var consumeNextNewline = false;
  2123. this.scroll.update();
  2124. var scrollLength = this.scroll.length();
  2125. this.scroll.batchStart();
  2126. delta = normalizeDelta(delta);
  2127. delta.reduce(function (index, op) {
  2128. var length = op.retain || op.delete || op.insert.length || 1;
  2129. var attributes = op.attributes || {};
  2130. if (op.insert != null) {
  2131. if (typeof op.insert === 'string') {
  2132. var text = op.insert;
  2133. if (text.endsWith('\n') && consumeNextNewline) {
  2134. consumeNextNewline = false;
  2135. text = text.slice(0, -1);
  2136. }
  2137. if (index >= scrollLength && !text.endsWith('\n')) {
  2138. consumeNextNewline = true;
  2139. }
  2140. _this.scroll.insertAt(index, text);
  2141. var _scroll$line = _this.scroll.line(index),
  2142. _scroll$line2 = _slicedToArray(_scroll$line, 2),
  2143. line = _scroll$line2[0],
  2144. offset = _scroll$line2[1];
  2145. var formats = (0, _extend2.default)({}, (0, _block.bubbleFormats)(line));
  2146. if (line instanceof _block2.default) {
  2147. var _line$descendant = line.descendant(_parchment2.default.Leaf, offset),
  2148. _line$descendant2 = _slicedToArray(_line$descendant, 1),
  2149. leaf = _line$descendant2[0];
  2150. formats = (0, _extend2.default)(formats, (0, _block.bubbleFormats)(leaf));
  2151. }
  2152. attributes = _op2.default.attributes.diff(formats, attributes) || {};
  2153. } else if (_typeof(op.insert) === 'object') {
  2154. var key = Object.keys(op.insert)[0]; // There should only be one key
  2155. if (key == null) return index;
  2156. _this.scroll.insertAt(index, key, op.insert[key]);
  2157. }
  2158. scrollLength += length;
  2159. }
  2160. Object.keys(attributes).forEach(function (name) {
  2161. _this.scroll.formatAt(index, length, name, attributes[name]);
  2162. });
  2163. return index + length;
  2164. }, 0);
  2165. delta.reduce(function (index, op) {
  2166. if (typeof op.delete === 'number') {
  2167. _this.scroll.deleteAt(index, op.delete);
  2168. return index;
  2169. }
  2170. return index + (op.retain || op.insert.length || 1);
  2171. }, 0);
  2172. this.scroll.batchEnd();
  2173. return this.update(delta);
  2174. }
  2175. }, {
  2176. key: 'deleteText',
  2177. value: function deleteText(index, length) {
  2178. this.scroll.deleteAt(index, length);
  2179. return this.update(new _quillDelta2.default().retain(index).delete(length));
  2180. }
  2181. }, {
  2182. key: 'formatLine',
  2183. value: function formatLine(index, length) {
  2184. var _this2 = this;
  2185. var formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  2186. this.scroll.update();
  2187. Object.keys(formats).forEach(function (format) {
  2188. if (_this2.scroll.whitelist != null && !_this2.scroll.whitelist[format]) return;
  2189. var lines = _this2.scroll.lines(index, Math.max(length, 1));
  2190. var lengthRemaining = length;
  2191. lines.forEach(function (line) {
  2192. var lineLength = line.length();
  2193. if (!(line instanceof _code2.default)) {
  2194. line.format(format, formats[format]);
  2195. } else {
  2196. var codeIndex = index - line.offset(_this2.scroll);
  2197. var codeLength = line.newlineIndex(codeIndex + lengthRemaining) - codeIndex + 1;
  2198. line.formatAt(codeIndex, codeLength, format, formats[format]);
  2199. }
  2200. lengthRemaining -= lineLength;
  2201. });
  2202. });
  2203. this.scroll.optimize();
  2204. return this.update(new _quillDelta2.default().retain(index).retain(length, (0, _clone2.default)(formats)));
  2205. }
  2206. }, {
  2207. key: 'formatText',
  2208. value: function formatText(index, length) {
  2209. var _this3 = this;
  2210. var formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  2211. Object.keys(formats).forEach(function (format) {
  2212. _this3.scroll.formatAt(index, length, format, formats[format]);
  2213. });
  2214. return this.update(new _quillDelta2.default().retain(index).retain(length, (0, _clone2.default)(formats)));
  2215. }
  2216. }, {
  2217. key: 'getContents',
  2218. value: function getContents(index, length) {
  2219. return this.delta.slice(index, index + length);
  2220. }
  2221. }, {
  2222. key: 'getDelta',
  2223. value: function getDelta() {
  2224. return this.scroll.lines().reduce(function (delta, line) {
  2225. return delta.concat(line.delta());
  2226. }, new _quillDelta2.default());
  2227. }
  2228. }, {
  2229. key: 'getFormat',
  2230. value: function getFormat(index) {
  2231. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  2232. var lines = [],
  2233. leaves = [];
  2234. if (length === 0) {
  2235. this.scroll.path(index).forEach(function (path) {
  2236. var _path = _slicedToArray(path, 1),
  2237. blot = _path[0];
  2238. if (blot instanceof _block2.default) {
  2239. lines.push(blot);
  2240. } else if (blot instanceof _parchment2.default.Leaf) {
  2241. leaves.push(blot);
  2242. }
  2243. });
  2244. } else {
  2245. lines = this.scroll.lines(index, length);
  2246. leaves = this.scroll.descendants(_parchment2.default.Leaf, index, length);
  2247. }
  2248. var formatsArr = [lines, leaves].map(function (blots) {
  2249. if (blots.length === 0) return {};
  2250. var formats = (0, _block.bubbleFormats)(blots.shift());
  2251. while (Object.keys(formats).length > 0) {
  2252. var blot = blots.shift();
  2253. if (blot == null) return formats;
  2254. formats = combineFormats((0, _block.bubbleFormats)(blot), formats);
  2255. }
  2256. return formats;
  2257. });
  2258. return _extend2.default.apply(_extend2.default, formatsArr);
  2259. }
  2260. }, {
  2261. key: 'getText',
  2262. value: function getText(index, length) {
  2263. return this.getContents(index, length).filter(function (op) {
  2264. return typeof op.insert === 'string';
  2265. }).map(function (op) {
  2266. return op.insert;
  2267. }).join('');
  2268. }
  2269. }, {
  2270. key: 'insertEmbed',
  2271. value: function insertEmbed(index, embed, value) {
  2272. this.scroll.insertAt(index, embed, value);
  2273. return this.update(new _quillDelta2.default().retain(index).insert(_defineProperty({}, embed, value)));
  2274. }
  2275. }, {
  2276. key: 'insertText',
  2277. value: function insertText(index, text) {
  2278. var _this4 = this;
  2279. var formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  2280. text = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
  2281. this.scroll.insertAt(index, text);
  2282. Object.keys(formats).forEach(function (format) {
  2283. _this4.scroll.formatAt(index, text.length, format, formats[format]);
  2284. });
  2285. return this.update(new _quillDelta2.default().retain(index).insert(text, (0, _clone2.default)(formats)));
  2286. }
  2287. }, {
  2288. key: 'isBlank',
  2289. value: function isBlank() {
  2290. if (this.scroll.children.length == 0) return true;
  2291. if (this.scroll.children.length > 1) return false;
  2292. var block = this.scroll.children.head;
  2293. if (block.statics.blotName !== _block2.default.blotName) return false;
  2294. if (block.children.length > 1) return false;
  2295. return block.children.head instanceof _break2.default;
  2296. }
  2297. }, {
  2298. key: 'removeFormat',
  2299. value: function removeFormat(index, length) {
  2300. var text = this.getText(index, length);
  2301. var _scroll$line3 = this.scroll.line(index + length),
  2302. _scroll$line4 = _slicedToArray(_scroll$line3, 2),
  2303. line = _scroll$line4[0],
  2304. offset = _scroll$line4[1];
  2305. var suffixLength = 0,
  2306. suffix = new _quillDelta2.default();
  2307. if (line != null) {
  2308. if (!(line instanceof _code2.default)) {
  2309. suffixLength = line.length() - offset;
  2310. } else {
  2311. suffixLength = line.newlineIndex(offset) - offset + 1;
  2312. }
  2313. suffix = line.delta().slice(offset, offset + suffixLength - 1).insert('\n');
  2314. }
  2315. var contents = this.getContents(index, length + suffixLength);
  2316. var diff = contents.diff(new _quillDelta2.default().insert(text).concat(suffix));
  2317. var delta = new _quillDelta2.default().retain(index).concat(diff);
  2318. return this.applyDelta(delta);
  2319. }
  2320. }, {
  2321. key: 'update',
  2322. value: function update(change) {
  2323. var mutations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  2324. var cursorIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
  2325. var oldDelta = this.delta;
  2326. if (mutations.length === 1 && mutations[0].type === 'characterData' && mutations[0].target.data.match(ASCII) && _parchment2.default.find(mutations[0].target)) {
  2327. // Optimization for character changes
  2328. var textBlot = _parchment2.default.find(mutations[0].target);
  2329. var formats = (0, _block.bubbleFormats)(textBlot);
  2330. var index = textBlot.offset(this.scroll);
  2331. var oldValue = mutations[0].oldValue.replace(_cursor2.default.CONTENTS, '');
  2332. var oldText = new _quillDelta2.default().insert(oldValue);
  2333. var newText = new _quillDelta2.default().insert(textBlot.value());
  2334. var diffDelta = new _quillDelta2.default().retain(index).concat(oldText.diff(newText, cursorIndex));
  2335. change = diffDelta.reduce(function (delta, op) {
  2336. if (op.insert) {
  2337. return delta.insert(op.insert, formats);
  2338. } else {
  2339. return delta.push(op);
  2340. }
  2341. }, new _quillDelta2.default());
  2342. this.delta = oldDelta.compose(change);
  2343. } else {
  2344. this.delta = this.getDelta();
  2345. if (!change || !(0, _deepEqual2.default)(oldDelta.compose(change), this.delta)) {
  2346. change = oldDelta.diff(this.delta, cursorIndex);
  2347. }
  2348. }
  2349. return change;
  2350. }
  2351. }]);
  2352. return Editor;
  2353. }();
  2354. function combineFormats(formats, combined) {
  2355. return Object.keys(combined).reduce(function (merged, name) {
  2356. if (formats[name] == null) return merged;
  2357. if (combined[name] === formats[name]) {
  2358. merged[name] = combined[name];
  2359. } else if (Array.isArray(combined[name])) {
  2360. if (combined[name].indexOf(formats[name]) < 0) {
  2361. merged[name] = combined[name].concat([formats[name]]);
  2362. }
  2363. } else {
  2364. merged[name] = [combined[name], formats[name]];
  2365. }
  2366. return merged;
  2367. }, {});
  2368. }
  2369. function normalizeDelta(delta) {
  2370. return delta.reduce(function (delta, op) {
  2371. if (op.insert === 1) {
  2372. var attributes = (0, _clone2.default)(op.attributes);
  2373. delete attributes['image'];
  2374. return delta.insert({ image: op.attributes.image }, attributes);
  2375. }
  2376. if (op.attributes != null && (op.attributes.list === true || op.attributes.bullet === true)) {
  2377. op = (0, _clone2.default)(op);
  2378. if (op.attributes.list) {
  2379. op.attributes.list = 'ordered';
  2380. } else {
  2381. op.attributes.list = 'bullet';
  2382. delete op.attributes.bullet;
  2383. }
  2384. }
  2385. if (typeof op.insert === 'string') {
  2386. var text = op.insert.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
  2387. return delta.insert(text, op.attributes);
  2388. }
  2389. return delta.push(op);
  2390. }, new _quillDelta2.default());
  2391. }
  2392. exports.default = Editor;
  2393. /***/ }),
  2394. /* 15 */
  2395. /***/ (function(module, exports, __webpack_require__) {
  2396. "use strict";
  2397. Object.defineProperty(exports, "__esModule", {
  2398. value: true
  2399. });
  2400. exports.default = exports.Range = undefined;
  2401. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  2402. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2403. var _parchment = __webpack_require__(0);
  2404. var _parchment2 = _interopRequireDefault(_parchment);
  2405. var _clone = __webpack_require__(21);
  2406. var _clone2 = _interopRequireDefault(_clone);
  2407. var _deepEqual = __webpack_require__(11);
  2408. var _deepEqual2 = _interopRequireDefault(_deepEqual);
  2409. var _emitter3 = __webpack_require__(8);
  2410. var _emitter4 = _interopRequireDefault(_emitter3);
  2411. var _logger = __webpack_require__(10);
  2412. var _logger2 = _interopRequireDefault(_logger);
  2413. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2414. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  2415. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2416. var debug = (0, _logger2.default)('quill:selection');
  2417. var Range = function Range(index) {
  2418. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  2419. _classCallCheck(this, Range);
  2420. this.index = index;
  2421. this.length = length;
  2422. };
  2423. var Selection = function () {
  2424. function Selection(scroll, emitter) {
  2425. var _this = this;
  2426. _classCallCheck(this, Selection);
  2427. this.emitter = emitter;
  2428. this.scroll = scroll;
  2429. this.composing = false;
  2430. this.mouseDown = false;
  2431. this.root = this.scroll.domNode;
  2432. this.cursor = _parchment2.default.create('cursor', this);
  2433. // savedRange is last non-null range
  2434. this.lastRange = this.savedRange = new Range(0, 0);
  2435. this.handleComposition();
  2436. this.handleDragging();
  2437. this.emitter.listenDOM('selectionchange', document, function () {
  2438. if (!_this.mouseDown) {
  2439. setTimeout(_this.update.bind(_this, _emitter4.default.sources.USER), 1);
  2440. }
  2441. });
  2442. this.emitter.on(_emitter4.default.events.EDITOR_CHANGE, function (type, delta) {
  2443. if (type === _emitter4.default.events.TEXT_CHANGE && delta.length() > 0) {
  2444. _this.update(_emitter4.default.sources.SILENT);
  2445. }
  2446. });
  2447. this.emitter.on(_emitter4.default.events.SCROLL_BEFORE_UPDATE, function () {
  2448. if (!_this.hasFocus()) return;
  2449. var native = _this.getNativeRange();
  2450. if (native == null) return;
  2451. if (native.start.node === _this.cursor.textNode) return; // cursor.restore() will handle
  2452. // TODO unclear if this has negative side effects
  2453. _this.emitter.once(_emitter4.default.events.SCROLL_UPDATE, function () {
  2454. try {
  2455. _this.setNativeRange(native.start.node, native.start.offset, native.end.node, native.end.offset);
  2456. } catch (ignored) {}
  2457. });
  2458. });
  2459. this.emitter.on(_emitter4.default.events.SCROLL_OPTIMIZE, function (mutations, context) {
  2460. if (context.range) {
  2461. var _context$range = context.range,
  2462. startNode = _context$range.startNode,
  2463. startOffset = _context$range.startOffset,
  2464. endNode = _context$range.endNode,
  2465. endOffset = _context$range.endOffset;
  2466. _this.setNativeRange(startNode, startOffset, endNode, endOffset);
  2467. }
  2468. });
  2469. this.update(_emitter4.default.sources.SILENT);
  2470. }
  2471. _createClass(Selection, [{
  2472. key: 'handleComposition',
  2473. value: function handleComposition() {
  2474. var _this2 = this;
  2475. this.root.addEventListener('compositionstart', function () {
  2476. _this2.composing = true;
  2477. });
  2478. this.root.addEventListener('compositionend', function () {
  2479. _this2.composing = false;
  2480. if (_this2.cursor.parent) {
  2481. var range = _this2.cursor.restore();
  2482. if (!range) return;
  2483. setTimeout(function () {
  2484. _this2.setNativeRange(range.startNode, range.startOffset, range.endNode, range.endOffset);
  2485. }, 1);
  2486. }
  2487. });
  2488. }
  2489. }, {
  2490. key: 'handleDragging',
  2491. value: function handleDragging() {
  2492. var _this3 = this;
  2493. this.emitter.listenDOM('mousedown', document.body, function () {
  2494. _this3.mouseDown = true;
  2495. });
  2496. this.emitter.listenDOM('mouseup', document.body, function () {
  2497. _this3.mouseDown = false;
  2498. _this3.update(_emitter4.default.sources.USER);
  2499. });
  2500. }
  2501. }, {
  2502. key: 'focus',
  2503. value: function focus() {
  2504. if (this.hasFocus()) return;
  2505. this.root.focus();
  2506. this.setRange(this.savedRange);
  2507. }
  2508. }, {
  2509. key: 'format',
  2510. value: function format(_format, value) {
  2511. if (this.scroll.whitelist != null && !this.scroll.whitelist[_format]) return;
  2512. this.scroll.update();
  2513. var nativeRange = this.getNativeRange();
  2514. if (nativeRange == null || !nativeRange.native.collapsed || _parchment2.default.query(_format, _parchment2.default.Scope.BLOCK)) return;
  2515. if (nativeRange.start.node !== this.cursor.textNode) {
  2516. var blot = _parchment2.default.find(nativeRange.start.node, false);
  2517. if (blot == null) return;
  2518. // TODO Give blot ability to not split
  2519. if (blot instanceof _parchment2.default.Leaf) {
  2520. var after = blot.split(nativeRange.start.offset);
  2521. blot.parent.insertBefore(this.cursor, after);
  2522. } else {
  2523. blot.insertBefore(this.cursor, nativeRange.start.node); // Should never happen
  2524. }
  2525. this.cursor.attach();
  2526. }
  2527. this.cursor.format(_format, value);
  2528. this.scroll.optimize();
  2529. this.setNativeRange(this.cursor.textNode, this.cursor.textNode.data.length);
  2530. this.update();
  2531. }
  2532. }, {
  2533. key: 'getBounds',
  2534. value: function getBounds(index) {
  2535. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  2536. var scrollLength = this.scroll.length();
  2537. index = Math.min(index, scrollLength - 1);
  2538. length = Math.min(index + length, scrollLength - 1) - index;
  2539. var node = void 0,
  2540. _scroll$leaf = this.scroll.leaf(index),
  2541. _scroll$leaf2 = _slicedToArray(_scroll$leaf, 2),
  2542. leaf = _scroll$leaf2[0],
  2543. offset = _scroll$leaf2[1];
  2544. if (leaf == null) return null;
  2545. var _leaf$position = leaf.position(offset, true);
  2546. var _leaf$position2 = _slicedToArray(_leaf$position, 2);
  2547. node = _leaf$position2[0];
  2548. offset = _leaf$position2[1];
  2549. var range = document.createRange();
  2550. if (length > 0) {
  2551. range.setStart(node, offset);
  2552. var _scroll$leaf3 = this.scroll.leaf(index + length);
  2553. var _scroll$leaf4 = _slicedToArray(_scroll$leaf3, 2);
  2554. leaf = _scroll$leaf4[0];
  2555. offset = _scroll$leaf4[1];
  2556. if (leaf == null) return null;
  2557. var _leaf$position3 = leaf.position(offset, true);
  2558. var _leaf$position4 = _slicedToArray(_leaf$position3, 2);
  2559. node = _leaf$position4[0];
  2560. offset = _leaf$position4[1];
  2561. range.setEnd(node, offset);
  2562. return range.getBoundingClientRect();
  2563. } else {
  2564. var side = 'left';
  2565. var rect = void 0;
  2566. if (node instanceof Text) {
  2567. if (offset < node.data.length) {
  2568. range.setStart(node, offset);
  2569. range.setEnd(node, offset + 1);
  2570. } else {
  2571. range.setStart(node, offset - 1);
  2572. range.setEnd(node, offset);
  2573. side = 'right';
  2574. }
  2575. rect = range.getBoundingClientRect();
  2576. } else {
  2577. rect = leaf.domNode.getBoundingClientRect();
  2578. if (offset > 0) side = 'right';
  2579. }
  2580. return {
  2581. bottom: rect.top + rect.height,
  2582. height: rect.height,
  2583. left: rect[side],
  2584. right: rect[side],
  2585. top: rect.top,
  2586. width: 0
  2587. };
  2588. }
  2589. }
  2590. }, {
  2591. key: 'getNativeRange',
  2592. value: function getNativeRange() {
  2593. var selection = document.getSelection();
  2594. if (selection == null || selection.rangeCount <= 0) return null;
  2595. var nativeRange = selection.getRangeAt(0);
  2596. if (nativeRange == null) return null;
  2597. var range = this.normalizeNative(nativeRange);
  2598. debug.info('getNativeRange', range);
  2599. return range;
  2600. }
  2601. }, {
  2602. key: 'getRange',
  2603. value: function getRange() {
  2604. var normalized = this.getNativeRange();
  2605. if (normalized == null) return [null, null];
  2606. var range = this.normalizedToRange(normalized);
  2607. return [range, normalized];
  2608. }
  2609. }, {
  2610. key: 'hasFocus',
  2611. value: function hasFocus() {
  2612. return document.activeElement === this.root;
  2613. }
  2614. }, {
  2615. key: 'normalizedToRange',
  2616. value: function normalizedToRange(range) {
  2617. var _this4 = this;
  2618. var positions = [[range.start.node, range.start.offset]];
  2619. if (!range.native.collapsed) {
  2620. positions.push([range.end.node, range.end.offset]);
  2621. }
  2622. var indexes = positions.map(function (position) {
  2623. var _position = _slicedToArray(position, 2),
  2624. node = _position[0],
  2625. offset = _position[1];
  2626. var blot = _parchment2.default.find(node, true);
  2627. var index = blot.offset(_this4.scroll);
  2628. if (offset === 0) {
  2629. return index;
  2630. } else if (blot instanceof _parchment2.default.Container) {
  2631. return index + blot.length();
  2632. } else {
  2633. return index + blot.index(node, offset);
  2634. }
  2635. });
  2636. var end = Math.min(Math.max.apply(Math, _toConsumableArray(indexes)), this.scroll.length() - 1);
  2637. var start = Math.min.apply(Math, [end].concat(_toConsumableArray(indexes)));
  2638. return new Range(start, end - start);
  2639. }
  2640. }, {
  2641. key: 'normalizeNative',
  2642. value: function normalizeNative(nativeRange) {
  2643. if (!contains(this.root, nativeRange.startContainer) || !nativeRange.collapsed && !contains(this.root, nativeRange.endContainer)) {
  2644. return null;
  2645. }
  2646. var range = {
  2647. start: { node: nativeRange.startContainer, offset: nativeRange.startOffset },
  2648. end: { node: nativeRange.endContainer, offset: nativeRange.endOffset },
  2649. native: nativeRange
  2650. };
  2651. [range.start, range.end].forEach(function (position) {
  2652. var node = position.node,
  2653. offset = position.offset;
  2654. while (!(node instanceof Text) && node.childNodes.length > 0) {
  2655. if (node.childNodes.length > offset) {
  2656. node = node.childNodes[offset];
  2657. offset = 0;
  2658. } else if (node.childNodes.length === offset) {
  2659. node = node.lastChild;
  2660. offset = node instanceof Text ? node.data.length : node.childNodes.length + 1;
  2661. } else {
  2662. break;
  2663. }
  2664. }
  2665. position.node = node, position.offset = offset;
  2666. });
  2667. return range;
  2668. }
  2669. }, {
  2670. key: 'rangeToNative',
  2671. value: function rangeToNative(range) {
  2672. var _this5 = this;
  2673. var indexes = range.collapsed ? [range.index] : [range.index, range.index + range.length];
  2674. var args = [];
  2675. var scrollLength = this.scroll.length();
  2676. indexes.forEach(function (index, i) {
  2677. index = Math.min(scrollLength - 1, index);
  2678. var node = void 0,
  2679. _scroll$leaf5 = _this5.scroll.leaf(index),
  2680. _scroll$leaf6 = _slicedToArray(_scroll$leaf5, 2),
  2681. leaf = _scroll$leaf6[0],
  2682. offset = _scroll$leaf6[1];
  2683. var _leaf$position5 = leaf.position(offset, i !== 0);
  2684. var _leaf$position6 = _slicedToArray(_leaf$position5, 2);
  2685. node = _leaf$position6[0];
  2686. offset = _leaf$position6[1];
  2687. args.push(node, offset);
  2688. });
  2689. if (args.length < 2) {
  2690. args = args.concat(args);
  2691. }
  2692. return args;
  2693. }
  2694. }, {
  2695. key: 'scrollIntoView',
  2696. value: function scrollIntoView(scrollingContainer) {
  2697. var range = this.lastRange;
  2698. if (range == null) return;
  2699. var bounds = this.getBounds(range.index, range.length);
  2700. if (bounds == null) return;
  2701. var limit = this.scroll.length() - 1;
  2702. var _scroll$line = this.scroll.line(Math.min(range.index, limit)),
  2703. _scroll$line2 = _slicedToArray(_scroll$line, 1),
  2704. first = _scroll$line2[0];
  2705. var last = first;
  2706. if (range.length > 0) {
  2707. var _scroll$line3 = this.scroll.line(Math.min(range.index + range.length, limit));
  2708. var _scroll$line4 = _slicedToArray(_scroll$line3, 1);
  2709. last = _scroll$line4[0];
  2710. }
  2711. if (first == null || last == null) return;
  2712. var scrollBounds = scrollingContainer.getBoundingClientRect();
  2713. if (bounds.top < scrollBounds.top) {
  2714. scrollingContainer.scrollTop -= scrollBounds.top - bounds.top;
  2715. } else if (bounds.bottom > scrollBounds.bottom) {
  2716. scrollingContainer.scrollTop += bounds.bottom - scrollBounds.bottom;
  2717. }
  2718. }
  2719. }, {
  2720. key: 'setNativeRange',
  2721. value: function setNativeRange(startNode, startOffset) {
  2722. var endNode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : startNode;
  2723. var endOffset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : startOffset;
  2724. var force = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  2725. debug.info('setNativeRange', startNode, startOffset, endNode, endOffset);
  2726. if (startNode != null && (this.root.parentNode == null || startNode.parentNode == null || endNode.parentNode == null)) {
  2727. return;
  2728. }
  2729. var selection = document.getSelection();
  2730. if (selection == null) return;
  2731. if (startNode != null) {
  2732. if (!this.hasFocus()) this.root.focus();
  2733. var native = (this.getNativeRange() || {}).native;
  2734. if (native == null || force || startNode !== native.startContainer || startOffset !== native.startOffset || endNode !== native.endContainer || endOffset !== native.endOffset) {
  2735. if (startNode.tagName == "BR") {
  2736. startOffset = [].indexOf.call(startNode.parentNode.childNodes, startNode);
  2737. startNode = startNode.parentNode;
  2738. }
  2739. if (endNode.tagName == "BR") {
  2740. endOffset = [].indexOf.call(endNode.parentNode.childNodes, endNode);
  2741. endNode = endNode.parentNode;
  2742. }
  2743. var range = document.createRange();
  2744. range.setStart(startNode, startOffset);
  2745. range.setEnd(endNode, endOffset);
  2746. selection.removeAllRanges();
  2747. selection.addRange(range);
  2748. }
  2749. } else {
  2750. selection.removeAllRanges();
  2751. this.root.blur();
  2752. document.body.focus(); // root.blur() not enough on IE11+Travis+SauceLabs (but not local VMs)
  2753. }
  2754. }
  2755. }, {
  2756. key: 'setRange',
  2757. value: function setRange(range) {
  2758. var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2759. var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _emitter4.default.sources.API;
  2760. if (typeof force === 'string') {
  2761. source = force;
  2762. force = false;
  2763. }
  2764. debug.info('setRange', range);
  2765. if (range != null) {
  2766. var args = this.rangeToNative(range);
  2767. this.setNativeRange.apply(this, _toConsumableArray(args).concat([force]));
  2768. } else {
  2769. this.setNativeRange(null);
  2770. }
  2771. this.update(source);
  2772. }
  2773. }, {
  2774. key: 'update',
  2775. value: function update() {
  2776. var source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _emitter4.default.sources.USER;
  2777. var oldRange = this.lastRange;
  2778. var _getRange = this.getRange(),
  2779. _getRange2 = _slicedToArray(_getRange, 2),
  2780. lastRange = _getRange2[0],
  2781. nativeRange = _getRange2[1];
  2782. this.lastRange = lastRange;
  2783. if (this.lastRange != null) {
  2784. this.savedRange = this.lastRange;
  2785. }
  2786. if (!(0, _deepEqual2.default)(oldRange, this.lastRange)) {
  2787. var _emitter;
  2788. if (!this.composing && nativeRange != null && nativeRange.native.collapsed && nativeRange.start.node !== this.cursor.textNode) {
  2789. this.cursor.restore();
  2790. }
  2791. var args = [_emitter4.default.events.SELECTION_CHANGE, (0, _clone2.default)(this.lastRange), (0, _clone2.default)(oldRange), source];
  2792. (_emitter = this.emitter).emit.apply(_emitter, [_emitter4.default.events.EDITOR_CHANGE].concat(args));
  2793. if (source !== _emitter4.default.sources.SILENT) {
  2794. var _emitter2;
  2795. (_emitter2 = this.emitter).emit.apply(_emitter2, args);
  2796. }
  2797. }
  2798. }
  2799. }]);
  2800. return Selection;
  2801. }();
  2802. function contains(parent, descendant) {
  2803. try {
  2804. // Firefox inserts inaccessible nodes around video elements
  2805. descendant.parentNode;
  2806. } catch (e) {
  2807. return false;
  2808. }
  2809. // IE11 has bug with Text nodes
  2810. // https://connect.microsoft.com/IE/feedback/details/780874/node-contains-is-incorrect
  2811. if (descendant instanceof Text) {
  2812. descendant = descendant.parentNode;
  2813. }
  2814. return parent.contains(descendant);
  2815. }
  2816. exports.Range = Range;
  2817. exports.default = Selection;
  2818. /***/ }),
  2819. /* 16 */
  2820. /***/ (function(module, exports, __webpack_require__) {
  2821. "use strict";
  2822. Object.defineProperty(exports, "__esModule", {
  2823. value: true
  2824. });
  2825. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2826. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  2827. var _parchment = __webpack_require__(0);
  2828. var _parchment2 = _interopRequireDefault(_parchment);
  2829. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2830. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2831. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  2832. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  2833. var Break = function (_Parchment$Embed) {
  2834. _inherits(Break, _Parchment$Embed);
  2835. function Break() {
  2836. _classCallCheck(this, Break);
  2837. return _possibleConstructorReturn(this, (Break.__proto__ || Object.getPrototypeOf(Break)).apply(this, arguments));
  2838. }
  2839. _createClass(Break, [{
  2840. key: 'insertInto',
  2841. value: function insertInto(parent, ref) {
  2842. if (parent.children.length === 0) {
  2843. _get(Break.prototype.__proto__ || Object.getPrototypeOf(Break.prototype), 'insertInto', this).call(this, parent, ref);
  2844. } else {
  2845. this.remove();
  2846. }
  2847. }
  2848. }, {
  2849. key: 'length',
  2850. value: function length() {
  2851. return 0;
  2852. }
  2853. }, {
  2854. key: 'value',
  2855. value: function value() {
  2856. return '';
  2857. }
  2858. }], [{
  2859. key: 'value',
  2860. value: function value() {
  2861. return undefined;
  2862. }
  2863. }]);
  2864. return Break;
  2865. }(_parchment2.default.Embed);
  2866. Break.blotName = 'break';
  2867. Break.tagName = 'BR';
  2868. exports.default = Break;
  2869. /***/ }),
  2870. /* 17 */
  2871. /***/ (function(module, exports, __webpack_require__) {
  2872. "use strict";
  2873. var __extends = (this && this.__extends) || (function () {
  2874. var extendStatics = Object.setPrototypeOf ||
  2875. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2876. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2877. return function (d, b) {
  2878. extendStatics(d, b);
  2879. function __() { this.constructor = d; }
  2880. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2881. };
  2882. })();
  2883. Object.defineProperty(exports, "__esModule", { value: true });
  2884. var linked_list_1 = __webpack_require__(44);
  2885. var shadow_1 = __webpack_require__(30);
  2886. var Registry = __webpack_require__(1);
  2887. var ContainerBlot = /** @class */ (function (_super) {
  2888. __extends(ContainerBlot, _super);
  2889. function ContainerBlot(domNode) {
  2890. var _this = _super.call(this, domNode) || this;
  2891. _this.build();
  2892. return _this;
  2893. }
  2894. ContainerBlot.prototype.appendChild = function (other) {
  2895. this.insertBefore(other);
  2896. };
  2897. ContainerBlot.prototype.attach = function () {
  2898. _super.prototype.attach.call(this);
  2899. this.children.forEach(function (child) {
  2900. child.attach();
  2901. });
  2902. };
  2903. ContainerBlot.prototype.build = function () {
  2904. var _this = this;
  2905. this.children = new linked_list_1.default();
  2906. // Need to be reversed for if DOM nodes already in order
  2907. [].slice
  2908. .call(this.domNode.childNodes)
  2909. .reverse()
  2910. .forEach(function (node) {
  2911. try {
  2912. var child = makeBlot(node);
  2913. _this.insertBefore(child, _this.children.head || undefined);
  2914. }
  2915. catch (err) {
  2916. if (err instanceof Registry.ParchmentError)
  2917. return;
  2918. else
  2919. throw err;
  2920. }
  2921. });
  2922. };
  2923. ContainerBlot.prototype.deleteAt = function (index, length) {
  2924. if (index === 0 && length === this.length()) {
  2925. return this.remove();
  2926. }
  2927. this.children.forEachAt(index, length, function (child, offset, length) {
  2928. child.deleteAt(offset, length);
  2929. });
  2930. };
  2931. ContainerBlot.prototype.descendant = function (criteria, index) {
  2932. var _a = this.children.find(index), child = _a[0], offset = _a[1];
  2933. if ((criteria.blotName == null && criteria(child)) ||
  2934. (criteria.blotName != null && child instanceof criteria)) {
  2935. return [child, offset];
  2936. }
  2937. else if (child instanceof ContainerBlot) {
  2938. return child.descendant(criteria, offset);
  2939. }
  2940. else {
  2941. return [null, -1];
  2942. }
  2943. };
  2944. ContainerBlot.prototype.descendants = function (criteria, index, length) {
  2945. if (index === void 0) { index = 0; }
  2946. if (length === void 0) { length = Number.MAX_VALUE; }
  2947. var descendants = [];
  2948. var lengthLeft = length;
  2949. this.children.forEachAt(index, length, function (child, index, length) {
  2950. if ((criteria.blotName == null && criteria(child)) ||
  2951. (criteria.blotName != null && child instanceof criteria)) {
  2952. descendants.push(child);
  2953. }
  2954. if (child instanceof ContainerBlot) {
  2955. descendants = descendants.concat(child.descendants(criteria, index, lengthLeft));
  2956. }
  2957. lengthLeft -= length;
  2958. });
  2959. return descendants;
  2960. };
  2961. ContainerBlot.prototype.detach = function () {
  2962. this.children.forEach(function (child) {
  2963. child.detach();
  2964. });
  2965. _super.prototype.detach.call(this);
  2966. };
  2967. ContainerBlot.prototype.formatAt = function (index, length, name, value) {
  2968. this.children.forEachAt(index, length, function (child, offset, length) {
  2969. child.formatAt(offset, length, name, value);
  2970. });
  2971. };
  2972. ContainerBlot.prototype.insertAt = function (index, value, def) {
  2973. var _a = this.children.find(index), child = _a[0], offset = _a[1];
  2974. if (child) {
  2975. child.insertAt(offset, value, def);
  2976. }
  2977. else {
  2978. var blot = def == null ? Registry.create('text', value) : Registry.create(value, def);
  2979. this.appendChild(blot);
  2980. }
  2981. };
  2982. ContainerBlot.prototype.insertBefore = function (childBlot, refBlot) {
  2983. if (this.statics.allowedChildren != null &&
  2984. !this.statics.allowedChildren.some(function (child) {
  2985. return childBlot instanceof child;
  2986. })) {
  2987. throw new Registry.ParchmentError("Cannot insert " + childBlot.statics.blotName + " into " + this.statics.blotName);
  2988. }
  2989. childBlot.insertInto(this, refBlot);
  2990. };
  2991. ContainerBlot.prototype.length = function () {
  2992. return this.children.reduce(function (memo, child) {
  2993. return memo + child.length();
  2994. }, 0);
  2995. };
  2996. ContainerBlot.prototype.moveChildren = function (targetParent, refNode) {
  2997. this.children.forEach(function (child) {
  2998. targetParent.insertBefore(child, refNode);
  2999. });
  3000. };
  3001. ContainerBlot.prototype.optimize = function (context) {
  3002. _super.prototype.optimize.call(this, context);
  3003. if (this.children.length === 0) {
  3004. if (this.statics.defaultChild != null) {
  3005. var child = Registry.create(this.statics.defaultChild);
  3006. this.appendChild(child);
  3007. child.optimize(context);
  3008. }
  3009. else {
  3010. this.remove();
  3011. }
  3012. }
  3013. };
  3014. ContainerBlot.prototype.path = function (index, inclusive) {
  3015. if (inclusive === void 0) { inclusive = false; }
  3016. var _a = this.children.find(index, inclusive), child = _a[0], offset = _a[1];
  3017. var position = [[this, index]];
  3018. if (child instanceof ContainerBlot) {
  3019. return position.concat(child.path(offset, inclusive));
  3020. }
  3021. else if (child != null) {
  3022. position.push([child, offset]);
  3023. }
  3024. return position;
  3025. };
  3026. ContainerBlot.prototype.removeChild = function (child) {
  3027. this.children.remove(child);
  3028. };
  3029. ContainerBlot.prototype.replace = function (target) {
  3030. if (target instanceof ContainerBlot) {
  3031. target.moveChildren(this);
  3032. }
  3033. _super.prototype.replace.call(this, target);
  3034. };
  3035. ContainerBlot.prototype.split = function (index, force) {
  3036. if (force === void 0) { force = false; }
  3037. if (!force) {
  3038. if (index === 0)
  3039. return this;
  3040. if (index === this.length())
  3041. return this.next;
  3042. }
  3043. var after = this.clone();
  3044. this.parent.insertBefore(after, this.next);
  3045. this.children.forEachAt(index, this.length(), function (child, offset, length) {
  3046. child = child.split(offset, force);
  3047. after.appendChild(child);
  3048. });
  3049. return after;
  3050. };
  3051. ContainerBlot.prototype.unwrap = function () {
  3052. this.moveChildren(this.parent, this.next);
  3053. this.remove();
  3054. };
  3055. ContainerBlot.prototype.update = function (mutations, context) {
  3056. var _this = this;
  3057. var addedNodes = [];
  3058. var removedNodes = [];
  3059. mutations.forEach(function (mutation) {
  3060. if (mutation.target === _this.domNode && mutation.type === 'childList') {
  3061. addedNodes.push.apply(addedNodes, mutation.addedNodes);
  3062. removedNodes.push.apply(removedNodes, mutation.removedNodes);
  3063. }
  3064. });
  3065. removedNodes.forEach(function (node) {
  3066. // Check node has actually been removed
  3067. // One exception is Chrome does not immediately remove IFRAMEs
  3068. // from DOM but MutationRecord is correct in its reported removal
  3069. if (node.parentNode != null &&
  3070. // @ts-ignore
  3071. node.tagName !== 'IFRAME' &&
  3072. document.body.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_CONTAINED_BY) {
  3073. return;
  3074. }
  3075. var blot = Registry.find(node);
  3076. if (blot == null)
  3077. return;
  3078. if (blot.domNode.parentNode == null || blot.domNode.parentNode === _this.domNode) {
  3079. blot.detach();
  3080. }
  3081. });
  3082. addedNodes
  3083. .filter(function (node) {
  3084. return node.parentNode == _this.domNode;
  3085. })
  3086. .sort(function (a, b) {
  3087. if (a === b)
  3088. return 0;
  3089. if (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING) {
  3090. return 1;
  3091. }
  3092. return -1;
  3093. })
  3094. .forEach(function (node) {
  3095. var refBlot = null;
  3096. if (node.nextSibling != null) {
  3097. refBlot = Registry.find(node.nextSibling);
  3098. }
  3099. var blot = makeBlot(node);
  3100. if (blot.next != refBlot || blot.next == null) {
  3101. if (blot.parent != null) {
  3102. blot.parent.removeChild(_this);
  3103. }
  3104. _this.insertBefore(blot, refBlot || undefined);
  3105. }
  3106. });
  3107. };
  3108. return ContainerBlot;
  3109. }(shadow_1.default));
  3110. function makeBlot(node) {
  3111. var blot = Registry.find(node);
  3112. if (blot == null) {
  3113. try {
  3114. blot = Registry.create(node);
  3115. }
  3116. catch (e) {
  3117. blot = Registry.create(Registry.Scope.INLINE);
  3118. [].slice.call(node.childNodes).forEach(function (child) {
  3119. // @ts-ignore
  3120. blot.domNode.appendChild(child);
  3121. });
  3122. if (node.parentNode) {
  3123. node.parentNode.replaceChild(blot.domNode, node);
  3124. }
  3125. blot.attach();
  3126. }
  3127. }
  3128. return blot;
  3129. }
  3130. exports.default = ContainerBlot;
  3131. /***/ }),
  3132. /* 18 */
  3133. /***/ (function(module, exports, __webpack_require__) {
  3134. "use strict";
  3135. var __extends = (this && this.__extends) || (function () {
  3136. var extendStatics = Object.setPrototypeOf ||
  3137. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3138. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3139. return function (d, b) {
  3140. extendStatics(d, b);
  3141. function __() { this.constructor = d; }
  3142. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3143. };
  3144. })();
  3145. Object.defineProperty(exports, "__esModule", { value: true });
  3146. var attributor_1 = __webpack_require__(12);
  3147. var store_1 = __webpack_require__(31);
  3148. var container_1 = __webpack_require__(17);
  3149. var Registry = __webpack_require__(1);
  3150. var FormatBlot = /** @class */ (function (_super) {
  3151. __extends(FormatBlot, _super);
  3152. function FormatBlot(domNode) {
  3153. var _this = _super.call(this, domNode) || this;
  3154. _this.attributes = new store_1.default(_this.domNode);
  3155. return _this;
  3156. }
  3157. FormatBlot.formats = function (domNode) {
  3158. if (typeof this.tagName === 'string') {
  3159. return true;
  3160. }
  3161. else if (Array.isArray(this.tagName)) {
  3162. return domNode.tagName.toLowerCase();
  3163. }
  3164. return undefined;
  3165. };
  3166. FormatBlot.prototype.format = function (name, value) {
  3167. var format = Registry.query(name);
  3168. if (format instanceof attributor_1.default) {
  3169. this.attributes.attribute(format, value);
  3170. }
  3171. else if (value) {
  3172. if (format != null && (name !== this.statics.blotName || this.formats()[name] !== value)) {
  3173. this.replaceWith(name, value);
  3174. }
  3175. }
  3176. };
  3177. FormatBlot.prototype.formats = function () {
  3178. var formats = this.attributes.values();
  3179. var format = this.statics.formats(this.domNode);
  3180. if (format != null) {
  3181. formats[this.statics.blotName] = format;
  3182. }
  3183. return formats;
  3184. };
  3185. FormatBlot.prototype.replaceWith = function (name, value) {
  3186. var replacement = _super.prototype.replaceWith.call(this, name, value);
  3187. this.attributes.copy(replacement);
  3188. return replacement;
  3189. };
  3190. FormatBlot.prototype.update = function (mutations, context) {
  3191. var _this = this;
  3192. _super.prototype.update.call(this, mutations, context);
  3193. if (mutations.some(function (mutation) {
  3194. return mutation.target === _this.domNode && mutation.type === 'attributes';
  3195. })) {
  3196. this.attributes.build();
  3197. }
  3198. };
  3199. FormatBlot.prototype.wrap = function (name, value) {
  3200. var wrapper = _super.prototype.wrap.call(this, name, value);
  3201. if (wrapper instanceof FormatBlot && wrapper.statics.scope === this.statics.scope) {
  3202. this.attributes.move(wrapper);
  3203. }
  3204. return wrapper;
  3205. };
  3206. return FormatBlot;
  3207. }(container_1.default));
  3208. exports.default = FormatBlot;
  3209. /***/ }),
  3210. /* 19 */
  3211. /***/ (function(module, exports, __webpack_require__) {
  3212. "use strict";
  3213. var __extends = (this && this.__extends) || (function () {
  3214. var extendStatics = Object.setPrototypeOf ||
  3215. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3216. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3217. return function (d, b) {
  3218. extendStatics(d, b);
  3219. function __() { this.constructor = d; }
  3220. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3221. };
  3222. })();
  3223. Object.defineProperty(exports, "__esModule", { value: true });
  3224. var shadow_1 = __webpack_require__(30);
  3225. var Registry = __webpack_require__(1);
  3226. var LeafBlot = /** @class */ (function (_super) {
  3227. __extends(LeafBlot, _super);
  3228. function LeafBlot() {
  3229. return _super !== null && _super.apply(this, arguments) || this;
  3230. }
  3231. LeafBlot.value = function (domNode) {
  3232. return true;
  3233. };
  3234. LeafBlot.prototype.index = function (node, offset) {
  3235. if (this.domNode === node ||
  3236. this.domNode.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_CONTAINED_BY) {
  3237. return Math.min(offset, 1);
  3238. }
  3239. return -1;
  3240. };
  3241. LeafBlot.prototype.position = function (index, inclusive) {
  3242. var offset = [].indexOf.call(this.parent.domNode.childNodes, this.domNode);
  3243. if (index > 0)
  3244. offset += 1;
  3245. return [this.parent.domNode, offset];
  3246. };
  3247. LeafBlot.prototype.value = function () {
  3248. var _a;
  3249. return _a = {}, _a[this.statics.blotName] = this.statics.value(this.domNode) || true, _a;
  3250. };
  3251. LeafBlot.scope = Registry.Scope.INLINE_BLOT;
  3252. return LeafBlot;
  3253. }(shadow_1.default));
  3254. exports.default = LeafBlot;
  3255. /***/ }),
  3256. /* 20 */
  3257. /***/ (function(module, exports, __webpack_require__) {
  3258. var equal = __webpack_require__(11);
  3259. var extend = __webpack_require__(3);
  3260. var lib = {
  3261. attributes: {
  3262. compose: function (a, b, keepNull) {
  3263. if (typeof a !== 'object') a = {};
  3264. if (typeof b !== 'object') b = {};
  3265. var attributes = extend(true, {}, b);
  3266. if (!keepNull) {
  3267. attributes = Object.keys(attributes).reduce(function (copy, key) {
  3268. if (attributes[key] != null) {
  3269. copy[key] = attributes[key];
  3270. }
  3271. return copy;
  3272. }, {});
  3273. }
  3274. for (var key in a) {
  3275. if (a[key] !== undefined && b[key] === undefined) {
  3276. attributes[key] = a[key];
  3277. }
  3278. }
  3279. return Object.keys(attributes).length > 0 ? attributes : undefined;
  3280. },
  3281. diff: function(a, b) {
  3282. if (typeof a !== 'object') a = {};
  3283. if (typeof b !== 'object') b = {};
  3284. var attributes = Object.keys(a).concat(Object.keys(b)).reduce(function (attributes, key) {
  3285. if (!equal(a[key], b[key])) {
  3286. attributes[key] = b[key] === undefined ? null : b[key];
  3287. }
  3288. return attributes;
  3289. }, {});
  3290. return Object.keys(attributes).length > 0 ? attributes : undefined;
  3291. },
  3292. transform: function (a, b, priority) {
  3293. if (typeof a !== 'object') return b;
  3294. if (typeof b !== 'object') return undefined;
  3295. if (!priority) return b; // b simply overwrites us without priority
  3296. var attributes = Object.keys(b).reduce(function (attributes, key) {
  3297. if (a[key] === undefined) attributes[key] = b[key]; // null is a valid value
  3298. return attributes;
  3299. }, {});
  3300. return Object.keys(attributes).length > 0 ? attributes : undefined;
  3301. }
  3302. },
  3303. iterator: function (ops) {
  3304. return new Iterator(ops);
  3305. },
  3306. length: function (op) {
  3307. if (typeof op['delete'] === 'number') {
  3308. return op['delete'];
  3309. } else if (typeof op.retain === 'number') {
  3310. return op.retain;
  3311. } else {
  3312. return typeof op.insert === 'string' ? op.insert.length : 1;
  3313. }
  3314. }
  3315. };
  3316. function Iterator(ops) {
  3317. this.ops = ops;
  3318. this.index = 0;
  3319. this.offset = 0;
  3320. };
  3321. Iterator.prototype.hasNext = function () {
  3322. return this.peekLength() < Infinity;
  3323. };
  3324. Iterator.prototype.next = function (length) {
  3325. if (!length) length = Infinity;
  3326. var nextOp = this.ops[this.index];
  3327. if (nextOp) {
  3328. var offset = this.offset;
  3329. var opLength = lib.length(nextOp)
  3330. if (length >= opLength - offset) {
  3331. length = opLength - offset;
  3332. this.index += 1;
  3333. this.offset = 0;
  3334. } else {
  3335. this.offset += length;
  3336. }
  3337. if (typeof nextOp['delete'] === 'number') {
  3338. return { 'delete': length };
  3339. } else {
  3340. var retOp = {};
  3341. if (nextOp.attributes) {
  3342. retOp.attributes = nextOp.attributes;
  3343. }
  3344. if (typeof nextOp.retain === 'number') {
  3345. retOp.retain = length;
  3346. } else if (typeof nextOp.insert === 'string') {
  3347. retOp.insert = nextOp.insert.substr(offset, length);
  3348. } else {
  3349. // offset should === 0, length should === 1
  3350. retOp.insert = nextOp.insert;
  3351. }
  3352. return retOp;
  3353. }
  3354. } else {
  3355. return { retain: Infinity };
  3356. }
  3357. };
  3358. Iterator.prototype.peek = function () {
  3359. return this.ops[this.index];
  3360. };
  3361. Iterator.prototype.peekLength = function () {
  3362. if (this.ops[this.index]) {
  3363. // Should never return 0 if our index is being managed correctly
  3364. return lib.length(this.ops[this.index]) - this.offset;
  3365. } else {
  3366. return Infinity;
  3367. }
  3368. };
  3369. Iterator.prototype.peekType = function () {
  3370. if (this.ops[this.index]) {
  3371. if (typeof this.ops[this.index]['delete'] === 'number') {
  3372. return 'delete';
  3373. } else if (typeof this.ops[this.index].retain === 'number') {
  3374. return 'retain';
  3375. } else {
  3376. return 'insert';
  3377. }
  3378. }
  3379. return 'retain';
  3380. };
  3381. Iterator.prototype.rest = function () {
  3382. if (!this.hasNext()) {
  3383. return [];
  3384. } else if (this.offset === 0) {
  3385. return this.ops.slice(this.index);
  3386. } else {
  3387. var offset = this.offset;
  3388. var index = this.index;
  3389. var next = this.next();
  3390. var rest = this.ops.slice(this.index);
  3391. this.offset = offset;
  3392. this.index = index;
  3393. return [next].concat(rest);
  3394. }
  3395. };
  3396. module.exports = lib;
  3397. /***/ }),
  3398. /* 21 */
  3399. /***/ (function(module, exports) {
  3400. var clone = (function() {
  3401. 'use strict';
  3402. function _instanceof(obj, type) {
  3403. return type != null && obj instanceof type;
  3404. }
  3405. var nativeMap;
  3406. try {
  3407. nativeMap = Map;
  3408. } catch(_) {
  3409. // maybe a reference error because no `Map`. Give it a dummy value that no
  3410. // value will ever be an instanceof.
  3411. nativeMap = function() {};
  3412. }
  3413. var nativeSet;
  3414. try {
  3415. nativeSet = Set;
  3416. } catch(_) {
  3417. nativeSet = function() {};
  3418. }
  3419. var nativePromise;
  3420. try {
  3421. nativePromise = Promise;
  3422. } catch(_) {
  3423. nativePromise = function() {};
  3424. }
  3425. /**
  3426. * Clones (copies) an Object using deep copying.
  3427. *
  3428. * This function supports circular references by default, but if you are certain
  3429. * there are no circular references in your object, you can save some CPU time
  3430. * by calling clone(obj, false).
  3431. *
  3432. * Caution: if `circular` is false and `parent` contains circular references,
  3433. * your program may enter an infinite loop and crash.
  3434. *
  3435. * @param `parent` - the object to be cloned
  3436. * @param `circular` - set to true if the object to be cloned may contain
  3437. * circular references. (optional - true by default)
  3438. * @param `depth` - set to a number if the object is only to be cloned to
  3439. * a particular depth. (optional - defaults to Infinity)
  3440. * @param `prototype` - sets the prototype to be used when cloning an object.
  3441. * (optional - defaults to parent prototype).
  3442. * @param `includeNonEnumerable` - set to true if the non-enumerable properties
  3443. * should be cloned as well. Non-enumerable properties on the prototype
  3444. * chain will be ignored. (optional - false by default)
  3445. */
  3446. function clone(parent, circular, depth, prototype, includeNonEnumerable) {
  3447. if (typeof circular === 'object') {
  3448. depth = circular.depth;
  3449. prototype = circular.prototype;
  3450. includeNonEnumerable = circular.includeNonEnumerable;
  3451. circular = circular.circular;
  3452. }
  3453. // maintain two arrays for circular references, where corresponding parents
  3454. // and children have the same index
  3455. var allParents = [];
  3456. var allChildren = [];
  3457. var useBuffer = typeof Buffer != 'undefined';
  3458. if (typeof circular == 'undefined')
  3459. circular = true;
  3460. if (typeof depth == 'undefined')
  3461. depth = Infinity;
  3462. // recurse this function so we don't reset allParents and allChildren
  3463. function _clone(parent, depth) {
  3464. // cloning null always returns null
  3465. if (parent === null)
  3466. return null;
  3467. if (depth === 0)
  3468. return parent;
  3469. var child;
  3470. var proto;
  3471. if (typeof parent != 'object') {
  3472. return parent;
  3473. }
  3474. if (_instanceof(parent, nativeMap)) {
  3475. child = new nativeMap();
  3476. } else if (_instanceof(parent, nativeSet)) {
  3477. child = new nativeSet();
  3478. } else if (_instanceof(parent, nativePromise)) {
  3479. child = new nativePromise(function (resolve, reject) {
  3480. parent.then(function(value) {
  3481. resolve(_clone(value, depth - 1));
  3482. }, function(err) {
  3483. reject(_clone(err, depth - 1));
  3484. });
  3485. });
  3486. } else if (clone.__isArray(parent)) {
  3487. child = [];
  3488. } else if (clone.__isRegExp(parent)) {
  3489. child = new RegExp(parent.source, __getRegExpFlags(parent));
  3490. if (parent.lastIndex) child.lastIndex = parent.lastIndex;
  3491. } else if (clone.__isDate(parent)) {
  3492. child = new Date(parent.getTime());
  3493. } else if (useBuffer && Buffer.isBuffer(parent)) {
  3494. if (Buffer.allocUnsafe) {
  3495. // Node.js >= 4.5.0
  3496. child = Buffer.allocUnsafe(parent.length);
  3497. } else {
  3498. // Older Node.js versions
  3499. child = new Buffer(parent.length);
  3500. }
  3501. parent.copy(child);
  3502. return child;
  3503. } else if (_instanceof(parent, Error)) {
  3504. child = Object.create(parent);
  3505. } else {
  3506. if (typeof prototype == 'undefined') {
  3507. proto = Object.getPrototypeOf(parent);
  3508. child = Object.create(proto);
  3509. }
  3510. else {
  3511. child = Object.create(prototype);
  3512. proto = prototype;
  3513. }
  3514. }
  3515. if (circular) {
  3516. var index = allParents.indexOf(parent);
  3517. if (index != -1) {
  3518. return allChildren[index];
  3519. }
  3520. allParents.push(parent);
  3521. allChildren.push(child);
  3522. }
  3523. if (_instanceof(parent, nativeMap)) {
  3524. parent.forEach(function(value, key) {
  3525. var keyChild = _clone(key, depth - 1);
  3526. var valueChild = _clone(value, depth - 1);
  3527. child.set(keyChild, valueChild);
  3528. });
  3529. }
  3530. if (_instanceof(parent, nativeSet)) {
  3531. parent.forEach(function(value) {
  3532. var entryChild = _clone(value, depth - 1);
  3533. child.add(entryChild);
  3534. });
  3535. }
  3536. for (var i in parent) {
  3537. var attrs;
  3538. if (proto) {
  3539. attrs = Object.getOwnPropertyDescriptor(proto, i);
  3540. }
  3541. if (attrs && attrs.set == null) {
  3542. continue;
  3543. }
  3544. child[i] = _clone(parent[i], depth - 1);
  3545. }
  3546. if (Object.getOwnPropertySymbols) {
  3547. var symbols = Object.getOwnPropertySymbols(parent);
  3548. for (var i = 0; i < symbols.length; i++) {
  3549. // Don't need to worry about cloning a symbol because it is a primitive,
  3550. // like a number or string.
  3551. var symbol = symbols[i];
  3552. var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
  3553. if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
  3554. continue;
  3555. }
  3556. child[symbol] = _clone(parent[symbol], depth - 1);
  3557. if (!descriptor.enumerable) {
  3558. Object.defineProperty(child, symbol, {
  3559. enumerable: false
  3560. });
  3561. }
  3562. }
  3563. }
  3564. if (includeNonEnumerable) {
  3565. var allPropertyNames = Object.getOwnPropertyNames(parent);
  3566. for (var i = 0; i < allPropertyNames.length; i++) {
  3567. var propertyName = allPropertyNames[i];
  3568. var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
  3569. if (descriptor && descriptor.enumerable) {
  3570. continue;
  3571. }
  3572. child[propertyName] = _clone(parent[propertyName], depth - 1);
  3573. Object.defineProperty(child, propertyName, {
  3574. enumerable: false
  3575. });
  3576. }
  3577. }
  3578. return child;
  3579. }
  3580. return _clone(parent, depth);
  3581. }
  3582. /**
  3583. * Simple flat clone using prototype, accepts only objects, usefull for property
  3584. * override on FLAT configuration object (no nested props).
  3585. *
  3586. * USE WITH CAUTION! This may not behave as you wish if you do not know how this
  3587. * works.
  3588. */
  3589. clone.clonePrototype = function clonePrototype(parent) {
  3590. if (parent === null)
  3591. return null;
  3592. var c = function () {};
  3593. c.prototype = parent;
  3594. return new c();
  3595. };
  3596. // private utility functions
  3597. function __objToStr(o) {
  3598. return Object.prototype.toString.call(o);
  3599. }
  3600. clone.__objToStr = __objToStr;
  3601. function __isDate(o) {
  3602. return typeof o === 'object' && __objToStr(o) === '[object Date]';
  3603. }
  3604. clone.__isDate = __isDate;
  3605. function __isArray(o) {
  3606. return typeof o === 'object' && __objToStr(o) === '[object Array]';
  3607. }
  3608. clone.__isArray = __isArray;
  3609. function __isRegExp(o) {
  3610. return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
  3611. }
  3612. clone.__isRegExp = __isRegExp;
  3613. function __getRegExpFlags(re) {
  3614. var flags = '';
  3615. if (re.global) flags += 'g';
  3616. if (re.ignoreCase) flags += 'i';
  3617. if (re.multiline) flags += 'm';
  3618. return flags;
  3619. }
  3620. clone.__getRegExpFlags = __getRegExpFlags;
  3621. return clone;
  3622. })();
  3623. if (typeof module === 'object' && module.exports) {
  3624. module.exports = clone;
  3625. }
  3626. /***/ }),
  3627. /* 22 */
  3628. /***/ (function(module, exports, __webpack_require__) {
  3629. "use strict";
  3630. Object.defineProperty(exports, "__esModule", {
  3631. value: true
  3632. });
  3633. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  3634. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3635. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  3636. var _parchment = __webpack_require__(0);
  3637. var _parchment2 = _interopRequireDefault(_parchment);
  3638. var _emitter = __webpack_require__(8);
  3639. var _emitter2 = _interopRequireDefault(_emitter);
  3640. var _block = __webpack_require__(4);
  3641. var _block2 = _interopRequireDefault(_block);
  3642. var _break = __webpack_require__(16);
  3643. var _break2 = _interopRequireDefault(_break);
  3644. var _code = __webpack_require__(13);
  3645. var _code2 = _interopRequireDefault(_code);
  3646. var _container = __webpack_require__(25);
  3647. var _container2 = _interopRequireDefault(_container);
  3648. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3649. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3650. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3651. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3652. function isLine(blot) {
  3653. return blot instanceof _block2.default || blot instanceof _block.BlockEmbed;
  3654. }
  3655. var Scroll = function (_Parchment$Scroll) {
  3656. _inherits(Scroll, _Parchment$Scroll);
  3657. function Scroll(domNode, config) {
  3658. _classCallCheck(this, Scroll);
  3659. var _this = _possibleConstructorReturn(this, (Scroll.__proto__ || Object.getPrototypeOf(Scroll)).call(this, domNode));
  3660. _this.emitter = config.emitter;
  3661. if (Array.isArray(config.whitelist)) {
  3662. _this.whitelist = config.whitelist.reduce(function (whitelist, format) {
  3663. whitelist[format] = true;
  3664. return whitelist;
  3665. }, {});
  3666. }
  3667. // Some reason fixes composition issues with character languages in Windows/Chrome, Safari
  3668. _this.domNode.addEventListener('DOMNodeInserted', function () {});
  3669. _this.optimize();
  3670. _this.enable();
  3671. return _this;
  3672. }
  3673. _createClass(Scroll, [{
  3674. key: 'batchStart',
  3675. value: function batchStart() {
  3676. this.batch = true;
  3677. }
  3678. }, {
  3679. key: 'batchEnd',
  3680. value: function batchEnd() {
  3681. this.batch = false;
  3682. this.optimize();
  3683. }
  3684. }, {
  3685. key: 'deleteAt',
  3686. value: function deleteAt(index, length) {
  3687. var _line = this.line(index),
  3688. _line2 = _slicedToArray(_line, 2),
  3689. first = _line2[0],
  3690. offset = _line2[1];
  3691. var _line3 = this.line(index + length),
  3692. _line4 = _slicedToArray(_line3, 1),
  3693. last = _line4[0];
  3694. _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'deleteAt', this).call(this, index, length);
  3695. if (last != null && first !== last && offset > 0) {
  3696. if (first instanceof _block.BlockEmbed || last instanceof _block.BlockEmbed) {
  3697. this.optimize();
  3698. return;
  3699. }
  3700. if (first instanceof _code2.default) {
  3701. var newlineIndex = first.newlineIndex(first.length(), true);
  3702. if (newlineIndex > -1) {
  3703. first = first.split(newlineIndex + 1);
  3704. if (first === last) {
  3705. this.optimize();
  3706. return;
  3707. }
  3708. }
  3709. } else if (last instanceof _code2.default) {
  3710. var _newlineIndex = last.newlineIndex(0);
  3711. if (_newlineIndex > -1) {
  3712. last.split(_newlineIndex + 1);
  3713. }
  3714. }
  3715. var ref = last.children.head instanceof _break2.default ? null : last.children.head;
  3716. first.moveChildren(last, ref);
  3717. first.remove();
  3718. }
  3719. this.optimize();
  3720. }
  3721. }, {
  3722. key: 'enable',
  3723. value: function enable() {
  3724. var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  3725. this.domNode.setAttribute('contenteditable', enabled);
  3726. }
  3727. }, {
  3728. key: 'formatAt',
  3729. value: function formatAt(index, length, format, value) {
  3730. if (this.whitelist != null && !this.whitelist[format]) return;
  3731. _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'formatAt', this).call(this, index, length, format, value);
  3732. this.optimize();
  3733. }
  3734. }, {
  3735. key: 'insertAt',
  3736. value: function insertAt(index, value, def) {
  3737. if (def != null && this.whitelist != null && !this.whitelist[value]) return;
  3738. if (index >= this.length()) {
  3739. if (def == null || _parchment2.default.query(value, _parchment2.default.Scope.BLOCK) == null) {
  3740. var blot = _parchment2.default.create(this.statics.defaultChild);
  3741. this.appendChild(blot);
  3742. if (def == null && value.endsWith('\n')) {
  3743. value = value.slice(0, -1);
  3744. }
  3745. blot.insertAt(0, value, def);
  3746. } else {
  3747. var embed = _parchment2.default.create(value, def);
  3748. this.appendChild(embed);
  3749. }
  3750. } else {
  3751. _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'insertAt', this).call(this, index, value, def);
  3752. }
  3753. this.optimize();
  3754. }
  3755. }, {
  3756. key: 'insertBefore',
  3757. value: function insertBefore(blot, ref) {
  3758. if (blot.statics.scope === _parchment2.default.Scope.INLINE_BLOT) {
  3759. var wrapper = _parchment2.default.create(this.statics.defaultChild);
  3760. wrapper.appendChild(blot);
  3761. blot = wrapper;
  3762. }
  3763. _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'insertBefore', this).call(this, blot, ref);
  3764. }
  3765. }, {
  3766. key: 'leaf',
  3767. value: function leaf(index) {
  3768. return this.path(index).pop() || [null, -1];
  3769. }
  3770. }, {
  3771. key: 'line',
  3772. value: function line(index) {
  3773. if (index === this.length()) {
  3774. return this.line(index - 1);
  3775. }
  3776. return this.descendant(isLine, index);
  3777. }
  3778. }, {
  3779. key: 'lines',
  3780. value: function lines() {
  3781. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  3782. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_VALUE;
  3783. var getLines = function getLines(blot, index, length) {
  3784. var lines = [],
  3785. lengthLeft = length;
  3786. blot.children.forEachAt(index, length, function (child, index, length) {
  3787. if (isLine(child)) {
  3788. lines.push(child);
  3789. } else if (child instanceof _parchment2.default.Container) {
  3790. lines = lines.concat(getLines(child, index, lengthLeft));
  3791. }
  3792. lengthLeft -= length;
  3793. });
  3794. return lines;
  3795. };
  3796. return getLines(this, index, length);
  3797. }
  3798. }, {
  3799. key: 'optimize',
  3800. value: function optimize() {
  3801. var mutations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  3802. var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  3803. if (this.batch === true) return;
  3804. _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'optimize', this).call(this, mutations, context);
  3805. if (mutations.length > 0) {
  3806. this.emitter.emit(_emitter2.default.events.SCROLL_OPTIMIZE, mutations, context);
  3807. }
  3808. }
  3809. }, {
  3810. key: 'path',
  3811. value: function path(index) {
  3812. return _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'path', this).call(this, index).slice(1); // Exclude self
  3813. }
  3814. }, {
  3815. key: 'update',
  3816. value: function update(mutations) {
  3817. if (this.batch === true) return;
  3818. var source = _emitter2.default.sources.USER;
  3819. if (typeof mutations === 'string') {
  3820. source = mutations;
  3821. }
  3822. if (!Array.isArray(mutations)) {
  3823. mutations = this.observer.takeRecords();
  3824. }
  3825. if (mutations.length > 0) {
  3826. this.emitter.emit(_emitter2.default.events.SCROLL_BEFORE_UPDATE, source, mutations);
  3827. }
  3828. _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'update', this).call(this, mutations.concat([])); // pass copy
  3829. if (mutations.length > 0) {
  3830. this.emitter.emit(_emitter2.default.events.SCROLL_UPDATE, source, mutations);
  3831. }
  3832. }
  3833. }]);
  3834. return Scroll;
  3835. }(_parchment2.default.Scroll);
  3836. Scroll.blotName = 'scroll';
  3837. Scroll.className = 'ql-editor';
  3838. Scroll.tagName = 'DIV';
  3839. Scroll.defaultChild = 'block';
  3840. Scroll.allowedChildren = [_block2.default, _block.BlockEmbed, _container2.default];
  3841. exports.default = Scroll;
  3842. /***/ }),
  3843. /* 23 */
  3844. /***/ (function(module, exports, __webpack_require__) {
  3845. "use strict";
  3846. Object.defineProperty(exports, "__esModule", {
  3847. value: true
  3848. });
  3849. exports.SHORTKEY = exports.default = undefined;
  3850. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  3851. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  3852. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3853. var _clone = __webpack_require__(21);
  3854. var _clone2 = _interopRequireDefault(_clone);
  3855. var _deepEqual = __webpack_require__(11);
  3856. var _deepEqual2 = _interopRequireDefault(_deepEqual);
  3857. var _extend = __webpack_require__(3);
  3858. var _extend2 = _interopRequireDefault(_extend);
  3859. var _quillDelta = __webpack_require__(2);
  3860. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  3861. var _op = __webpack_require__(20);
  3862. var _op2 = _interopRequireDefault(_op);
  3863. var _parchment = __webpack_require__(0);
  3864. var _parchment2 = _interopRequireDefault(_parchment);
  3865. var _quill = __webpack_require__(5);
  3866. var _quill2 = _interopRequireDefault(_quill);
  3867. var _logger = __webpack_require__(10);
  3868. var _logger2 = _interopRequireDefault(_logger);
  3869. var _module = __webpack_require__(9);
  3870. var _module2 = _interopRequireDefault(_module);
  3871. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3872. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  3873. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3874. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3875. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3876. var debug = (0, _logger2.default)('quill:keyboard');
  3877. var SHORTKEY = /Mac/i.test(navigator.platform) ? 'metaKey' : 'ctrlKey';
  3878. var Keyboard = function (_Module) {
  3879. _inherits(Keyboard, _Module);
  3880. _createClass(Keyboard, null, [{
  3881. key: 'match',
  3882. value: function match(evt, binding) {
  3883. binding = normalize(binding);
  3884. if (['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].some(function (key) {
  3885. return !!binding[key] !== evt[key] && binding[key] !== null;
  3886. })) {
  3887. return false;
  3888. }
  3889. return binding.key === (evt.which || evt.keyCode);
  3890. }
  3891. }]);
  3892. function Keyboard(quill, options) {
  3893. _classCallCheck(this, Keyboard);
  3894. var _this = _possibleConstructorReturn(this, (Keyboard.__proto__ || Object.getPrototypeOf(Keyboard)).call(this, quill, options));
  3895. _this.bindings = {};
  3896. Object.keys(_this.options.bindings).forEach(function (name) {
  3897. if (name === 'list autofill' && quill.scroll.whitelist != null && !quill.scroll.whitelist['list']) {
  3898. return;
  3899. }
  3900. if (_this.options.bindings[name]) {
  3901. _this.addBinding(_this.options.bindings[name]);
  3902. }
  3903. });
  3904. _this.addBinding({ key: Keyboard.keys.ENTER, shiftKey: null }, handleEnter);
  3905. _this.addBinding({ key: Keyboard.keys.ENTER, metaKey: null, ctrlKey: null, altKey: null }, function () {});
  3906. if (/Firefox/i.test(navigator.userAgent)) {
  3907. // Need to handle delete and backspace for Firefox in the general case #1171
  3908. _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true }, handleBackspace);
  3909. _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true }, handleDelete);
  3910. } else {
  3911. _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true, prefix: /^.?$/ }, handleBackspace);
  3912. _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true, suffix: /^.?$/ }, handleDelete);
  3913. }
  3914. _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: false }, handleDeleteRange);
  3915. _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: false }, handleDeleteRange);
  3916. _this.addBinding({ key: Keyboard.keys.BACKSPACE, altKey: null, ctrlKey: null, metaKey: null, shiftKey: null }, { collapsed: true, offset: 0 }, handleBackspace);
  3917. _this.listen();
  3918. return _this;
  3919. }
  3920. _createClass(Keyboard, [{
  3921. key: 'addBinding',
  3922. value: function addBinding(key) {
  3923. var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  3924. var handler = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  3925. var binding = normalize(key);
  3926. if (binding == null || binding.key == null) {
  3927. return debug.warn('Attempted to add invalid keyboard binding', binding);
  3928. }
  3929. if (typeof context === 'function') {
  3930. context = { handler: context };
  3931. }
  3932. if (typeof handler === 'function') {
  3933. handler = { handler: handler };
  3934. }
  3935. binding = (0, _extend2.default)(binding, context, handler);
  3936. this.bindings[binding.key] = this.bindings[binding.key] || [];
  3937. this.bindings[binding.key].push(binding);
  3938. }
  3939. }, {
  3940. key: 'listen',
  3941. value: function listen() {
  3942. var _this2 = this;
  3943. this.quill.root.addEventListener('keydown', function (evt) {
  3944. if (evt.defaultPrevented) return;
  3945. var which = evt.which || evt.keyCode;
  3946. var bindings = (_this2.bindings[which] || []).filter(function (binding) {
  3947. return Keyboard.match(evt, binding);
  3948. });
  3949. if (bindings.length === 0) return;
  3950. var range = _this2.quill.getSelection();
  3951. if (range == null || !_this2.quill.hasFocus()) return;
  3952. var _quill$getLine = _this2.quill.getLine(range.index),
  3953. _quill$getLine2 = _slicedToArray(_quill$getLine, 2),
  3954. line = _quill$getLine2[0],
  3955. offset = _quill$getLine2[1];
  3956. var _quill$getLeaf = _this2.quill.getLeaf(range.index),
  3957. _quill$getLeaf2 = _slicedToArray(_quill$getLeaf, 2),
  3958. leafStart = _quill$getLeaf2[0],
  3959. offsetStart = _quill$getLeaf2[1];
  3960. var _ref = range.length === 0 ? [leafStart, offsetStart] : _this2.quill.getLeaf(range.index + range.length),
  3961. _ref2 = _slicedToArray(_ref, 2),
  3962. leafEnd = _ref2[0],
  3963. offsetEnd = _ref2[1];
  3964. var prefixText = leafStart instanceof _parchment2.default.Text ? leafStart.value().slice(0, offsetStart) : '';
  3965. var suffixText = leafEnd instanceof _parchment2.default.Text ? leafEnd.value().slice(offsetEnd) : '';
  3966. var curContext = {
  3967. collapsed: range.length === 0,
  3968. empty: range.length === 0 && line.length() <= 1,
  3969. format: _this2.quill.getFormat(range),
  3970. offset: offset,
  3971. prefix: prefixText,
  3972. suffix: suffixText
  3973. };
  3974. var prevented = bindings.some(function (binding) {
  3975. if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) return false;
  3976. if (binding.empty != null && binding.empty !== curContext.empty) return false;
  3977. if (binding.offset != null && binding.offset !== curContext.offset) return false;
  3978. if (Array.isArray(binding.format)) {
  3979. // any format is present
  3980. if (binding.format.every(function (name) {
  3981. return curContext.format[name] == null;
  3982. })) {
  3983. return false;
  3984. }
  3985. } else if (_typeof(binding.format) === 'object') {
  3986. // all formats must match
  3987. if (!Object.keys(binding.format).every(function (name) {
  3988. if (binding.format[name] === true) return curContext.format[name] != null;
  3989. if (binding.format[name] === false) return curContext.format[name] == null;
  3990. return (0, _deepEqual2.default)(binding.format[name], curContext.format[name]);
  3991. })) {
  3992. return false;
  3993. }
  3994. }
  3995. if (binding.prefix != null && !binding.prefix.test(curContext.prefix)) return false;
  3996. if (binding.suffix != null && !binding.suffix.test(curContext.suffix)) return false;
  3997. return binding.handler.call(_this2, range, curContext) !== true;
  3998. });
  3999. if (prevented) {
  4000. evt.preventDefault();
  4001. }
  4002. });
  4003. }
  4004. }]);
  4005. return Keyboard;
  4006. }(_module2.default);
  4007. Keyboard.keys = {
  4008. BACKSPACE: 8,
  4009. TAB: 9,
  4010. ENTER: 13,
  4011. ESCAPE: 27,
  4012. LEFT: 37,
  4013. UP: 38,
  4014. RIGHT: 39,
  4015. DOWN: 40,
  4016. DELETE: 46
  4017. };
  4018. Keyboard.DEFAULTS = {
  4019. bindings: {
  4020. 'bold': makeFormatHandler('bold'),
  4021. 'italic': makeFormatHandler('italic'),
  4022. 'underline': makeFormatHandler('underline'),
  4023. 'indent': {
  4024. // highlight tab or tab at beginning of list, indent or blockquote
  4025. key: Keyboard.keys.TAB,
  4026. format: ['blockquote', 'indent', 'list'],
  4027. handler: function handler(range, context) {
  4028. if (context.collapsed && context.offset !== 0) return true;
  4029. this.quill.format('indent', '+1', _quill2.default.sources.USER);
  4030. }
  4031. },
  4032. 'outdent': {
  4033. key: Keyboard.keys.TAB,
  4034. shiftKey: true,
  4035. format: ['blockquote', 'indent', 'list'],
  4036. // highlight tab or tab at beginning of list, indent or blockquote
  4037. handler: function handler(range, context) {
  4038. if (context.collapsed && context.offset !== 0) return true;
  4039. this.quill.format('indent', '-1', _quill2.default.sources.USER);
  4040. }
  4041. },
  4042. 'outdent backspace': {
  4043. key: Keyboard.keys.BACKSPACE,
  4044. collapsed: true,
  4045. shiftKey: null,
  4046. metaKey: null,
  4047. ctrlKey: null,
  4048. altKey: null,
  4049. format: ['indent', 'list'],
  4050. offset: 0,
  4051. handler: function handler(range, context) {
  4052. if (context.format.indent != null) {
  4053. this.quill.format('indent', '-1', _quill2.default.sources.USER);
  4054. } else if (context.format.list != null) {
  4055. this.quill.format('list', false, _quill2.default.sources.USER);
  4056. }
  4057. }
  4058. },
  4059. 'indent code-block': makeCodeBlockHandler(true),
  4060. 'outdent code-block': makeCodeBlockHandler(false),
  4061. 'remove tab': {
  4062. key: Keyboard.keys.TAB,
  4063. shiftKey: true,
  4064. collapsed: true,
  4065. prefix: /\t$/,
  4066. handler: function handler(range) {
  4067. this.quill.deleteText(range.index - 1, 1, _quill2.default.sources.USER);
  4068. }
  4069. },
  4070. 'tab': {
  4071. key: Keyboard.keys.TAB,
  4072. handler: function handler(range) {
  4073. this.quill.history.cutoff();
  4074. var delta = new _quillDelta2.default().retain(range.index).delete(range.length).insert('\t');
  4075. this.quill.updateContents(delta, _quill2.default.sources.USER);
  4076. this.quill.history.cutoff();
  4077. this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
  4078. }
  4079. },
  4080. 'list empty enter': {
  4081. key: Keyboard.keys.ENTER,
  4082. collapsed: true,
  4083. format: ['list'],
  4084. empty: true,
  4085. handler: function handler(range, context) {
  4086. this.quill.format('list', false, _quill2.default.sources.USER);
  4087. if (context.format.indent) {
  4088. this.quill.format('indent', false, _quill2.default.sources.USER);
  4089. }
  4090. }
  4091. },
  4092. 'checklist enter': {
  4093. key: Keyboard.keys.ENTER,
  4094. collapsed: true,
  4095. format: { list: 'checked' },
  4096. handler: function handler(range) {
  4097. var _quill$getLine3 = this.quill.getLine(range.index),
  4098. _quill$getLine4 = _slicedToArray(_quill$getLine3, 2),
  4099. line = _quill$getLine4[0],
  4100. offset = _quill$getLine4[1];
  4101. var formats = (0, _extend2.default)({}, line.formats(), { list: 'checked' });
  4102. var delta = new _quillDelta2.default().retain(range.index).insert('\n', formats).retain(line.length() - offset - 1).retain(1, { list: 'unchecked' });
  4103. this.quill.updateContents(delta, _quill2.default.sources.USER);
  4104. this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
  4105. this.quill.scrollIntoView();
  4106. }
  4107. },
  4108. 'header enter': {
  4109. key: Keyboard.keys.ENTER,
  4110. collapsed: true,
  4111. format: ['header'],
  4112. suffix: /^$/,
  4113. handler: function handler(range, context) {
  4114. var _quill$getLine5 = this.quill.getLine(range.index),
  4115. _quill$getLine6 = _slicedToArray(_quill$getLine5, 2),
  4116. line = _quill$getLine6[0],
  4117. offset = _quill$getLine6[1];
  4118. var delta = new _quillDelta2.default().retain(range.index).insert('\n', context.format).retain(line.length() - offset - 1).retain(1, { header: null });
  4119. this.quill.updateContents(delta, _quill2.default.sources.USER);
  4120. this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
  4121. this.quill.scrollIntoView();
  4122. }
  4123. },
  4124. 'list autofill': {
  4125. key: ' ',
  4126. collapsed: true,
  4127. format: { list: false },
  4128. prefix: /^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,
  4129. handler: function handler(range, context) {
  4130. var length = context.prefix.length;
  4131. var _quill$getLine7 = this.quill.getLine(range.index),
  4132. _quill$getLine8 = _slicedToArray(_quill$getLine7, 2),
  4133. line = _quill$getLine8[0],
  4134. offset = _quill$getLine8[1];
  4135. if (offset > length) return true;
  4136. var value = void 0;
  4137. switch (context.prefix.trim()) {
  4138. case '[]':case '[ ]':
  4139. value = 'unchecked';
  4140. break;
  4141. case '[x]':
  4142. value = 'checked';
  4143. break;
  4144. case '-':case '*':
  4145. value = 'bullet';
  4146. break;
  4147. default:
  4148. value = 'ordered';
  4149. }
  4150. this.quill.insertText(range.index, ' ', _quill2.default.sources.USER);
  4151. this.quill.history.cutoff();
  4152. var delta = new _quillDelta2.default().retain(range.index - offset).delete(length + 1).retain(line.length() - 2 - offset).retain(1, { list: value });
  4153. this.quill.updateContents(delta, _quill2.default.sources.USER);
  4154. this.quill.history.cutoff();
  4155. this.quill.setSelection(range.index - length, _quill2.default.sources.SILENT);
  4156. }
  4157. },
  4158. 'code exit': {
  4159. key: Keyboard.keys.ENTER,
  4160. collapsed: true,
  4161. format: ['code-block'],
  4162. prefix: /\n\n$/,
  4163. suffix: /^\s+$/,
  4164. handler: function handler(range) {
  4165. var _quill$getLine9 = this.quill.getLine(range.index),
  4166. _quill$getLine10 = _slicedToArray(_quill$getLine9, 2),
  4167. line = _quill$getLine10[0],
  4168. offset = _quill$getLine10[1];
  4169. var delta = new _quillDelta2.default().retain(range.index + line.length() - offset - 2).retain(1, { 'code-block': null }).delete(1);
  4170. this.quill.updateContents(delta, _quill2.default.sources.USER);
  4171. }
  4172. },
  4173. 'embed left': makeEmbedArrowHandler(Keyboard.keys.LEFT, false),
  4174. 'embed left shift': makeEmbedArrowHandler(Keyboard.keys.LEFT, true),
  4175. 'embed right': makeEmbedArrowHandler(Keyboard.keys.RIGHT, false),
  4176. 'embed right shift': makeEmbedArrowHandler(Keyboard.keys.RIGHT, true)
  4177. }
  4178. };
  4179. function makeEmbedArrowHandler(key, shiftKey) {
  4180. var _ref3;
  4181. var where = key === Keyboard.keys.LEFT ? 'prefix' : 'suffix';
  4182. return _ref3 = {
  4183. key: key,
  4184. shiftKey: shiftKey,
  4185. altKey: null
  4186. }, _defineProperty(_ref3, where, /^$/), _defineProperty(_ref3, 'handler', function handler(range) {
  4187. var index = range.index;
  4188. if (key === Keyboard.keys.RIGHT) {
  4189. index += range.length + 1;
  4190. }
  4191. var _quill$getLeaf3 = this.quill.getLeaf(index),
  4192. _quill$getLeaf4 = _slicedToArray(_quill$getLeaf3, 1),
  4193. leaf = _quill$getLeaf4[0];
  4194. if (!(leaf instanceof _parchment2.default.Embed)) return true;
  4195. if (key === Keyboard.keys.LEFT) {
  4196. if (shiftKey) {
  4197. this.quill.setSelection(range.index - 1, range.length + 1, _quill2.default.sources.USER);
  4198. } else {
  4199. this.quill.setSelection(range.index - 1, _quill2.default.sources.USER);
  4200. }
  4201. } else {
  4202. if (shiftKey) {
  4203. this.quill.setSelection(range.index, range.length + 1, _quill2.default.sources.USER);
  4204. } else {
  4205. this.quill.setSelection(range.index + range.length + 1, _quill2.default.sources.USER);
  4206. }
  4207. }
  4208. return false;
  4209. }), _ref3;
  4210. }
  4211. function handleBackspace(range, context) {
  4212. if (range.index === 0 || this.quill.getLength() <= 1) return;
  4213. var _quill$getLine11 = this.quill.getLine(range.index),
  4214. _quill$getLine12 = _slicedToArray(_quill$getLine11, 1),
  4215. line = _quill$getLine12[0];
  4216. var formats = {};
  4217. if (context.offset === 0) {
  4218. var _quill$getLine13 = this.quill.getLine(range.index - 1),
  4219. _quill$getLine14 = _slicedToArray(_quill$getLine13, 1),
  4220. prev = _quill$getLine14[0];
  4221. if (prev != null && prev.length() > 1) {
  4222. var curFormats = line.formats();
  4223. var prevFormats = this.quill.getFormat(range.index - 1, 1);
  4224. formats = _op2.default.attributes.diff(curFormats, prevFormats) || {};
  4225. }
  4226. }
  4227. // Check for astral symbols
  4228. var length = /[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(context.prefix) ? 2 : 1;
  4229. this.quill.deleteText(range.index - length, length, _quill2.default.sources.USER);
  4230. if (Object.keys(formats).length > 0) {
  4231. this.quill.formatLine(range.index - length, length, formats, _quill2.default.sources.USER);
  4232. }
  4233. this.quill.focus();
  4234. }
  4235. function handleDelete(range, context) {
  4236. // Check for astral symbols
  4237. var length = /^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(context.suffix) ? 2 : 1;
  4238. if (range.index >= this.quill.getLength() - length) return;
  4239. var formats = {},
  4240. nextLength = 0;
  4241. var _quill$getLine15 = this.quill.getLine(range.index),
  4242. _quill$getLine16 = _slicedToArray(_quill$getLine15, 1),
  4243. line = _quill$getLine16[0];
  4244. if (context.offset >= line.length() - 1) {
  4245. var _quill$getLine17 = this.quill.getLine(range.index + 1),
  4246. _quill$getLine18 = _slicedToArray(_quill$getLine17, 1),
  4247. next = _quill$getLine18[0];
  4248. if (next) {
  4249. var curFormats = line.formats();
  4250. var nextFormats = this.quill.getFormat(range.index, 1);
  4251. formats = _op2.default.attributes.diff(curFormats, nextFormats) || {};
  4252. nextLength = next.length();
  4253. }
  4254. }
  4255. this.quill.deleteText(range.index, length, _quill2.default.sources.USER);
  4256. if (Object.keys(formats).length > 0) {
  4257. this.quill.formatLine(range.index + nextLength - 1, length, formats, _quill2.default.sources.USER);
  4258. }
  4259. }
  4260. function handleDeleteRange(range) {
  4261. var lines = this.quill.getLines(range);
  4262. var formats = {};
  4263. if (lines.length > 1) {
  4264. var firstFormats = lines[0].formats();
  4265. var lastFormats = lines[lines.length - 1].formats();
  4266. formats = _op2.default.attributes.diff(lastFormats, firstFormats) || {};
  4267. }
  4268. this.quill.deleteText(range, _quill2.default.sources.USER);
  4269. if (Object.keys(formats).length > 0) {
  4270. this.quill.formatLine(range.index, 1, formats, _quill2.default.sources.USER);
  4271. }
  4272. this.quill.setSelection(range.index, _quill2.default.sources.SILENT);
  4273. this.quill.focus();
  4274. }
  4275. function handleEnter(range, context) {
  4276. var _this3 = this;
  4277. if (range.length > 0) {
  4278. this.quill.scroll.deleteAt(range.index, range.length); // So we do not trigger text-change
  4279. }
  4280. var lineFormats = Object.keys(context.format).reduce(function (lineFormats, format) {
  4281. if (_parchment2.default.query(format, _parchment2.default.Scope.BLOCK) && !Array.isArray(context.format[format])) {
  4282. lineFormats[format] = context.format[format];
  4283. }
  4284. return lineFormats;
  4285. }, {});
  4286. this.quill.insertText(range.index, '\n', lineFormats, _quill2.default.sources.USER);
  4287. // Earlier scroll.deleteAt might have messed up our selection,
  4288. // so insertText's built in selection preservation is not reliable
  4289. this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
  4290. this.quill.focus();
  4291. Object.keys(context.format).forEach(function (name) {
  4292. if (lineFormats[name] != null) return;
  4293. if (Array.isArray(context.format[name])) return;
  4294. if (name === 'link') return;
  4295. _this3.quill.format(name, context.format[name], _quill2.default.sources.USER);
  4296. });
  4297. }
  4298. function makeCodeBlockHandler(indent) {
  4299. return {
  4300. key: Keyboard.keys.TAB,
  4301. shiftKey: !indent,
  4302. format: { 'code-block': true },
  4303. handler: function handler(range) {
  4304. var CodeBlock = _parchment2.default.query('code-block');
  4305. var index = range.index,
  4306. length = range.length;
  4307. var _quill$scroll$descend = this.quill.scroll.descendant(CodeBlock, index),
  4308. _quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2),
  4309. block = _quill$scroll$descend2[0],
  4310. offset = _quill$scroll$descend2[1];
  4311. if (block == null) return;
  4312. var scrollIndex = this.quill.getIndex(block);
  4313. var start = block.newlineIndex(offset, true) + 1;
  4314. var end = block.newlineIndex(scrollIndex + offset + length);
  4315. var lines = block.domNode.textContent.slice(start, end).split('\n');
  4316. offset = 0;
  4317. lines.forEach(function (line, i) {
  4318. if (indent) {
  4319. block.insertAt(start + offset, CodeBlock.TAB);
  4320. offset += CodeBlock.TAB.length;
  4321. if (i === 0) {
  4322. index += CodeBlock.TAB.length;
  4323. } else {
  4324. length += CodeBlock.TAB.length;
  4325. }
  4326. } else if (line.startsWith(CodeBlock.TAB)) {
  4327. block.deleteAt(start + offset, CodeBlock.TAB.length);
  4328. offset -= CodeBlock.TAB.length;
  4329. if (i === 0) {
  4330. index -= CodeBlock.TAB.length;
  4331. } else {
  4332. length -= CodeBlock.TAB.length;
  4333. }
  4334. }
  4335. offset += line.length + 1;
  4336. });
  4337. this.quill.update(_quill2.default.sources.USER);
  4338. this.quill.setSelection(index, length, _quill2.default.sources.SILENT);
  4339. }
  4340. };
  4341. }
  4342. function makeFormatHandler(format) {
  4343. return {
  4344. key: format[0].toUpperCase(),
  4345. shortKey: true,
  4346. handler: function handler(range, context) {
  4347. this.quill.format(format, !context.format[format], _quill2.default.sources.USER);
  4348. }
  4349. };
  4350. }
  4351. function normalize(binding) {
  4352. if (typeof binding === 'string' || typeof binding === 'number') {
  4353. return normalize({ key: binding });
  4354. }
  4355. if ((typeof binding === 'undefined' ? 'undefined' : _typeof(binding)) === 'object') {
  4356. binding = (0, _clone2.default)(binding, false);
  4357. }
  4358. if (typeof binding.key === 'string') {
  4359. if (Keyboard.keys[binding.key.toUpperCase()] != null) {
  4360. binding.key = Keyboard.keys[binding.key.toUpperCase()];
  4361. } else if (binding.key.length === 1) {
  4362. binding.key = binding.key.toUpperCase().charCodeAt(0);
  4363. } else {
  4364. return null;
  4365. }
  4366. }
  4367. if (binding.shortKey) {
  4368. binding[SHORTKEY] = binding.shortKey;
  4369. delete binding.shortKey;
  4370. }
  4371. return binding;
  4372. }
  4373. exports.default = Keyboard;
  4374. exports.SHORTKEY = SHORTKEY;
  4375. /***/ }),
  4376. /* 24 */
  4377. /***/ (function(module, exports, __webpack_require__) {
  4378. "use strict";
  4379. Object.defineProperty(exports, "__esModule", {
  4380. value: true
  4381. });
  4382. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  4383. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  4384. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4385. var _parchment = __webpack_require__(0);
  4386. var _parchment2 = _interopRequireDefault(_parchment);
  4387. var _text = __webpack_require__(7);
  4388. var _text2 = _interopRequireDefault(_text);
  4389. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4390. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4391. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4392. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4393. var Cursor = function (_Parchment$Embed) {
  4394. _inherits(Cursor, _Parchment$Embed);
  4395. _createClass(Cursor, null, [{
  4396. key: 'value',
  4397. value: function value() {
  4398. return undefined;
  4399. }
  4400. }]);
  4401. function Cursor(domNode, selection) {
  4402. _classCallCheck(this, Cursor);
  4403. var _this = _possibleConstructorReturn(this, (Cursor.__proto__ || Object.getPrototypeOf(Cursor)).call(this, domNode));
  4404. _this.selection = selection;
  4405. _this.textNode = document.createTextNode(Cursor.CONTENTS);
  4406. _this.domNode.appendChild(_this.textNode);
  4407. _this._length = 0;
  4408. return _this;
  4409. }
  4410. _createClass(Cursor, [{
  4411. key: 'detach',
  4412. value: function detach() {
  4413. // super.detach() will also clear domNode.__blot
  4414. if (this.parent != null) this.parent.removeChild(this);
  4415. }
  4416. }, {
  4417. key: 'format',
  4418. value: function format(name, value) {
  4419. if (this._length !== 0) {
  4420. return _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'format', this).call(this, name, value);
  4421. }
  4422. var target = this,
  4423. index = 0;
  4424. while (target != null && target.statics.scope !== _parchment2.default.Scope.BLOCK_BLOT) {
  4425. index += target.offset(target.parent);
  4426. target = target.parent;
  4427. }
  4428. if (target != null) {
  4429. this._length = Cursor.CONTENTS.length;
  4430. target.optimize();
  4431. target.formatAt(index, Cursor.CONTENTS.length, name, value);
  4432. this._length = 0;
  4433. }
  4434. }
  4435. }, {
  4436. key: 'index',
  4437. value: function index(node, offset) {
  4438. if (node === this.textNode) return 0;
  4439. return _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'index', this).call(this, node, offset);
  4440. }
  4441. }, {
  4442. key: 'length',
  4443. value: function length() {
  4444. return this._length;
  4445. }
  4446. }, {
  4447. key: 'position',
  4448. value: function position() {
  4449. return [this.textNode, this.textNode.data.length];
  4450. }
  4451. }, {
  4452. key: 'remove',
  4453. value: function remove() {
  4454. _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'remove', this).call(this);
  4455. this.parent = null;
  4456. }
  4457. }, {
  4458. key: 'restore',
  4459. value: function restore() {
  4460. if (this.selection.composing || this.parent == null) return;
  4461. var textNode = this.textNode;
  4462. var range = this.selection.getNativeRange();
  4463. var restoreText = void 0,
  4464. start = void 0,
  4465. end = void 0;
  4466. if (range != null && range.start.node === textNode && range.end.node === textNode) {
  4467. var _ref = [textNode, range.start.offset, range.end.offset];
  4468. restoreText = _ref[0];
  4469. start = _ref[1];
  4470. end = _ref[2];
  4471. }
  4472. // Link format will insert text outside of anchor tag
  4473. while (this.domNode.lastChild != null && this.domNode.lastChild !== this.textNode) {
  4474. this.domNode.parentNode.insertBefore(this.domNode.lastChild, this.domNode);
  4475. }
  4476. if (this.textNode.data !== Cursor.CONTENTS) {
  4477. var text = this.textNode.data.split(Cursor.CONTENTS).join('');
  4478. if (this.next instanceof _text2.default) {
  4479. restoreText = this.next.domNode;
  4480. this.next.insertAt(0, text);
  4481. this.textNode.data = Cursor.CONTENTS;
  4482. } else {
  4483. this.textNode.data = text;
  4484. this.parent.insertBefore(_parchment2.default.create(this.textNode), this);
  4485. this.textNode = document.createTextNode(Cursor.CONTENTS);
  4486. this.domNode.appendChild(this.textNode);
  4487. }
  4488. }
  4489. this.remove();
  4490. if (start != null) {
  4491. var _map = [start, end].map(function (offset) {
  4492. return Math.max(0, Math.min(restoreText.data.length, offset - 1));
  4493. });
  4494. var _map2 = _slicedToArray(_map, 2);
  4495. start = _map2[0];
  4496. end = _map2[1];
  4497. return {
  4498. startNode: restoreText,
  4499. startOffset: start,
  4500. endNode: restoreText,
  4501. endOffset: end
  4502. };
  4503. }
  4504. }
  4505. }, {
  4506. key: 'update',
  4507. value: function update(mutations, context) {
  4508. var _this2 = this;
  4509. if (mutations.some(function (mutation) {
  4510. return mutation.type === 'characterData' && mutation.target === _this2.textNode;
  4511. })) {
  4512. var range = this.restore();
  4513. if (range) context.range = range;
  4514. }
  4515. }
  4516. }, {
  4517. key: 'value',
  4518. value: function value() {
  4519. return '';
  4520. }
  4521. }]);
  4522. return Cursor;
  4523. }(_parchment2.default.Embed);
  4524. Cursor.blotName = 'cursor';
  4525. Cursor.className = 'ql-cursor';
  4526. Cursor.tagName = 'span';
  4527. Cursor.CONTENTS = '\uFEFF'; // Zero width no break space
  4528. exports.default = Cursor;
  4529. /***/ }),
  4530. /* 25 */
  4531. /***/ (function(module, exports, __webpack_require__) {
  4532. "use strict";
  4533. Object.defineProperty(exports, "__esModule", {
  4534. value: true
  4535. });
  4536. var _parchment = __webpack_require__(0);
  4537. var _parchment2 = _interopRequireDefault(_parchment);
  4538. var _block = __webpack_require__(4);
  4539. var _block2 = _interopRequireDefault(_block);
  4540. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4541. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4542. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4543. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4544. var Container = function (_Parchment$Container) {
  4545. _inherits(Container, _Parchment$Container);
  4546. function Container() {
  4547. _classCallCheck(this, Container);
  4548. return _possibleConstructorReturn(this, (Container.__proto__ || Object.getPrototypeOf(Container)).apply(this, arguments));
  4549. }
  4550. return Container;
  4551. }(_parchment2.default.Container);
  4552. Container.allowedChildren = [_block2.default, _block.BlockEmbed, Container];
  4553. exports.default = Container;
  4554. /***/ }),
  4555. /* 26 */
  4556. /***/ (function(module, exports, __webpack_require__) {
  4557. "use strict";
  4558. Object.defineProperty(exports, "__esModule", {
  4559. value: true
  4560. });
  4561. exports.ColorStyle = exports.ColorClass = exports.ColorAttributor = undefined;
  4562. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4563. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  4564. var _parchment = __webpack_require__(0);
  4565. var _parchment2 = _interopRequireDefault(_parchment);
  4566. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4567. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4568. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4569. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4570. var ColorAttributor = function (_Parchment$Attributor) {
  4571. _inherits(ColorAttributor, _Parchment$Attributor);
  4572. function ColorAttributor() {
  4573. _classCallCheck(this, ColorAttributor);
  4574. return _possibleConstructorReturn(this, (ColorAttributor.__proto__ || Object.getPrototypeOf(ColorAttributor)).apply(this, arguments));
  4575. }
  4576. _createClass(ColorAttributor, [{
  4577. key: 'value',
  4578. value: function value(domNode) {
  4579. var value = _get(ColorAttributor.prototype.__proto__ || Object.getPrototypeOf(ColorAttributor.prototype), 'value', this).call(this, domNode);
  4580. if (!value.startsWith('rgb(')) return value;
  4581. value = value.replace(/^[^\d]+/, '').replace(/[^\d]+$/, '');
  4582. return '#' + value.split(',').map(function (component) {
  4583. return ('00' + parseInt(component).toString(16)).slice(-2);
  4584. }).join('');
  4585. }
  4586. }]);
  4587. return ColorAttributor;
  4588. }(_parchment2.default.Attributor.Style);
  4589. var ColorClass = new _parchment2.default.Attributor.Class('color', 'ql-color', {
  4590. scope: _parchment2.default.Scope.INLINE
  4591. });
  4592. var ColorStyle = new ColorAttributor('color', 'color', {
  4593. scope: _parchment2.default.Scope.INLINE
  4594. });
  4595. exports.ColorAttributor = ColorAttributor;
  4596. exports.ColorClass = ColorClass;
  4597. exports.ColorStyle = ColorStyle;
  4598. /***/ }),
  4599. /* 27 */
  4600. /***/ (function(module, exports, __webpack_require__) {
  4601. "use strict";
  4602. Object.defineProperty(exports, "__esModule", {
  4603. value: true
  4604. });
  4605. exports.sanitize = exports.default = undefined;
  4606. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4607. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  4608. var _inline = __webpack_require__(6);
  4609. var _inline2 = _interopRequireDefault(_inline);
  4610. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4611. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4612. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4613. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4614. var Link = function (_Inline) {
  4615. _inherits(Link, _Inline);
  4616. function Link() {
  4617. _classCallCheck(this, Link);
  4618. return _possibleConstructorReturn(this, (Link.__proto__ || Object.getPrototypeOf(Link)).apply(this, arguments));
  4619. }
  4620. _createClass(Link, [{
  4621. key: 'format',
  4622. value: function format(name, value) {
  4623. if (name !== this.statics.blotName || !value) return _get(Link.prototype.__proto__ || Object.getPrototypeOf(Link.prototype), 'format', this).call(this, name, value);
  4624. value = this.constructor.sanitize(value);
  4625. this.domNode.setAttribute('href', value);
  4626. }
  4627. }], [{
  4628. key: 'create',
  4629. value: function create(value) {
  4630. var node = _get(Link.__proto__ || Object.getPrototypeOf(Link), 'create', this).call(this, value);
  4631. value = this.sanitize(value);
  4632. node.setAttribute('href', value);
  4633. node.setAttribute('rel', 'noopener noreferrer');
  4634. node.setAttribute('target', '_blank');
  4635. return node;
  4636. }
  4637. }, {
  4638. key: 'formats',
  4639. value: function formats(domNode) {
  4640. return domNode.getAttribute('href');
  4641. }
  4642. }, {
  4643. key: 'sanitize',
  4644. value: function sanitize(url) {
  4645. return _sanitize(url, this.PROTOCOL_WHITELIST) ? url : this.SANITIZED_URL;
  4646. }
  4647. }]);
  4648. return Link;
  4649. }(_inline2.default);
  4650. Link.blotName = 'link';
  4651. Link.tagName = 'A';
  4652. Link.SANITIZED_URL = 'about:blank';
  4653. Link.PROTOCOL_WHITELIST = ['http', 'https', 'mailto', 'tel'];
  4654. function _sanitize(url, protocols) {
  4655. var anchor = document.createElement('a');
  4656. anchor.href = url;
  4657. var protocol = anchor.href.slice(0, anchor.href.indexOf(':'));
  4658. return protocols.indexOf(protocol) > -1;
  4659. }
  4660. exports.default = Link;
  4661. exports.sanitize = _sanitize;
  4662. /***/ }),
  4663. /* 28 */
  4664. /***/ (function(module, exports, __webpack_require__) {
  4665. "use strict";
  4666. Object.defineProperty(exports, "__esModule", {
  4667. value: true
  4668. });
  4669. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  4670. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4671. var _keyboard = __webpack_require__(23);
  4672. var _keyboard2 = _interopRequireDefault(_keyboard);
  4673. var _dropdown = __webpack_require__(107);
  4674. var _dropdown2 = _interopRequireDefault(_dropdown);
  4675. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4676. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4677. var optionsCounter = 0;
  4678. function toggleAriaAttribute(element, attribute) {
  4679. element.setAttribute(attribute, !(element.getAttribute(attribute) === 'true'));
  4680. }
  4681. var Picker = function () {
  4682. function Picker(select) {
  4683. var _this = this;
  4684. _classCallCheck(this, Picker);
  4685. this.select = select;
  4686. this.container = document.createElement('span');
  4687. this.buildPicker();
  4688. this.select.style.display = 'none';
  4689. this.select.parentNode.insertBefore(this.container, this.select);
  4690. this.label.addEventListener('mousedown', function () {
  4691. _this.togglePicker();
  4692. });
  4693. this.label.addEventListener('keydown', function (event) {
  4694. switch (event.keyCode) {
  4695. // Allows the "Enter" key to open the picker
  4696. case _keyboard2.default.keys.ENTER:
  4697. _this.togglePicker();
  4698. break;
  4699. // Allows the "Escape" key to close the picker
  4700. case _keyboard2.default.keys.ESCAPE:
  4701. _this.escape();
  4702. event.preventDefault();
  4703. break;
  4704. default:
  4705. }
  4706. });
  4707. this.select.addEventListener('change', this.update.bind(this));
  4708. }
  4709. _createClass(Picker, [{
  4710. key: 'togglePicker',
  4711. value: function togglePicker() {
  4712. this.container.classList.toggle('ql-expanded');
  4713. // Toggle aria-expanded and aria-hidden to make the picker accessible
  4714. toggleAriaAttribute(this.label, 'aria-expanded');
  4715. toggleAriaAttribute(this.options, 'aria-hidden');
  4716. }
  4717. }, {
  4718. key: 'buildItem',
  4719. value: function buildItem(option) {
  4720. var _this2 = this;
  4721. var item = document.createElement('span');
  4722. item.tabIndex = '0';
  4723. item.setAttribute('role', 'button');
  4724. item.classList.add('ql-picker-item');
  4725. if (option.hasAttribute('value')) {
  4726. item.setAttribute('data-value', option.getAttribute('value'));
  4727. }
  4728. if (option.textContent) {
  4729. item.setAttribute('data-label', option.textContent);
  4730. }
  4731. item.addEventListener('click', function () {
  4732. _this2.selectItem(item, true);
  4733. });
  4734. item.addEventListener('keydown', function (event) {
  4735. switch (event.keyCode) {
  4736. // Allows the "Enter" key to select an item
  4737. case _keyboard2.default.keys.ENTER:
  4738. _this2.selectItem(item, true);
  4739. event.preventDefault();
  4740. break;
  4741. // Allows the "Escape" key to close the picker
  4742. case _keyboard2.default.keys.ESCAPE:
  4743. _this2.escape();
  4744. event.preventDefault();
  4745. break;
  4746. default:
  4747. }
  4748. });
  4749. return item;
  4750. }
  4751. }, {
  4752. key: 'buildLabel',
  4753. value: function buildLabel() {
  4754. var label = document.createElement('span');
  4755. label.classList.add('ql-picker-label');
  4756. label.innerHTML = _dropdown2.default;
  4757. label.tabIndex = '0';
  4758. label.setAttribute('role', 'button');
  4759. label.setAttribute('aria-expanded', 'false');
  4760. this.container.appendChild(label);
  4761. return label;
  4762. }
  4763. }, {
  4764. key: 'buildOptions',
  4765. value: function buildOptions() {
  4766. var _this3 = this;
  4767. var options = document.createElement('span');
  4768. options.classList.add('ql-picker-options');
  4769. // Don't want screen readers to read this until options are visible
  4770. options.setAttribute('aria-hidden', 'true');
  4771. options.tabIndex = '-1';
  4772. // Need a unique id for aria-controls
  4773. options.id = 'ql-picker-options-' + optionsCounter;
  4774. optionsCounter += 1;
  4775. this.label.setAttribute('aria-controls', options.id);
  4776. this.options = options;
  4777. [].slice.call(this.select.options).forEach(function (option) {
  4778. var item = _this3.buildItem(option);
  4779. options.appendChild(item);
  4780. if (option.selected === true) {
  4781. _this3.selectItem(item);
  4782. }
  4783. });
  4784. this.container.appendChild(options);
  4785. }
  4786. }, {
  4787. key: 'buildPicker',
  4788. value: function buildPicker() {
  4789. var _this4 = this;
  4790. [].slice.call(this.select.attributes).forEach(function (item) {
  4791. _this4.container.setAttribute(item.name, item.value);
  4792. });
  4793. this.container.classList.add('ql-picker');
  4794. this.label = this.buildLabel();
  4795. this.buildOptions();
  4796. }
  4797. }, {
  4798. key: 'escape',
  4799. value: function escape() {
  4800. var _this5 = this;
  4801. // Close menu and return focus to trigger label
  4802. this.close();
  4803. // Need setTimeout for accessibility to ensure that the browser executes
  4804. // focus on the next process thread and after any DOM content changes
  4805. setTimeout(function () {
  4806. return _this5.label.focus();
  4807. }, 1);
  4808. }
  4809. }, {
  4810. key: 'close',
  4811. value: function close() {
  4812. this.container.classList.remove('ql-expanded');
  4813. this.label.setAttribute('aria-expanded', 'false');
  4814. this.options.setAttribute('aria-hidden', 'true');
  4815. }
  4816. }, {
  4817. key: 'selectItem',
  4818. value: function selectItem(item) {
  4819. var trigger = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4820. var selected = this.container.querySelector('.ql-selected');
  4821. if (item === selected) return;
  4822. if (selected != null) {
  4823. selected.classList.remove('ql-selected');
  4824. }
  4825. if (item == null) return;
  4826. item.classList.add('ql-selected');
  4827. this.select.selectedIndex = [].indexOf.call(item.parentNode.children, item);
  4828. if (item.hasAttribute('data-value')) {
  4829. this.label.setAttribute('data-value', item.getAttribute('data-value'));
  4830. } else {
  4831. this.label.removeAttribute('data-value');
  4832. }
  4833. if (item.hasAttribute('data-label')) {
  4834. this.label.setAttribute('data-label', item.getAttribute('data-label'));
  4835. } else {
  4836. this.label.removeAttribute('data-label');
  4837. }
  4838. if (trigger) {
  4839. if (typeof Event === 'function') {
  4840. this.select.dispatchEvent(new Event('change'));
  4841. } else if ((typeof Event === 'undefined' ? 'undefined' : _typeof(Event)) === 'object') {
  4842. // IE11
  4843. var event = document.createEvent('Event');
  4844. event.initEvent('change', true, true);
  4845. this.select.dispatchEvent(event);
  4846. }
  4847. this.close();
  4848. }
  4849. }
  4850. }, {
  4851. key: 'update',
  4852. value: function update() {
  4853. var option = void 0;
  4854. if (this.select.selectedIndex > -1) {
  4855. var item = this.container.querySelector('.ql-picker-options').children[this.select.selectedIndex];
  4856. option = this.select.options[this.select.selectedIndex];
  4857. this.selectItem(item);
  4858. } else {
  4859. this.selectItem(null);
  4860. }
  4861. var isActive = option != null && option !== this.select.querySelector('option[selected]');
  4862. this.label.classList.toggle('ql-active', isActive);
  4863. }
  4864. }]);
  4865. return Picker;
  4866. }();
  4867. exports.default = Picker;
  4868. /***/ }),
  4869. /* 29 */
  4870. /***/ (function(module, exports, __webpack_require__) {
  4871. "use strict";
  4872. Object.defineProperty(exports, "__esModule", {
  4873. value: true
  4874. });
  4875. var _parchment = __webpack_require__(0);
  4876. var _parchment2 = _interopRequireDefault(_parchment);
  4877. var _quill = __webpack_require__(5);
  4878. var _quill2 = _interopRequireDefault(_quill);
  4879. var _block = __webpack_require__(4);
  4880. var _block2 = _interopRequireDefault(_block);
  4881. var _break = __webpack_require__(16);
  4882. var _break2 = _interopRequireDefault(_break);
  4883. var _container = __webpack_require__(25);
  4884. var _container2 = _interopRequireDefault(_container);
  4885. var _cursor = __webpack_require__(24);
  4886. var _cursor2 = _interopRequireDefault(_cursor);
  4887. var _embed = __webpack_require__(35);
  4888. var _embed2 = _interopRequireDefault(_embed);
  4889. var _inline = __webpack_require__(6);
  4890. var _inline2 = _interopRequireDefault(_inline);
  4891. var _scroll = __webpack_require__(22);
  4892. var _scroll2 = _interopRequireDefault(_scroll);
  4893. var _text = __webpack_require__(7);
  4894. var _text2 = _interopRequireDefault(_text);
  4895. var _clipboard = __webpack_require__(55);
  4896. var _clipboard2 = _interopRequireDefault(_clipboard);
  4897. var _history = __webpack_require__(42);
  4898. var _history2 = _interopRequireDefault(_history);
  4899. var _keyboard = __webpack_require__(23);
  4900. var _keyboard2 = _interopRequireDefault(_keyboard);
  4901. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4902. _quill2.default.register({
  4903. 'blots/block': _block2.default,
  4904. 'blots/block/embed': _block.BlockEmbed,
  4905. 'blots/break': _break2.default,
  4906. 'blots/container': _container2.default,
  4907. 'blots/cursor': _cursor2.default,
  4908. 'blots/embed': _embed2.default,
  4909. 'blots/inline': _inline2.default,
  4910. 'blots/scroll': _scroll2.default,
  4911. 'blots/text': _text2.default,
  4912. 'modules/clipboard': _clipboard2.default,
  4913. 'modules/history': _history2.default,
  4914. 'modules/keyboard': _keyboard2.default
  4915. });
  4916. _parchment2.default.register(_block2.default, _break2.default, _cursor2.default, _inline2.default, _scroll2.default, _text2.default);
  4917. exports.default = _quill2.default;
  4918. /***/ }),
  4919. /* 30 */
  4920. /***/ (function(module, exports, __webpack_require__) {
  4921. "use strict";
  4922. Object.defineProperty(exports, "__esModule", { value: true });
  4923. var Registry = __webpack_require__(1);
  4924. var ShadowBlot = /** @class */ (function () {
  4925. function ShadowBlot(domNode) {
  4926. this.domNode = domNode;
  4927. // @ts-ignore
  4928. this.domNode[Registry.DATA_KEY] = { blot: this };
  4929. }
  4930. Object.defineProperty(ShadowBlot.prototype, "statics", {
  4931. // Hack for accessing inherited static methods
  4932. get: function () {
  4933. return this.constructor;
  4934. },
  4935. enumerable: true,
  4936. configurable: true
  4937. });
  4938. ShadowBlot.create = function (value) {
  4939. if (this.tagName == null) {
  4940. throw new Registry.ParchmentError('Blot definition missing tagName');
  4941. }
  4942. var node;
  4943. if (Array.isArray(this.tagName)) {
  4944. if (typeof value === 'string') {
  4945. value = value.toUpperCase();
  4946. if (parseInt(value).toString() === value) {
  4947. value = parseInt(value);
  4948. }
  4949. }
  4950. if (typeof value === 'number') {
  4951. node = document.createElement(this.tagName[value - 1]);
  4952. }
  4953. else if (this.tagName.indexOf(value) > -1) {
  4954. node = document.createElement(value);
  4955. }
  4956. else {
  4957. node = document.createElement(this.tagName[0]);
  4958. }
  4959. }
  4960. else {
  4961. node = document.createElement(this.tagName);
  4962. }
  4963. if (this.className) {
  4964. node.classList.add(this.className);
  4965. }
  4966. return node;
  4967. };
  4968. ShadowBlot.prototype.attach = function () {
  4969. if (this.parent != null) {
  4970. this.scroll = this.parent.scroll;
  4971. }
  4972. };
  4973. ShadowBlot.prototype.clone = function () {
  4974. var domNode = this.domNode.cloneNode(false);
  4975. return Registry.create(domNode);
  4976. };
  4977. ShadowBlot.prototype.detach = function () {
  4978. if (this.parent != null)
  4979. this.parent.removeChild(this);
  4980. // @ts-ignore
  4981. delete this.domNode[Registry.DATA_KEY];
  4982. };
  4983. ShadowBlot.prototype.deleteAt = function (index, length) {
  4984. var blot = this.isolate(index, length);
  4985. blot.remove();
  4986. };
  4987. ShadowBlot.prototype.formatAt = function (index, length, name, value) {
  4988. var blot = this.isolate(index, length);
  4989. if (Registry.query(name, Registry.Scope.BLOT) != null && value) {
  4990. blot.wrap(name, value);
  4991. }
  4992. else if (Registry.query(name, Registry.Scope.ATTRIBUTE) != null) {
  4993. var parent = Registry.create(this.statics.scope);
  4994. blot.wrap(parent);
  4995. parent.format(name, value);
  4996. }
  4997. };
  4998. ShadowBlot.prototype.insertAt = function (index, value, def) {
  4999. var blot = def == null ? Registry.create('text', value) : Registry.create(value, def);
  5000. var ref = this.split(index);
  5001. this.parent.insertBefore(blot, ref);
  5002. };
  5003. ShadowBlot.prototype.insertInto = function (parentBlot, refBlot) {
  5004. if (refBlot === void 0) { refBlot = null; }
  5005. if (this.parent != null) {
  5006. this.parent.children.remove(this);
  5007. }
  5008. var refDomNode = null;
  5009. parentBlot.children.insertBefore(this, refBlot);
  5010. if (refBlot != null) {
  5011. refDomNode = refBlot.domNode;
  5012. }
  5013. if (this.domNode.parentNode != parentBlot.domNode ||
  5014. this.domNode.nextSibling != refDomNode) {
  5015. parentBlot.domNode.insertBefore(this.domNode, refDomNode);
  5016. }
  5017. this.parent = parentBlot;
  5018. this.attach();
  5019. };
  5020. ShadowBlot.prototype.isolate = function (index, length) {
  5021. var target = this.split(index);
  5022. target.split(length);
  5023. return target;
  5024. };
  5025. ShadowBlot.prototype.length = function () {
  5026. return 1;
  5027. };
  5028. ShadowBlot.prototype.offset = function (root) {
  5029. if (root === void 0) { root = this.parent; }
  5030. if (this.parent == null || this == root)
  5031. return 0;
  5032. return this.parent.children.offset(this) + this.parent.offset(root);
  5033. };
  5034. ShadowBlot.prototype.optimize = function (context) {
  5035. // TODO clean up once we use WeakMap
  5036. // @ts-ignore
  5037. if (this.domNode[Registry.DATA_KEY] != null) {
  5038. // @ts-ignore
  5039. delete this.domNode[Registry.DATA_KEY].mutations;
  5040. }
  5041. };
  5042. ShadowBlot.prototype.remove = function () {
  5043. if (this.domNode.parentNode != null) {
  5044. this.domNode.parentNode.removeChild(this.domNode);
  5045. }
  5046. this.detach();
  5047. };
  5048. ShadowBlot.prototype.replace = function (target) {
  5049. if (target.parent == null)
  5050. return;
  5051. target.parent.insertBefore(this, target.next);
  5052. target.remove();
  5053. };
  5054. ShadowBlot.prototype.replaceWith = function (name, value) {
  5055. var replacement = typeof name === 'string' ? Registry.create(name, value) : name;
  5056. replacement.replace(this);
  5057. return replacement;
  5058. };
  5059. ShadowBlot.prototype.split = function (index, force) {
  5060. return index === 0 ? this : this.next;
  5061. };
  5062. ShadowBlot.prototype.update = function (mutations, context) {
  5063. // Nothing to do by default
  5064. };
  5065. ShadowBlot.prototype.wrap = function (name, value) {
  5066. var wrapper = typeof name === 'string' ? Registry.create(name, value) : name;
  5067. if (this.parent != null) {
  5068. this.parent.insertBefore(wrapper, this.next);
  5069. }
  5070. wrapper.appendChild(this);
  5071. return wrapper;
  5072. };
  5073. ShadowBlot.blotName = 'abstract';
  5074. return ShadowBlot;
  5075. }());
  5076. exports.default = ShadowBlot;
  5077. /***/ }),
  5078. /* 31 */
  5079. /***/ (function(module, exports, __webpack_require__) {
  5080. "use strict";
  5081. Object.defineProperty(exports, "__esModule", { value: true });
  5082. var attributor_1 = __webpack_require__(12);
  5083. var class_1 = __webpack_require__(32);
  5084. var style_1 = __webpack_require__(33);
  5085. var Registry = __webpack_require__(1);
  5086. var AttributorStore = /** @class */ (function () {
  5087. function AttributorStore(domNode) {
  5088. this.attributes = {};
  5089. this.domNode = domNode;
  5090. this.build();
  5091. }
  5092. AttributorStore.prototype.attribute = function (attribute, value) {
  5093. // verb
  5094. if (value) {
  5095. if (attribute.add(this.domNode, value)) {
  5096. if (attribute.value(this.domNode) != null) {
  5097. this.attributes[attribute.attrName] = attribute;
  5098. }
  5099. else {
  5100. delete this.attributes[attribute.attrName];
  5101. }
  5102. }
  5103. }
  5104. else {
  5105. attribute.remove(this.domNode);
  5106. delete this.attributes[attribute.attrName];
  5107. }
  5108. };
  5109. AttributorStore.prototype.build = function () {
  5110. var _this = this;
  5111. this.attributes = {};
  5112. var attributes = attributor_1.default.keys(this.domNode);
  5113. var classes = class_1.default.keys(this.domNode);
  5114. var styles = style_1.default.keys(this.domNode);
  5115. attributes
  5116. .concat(classes)
  5117. .concat(styles)
  5118. .forEach(function (name) {
  5119. var attr = Registry.query(name, Registry.Scope.ATTRIBUTE);
  5120. if (attr instanceof attributor_1.default) {
  5121. _this.attributes[attr.attrName] = attr;
  5122. }
  5123. });
  5124. };
  5125. AttributorStore.prototype.copy = function (target) {
  5126. var _this = this;
  5127. Object.keys(this.attributes).forEach(function (key) {
  5128. var value = _this.attributes[key].value(_this.domNode);
  5129. target.format(key, value);
  5130. });
  5131. };
  5132. AttributorStore.prototype.move = function (target) {
  5133. var _this = this;
  5134. this.copy(target);
  5135. Object.keys(this.attributes).forEach(function (key) {
  5136. _this.attributes[key].remove(_this.domNode);
  5137. });
  5138. this.attributes = {};
  5139. };
  5140. AttributorStore.prototype.values = function () {
  5141. var _this = this;
  5142. return Object.keys(this.attributes).reduce(function (attributes, name) {
  5143. attributes[name] = _this.attributes[name].value(_this.domNode);
  5144. return attributes;
  5145. }, {});
  5146. };
  5147. return AttributorStore;
  5148. }());
  5149. exports.default = AttributorStore;
  5150. /***/ }),
  5151. /* 32 */
  5152. /***/ (function(module, exports, __webpack_require__) {
  5153. "use strict";
  5154. var __extends = (this && this.__extends) || (function () {
  5155. var extendStatics = Object.setPrototypeOf ||
  5156. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5157. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5158. return function (d, b) {
  5159. extendStatics(d, b);
  5160. function __() { this.constructor = d; }
  5161. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5162. };
  5163. })();
  5164. Object.defineProperty(exports, "__esModule", { value: true });
  5165. var attributor_1 = __webpack_require__(12);
  5166. function match(node, prefix) {
  5167. var className = node.getAttribute('class') || '';
  5168. return className.split(/\s+/).filter(function (name) {
  5169. return name.indexOf(prefix + "-") === 0;
  5170. });
  5171. }
  5172. var ClassAttributor = /** @class */ (function (_super) {
  5173. __extends(ClassAttributor, _super);
  5174. function ClassAttributor() {
  5175. return _super !== null && _super.apply(this, arguments) || this;
  5176. }
  5177. ClassAttributor.keys = function (node) {
  5178. return (node.getAttribute('class') || '').split(/\s+/).map(function (name) {
  5179. return name
  5180. .split('-')
  5181. .slice(0, -1)
  5182. .join('-');
  5183. });
  5184. };
  5185. ClassAttributor.prototype.add = function (node, value) {
  5186. if (!this.canAdd(node, value))
  5187. return false;
  5188. this.remove(node);
  5189. node.classList.add(this.keyName + "-" + value);
  5190. return true;
  5191. };
  5192. ClassAttributor.prototype.remove = function (node) {
  5193. var matches = match(node, this.keyName);
  5194. matches.forEach(function (name) {
  5195. node.classList.remove(name);
  5196. });
  5197. if (node.classList.length === 0) {
  5198. node.removeAttribute('class');
  5199. }
  5200. };
  5201. ClassAttributor.prototype.value = function (node) {
  5202. var result = match(node, this.keyName)[0] || '';
  5203. var value = result.slice(this.keyName.length + 1); // +1 for hyphen
  5204. return this.canAdd(node, value) ? value : '';
  5205. };
  5206. return ClassAttributor;
  5207. }(attributor_1.default));
  5208. exports.default = ClassAttributor;
  5209. /***/ }),
  5210. /* 33 */
  5211. /***/ (function(module, exports, __webpack_require__) {
  5212. "use strict";
  5213. var __extends = (this && this.__extends) || (function () {
  5214. var extendStatics = Object.setPrototypeOf ||
  5215. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5216. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5217. return function (d, b) {
  5218. extendStatics(d, b);
  5219. function __() { this.constructor = d; }
  5220. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5221. };
  5222. })();
  5223. Object.defineProperty(exports, "__esModule", { value: true });
  5224. var attributor_1 = __webpack_require__(12);
  5225. function camelize(name) {
  5226. var parts = name.split('-');
  5227. var rest = parts
  5228. .slice(1)
  5229. .map(function (part) {
  5230. return part[0].toUpperCase() + part.slice(1);
  5231. })
  5232. .join('');
  5233. return parts[0] + rest;
  5234. }
  5235. var StyleAttributor = /** @class */ (function (_super) {
  5236. __extends(StyleAttributor, _super);
  5237. function StyleAttributor() {
  5238. return _super !== null && _super.apply(this, arguments) || this;
  5239. }
  5240. StyleAttributor.keys = function (node) {
  5241. return (node.getAttribute('style') || '').split(';').map(function (value) {
  5242. var arr = value.split(':');
  5243. return arr[0].trim();
  5244. });
  5245. };
  5246. StyleAttributor.prototype.add = function (node, value) {
  5247. if (!this.canAdd(node, value))
  5248. return false;
  5249. // @ts-ignore
  5250. node.style[camelize(this.keyName)] = value;
  5251. return true;
  5252. };
  5253. StyleAttributor.prototype.remove = function (node) {
  5254. // @ts-ignore
  5255. node.style[camelize(this.keyName)] = '';
  5256. if (!node.getAttribute('style')) {
  5257. node.removeAttribute('style');
  5258. }
  5259. };
  5260. StyleAttributor.prototype.value = function (node) {
  5261. // @ts-ignore
  5262. var value = node.style[camelize(this.keyName)];
  5263. return this.canAdd(node, value) ? value : '';
  5264. };
  5265. return StyleAttributor;
  5266. }(attributor_1.default));
  5267. exports.default = StyleAttributor;
  5268. /***/ }),
  5269. /* 34 */
  5270. /***/ (function(module, exports, __webpack_require__) {
  5271. "use strict";
  5272. Object.defineProperty(exports, "__esModule", {
  5273. value: true
  5274. });
  5275. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  5276. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5277. var Theme = function () {
  5278. function Theme(quill, options) {
  5279. _classCallCheck(this, Theme);
  5280. this.quill = quill;
  5281. this.options = options;
  5282. this.modules = {};
  5283. }
  5284. _createClass(Theme, [{
  5285. key: 'init',
  5286. value: function init() {
  5287. var _this = this;
  5288. Object.keys(this.options.modules).forEach(function (name) {
  5289. if (_this.modules[name] == null) {
  5290. _this.addModule(name);
  5291. }
  5292. });
  5293. }
  5294. }, {
  5295. key: 'addModule',
  5296. value: function addModule(name) {
  5297. var moduleClass = this.quill.constructor.import('modules/' + name);
  5298. this.modules[name] = new moduleClass(this.quill, this.options.modules[name] || {});
  5299. return this.modules[name];
  5300. }
  5301. }]);
  5302. return Theme;
  5303. }();
  5304. Theme.DEFAULTS = {
  5305. modules: {}
  5306. };
  5307. Theme.themes = {
  5308. 'default': Theme
  5309. };
  5310. exports.default = Theme;
  5311. /***/ }),
  5312. /* 35 */
  5313. /***/ (function(module, exports, __webpack_require__) {
  5314. "use strict";
  5315. Object.defineProperty(exports, "__esModule", {
  5316. value: true
  5317. });
  5318. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  5319. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  5320. var _parchment = __webpack_require__(0);
  5321. var _parchment2 = _interopRequireDefault(_parchment);
  5322. var _text = __webpack_require__(7);
  5323. var _text2 = _interopRequireDefault(_text);
  5324. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5325. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5326. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  5327. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5328. var GUARD_TEXT = '\uFEFF';
  5329. var Embed = function (_Parchment$Embed) {
  5330. _inherits(Embed, _Parchment$Embed);
  5331. function Embed(node) {
  5332. _classCallCheck(this, Embed);
  5333. var _this = _possibleConstructorReturn(this, (Embed.__proto__ || Object.getPrototypeOf(Embed)).call(this, node));
  5334. _this.contentNode = document.createElement('span');
  5335. _this.contentNode.setAttribute('contenteditable', false);
  5336. [].slice.call(_this.domNode.childNodes).forEach(function (childNode) {
  5337. _this.contentNode.appendChild(childNode);
  5338. });
  5339. _this.leftGuard = document.createTextNode(GUARD_TEXT);
  5340. _this.rightGuard = document.createTextNode(GUARD_TEXT);
  5341. _this.domNode.appendChild(_this.leftGuard);
  5342. _this.domNode.appendChild(_this.contentNode);
  5343. _this.domNode.appendChild(_this.rightGuard);
  5344. return _this;
  5345. }
  5346. _createClass(Embed, [{
  5347. key: 'index',
  5348. value: function index(node, offset) {
  5349. if (node === this.leftGuard) return 0;
  5350. if (node === this.rightGuard) return 1;
  5351. return _get(Embed.prototype.__proto__ || Object.getPrototypeOf(Embed.prototype), 'index', this).call(this, node, offset);
  5352. }
  5353. }, {
  5354. key: 'restore',
  5355. value: function restore(node) {
  5356. var range = void 0,
  5357. textNode = void 0;
  5358. var text = node.data.split(GUARD_TEXT).join('');
  5359. if (node === this.leftGuard) {
  5360. if (this.prev instanceof _text2.default) {
  5361. var prevLength = this.prev.length();
  5362. this.prev.insertAt(prevLength, text);
  5363. range = {
  5364. startNode: this.prev.domNode,
  5365. startOffset: prevLength + text.length
  5366. };
  5367. } else {
  5368. textNode = document.createTextNode(text);
  5369. this.parent.insertBefore(_parchment2.default.create(textNode), this);
  5370. range = {
  5371. startNode: textNode,
  5372. startOffset: text.length
  5373. };
  5374. }
  5375. } else if (node === this.rightGuard) {
  5376. if (this.next instanceof _text2.default) {
  5377. this.next.insertAt(0, text);
  5378. range = {
  5379. startNode: this.next.domNode,
  5380. startOffset: text.length
  5381. };
  5382. } else {
  5383. textNode = document.createTextNode(text);
  5384. this.parent.insertBefore(_parchment2.default.create(textNode), this.next);
  5385. range = {
  5386. startNode: textNode,
  5387. startOffset: text.length
  5388. };
  5389. }
  5390. }
  5391. node.data = GUARD_TEXT;
  5392. return range;
  5393. }
  5394. }, {
  5395. key: 'update',
  5396. value: function update(mutations, context) {
  5397. var _this2 = this;
  5398. mutations.forEach(function (mutation) {
  5399. if (mutation.type === 'characterData' && (mutation.target === _this2.leftGuard || mutation.target === _this2.rightGuard)) {
  5400. var range = _this2.restore(mutation.target);
  5401. if (range) context.range = range;
  5402. }
  5403. });
  5404. }
  5405. }]);
  5406. return Embed;
  5407. }(_parchment2.default.Embed);
  5408. exports.default = Embed;
  5409. /***/ }),
  5410. /* 36 */
  5411. /***/ (function(module, exports, __webpack_require__) {
  5412. "use strict";
  5413. Object.defineProperty(exports, "__esModule", {
  5414. value: true
  5415. });
  5416. exports.AlignStyle = exports.AlignClass = exports.AlignAttribute = undefined;
  5417. var _parchment = __webpack_require__(0);
  5418. var _parchment2 = _interopRequireDefault(_parchment);
  5419. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5420. var config = {
  5421. scope: _parchment2.default.Scope.BLOCK,
  5422. whitelist: ['right', 'center', 'justify']
  5423. };
  5424. var AlignAttribute = new _parchment2.default.Attributor.Attribute('align', 'align', config);
  5425. var AlignClass = new _parchment2.default.Attributor.Class('align', 'ql-align', config);
  5426. var AlignStyle = new _parchment2.default.Attributor.Style('align', 'text-align', config);
  5427. exports.AlignAttribute = AlignAttribute;
  5428. exports.AlignClass = AlignClass;
  5429. exports.AlignStyle = AlignStyle;
  5430. /***/ }),
  5431. /* 37 */
  5432. /***/ (function(module, exports, __webpack_require__) {
  5433. "use strict";
  5434. Object.defineProperty(exports, "__esModule", {
  5435. value: true
  5436. });
  5437. exports.BackgroundStyle = exports.BackgroundClass = undefined;
  5438. var _parchment = __webpack_require__(0);
  5439. var _parchment2 = _interopRequireDefault(_parchment);
  5440. var _color = __webpack_require__(26);
  5441. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5442. var BackgroundClass = new _parchment2.default.Attributor.Class('background', 'ql-bg', {
  5443. scope: _parchment2.default.Scope.INLINE
  5444. });
  5445. var BackgroundStyle = new _color.ColorAttributor('background', 'background-color', {
  5446. scope: _parchment2.default.Scope.INLINE
  5447. });
  5448. exports.BackgroundClass = BackgroundClass;
  5449. exports.BackgroundStyle = BackgroundStyle;
  5450. /***/ }),
  5451. /* 38 */
  5452. /***/ (function(module, exports, __webpack_require__) {
  5453. "use strict";
  5454. Object.defineProperty(exports, "__esModule", {
  5455. value: true
  5456. });
  5457. exports.DirectionStyle = exports.DirectionClass = exports.DirectionAttribute = undefined;
  5458. var _parchment = __webpack_require__(0);
  5459. var _parchment2 = _interopRequireDefault(_parchment);
  5460. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5461. var config = {
  5462. scope: _parchment2.default.Scope.BLOCK,
  5463. whitelist: ['rtl']
  5464. };
  5465. var DirectionAttribute = new _parchment2.default.Attributor.Attribute('direction', 'dir', config);
  5466. var DirectionClass = new _parchment2.default.Attributor.Class('direction', 'ql-direction', config);
  5467. var DirectionStyle = new _parchment2.default.Attributor.Style('direction', 'direction', config);
  5468. exports.DirectionAttribute = DirectionAttribute;
  5469. exports.DirectionClass = DirectionClass;
  5470. exports.DirectionStyle = DirectionStyle;
  5471. /***/ }),
  5472. /* 39 */
  5473. /***/ (function(module, exports, __webpack_require__) {
  5474. "use strict";
  5475. Object.defineProperty(exports, "__esModule", {
  5476. value: true
  5477. });
  5478. exports.FontClass = exports.FontStyle = undefined;
  5479. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  5480. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  5481. var _parchment = __webpack_require__(0);
  5482. var _parchment2 = _interopRequireDefault(_parchment);
  5483. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5484. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5485. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  5486. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5487. var config = {
  5488. scope: _parchment2.default.Scope.INLINE,
  5489. whitelist: ['serif', 'monospace']
  5490. };
  5491. var FontClass = new _parchment2.default.Attributor.Class('font', 'ql-font', config);
  5492. var FontStyleAttributor = function (_Parchment$Attributor) {
  5493. _inherits(FontStyleAttributor, _Parchment$Attributor);
  5494. function FontStyleAttributor() {
  5495. _classCallCheck(this, FontStyleAttributor);
  5496. return _possibleConstructorReturn(this, (FontStyleAttributor.__proto__ || Object.getPrototypeOf(FontStyleAttributor)).apply(this, arguments));
  5497. }
  5498. _createClass(FontStyleAttributor, [{
  5499. key: 'value',
  5500. value: function value(node) {
  5501. return _get(FontStyleAttributor.prototype.__proto__ || Object.getPrototypeOf(FontStyleAttributor.prototype), 'value', this).call(this, node).replace(/["']/g, '');
  5502. }
  5503. }]);
  5504. return FontStyleAttributor;
  5505. }(_parchment2.default.Attributor.Style);
  5506. var FontStyle = new FontStyleAttributor('font', 'font-family', config);
  5507. exports.FontStyle = FontStyle;
  5508. exports.FontClass = FontClass;
  5509. /***/ }),
  5510. /* 40 */
  5511. /***/ (function(module, exports, __webpack_require__) {
  5512. "use strict";
  5513. Object.defineProperty(exports, "__esModule", {
  5514. value: true
  5515. });
  5516. exports.SizeStyle = exports.SizeClass = undefined;
  5517. var _parchment = __webpack_require__(0);
  5518. var _parchment2 = _interopRequireDefault(_parchment);
  5519. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5520. var SizeClass = new _parchment2.default.Attributor.Class('size', 'ql-size', {
  5521. scope: _parchment2.default.Scope.INLINE,
  5522. whitelist: ['small', 'large', 'huge']
  5523. });
  5524. var SizeStyle = new _parchment2.default.Attributor.Style('size', 'font-size', {
  5525. scope: _parchment2.default.Scope.INLINE,
  5526. whitelist: ['10px', '18px', '32px']
  5527. });
  5528. exports.SizeClass = SizeClass;
  5529. exports.SizeStyle = SizeStyle;
  5530. /***/ }),
  5531. /* 41 */
  5532. /***/ (function(module, exports, __webpack_require__) {
  5533. "use strict";
  5534. module.exports = {
  5535. 'align': {
  5536. '': __webpack_require__(76),
  5537. 'center': __webpack_require__(77),
  5538. 'right': __webpack_require__(78),
  5539. 'justify': __webpack_require__(79)
  5540. },
  5541. 'background': __webpack_require__(80),
  5542. 'blockquote': __webpack_require__(81),
  5543. 'bold': __webpack_require__(82),
  5544. 'clean': __webpack_require__(83),
  5545. 'code': __webpack_require__(58),
  5546. 'code-block': __webpack_require__(58),
  5547. 'color': __webpack_require__(84),
  5548. 'direction': {
  5549. '': __webpack_require__(85),
  5550. 'rtl': __webpack_require__(86)
  5551. },
  5552. 'float': {
  5553. 'center': __webpack_require__(87),
  5554. 'full': __webpack_require__(88),
  5555. 'left': __webpack_require__(89),
  5556. 'right': __webpack_require__(90)
  5557. },
  5558. 'formula': __webpack_require__(91),
  5559. 'header': {
  5560. '1': __webpack_require__(92),
  5561. '2': __webpack_require__(93)
  5562. },
  5563. 'italic': __webpack_require__(94),
  5564. 'image': __webpack_require__(95),
  5565. 'indent': {
  5566. '+1': __webpack_require__(96),
  5567. '-1': __webpack_require__(97)
  5568. },
  5569. 'link': __webpack_require__(98),
  5570. 'list': {
  5571. 'ordered': __webpack_require__(99),
  5572. 'bullet': __webpack_require__(100),
  5573. 'check': __webpack_require__(101)
  5574. },
  5575. 'script': {
  5576. 'sub': __webpack_require__(102),
  5577. 'super': __webpack_require__(103)
  5578. },
  5579. 'strike': __webpack_require__(104),
  5580. 'underline': __webpack_require__(105),
  5581. 'video': __webpack_require__(106)
  5582. };
  5583. /***/ }),
  5584. /* 42 */
  5585. /***/ (function(module, exports, __webpack_require__) {
  5586. "use strict";
  5587. Object.defineProperty(exports, "__esModule", {
  5588. value: true
  5589. });
  5590. exports.getLastChangeIndex = exports.default = undefined;
  5591. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  5592. var _parchment = __webpack_require__(0);
  5593. var _parchment2 = _interopRequireDefault(_parchment);
  5594. var _quill = __webpack_require__(5);
  5595. var _quill2 = _interopRequireDefault(_quill);
  5596. var _module = __webpack_require__(9);
  5597. var _module2 = _interopRequireDefault(_module);
  5598. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5599. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5600. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  5601. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5602. var History = function (_Module) {
  5603. _inherits(History, _Module);
  5604. function History(quill, options) {
  5605. _classCallCheck(this, History);
  5606. var _this = _possibleConstructorReturn(this, (History.__proto__ || Object.getPrototypeOf(History)).call(this, quill, options));
  5607. _this.lastRecorded = 0;
  5608. _this.ignoreChange = false;
  5609. _this.clear();
  5610. _this.quill.on(_quill2.default.events.EDITOR_CHANGE, function (eventName, delta, oldDelta, source) {
  5611. if (eventName !== _quill2.default.events.TEXT_CHANGE || _this.ignoreChange) return;
  5612. if (!_this.options.userOnly || source === _quill2.default.sources.USER) {
  5613. _this.record(delta, oldDelta);
  5614. } else {
  5615. _this.transform(delta);
  5616. }
  5617. });
  5618. _this.quill.keyboard.addBinding({ key: 'Z', shortKey: true }, _this.undo.bind(_this));
  5619. _this.quill.keyboard.addBinding({ key: 'Z', shortKey: true, shiftKey: true }, _this.redo.bind(_this));
  5620. if (/Win/i.test(navigator.platform)) {
  5621. _this.quill.keyboard.addBinding({ key: 'Y', shortKey: true }, _this.redo.bind(_this));
  5622. }
  5623. return _this;
  5624. }
  5625. _createClass(History, [{
  5626. key: 'change',
  5627. value: function change(source, dest) {
  5628. if (this.stack[source].length === 0) return;
  5629. var delta = this.stack[source].pop();
  5630. this.stack[dest].push(delta);
  5631. this.lastRecorded = 0;
  5632. this.ignoreChange = true;
  5633. this.quill.updateContents(delta[source], _quill2.default.sources.USER);
  5634. this.ignoreChange = false;
  5635. var index = getLastChangeIndex(delta[source]);
  5636. this.quill.setSelection(index);
  5637. }
  5638. }, {
  5639. key: 'clear',
  5640. value: function clear() {
  5641. this.stack = { undo: [], redo: [] };
  5642. }
  5643. }, {
  5644. key: 'cutoff',
  5645. value: function cutoff() {
  5646. this.lastRecorded = 0;
  5647. }
  5648. }, {
  5649. key: 'record',
  5650. value: function record(changeDelta, oldDelta) {
  5651. if (changeDelta.ops.length === 0) return;
  5652. this.stack.redo = [];
  5653. var undoDelta = this.quill.getContents().diff(oldDelta);
  5654. var timestamp = Date.now();
  5655. if (this.lastRecorded + this.options.delay > timestamp && this.stack.undo.length > 0) {
  5656. var delta = this.stack.undo.pop();
  5657. undoDelta = undoDelta.compose(delta.undo);
  5658. changeDelta = delta.redo.compose(changeDelta);
  5659. } else {
  5660. this.lastRecorded = timestamp;
  5661. }
  5662. this.stack.undo.push({
  5663. redo: changeDelta,
  5664. undo: undoDelta
  5665. });
  5666. if (this.stack.undo.length > this.options.maxStack) {
  5667. this.stack.undo.shift();
  5668. }
  5669. }
  5670. }, {
  5671. key: 'redo',
  5672. value: function redo() {
  5673. this.change('redo', 'undo');
  5674. }
  5675. }, {
  5676. key: 'transform',
  5677. value: function transform(delta) {
  5678. this.stack.undo.forEach(function (change) {
  5679. change.undo = delta.transform(change.undo, true);
  5680. change.redo = delta.transform(change.redo, true);
  5681. });
  5682. this.stack.redo.forEach(function (change) {
  5683. change.undo = delta.transform(change.undo, true);
  5684. change.redo = delta.transform(change.redo, true);
  5685. });
  5686. }
  5687. }, {
  5688. key: 'undo',
  5689. value: function undo() {
  5690. this.change('undo', 'redo');
  5691. }
  5692. }]);
  5693. return History;
  5694. }(_module2.default);
  5695. History.DEFAULTS = {
  5696. delay: 1000,
  5697. maxStack: 100,
  5698. userOnly: false
  5699. };
  5700. function endsWithNewlineChange(delta) {
  5701. var lastOp = delta.ops[delta.ops.length - 1];
  5702. if (lastOp == null) return false;
  5703. if (lastOp.insert != null) {
  5704. return typeof lastOp.insert === 'string' && lastOp.insert.endsWith('\n');
  5705. }
  5706. if (lastOp.attributes != null) {
  5707. return Object.keys(lastOp.attributes).some(function (attr) {
  5708. return _parchment2.default.query(attr, _parchment2.default.Scope.BLOCK) != null;
  5709. });
  5710. }
  5711. return false;
  5712. }
  5713. function getLastChangeIndex(delta) {
  5714. var deleteLength = delta.reduce(function (length, op) {
  5715. length += op.delete || 0;
  5716. return length;
  5717. }, 0);
  5718. var changeIndex = delta.length() - deleteLength;
  5719. if (endsWithNewlineChange(delta)) {
  5720. changeIndex -= 1;
  5721. }
  5722. return changeIndex;
  5723. }
  5724. exports.default = History;
  5725. exports.getLastChangeIndex = getLastChangeIndex;
  5726. /***/ }),
  5727. /* 43 */
  5728. /***/ (function(module, exports, __webpack_require__) {
  5729. "use strict";
  5730. Object.defineProperty(exports, "__esModule", {
  5731. value: true
  5732. });
  5733. exports.default = exports.BaseTooltip = undefined;
  5734. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  5735. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  5736. var _extend = __webpack_require__(3);
  5737. var _extend2 = _interopRequireDefault(_extend);
  5738. var _quillDelta = __webpack_require__(2);
  5739. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  5740. var _emitter = __webpack_require__(8);
  5741. var _emitter2 = _interopRequireDefault(_emitter);
  5742. var _keyboard = __webpack_require__(23);
  5743. var _keyboard2 = _interopRequireDefault(_keyboard);
  5744. var _theme = __webpack_require__(34);
  5745. var _theme2 = _interopRequireDefault(_theme);
  5746. var _colorPicker = __webpack_require__(59);
  5747. var _colorPicker2 = _interopRequireDefault(_colorPicker);
  5748. var _iconPicker = __webpack_require__(60);
  5749. var _iconPicker2 = _interopRequireDefault(_iconPicker);
  5750. var _picker = __webpack_require__(28);
  5751. var _picker2 = _interopRequireDefault(_picker);
  5752. var _tooltip = __webpack_require__(61);
  5753. var _tooltip2 = _interopRequireDefault(_tooltip);
  5754. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5755. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5756. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  5757. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5758. var ALIGNS = [false, 'center', 'right', 'justify'];
  5759. var COLORS = ["#000000", "#e60000", "#ff9900", "#ffff00", "#008a00", "#0066cc", "#9933ff", "#ffffff", "#facccc", "#ffebcc", "#ffffcc", "#cce8cc", "#cce0f5", "#ebd6ff", "#bbbbbb", "#f06666", "#ffc266", "#ffff66", "#66b966", "#66a3e0", "#c285ff", "#888888", "#a10000", "#b26b00", "#b2b200", "#006100", "#0047b2", "#6b24b2", "#444444", "#5c0000", "#663d00", "#666600", "#003700", "#002966", "#3d1466"];
  5760. var FONTS = [false, 'serif', 'monospace'];
  5761. var HEADERS = ['1', '2', '3', false];
  5762. var SIZES = ['small', false, 'large', 'huge'];
  5763. var BaseTheme = function (_Theme) {
  5764. _inherits(BaseTheme, _Theme);
  5765. function BaseTheme(quill, options) {
  5766. _classCallCheck(this, BaseTheme);
  5767. var _this = _possibleConstructorReturn(this, (BaseTheme.__proto__ || Object.getPrototypeOf(BaseTheme)).call(this, quill, options));
  5768. var listener = function listener(e) {
  5769. if (!document.body.contains(quill.root)) {
  5770. return document.body.removeEventListener('click', listener);
  5771. }
  5772. if (_this.tooltip != null && !_this.tooltip.root.contains(e.target) && document.activeElement !== _this.tooltip.textbox && !_this.quill.hasFocus()) {
  5773. _this.tooltip.hide();
  5774. }
  5775. if (_this.pickers != null) {
  5776. _this.pickers.forEach(function (picker) {
  5777. if (!picker.container.contains(e.target)) {
  5778. picker.close();
  5779. }
  5780. });
  5781. }
  5782. };
  5783. quill.emitter.listenDOM('click', document.body, listener);
  5784. return _this;
  5785. }
  5786. _createClass(BaseTheme, [{
  5787. key: 'addModule',
  5788. value: function addModule(name) {
  5789. var module = _get(BaseTheme.prototype.__proto__ || Object.getPrototypeOf(BaseTheme.prototype), 'addModule', this).call(this, name);
  5790. if (name === 'toolbar') {
  5791. this.extendToolbar(module);
  5792. }
  5793. return module;
  5794. }
  5795. }, {
  5796. key: 'buildButtons',
  5797. value: function buildButtons(buttons, icons) {
  5798. buttons.forEach(function (button) {
  5799. var className = button.getAttribute('class') || '';
  5800. className.split(/\s+/).forEach(function (name) {
  5801. if (!name.startsWith('ql-')) return;
  5802. name = name.slice('ql-'.length);
  5803. if (icons[name] == null) return;
  5804. if (name === 'direction') {
  5805. button.innerHTML = icons[name][''] + icons[name]['rtl'];
  5806. } else if (typeof icons[name] === 'string') {
  5807. button.innerHTML = icons[name];
  5808. } else {
  5809. var value = button.value || '';
  5810. if (value != null && icons[name][value]) {
  5811. button.innerHTML = icons[name][value];
  5812. }
  5813. }
  5814. });
  5815. });
  5816. }
  5817. }, {
  5818. key: 'buildPickers',
  5819. value: function buildPickers(selects, icons) {
  5820. var _this2 = this;
  5821. this.pickers = selects.map(function (select) {
  5822. if (select.classList.contains('ql-align')) {
  5823. if (select.querySelector('option') == null) {
  5824. fillSelect(select, ALIGNS);
  5825. }
  5826. return new _iconPicker2.default(select, icons.align);
  5827. } else if (select.classList.contains('ql-background') || select.classList.contains('ql-color')) {
  5828. var format = select.classList.contains('ql-background') ? 'background' : 'color';
  5829. if (select.querySelector('option') == null) {
  5830. fillSelect(select, COLORS, format === 'background' ? '#ffffff' : '#000000');
  5831. }
  5832. return new _colorPicker2.default(select, icons[format]);
  5833. } else {
  5834. if (select.querySelector('option') == null) {
  5835. if (select.classList.contains('ql-font')) {
  5836. fillSelect(select, FONTS);
  5837. } else if (select.classList.contains('ql-header')) {
  5838. fillSelect(select, HEADERS);
  5839. } else if (select.classList.contains('ql-size')) {
  5840. fillSelect(select, SIZES);
  5841. }
  5842. }
  5843. return new _picker2.default(select);
  5844. }
  5845. });
  5846. var update = function update() {
  5847. _this2.pickers.forEach(function (picker) {
  5848. picker.update();
  5849. });
  5850. };
  5851. this.quill.on(_emitter2.default.events.EDITOR_CHANGE, update);
  5852. }
  5853. }]);
  5854. return BaseTheme;
  5855. }(_theme2.default);
  5856. BaseTheme.DEFAULTS = (0, _extend2.default)(true, {}, _theme2.default.DEFAULTS, {
  5857. modules: {
  5858. toolbar: {
  5859. handlers: {
  5860. formula: function formula() {
  5861. this.quill.theme.tooltip.edit('formula');
  5862. },
  5863. image: function image() {
  5864. var _this3 = this;
  5865. var fileInput = this.container.querySelector('input.ql-image[type=file]');
  5866. if (fileInput == null) {
  5867. fileInput = document.createElement('input');
  5868. fileInput.setAttribute('type', 'file');
  5869. fileInput.setAttribute('accept', 'image/png, image/gif, image/jpeg, image/bmp, image/x-icon');
  5870. fileInput.classList.add('ql-image');
  5871. fileInput.addEventListener('change', function () {
  5872. if (fileInput.files != null && fileInput.files[0] != null) {
  5873. var reader = new FileReader();
  5874. reader.onload = function (e) {
  5875. var range = _this3.quill.getSelection(true);
  5876. _this3.quill.updateContents(new _quillDelta2.default().retain(range.index).delete(range.length).insert({ image: e.target.result }), _emitter2.default.sources.USER);
  5877. _this3.quill.setSelection(range.index + 1, _emitter2.default.sources.SILENT);
  5878. fileInput.value = "";
  5879. };
  5880. reader.readAsDataURL(fileInput.files[0]);
  5881. }
  5882. });
  5883. this.container.appendChild(fileInput);
  5884. }
  5885. fileInput.click();
  5886. },
  5887. video: function video() {
  5888. this.quill.theme.tooltip.edit('video');
  5889. }
  5890. }
  5891. }
  5892. }
  5893. });
  5894. var BaseTooltip = function (_Tooltip) {
  5895. _inherits(BaseTooltip, _Tooltip);
  5896. function BaseTooltip(quill, boundsContainer) {
  5897. _classCallCheck(this, BaseTooltip);
  5898. var _this4 = _possibleConstructorReturn(this, (BaseTooltip.__proto__ || Object.getPrototypeOf(BaseTooltip)).call(this, quill, boundsContainer));
  5899. _this4.textbox = _this4.root.querySelector('input[type="text"]');
  5900. _this4.listen();
  5901. return _this4;
  5902. }
  5903. _createClass(BaseTooltip, [{
  5904. key: 'listen',
  5905. value: function listen() {
  5906. var _this5 = this;
  5907. this.textbox.addEventListener('keydown', function (event) {
  5908. if (_keyboard2.default.match(event, 'enter')) {
  5909. _this5.save();
  5910. event.preventDefault();
  5911. } else if (_keyboard2.default.match(event, 'escape')) {
  5912. _this5.cancel();
  5913. event.preventDefault();
  5914. }
  5915. });
  5916. }
  5917. }, {
  5918. key: 'cancel',
  5919. value: function cancel() {
  5920. this.hide();
  5921. }
  5922. }, {
  5923. key: 'edit',
  5924. value: function edit() {
  5925. var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'link';
  5926. var preview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5927. this.root.classList.remove('ql-hidden');
  5928. this.root.classList.add('ql-editing');
  5929. if (preview != null) {
  5930. this.textbox.value = preview;
  5931. } else if (mode !== this.root.getAttribute('data-mode')) {
  5932. this.textbox.value = '';
  5933. }
  5934. this.position(this.quill.getBounds(this.quill.selection.savedRange));
  5935. this.textbox.select();
  5936. this.textbox.setAttribute('placeholder', this.textbox.getAttribute('data-' + mode) || '');
  5937. this.root.setAttribute('data-mode', mode);
  5938. }
  5939. }, {
  5940. key: 'restoreFocus',
  5941. value: function restoreFocus() {
  5942. var scrollTop = this.quill.scrollingContainer.scrollTop;
  5943. this.quill.focus();
  5944. this.quill.scrollingContainer.scrollTop = scrollTop;
  5945. }
  5946. }, {
  5947. key: 'save',
  5948. value: function save() {
  5949. var value = this.textbox.value;
  5950. switch (this.root.getAttribute('data-mode')) {
  5951. case 'link':
  5952. {
  5953. var scrollTop = this.quill.root.scrollTop;
  5954. if (this.linkRange) {
  5955. this.quill.formatText(this.linkRange, 'link', value, _emitter2.default.sources.USER);
  5956. delete this.linkRange;
  5957. } else {
  5958. this.restoreFocus();
  5959. this.quill.format('link', value, _emitter2.default.sources.USER);
  5960. }
  5961. this.quill.root.scrollTop = scrollTop;
  5962. break;
  5963. }
  5964. case 'video':
  5965. {
  5966. value = extractVideoUrl(value);
  5967. } // eslint-disable-next-line no-fallthrough
  5968. case 'formula':
  5969. {
  5970. if (!value) break;
  5971. var range = this.quill.getSelection(true);
  5972. if (range != null) {
  5973. var index = range.index + range.length;
  5974. this.quill.insertEmbed(index, this.root.getAttribute('data-mode'), value, _emitter2.default.sources.USER);
  5975. if (this.root.getAttribute('data-mode') === 'formula') {
  5976. this.quill.insertText(index + 1, ' ', _emitter2.default.sources.USER);
  5977. }
  5978. this.quill.setSelection(index + 2, _emitter2.default.sources.USER);
  5979. }
  5980. break;
  5981. }
  5982. default:
  5983. }
  5984. this.textbox.value = '';
  5985. this.hide();
  5986. }
  5987. }]);
  5988. return BaseTooltip;
  5989. }(_tooltip2.default);
  5990. function extractVideoUrl(url) {
  5991. var match = url.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/) || url.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);
  5992. if (match) {
  5993. return (match[1] || 'https') + '://www.youtube.com/embed/' + match[2] + '?showinfo=0';
  5994. }
  5995. if (match = url.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/)) {
  5996. // eslint-disable-line no-cond-assign
  5997. return (match[1] || 'https') + '://player.vimeo.com/video/' + match[2] + '/';
  5998. }
  5999. return url;
  6000. }
  6001. function fillSelect(select, values) {
  6002. var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6003. values.forEach(function (value) {
  6004. var option = document.createElement('option');
  6005. if (value === defaultValue) {
  6006. option.setAttribute('selected', 'selected');
  6007. } else {
  6008. option.setAttribute('value', value);
  6009. }
  6010. select.appendChild(option);
  6011. });
  6012. }
  6013. exports.BaseTooltip = BaseTooltip;
  6014. exports.default = BaseTheme;
  6015. /***/ }),
  6016. /* 44 */
  6017. /***/ (function(module, exports, __webpack_require__) {
  6018. "use strict";
  6019. Object.defineProperty(exports, "__esModule", { value: true });
  6020. var LinkedList = /** @class */ (function () {
  6021. function LinkedList() {
  6022. this.head = this.tail = null;
  6023. this.length = 0;
  6024. }
  6025. LinkedList.prototype.append = function () {
  6026. var nodes = [];
  6027. for (var _i = 0; _i < arguments.length; _i++) {
  6028. nodes[_i] = arguments[_i];
  6029. }
  6030. this.insertBefore(nodes[0], null);
  6031. if (nodes.length > 1) {
  6032. this.append.apply(this, nodes.slice(1));
  6033. }
  6034. };
  6035. LinkedList.prototype.contains = function (node) {
  6036. var cur, next = this.iterator();
  6037. while ((cur = next())) {
  6038. if (cur === node)
  6039. return true;
  6040. }
  6041. return false;
  6042. };
  6043. LinkedList.prototype.insertBefore = function (node, refNode) {
  6044. if (!node)
  6045. return;
  6046. node.next = refNode;
  6047. if (refNode != null) {
  6048. node.prev = refNode.prev;
  6049. if (refNode.prev != null) {
  6050. refNode.prev.next = node;
  6051. }
  6052. refNode.prev = node;
  6053. if (refNode === this.head) {
  6054. this.head = node;
  6055. }
  6056. }
  6057. else if (this.tail != null) {
  6058. this.tail.next = node;
  6059. node.prev = this.tail;
  6060. this.tail = node;
  6061. }
  6062. else {
  6063. node.prev = null;
  6064. this.head = this.tail = node;
  6065. }
  6066. this.length += 1;
  6067. };
  6068. LinkedList.prototype.offset = function (target) {
  6069. var index = 0, cur = this.head;
  6070. while (cur != null) {
  6071. if (cur === target)
  6072. return index;
  6073. index += cur.length();
  6074. cur = cur.next;
  6075. }
  6076. return -1;
  6077. };
  6078. LinkedList.prototype.remove = function (node) {
  6079. if (!this.contains(node))
  6080. return;
  6081. if (node.prev != null)
  6082. node.prev.next = node.next;
  6083. if (node.next != null)
  6084. node.next.prev = node.prev;
  6085. if (node === this.head)
  6086. this.head = node.next;
  6087. if (node === this.tail)
  6088. this.tail = node.prev;
  6089. this.length -= 1;
  6090. };
  6091. LinkedList.prototype.iterator = function (curNode) {
  6092. if (curNode === void 0) { curNode = this.head; }
  6093. // TODO use yield when we can
  6094. return function () {
  6095. var ret = curNode;
  6096. if (curNode != null)
  6097. curNode = curNode.next;
  6098. return ret;
  6099. };
  6100. };
  6101. LinkedList.prototype.find = function (index, inclusive) {
  6102. if (inclusive === void 0) { inclusive = false; }
  6103. var cur, next = this.iterator();
  6104. while ((cur = next())) {
  6105. var length = cur.length();
  6106. if (index < length ||
  6107. (inclusive && index === length && (cur.next == null || cur.next.length() !== 0))) {
  6108. return [cur, index];
  6109. }
  6110. index -= length;
  6111. }
  6112. return [null, 0];
  6113. };
  6114. LinkedList.prototype.forEach = function (callback) {
  6115. var cur, next = this.iterator();
  6116. while ((cur = next())) {
  6117. callback(cur);
  6118. }
  6119. };
  6120. LinkedList.prototype.forEachAt = function (index, length, callback) {
  6121. if (length <= 0)
  6122. return;
  6123. var _a = this.find(index), startNode = _a[0], offset = _a[1];
  6124. var cur, curIndex = index - offset, next = this.iterator(startNode);
  6125. while ((cur = next()) && curIndex < index + length) {
  6126. var curLength = cur.length();
  6127. if (index > curIndex) {
  6128. callback(cur, index - curIndex, Math.min(length, curIndex + curLength - index));
  6129. }
  6130. else {
  6131. callback(cur, 0, Math.min(curLength, index + length - curIndex));
  6132. }
  6133. curIndex += curLength;
  6134. }
  6135. };
  6136. LinkedList.prototype.map = function (callback) {
  6137. return this.reduce(function (memo, cur) {
  6138. memo.push(callback(cur));
  6139. return memo;
  6140. }, []);
  6141. };
  6142. LinkedList.prototype.reduce = function (callback, memo) {
  6143. var cur, next = this.iterator();
  6144. while ((cur = next())) {
  6145. memo = callback(memo, cur);
  6146. }
  6147. return memo;
  6148. };
  6149. return LinkedList;
  6150. }());
  6151. exports.default = LinkedList;
  6152. /***/ }),
  6153. /* 45 */
  6154. /***/ (function(module, exports, __webpack_require__) {
  6155. "use strict";
  6156. var __extends = (this && this.__extends) || (function () {
  6157. var extendStatics = Object.setPrototypeOf ||
  6158. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6159. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6160. return function (d, b) {
  6161. extendStatics(d, b);
  6162. function __() { this.constructor = d; }
  6163. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6164. };
  6165. })();
  6166. Object.defineProperty(exports, "__esModule", { value: true });
  6167. var container_1 = __webpack_require__(17);
  6168. var Registry = __webpack_require__(1);
  6169. var OBSERVER_CONFIG = {
  6170. attributes: true,
  6171. characterData: true,
  6172. characterDataOldValue: true,
  6173. childList: true,
  6174. subtree: true,
  6175. };
  6176. var MAX_OPTIMIZE_ITERATIONS = 100;
  6177. var ScrollBlot = /** @class */ (function (_super) {
  6178. __extends(ScrollBlot, _super);
  6179. function ScrollBlot(node) {
  6180. var _this = _super.call(this, node) || this;
  6181. _this.scroll = _this;
  6182. _this.observer = new MutationObserver(function (mutations) {
  6183. _this.update(mutations);
  6184. });
  6185. _this.observer.observe(_this.domNode, OBSERVER_CONFIG);
  6186. _this.attach();
  6187. return _this;
  6188. }
  6189. ScrollBlot.prototype.detach = function () {
  6190. _super.prototype.detach.call(this);
  6191. this.observer.disconnect();
  6192. };
  6193. ScrollBlot.prototype.deleteAt = function (index, length) {
  6194. this.update();
  6195. if (index === 0 && length === this.length()) {
  6196. this.children.forEach(function (child) {
  6197. child.remove();
  6198. });
  6199. }
  6200. else {
  6201. _super.prototype.deleteAt.call(this, index, length);
  6202. }
  6203. };
  6204. ScrollBlot.prototype.formatAt = function (index, length, name, value) {
  6205. this.update();
  6206. _super.prototype.formatAt.call(this, index, length, name, value);
  6207. };
  6208. ScrollBlot.prototype.insertAt = function (index, value, def) {
  6209. this.update();
  6210. _super.prototype.insertAt.call(this, index, value, def);
  6211. };
  6212. ScrollBlot.prototype.optimize = function (mutations, context) {
  6213. var _this = this;
  6214. if (mutations === void 0) { mutations = []; }
  6215. if (context === void 0) { context = {}; }
  6216. _super.prototype.optimize.call(this, context);
  6217. // We must modify mutations directly, cannot make copy and then modify
  6218. var records = [].slice.call(this.observer.takeRecords());
  6219. // Array.push currently seems to be implemented by a non-tail recursive function
  6220. // so we cannot just mutations.push.apply(mutations, this.observer.takeRecords());
  6221. while (records.length > 0)
  6222. mutations.push(records.pop());
  6223. // TODO use WeakMap
  6224. var mark = function (blot, markParent) {
  6225. if (markParent === void 0) { markParent = true; }
  6226. if (blot == null || blot === _this)
  6227. return;
  6228. if (blot.domNode.parentNode == null)
  6229. return;
  6230. // @ts-ignore
  6231. if (blot.domNode[Registry.DATA_KEY].mutations == null) {
  6232. // @ts-ignore
  6233. blot.domNode[Registry.DATA_KEY].mutations = [];
  6234. }
  6235. if (markParent)
  6236. mark(blot.parent);
  6237. };
  6238. var optimize = function (blot) {
  6239. // Post-order traversal
  6240. if (
  6241. // @ts-ignore
  6242. blot.domNode[Registry.DATA_KEY] == null ||
  6243. // @ts-ignore
  6244. blot.domNode[Registry.DATA_KEY].mutations == null) {
  6245. return;
  6246. }
  6247. if (blot instanceof container_1.default) {
  6248. blot.children.forEach(optimize);
  6249. }
  6250. blot.optimize(context);
  6251. };
  6252. var remaining = mutations;
  6253. for (var i = 0; remaining.length > 0; i += 1) {
  6254. if (i >= MAX_OPTIMIZE_ITERATIONS) {
  6255. throw new Error('[Parchment] Maximum optimize iterations reached');
  6256. }
  6257. remaining.forEach(function (mutation) {
  6258. var blot = Registry.find(mutation.target, true);
  6259. if (blot == null)
  6260. return;
  6261. if (blot.domNode === mutation.target) {
  6262. if (mutation.type === 'childList') {
  6263. mark(Registry.find(mutation.previousSibling, false));
  6264. [].forEach.call(mutation.addedNodes, function (node) {
  6265. var child = Registry.find(node, false);
  6266. mark(child, false);
  6267. if (child instanceof container_1.default) {
  6268. child.children.forEach(function (grandChild) {
  6269. mark(grandChild, false);
  6270. });
  6271. }
  6272. });
  6273. }
  6274. else if (mutation.type === 'attributes') {
  6275. mark(blot.prev);
  6276. }
  6277. }
  6278. mark(blot);
  6279. });
  6280. this.children.forEach(optimize);
  6281. remaining = [].slice.call(this.observer.takeRecords());
  6282. records = remaining.slice();
  6283. while (records.length > 0)
  6284. mutations.push(records.pop());
  6285. }
  6286. };
  6287. ScrollBlot.prototype.update = function (mutations, context) {
  6288. var _this = this;
  6289. if (context === void 0) { context = {}; }
  6290. mutations = mutations || this.observer.takeRecords();
  6291. // TODO use WeakMap
  6292. mutations
  6293. .map(function (mutation) {
  6294. var blot = Registry.find(mutation.target, true);
  6295. if (blot == null)
  6296. return null;
  6297. // @ts-ignore
  6298. if (blot.domNode[Registry.DATA_KEY].mutations == null) {
  6299. // @ts-ignore
  6300. blot.domNode[Registry.DATA_KEY].mutations = [mutation];
  6301. return blot;
  6302. }
  6303. else {
  6304. // @ts-ignore
  6305. blot.domNode[Registry.DATA_KEY].mutations.push(mutation);
  6306. return null;
  6307. }
  6308. })
  6309. .forEach(function (blot) {
  6310. if (blot == null ||
  6311. blot === _this ||
  6312. //@ts-ignore
  6313. blot.domNode[Registry.DATA_KEY] == null)
  6314. return;
  6315. // @ts-ignore
  6316. blot.update(blot.domNode[Registry.DATA_KEY].mutations || [], context);
  6317. });
  6318. // @ts-ignore
  6319. if (this.domNode[Registry.DATA_KEY].mutations != null) {
  6320. // @ts-ignore
  6321. _super.prototype.update.call(this, this.domNode[Registry.DATA_KEY].mutations, context);
  6322. }
  6323. this.optimize(mutations, context);
  6324. };
  6325. ScrollBlot.blotName = 'scroll';
  6326. ScrollBlot.defaultChild = 'block';
  6327. ScrollBlot.scope = Registry.Scope.BLOCK_BLOT;
  6328. ScrollBlot.tagName = 'DIV';
  6329. return ScrollBlot;
  6330. }(container_1.default));
  6331. exports.default = ScrollBlot;
  6332. /***/ }),
  6333. /* 46 */
  6334. /***/ (function(module, exports, __webpack_require__) {
  6335. "use strict";
  6336. var __extends = (this && this.__extends) || (function () {
  6337. var extendStatics = Object.setPrototypeOf ||
  6338. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6339. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6340. return function (d, b) {
  6341. extendStatics(d, b);
  6342. function __() { this.constructor = d; }
  6343. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6344. };
  6345. })();
  6346. Object.defineProperty(exports, "__esModule", { value: true });
  6347. var format_1 = __webpack_require__(18);
  6348. var Registry = __webpack_require__(1);
  6349. // Shallow object comparison
  6350. function isEqual(obj1, obj2) {
  6351. if (Object.keys(obj1).length !== Object.keys(obj2).length)
  6352. return false;
  6353. // @ts-ignore
  6354. for (var prop in obj1) {
  6355. // @ts-ignore
  6356. if (obj1[prop] !== obj2[prop])
  6357. return false;
  6358. }
  6359. return true;
  6360. }
  6361. var InlineBlot = /** @class */ (function (_super) {
  6362. __extends(InlineBlot, _super);
  6363. function InlineBlot() {
  6364. return _super !== null && _super.apply(this, arguments) || this;
  6365. }
  6366. InlineBlot.formats = function (domNode) {
  6367. if (domNode.tagName === InlineBlot.tagName)
  6368. return undefined;
  6369. return _super.formats.call(this, domNode);
  6370. };
  6371. InlineBlot.prototype.format = function (name, value) {
  6372. var _this = this;
  6373. if (name === this.statics.blotName && !value) {
  6374. this.children.forEach(function (child) {
  6375. if (!(child instanceof format_1.default)) {
  6376. child = child.wrap(InlineBlot.blotName, true);
  6377. }
  6378. _this.attributes.copy(child);
  6379. });
  6380. this.unwrap();
  6381. }
  6382. else {
  6383. _super.prototype.format.call(this, name, value);
  6384. }
  6385. };
  6386. InlineBlot.prototype.formatAt = function (index, length, name, value) {
  6387. if (this.formats()[name] != null || Registry.query(name, Registry.Scope.ATTRIBUTE)) {
  6388. var blot = this.isolate(index, length);
  6389. blot.format(name, value);
  6390. }
  6391. else {
  6392. _super.prototype.formatAt.call(this, index, length, name, value);
  6393. }
  6394. };
  6395. InlineBlot.prototype.optimize = function (context) {
  6396. _super.prototype.optimize.call(this, context);
  6397. var formats = this.formats();
  6398. if (Object.keys(formats).length === 0) {
  6399. return this.unwrap(); // unformatted span
  6400. }
  6401. var next = this.next;
  6402. if (next instanceof InlineBlot && next.prev === this && isEqual(formats, next.formats())) {
  6403. next.moveChildren(this);
  6404. next.remove();
  6405. }
  6406. };
  6407. InlineBlot.blotName = 'inline';
  6408. InlineBlot.scope = Registry.Scope.INLINE_BLOT;
  6409. InlineBlot.tagName = 'SPAN';
  6410. return InlineBlot;
  6411. }(format_1.default));
  6412. exports.default = InlineBlot;
  6413. /***/ }),
  6414. /* 47 */
  6415. /***/ (function(module, exports, __webpack_require__) {
  6416. "use strict";
  6417. var __extends = (this && this.__extends) || (function () {
  6418. var extendStatics = Object.setPrototypeOf ||
  6419. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6420. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6421. return function (d, b) {
  6422. extendStatics(d, b);
  6423. function __() { this.constructor = d; }
  6424. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6425. };
  6426. })();
  6427. Object.defineProperty(exports, "__esModule", { value: true });
  6428. var format_1 = __webpack_require__(18);
  6429. var Registry = __webpack_require__(1);
  6430. var BlockBlot = /** @class */ (function (_super) {
  6431. __extends(BlockBlot, _super);
  6432. function BlockBlot() {
  6433. return _super !== null && _super.apply(this, arguments) || this;
  6434. }
  6435. BlockBlot.formats = function (domNode) {
  6436. var tagName = Registry.query(BlockBlot.blotName).tagName;
  6437. if (domNode.tagName === tagName)
  6438. return undefined;
  6439. return _super.formats.call(this, domNode);
  6440. };
  6441. BlockBlot.prototype.format = function (name, value) {
  6442. if (Registry.query(name, Registry.Scope.BLOCK) == null) {
  6443. return;
  6444. }
  6445. else if (name === this.statics.blotName && !value) {
  6446. this.replaceWith(BlockBlot.blotName);
  6447. }
  6448. else {
  6449. _super.prototype.format.call(this, name, value);
  6450. }
  6451. };
  6452. BlockBlot.prototype.formatAt = function (index, length, name, value) {
  6453. if (Registry.query(name, Registry.Scope.BLOCK) != null) {
  6454. this.format(name, value);
  6455. }
  6456. else {
  6457. _super.prototype.formatAt.call(this, index, length, name, value);
  6458. }
  6459. };
  6460. BlockBlot.prototype.insertAt = function (index, value, def) {
  6461. if (def == null || Registry.query(value, Registry.Scope.INLINE) != null) {
  6462. // Insert text or inline
  6463. _super.prototype.insertAt.call(this, index, value, def);
  6464. }
  6465. else {
  6466. var after = this.split(index);
  6467. var blot = Registry.create(value, def);
  6468. after.parent.insertBefore(blot, after);
  6469. }
  6470. };
  6471. BlockBlot.prototype.update = function (mutations, context) {
  6472. if (navigator.userAgent.match(/Trident/)) {
  6473. this.build();
  6474. }
  6475. else {
  6476. _super.prototype.update.call(this, mutations, context);
  6477. }
  6478. };
  6479. BlockBlot.blotName = 'block';
  6480. BlockBlot.scope = Registry.Scope.BLOCK_BLOT;
  6481. BlockBlot.tagName = 'P';
  6482. return BlockBlot;
  6483. }(format_1.default));
  6484. exports.default = BlockBlot;
  6485. /***/ }),
  6486. /* 48 */
  6487. /***/ (function(module, exports, __webpack_require__) {
  6488. "use strict";
  6489. var __extends = (this && this.__extends) || (function () {
  6490. var extendStatics = Object.setPrototypeOf ||
  6491. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6492. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6493. return function (d, b) {
  6494. extendStatics(d, b);
  6495. function __() { this.constructor = d; }
  6496. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6497. };
  6498. })();
  6499. Object.defineProperty(exports, "__esModule", { value: true });
  6500. var leaf_1 = __webpack_require__(19);
  6501. var EmbedBlot = /** @class */ (function (_super) {
  6502. __extends(EmbedBlot, _super);
  6503. function EmbedBlot() {
  6504. return _super !== null && _super.apply(this, arguments) || this;
  6505. }
  6506. EmbedBlot.formats = function (domNode) {
  6507. return undefined;
  6508. };
  6509. EmbedBlot.prototype.format = function (name, value) {
  6510. // super.formatAt wraps, which is what we want in general,
  6511. // but this allows subclasses to overwrite for formats
  6512. // that just apply to particular embeds
  6513. _super.prototype.formatAt.call(this, 0, this.length(), name, value);
  6514. };
  6515. EmbedBlot.prototype.formatAt = function (index, length, name, value) {
  6516. if (index === 0 && length === this.length()) {
  6517. this.format(name, value);
  6518. }
  6519. else {
  6520. _super.prototype.formatAt.call(this, index, length, name, value);
  6521. }
  6522. };
  6523. EmbedBlot.prototype.formats = function () {
  6524. return this.statics.formats(this.domNode);
  6525. };
  6526. return EmbedBlot;
  6527. }(leaf_1.default));
  6528. exports.default = EmbedBlot;
  6529. /***/ }),
  6530. /* 49 */
  6531. /***/ (function(module, exports, __webpack_require__) {
  6532. "use strict";
  6533. var __extends = (this && this.__extends) || (function () {
  6534. var extendStatics = Object.setPrototypeOf ||
  6535. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6536. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6537. return function (d, b) {
  6538. extendStatics(d, b);
  6539. function __() { this.constructor = d; }
  6540. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6541. };
  6542. })();
  6543. Object.defineProperty(exports, "__esModule", { value: true });
  6544. var leaf_1 = __webpack_require__(19);
  6545. var Registry = __webpack_require__(1);
  6546. var TextBlot = /** @class */ (function (_super) {
  6547. __extends(TextBlot, _super);
  6548. function TextBlot(node) {
  6549. var _this = _super.call(this, node) || this;
  6550. _this.text = _this.statics.value(_this.domNode);
  6551. return _this;
  6552. }
  6553. TextBlot.create = function (value) {
  6554. return document.createTextNode(value);
  6555. };
  6556. TextBlot.value = function (domNode) {
  6557. var text = domNode.data;
  6558. // @ts-ignore
  6559. if (text['normalize'])
  6560. text = text['normalize']();
  6561. return text;
  6562. };
  6563. TextBlot.prototype.deleteAt = function (index, length) {
  6564. this.domNode.data = this.text = this.text.slice(0, index) + this.text.slice(index + length);
  6565. };
  6566. TextBlot.prototype.index = function (node, offset) {
  6567. if (this.domNode === node) {
  6568. return offset;
  6569. }
  6570. return -1;
  6571. };
  6572. TextBlot.prototype.insertAt = function (index, value, def) {
  6573. if (def == null) {
  6574. this.text = this.text.slice(0, index) + value + this.text.slice(index);
  6575. this.domNode.data = this.text;
  6576. }
  6577. else {
  6578. _super.prototype.insertAt.call(this, index, value, def);
  6579. }
  6580. };
  6581. TextBlot.prototype.length = function () {
  6582. return this.text.length;
  6583. };
  6584. TextBlot.prototype.optimize = function (context) {
  6585. _super.prototype.optimize.call(this, context);
  6586. this.text = this.statics.value(this.domNode);
  6587. if (this.text.length === 0) {
  6588. this.remove();
  6589. }
  6590. else if (this.next instanceof TextBlot && this.next.prev === this) {
  6591. this.insertAt(this.length(), this.next.value());
  6592. this.next.remove();
  6593. }
  6594. };
  6595. TextBlot.prototype.position = function (index, inclusive) {
  6596. if (inclusive === void 0) { inclusive = false; }
  6597. return [this.domNode, index];
  6598. };
  6599. TextBlot.prototype.split = function (index, force) {
  6600. if (force === void 0) { force = false; }
  6601. if (!force) {
  6602. if (index === 0)
  6603. return this;
  6604. if (index === this.length())
  6605. return this.next;
  6606. }
  6607. var after = Registry.create(this.domNode.splitText(index));
  6608. this.parent.insertBefore(after, this.next);
  6609. this.text = this.statics.value(this.domNode);
  6610. return after;
  6611. };
  6612. TextBlot.prototype.update = function (mutations, context) {
  6613. var _this = this;
  6614. if (mutations.some(function (mutation) {
  6615. return mutation.type === 'characterData' && mutation.target === _this.domNode;
  6616. })) {
  6617. this.text = this.statics.value(this.domNode);
  6618. }
  6619. };
  6620. TextBlot.prototype.value = function () {
  6621. return this.text;
  6622. };
  6623. TextBlot.blotName = 'text';
  6624. TextBlot.scope = Registry.Scope.INLINE_BLOT;
  6625. return TextBlot;
  6626. }(leaf_1.default));
  6627. exports.default = TextBlot;
  6628. /***/ }),
  6629. /* 50 */
  6630. /***/ (function(module, exports, __webpack_require__) {
  6631. "use strict";
  6632. var elem = document.createElement('div');
  6633. elem.classList.toggle('test-class', false);
  6634. if (elem.classList.contains('test-class')) {
  6635. var _toggle = DOMTokenList.prototype.toggle;
  6636. DOMTokenList.prototype.toggle = function (token, force) {
  6637. if (arguments.length > 1 && !this.contains(token) === !force) {
  6638. return force;
  6639. } else {
  6640. return _toggle.call(this, token);
  6641. }
  6642. };
  6643. }
  6644. if (!String.prototype.startsWith) {
  6645. String.prototype.startsWith = function (searchString, position) {
  6646. position = position || 0;
  6647. return this.substr(position, searchString.length) === searchString;
  6648. };
  6649. }
  6650. if (!String.prototype.endsWith) {
  6651. String.prototype.endsWith = function (searchString, position) {
  6652. var subjectString = this.toString();
  6653. if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
  6654. position = subjectString.length;
  6655. }
  6656. position -= searchString.length;
  6657. var lastIndex = subjectString.indexOf(searchString, position);
  6658. return lastIndex !== -1 && lastIndex === position;
  6659. };
  6660. }
  6661. if (!Array.prototype.find) {
  6662. Object.defineProperty(Array.prototype, "find", {
  6663. value: function value(predicate) {
  6664. if (this === null) {
  6665. throw new TypeError('Array.prototype.find called on null or undefined');
  6666. }
  6667. if (typeof predicate !== 'function') {
  6668. throw new TypeError('predicate must be a function');
  6669. }
  6670. var list = Object(this);
  6671. var length = list.length >>> 0;
  6672. var thisArg = arguments[1];
  6673. var value;
  6674. for (var i = 0; i < length; i++) {
  6675. value = list[i];
  6676. if (predicate.call(thisArg, value, i, list)) {
  6677. return value;
  6678. }
  6679. }
  6680. return undefined;
  6681. }
  6682. });
  6683. }
  6684. document.addEventListener("DOMContentLoaded", function () {
  6685. // Disable resizing in Firefox
  6686. document.execCommand("enableObjectResizing", false, false);
  6687. // Disable automatic linkifying in IE11
  6688. document.execCommand("autoUrlDetect", false, false);
  6689. });
  6690. /***/ }),
  6691. /* 51 */
  6692. /***/ (function(module, exports) {
  6693. /**
  6694. * This library modifies the diff-patch-match library by Neil Fraser
  6695. * by removing the patch and match functionality and certain advanced
  6696. * options in the diff function. The original license is as follows:
  6697. *
  6698. * ===
  6699. *
  6700. * Diff Match and Patch
  6701. *
  6702. * Copyright 2006 Google Inc.
  6703. * http://code.google.com/p/google-diff-match-patch/
  6704. *
  6705. * Licensed under the Apache License, Version 2.0 (the "License");
  6706. * you may not use this file except in compliance with the License.
  6707. * You may obtain a copy of the License at
  6708. *
  6709. * http://www.apache.org/licenses/LICENSE-2.0
  6710. *
  6711. * Unless required by applicable law or agreed to in writing, software
  6712. * distributed under the License is distributed on an "AS IS" BASIS,
  6713. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  6714. * See the License for the specific language governing permissions and
  6715. * limitations under the License.
  6716. */
  6717. /**
  6718. * The data structure representing a diff is an array of tuples:
  6719. * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
  6720. * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
  6721. */
  6722. var DIFF_DELETE = -1;
  6723. var DIFF_INSERT = 1;
  6724. var DIFF_EQUAL = 0;
  6725. /**
  6726. * Find the differences between two texts. Simplifies the problem by stripping
  6727. * any common prefix or suffix off the texts before diffing.
  6728. * @param {string} text1 Old string to be diffed.
  6729. * @param {string} text2 New string to be diffed.
  6730. * @param {Int} cursor_pos Expected edit position in text1 (optional)
  6731. * @return {Array} Array of diff tuples.
  6732. */
  6733. function diff_main(text1, text2, cursor_pos) {
  6734. // Check for equality (speedup).
  6735. if (text1 == text2) {
  6736. if (text1) {
  6737. return [[DIFF_EQUAL, text1]];
  6738. }
  6739. return [];
  6740. }
  6741. // Check cursor_pos within bounds
  6742. if (cursor_pos < 0 || text1.length < cursor_pos) {
  6743. cursor_pos = null;
  6744. }
  6745. // Trim off common prefix (speedup).
  6746. var commonlength = diff_commonPrefix(text1, text2);
  6747. var commonprefix = text1.substring(0, commonlength);
  6748. text1 = text1.substring(commonlength);
  6749. text2 = text2.substring(commonlength);
  6750. // Trim off common suffix (speedup).
  6751. commonlength = diff_commonSuffix(text1, text2);
  6752. var commonsuffix = text1.substring(text1.length - commonlength);
  6753. text1 = text1.substring(0, text1.length - commonlength);
  6754. text2 = text2.substring(0, text2.length - commonlength);
  6755. // Compute the diff on the middle block.
  6756. var diffs = diff_compute_(text1, text2);
  6757. // Restore the prefix and suffix.
  6758. if (commonprefix) {
  6759. diffs.unshift([DIFF_EQUAL, commonprefix]);
  6760. }
  6761. if (commonsuffix) {
  6762. diffs.push([DIFF_EQUAL, commonsuffix]);
  6763. }
  6764. diff_cleanupMerge(diffs);
  6765. if (cursor_pos != null) {
  6766. diffs = fix_cursor(diffs, cursor_pos);
  6767. }
  6768. diffs = fix_emoji(diffs);
  6769. return diffs;
  6770. };
  6771. /**
  6772. * Find the differences between two texts. Assumes that the texts do not
  6773. * have any common prefix or suffix.
  6774. * @param {string} text1 Old string to be diffed.
  6775. * @param {string} text2 New string to be diffed.
  6776. * @return {Array} Array of diff tuples.
  6777. */
  6778. function diff_compute_(text1, text2) {
  6779. var diffs;
  6780. if (!text1) {
  6781. // Just add some text (speedup).
  6782. return [[DIFF_INSERT, text2]];
  6783. }
  6784. if (!text2) {
  6785. // Just delete some text (speedup).
  6786. return [[DIFF_DELETE, text1]];
  6787. }
  6788. var longtext = text1.length > text2.length ? text1 : text2;
  6789. var shorttext = text1.length > text2.length ? text2 : text1;
  6790. var i = longtext.indexOf(shorttext);
  6791. if (i != -1) {
  6792. // Shorter text is inside the longer text (speedup).
  6793. diffs = [[DIFF_INSERT, longtext.substring(0, i)],
  6794. [DIFF_EQUAL, shorttext],
  6795. [DIFF_INSERT, longtext.substring(i + shorttext.length)]];
  6796. // Swap insertions for deletions if diff is reversed.
  6797. if (text1.length > text2.length) {
  6798. diffs[0][0] = diffs[2][0] = DIFF_DELETE;
  6799. }
  6800. return diffs;
  6801. }
  6802. if (shorttext.length == 1) {
  6803. // Single character string.
  6804. // After the previous speedup, the character can't be an equality.
  6805. return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
  6806. }
  6807. // Check to see if the problem can be split in two.
  6808. var hm = diff_halfMatch_(text1, text2);
  6809. if (hm) {
  6810. // A half-match was found, sort out the return data.
  6811. var text1_a = hm[0];
  6812. var text1_b = hm[1];
  6813. var text2_a = hm[2];
  6814. var text2_b = hm[3];
  6815. var mid_common = hm[4];
  6816. // Send both pairs off for separate processing.
  6817. var diffs_a = diff_main(text1_a, text2_a);
  6818. var diffs_b = diff_main(text1_b, text2_b);
  6819. // Merge the results.
  6820. return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b);
  6821. }
  6822. return diff_bisect_(text1, text2);
  6823. };
  6824. /**
  6825. * Find the 'middle snake' of a diff, split the problem in two
  6826. * and return the recursively constructed diff.
  6827. * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
  6828. * @param {string} text1 Old string to be diffed.
  6829. * @param {string} text2 New string to be diffed.
  6830. * @return {Array} Array of diff tuples.
  6831. * @private
  6832. */
  6833. function diff_bisect_(text1, text2) {
  6834. // Cache the text lengths to prevent multiple calls.
  6835. var text1_length = text1.length;
  6836. var text2_length = text2.length;
  6837. var max_d = Math.ceil((text1_length + text2_length) / 2);
  6838. var v_offset = max_d;
  6839. var v_length = 2 * max_d;
  6840. var v1 = new Array(v_length);
  6841. var v2 = new Array(v_length);
  6842. // Setting all elements to -1 is faster in Chrome & Firefox than mixing
  6843. // integers and undefined.
  6844. for (var x = 0; x < v_length; x++) {
  6845. v1[x] = -1;
  6846. v2[x] = -1;
  6847. }
  6848. v1[v_offset + 1] = 0;
  6849. v2[v_offset + 1] = 0;
  6850. var delta = text1_length - text2_length;
  6851. // If the total number of characters is odd, then the front path will collide
  6852. // with the reverse path.
  6853. var front = (delta % 2 != 0);
  6854. // Offsets for start and end of k loop.
  6855. // Prevents mapping of space beyond the grid.
  6856. var k1start = 0;
  6857. var k1end = 0;
  6858. var k2start = 0;
  6859. var k2end = 0;
  6860. for (var d = 0; d < max_d; d++) {
  6861. // Walk the front path one step.
  6862. for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
  6863. var k1_offset = v_offset + k1;
  6864. var x1;
  6865. if (k1 == -d || (k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1])) {
  6866. x1 = v1[k1_offset + 1];
  6867. } else {
  6868. x1 = v1[k1_offset - 1] + 1;
  6869. }
  6870. var y1 = x1 - k1;
  6871. while (x1 < text1_length && y1 < text2_length &&
  6872. text1.charAt(x1) == text2.charAt(y1)) {
  6873. x1++;
  6874. y1++;
  6875. }
  6876. v1[k1_offset] = x1;
  6877. if (x1 > text1_length) {
  6878. // Ran off the right of the graph.
  6879. k1end += 2;
  6880. } else if (y1 > text2_length) {
  6881. // Ran off the bottom of the graph.
  6882. k1start += 2;
  6883. } else if (front) {
  6884. var k2_offset = v_offset + delta - k1;
  6885. if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] != -1) {
  6886. // Mirror x2 onto top-left coordinate system.
  6887. var x2 = text1_length - v2[k2_offset];
  6888. if (x1 >= x2) {
  6889. // Overlap detected.
  6890. return diff_bisectSplit_(text1, text2, x1, y1);
  6891. }
  6892. }
  6893. }
  6894. }
  6895. // Walk the reverse path one step.
  6896. for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
  6897. var k2_offset = v_offset + k2;
  6898. var x2;
  6899. if (k2 == -d || (k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1])) {
  6900. x2 = v2[k2_offset + 1];
  6901. } else {
  6902. x2 = v2[k2_offset - 1] + 1;
  6903. }
  6904. var y2 = x2 - k2;
  6905. while (x2 < text1_length && y2 < text2_length &&
  6906. text1.charAt(text1_length - x2 - 1) ==
  6907. text2.charAt(text2_length - y2 - 1)) {
  6908. x2++;
  6909. y2++;
  6910. }
  6911. v2[k2_offset] = x2;
  6912. if (x2 > text1_length) {
  6913. // Ran off the left of the graph.
  6914. k2end += 2;
  6915. } else if (y2 > text2_length) {
  6916. // Ran off the top of the graph.
  6917. k2start += 2;
  6918. } else if (!front) {
  6919. var k1_offset = v_offset + delta - k2;
  6920. if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] != -1) {
  6921. var x1 = v1[k1_offset];
  6922. var y1 = v_offset + x1 - k1_offset;
  6923. // Mirror x2 onto top-left coordinate system.
  6924. x2 = text1_length - x2;
  6925. if (x1 >= x2) {
  6926. // Overlap detected.
  6927. return diff_bisectSplit_(text1, text2, x1, y1);
  6928. }
  6929. }
  6930. }
  6931. }
  6932. }
  6933. // Diff took too long and hit the deadline or
  6934. // number of diffs equals number of characters, no commonality at all.
  6935. return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
  6936. };
  6937. /**
  6938. * Given the location of the 'middle snake', split the diff in two parts
  6939. * and recurse.
  6940. * @param {string} text1 Old string to be diffed.
  6941. * @param {string} text2 New string to be diffed.
  6942. * @param {number} x Index of split point in text1.
  6943. * @param {number} y Index of split point in text2.
  6944. * @return {Array} Array of diff tuples.
  6945. */
  6946. function diff_bisectSplit_(text1, text2, x, y) {
  6947. var text1a = text1.substring(0, x);
  6948. var text2a = text2.substring(0, y);
  6949. var text1b = text1.substring(x);
  6950. var text2b = text2.substring(y);
  6951. // Compute both diffs serially.
  6952. var diffs = diff_main(text1a, text2a);
  6953. var diffsb = diff_main(text1b, text2b);
  6954. return diffs.concat(diffsb);
  6955. };
  6956. /**
  6957. * Determine the common prefix of two strings.
  6958. * @param {string} text1 First string.
  6959. * @param {string} text2 Second string.
  6960. * @return {number} The number of characters common to the start of each
  6961. * string.
  6962. */
  6963. function diff_commonPrefix(text1, text2) {
  6964. // Quick check for common null cases.
  6965. if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) {
  6966. return 0;
  6967. }
  6968. // Binary search.
  6969. // Performance analysis: http://neil.fraser.name/news/2007/10/09/
  6970. var pointermin = 0;
  6971. var pointermax = Math.min(text1.length, text2.length);
  6972. var pointermid = pointermax;
  6973. var pointerstart = 0;
  6974. while (pointermin < pointermid) {
  6975. if (text1.substring(pointerstart, pointermid) ==
  6976. text2.substring(pointerstart, pointermid)) {
  6977. pointermin = pointermid;
  6978. pointerstart = pointermin;
  6979. } else {
  6980. pointermax = pointermid;
  6981. }
  6982. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  6983. }
  6984. return pointermid;
  6985. };
  6986. /**
  6987. * Determine the common suffix of two strings.
  6988. * @param {string} text1 First string.
  6989. * @param {string} text2 Second string.
  6990. * @return {number} The number of characters common to the end of each string.
  6991. */
  6992. function diff_commonSuffix(text1, text2) {
  6993. // Quick check for common null cases.
  6994. if (!text1 || !text2 ||
  6995. text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)) {
  6996. return 0;
  6997. }
  6998. // Binary search.
  6999. // Performance analysis: http://neil.fraser.name/news/2007/10/09/
  7000. var pointermin = 0;
  7001. var pointermax = Math.min(text1.length, text2.length);
  7002. var pointermid = pointermax;
  7003. var pointerend = 0;
  7004. while (pointermin < pointermid) {
  7005. if (text1.substring(text1.length - pointermid, text1.length - pointerend) ==
  7006. text2.substring(text2.length - pointermid, text2.length - pointerend)) {
  7007. pointermin = pointermid;
  7008. pointerend = pointermin;
  7009. } else {
  7010. pointermax = pointermid;
  7011. }
  7012. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  7013. }
  7014. return pointermid;
  7015. };
  7016. /**
  7017. * Do the two texts share a substring which is at least half the length of the
  7018. * longer text?
  7019. * This speedup can produce non-minimal diffs.
  7020. * @param {string} text1 First string.
  7021. * @param {string} text2 Second string.
  7022. * @return {Array.<string>} Five element Array, containing the prefix of
  7023. * text1, the suffix of text1, the prefix of text2, the suffix of
  7024. * text2 and the common middle. Or null if there was no match.
  7025. */
  7026. function diff_halfMatch_(text1, text2) {
  7027. var longtext = text1.length > text2.length ? text1 : text2;
  7028. var shorttext = text1.length > text2.length ? text2 : text1;
  7029. if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
  7030. return null; // Pointless.
  7031. }
  7032. /**
  7033. * Does a substring of shorttext exist within longtext such that the substring
  7034. * is at least half the length of longtext?
  7035. * Closure, but does not reference any external variables.
  7036. * @param {string} longtext Longer string.
  7037. * @param {string} shorttext Shorter string.
  7038. * @param {number} i Start index of quarter length substring within longtext.
  7039. * @return {Array.<string>} Five element Array, containing the prefix of
  7040. * longtext, the suffix of longtext, the prefix of shorttext, the suffix
  7041. * of shorttext and the common middle. Or null if there was no match.
  7042. * @private
  7043. */
  7044. function diff_halfMatchI_(longtext, shorttext, i) {
  7045. // Start with a 1/4 length substring at position i as a seed.
  7046. var seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
  7047. var j = -1;
  7048. var best_common = '';
  7049. var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
  7050. while ((j = shorttext.indexOf(seed, j + 1)) != -1) {
  7051. var prefixLength = diff_commonPrefix(longtext.substring(i),
  7052. shorttext.substring(j));
  7053. var suffixLength = diff_commonSuffix(longtext.substring(0, i),
  7054. shorttext.substring(0, j));
  7055. if (best_common.length < suffixLength + prefixLength) {
  7056. best_common = shorttext.substring(j - suffixLength, j) +
  7057. shorttext.substring(j, j + prefixLength);
  7058. best_longtext_a = longtext.substring(0, i - suffixLength);
  7059. best_longtext_b = longtext.substring(i + prefixLength);
  7060. best_shorttext_a = shorttext.substring(0, j - suffixLength);
  7061. best_shorttext_b = shorttext.substring(j + prefixLength);
  7062. }
  7063. }
  7064. if (best_common.length * 2 >= longtext.length) {
  7065. return [best_longtext_a, best_longtext_b,
  7066. best_shorttext_a, best_shorttext_b, best_common];
  7067. } else {
  7068. return null;
  7069. }
  7070. }
  7071. // First check if the second quarter is the seed for a half-match.
  7072. var hm1 = diff_halfMatchI_(longtext, shorttext,
  7073. Math.ceil(longtext.length / 4));
  7074. // Check again based on the third quarter.
  7075. var hm2 = diff_halfMatchI_(longtext, shorttext,
  7076. Math.ceil(longtext.length / 2));
  7077. var hm;
  7078. if (!hm1 && !hm2) {
  7079. return null;
  7080. } else if (!hm2) {
  7081. hm = hm1;
  7082. } else if (!hm1) {
  7083. hm = hm2;
  7084. } else {
  7085. // Both matched. Select the longest.
  7086. hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
  7087. }
  7088. // A half-match was found, sort out the return data.
  7089. var text1_a, text1_b, text2_a, text2_b;
  7090. if (text1.length > text2.length) {
  7091. text1_a = hm[0];
  7092. text1_b = hm[1];
  7093. text2_a = hm[2];
  7094. text2_b = hm[3];
  7095. } else {
  7096. text2_a = hm[0];
  7097. text2_b = hm[1];
  7098. text1_a = hm[2];
  7099. text1_b = hm[3];
  7100. }
  7101. var mid_common = hm[4];
  7102. return [text1_a, text1_b, text2_a, text2_b, mid_common];
  7103. };
  7104. /**
  7105. * Reorder and merge like edit sections. Merge equalities.
  7106. * Any edit section can move as long as it doesn't cross an equality.
  7107. * @param {Array} diffs Array of diff tuples.
  7108. */
  7109. function diff_cleanupMerge(diffs) {
  7110. diffs.push([DIFF_EQUAL, '']); // Add a dummy entry at the end.
  7111. var pointer = 0;
  7112. var count_delete = 0;
  7113. var count_insert = 0;
  7114. var text_delete = '';
  7115. var text_insert = '';
  7116. var commonlength;
  7117. while (pointer < diffs.length) {
  7118. switch (diffs[pointer][0]) {
  7119. case DIFF_INSERT:
  7120. count_insert++;
  7121. text_insert += diffs[pointer][1];
  7122. pointer++;
  7123. break;
  7124. case DIFF_DELETE:
  7125. count_delete++;
  7126. text_delete += diffs[pointer][1];
  7127. pointer++;
  7128. break;
  7129. case DIFF_EQUAL:
  7130. // Upon reaching an equality, check for prior redundancies.
  7131. if (count_delete + count_insert > 1) {
  7132. if (count_delete !== 0 && count_insert !== 0) {
  7133. // Factor out any common prefixies.
  7134. commonlength = diff_commonPrefix(text_insert, text_delete);
  7135. if (commonlength !== 0) {
  7136. if ((pointer - count_delete - count_insert) > 0 &&
  7137. diffs[pointer - count_delete - count_insert - 1][0] ==
  7138. DIFF_EQUAL) {
  7139. diffs[pointer - count_delete - count_insert - 1][1] +=
  7140. text_insert.substring(0, commonlength);
  7141. } else {
  7142. diffs.splice(0, 0, [DIFF_EQUAL,
  7143. text_insert.substring(0, commonlength)]);
  7144. pointer++;
  7145. }
  7146. text_insert = text_insert.substring(commonlength);
  7147. text_delete = text_delete.substring(commonlength);
  7148. }
  7149. // Factor out any common suffixies.
  7150. commonlength = diff_commonSuffix(text_insert, text_delete);
  7151. if (commonlength !== 0) {
  7152. diffs[pointer][1] = text_insert.substring(text_insert.length -
  7153. commonlength) + diffs[pointer][1];
  7154. text_insert = text_insert.substring(0, text_insert.length -
  7155. commonlength);
  7156. text_delete = text_delete.substring(0, text_delete.length -
  7157. commonlength);
  7158. }
  7159. }
  7160. // Delete the offending records and add the merged ones.
  7161. if (count_delete === 0) {
  7162. diffs.splice(pointer - count_insert,
  7163. count_delete + count_insert, [DIFF_INSERT, text_insert]);
  7164. } else if (count_insert === 0) {
  7165. diffs.splice(pointer - count_delete,
  7166. count_delete + count_insert, [DIFF_DELETE, text_delete]);
  7167. } else {
  7168. diffs.splice(pointer - count_delete - count_insert,
  7169. count_delete + count_insert, [DIFF_DELETE, text_delete],
  7170. [DIFF_INSERT, text_insert]);
  7171. }
  7172. pointer = pointer - count_delete - count_insert +
  7173. (count_delete ? 1 : 0) + (count_insert ? 1 : 0) + 1;
  7174. } else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) {
  7175. // Merge this equality with the previous one.
  7176. diffs[pointer - 1][1] += diffs[pointer][1];
  7177. diffs.splice(pointer, 1);
  7178. } else {
  7179. pointer++;
  7180. }
  7181. count_insert = 0;
  7182. count_delete = 0;
  7183. text_delete = '';
  7184. text_insert = '';
  7185. break;
  7186. }
  7187. }
  7188. if (diffs[diffs.length - 1][1] === '') {
  7189. diffs.pop(); // Remove the dummy entry at the end.
  7190. }
  7191. // Second pass: look for single edits surrounded on both sides by equalities
  7192. // which can be shifted sideways to eliminate an equality.
  7193. // e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
  7194. var changes = false;
  7195. pointer = 1;
  7196. // Intentionally ignore the first and last element (don't need checking).
  7197. while (pointer < diffs.length - 1) {
  7198. if (diffs[pointer - 1][0] == DIFF_EQUAL &&
  7199. diffs[pointer + 1][0] == DIFF_EQUAL) {
  7200. // This is a single edit surrounded by equalities.
  7201. if (diffs[pointer][1].substring(diffs[pointer][1].length -
  7202. diffs[pointer - 1][1].length) == diffs[pointer - 1][1]) {
  7203. // Shift the edit over the previous equality.
  7204. diffs[pointer][1] = diffs[pointer - 1][1] +
  7205. diffs[pointer][1].substring(0, diffs[pointer][1].length -
  7206. diffs[pointer - 1][1].length);
  7207. diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
  7208. diffs.splice(pointer - 1, 1);
  7209. changes = true;
  7210. } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) ==
  7211. diffs[pointer + 1][1]) {
  7212. // Shift the edit over the next equality.
  7213. diffs[pointer - 1][1] += diffs[pointer + 1][1];
  7214. diffs[pointer][1] =
  7215. diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
  7216. diffs[pointer + 1][1];
  7217. diffs.splice(pointer + 1, 1);
  7218. changes = true;
  7219. }
  7220. }
  7221. pointer++;
  7222. }
  7223. // If shifts were made, the diff needs reordering and another shift sweep.
  7224. if (changes) {
  7225. diff_cleanupMerge(diffs);
  7226. }
  7227. };
  7228. var diff = diff_main;
  7229. diff.INSERT = DIFF_INSERT;
  7230. diff.DELETE = DIFF_DELETE;
  7231. diff.EQUAL = DIFF_EQUAL;
  7232. module.exports = diff;
  7233. /*
  7234. * Modify a diff such that the cursor position points to the start of a change:
  7235. * E.g.
  7236. * cursor_normalize_diff([[DIFF_EQUAL, 'abc']], 1)
  7237. * => [1, [[DIFF_EQUAL, 'a'], [DIFF_EQUAL, 'bc']]]
  7238. * cursor_normalize_diff([[DIFF_INSERT, 'new'], [DIFF_DELETE, 'xyz']], 2)
  7239. * => [2, [[DIFF_INSERT, 'new'], [DIFF_DELETE, 'xy'], [DIFF_DELETE, 'z']]]
  7240. *
  7241. * @param {Array} diffs Array of diff tuples
  7242. * @param {Int} cursor_pos Suggested edit position. Must not be out of bounds!
  7243. * @return {Array} A tuple [cursor location in the modified diff, modified diff]
  7244. */
  7245. function cursor_normalize_diff (diffs, cursor_pos) {
  7246. if (cursor_pos === 0) {
  7247. return [DIFF_EQUAL, diffs];
  7248. }
  7249. for (var current_pos = 0, i = 0; i < diffs.length; i++) {
  7250. var d = diffs[i];
  7251. if (d[0] === DIFF_DELETE || d[0] === DIFF_EQUAL) {
  7252. var next_pos = current_pos + d[1].length;
  7253. if (cursor_pos === next_pos) {
  7254. return [i + 1, diffs];
  7255. } else if (cursor_pos < next_pos) {
  7256. // copy to prevent side effects
  7257. diffs = diffs.slice();
  7258. // split d into two diff changes
  7259. var split_pos = cursor_pos - current_pos;
  7260. var d_left = [d[0], d[1].slice(0, split_pos)];
  7261. var d_right = [d[0], d[1].slice(split_pos)];
  7262. diffs.splice(i, 1, d_left, d_right);
  7263. return [i + 1, diffs];
  7264. } else {
  7265. current_pos = next_pos;
  7266. }
  7267. }
  7268. }
  7269. throw new Error('cursor_pos is out of bounds!')
  7270. }
  7271. /*
  7272. * Modify a diff such that the edit position is "shifted" to the proposed edit location (cursor_position).
  7273. *
  7274. * Case 1)
  7275. * Check if a naive shift is possible:
  7276. * [0, X], [ 1, Y] -> [ 1, Y], [0, X] (if X + Y === Y + X)
  7277. * [0, X], [-1, Y] -> [-1, Y], [0, X] (if X + Y === Y + X) - holds same result
  7278. * Case 2)
  7279. * Check if the following shifts are possible:
  7280. * [0, 'pre'], [ 1, 'prefix'] -> [ 1, 'pre'], [0, 'pre'], [ 1, 'fix']
  7281. * [0, 'pre'], [-1, 'prefix'] -> [-1, 'pre'], [0, 'pre'], [-1, 'fix']
  7282. * ^ ^
  7283. * d d_next
  7284. *
  7285. * @param {Array} diffs Array of diff tuples
  7286. * @param {Int} cursor_pos Suggested edit position. Must not be out of bounds!
  7287. * @return {Array} Array of diff tuples
  7288. */
  7289. function fix_cursor (diffs, cursor_pos) {
  7290. var norm = cursor_normalize_diff(diffs, cursor_pos);
  7291. var ndiffs = norm[1];
  7292. var cursor_pointer = norm[0];
  7293. var d = ndiffs[cursor_pointer];
  7294. var d_next = ndiffs[cursor_pointer + 1];
  7295. if (d == null) {
  7296. // Text was deleted from end of original string,
  7297. // cursor is now out of bounds in new string
  7298. return diffs;
  7299. } else if (d[0] !== DIFF_EQUAL) {
  7300. // A modification happened at the cursor location.
  7301. // This is the expected outcome, so we can return the original diff.
  7302. return diffs;
  7303. } else {
  7304. if (d_next != null && d[1] + d_next[1] === d_next[1] + d[1]) {
  7305. // Case 1)
  7306. // It is possible to perform a naive shift
  7307. ndiffs.splice(cursor_pointer, 2, d_next, d)
  7308. return merge_tuples(ndiffs, cursor_pointer, 2)
  7309. } else if (d_next != null && d_next[1].indexOf(d[1]) === 0) {
  7310. // Case 2)
  7311. // d[1] is a prefix of d_next[1]
  7312. // We can assume that d_next[0] !== 0, since d[0] === 0
  7313. // Shift edit locations..
  7314. ndiffs.splice(cursor_pointer, 2, [d_next[0], d[1]], [0, d[1]]);
  7315. var suffix = d_next[1].slice(d[1].length);
  7316. if (suffix.length > 0) {
  7317. ndiffs.splice(cursor_pointer + 2, 0, [d_next[0], suffix]);
  7318. }
  7319. return merge_tuples(ndiffs, cursor_pointer, 3)
  7320. } else {
  7321. // Not possible to perform any modification
  7322. return diffs;
  7323. }
  7324. }
  7325. }
  7326. /*
  7327. * Check diff did not split surrogate pairs.
  7328. * Ex. [0, '\uD83D'], [-1, '\uDC36'], [1, '\uDC2F'] -> [-1, '\uD83D\uDC36'], [1, '\uD83D\uDC2F']
  7329. * '\uD83D\uDC36' === '🐶', '\uD83D\uDC2F' === '🐯'
  7330. *
  7331. * @param {Array} diffs Array of diff tuples
  7332. * @return {Array} Array of diff tuples
  7333. */
  7334. function fix_emoji (diffs) {
  7335. var compact = false;
  7336. var starts_with_pair_end = function(str) {
  7337. return str.charCodeAt(0) >= 0xDC00 && str.charCodeAt(0) <= 0xDFFF;
  7338. }
  7339. var ends_with_pair_start = function(str) {
  7340. return str.charCodeAt(str.length-1) >= 0xD800 && str.charCodeAt(str.length-1) <= 0xDBFF;
  7341. }
  7342. for (var i = 2; i < diffs.length; i += 1) {
  7343. if (diffs[i-2][0] === DIFF_EQUAL && ends_with_pair_start(diffs[i-2][1]) &&
  7344. diffs[i-1][0] === DIFF_DELETE && starts_with_pair_end(diffs[i-1][1]) &&
  7345. diffs[i][0] === DIFF_INSERT && starts_with_pair_end(diffs[i][1])) {
  7346. compact = true;
  7347. diffs[i-1][1] = diffs[i-2][1].slice(-1) + diffs[i-1][1];
  7348. diffs[i][1] = diffs[i-2][1].slice(-1) + diffs[i][1];
  7349. diffs[i-2][1] = diffs[i-2][1].slice(0, -1);
  7350. }
  7351. }
  7352. if (!compact) {
  7353. return diffs;
  7354. }
  7355. var fixed_diffs = [];
  7356. for (var i = 0; i < diffs.length; i += 1) {
  7357. if (diffs[i][1].length > 0) {
  7358. fixed_diffs.push(diffs[i]);
  7359. }
  7360. }
  7361. return fixed_diffs;
  7362. }
  7363. /*
  7364. * Try to merge tuples with their neigbors in a given range.
  7365. * E.g. [0, 'a'], [0, 'b'] -> [0, 'ab']
  7366. *
  7367. * @param {Array} diffs Array of diff tuples.
  7368. * @param {Int} start Position of the first element to merge (diffs[start] is also merged with diffs[start - 1]).
  7369. * @param {Int} length Number of consecutive elements to check.
  7370. * @return {Array} Array of merged diff tuples.
  7371. */
  7372. function merge_tuples (diffs, start, length) {
  7373. // Check from (start-1) to (start+length).
  7374. for (var i = start + length - 1; i >= 0 && i >= start - 1; i--) {
  7375. if (i + 1 < diffs.length) {
  7376. var left_d = diffs[i];
  7377. var right_d = diffs[i+1];
  7378. if (left_d[0] === right_d[1]) {
  7379. diffs.splice(i, 2, [left_d[0], left_d[1] + right_d[1]]);
  7380. }
  7381. }
  7382. }
  7383. return diffs;
  7384. }
  7385. /***/ }),
  7386. /* 52 */
  7387. /***/ (function(module, exports) {
  7388. exports = module.exports = typeof Object.keys === 'function'
  7389. ? Object.keys : shim;
  7390. exports.shim = shim;
  7391. function shim (obj) {
  7392. var keys = [];
  7393. for (var key in obj) keys.push(key);
  7394. return keys;
  7395. }
  7396. /***/ }),
  7397. /* 53 */
  7398. /***/ (function(module, exports) {
  7399. var supportsArgumentsClass = (function(){
  7400. return Object.prototype.toString.call(arguments)
  7401. })() == '[object Arguments]';
  7402. exports = module.exports = supportsArgumentsClass ? supported : unsupported;
  7403. exports.supported = supported;
  7404. function supported(object) {
  7405. return Object.prototype.toString.call(object) == '[object Arguments]';
  7406. };
  7407. exports.unsupported = unsupported;
  7408. function unsupported(object){
  7409. return object &&
  7410. typeof object == 'object' &&
  7411. typeof object.length == 'number' &&
  7412. Object.prototype.hasOwnProperty.call(object, 'callee') &&
  7413. !Object.prototype.propertyIsEnumerable.call(object, 'callee') ||
  7414. false;
  7415. };
  7416. /***/ }),
  7417. /* 54 */
  7418. /***/ (function(module, exports) {
  7419. 'use strict';
  7420. var has = Object.prototype.hasOwnProperty
  7421. , prefix = '~';
  7422. /**
  7423. * Constructor to create a storage for our `EE` objects.
  7424. * An `Events` instance is a plain object whose properties are event names.
  7425. *
  7426. * @constructor
  7427. * @api private
  7428. */
  7429. function Events() {}
  7430. //
  7431. // We try to not inherit from `Object.prototype`. In some engines creating an
  7432. // instance in this way is faster than calling `Object.create(null)` directly.
  7433. // If `Object.create(null)` is not supported we prefix the event names with a
  7434. // character to make sure that the built-in object properties are not
  7435. // overridden or used as an attack vector.
  7436. //
  7437. if (Object.create) {
  7438. Events.prototype = Object.create(null);
  7439. //
  7440. // This hack is needed because the `__proto__` property is still inherited in
  7441. // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
  7442. //
  7443. if (!new Events().__proto__) prefix = false;
  7444. }
  7445. /**
  7446. * Representation of a single event listener.
  7447. *
  7448. * @param {Function} fn The listener function.
  7449. * @param {Mixed} context The context to invoke the listener with.
  7450. * @param {Boolean} [once=false] Specify if the listener is a one-time listener.
  7451. * @constructor
  7452. * @api private
  7453. */
  7454. function EE(fn, context, once) {
  7455. this.fn = fn;
  7456. this.context = context;
  7457. this.once = once || false;
  7458. }
  7459. /**
  7460. * Minimal `EventEmitter` interface that is molded against the Node.js
  7461. * `EventEmitter` interface.
  7462. *
  7463. * @constructor
  7464. * @api public
  7465. */
  7466. function EventEmitter() {
  7467. this._events = new Events();
  7468. this._eventsCount = 0;
  7469. }
  7470. /**
  7471. * Return an array listing the events for which the emitter has registered
  7472. * listeners.
  7473. *
  7474. * @returns {Array}
  7475. * @api public
  7476. */
  7477. EventEmitter.prototype.eventNames = function eventNames() {
  7478. var names = []
  7479. , events
  7480. , name;
  7481. if (this._eventsCount === 0) return names;
  7482. for (name in (events = this._events)) {
  7483. if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
  7484. }
  7485. if (Object.getOwnPropertySymbols) {
  7486. return names.concat(Object.getOwnPropertySymbols(events));
  7487. }
  7488. return names;
  7489. };
  7490. /**
  7491. * Return the listeners registered for a given event.
  7492. *
  7493. * @param {String|Symbol} event The event name.
  7494. * @param {Boolean} exists Only check if there are listeners.
  7495. * @returns {Array|Boolean}
  7496. * @api public
  7497. */
  7498. EventEmitter.prototype.listeners = function listeners(event, exists) {
  7499. var evt = prefix ? prefix + event : event
  7500. , available = this._events[evt];
  7501. if (exists) return !!available;
  7502. if (!available) return [];
  7503. if (available.fn) return [available.fn];
  7504. for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) {
  7505. ee[i] = available[i].fn;
  7506. }
  7507. return ee;
  7508. };
  7509. /**
  7510. * Calls each of the listeners registered for a given event.
  7511. *
  7512. * @param {String|Symbol} event The event name.
  7513. * @returns {Boolean} `true` if the event had listeners, else `false`.
  7514. * @api public
  7515. */
  7516. EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
  7517. var evt = prefix ? prefix + event : event;
  7518. if (!this._events[evt]) return false;
  7519. var listeners = this._events[evt]
  7520. , len = arguments.length
  7521. , args
  7522. , i;
  7523. if (listeners.fn) {
  7524. if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
  7525. switch (len) {
  7526. case 1: return listeners.fn.call(listeners.context), true;
  7527. case 2: return listeners.fn.call(listeners.context, a1), true;
  7528. case 3: return listeners.fn.call(listeners.context, a1, a2), true;
  7529. case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
  7530. case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
  7531. case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
  7532. }
  7533. for (i = 1, args = new Array(len -1); i < len; i++) {
  7534. args[i - 1] = arguments[i];
  7535. }
  7536. listeners.fn.apply(listeners.context, args);
  7537. } else {
  7538. var length = listeners.length
  7539. , j;
  7540. for (i = 0; i < length; i++) {
  7541. if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
  7542. switch (len) {
  7543. case 1: listeners[i].fn.call(listeners[i].context); break;
  7544. case 2: listeners[i].fn.call(listeners[i].context, a1); break;
  7545. case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
  7546. case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
  7547. default:
  7548. if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
  7549. args[j - 1] = arguments[j];
  7550. }
  7551. listeners[i].fn.apply(listeners[i].context, args);
  7552. }
  7553. }
  7554. }
  7555. return true;
  7556. };
  7557. /**
  7558. * Add a listener for a given event.
  7559. *
  7560. * @param {String|Symbol} event The event name.
  7561. * @param {Function} fn The listener function.
  7562. * @param {Mixed} [context=this] The context to invoke the listener with.
  7563. * @returns {EventEmitter} `this`.
  7564. * @api public
  7565. */
  7566. EventEmitter.prototype.on = function on(event, fn, context) {
  7567. var listener = new EE(fn, context || this)
  7568. , evt = prefix ? prefix + event : event;
  7569. if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
  7570. else if (!this._events[evt].fn) this._events[evt].push(listener);
  7571. else this._events[evt] = [this._events[evt], listener];
  7572. return this;
  7573. };
  7574. /**
  7575. * Add a one-time listener for a given event.
  7576. *
  7577. * @param {String|Symbol} event The event name.
  7578. * @param {Function} fn The listener function.
  7579. * @param {Mixed} [context=this] The context to invoke the listener with.
  7580. * @returns {EventEmitter} `this`.
  7581. * @api public
  7582. */
  7583. EventEmitter.prototype.once = function once(event, fn, context) {
  7584. var listener = new EE(fn, context || this, true)
  7585. , evt = prefix ? prefix + event : event;
  7586. if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
  7587. else if (!this._events[evt].fn) this._events[evt].push(listener);
  7588. else this._events[evt] = [this._events[evt], listener];
  7589. return this;
  7590. };
  7591. /**
  7592. * Remove the listeners of a given event.
  7593. *
  7594. * @param {String|Symbol} event The event name.
  7595. * @param {Function} fn Only remove the listeners that match this function.
  7596. * @param {Mixed} context Only remove the listeners that have this context.
  7597. * @param {Boolean} once Only remove one-time listeners.
  7598. * @returns {EventEmitter} `this`.
  7599. * @api public
  7600. */
  7601. EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
  7602. var evt = prefix ? prefix + event : event;
  7603. if (!this._events[evt]) return this;
  7604. if (!fn) {
  7605. if (--this._eventsCount === 0) this._events = new Events();
  7606. else delete this._events[evt];
  7607. return this;
  7608. }
  7609. var listeners = this._events[evt];
  7610. if (listeners.fn) {
  7611. if (
  7612. listeners.fn === fn
  7613. && (!once || listeners.once)
  7614. && (!context || listeners.context === context)
  7615. ) {
  7616. if (--this._eventsCount === 0) this._events = new Events();
  7617. else delete this._events[evt];
  7618. }
  7619. } else {
  7620. for (var i = 0, events = [], length = listeners.length; i < length; i++) {
  7621. if (
  7622. listeners[i].fn !== fn
  7623. || (once && !listeners[i].once)
  7624. || (context && listeners[i].context !== context)
  7625. ) {
  7626. events.push(listeners[i]);
  7627. }
  7628. }
  7629. //
  7630. // Reset the array, or remove it completely if we have no more listeners.
  7631. //
  7632. if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
  7633. else if (--this._eventsCount === 0) this._events = new Events();
  7634. else delete this._events[evt];
  7635. }
  7636. return this;
  7637. };
  7638. /**
  7639. * Remove all listeners, or those of the specified event.
  7640. *
  7641. * @param {String|Symbol} [event] The event name.
  7642. * @returns {EventEmitter} `this`.
  7643. * @api public
  7644. */
  7645. EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
  7646. var evt;
  7647. if (event) {
  7648. evt = prefix ? prefix + event : event;
  7649. if (this._events[evt]) {
  7650. if (--this._eventsCount === 0) this._events = new Events();
  7651. else delete this._events[evt];
  7652. }
  7653. } else {
  7654. this._events = new Events();
  7655. this._eventsCount = 0;
  7656. }
  7657. return this;
  7658. };
  7659. //
  7660. // Alias methods names because people roll like that.
  7661. //
  7662. EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
  7663. EventEmitter.prototype.addListener = EventEmitter.prototype.on;
  7664. //
  7665. // This function doesn't apply anymore.
  7666. //
  7667. EventEmitter.prototype.setMaxListeners = function setMaxListeners() {
  7668. return this;
  7669. };
  7670. //
  7671. // Expose the prefix.
  7672. //
  7673. EventEmitter.prefixed = prefix;
  7674. //
  7675. // Allow `EventEmitter` to be imported as module namespace.
  7676. //
  7677. EventEmitter.EventEmitter = EventEmitter;
  7678. //
  7679. // Expose the module.
  7680. //
  7681. if ('undefined' !== typeof module) {
  7682. module.exports = EventEmitter;
  7683. }
  7684. /***/ }),
  7685. /* 55 */
  7686. /***/ (function(module, exports, __webpack_require__) {
  7687. "use strict";
  7688. Object.defineProperty(exports, "__esModule", {
  7689. value: true
  7690. });
  7691. exports.matchText = exports.matchSpacing = exports.matchNewline = exports.matchBlot = exports.matchAttributor = exports.default = undefined;
  7692. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  7693. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  7694. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  7695. var _extend2 = __webpack_require__(3);
  7696. var _extend3 = _interopRequireDefault(_extend2);
  7697. var _quillDelta = __webpack_require__(2);
  7698. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  7699. var _parchment = __webpack_require__(0);
  7700. var _parchment2 = _interopRequireDefault(_parchment);
  7701. var _quill = __webpack_require__(5);
  7702. var _quill2 = _interopRequireDefault(_quill);
  7703. var _logger = __webpack_require__(10);
  7704. var _logger2 = _interopRequireDefault(_logger);
  7705. var _module = __webpack_require__(9);
  7706. var _module2 = _interopRequireDefault(_module);
  7707. var _align = __webpack_require__(36);
  7708. var _background = __webpack_require__(37);
  7709. var _code = __webpack_require__(13);
  7710. var _code2 = _interopRequireDefault(_code);
  7711. var _color = __webpack_require__(26);
  7712. var _direction = __webpack_require__(38);
  7713. var _font = __webpack_require__(39);
  7714. var _size = __webpack_require__(40);
  7715. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7716. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  7717. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7718. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  7719. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  7720. var debug = (0, _logger2.default)('quill:clipboard');
  7721. var DOM_KEY = '__ql-matcher';
  7722. var CLIPBOARD_CONFIG = [[Node.TEXT_NODE, matchText], [Node.TEXT_NODE, matchNewline], ['br', matchBreak], [Node.ELEMENT_NODE, matchNewline], [Node.ELEMENT_NODE, matchBlot], [Node.ELEMENT_NODE, matchSpacing], [Node.ELEMENT_NODE, matchAttributor], [Node.ELEMENT_NODE, matchStyles], ['li', matchIndent], ['b', matchAlias.bind(matchAlias, 'bold')], ['i', matchAlias.bind(matchAlias, 'italic')], ['style', matchIgnore]];
  7723. var ATTRIBUTE_ATTRIBUTORS = [_align.AlignAttribute, _direction.DirectionAttribute].reduce(function (memo, attr) {
  7724. memo[attr.keyName] = attr;
  7725. return memo;
  7726. }, {});
  7727. var STYLE_ATTRIBUTORS = [_align.AlignStyle, _background.BackgroundStyle, _color.ColorStyle, _direction.DirectionStyle, _font.FontStyle, _size.SizeStyle].reduce(function (memo, attr) {
  7728. memo[attr.keyName] = attr;
  7729. return memo;
  7730. }, {});
  7731. var Clipboard = function (_Module) {
  7732. _inherits(Clipboard, _Module);
  7733. function Clipboard(quill, options) {
  7734. _classCallCheck(this, Clipboard);
  7735. var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this, quill, options));
  7736. _this.quill.root.addEventListener('paste', _this.onPaste.bind(_this));
  7737. _this.container = _this.quill.addContainer('ql-clipboard');
  7738. _this.container.setAttribute('contenteditable', true);
  7739. _this.container.setAttribute('tabindex', -1);
  7740. _this.matchers = [];
  7741. CLIPBOARD_CONFIG.concat(_this.options.matchers).forEach(function (_ref) {
  7742. var _ref2 = _slicedToArray(_ref, 2),
  7743. selector = _ref2[0],
  7744. matcher = _ref2[1];
  7745. if (!options.matchVisual && matcher === matchSpacing) return;
  7746. _this.addMatcher(selector, matcher);
  7747. });
  7748. return _this;
  7749. }
  7750. _createClass(Clipboard, [{
  7751. key: 'addMatcher',
  7752. value: function addMatcher(selector, matcher) {
  7753. this.matchers.push([selector, matcher]);
  7754. }
  7755. }, {
  7756. key: 'convert',
  7757. value: function convert(html) {
  7758. if (typeof html === 'string') {
  7759. this.container.innerHTML = html.replace(/\>\r?\n +\</g, '><'); // Remove spaces between tags
  7760. return this.convert();
  7761. }
  7762. var formats = this.quill.getFormat(this.quill.selection.savedRange.index);
  7763. if (formats[_code2.default.blotName]) {
  7764. var text = this.container.innerText;
  7765. this.container.innerHTML = '';
  7766. return new _quillDelta2.default().insert(text, _defineProperty({}, _code2.default.blotName, formats[_code2.default.blotName]));
  7767. }
  7768. var _prepareMatching = this.prepareMatching(),
  7769. _prepareMatching2 = _slicedToArray(_prepareMatching, 2),
  7770. elementMatchers = _prepareMatching2[0],
  7771. textMatchers = _prepareMatching2[1];
  7772. var delta = traverse(this.container, elementMatchers, textMatchers);
  7773. // Remove trailing newline
  7774. if (deltaEndsWith(delta, '\n') && delta.ops[delta.ops.length - 1].attributes == null) {
  7775. delta = delta.compose(new _quillDelta2.default().retain(delta.length() - 1).delete(1));
  7776. }
  7777. debug.log('convert', this.container.innerHTML, delta);
  7778. this.container.innerHTML = '';
  7779. return delta;
  7780. }
  7781. }, {
  7782. key: 'dangerouslyPasteHTML',
  7783. value: function dangerouslyPasteHTML(index, html) {
  7784. var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _quill2.default.sources.API;
  7785. if (typeof index === 'string') {
  7786. this.quill.setContents(this.convert(index), html);
  7787. this.quill.setSelection(0, _quill2.default.sources.SILENT);
  7788. } else {
  7789. var paste = this.convert(html);
  7790. this.quill.updateContents(new _quillDelta2.default().retain(index).concat(paste), source);
  7791. this.quill.setSelection(index + paste.length(), _quill2.default.sources.SILENT);
  7792. }
  7793. }
  7794. }, {
  7795. key: 'onPaste',
  7796. value: function onPaste(e) {
  7797. var _this2 = this;
  7798. if (e.defaultPrevented || !this.quill.isEnabled()) return;
  7799. var range = this.quill.getSelection();
  7800. var delta = new _quillDelta2.default().retain(range.index);
  7801. var scrollTop = this.quill.scrollingContainer.scrollTop;
  7802. this.container.focus();
  7803. this.quill.selection.update(_quill2.default.sources.SILENT);
  7804. setTimeout(function () {
  7805. delta = delta.concat(_this2.convert()).delete(range.length);
  7806. _this2.quill.updateContents(delta, _quill2.default.sources.USER);
  7807. // range.length contributes to delta.length()
  7808. _this2.quill.setSelection(delta.length() - range.length, _quill2.default.sources.SILENT);
  7809. _this2.quill.scrollingContainer.scrollTop = scrollTop;
  7810. _this2.quill.focus();
  7811. }, 1);
  7812. }
  7813. }, {
  7814. key: 'prepareMatching',
  7815. value: function prepareMatching() {
  7816. var _this3 = this;
  7817. var elementMatchers = [],
  7818. textMatchers = [];
  7819. this.matchers.forEach(function (pair) {
  7820. var _pair = _slicedToArray(pair, 2),
  7821. selector = _pair[0],
  7822. matcher = _pair[1];
  7823. switch (selector) {
  7824. case Node.TEXT_NODE:
  7825. textMatchers.push(matcher);
  7826. break;
  7827. case Node.ELEMENT_NODE:
  7828. elementMatchers.push(matcher);
  7829. break;
  7830. default:
  7831. [].forEach.call(_this3.container.querySelectorAll(selector), function (node) {
  7832. // TODO use weakmap
  7833. node[DOM_KEY] = node[DOM_KEY] || [];
  7834. node[DOM_KEY].push(matcher);
  7835. });
  7836. break;
  7837. }
  7838. });
  7839. return [elementMatchers, textMatchers];
  7840. }
  7841. }]);
  7842. return Clipboard;
  7843. }(_module2.default);
  7844. Clipboard.DEFAULTS = {
  7845. matchers: [],
  7846. matchVisual: true
  7847. };
  7848. function applyFormat(delta, format, value) {
  7849. if ((typeof format === 'undefined' ? 'undefined' : _typeof(format)) === 'object') {
  7850. return Object.keys(format).reduce(function (delta, key) {
  7851. return applyFormat(delta, key, format[key]);
  7852. }, delta);
  7853. } else {
  7854. return delta.reduce(function (delta, op) {
  7855. if (op.attributes && op.attributes[format]) {
  7856. return delta.push(op);
  7857. } else {
  7858. return delta.insert(op.insert, (0, _extend3.default)({}, _defineProperty({}, format, value), op.attributes));
  7859. }
  7860. }, new _quillDelta2.default());
  7861. }
  7862. }
  7863. function computeStyle(node) {
  7864. if (node.nodeType !== Node.ELEMENT_NODE) return {};
  7865. var DOM_KEY = '__ql-computed-style';
  7866. return node[DOM_KEY] || (node[DOM_KEY] = window.getComputedStyle(node));
  7867. }
  7868. function deltaEndsWith(delta, text) {
  7869. var endText = "";
  7870. for (var i = delta.ops.length - 1; i >= 0 && endText.length < text.length; --i) {
  7871. var op = delta.ops[i];
  7872. if (typeof op.insert !== 'string') break;
  7873. endText = op.insert + endText;
  7874. }
  7875. return endText.slice(-1 * text.length) === text;
  7876. }
  7877. function isLine(node) {
  7878. if (node.childNodes.length === 0) return false; // Exclude embed blocks
  7879. var style = computeStyle(node);
  7880. return ['block', 'list-item'].indexOf(style.display) > -1;
  7881. }
  7882. function traverse(node, elementMatchers, textMatchers) {
  7883. // Post-order
  7884. if (node.nodeType === node.TEXT_NODE) {
  7885. return textMatchers.reduce(function (delta, matcher) {
  7886. return matcher(node, delta);
  7887. }, new _quillDelta2.default());
  7888. } else if (node.nodeType === node.ELEMENT_NODE) {
  7889. return [].reduce.call(node.childNodes || [], function (delta, childNode) {
  7890. var childrenDelta = traverse(childNode, elementMatchers, textMatchers);
  7891. if (childNode.nodeType === node.ELEMENT_NODE) {
  7892. childrenDelta = elementMatchers.reduce(function (childrenDelta, matcher) {
  7893. return matcher(childNode, childrenDelta);
  7894. }, childrenDelta);
  7895. childrenDelta = (childNode[DOM_KEY] || []).reduce(function (childrenDelta, matcher) {
  7896. return matcher(childNode, childrenDelta);
  7897. }, childrenDelta);
  7898. }
  7899. return delta.concat(childrenDelta);
  7900. }, new _quillDelta2.default());
  7901. } else {
  7902. return new _quillDelta2.default();
  7903. }
  7904. }
  7905. function matchAlias(format, node, delta) {
  7906. return applyFormat(delta, format, true);
  7907. }
  7908. function matchAttributor(node, delta) {
  7909. var attributes = _parchment2.default.Attributor.Attribute.keys(node);
  7910. var classes = _parchment2.default.Attributor.Class.keys(node);
  7911. var styles = _parchment2.default.Attributor.Style.keys(node);
  7912. var formats = {};
  7913. attributes.concat(classes).concat(styles).forEach(function (name) {
  7914. var attr = _parchment2.default.query(name, _parchment2.default.Scope.ATTRIBUTE);
  7915. if (attr != null) {
  7916. formats[attr.attrName] = attr.value(node);
  7917. if (formats[attr.attrName]) return;
  7918. }
  7919. attr = ATTRIBUTE_ATTRIBUTORS[name];
  7920. if (attr != null && (attr.attrName === name || attr.keyName === name)) {
  7921. formats[attr.attrName] = attr.value(node) || undefined;
  7922. }
  7923. attr = STYLE_ATTRIBUTORS[name];
  7924. if (attr != null && (attr.attrName === name || attr.keyName === name)) {
  7925. attr = STYLE_ATTRIBUTORS[name];
  7926. formats[attr.attrName] = attr.value(node) || undefined;
  7927. }
  7928. });
  7929. if (Object.keys(formats).length > 0) {
  7930. delta = applyFormat(delta, formats);
  7931. }
  7932. return delta;
  7933. }
  7934. function matchBlot(node, delta) {
  7935. var match = _parchment2.default.query(node);
  7936. if (match == null) return delta;
  7937. if (match.prototype instanceof _parchment2.default.Embed) {
  7938. var embed = {};
  7939. var value = match.value(node);
  7940. if (value != null) {
  7941. embed[match.blotName] = value;
  7942. delta = new _quillDelta2.default().insert(embed, match.formats(node));
  7943. }
  7944. } else if (typeof match.formats === 'function') {
  7945. delta = applyFormat(delta, match.blotName, match.formats(node));
  7946. }
  7947. return delta;
  7948. }
  7949. function matchBreak(node, delta) {
  7950. if (!deltaEndsWith(delta, '\n')) {
  7951. delta.insert('\n');
  7952. }
  7953. return delta;
  7954. }
  7955. function matchIgnore() {
  7956. return new _quillDelta2.default();
  7957. }
  7958. function matchIndent(node, delta) {
  7959. var match = _parchment2.default.query(node);
  7960. if (match == null || match.blotName !== 'list-item' || !deltaEndsWith(delta, '\n')) {
  7961. return delta;
  7962. }
  7963. var indent = -1,
  7964. parent = node.parentNode;
  7965. while (!parent.classList.contains('ql-clipboard')) {
  7966. if ((_parchment2.default.query(parent) || {}).blotName === 'list') {
  7967. indent += 1;
  7968. }
  7969. parent = parent.parentNode;
  7970. }
  7971. if (indent <= 0) return delta;
  7972. return delta.compose(new _quillDelta2.default().retain(delta.length() - 1).retain(1, { indent: indent }));
  7973. }
  7974. function matchNewline(node, delta) {
  7975. if (!deltaEndsWith(delta, '\n')) {
  7976. if (isLine(node) || delta.length() > 0 && node.nextSibling && isLine(node.nextSibling)) {
  7977. delta.insert('\n');
  7978. }
  7979. }
  7980. return delta;
  7981. }
  7982. function matchSpacing(node, delta) {
  7983. if (isLine(node) && node.nextElementSibling != null && !deltaEndsWith(delta, '\n\n')) {
  7984. var nodeHeight = node.offsetHeight + parseFloat(computeStyle(node).marginTop) + parseFloat(computeStyle(node).marginBottom);
  7985. if (node.nextElementSibling.offsetTop > node.offsetTop + nodeHeight * 1.5) {
  7986. delta.insert('\n');
  7987. }
  7988. }
  7989. return delta;
  7990. }
  7991. function matchStyles(node, delta) {
  7992. var formats = {};
  7993. var style = node.style || {};
  7994. if (style.fontStyle && computeStyle(node).fontStyle === 'italic') {
  7995. formats.italic = true;
  7996. }
  7997. if (style.fontWeight && (computeStyle(node).fontWeight.startsWith('bold') || parseInt(computeStyle(node).fontWeight) >= 700)) {
  7998. formats.bold = true;
  7999. }
  8000. if (Object.keys(formats).length > 0) {
  8001. delta = applyFormat(delta, formats);
  8002. }
  8003. if (parseFloat(style.textIndent || 0) > 0) {
  8004. // Could be 0.5in
  8005. delta = new _quillDelta2.default().insert('\t').concat(delta);
  8006. }
  8007. return delta;
  8008. }
  8009. function matchText(node, delta) {
  8010. var text = node.data;
  8011. // Word represents empty line with <o:p>&nbsp;</o:p>
  8012. if (node.parentNode.tagName === 'O:P') {
  8013. return delta.insert(text.trim());
  8014. }
  8015. if (text.trim().length === 0 && node.parentNode.classList.contains('ql-clipboard')) {
  8016. return delta;
  8017. }
  8018. if (!computeStyle(node.parentNode).whiteSpace.startsWith('pre')) {
  8019. // eslint-disable-next-line func-style
  8020. var replacer = function replacer(collapse, match) {
  8021. match = match.replace(/[^\u00a0]/g, ''); // \u00a0 is nbsp;
  8022. return match.length < 1 && collapse ? ' ' : match;
  8023. };
  8024. text = text.replace(/\r\n/g, ' ').replace(/\n/g, ' ');
  8025. text = text.replace(/\s\s+/g, replacer.bind(replacer, true)); // collapse whitespace
  8026. if (node.previousSibling == null && isLine(node.parentNode) || node.previousSibling != null && isLine(node.previousSibling)) {
  8027. text = text.replace(/^\s+/, replacer.bind(replacer, false));
  8028. }
  8029. if (node.nextSibling == null && isLine(node.parentNode) || node.nextSibling != null && isLine(node.nextSibling)) {
  8030. text = text.replace(/\s+$/, replacer.bind(replacer, false));
  8031. }
  8032. }
  8033. return delta.insert(text);
  8034. }
  8035. exports.default = Clipboard;
  8036. exports.matchAttributor = matchAttributor;
  8037. exports.matchBlot = matchBlot;
  8038. exports.matchNewline = matchNewline;
  8039. exports.matchSpacing = matchSpacing;
  8040. exports.matchText = matchText;
  8041. /***/ }),
  8042. /* 56 */
  8043. /***/ (function(module, exports, __webpack_require__) {
  8044. "use strict";
  8045. Object.defineProperty(exports, "__esModule", {
  8046. value: true
  8047. });
  8048. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  8049. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  8050. var _inline = __webpack_require__(6);
  8051. var _inline2 = _interopRequireDefault(_inline);
  8052. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8053. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8054. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  8055. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  8056. var Bold = function (_Inline) {
  8057. _inherits(Bold, _Inline);
  8058. function Bold() {
  8059. _classCallCheck(this, Bold);
  8060. return _possibleConstructorReturn(this, (Bold.__proto__ || Object.getPrototypeOf(Bold)).apply(this, arguments));
  8061. }
  8062. _createClass(Bold, [{
  8063. key: 'optimize',
  8064. value: function optimize(context) {
  8065. _get(Bold.prototype.__proto__ || Object.getPrototypeOf(Bold.prototype), 'optimize', this).call(this, context);
  8066. if (this.domNode.tagName !== this.statics.tagName[0]) {
  8067. this.replaceWith(this.statics.blotName);
  8068. }
  8069. }
  8070. }], [{
  8071. key: 'create',
  8072. value: function create() {
  8073. return _get(Bold.__proto__ || Object.getPrototypeOf(Bold), 'create', this).call(this);
  8074. }
  8075. }, {
  8076. key: 'formats',
  8077. value: function formats() {
  8078. return true;
  8079. }
  8080. }]);
  8081. return Bold;
  8082. }(_inline2.default);
  8083. Bold.blotName = 'bold';
  8084. Bold.tagName = ['STRONG', 'B'];
  8085. exports.default = Bold;
  8086. /***/ }),
  8087. /* 57 */
  8088. /***/ (function(module, exports, __webpack_require__) {
  8089. "use strict";
  8090. Object.defineProperty(exports, "__esModule", {
  8091. value: true
  8092. });
  8093. exports.addControls = exports.default = undefined;
  8094. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  8095. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  8096. var _quillDelta = __webpack_require__(2);
  8097. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  8098. var _parchment = __webpack_require__(0);
  8099. var _parchment2 = _interopRequireDefault(_parchment);
  8100. var _quill = __webpack_require__(5);
  8101. var _quill2 = _interopRequireDefault(_quill);
  8102. var _logger = __webpack_require__(10);
  8103. var _logger2 = _interopRequireDefault(_logger);
  8104. var _module = __webpack_require__(9);
  8105. var _module2 = _interopRequireDefault(_module);
  8106. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8107. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  8108. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8109. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  8110. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  8111. var debug = (0, _logger2.default)('quill:toolbar');
  8112. var Toolbar = function (_Module) {
  8113. _inherits(Toolbar, _Module);
  8114. function Toolbar(quill, options) {
  8115. _classCallCheck(this, Toolbar);
  8116. var _this = _possibleConstructorReturn(this, (Toolbar.__proto__ || Object.getPrototypeOf(Toolbar)).call(this, quill, options));
  8117. if (Array.isArray(_this.options.container)) {
  8118. var container = document.createElement('div');
  8119. addControls(container, _this.options.container);
  8120. quill.container.parentNode.insertBefore(container, quill.container);
  8121. _this.container = container;
  8122. } else if (typeof _this.options.container === 'string') {
  8123. _this.container = document.querySelector(_this.options.container);
  8124. } else {
  8125. _this.container = _this.options.container;
  8126. }
  8127. if (!(_this.container instanceof HTMLElement)) {
  8128. var _ret;
  8129. return _ret = debug.error('Container required for toolbar', _this.options), _possibleConstructorReturn(_this, _ret);
  8130. }
  8131. _this.container.classList.add('ql-toolbar');
  8132. _this.controls = [];
  8133. _this.handlers = {};
  8134. Object.keys(_this.options.handlers).forEach(function (format) {
  8135. _this.addHandler(format, _this.options.handlers[format]);
  8136. });
  8137. [].forEach.call(_this.container.querySelectorAll('button, select'), function (input) {
  8138. _this.attach(input);
  8139. });
  8140. _this.quill.on(_quill2.default.events.EDITOR_CHANGE, function (type, range) {
  8141. if (type === _quill2.default.events.SELECTION_CHANGE) {
  8142. _this.update(range);
  8143. }
  8144. });
  8145. _this.quill.on(_quill2.default.events.SCROLL_OPTIMIZE, function () {
  8146. var _this$quill$selection = _this.quill.selection.getRange(),
  8147. _this$quill$selection2 = _slicedToArray(_this$quill$selection, 1),
  8148. range = _this$quill$selection2[0]; // quill.getSelection triggers update
  8149. _this.update(range);
  8150. });
  8151. return _this;
  8152. }
  8153. _createClass(Toolbar, [{
  8154. key: 'addHandler',
  8155. value: function addHandler(format, handler) {
  8156. this.handlers[format] = handler;
  8157. }
  8158. }, {
  8159. key: 'attach',
  8160. value: function attach(input) {
  8161. var _this2 = this;
  8162. var format = [].find.call(input.classList, function (className) {
  8163. return className.indexOf('ql-') === 0;
  8164. });
  8165. if (!format) return;
  8166. format = format.slice('ql-'.length);
  8167. if (input.tagName === 'BUTTON') {
  8168. input.setAttribute('type', 'button');
  8169. }
  8170. if (this.handlers[format] == null) {
  8171. if (this.quill.scroll.whitelist != null && this.quill.scroll.whitelist[format] == null) {
  8172. debug.warn('ignoring attaching to disabled format', format, input);
  8173. return;
  8174. }
  8175. if (_parchment2.default.query(format) == null) {
  8176. debug.warn('ignoring attaching to nonexistent format', format, input);
  8177. return;
  8178. }
  8179. }
  8180. var eventName = input.tagName === 'SELECT' ? 'change' : 'click';
  8181. input.addEventListener(eventName, function (e) {
  8182. var value = void 0;
  8183. if (input.tagName === 'SELECT') {
  8184. if (input.selectedIndex < 0) return;
  8185. var selected = input.options[input.selectedIndex];
  8186. if (selected.hasAttribute('selected')) {
  8187. value = false;
  8188. } else {
  8189. value = selected.value || false;
  8190. }
  8191. } else {
  8192. if (input.classList.contains('ql-active')) {
  8193. value = false;
  8194. } else {
  8195. value = input.value || !input.hasAttribute('value');
  8196. }
  8197. e.preventDefault();
  8198. }
  8199. _this2.quill.focus();
  8200. var _quill$selection$getR = _this2.quill.selection.getRange(),
  8201. _quill$selection$getR2 = _slicedToArray(_quill$selection$getR, 1),
  8202. range = _quill$selection$getR2[0];
  8203. if (_this2.handlers[format] != null) {
  8204. _this2.handlers[format].call(_this2, value);
  8205. } else if (_parchment2.default.query(format).prototype instanceof _parchment2.default.Embed) {
  8206. value = prompt('Enter ' + format);
  8207. if (!value) return;
  8208. _this2.quill.updateContents(new _quillDelta2.default().retain(range.index).delete(range.length).insert(_defineProperty({}, format, value)), _quill2.default.sources.USER);
  8209. } else {
  8210. _this2.quill.format(format, value, _quill2.default.sources.USER);
  8211. }
  8212. _this2.update(range);
  8213. });
  8214. // TODO use weakmap
  8215. this.controls.push([format, input]);
  8216. }
  8217. }, {
  8218. key: 'update',
  8219. value: function update(range) {
  8220. var formats = range == null ? {} : this.quill.getFormat(range);
  8221. this.controls.forEach(function (pair) {
  8222. var _pair = _slicedToArray(pair, 2),
  8223. format = _pair[0],
  8224. input = _pair[1];
  8225. if (input.tagName === 'SELECT') {
  8226. var option = void 0;
  8227. if (range == null) {
  8228. option = null;
  8229. } else if (formats[format] == null) {
  8230. option = input.querySelector('option[selected]');
  8231. } else if (!Array.isArray(formats[format])) {
  8232. var value = formats[format];
  8233. if (typeof value === 'string') {
  8234. value = value.replace(/\"/g, '\\"');
  8235. }
  8236. option = input.querySelector('option[value="' + value + '"]');
  8237. }
  8238. if (option == null) {
  8239. input.value = ''; // TODO make configurable?
  8240. input.selectedIndex = -1;
  8241. } else {
  8242. option.selected = true;
  8243. }
  8244. } else {
  8245. if (range == null) {
  8246. input.classList.remove('ql-active');
  8247. } else if (input.hasAttribute('value')) {
  8248. // both being null should match (default values)
  8249. // '1' should match with 1 (headers)
  8250. var isActive = formats[format] === input.getAttribute('value') || formats[format] != null && formats[format].toString() === input.getAttribute('value') || formats[format] == null && !input.getAttribute('value');
  8251. input.classList.toggle('ql-active', isActive);
  8252. } else {
  8253. input.classList.toggle('ql-active', formats[format] != null);
  8254. }
  8255. }
  8256. });
  8257. }
  8258. }]);
  8259. return Toolbar;
  8260. }(_module2.default);
  8261. Toolbar.DEFAULTS = {};
  8262. function addButton(container, format, value) {
  8263. var input = document.createElement('button');
  8264. input.setAttribute('type', 'button');
  8265. input.classList.add('ql-' + format);
  8266. if (value != null) {
  8267. input.value = value;
  8268. }
  8269. container.appendChild(input);
  8270. }
  8271. function addControls(container, groups) {
  8272. if (!Array.isArray(groups[0])) {
  8273. groups = [groups];
  8274. }
  8275. groups.forEach(function (controls) {
  8276. var group = document.createElement('span');
  8277. group.classList.add('ql-formats');
  8278. controls.forEach(function (control) {
  8279. if (typeof control === 'string') {
  8280. addButton(group, control);
  8281. } else {
  8282. var format = Object.keys(control)[0];
  8283. var value = control[format];
  8284. if (Array.isArray(value)) {
  8285. addSelect(group, format, value);
  8286. } else {
  8287. addButton(group, format, value);
  8288. }
  8289. }
  8290. });
  8291. container.appendChild(group);
  8292. });
  8293. }
  8294. function addSelect(container, format, values) {
  8295. var input = document.createElement('select');
  8296. input.classList.add('ql-' + format);
  8297. values.forEach(function (value) {
  8298. var option = document.createElement('option');
  8299. if (value !== false) {
  8300. option.setAttribute('value', value);
  8301. } else {
  8302. option.setAttribute('selected', 'selected');
  8303. }
  8304. input.appendChild(option);
  8305. });
  8306. container.appendChild(input);
  8307. }
  8308. Toolbar.DEFAULTS = {
  8309. container: null,
  8310. handlers: {
  8311. clean: function clean() {
  8312. var _this3 = this;
  8313. var range = this.quill.getSelection();
  8314. if (range == null) return;
  8315. if (range.length == 0) {
  8316. var formats = this.quill.getFormat();
  8317. Object.keys(formats).forEach(function (name) {
  8318. // Clean functionality in existing apps only clean inline formats
  8319. if (_parchment2.default.query(name, _parchment2.default.Scope.INLINE) != null) {
  8320. _this3.quill.format(name, false);
  8321. }
  8322. });
  8323. } else {
  8324. this.quill.removeFormat(range, _quill2.default.sources.USER);
  8325. }
  8326. },
  8327. direction: function direction(value) {
  8328. var align = this.quill.getFormat()['align'];
  8329. if (value === 'rtl' && align == null) {
  8330. this.quill.format('align', 'right', _quill2.default.sources.USER);
  8331. } else if (!value && align === 'right') {
  8332. this.quill.format('align', false, _quill2.default.sources.USER);
  8333. }
  8334. this.quill.format('direction', value, _quill2.default.sources.USER);
  8335. },
  8336. indent: function indent(value) {
  8337. var range = this.quill.getSelection();
  8338. var formats = this.quill.getFormat(range);
  8339. var indent = parseInt(formats.indent || 0);
  8340. if (value === '+1' || value === '-1') {
  8341. var modifier = value === '+1' ? 1 : -1;
  8342. if (formats.direction === 'rtl') modifier *= -1;
  8343. this.quill.format('indent', indent + modifier, _quill2.default.sources.USER);
  8344. }
  8345. },
  8346. link: function link(value) {
  8347. if (value === true) {
  8348. value = prompt('Enter link URL:');
  8349. }
  8350. this.quill.format('link', value, _quill2.default.sources.USER);
  8351. },
  8352. list: function list(value) {
  8353. var range = this.quill.getSelection();
  8354. var formats = this.quill.getFormat(range);
  8355. if (value === 'check') {
  8356. if (formats['list'] === 'checked' || formats['list'] === 'unchecked') {
  8357. this.quill.format('list', false, _quill2.default.sources.USER);
  8358. } else {
  8359. this.quill.format('list', 'unchecked', _quill2.default.sources.USER);
  8360. }
  8361. } else {
  8362. this.quill.format('list', value, _quill2.default.sources.USER);
  8363. }
  8364. }
  8365. }
  8366. };
  8367. exports.default = Toolbar;
  8368. exports.addControls = addControls;
  8369. /***/ }),
  8370. /* 58 */
  8371. /***/ (function(module, exports) {
  8372. module.exports = "<svg viewbox=\"0 0 18 18\"> <polyline class=\"ql-even ql-stroke\" points=\"5 7 3 9 5 11\"></polyline> <polyline class=\"ql-even ql-stroke\" points=\"13 7 15 9 13 11\"></polyline> <line class=ql-stroke x1=10 x2=8 y1=5 y2=13></line> </svg>";
  8373. /***/ }),
  8374. /* 59 */
  8375. /***/ (function(module, exports, __webpack_require__) {
  8376. "use strict";
  8377. Object.defineProperty(exports, "__esModule", {
  8378. value: true
  8379. });
  8380. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  8381. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  8382. var _picker = __webpack_require__(28);
  8383. var _picker2 = _interopRequireDefault(_picker);
  8384. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8385. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8386. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  8387. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  8388. var ColorPicker = function (_Picker) {
  8389. _inherits(ColorPicker, _Picker);
  8390. function ColorPicker(select, label) {
  8391. _classCallCheck(this, ColorPicker);
  8392. var _this = _possibleConstructorReturn(this, (ColorPicker.__proto__ || Object.getPrototypeOf(ColorPicker)).call(this, select));
  8393. _this.label.innerHTML = label;
  8394. _this.container.classList.add('ql-color-picker');
  8395. [].slice.call(_this.container.querySelectorAll('.ql-picker-item'), 0, 7).forEach(function (item) {
  8396. item.classList.add('ql-primary');
  8397. });
  8398. return _this;
  8399. }
  8400. _createClass(ColorPicker, [{
  8401. key: 'buildItem',
  8402. value: function buildItem(option) {
  8403. var item = _get(ColorPicker.prototype.__proto__ || Object.getPrototypeOf(ColorPicker.prototype), 'buildItem', this).call(this, option);
  8404. item.style.backgroundColor = option.getAttribute('value') || '';
  8405. return item;
  8406. }
  8407. }, {
  8408. key: 'selectItem',
  8409. value: function selectItem(item, trigger) {
  8410. _get(ColorPicker.prototype.__proto__ || Object.getPrototypeOf(ColorPicker.prototype), 'selectItem', this).call(this, item, trigger);
  8411. var colorLabel = this.label.querySelector('.ql-color-label');
  8412. var value = item ? item.getAttribute('data-value') || '' : '';
  8413. if (colorLabel) {
  8414. if (colorLabel.tagName === 'line') {
  8415. colorLabel.style.stroke = value;
  8416. } else {
  8417. colorLabel.style.fill = value;
  8418. }
  8419. }
  8420. }
  8421. }]);
  8422. return ColorPicker;
  8423. }(_picker2.default);
  8424. exports.default = ColorPicker;
  8425. /***/ }),
  8426. /* 60 */
  8427. /***/ (function(module, exports, __webpack_require__) {
  8428. "use strict";
  8429. Object.defineProperty(exports, "__esModule", {
  8430. value: true
  8431. });
  8432. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  8433. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  8434. var _picker = __webpack_require__(28);
  8435. var _picker2 = _interopRequireDefault(_picker);
  8436. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8437. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8438. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  8439. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  8440. var IconPicker = function (_Picker) {
  8441. _inherits(IconPicker, _Picker);
  8442. function IconPicker(select, icons) {
  8443. _classCallCheck(this, IconPicker);
  8444. var _this = _possibleConstructorReturn(this, (IconPicker.__proto__ || Object.getPrototypeOf(IconPicker)).call(this, select));
  8445. _this.container.classList.add('ql-icon-picker');
  8446. [].forEach.call(_this.container.querySelectorAll('.ql-picker-item'), function (item) {
  8447. item.innerHTML = icons[item.getAttribute('data-value') || ''];
  8448. });
  8449. _this.defaultItem = _this.container.querySelector('.ql-selected');
  8450. _this.selectItem(_this.defaultItem);
  8451. return _this;
  8452. }
  8453. _createClass(IconPicker, [{
  8454. key: 'selectItem',
  8455. value: function selectItem(item, trigger) {
  8456. _get(IconPicker.prototype.__proto__ || Object.getPrototypeOf(IconPicker.prototype), 'selectItem', this).call(this, item, trigger);
  8457. item = item || this.defaultItem;
  8458. this.label.innerHTML = item.innerHTML;
  8459. }
  8460. }]);
  8461. return IconPicker;
  8462. }(_picker2.default);
  8463. exports.default = IconPicker;
  8464. /***/ }),
  8465. /* 61 */
  8466. /***/ (function(module, exports, __webpack_require__) {
  8467. "use strict";
  8468. Object.defineProperty(exports, "__esModule", {
  8469. value: true
  8470. });
  8471. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  8472. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8473. var Tooltip = function () {
  8474. function Tooltip(quill, boundsContainer) {
  8475. var _this = this;
  8476. _classCallCheck(this, Tooltip);
  8477. this.quill = quill;
  8478. this.boundsContainer = boundsContainer || document.body;
  8479. this.root = quill.addContainer('ql-tooltip');
  8480. this.root.innerHTML = this.constructor.TEMPLATE;
  8481. if (this.quill.root === this.quill.scrollingContainer) {
  8482. this.quill.root.addEventListener('scroll', function () {
  8483. _this.root.style.marginTop = -1 * _this.quill.root.scrollTop + 'px';
  8484. });
  8485. }
  8486. this.hide();
  8487. }
  8488. _createClass(Tooltip, [{
  8489. key: 'hide',
  8490. value: function hide() {
  8491. this.root.classList.add('ql-hidden');
  8492. }
  8493. }, {
  8494. key: 'position',
  8495. value: function position(reference) {
  8496. var left = reference.left + reference.width / 2 - this.root.offsetWidth / 2;
  8497. // root.scrollTop should be 0 if scrollContainer !== root
  8498. var top = reference.bottom + this.quill.root.scrollTop;
  8499. this.root.style.left = left + 'px';
  8500. this.root.style.top = top + 'px';
  8501. this.root.classList.remove('ql-flip');
  8502. var containerBounds = this.boundsContainer.getBoundingClientRect();
  8503. var rootBounds = this.root.getBoundingClientRect();
  8504. var shift = 0;
  8505. if (rootBounds.right > containerBounds.right) {
  8506. shift = containerBounds.right - rootBounds.right;
  8507. this.root.style.left = left + shift + 'px';
  8508. }
  8509. if (rootBounds.left < containerBounds.left) {
  8510. shift = containerBounds.left - rootBounds.left;
  8511. this.root.style.left = left + shift + 'px';
  8512. }
  8513. if (rootBounds.bottom > containerBounds.bottom) {
  8514. var height = rootBounds.bottom - rootBounds.top;
  8515. var verticalShift = reference.bottom - reference.top + height;
  8516. this.root.style.top = top - verticalShift + 'px';
  8517. this.root.classList.add('ql-flip');
  8518. }
  8519. return shift;
  8520. }
  8521. }, {
  8522. key: 'show',
  8523. value: function show() {
  8524. this.root.classList.remove('ql-editing');
  8525. this.root.classList.remove('ql-hidden');
  8526. }
  8527. }]);
  8528. return Tooltip;
  8529. }();
  8530. exports.default = Tooltip;
  8531. /***/ }),
  8532. /* 62 */
  8533. /***/ (function(module, exports, __webpack_require__) {
  8534. "use strict";
  8535. Object.defineProperty(exports, "__esModule", {
  8536. value: true
  8537. });
  8538. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  8539. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  8540. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  8541. var _extend = __webpack_require__(3);
  8542. var _extend2 = _interopRequireDefault(_extend);
  8543. var _emitter = __webpack_require__(8);
  8544. var _emitter2 = _interopRequireDefault(_emitter);
  8545. var _base = __webpack_require__(43);
  8546. var _base2 = _interopRequireDefault(_base);
  8547. var _link = __webpack_require__(27);
  8548. var _link2 = _interopRequireDefault(_link);
  8549. var _selection = __webpack_require__(15);
  8550. var _icons = __webpack_require__(41);
  8551. var _icons2 = _interopRequireDefault(_icons);
  8552. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8553. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8554. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  8555. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  8556. var TOOLBAR_CONFIG = [[{ header: ['1', '2', '3', false] }], ['bold', 'italic', 'underline', 'link'], [{ list: 'ordered' }, { list: 'bullet' }], ['clean']];
  8557. var SnowTheme = function (_BaseTheme) {
  8558. _inherits(SnowTheme, _BaseTheme);
  8559. function SnowTheme(quill, options) {
  8560. _classCallCheck(this, SnowTheme);
  8561. if (options.modules.toolbar != null && options.modules.toolbar.container == null) {
  8562. options.modules.toolbar.container = TOOLBAR_CONFIG;
  8563. }
  8564. var _this = _possibleConstructorReturn(this, (SnowTheme.__proto__ || Object.getPrototypeOf(SnowTheme)).call(this, quill, options));
  8565. _this.quill.container.classList.add('ql-snow');
  8566. return _this;
  8567. }
  8568. _createClass(SnowTheme, [{
  8569. key: 'extendToolbar',
  8570. value: function extendToolbar(toolbar) {
  8571. toolbar.container.classList.add('ql-snow');
  8572. this.buildButtons([].slice.call(toolbar.container.querySelectorAll('button')), _icons2.default);
  8573. this.buildPickers([].slice.call(toolbar.container.querySelectorAll('select')), _icons2.default);
  8574. this.tooltip = new SnowTooltip(this.quill, this.options.bounds);
  8575. if (toolbar.container.querySelector('.ql-link')) {
  8576. this.quill.keyboard.addBinding({ key: 'K', shortKey: true }, function (range, context) {
  8577. toolbar.handlers['link'].call(toolbar, !context.format.link);
  8578. });
  8579. }
  8580. }
  8581. }]);
  8582. return SnowTheme;
  8583. }(_base2.default);
  8584. SnowTheme.DEFAULTS = (0, _extend2.default)(true, {}, _base2.default.DEFAULTS, {
  8585. modules: {
  8586. toolbar: {
  8587. handlers: {
  8588. link: function link(value) {
  8589. if (value) {
  8590. var range = this.quill.getSelection();
  8591. if (range == null || range.length == 0) return;
  8592. var preview = this.quill.getText(range);
  8593. if (/^\S+@\S+\.\S+$/.test(preview) && preview.indexOf('mailto:') !== 0) {
  8594. preview = 'mailto:' + preview;
  8595. }
  8596. var tooltip = this.quill.theme.tooltip;
  8597. tooltip.edit('link', preview);
  8598. } else {
  8599. this.quill.format('link', false);
  8600. }
  8601. }
  8602. }
  8603. }
  8604. }
  8605. });
  8606. var SnowTooltip = function (_BaseTooltip) {
  8607. _inherits(SnowTooltip, _BaseTooltip);
  8608. function SnowTooltip(quill, bounds) {
  8609. _classCallCheck(this, SnowTooltip);
  8610. var _this2 = _possibleConstructorReturn(this, (SnowTooltip.__proto__ || Object.getPrototypeOf(SnowTooltip)).call(this, quill, bounds));
  8611. _this2.preview = _this2.root.querySelector('a.ql-preview');
  8612. return _this2;
  8613. }
  8614. _createClass(SnowTooltip, [{
  8615. key: 'listen',
  8616. value: function listen() {
  8617. var _this3 = this;
  8618. _get(SnowTooltip.prototype.__proto__ || Object.getPrototypeOf(SnowTooltip.prototype), 'listen', this).call(this);
  8619. this.root.querySelector('a.ql-action').addEventListener('click', function (event) {
  8620. if (_this3.root.classList.contains('ql-editing')) {
  8621. _this3.save();
  8622. } else {
  8623. _this3.edit('link', _this3.preview.textContent);
  8624. }
  8625. event.preventDefault();
  8626. });
  8627. this.root.querySelector('a.ql-remove').addEventListener('click', function (event) {
  8628. if (_this3.linkRange != null) {
  8629. var range = _this3.linkRange;
  8630. _this3.restoreFocus();
  8631. _this3.quill.formatText(range, 'link', false, _emitter2.default.sources.USER);
  8632. delete _this3.linkRange;
  8633. }
  8634. event.preventDefault();
  8635. _this3.hide();
  8636. });
  8637. this.quill.on(_emitter2.default.events.SELECTION_CHANGE, function (range, oldRange, source) {
  8638. if (range == null) return;
  8639. if (range.length === 0 && source === _emitter2.default.sources.USER) {
  8640. var _quill$scroll$descend = _this3.quill.scroll.descendant(_link2.default, range.index),
  8641. _quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2),
  8642. link = _quill$scroll$descend2[0],
  8643. offset = _quill$scroll$descend2[1];
  8644. if (link != null) {
  8645. _this3.linkRange = new _selection.Range(range.index - offset, link.length());
  8646. var preview = _link2.default.formats(link.domNode);
  8647. _this3.preview.textContent = preview;
  8648. _this3.preview.setAttribute('href', preview);
  8649. _this3.show();
  8650. _this3.position(_this3.quill.getBounds(_this3.linkRange));
  8651. return;
  8652. }
  8653. } else {
  8654. delete _this3.linkRange;
  8655. }
  8656. _this3.hide();
  8657. });
  8658. }
  8659. }, {
  8660. key: 'show',
  8661. value: function show() {
  8662. _get(SnowTooltip.prototype.__proto__ || Object.getPrototypeOf(SnowTooltip.prototype), 'show', this).call(this);
  8663. this.root.removeAttribute('data-mode');
  8664. }
  8665. }]);
  8666. return SnowTooltip;
  8667. }(_base.BaseTooltip);
  8668. SnowTooltip.TEMPLATE = ['<a class="ql-preview" rel="noopener noreferrer" target="_blank" href="about:blank"></a>', '<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">', '<a class="ql-action"></a>', '<a class="ql-remove"></a>'].join('');
  8669. exports.default = SnowTheme;
  8670. /***/ }),
  8671. /* 63 */
  8672. /***/ (function(module, exports, __webpack_require__) {
  8673. "use strict";
  8674. Object.defineProperty(exports, "__esModule", {
  8675. value: true
  8676. });
  8677. var _core = __webpack_require__(29);
  8678. var _core2 = _interopRequireDefault(_core);
  8679. var _align = __webpack_require__(36);
  8680. var _direction = __webpack_require__(38);
  8681. var _indent = __webpack_require__(64);
  8682. var _blockquote = __webpack_require__(65);
  8683. var _blockquote2 = _interopRequireDefault(_blockquote);
  8684. var _header = __webpack_require__(66);
  8685. var _header2 = _interopRequireDefault(_header);
  8686. var _list = __webpack_require__(67);
  8687. var _list2 = _interopRequireDefault(_list);
  8688. var _background = __webpack_require__(37);
  8689. var _color = __webpack_require__(26);
  8690. var _font = __webpack_require__(39);
  8691. var _size = __webpack_require__(40);
  8692. var _bold = __webpack_require__(56);
  8693. var _bold2 = _interopRequireDefault(_bold);
  8694. var _italic = __webpack_require__(68);
  8695. var _italic2 = _interopRequireDefault(_italic);
  8696. var _link = __webpack_require__(27);
  8697. var _link2 = _interopRequireDefault(_link);
  8698. var _script = __webpack_require__(69);
  8699. var _script2 = _interopRequireDefault(_script);
  8700. var _strike = __webpack_require__(70);
  8701. var _strike2 = _interopRequireDefault(_strike);
  8702. var _underline = __webpack_require__(71);
  8703. var _underline2 = _interopRequireDefault(_underline);
  8704. var _image = __webpack_require__(72);
  8705. var _image2 = _interopRequireDefault(_image);
  8706. var _video = __webpack_require__(73);
  8707. var _video2 = _interopRequireDefault(_video);
  8708. var _code = __webpack_require__(13);
  8709. var _code2 = _interopRequireDefault(_code);
  8710. var _formula = __webpack_require__(74);
  8711. var _formula2 = _interopRequireDefault(_formula);
  8712. var _syntax = __webpack_require__(75);
  8713. var _syntax2 = _interopRequireDefault(_syntax);
  8714. var _toolbar = __webpack_require__(57);
  8715. var _toolbar2 = _interopRequireDefault(_toolbar);
  8716. var _icons = __webpack_require__(41);
  8717. var _icons2 = _interopRequireDefault(_icons);
  8718. var _picker = __webpack_require__(28);
  8719. var _picker2 = _interopRequireDefault(_picker);
  8720. var _colorPicker = __webpack_require__(59);
  8721. var _colorPicker2 = _interopRequireDefault(_colorPicker);
  8722. var _iconPicker = __webpack_require__(60);
  8723. var _iconPicker2 = _interopRequireDefault(_iconPicker);
  8724. var _tooltip = __webpack_require__(61);
  8725. var _tooltip2 = _interopRequireDefault(_tooltip);
  8726. var _bubble = __webpack_require__(108);
  8727. var _bubble2 = _interopRequireDefault(_bubble);
  8728. var _snow = __webpack_require__(62);
  8729. var _snow2 = _interopRequireDefault(_snow);
  8730. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8731. _core2.default.register({
  8732. 'attributors/attribute/direction': _direction.DirectionAttribute,
  8733. 'attributors/class/align': _align.AlignClass,
  8734. 'attributors/class/background': _background.BackgroundClass,
  8735. 'attributors/class/color': _color.ColorClass,
  8736. 'attributors/class/direction': _direction.DirectionClass,
  8737. 'attributors/class/font': _font.FontClass,
  8738. 'attributors/class/size': _size.SizeClass,
  8739. 'attributors/style/align': _align.AlignStyle,
  8740. 'attributors/style/background': _background.BackgroundStyle,
  8741. 'attributors/style/color': _color.ColorStyle,
  8742. 'attributors/style/direction': _direction.DirectionStyle,
  8743. 'attributors/style/font': _font.FontStyle,
  8744. 'attributors/style/size': _size.SizeStyle
  8745. }, true);
  8746. _core2.default.register({
  8747. 'formats/align': _align.AlignClass,
  8748. 'formats/direction': _direction.DirectionClass,
  8749. 'formats/indent': _indent.IndentClass,
  8750. 'formats/background': _background.BackgroundStyle,
  8751. 'formats/color': _color.ColorStyle,
  8752. 'formats/font': _font.FontClass,
  8753. 'formats/size': _size.SizeClass,
  8754. 'formats/blockquote': _blockquote2.default,
  8755. 'formats/code-block': _code2.default,
  8756. 'formats/header': _header2.default,
  8757. 'formats/list': _list2.default,
  8758. 'formats/bold': _bold2.default,
  8759. 'formats/code': _code.Code,
  8760. 'formats/italic': _italic2.default,
  8761. 'formats/link': _link2.default,
  8762. 'formats/script': _script2.default,
  8763. 'formats/strike': _strike2.default,
  8764. 'formats/underline': _underline2.default,
  8765. 'formats/image': _image2.default,
  8766. 'formats/video': _video2.default,
  8767. 'formats/list/item': _list.ListItem,
  8768. 'modules/formula': _formula2.default,
  8769. 'modules/syntax': _syntax2.default,
  8770. 'modules/toolbar': _toolbar2.default,
  8771. 'themes/bubble': _bubble2.default,
  8772. 'themes/snow': _snow2.default,
  8773. 'ui/icons': _icons2.default,
  8774. 'ui/picker': _picker2.default,
  8775. 'ui/icon-picker': _iconPicker2.default,
  8776. 'ui/color-picker': _colorPicker2.default,
  8777. 'ui/tooltip': _tooltip2.default
  8778. }, true);
  8779. exports.default = _core2.default;
  8780. /***/ }),
  8781. /* 64 */
  8782. /***/ (function(module, exports, __webpack_require__) {
  8783. "use strict";
  8784. Object.defineProperty(exports, "__esModule", {
  8785. value: true
  8786. });
  8787. exports.IndentClass = undefined;
  8788. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  8789. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  8790. var _parchment = __webpack_require__(0);
  8791. var _parchment2 = _interopRequireDefault(_parchment);
  8792. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8793. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8794. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  8795. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  8796. var IdentAttributor = function (_Parchment$Attributor) {
  8797. _inherits(IdentAttributor, _Parchment$Attributor);
  8798. function IdentAttributor() {
  8799. _classCallCheck(this, IdentAttributor);
  8800. return _possibleConstructorReturn(this, (IdentAttributor.__proto__ || Object.getPrototypeOf(IdentAttributor)).apply(this, arguments));
  8801. }
  8802. _createClass(IdentAttributor, [{
  8803. key: 'add',
  8804. value: function add(node, value) {
  8805. if (value === '+1' || value === '-1') {
  8806. var indent = this.value(node) || 0;
  8807. value = value === '+1' ? indent + 1 : indent - 1;
  8808. }
  8809. if (value === 0) {
  8810. this.remove(node);
  8811. return true;
  8812. } else {
  8813. return _get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'add', this).call(this, node, value);
  8814. }
  8815. }
  8816. }, {
  8817. key: 'canAdd',
  8818. value: function canAdd(node, value) {
  8819. return _get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'canAdd', this).call(this, node, value) || _get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'canAdd', this).call(this, node, parseInt(value));
  8820. }
  8821. }, {
  8822. key: 'value',
  8823. value: function value(node) {
  8824. return parseInt(_get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'value', this).call(this, node)) || undefined; // Don't return NaN
  8825. }
  8826. }]);
  8827. return IdentAttributor;
  8828. }(_parchment2.default.Attributor.Class);
  8829. var IndentClass = new IdentAttributor('indent', 'ql-indent', {
  8830. scope: _parchment2.default.Scope.BLOCK,
  8831. whitelist: [1, 2, 3, 4, 5, 6, 7, 8]
  8832. });
  8833. exports.IndentClass = IndentClass;
  8834. /***/ }),
  8835. /* 65 */
  8836. /***/ (function(module, exports, __webpack_require__) {
  8837. "use strict";
  8838. Object.defineProperty(exports, "__esModule", {
  8839. value: true
  8840. });
  8841. var _block = __webpack_require__(4);
  8842. var _block2 = _interopRequireDefault(_block);
  8843. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8844. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8845. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  8846. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  8847. var Blockquote = function (_Block) {
  8848. _inherits(Blockquote, _Block);
  8849. function Blockquote() {
  8850. _classCallCheck(this, Blockquote);
  8851. return _possibleConstructorReturn(this, (Blockquote.__proto__ || Object.getPrototypeOf(Blockquote)).apply(this, arguments));
  8852. }
  8853. return Blockquote;
  8854. }(_block2.default);
  8855. Blockquote.blotName = 'blockquote';
  8856. Blockquote.tagName = 'blockquote';
  8857. exports.default = Blockquote;
  8858. /***/ }),
  8859. /* 66 */
  8860. /***/ (function(module, exports, __webpack_require__) {
  8861. "use strict";
  8862. Object.defineProperty(exports, "__esModule", {
  8863. value: true
  8864. });
  8865. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  8866. var _block = __webpack_require__(4);
  8867. var _block2 = _interopRequireDefault(_block);
  8868. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8869. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8870. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  8871. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  8872. var Header = function (_Block) {
  8873. _inherits(Header, _Block);
  8874. function Header() {
  8875. _classCallCheck(this, Header);
  8876. return _possibleConstructorReturn(this, (Header.__proto__ || Object.getPrototypeOf(Header)).apply(this, arguments));
  8877. }
  8878. _createClass(Header, null, [{
  8879. key: 'formats',
  8880. value: function formats(domNode) {
  8881. return this.tagName.indexOf(domNode.tagName) + 1;
  8882. }
  8883. }]);
  8884. return Header;
  8885. }(_block2.default);
  8886. Header.blotName = 'header';
  8887. Header.tagName = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
  8888. exports.default = Header;
  8889. /***/ }),
  8890. /* 67 */
  8891. /***/ (function(module, exports, __webpack_require__) {
  8892. "use strict";
  8893. Object.defineProperty(exports, "__esModule", {
  8894. value: true
  8895. });
  8896. exports.default = exports.ListItem = undefined;
  8897. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  8898. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  8899. var _parchment = __webpack_require__(0);
  8900. var _parchment2 = _interopRequireDefault(_parchment);
  8901. var _block = __webpack_require__(4);
  8902. var _block2 = _interopRequireDefault(_block);
  8903. var _container = __webpack_require__(25);
  8904. var _container2 = _interopRequireDefault(_container);
  8905. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8906. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  8907. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8908. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  8909. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  8910. var ListItem = function (_Block) {
  8911. _inherits(ListItem, _Block);
  8912. function ListItem() {
  8913. _classCallCheck(this, ListItem);
  8914. return _possibleConstructorReturn(this, (ListItem.__proto__ || Object.getPrototypeOf(ListItem)).apply(this, arguments));
  8915. }
  8916. _createClass(ListItem, [{
  8917. key: 'format',
  8918. value: function format(name, value) {
  8919. if (name === List.blotName && !value) {
  8920. this.replaceWith(_parchment2.default.create(this.statics.scope));
  8921. } else {
  8922. _get(ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), 'format', this).call(this, name, value);
  8923. }
  8924. }
  8925. }, {
  8926. key: 'remove',
  8927. value: function remove() {
  8928. if (this.prev == null && this.next == null) {
  8929. this.parent.remove();
  8930. } else {
  8931. _get(ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), 'remove', this).call(this);
  8932. }
  8933. }
  8934. }, {
  8935. key: 'replaceWith',
  8936. value: function replaceWith(name, value) {
  8937. this.parent.isolate(this.offset(this.parent), this.length());
  8938. if (name === this.parent.statics.blotName) {
  8939. this.parent.replaceWith(name, value);
  8940. return this;
  8941. } else {
  8942. this.parent.unwrap();
  8943. return _get(ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), 'replaceWith', this).call(this, name, value);
  8944. }
  8945. }
  8946. }], [{
  8947. key: 'formats',
  8948. value: function formats(domNode) {
  8949. return domNode.tagName === this.tagName ? undefined : _get(ListItem.__proto__ || Object.getPrototypeOf(ListItem), 'formats', this).call(this, domNode);
  8950. }
  8951. }]);
  8952. return ListItem;
  8953. }(_block2.default);
  8954. ListItem.blotName = 'list-item';
  8955. ListItem.tagName = 'LI';
  8956. var List = function (_Container) {
  8957. _inherits(List, _Container);
  8958. _createClass(List, null, [{
  8959. key: 'create',
  8960. value: function create(value) {
  8961. var tagName = value === 'ordered' ? 'OL' : 'UL';
  8962. var node = _get(List.__proto__ || Object.getPrototypeOf(List), 'create', this).call(this, tagName);
  8963. if (value === 'checked' || value === 'unchecked') {
  8964. node.setAttribute('data-checked', value === 'checked');
  8965. }
  8966. return node;
  8967. }
  8968. }, {
  8969. key: 'formats',
  8970. value: function formats(domNode) {
  8971. if (domNode.tagName === 'OL') return 'ordered';
  8972. if (domNode.tagName === 'UL') {
  8973. if (domNode.hasAttribute('data-checked')) {
  8974. return domNode.getAttribute('data-checked') === 'true' ? 'checked' : 'unchecked';
  8975. } else {
  8976. return 'bullet';
  8977. }
  8978. }
  8979. return undefined;
  8980. }
  8981. }]);
  8982. function List(domNode) {
  8983. _classCallCheck(this, List);
  8984. var _this2 = _possibleConstructorReturn(this, (List.__proto__ || Object.getPrototypeOf(List)).call(this, domNode));
  8985. var listEventHandler = function listEventHandler(e) {
  8986. if (e.target.parentNode !== domNode) return;
  8987. var format = _this2.statics.formats(domNode);
  8988. var blot = _parchment2.default.find(e.target);
  8989. if (format === 'checked') {
  8990. blot.format('list', 'unchecked');
  8991. } else if (format === 'unchecked') {
  8992. blot.format('list', 'checked');
  8993. }
  8994. };
  8995. domNode.addEventListener('touchstart', listEventHandler);
  8996. domNode.addEventListener('mousedown', listEventHandler);
  8997. return _this2;
  8998. }
  8999. _createClass(List, [{
  9000. key: 'format',
  9001. value: function format(name, value) {
  9002. if (this.children.length > 0) {
  9003. this.children.tail.format(name, value);
  9004. }
  9005. }
  9006. }, {
  9007. key: 'formats',
  9008. value: function formats() {
  9009. // We don't inherit from FormatBlot
  9010. return _defineProperty({}, this.statics.blotName, this.statics.formats(this.domNode));
  9011. }
  9012. }, {
  9013. key: 'insertBefore',
  9014. value: function insertBefore(blot, ref) {
  9015. if (blot instanceof ListItem) {
  9016. _get(List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), 'insertBefore', this).call(this, blot, ref);
  9017. } else {
  9018. var index = ref == null ? this.length() : ref.offset(this);
  9019. var after = this.split(index);
  9020. after.parent.insertBefore(blot, after);
  9021. }
  9022. }
  9023. }, {
  9024. key: 'optimize',
  9025. value: function optimize(context) {
  9026. _get(List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), 'optimize', this).call(this, context);
  9027. var next = this.next;
  9028. if (next != null && next.prev === this && next.statics.blotName === this.statics.blotName && next.domNode.tagName === this.domNode.tagName && next.domNode.getAttribute('data-checked') === this.domNode.getAttribute('data-checked')) {
  9029. next.moveChildren(this);
  9030. next.remove();
  9031. }
  9032. }
  9033. }, {
  9034. key: 'replace',
  9035. value: function replace(target) {
  9036. if (target.statics.blotName !== this.statics.blotName) {
  9037. var item = _parchment2.default.create(this.statics.defaultChild);
  9038. target.moveChildren(item);
  9039. this.appendChild(item);
  9040. }
  9041. _get(List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), 'replace', this).call(this, target);
  9042. }
  9043. }]);
  9044. return List;
  9045. }(_container2.default);
  9046. List.blotName = 'list';
  9047. List.scope = _parchment2.default.Scope.BLOCK_BLOT;
  9048. List.tagName = ['OL', 'UL'];
  9049. List.defaultChild = 'list-item';
  9050. List.allowedChildren = [ListItem];
  9051. exports.ListItem = ListItem;
  9052. exports.default = List;
  9053. /***/ }),
  9054. /* 68 */
  9055. /***/ (function(module, exports, __webpack_require__) {
  9056. "use strict";
  9057. Object.defineProperty(exports, "__esModule", {
  9058. value: true
  9059. });
  9060. var _bold = __webpack_require__(56);
  9061. var _bold2 = _interopRequireDefault(_bold);
  9062. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9063. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9064. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9065. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  9066. var Italic = function (_Bold) {
  9067. _inherits(Italic, _Bold);
  9068. function Italic() {
  9069. _classCallCheck(this, Italic);
  9070. return _possibleConstructorReturn(this, (Italic.__proto__ || Object.getPrototypeOf(Italic)).apply(this, arguments));
  9071. }
  9072. return Italic;
  9073. }(_bold2.default);
  9074. Italic.blotName = 'italic';
  9075. Italic.tagName = ['EM', 'I'];
  9076. exports.default = Italic;
  9077. /***/ }),
  9078. /* 69 */
  9079. /***/ (function(module, exports, __webpack_require__) {
  9080. "use strict";
  9081. Object.defineProperty(exports, "__esModule", {
  9082. value: true
  9083. });
  9084. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9085. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  9086. var _inline = __webpack_require__(6);
  9087. var _inline2 = _interopRequireDefault(_inline);
  9088. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9089. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9090. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9091. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  9092. var Script = function (_Inline) {
  9093. _inherits(Script, _Inline);
  9094. function Script() {
  9095. _classCallCheck(this, Script);
  9096. return _possibleConstructorReturn(this, (Script.__proto__ || Object.getPrototypeOf(Script)).apply(this, arguments));
  9097. }
  9098. _createClass(Script, null, [{
  9099. key: 'create',
  9100. value: function create(value) {
  9101. if (value === 'super') {
  9102. return document.createElement('sup');
  9103. } else if (value === 'sub') {
  9104. return document.createElement('sub');
  9105. } else {
  9106. return _get(Script.__proto__ || Object.getPrototypeOf(Script), 'create', this).call(this, value);
  9107. }
  9108. }
  9109. }, {
  9110. key: 'formats',
  9111. value: function formats(domNode) {
  9112. if (domNode.tagName === 'SUB') return 'sub';
  9113. if (domNode.tagName === 'SUP') return 'super';
  9114. return undefined;
  9115. }
  9116. }]);
  9117. return Script;
  9118. }(_inline2.default);
  9119. Script.blotName = 'script';
  9120. Script.tagName = ['SUB', 'SUP'];
  9121. exports.default = Script;
  9122. /***/ }),
  9123. /* 70 */
  9124. /***/ (function(module, exports, __webpack_require__) {
  9125. "use strict";
  9126. Object.defineProperty(exports, "__esModule", {
  9127. value: true
  9128. });
  9129. var _inline = __webpack_require__(6);
  9130. var _inline2 = _interopRequireDefault(_inline);
  9131. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9132. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9133. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9134. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  9135. var Strike = function (_Inline) {
  9136. _inherits(Strike, _Inline);
  9137. function Strike() {
  9138. _classCallCheck(this, Strike);
  9139. return _possibleConstructorReturn(this, (Strike.__proto__ || Object.getPrototypeOf(Strike)).apply(this, arguments));
  9140. }
  9141. return Strike;
  9142. }(_inline2.default);
  9143. Strike.blotName = 'strike';
  9144. Strike.tagName = 'S';
  9145. exports.default = Strike;
  9146. /***/ }),
  9147. /* 71 */
  9148. /***/ (function(module, exports, __webpack_require__) {
  9149. "use strict";
  9150. Object.defineProperty(exports, "__esModule", {
  9151. value: true
  9152. });
  9153. var _inline = __webpack_require__(6);
  9154. var _inline2 = _interopRequireDefault(_inline);
  9155. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9156. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9157. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9158. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  9159. var Underline = function (_Inline) {
  9160. _inherits(Underline, _Inline);
  9161. function Underline() {
  9162. _classCallCheck(this, Underline);
  9163. return _possibleConstructorReturn(this, (Underline.__proto__ || Object.getPrototypeOf(Underline)).apply(this, arguments));
  9164. }
  9165. return Underline;
  9166. }(_inline2.default);
  9167. Underline.blotName = 'underline';
  9168. Underline.tagName = 'U';
  9169. exports.default = Underline;
  9170. /***/ }),
  9171. /* 72 */
  9172. /***/ (function(module, exports, __webpack_require__) {
  9173. "use strict";
  9174. Object.defineProperty(exports, "__esModule", {
  9175. value: true
  9176. });
  9177. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9178. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  9179. var _parchment = __webpack_require__(0);
  9180. var _parchment2 = _interopRequireDefault(_parchment);
  9181. var _link = __webpack_require__(27);
  9182. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9183. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9184. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9185. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  9186. var ATTRIBUTES = ['alt', 'height', 'width'];
  9187. var Image = function (_Parchment$Embed) {
  9188. _inherits(Image, _Parchment$Embed);
  9189. function Image() {
  9190. _classCallCheck(this, Image);
  9191. return _possibleConstructorReturn(this, (Image.__proto__ || Object.getPrototypeOf(Image)).apply(this, arguments));
  9192. }
  9193. _createClass(Image, [{
  9194. key: 'format',
  9195. value: function format(name, value) {
  9196. if (ATTRIBUTES.indexOf(name) > -1) {
  9197. if (value) {
  9198. this.domNode.setAttribute(name, value);
  9199. } else {
  9200. this.domNode.removeAttribute(name);
  9201. }
  9202. } else {
  9203. _get(Image.prototype.__proto__ || Object.getPrototypeOf(Image.prototype), 'format', this).call(this, name, value);
  9204. }
  9205. }
  9206. }], [{
  9207. key: 'create',
  9208. value: function create(value) {
  9209. var node = _get(Image.__proto__ || Object.getPrototypeOf(Image), 'create', this).call(this, value);
  9210. if (typeof value === 'string') {
  9211. node.setAttribute('src', this.sanitize(value));
  9212. }
  9213. return node;
  9214. }
  9215. }, {
  9216. key: 'formats',
  9217. value: function formats(domNode) {
  9218. return ATTRIBUTES.reduce(function (formats, attribute) {
  9219. if (domNode.hasAttribute(attribute)) {
  9220. formats[attribute] = domNode.getAttribute(attribute);
  9221. }
  9222. return formats;
  9223. }, {});
  9224. }
  9225. }, {
  9226. key: 'match',
  9227. value: function match(url) {
  9228. return (/\.(jpe?g|gif|png)$/.test(url) || /^data:image\/.+;base64/.test(url)
  9229. );
  9230. }
  9231. }, {
  9232. key: 'sanitize',
  9233. value: function sanitize(url) {
  9234. return (0, _link.sanitize)(url, ['http', 'https', 'data']) ? url : '//:0';
  9235. }
  9236. }, {
  9237. key: 'value',
  9238. value: function value(domNode) {
  9239. return domNode.getAttribute('src');
  9240. }
  9241. }]);
  9242. return Image;
  9243. }(_parchment2.default.Embed);
  9244. Image.blotName = 'image';
  9245. Image.tagName = 'IMG';
  9246. exports.default = Image;
  9247. /***/ }),
  9248. /* 73 */
  9249. /***/ (function(module, exports, __webpack_require__) {
  9250. "use strict";
  9251. Object.defineProperty(exports, "__esModule", {
  9252. value: true
  9253. });
  9254. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9255. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  9256. var _block = __webpack_require__(4);
  9257. var _link = __webpack_require__(27);
  9258. var _link2 = _interopRequireDefault(_link);
  9259. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9260. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9261. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9262. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  9263. var ATTRIBUTES = ['height', 'width'];
  9264. var Video = function (_BlockEmbed) {
  9265. _inherits(Video, _BlockEmbed);
  9266. function Video() {
  9267. _classCallCheck(this, Video);
  9268. return _possibleConstructorReturn(this, (Video.__proto__ || Object.getPrototypeOf(Video)).apply(this, arguments));
  9269. }
  9270. _createClass(Video, [{
  9271. key: 'format',
  9272. value: function format(name, value) {
  9273. if (ATTRIBUTES.indexOf(name) > -1) {
  9274. if (value) {
  9275. this.domNode.setAttribute(name, value);
  9276. } else {
  9277. this.domNode.removeAttribute(name);
  9278. }
  9279. } else {
  9280. _get(Video.prototype.__proto__ || Object.getPrototypeOf(Video.prototype), 'format', this).call(this, name, value);
  9281. }
  9282. }
  9283. }], [{
  9284. key: 'create',
  9285. value: function create(value) {
  9286. var node = _get(Video.__proto__ || Object.getPrototypeOf(Video), 'create', this).call(this, value);
  9287. node.setAttribute('frameborder', '0');
  9288. node.setAttribute('allowfullscreen', true);
  9289. node.setAttribute('src', this.sanitize(value));
  9290. return node;
  9291. }
  9292. }, {
  9293. key: 'formats',
  9294. value: function formats(domNode) {
  9295. return ATTRIBUTES.reduce(function (formats, attribute) {
  9296. if (domNode.hasAttribute(attribute)) {
  9297. formats[attribute] = domNode.getAttribute(attribute);
  9298. }
  9299. return formats;
  9300. }, {});
  9301. }
  9302. }, {
  9303. key: 'sanitize',
  9304. value: function sanitize(url) {
  9305. return _link2.default.sanitize(url);
  9306. }
  9307. }, {
  9308. key: 'value',
  9309. value: function value(domNode) {
  9310. return domNode.getAttribute('src');
  9311. }
  9312. }]);
  9313. return Video;
  9314. }(_block.BlockEmbed);
  9315. Video.blotName = 'video';
  9316. Video.className = 'ql-video';
  9317. Video.tagName = 'IFRAME';
  9318. exports.default = Video;
  9319. /***/ }),
  9320. /* 74 */
  9321. /***/ (function(module, exports, __webpack_require__) {
  9322. "use strict";
  9323. Object.defineProperty(exports, "__esModule", {
  9324. value: true
  9325. });
  9326. exports.default = exports.FormulaBlot = undefined;
  9327. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9328. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  9329. var _embed = __webpack_require__(35);
  9330. var _embed2 = _interopRequireDefault(_embed);
  9331. var _quill = __webpack_require__(5);
  9332. var _quill2 = _interopRequireDefault(_quill);
  9333. var _module = __webpack_require__(9);
  9334. var _module2 = _interopRequireDefault(_module);
  9335. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9336. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9337. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9338. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  9339. var FormulaBlot = function (_Embed) {
  9340. _inherits(FormulaBlot, _Embed);
  9341. function FormulaBlot() {
  9342. _classCallCheck(this, FormulaBlot);
  9343. return _possibleConstructorReturn(this, (FormulaBlot.__proto__ || Object.getPrototypeOf(FormulaBlot)).apply(this, arguments));
  9344. }
  9345. _createClass(FormulaBlot, null, [{
  9346. key: 'create',
  9347. value: function create(value) {
  9348. var node = _get(FormulaBlot.__proto__ || Object.getPrototypeOf(FormulaBlot), 'create', this).call(this, value);
  9349. if (typeof value === 'string') {
  9350. window.katex.render(value, node, {
  9351. throwOnError: false,
  9352. errorColor: '#f00'
  9353. });
  9354. node.setAttribute('data-value', value);
  9355. }
  9356. return node;
  9357. }
  9358. }, {
  9359. key: 'value',
  9360. value: function value(domNode) {
  9361. return domNode.getAttribute('data-value');
  9362. }
  9363. }]);
  9364. return FormulaBlot;
  9365. }(_embed2.default);
  9366. FormulaBlot.blotName = 'formula';
  9367. FormulaBlot.className = 'ql-formula';
  9368. FormulaBlot.tagName = 'SPAN';
  9369. var Formula = function (_Module) {
  9370. _inherits(Formula, _Module);
  9371. _createClass(Formula, null, [{
  9372. key: 'register',
  9373. value: function register() {
  9374. _quill2.default.register(FormulaBlot, true);
  9375. }
  9376. }]);
  9377. function Formula() {
  9378. _classCallCheck(this, Formula);
  9379. var _this2 = _possibleConstructorReturn(this, (Formula.__proto__ || Object.getPrototypeOf(Formula)).call(this));
  9380. if (window.katex == null) {
  9381. throw new Error('Formula module requires KaTeX.');
  9382. }
  9383. return _this2;
  9384. }
  9385. return Formula;
  9386. }(_module2.default);
  9387. exports.FormulaBlot = FormulaBlot;
  9388. exports.default = Formula;
  9389. /***/ }),
  9390. /* 75 */
  9391. /***/ (function(module, exports, __webpack_require__) {
  9392. "use strict";
  9393. Object.defineProperty(exports, "__esModule", {
  9394. value: true
  9395. });
  9396. exports.default = exports.CodeToken = exports.CodeBlock = undefined;
  9397. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9398. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  9399. var _parchment = __webpack_require__(0);
  9400. var _parchment2 = _interopRequireDefault(_parchment);
  9401. var _quill = __webpack_require__(5);
  9402. var _quill2 = _interopRequireDefault(_quill);
  9403. var _module = __webpack_require__(9);
  9404. var _module2 = _interopRequireDefault(_module);
  9405. var _code = __webpack_require__(13);
  9406. var _code2 = _interopRequireDefault(_code);
  9407. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9408. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9409. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9410. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  9411. var SyntaxCodeBlock = function (_CodeBlock) {
  9412. _inherits(SyntaxCodeBlock, _CodeBlock);
  9413. function SyntaxCodeBlock() {
  9414. _classCallCheck(this, SyntaxCodeBlock);
  9415. return _possibleConstructorReturn(this, (SyntaxCodeBlock.__proto__ || Object.getPrototypeOf(SyntaxCodeBlock)).apply(this, arguments));
  9416. }
  9417. _createClass(SyntaxCodeBlock, [{
  9418. key: 'replaceWith',
  9419. value: function replaceWith(block) {
  9420. this.domNode.textContent = this.domNode.textContent;
  9421. this.attach();
  9422. _get(SyntaxCodeBlock.prototype.__proto__ || Object.getPrototypeOf(SyntaxCodeBlock.prototype), 'replaceWith', this).call(this, block);
  9423. }
  9424. }, {
  9425. key: 'highlight',
  9426. value: function highlight(_highlight) {
  9427. var text = this.domNode.textContent;
  9428. if (this.cachedText !== text) {
  9429. if (text.trim().length > 0 || this.cachedText == null) {
  9430. this.domNode.innerHTML = _highlight(text);
  9431. this.domNode.normalize();
  9432. this.attach();
  9433. }
  9434. this.cachedText = text;
  9435. }
  9436. }
  9437. }]);
  9438. return SyntaxCodeBlock;
  9439. }(_code2.default);
  9440. SyntaxCodeBlock.className = 'ql-syntax';
  9441. var CodeToken = new _parchment2.default.Attributor.Class('token', 'hljs', {
  9442. scope: _parchment2.default.Scope.INLINE
  9443. });
  9444. var Syntax = function (_Module) {
  9445. _inherits(Syntax, _Module);
  9446. _createClass(Syntax, null, [{
  9447. key: 'register',
  9448. value: function register() {
  9449. _quill2.default.register(CodeToken, true);
  9450. _quill2.default.register(SyntaxCodeBlock, true);
  9451. }
  9452. }]);
  9453. function Syntax(quill, options) {
  9454. _classCallCheck(this, Syntax);
  9455. var _this2 = _possibleConstructorReturn(this, (Syntax.__proto__ || Object.getPrototypeOf(Syntax)).call(this, quill, options));
  9456. if (typeof _this2.options.highlight !== 'function') {
  9457. throw new Error('Syntax module requires highlight.js. Please include the library on the page before Quill.');
  9458. }
  9459. var timer = null;
  9460. _this2.quill.on(_quill2.default.events.SCROLL_OPTIMIZE, function () {
  9461. clearTimeout(timer);
  9462. timer = setTimeout(function () {
  9463. _this2.highlight();
  9464. timer = null;
  9465. }, _this2.options.interval);
  9466. });
  9467. _this2.highlight();
  9468. return _this2;
  9469. }
  9470. _createClass(Syntax, [{
  9471. key: 'highlight',
  9472. value: function highlight() {
  9473. var _this3 = this;
  9474. if (this.quill.selection.composing) return;
  9475. this.quill.update(_quill2.default.sources.USER);
  9476. var range = this.quill.getSelection();
  9477. this.quill.scroll.descendants(SyntaxCodeBlock).forEach(function (code) {
  9478. code.highlight(_this3.options.highlight);
  9479. });
  9480. this.quill.update(_quill2.default.sources.SILENT);
  9481. if (range != null) {
  9482. this.quill.setSelection(range, _quill2.default.sources.SILENT);
  9483. }
  9484. }
  9485. }]);
  9486. return Syntax;
  9487. }(_module2.default);
  9488. Syntax.DEFAULTS = {
  9489. highlight: function () {
  9490. if (window.hljs == null) return null;
  9491. return function (text) {
  9492. var result = window.hljs.highlightAuto(text);
  9493. return result.value;
  9494. };
  9495. }(),
  9496. interval: 1000
  9497. };
  9498. exports.CodeBlock = SyntaxCodeBlock;
  9499. exports.CodeToken = CodeToken;
  9500. exports.default = Syntax;
  9501. /***/ }),
  9502. /* 76 */
  9503. /***/ (function(module, exports) {
  9504. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=3 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=3 x2=13 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=9 y1=4 y2=4></line> </svg>";
  9505. /***/ }),
  9506. /* 77 */
  9507. /***/ (function(module, exports) {
  9508. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=14 x2=4 y1=14 y2=14></line> <line class=ql-stroke x1=12 x2=6 y1=4 y2=4></line> </svg>";
  9509. /***/ }),
  9510. /* 78 */
  9511. /***/ (function(module, exports) {
  9512. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=15 x2=5 y1=14 y2=14></line> <line class=ql-stroke x1=15 x2=9 y1=4 y2=4></line> </svg>";
  9513. /***/ }),
  9514. /* 79 */
  9515. /***/ (function(module, exports) {
  9516. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=15 x2=3 y1=14 y2=14></line> <line class=ql-stroke x1=15 x2=3 y1=4 y2=4></line> </svg>";
  9517. /***/ }),
  9518. /* 80 */
  9519. /***/ (function(module, exports) {
  9520. module.exports = "<svg viewbox=\"0 0 18 18\"> <g class=\"ql-fill ql-color-label\"> <polygon points=\"6 6.868 6 6 5 6 5 7 5.942 7 6 6.868\"></polygon> <rect height=1 width=1 x=4 y=4></rect> <polygon points=\"6.817 5 6 5 6 6 6.38 6 6.817 5\"></polygon> <rect height=1 width=1 x=2 y=6></rect> <rect height=1 width=1 x=3 y=5></rect> <rect height=1 width=1 x=4 y=7></rect> <polygon points=\"4 11.439 4 11 3 11 3 12 3.755 12 4 11.439\"></polygon> <rect height=1 width=1 x=2 y=12></rect> <rect height=1 width=1 x=2 y=9></rect> <rect height=1 width=1 x=2 y=15></rect> <polygon points=\"4.63 10 4 10 4 11 4.192 11 4.63 10\"></polygon> <rect height=1 width=1 x=3 y=8></rect> <path d=M10.832,4.2L11,4.582V4H10.708A1.948,1.948,0,0,1,10.832,4.2Z></path> <path d=M7,4.582L7.168,4.2A1.929,1.929,0,0,1,7.292,4H7V4.582Z></path> <path d=M8,13H7.683l-0.351.8a1.933,1.933,0,0,1-.124.2H8V13Z></path> <rect height=1 width=1 x=12 y=2></rect> <rect height=1 width=1 x=11 y=3></rect> <path d=M9,3H8V3.282A1.985,1.985,0,0,1,9,3Z></path> <rect height=1 width=1 x=2 y=3></rect> <rect height=1 width=1 x=6 y=2></rect> <rect height=1 width=1 x=3 y=2></rect> <rect height=1 width=1 x=5 y=3></rect> <rect height=1 width=1 x=9 y=2></rect> <rect height=1 width=1 x=15 y=14></rect> <polygon points=\"13.447 10.174 13.469 10.225 13.472 10.232 13.808 11 14 11 14 10 13.37 10 13.447 10.174\"></polygon> <rect height=1 width=1 x=13 y=7></rect> <rect height=1 width=1 x=15 y=5></rect> <rect height=1 width=1 x=14 y=6></rect> <rect height=1 width=1 x=15 y=8></rect> <rect height=1 width=1 x=14 y=9></rect> <path d=M3.775,14H3v1H4V14.314A1.97,1.97,0,0,1,3.775,14Z></path> <rect height=1 width=1 x=14 y=3></rect> <polygon points=\"12 6.868 12 6 11.62 6 12 6.868\"></polygon> <rect height=1 width=1 x=15 y=2></rect> <rect height=1 width=1 x=12 y=5></rect> <rect height=1 width=1 x=13 y=4></rect> <polygon points=\"12.933 9 13 9 13 8 12.495 8 12.933 9\"></polygon> <rect height=1 width=1 x=9 y=14></rect> <rect height=1 width=1 x=8 y=15></rect> <path d=M6,14.926V15H7V14.316A1.993,1.993,0,0,1,6,14.926Z></path> <rect height=1 width=1 x=5 y=15></rect> <path d=M10.668,13.8L10.317,13H10v1h0.792A1.947,1.947,0,0,1,10.668,13.8Z></path> <rect height=1 width=1 x=11 y=15></rect> <path d=M14.332,12.2a1.99,1.99,0,0,1,.166.8H15V12H14.245Z></path> <rect height=1 width=1 x=14 y=15></rect> <rect height=1 width=1 x=15 y=11></rect> </g> <polyline class=ql-stroke points=\"5.5 13 9 5 12.5 13\"></polyline> <line class=ql-stroke x1=11.63 x2=6.38 y1=11 y2=11></line> </svg>";
  9521. /***/ }),
  9522. /* 81 */
  9523. /***/ (function(module, exports) {
  9524. module.exports = "<svg viewbox=\"0 0 18 18\"> <rect class=\"ql-fill ql-stroke\" height=3 width=3 x=4 y=5></rect> <rect class=\"ql-fill ql-stroke\" height=3 width=3 x=11 y=5></rect> <path class=\"ql-even ql-fill ql-stroke\" d=M7,8c0,4.031-3,5-3,5></path> <path class=\"ql-even ql-fill ql-stroke\" d=M14,8c0,4.031-3,5-3,5></path> </svg>";
  9525. /***/ }),
  9526. /* 82 */
  9527. /***/ (function(module, exports) {
  9528. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-stroke d=M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z></path> <path class=ql-stroke d=M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z></path> </svg>";
  9529. /***/ }),
  9530. /* 83 */
  9531. /***/ (function(module, exports) {
  9532. module.exports = "<svg class=\"\" viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=5 x2=13 y1=3 y2=3></line> <line class=ql-stroke x1=6 x2=9.35 y1=12 y2=3></line> <line class=ql-stroke x1=11 x2=15 y1=11 y2=15></line> <line class=ql-stroke x1=15 x2=11 y1=11 y2=15></line> <rect class=ql-fill height=1 rx=0.5 ry=0.5 width=7 x=2 y=14></rect> </svg>";
  9533. /***/ }),
  9534. /* 84 */
  9535. /***/ (function(module, exports) {
  9536. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=\"ql-color-label ql-stroke ql-transparent\" x1=3 x2=15 y1=15 y2=15></line> <polyline class=ql-stroke points=\"5.5 11 9 3 12.5 11\"></polyline> <line class=ql-stroke x1=11.63 x2=6.38 y1=9 y2=9></line> </svg>";
  9537. /***/ }),
  9538. /* 85 */
  9539. /***/ (function(module, exports) {
  9540. module.exports = "<svg viewbox=\"0 0 18 18\"> <polygon class=\"ql-stroke ql-fill\" points=\"3 11 5 9 3 7 3 11\"></polygon> <line class=\"ql-stroke ql-fill\" x1=15 x2=11 y1=4 y2=4></line> <path class=ql-fill d=M11,3a3,3,0,0,0,0,6h1V3H11Z></path> <rect class=ql-fill height=11 width=1 x=11 y=4></rect> <rect class=ql-fill height=11 width=1 x=13 y=4></rect> </svg>";
  9541. /***/ }),
  9542. /* 86 */
  9543. /***/ (function(module, exports) {
  9544. module.exports = "<svg viewbox=\"0 0 18 18\"> <polygon class=\"ql-stroke ql-fill\" points=\"15 12 13 10 15 8 15 12\"></polygon> <line class=\"ql-stroke ql-fill\" x1=9 x2=5 y1=4 y2=4></line> <path class=ql-fill d=M5,3A3,3,0,0,0,5,9H6V3H5Z></path> <rect class=ql-fill height=11 width=1 x=5 y=4></rect> <rect class=ql-fill height=11 width=1 x=7 y=4></rect> </svg>";
  9545. /***/ }),
  9546. /* 87 */
  9547. /***/ (function(module, exports) {
  9548. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M14,16H4a1,1,0,0,1,0-2H14A1,1,0,0,1,14,16Z /> <path class=ql-fill d=M14,4H4A1,1,0,0,1,4,2H14A1,1,0,0,1,14,4Z /> <rect class=ql-fill x=3 y=6 width=12 height=6 rx=1 ry=1 /> </svg>";
  9549. /***/ }),
  9550. /* 88 */
  9551. /***/ (function(module, exports) {
  9552. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M13,16H5a1,1,0,0,1,0-2h8A1,1,0,0,1,13,16Z /> <path class=ql-fill d=M13,4H5A1,1,0,0,1,5,2h8A1,1,0,0,1,13,4Z /> <rect class=ql-fill x=2 y=6 width=14 height=6 rx=1 ry=1 /> </svg>";
  9553. /***/ }),
  9554. /* 89 */
  9555. /***/ (function(module, exports) {
  9556. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M15,8H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,8Z /> <path class=ql-fill d=M15,12H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,12Z /> <path class=ql-fill d=M15,16H5a1,1,0,0,1,0-2H15A1,1,0,0,1,15,16Z /> <path class=ql-fill d=M15,4H5A1,1,0,0,1,5,2H15A1,1,0,0,1,15,4Z /> <rect class=ql-fill x=2 y=6 width=8 height=6 rx=1 ry=1 /> </svg>";
  9557. /***/ }),
  9558. /* 90 */
  9559. /***/ (function(module, exports) {
  9560. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M5,8H3A1,1,0,0,1,3,6H5A1,1,0,0,1,5,8Z /> <path class=ql-fill d=M5,12H3a1,1,0,0,1,0-2H5A1,1,0,0,1,5,12Z /> <path class=ql-fill d=M13,16H3a1,1,0,0,1,0-2H13A1,1,0,0,1,13,16Z /> <path class=ql-fill d=M13,4H3A1,1,0,0,1,3,2H13A1,1,0,0,1,13,4Z /> <rect class=ql-fill x=8 y=6 width=8 height=6 rx=1 ry=1 transform=\"translate(24 18) rotate(-180)\"/> </svg>";
  9561. /***/ }),
  9562. /* 91 */
  9563. /***/ (function(module, exports) {
  9564. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M11.759,2.482a2.561,2.561,0,0,0-3.53.607A7.656,7.656,0,0,0,6.8,6.2C6.109,9.188,5.275,14.677,4.15,14.927a1.545,1.545,0,0,0-1.3-.933A0.922,0.922,0,0,0,2,15.036S1.954,16,4.119,16s3.091-2.691,3.7-5.553c0.177-.826.36-1.726,0.554-2.6L8.775,6.2c0.381-1.421.807-2.521,1.306-2.676a1.014,1.014,0,0,0,1.02.56A0.966,0.966,0,0,0,11.759,2.482Z></path> <rect class=ql-fill height=1.6 rx=0.8 ry=0.8 width=5 x=5.15 y=6.2></rect> <path class=ql-fill d=M13.663,12.027a1.662,1.662,0,0,1,.266-0.276q0.193,0.069.456,0.138a2.1,2.1,0,0,0,.535.069,1.075,1.075,0,0,0,.767-0.3,1.044,1.044,0,0,0,.314-0.8,0.84,0.84,0,0,0-.238-0.619,0.8,0.8,0,0,0-.594-0.239,1.154,1.154,0,0,0-.781.3,4.607,4.607,0,0,0-.781,1q-0.091.15-.218,0.346l-0.246.38c-0.068-.288-0.137-0.582-0.212-0.885-0.459-1.847-2.494-.984-2.941-0.8-0.482.2-.353,0.647-0.094,0.529a0.869,0.869,0,0,1,1.281.585c0.217,0.751.377,1.436,0.527,2.038a5.688,5.688,0,0,1-.362.467,2.69,2.69,0,0,1-.264.271q-0.221-.08-0.471-0.147a2.029,2.029,0,0,0-.522-0.066,1.079,1.079,0,0,0-.768.3A1.058,1.058,0,0,0,9,15.131a0.82,0.82,0,0,0,.832.852,1.134,1.134,0,0,0,.787-0.3,5.11,5.11,0,0,0,.776-0.993q0.141-.219.215-0.34c0.046-.076.122-0.194,0.223-0.346a2.786,2.786,0,0,0,.918,1.726,2.582,2.582,0,0,0,2.376-.185c0.317-.181.212-0.565,0-0.494A0.807,0.807,0,0,1,14.176,15a5.159,5.159,0,0,1-.913-2.446l0,0Q13.487,12.24,13.663,12.027Z></path> </svg>";
  9565. /***/ }),
  9566. /* 92 */
  9567. /***/ (function(module, exports) {
  9568. module.exports = "<svg viewBox=\"0 0 18 18\"> <path class=ql-fill d=M10,4V14a1,1,0,0,1-2,0V10H3v4a1,1,0,0,1-2,0V4A1,1,0,0,1,3,4V8H8V4a1,1,0,0,1,2,0Zm6.06787,9.209H14.98975V7.59863a.54085.54085,0,0,0-.605-.60547h-.62744a1.01119,1.01119,0,0,0-.748.29688L11.645,8.56641a.5435.5435,0,0,0-.022.8584l.28613.30762a.53861.53861,0,0,0,.84717.0332l.09912-.08789a1.2137,1.2137,0,0,0,.2417-.35254h.02246s-.01123.30859-.01123.60547V13.209H12.041a.54085.54085,0,0,0-.605.60547v.43945a.54085.54085,0,0,0,.605.60547h4.02686a.54085.54085,0,0,0,.605-.60547v-.43945A.54085.54085,0,0,0,16.06787,13.209Z /> </svg>";
  9569. /***/ }),
  9570. /* 93 */
  9571. /***/ (function(module, exports) {
  9572. module.exports = "<svg viewBox=\"0 0 18 18\"> <path class=ql-fill d=M16.73975,13.81445v.43945a.54085.54085,0,0,1-.605.60547H11.855a.58392.58392,0,0,1-.64893-.60547V14.0127c0-2.90527,3.39941-3.42187,3.39941-4.55469a.77675.77675,0,0,0-.84717-.78125,1.17684,1.17684,0,0,0-.83594.38477c-.2749.26367-.561.374-.85791.13184l-.4292-.34082c-.30811-.24219-.38525-.51758-.1543-.81445a2.97155,2.97155,0,0,1,2.45361-1.17676,2.45393,2.45393,0,0,1,2.68408,2.40918c0,2.45312-3.1792,2.92676-3.27832,3.93848h2.79443A.54085.54085,0,0,1,16.73975,13.81445ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z /> </svg>";
  9573. /***/ }),
  9574. /* 94 */
  9575. /***/ (function(module, exports) {
  9576. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=7 x2=13 y1=4 y2=4></line> <line class=ql-stroke x1=5 x2=11 y1=14 y2=14></line> <line class=ql-stroke x1=8 x2=10 y1=14 y2=4></line> </svg>";
  9577. /***/ }),
  9578. /* 95 */
  9579. /***/ (function(module, exports) {
  9580. module.exports = "<svg viewbox=\"0 0 18 18\"> <rect class=ql-stroke height=10 width=12 x=3 y=4></rect> <circle class=ql-fill cx=6 cy=7 r=1></circle> <polyline class=\"ql-even ql-fill\" points=\"5 12 5 11 7 9 8 10 11 7 13 9 13 12 5 12\"></polyline> </svg>";
  9581. /***/ }),
  9582. /* 96 */
  9583. /***/ (function(module, exports) {
  9584. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=3 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=\"ql-fill ql-stroke\" points=\"3 7 3 11 5 9 3 7\"></polyline> </svg>";
  9585. /***/ }),
  9586. /* 97 */
  9587. /***/ (function(module, exports) {
  9588. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=3 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=ql-stroke points=\"5 7 5 11 3 9 5 7\"></polyline> </svg>";
  9589. /***/ }),
  9590. /* 98 */
  9591. /***/ (function(module, exports) {
  9592. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=7 x2=11 y1=7 y2=11></line> <path class=\"ql-even ql-stroke\" d=M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z></path> <path class=\"ql-even ql-stroke\" d=M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z></path> </svg>";
  9593. /***/ }),
  9594. /* 99 */
  9595. /***/ (function(module, exports) {
  9596. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=7 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=7 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=7 x2=15 y1=14 y2=14></line> <line class=\"ql-stroke ql-thin\" x1=2.5 x2=4.5 y1=5.5 y2=5.5></line> <path class=ql-fill d=M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z></path> <path class=\"ql-stroke ql-thin\" d=M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156></path> <path class=\"ql-stroke ql-thin\" d=M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109></path> </svg>";
  9597. /***/ }),
  9598. /* 100 */
  9599. /***/ (function(module, exports) {
  9600. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=6 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=6 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=6 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=3 y1=4 y2=4></line> <line class=ql-stroke x1=3 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=3 x2=3 y1=14 y2=14></line> </svg>";
  9601. /***/ }),
  9602. /* 101 */
  9603. /***/ (function(module, exports) {
  9604. module.exports = "<svg class=\"\" viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=9 x2=15 y1=4 y2=4></line> <polyline class=ql-stroke points=\"3 4 4 5 6 3\"></polyline> <line class=ql-stroke x1=9 x2=15 y1=14 y2=14></line> <polyline class=ql-stroke points=\"3 14 4 15 6 13\"></polyline> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=ql-stroke points=\"3 9 4 10 6 8\"></polyline> </svg>";
  9605. /***/ }),
  9606. /* 102 */
  9607. /***/ (function(module, exports) {
  9608. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M15.5,15H13.861a3.858,3.858,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.921,1.921,0,0,0,12.021,11.7a0.50013,0.50013,0,1,0,.957.291h0a0.914,0.914,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.076-1.16971,1.86982-1.93971,2.43082A1.45639,1.45639,0,0,0,12,15.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,15Z /> <path class=ql-fill d=M9.65,5.241a1,1,0,0,0-1.409.108L6,7.964,3.759,5.349A1,1,0,0,0,2.192,6.59178Q2.21541,6.6213,2.241,6.649L4.684,9.5,2.241,12.35A1,1,0,0,0,3.71,13.70722q0.02557-.02768.049-0.05722L6,11.036,8.241,13.65a1,1,0,1,0,1.567-1.24277Q9.78459,12.3777,9.759,12.35L7.316,9.5,9.759,6.651A1,1,0,0,0,9.65,5.241Z /> </svg>";
  9609. /***/ }),
  9610. /* 103 */
  9611. /***/ (function(module, exports) {
  9612. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M15.5,7H13.861a4.015,4.015,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.922,1.922,0,0,0,12.021,3.7a0.5,0.5,0,1,0,.957.291,0.917,0.917,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.077-1.164,1.925-1.934,2.486A1.423,1.423,0,0,0,12,7.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,7Z /> <path class=ql-fill d=M9.651,5.241a1,1,0,0,0-1.41.108L6,7.964,3.759,5.349a1,1,0,1,0-1.519,1.3L4.683,9.5,2.241,12.35a1,1,0,1,0,1.519,1.3L6,11.036,8.241,13.65a1,1,0,0,0,1.519-1.3L7.317,9.5,9.759,6.651A1,1,0,0,0,9.651,5.241Z /> </svg>";
  9613. /***/ }),
  9614. /* 104 */
  9615. /***/ (function(module, exports) {
  9616. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=\"ql-stroke ql-thin\" x1=15.5 x2=2.5 y1=8.5 y2=9.5></line> <path class=ql-fill d=M9.007,8C6.542,7.791,6,7.519,6,6.5,6,5.792,7.283,5,9,5c1.571,0,2.765.679,2.969,1.309a1,1,0,0,0,1.9-.617C13.356,4.106,11.354,3,9,3,6.2,3,4,4.538,4,6.5a3.2,3.2,0,0,0,.5,1.843Z></path> <path class=ql-fill d=M8.984,10C11.457,10.208,12,10.479,12,11.5c0,0.708-1.283,1.5-3,1.5-1.571,0-2.765-.679-2.969-1.309a1,1,0,1,0-1.9.617C4.644,13.894,6.646,15,9,15c2.8,0,5-1.538,5-3.5a3.2,3.2,0,0,0-.5-1.843Z></path> </svg>";
  9617. /***/ }),
  9618. /* 105 */
  9619. /***/ (function(module, exports) {
  9620. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-stroke d=M5,3V9a4.012,4.012,0,0,0,4,4H9a4.012,4.012,0,0,0,4-4V3></path> <rect class=ql-fill height=1 rx=0.5 ry=0.5 width=12 x=3 y=15></rect> </svg>";
  9621. /***/ }),
  9622. /* 106 */
  9623. /***/ (function(module, exports) {
  9624. module.exports = "<svg viewbox=\"0 0 18 18\"> <rect class=ql-stroke height=12 width=12 x=3 y=3></rect> <rect class=ql-fill height=12 width=1 x=5 y=3></rect> <rect class=ql-fill height=12 width=1 x=12 y=3></rect> <rect class=ql-fill height=2 width=8 x=5 y=8></rect> <rect class=ql-fill height=1 width=3 x=3 y=5></rect> <rect class=ql-fill height=1 width=3 x=3 y=7></rect> <rect class=ql-fill height=1 width=3 x=3 y=10></rect> <rect class=ql-fill height=1 width=3 x=3 y=12></rect> <rect class=ql-fill height=1 width=3 x=12 y=5></rect> <rect class=ql-fill height=1 width=3 x=12 y=7></rect> <rect class=ql-fill height=1 width=3 x=12 y=10></rect> <rect class=ql-fill height=1 width=3 x=12 y=12></rect> </svg>";
  9625. /***/ }),
  9626. /* 107 */
  9627. /***/ (function(module, exports) {
  9628. module.exports = "<svg viewbox=\"0 0 18 18\"> <polygon class=ql-stroke points=\"7 11 9 13 11 11 7 11\"></polygon> <polygon class=ql-stroke points=\"7 7 9 5 11 7 7 7\"></polygon> </svg>";
  9629. /***/ }),
  9630. /* 108 */
  9631. /***/ (function(module, exports, __webpack_require__) {
  9632. "use strict";
  9633. Object.defineProperty(exports, "__esModule", {
  9634. value: true
  9635. });
  9636. exports.default = exports.BubbleTooltip = undefined;
  9637. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  9638. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9639. var _extend = __webpack_require__(3);
  9640. var _extend2 = _interopRequireDefault(_extend);
  9641. var _emitter = __webpack_require__(8);
  9642. var _emitter2 = _interopRequireDefault(_emitter);
  9643. var _base = __webpack_require__(43);
  9644. var _base2 = _interopRequireDefault(_base);
  9645. var _selection = __webpack_require__(15);
  9646. var _icons = __webpack_require__(41);
  9647. var _icons2 = _interopRequireDefault(_icons);
  9648. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9649. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9650. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9651. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  9652. var TOOLBAR_CONFIG = [['bold', 'italic', 'link'], [{ header: 1 }, { header: 2 }, 'blockquote']];
  9653. var BubbleTheme = function (_BaseTheme) {
  9654. _inherits(BubbleTheme, _BaseTheme);
  9655. function BubbleTheme(quill, options) {
  9656. _classCallCheck(this, BubbleTheme);
  9657. if (options.modules.toolbar != null && options.modules.toolbar.container == null) {
  9658. options.modules.toolbar.container = TOOLBAR_CONFIG;
  9659. }
  9660. var _this = _possibleConstructorReturn(this, (BubbleTheme.__proto__ || Object.getPrototypeOf(BubbleTheme)).call(this, quill, options));
  9661. _this.quill.container.classList.add('ql-bubble');
  9662. return _this;
  9663. }
  9664. _createClass(BubbleTheme, [{
  9665. key: 'extendToolbar',
  9666. value: function extendToolbar(toolbar) {
  9667. this.tooltip = new BubbleTooltip(this.quill, this.options.bounds);
  9668. this.tooltip.root.appendChild(toolbar.container);
  9669. this.buildButtons([].slice.call(toolbar.container.querySelectorAll('button')), _icons2.default);
  9670. this.buildPickers([].slice.call(toolbar.container.querySelectorAll('select')), _icons2.default);
  9671. }
  9672. }]);
  9673. return BubbleTheme;
  9674. }(_base2.default);
  9675. BubbleTheme.DEFAULTS = (0, _extend2.default)(true, {}, _base2.default.DEFAULTS, {
  9676. modules: {
  9677. toolbar: {
  9678. handlers: {
  9679. link: function link(value) {
  9680. if (!value) {
  9681. this.quill.format('link', false);
  9682. } else {
  9683. this.quill.theme.tooltip.edit();
  9684. }
  9685. }
  9686. }
  9687. }
  9688. }
  9689. });
  9690. var BubbleTooltip = function (_BaseTooltip) {
  9691. _inherits(BubbleTooltip, _BaseTooltip);
  9692. function BubbleTooltip(quill, bounds) {
  9693. _classCallCheck(this, BubbleTooltip);
  9694. var _this2 = _possibleConstructorReturn(this, (BubbleTooltip.__proto__ || Object.getPrototypeOf(BubbleTooltip)).call(this, quill, bounds));
  9695. _this2.quill.on(_emitter2.default.events.EDITOR_CHANGE, function (type, range, oldRange, source) {
  9696. if (type !== _emitter2.default.events.SELECTION_CHANGE) return;
  9697. if (range != null && range.length > 0 && source === _emitter2.default.sources.USER) {
  9698. _this2.show();
  9699. // Lock our width so we will expand beyond our offsetParent boundaries
  9700. _this2.root.style.left = '0px';
  9701. _this2.root.style.width = '';
  9702. _this2.root.style.width = _this2.root.offsetWidth + 'px';
  9703. var lines = _this2.quill.getLines(range.index, range.length);
  9704. if (lines.length === 1) {
  9705. _this2.position(_this2.quill.getBounds(range));
  9706. } else {
  9707. var lastLine = lines[lines.length - 1];
  9708. var index = _this2.quill.getIndex(lastLine);
  9709. var length = Math.min(lastLine.length() - 1, range.index + range.length - index);
  9710. var _bounds = _this2.quill.getBounds(new _selection.Range(index, length));
  9711. _this2.position(_bounds);
  9712. }
  9713. } else if (document.activeElement !== _this2.textbox && _this2.quill.hasFocus()) {
  9714. _this2.hide();
  9715. }
  9716. });
  9717. return _this2;
  9718. }
  9719. _createClass(BubbleTooltip, [{
  9720. key: 'listen',
  9721. value: function listen() {
  9722. var _this3 = this;
  9723. _get(BubbleTooltip.prototype.__proto__ || Object.getPrototypeOf(BubbleTooltip.prototype), 'listen', this).call(this);
  9724. this.root.querySelector('.ql-close').addEventListener('click', function () {
  9725. _this3.root.classList.remove('ql-editing');
  9726. });
  9727. this.quill.on(_emitter2.default.events.SCROLL_OPTIMIZE, function () {
  9728. // Let selection be restored by toolbar handlers before repositioning
  9729. setTimeout(function () {
  9730. if (_this3.root.classList.contains('ql-hidden')) return;
  9731. var range = _this3.quill.getSelection();
  9732. if (range != null) {
  9733. _this3.position(_this3.quill.getBounds(range));
  9734. }
  9735. }, 1);
  9736. });
  9737. }
  9738. }, {
  9739. key: 'cancel',
  9740. value: function cancel() {
  9741. this.show();
  9742. }
  9743. }, {
  9744. key: 'position',
  9745. value: function position(reference) {
  9746. var shift = _get(BubbleTooltip.prototype.__proto__ || Object.getPrototypeOf(BubbleTooltip.prototype), 'position', this).call(this, reference);
  9747. var arrow = this.root.querySelector('.ql-tooltip-arrow');
  9748. arrow.style.marginLeft = '';
  9749. if (shift === 0) return shift;
  9750. arrow.style.marginLeft = -1 * shift - arrow.offsetWidth / 2 + 'px';
  9751. }
  9752. }]);
  9753. return BubbleTooltip;
  9754. }(_base.BaseTooltip);
  9755. BubbleTooltip.TEMPLATE = ['<span class="ql-tooltip-arrow"></span>', '<div class="ql-tooltip-editor">', '<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">', '<a class="ql-close"></a>', '</div>'].join('');
  9756. exports.BubbleTooltip = BubbleTooltip;
  9757. exports.default = BubbleTheme;
  9758. /***/ }),
  9759. /* 109 */
  9760. /***/ (function(module, exports, __webpack_require__) {
  9761. module.exports = __webpack_require__(63);
  9762. /***/ })
  9763. /******/ ])["default"];
  9764. });