quill.core.js 300 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594
  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 = 110);
  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. /* 28 */,
  4601. /* 29 */
  4602. /***/ (function(module, exports, __webpack_require__) {
  4603. "use strict";
  4604. Object.defineProperty(exports, "__esModule", {
  4605. value: true
  4606. });
  4607. var _parchment = __webpack_require__(0);
  4608. var _parchment2 = _interopRequireDefault(_parchment);
  4609. var _quill = __webpack_require__(5);
  4610. var _quill2 = _interopRequireDefault(_quill);
  4611. var _block = __webpack_require__(4);
  4612. var _block2 = _interopRequireDefault(_block);
  4613. var _break = __webpack_require__(16);
  4614. var _break2 = _interopRequireDefault(_break);
  4615. var _container = __webpack_require__(25);
  4616. var _container2 = _interopRequireDefault(_container);
  4617. var _cursor = __webpack_require__(24);
  4618. var _cursor2 = _interopRequireDefault(_cursor);
  4619. var _embed = __webpack_require__(35);
  4620. var _embed2 = _interopRequireDefault(_embed);
  4621. var _inline = __webpack_require__(6);
  4622. var _inline2 = _interopRequireDefault(_inline);
  4623. var _scroll = __webpack_require__(22);
  4624. var _scroll2 = _interopRequireDefault(_scroll);
  4625. var _text = __webpack_require__(7);
  4626. var _text2 = _interopRequireDefault(_text);
  4627. var _clipboard = __webpack_require__(55);
  4628. var _clipboard2 = _interopRequireDefault(_clipboard);
  4629. var _history = __webpack_require__(42);
  4630. var _history2 = _interopRequireDefault(_history);
  4631. var _keyboard = __webpack_require__(23);
  4632. var _keyboard2 = _interopRequireDefault(_keyboard);
  4633. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4634. _quill2.default.register({
  4635. 'blots/block': _block2.default,
  4636. 'blots/block/embed': _block.BlockEmbed,
  4637. 'blots/break': _break2.default,
  4638. 'blots/container': _container2.default,
  4639. 'blots/cursor': _cursor2.default,
  4640. 'blots/embed': _embed2.default,
  4641. 'blots/inline': _inline2.default,
  4642. 'blots/scroll': _scroll2.default,
  4643. 'blots/text': _text2.default,
  4644. 'modules/clipboard': _clipboard2.default,
  4645. 'modules/history': _history2.default,
  4646. 'modules/keyboard': _keyboard2.default
  4647. });
  4648. _parchment2.default.register(_block2.default, _break2.default, _cursor2.default, _inline2.default, _scroll2.default, _text2.default);
  4649. exports.default = _quill2.default;
  4650. /***/ }),
  4651. /* 30 */
  4652. /***/ (function(module, exports, __webpack_require__) {
  4653. "use strict";
  4654. Object.defineProperty(exports, "__esModule", { value: true });
  4655. var Registry = __webpack_require__(1);
  4656. var ShadowBlot = /** @class */ (function () {
  4657. function ShadowBlot(domNode) {
  4658. this.domNode = domNode;
  4659. // @ts-ignore
  4660. this.domNode[Registry.DATA_KEY] = { blot: this };
  4661. }
  4662. Object.defineProperty(ShadowBlot.prototype, "statics", {
  4663. // Hack for accessing inherited static methods
  4664. get: function () {
  4665. return this.constructor;
  4666. },
  4667. enumerable: true,
  4668. configurable: true
  4669. });
  4670. ShadowBlot.create = function (value) {
  4671. if (this.tagName == null) {
  4672. throw new Registry.ParchmentError('Blot definition missing tagName');
  4673. }
  4674. var node;
  4675. if (Array.isArray(this.tagName)) {
  4676. if (typeof value === 'string') {
  4677. value = value.toUpperCase();
  4678. if (parseInt(value).toString() === value) {
  4679. value = parseInt(value);
  4680. }
  4681. }
  4682. if (typeof value === 'number') {
  4683. node = document.createElement(this.tagName[value - 1]);
  4684. }
  4685. else if (this.tagName.indexOf(value) > -1) {
  4686. node = document.createElement(value);
  4687. }
  4688. else {
  4689. node = document.createElement(this.tagName[0]);
  4690. }
  4691. }
  4692. else {
  4693. node = document.createElement(this.tagName);
  4694. }
  4695. if (this.className) {
  4696. node.classList.add(this.className);
  4697. }
  4698. return node;
  4699. };
  4700. ShadowBlot.prototype.attach = function () {
  4701. if (this.parent != null) {
  4702. this.scroll = this.parent.scroll;
  4703. }
  4704. };
  4705. ShadowBlot.prototype.clone = function () {
  4706. var domNode = this.domNode.cloneNode(false);
  4707. return Registry.create(domNode);
  4708. };
  4709. ShadowBlot.prototype.detach = function () {
  4710. if (this.parent != null)
  4711. this.parent.removeChild(this);
  4712. // @ts-ignore
  4713. delete this.domNode[Registry.DATA_KEY];
  4714. };
  4715. ShadowBlot.prototype.deleteAt = function (index, length) {
  4716. var blot = this.isolate(index, length);
  4717. blot.remove();
  4718. };
  4719. ShadowBlot.prototype.formatAt = function (index, length, name, value) {
  4720. var blot = this.isolate(index, length);
  4721. if (Registry.query(name, Registry.Scope.BLOT) != null && value) {
  4722. blot.wrap(name, value);
  4723. }
  4724. else if (Registry.query(name, Registry.Scope.ATTRIBUTE) != null) {
  4725. var parent = Registry.create(this.statics.scope);
  4726. blot.wrap(parent);
  4727. parent.format(name, value);
  4728. }
  4729. };
  4730. ShadowBlot.prototype.insertAt = function (index, value, def) {
  4731. var blot = def == null ? Registry.create('text', value) : Registry.create(value, def);
  4732. var ref = this.split(index);
  4733. this.parent.insertBefore(blot, ref);
  4734. };
  4735. ShadowBlot.prototype.insertInto = function (parentBlot, refBlot) {
  4736. if (refBlot === void 0) { refBlot = null; }
  4737. if (this.parent != null) {
  4738. this.parent.children.remove(this);
  4739. }
  4740. var refDomNode = null;
  4741. parentBlot.children.insertBefore(this, refBlot);
  4742. if (refBlot != null) {
  4743. refDomNode = refBlot.domNode;
  4744. }
  4745. if (this.domNode.parentNode != parentBlot.domNode ||
  4746. this.domNode.nextSibling != refDomNode) {
  4747. parentBlot.domNode.insertBefore(this.domNode, refDomNode);
  4748. }
  4749. this.parent = parentBlot;
  4750. this.attach();
  4751. };
  4752. ShadowBlot.prototype.isolate = function (index, length) {
  4753. var target = this.split(index);
  4754. target.split(length);
  4755. return target;
  4756. };
  4757. ShadowBlot.prototype.length = function () {
  4758. return 1;
  4759. };
  4760. ShadowBlot.prototype.offset = function (root) {
  4761. if (root === void 0) { root = this.parent; }
  4762. if (this.parent == null || this == root)
  4763. return 0;
  4764. return this.parent.children.offset(this) + this.parent.offset(root);
  4765. };
  4766. ShadowBlot.prototype.optimize = function (context) {
  4767. // TODO clean up once we use WeakMap
  4768. // @ts-ignore
  4769. if (this.domNode[Registry.DATA_KEY] != null) {
  4770. // @ts-ignore
  4771. delete this.domNode[Registry.DATA_KEY].mutations;
  4772. }
  4773. };
  4774. ShadowBlot.prototype.remove = function () {
  4775. if (this.domNode.parentNode != null) {
  4776. this.domNode.parentNode.removeChild(this.domNode);
  4777. }
  4778. this.detach();
  4779. };
  4780. ShadowBlot.prototype.replace = function (target) {
  4781. if (target.parent == null)
  4782. return;
  4783. target.parent.insertBefore(this, target.next);
  4784. target.remove();
  4785. };
  4786. ShadowBlot.prototype.replaceWith = function (name, value) {
  4787. var replacement = typeof name === 'string' ? Registry.create(name, value) : name;
  4788. replacement.replace(this);
  4789. return replacement;
  4790. };
  4791. ShadowBlot.prototype.split = function (index, force) {
  4792. return index === 0 ? this : this.next;
  4793. };
  4794. ShadowBlot.prototype.update = function (mutations, context) {
  4795. // Nothing to do by default
  4796. };
  4797. ShadowBlot.prototype.wrap = function (name, value) {
  4798. var wrapper = typeof name === 'string' ? Registry.create(name, value) : name;
  4799. if (this.parent != null) {
  4800. this.parent.insertBefore(wrapper, this.next);
  4801. }
  4802. wrapper.appendChild(this);
  4803. return wrapper;
  4804. };
  4805. ShadowBlot.blotName = 'abstract';
  4806. return ShadowBlot;
  4807. }());
  4808. exports.default = ShadowBlot;
  4809. /***/ }),
  4810. /* 31 */
  4811. /***/ (function(module, exports, __webpack_require__) {
  4812. "use strict";
  4813. Object.defineProperty(exports, "__esModule", { value: true });
  4814. var attributor_1 = __webpack_require__(12);
  4815. var class_1 = __webpack_require__(32);
  4816. var style_1 = __webpack_require__(33);
  4817. var Registry = __webpack_require__(1);
  4818. var AttributorStore = /** @class */ (function () {
  4819. function AttributorStore(domNode) {
  4820. this.attributes = {};
  4821. this.domNode = domNode;
  4822. this.build();
  4823. }
  4824. AttributorStore.prototype.attribute = function (attribute, value) {
  4825. // verb
  4826. if (value) {
  4827. if (attribute.add(this.domNode, value)) {
  4828. if (attribute.value(this.domNode) != null) {
  4829. this.attributes[attribute.attrName] = attribute;
  4830. }
  4831. else {
  4832. delete this.attributes[attribute.attrName];
  4833. }
  4834. }
  4835. }
  4836. else {
  4837. attribute.remove(this.domNode);
  4838. delete this.attributes[attribute.attrName];
  4839. }
  4840. };
  4841. AttributorStore.prototype.build = function () {
  4842. var _this = this;
  4843. this.attributes = {};
  4844. var attributes = attributor_1.default.keys(this.domNode);
  4845. var classes = class_1.default.keys(this.domNode);
  4846. var styles = style_1.default.keys(this.domNode);
  4847. attributes
  4848. .concat(classes)
  4849. .concat(styles)
  4850. .forEach(function (name) {
  4851. var attr = Registry.query(name, Registry.Scope.ATTRIBUTE);
  4852. if (attr instanceof attributor_1.default) {
  4853. _this.attributes[attr.attrName] = attr;
  4854. }
  4855. });
  4856. };
  4857. AttributorStore.prototype.copy = function (target) {
  4858. var _this = this;
  4859. Object.keys(this.attributes).forEach(function (key) {
  4860. var value = _this.attributes[key].value(_this.domNode);
  4861. target.format(key, value);
  4862. });
  4863. };
  4864. AttributorStore.prototype.move = function (target) {
  4865. var _this = this;
  4866. this.copy(target);
  4867. Object.keys(this.attributes).forEach(function (key) {
  4868. _this.attributes[key].remove(_this.domNode);
  4869. });
  4870. this.attributes = {};
  4871. };
  4872. AttributorStore.prototype.values = function () {
  4873. var _this = this;
  4874. return Object.keys(this.attributes).reduce(function (attributes, name) {
  4875. attributes[name] = _this.attributes[name].value(_this.domNode);
  4876. return attributes;
  4877. }, {});
  4878. };
  4879. return AttributorStore;
  4880. }());
  4881. exports.default = AttributorStore;
  4882. /***/ }),
  4883. /* 32 */
  4884. /***/ (function(module, exports, __webpack_require__) {
  4885. "use strict";
  4886. var __extends = (this && this.__extends) || (function () {
  4887. var extendStatics = Object.setPrototypeOf ||
  4888. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4889. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4890. return function (d, b) {
  4891. extendStatics(d, b);
  4892. function __() { this.constructor = d; }
  4893. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4894. };
  4895. })();
  4896. Object.defineProperty(exports, "__esModule", { value: true });
  4897. var attributor_1 = __webpack_require__(12);
  4898. function match(node, prefix) {
  4899. var className = node.getAttribute('class') || '';
  4900. return className.split(/\s+/).filter(function (name) {
  4901. return name.indexOf(prefix + "-") === 0;
  4902. });
  4903. }
  4904. var ClassAttributor = /** @class */ (function (_super) {
  4905. __extends(ClassAttributor, _super);
  4906. function ClassAttributor() {
  4907. return _super !== null && _super.apply(this, arguments) || this;
  4908. }
  4909. ClassAttributor.keys = function (node) {
  4910. return (node.getAttribute('class') || '').split(/\s+/).map(function (name) {
  4911. return name
  4912. .split('-')
  4913. .slice(0, -1)
  4914. .join('-');
  4915. });
  4916. };
  4917. ClassAttributor.prototype.add = function (node, value) {
  4918. if (!this.canAdd(node, value))
  4919. return false;
  4920. this.remove(node);
  4921. node.classList.add(this.keyName + "-" + value);
  4922. return true;
  4923. };
  4924. ClassAttributor.prototype.remove = function (node) {
  4925. var matches = match(node, this.keyName);
  4926. matches.forEach(function (name) {
  4927. node.classList.remove(name);
  4928. });
  4929. if (node.classList.length === 0) {
  4930. node.removeAttribute('class');
  4931. }
  4932. };
  4933. ClassAttributor.prototype.value = function (node) {
  4934. var result = match(node, this.keyName)[0] || '';
  4935. var value = result.slice(this.keyName.length + 1); // +1 for hyphen
  4936. return this.canAdd(node, value) ? value : '';
  4937. };
  4938. return ClassAttributor;
  4939. }(attributor_1.default));
  4940. exports.default = ClassAttributor;
  4941. /***/ }),
  4942. /* 33 */
  4943. /***/ (function(module, exports, __webpack_require__) {
  4944. "use strict";
  4945. var __extends = (this && this.__extends) || (function () {
  4946. var extendStatics = Object.setPrototypeOf ||
  4947. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4948. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4949. return function (d, b) {
  4950. extendStatics(d, b);
  4951. function __() { this.constructor = d; }
  4952. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4953. };
  4954. })();
  4955. Object.defineProperty(exports, "__esModule", { value: true });
  4956. var attributor_1 = __webpack_require__(12);
  4957. function camelize(name) {
  4958. var parts = name.split('-');
  4959. var rest = parts
  4960. .slice(1)
  4961. .map(function (part) {
  4962. return part[0].toUpperCase() + part.slice(1);
  4963. })
  4964. .join('');
  4965. return parts[0] + rest;
  4966. }
  4967. var StyleAttributor = /** @class */ (function (_super) {
  4968. __extends(StyleAttributor, _super);
  4969. function StyleAttributor() {
  4970. return _super !== null && _super.apply(this, arguments) || this;
  4971. }
  4972. StyleAttributor.keys = function (node) {
  4973. return (node.getAttribute('style') || '').split(';').map(function (value) {
  4974. var arr = value.split(':');
  4975. return arr[0].trim();
  4976. });
  4977. };
  4978. StyleAttributor.prototype.add = function (node, value) {
  4979. if (!this.canAdd(node, value))
  4980. return false;
  4981. // @ts-ignore
  4982. node.style[camelize(this.keyName)] = value;
  4983. return true;
  4984. };
  4985. StyleAttributor.prototype.remove = function (node) {
  4986. // @ts-ignore
  4987. node.style[camelize(this.keyName)] = '';
  4988. if (!node.getAttribute('style')) {
  4989. node.removeAttribute('style');
  4990. }
  4991. };
  4992. StyleAttributor.prototype.value = function (node) {
  4993. // @ts-ignore
  4994. var value = node.style[camelize(this.keyName)];
  4995. return this.canAdd(node, value) ? value : '';
  4996. };
  4997. return StyleAttributor;
  4998. }(attributor_1.default));
  4999. exports.default = StyleAttributor;
  5000. /***/ }),
  5001. /* 34 */
  5002. /***/ (function(module, exports, __webpack_require__) {
  5003. "use strict";
  5004. Object.defineProperty(exports, "__esModule", {
  5005. value: true
  5006. });
  5007. 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; }; }();
  5008. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5009. var Theme = function () {
  5010. function Theme(quill, options) {
  5011. _classCallCheck(this, Theme);
  5012. this.quill = quill;
  5013. this.options = options;
  5014. this.modules = {};
  5015. }
  5016. _createClass(Theme, [{
  5017. key: 'init',
  5018. value: function init() {
  5019. var _this = this;
  5020. Object.keys(this.options.modules).forEach(function (name) {
  5021. if (_this.modules[name] == null) {
  5022. _this.addModule(name);
  5023. }
  5024. });
  5025. }
  5026. }, {
  5027. key: 'addModule',
  5028. value: function addModule(name) {
  5029. var moduleClass = this.quill.constructor.import('modules/' + name);
  5030. this.modules[name] = new moduleClass(this.quill, this.options.modules[name] || {});
  5031. return this.modules[name];
  5032. }
  5033. }]);
  5034. return Theme;
  5035. }();
  5036. Theme.DEFAULTS = {
  5037. modules: {}
  5038. };
  5039. Theme.themes = {
  5040. 'default': Theme
  5041. };
  5042. exports.default = Theme;
  5043. /***/ }),
  5044. /* 35 */
  5045. /***/ (function(module, exports, __webpack_require__) {
  5046. "use strict";
  5047. Object.defineProperty(exports, "__esModule", {
  5048. value: true
  5049. });
  5050. 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; }; }();
  5051. 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); } };
  5052. var _parchment = __webpack_require__(0);
  5053. var _parchment2 = _interopRequireDefault(_parchment);
  5054. var _text = __webpack_require__(7);
  5055. var _text2 = _interopRequireDefault(_text);
  5056. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5057. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5058. 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; }
  5059. 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; }
  5060. var GUARD_TEXT = '\uFEFF';
  5061. var Embed = function (_Parchment$Embed) {
  5062. _inherits(Embed, _Parchment$Embed);
  5063. function Embed(node) {
  5064. _classCallCheck(this, Embed);
  5065. var _this = _possibleConstructorReturn(this, (Embed.__proto__ || Object.getPrototypeOf(Embed)).call(this, node));
  5066. _this.contentNode = document.createElement('span');
  5067. _this.contentNode.setAttribute('contenteditable', false);
  5068. [].slice.call(_this.domNode.childNodes).forEach(function (childNode) {
  5069. _this.contentNode.appendChild(childNode);
  5070. });
  5071. _this.leftGuard = document.createTextNode(GUARD_TEXT);
  5072. _this.rightGuard = document.createTextNode(GUARD_TEXT);
  5073. _this.domNode.appendChild(_this.leftGuard);
  5074. _this.domNode.appendChild(_this.contentNode);
  5075. _this.domNode.appendChild(_this.rightGuard);
  5076. return _this;
  5077. }
  5078. _createClass(Embed, [{
  5079. key: 'index',
  5080. value: function index(node, offset) {
  5081. if (node === this.leftGuard) return 0;
  5082. if (node === this.rightGuard) return 1;
  5083. return _get(Embed.prototype.__proto__ || Object.getPrototypeOf(Embed.prototype), 'index', this).call(this, node, offset);
  5084. }
  5085. }, {
  5086. key: 'restore',
  5087. value: function restore(node) {
  5088. var range = void 0,
  5089. textNode = void 0;
  5090. var text = node.data.split(GUARD_TEXT).join('');
  5091. if (node === this.leftGuard) {
  5092. if (this.prev instanceof _text2.default) {
  5093. var prevLength = this.prev.length();
  5094. this.prev.insertAt(prevLength, text);
  5095. range = {
  5096. startNode: this.prev.domNode,
  5097. startOffset: prevLength + text.length
  5098. };
  5099. } else {
  5100. textNode = document.createTextNode(text);
  5101. this.parent.insertBefore(_parchment2.default.create(textNode), this);
  5102. range = {
  5103. startNode: textNode,
  5104. startOffset: text.length
  5105. };
  5106. }
  5107. } else if (node === this.rightGuard) {
  5108. if (this.next instanceof _text2.default) {
  5109. this.next.insertAt(0, text);
  5110. range = {
  5111. startNode: this.next.domNode,
  5112. startOffset: text.length
  5113. };
  5114. } else {
  5115. textNode = document.createTextNode(text);
  5116. this.parent.insertBefore(_parchment2.default.create(textNode), this.next);
  5117. range = {
  5118. startNode: textNode,
  5119. startOffset: text.length
  5120. };
  5121. }
  5122. }
  5123. node.data = GUARD_TEXT;
  5124. return range;
  5125. }
  5126. }, {
  5127. key: 'update',
  5128. value: function update(mutations, context) {
  5129. var _this2 = this;
  5130. mutations.forEach(function (mutation) {
  5131. if (mutation.type === 'characterData' && (mutation.target === _this2.leftGuard || mutation.target === _this2.rightGuard)) {
  5132. var range = _this2.restore(mutation.target);
  5133. if (range) context.range = range;
  5134. }
  5135. });
  5136. }
  5137. }]);
  5138. return Embed;
  5139. }(_parchment2.default.Embed);
  5140. exports.default = Embed;
  5141. /***/ }),
  5142. /* 36 */
  5143. /***/ (function(module, exports, __webpack_require__) {
  5144. "use strict";
  5145. Object.defineProperty(exports, "__esModule", {
  5146. value: true
  5147. });
  5148. exports.AlignStyle = exports.AlignClass = exports.AlignAttribute = undefined;
  5149. var _parchment = __webpack_require__(0);
  5150. var _parchment2 = _interopRequireDefault(_parchment);
  5151. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5152. var config = {
  5153. scope: _parchment2.default.Scope.BLOCK,
  5154. whitelist: ['right', 'center', 'justify']
  5155. };
  5156. var AlignAttribute = new _parchment2.default.Attributor.Attribute('align', 'align', config);
  5157. var AlignClass = new _parchment2.default.Attributor.Class('align', 'ql-align', config);
  5158. var AlignStyle = new _parchment2.default.Attributor.Style('align', 'text-align', config);
  5159. exports.AlignAttribute = AlignAttribute;
  5160. exports.AlignClass = AlignClass;
  5161. exports.AlignStyle = AlignStyle;
  5162. /***/ }),
  5163. /* 37 */
  5164. /***/ (function(module, exports, __webpack_require__) {
  5165. "use strict";
  5166. Object.defineProperty(exports, "__esModule", {
  5167. value: true
  5168. });
  5169. exports.BackgroundStyle = exports.BackgroundClass = undefined;
  5170. var _parchment = __webpack_require__(0);
  5171. var _parchment2 = _interopRequireDefault(_parchment);
  5172. var _color = __webpack_require__(26);
  5173. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5174. var BackgroundClass = new _parchment2.default.Attributor.Class('background', 'ql-bg', {
  5175. scope: _parchment2.default.Scope.INLINE
  5176. });
  5177. var BackgroundStyle = new _color.ColorAttributor('background', 'background-color', {
  5178. scope: _parchment2.default.Scope.INLINE
  5179. });
  5180. exports.BackgroundClass = BackgroundClass;
  5181. exports.BackgroundStyle = BackgroundStyle;
  5182. /***/ }),
  5183. /* 38 */
  5184. /***/ (function(module, exports, __webpack_require__) {
  5185. "use strict";
  5186. Object.defineProperty(exports, "__esModule", {
  5187. value: true
  5188. });
  5189. exports.DirectionStyle = exports.DirectionClass = exports.DirectionAttribute = undefined;
  5190. var _parchment = __webpack_require__(0);
  5191. var _parchment2 = _interopRequireDefault(_parchment);
  5192. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5193. var config = {
  5194. scope: _parchment2.default.Scope.BLOCK,
  5195. whitelist: ['rtl']
  5196. };
  5197. var DirectionAttribute = new _parchment2.default.Attributor.Attribute('direction', 'dir', config);
  5198. var DirectionClass = new _parchment2.default.Attributor.Class('direction', 'ql-direction', config);
  5199. var DirectionStyle = new _parchment2.default.Attributor.Style('direction', 'direction', config);
  5200. exports.DirectionAttribute = DirectionAttribute;
  5201. exports.DirectionClass = DirectionClass;
  5202. exports.DirectionStyle = DirectionStyle;
  5203. /***/ }),
  5204. /* 39 */
  5205. /***/ (function(module, exports, __webpack_require__) {
  5206. "use strict";
  5207. Object.defineProperty(exports, "__esModule", {
  5208. value: true
  5209. });
  5210. exports.FontClass = exports.FontStyle = undefined;
  5211. 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; }; }();
  5212. 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); } };
  5213. var _parchment = __webpack_require__(0);
  5214. var _parchment2 = _interopRequireDefault(_parchment);
  5215. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5216. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5217. 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; }
  5218. 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; }
  5219. var config = {
  5220. scope: _parchment2.default.Scope.INLINE,
  5221. whitelist: ['serif', 'monospace']
  5222. };
  5223. var FontClass = new _parchment2.default.Attributor.Class('font', 'ql-font', config);
  5224. var FontStyleAttributor = function (_Parchment$Attributor) {
  5225. _inherits(FontStyleAttributor, _Parchment$Attributor);
  5226. function FontStyleAttributor() {
  5227. _classCallCheck(this, FontStyleAttributor);
  5228. return _possibleConstructorReturn(this, (FontStyleAttributor.__proto__ || Object.getPrototypeOf(FontStyleAttributor)).apply(this, arguments));
  5229. }
  5230. _createClass(FontStyleAttributor, [{
  5231. key: 'value',
  5232. value: function value(node) {
  5233. return _get(FontStyleAttributor.prototype.__proto__ || Object.getPrototypeOf(FontStyleAttributor.prototype), 'value', this).call(this, node).replace(/["']/g, '');
  5234. }
  5235. }]);
  5236. return FontStyleAttributor;
  5237. }(_parchment2.default.Attributor.Style);
  5238. var FontStyle = new FontStyleAttributor('font', 'font-family', config);
  5239. exports.FontStyle = FontStyle;
  5240. exports.FontClass = FontClass;
  5241. /***/ }),
  5242. /* 40 */
  5243. /***/ (function(module, exports, __webpack_require__) {
  5244. "use strict";
  5245. Object.defineProperty(exports, "__esModule", {
  5246. value: true
  5247. });
  5248. exports.SizeStyle = exports.SizeClass = undefined;
  5249. var _parchment = __webpack_require__(0);
  5250. var _parchment2 = _interopRequireDefault(_parchment);
  5251. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5252. var SizeClass = new _parchment2.default.Attributor.Class('size', 'ql-size', {
  5253. scope: _parchment2.default.Scope.INLINE,
  5254. whitelist: ['small', 'large', 'huge']
  5255. });
  5256. var SizeStyle = new _parchment2.default.Attributor.Style('size', 'font-size', {
  5257. scope: _parchment2.default.Scope.INLINE,
  5258. whitelist: ['10px', '18px', '32px']
  5259. });
  5260. exports.SizeClass = SizeClass;
  5261. exports.SizeStyle = SizeStyle;
  5262. /***/ }),
  5263. /* 41 */,
  5264. /* 42 */
  5265. /***/ (function(module, exports, __webpack_require__) {
  5266. "use strict";
  5267. Object.defineProperty(exports, "__esModule", {
  5268. value: true
  5269. });
  5270. exports.getLastChangeIndex = exports.default = undefined;
  5271. 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; }; }();
  5272. var _parchment = __webpack_require__(0);
  5273. var _parchment2 = _interopRequireDefault(_parchment);
  5274. var _quill = __webpack_require__(5);
  5275. var _quill2 = _interopRequireDefault(_quill);
  5276. var _module = __webpack_require__(9);
  5277. var _module2 = _interopRequireDefault(_module);
  5278. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5279. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5280. 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; }
  5281. 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; }
  5282. var History = function (_Module) {
  5283. _inherits(History, _Module);
  5284. function History(quill, options) {
  5285. _classCallCheck(this, History);
  5286. var _this = _possibleConstructorReturn(this, (History.__proto__ || Object.getPrototypeOf(History)).call(this, quill, options));
  5287. _this.lastRecorded = 0;
  5288. _this.ignoreChange = false;
  5289. _this.clear();
  5290. _this.quill.on(_quill2.default.events.EDITOR_CHANGE, function (eventName, delta, oldDelta, source) {
  5291. if (eventName !== _quill2.default.events.TEXT_CHANGE || _this.ignoreChange) return;
  5292. if (!_this.options.userOnly || source === _quill2.default.sources.USER) {
  5293. _this.record(delta, oldDelta);
  5294. } else {
  5295. _this.transform(delta);
  5296. }
  5297. });
  5298. _this.quill.keyboard.addBinding({ key: 'Z', shortKey: true }, _this.undo.bind(_this));
  5299. _this.quill.keyboard.addBinding({ key: 'Z', shortKey: true, shiftKey: true }, _this.redo.bind(_this));
  5300. if (/Win/i.test(navigator.platform)) {
  5301. _this.quill.keyboard.addBinding({ key: 'Y', shortKey: true }, _this.redo.bind(_this));
  5302. }
  5303. return _this;
  5304. }
  5305. _createClass(History, [{
  5306. key: 'change',
  5307. value: function change(source, dest) {
  5308. if (this.stack[source].length === 0) return;
  5309. var delta = this.stack[source].pop();
  5310. this.stack[dest].push(delta);
  5311. this.lastRecorded = 0;
  5312. this.ignoreChange = true;
  5313. this.quill.updateContents(delta[source], _quill2.default.sources.USER);
  5314. this.ignoreChange = false;
  5315. var index = getLastChangeIndex(delta[source]);
  5316. this.quill.setSelection(index);
  5317. }
  5318. }, {
  5319. key: 'clear',
  5320. value: function clear() {
  5321. this.stack = { undo: [], redo: [] };
  5322. }
  5323. }, {
  5324. key: 'cutoff',
  5325. value: function cutoff() {
  5326. this.lastRecorded = 0;
  5327. }
  5328. }, {
  5329. key: 'record',
  5330. value: function record(changeDelta, oldDelta) {
  5331. if (changeDelta.ops.length === 0) return;
  5332. this.stack.redo = [];
  5333. var undoDelta = this.quill.getContents().diff(oldDelta);
  5334. var timestamp = Date.now();
  5335. if (this.lastRecorded + this.options.delay > timestamp && this.stack.undo.length > 0) {
  5336. var delta = this.stack.undo.pop();
  5337. undoDelta = undoDelta.compose(delta.undo);
  5338. changeDelta = delta.redo.compose(changeDelta);
  5339. } else {
  5340. this.lastRecorded = timestamp;
  5341. }
  5342. this.stack.undo.push({
  5343. redo: changeDelta,
  5344. undo: undoDelta
  5345. });
  5346. if (this.stack.undo.length > this.options.maxStack) {
  5347. this.stack.undo.shift();
  5348. }
  5349. }
  5350. }, {
  5351. key: 'redo',
  5352. value: function redo() {
  5353. this.change('redo', 'undo');
  5354. }
  5355. }, {
  5356. key: 'transform',
  5357. value: function transform(delta) {
  5358. this.stack.undo.forEach(function (change) {
  5359. change.undo = delta.transform(change.undo, true);
  5360. change.redo = delta.transform(change.redo, true);
  5361. });
  5362. this.stack.redo.forEach(function (change) {
  5363. change.undo = delta.transform(change.undo, true);
  5364. change.redo = delta.transform(change.redo, true);
  5365. });
  5366. }
  5367. }, {
  5368. key: 'undo',
  5369. value: function undo() {
  5370. this.change('undo', 'redo');
  5371. }
  5372. }]);
  5373. return History;
  5374. }(_module2.default);
  5375. History.DEFAULTS = {
  5376. delay: 1000,
  5377. maxStack: 100,
  5378. userOnly: false
  5379. };
  5380. function endsWithNewlineChange(delta) {
  5381. var lastOp = delta.ops[delta.ops.length - 1];
  5382. if (lastOp == null) return false;
  5383. if (lastOp.insert != null) {
  5384. return typeof lastOp.insert === 'string' && lastOp.insert.endsWith('\n');
  5385. }
  5386. if (lastOp.attributes != null) {
  5387. return Object.keys(lastOp.attributes).some(function (attr) {
  5388. return _parchment2.default.query(attr, _parchment2.default.Scope.BLOCK) != null;
  5389. });
  5390. }
  5391. return false;
  5392. }
  5393. function getLastChangeIndex(delta) {
  5394. var deleteLength = delta.reduce(function (length, op) {
  5395. length += op.delete || 0;
  5396. return length;
  5397. }, 0);
  5398. var changeIndex = delta.length() - deleteLength;
  5399. if (endsWithNewlineChange(delta)) {
  5400. changeIndex -= 1;
  5401. }
  5402. return changeIndex;
  5403. }
  5404. exports.default = History;
  5405. exports.getLastChangeIndex = getLastChangeIndex;
  5406. /***/ }),
  5407. /* 43 */,
  5408. /* 44 */
  5409. /***/ (function(module, exports, __webpack_require__) {
  5410. "use strict";
  5411. Object.defineProperty(exports, "__esModule", { value: true });
  5412. var LinkedList = /** @class */ (function () {
  5413. function LinkedList() {
  5414. this.head = this.tail = null;
  5415. this.length = 0;
  5416. }
  5417. LinkedList.prototype.append = function () {
  5418. var nodes = [];
  5419. for (var _i = 0; _i < arguments.length; _i++) {
  5420. nodes[_i] = arguments[_i];
  5421. }
  5422. this.insertBefore(nodes[0], null);
  5423. if (nodes.length > 1) {
  5424. this.append.apply(this, nodes.slice(1));
  5425. }
  5426. };
  5427. LinkedList.prototype.contains = function (node) {
  5428. var cur, next = this.iterator();
  5429. while ((cur = next())) {
  5430. if (cur === node)
  5431. return true;
  5432. }
  5433. return false;
  5434. };
  5435. LinkedList.prototype.insertBefore = function (node, refNode) {
  5436. if (!node)
  5437. return;
  5438. node.next = refNode;
  5439. if (refNode != null) {
  5440. node.prev = refNode.prev;
  5441. if (refNode.prev != null) {
  5442. refNode.prev.next = node;
  5443. }
  5444. refNode.prev = node;
  5445. if (refNode === this.head) {
  5446. this.head = node;
  5447. }
  5448. }
  5449. else if (this.tail != null) {
  5450. this.tail.next = node;
  5451. node.prev = this.tail;
  5452. this.tail = node;
  5453. }
  5454. else {
  5455. node.prev = null;
  5456. this.head = this.tail = node;
  5457. }
  5458. this.length += 1;
  5459. };
  5460. LinkedList.prototype.offset = function (target) {
  5461. var index = 0, cur = this.head;
  5462. while (cur != null) {
  5463. if (cur === target)
  5464. return index;
  5465. index += cur.length();
  5466. cur = cur.next;
  5467. }
  5468. return -1;
  5469. };
  5470. LinkedList.prototype.remove = function (node) {
  5471. if (!this.contains(node))
  5472. return;
  5473. if (node.prev != null)
  5474. node.prev.next = node.next;
  5475. if (node.next != null)
  5476. node.next.prev = node.prev;
  5477. if (node === this.head)
  5478. this.head = node.next;
  5479. if (node === this.tail)
  5480. this.tail = node.prev;
  5481. this.length -= 1;
  5482. };
  5483. LinkedList.prototype.iterator = function (curNode) {
  5484. if (curNode === void 0) { curNode = this.head; }
  5485. // TODO use yield when we can
  5486. return function () {
  5487. var ret = curNode;
  5488. if (curNode != null)
  5489. curNode = curNode.next;
  5490. return ret;
  5491. };
  5492. };
  5493. LinkedList.prototype.find = function (index, inclusive) {
  5494. if (inclusive === void 0) { inclusive = false; }
  5495. var cur, next = this.iterator();
  5496. while ((cur = next())) {
  5497. var length = cur.length();
  5498. if (index < length ||
  5499. (inclusive && index === length && (cur.next == null || cur.next.length() !== 0))) {
  5500. return [cur, index];
  5501. }
  5502. index -= length;
  5503. }
  5504. return [null, 0];
  5505. };
  5506. LinkedList.prototype.forEach = function (callback) {
  5507. var cur, next = this.iterator();
  5508. while ((cur = next())) {
  5509. callback(cur);
  5510. }
  5511. };
  5512. LinkedList.prototype.forEachAt = function (index, length, callback) {
  5513. if (length <= 0)
  5514. return;
  5515. var _a = this.find(index), startNode = _a[0], offset = _a[1];
  5516. var cur, curIndex = index - offset, next = this.iterator(startNode);
  5517. while ((cur = next()) && curIndex < index + length) {
  5518. var curLength = cur.length();
  5519. if (index > curIndex) {
  5520. callback(cur, index - curIndex, Math.min(length, curIndex + curLength - index));
  5521. }
  5522. else {
  5523. callback(cur, 0, Math.min(curLength, index + length - curIndex));
  5524. }
  5525. curIndex += curLength;
  5526. }
  5527. };
  5528. LinkedList.prototype.map = function (callback) {
  5529. return this.reduce(function (memo, cur) {
  5530. memo.push(callback(cur));
  5531. return memo;
  5532. }, []);
  5533. };
  5534. LinkedList.prototype.reduce = function (callback, memo) {
  5535. var cur, next = this.iterator();
  5536. while ((cur = next())) {
  5537. memo = callback(memo, cur);
  5538. }
  5539. return memo;
  5540. };
  5541. return LinkedList;
  5542. }());
  5543. exports.default = LinkedList;
  5544. /***/ }),
  5545. /* 45 */
  5546. /***/ (function(module, exports, __webpack_require__) {
  5547. "use strict";
  5548. var __extends = (this && this.__extends) || (function () {
  5549. var extendStatics = Object.setPrototypeOf ||
  5550. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5551. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5552. return function (d, b) {
  5553. extendStatics(d, b);
  5554. function __() { this.constructor = d; }
  5555. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5556. };
  5557. })();
  5558. Object.defineProperty(exports, "__esModule", { value: true });
  5559. var container_1 = __webpack_require__(17);
  5560. var Registry = __webpack_require__(1);
  5561. var OBSERVER_CONFIG = {
  5562. attributes: true,
  5563. characterData: true,
  5564. characterDataOldValue: true,
  5565. childList: true,
  5566. subtree: true,
  5567. };
  5568. var MAX_OPTIMIZE_ITERATIONS = 100;
  5569. var ScrollBlot = /** @class */ (function (_super) {
  5570. __extends(ScrollBlot, _super);
  5571. function ScrollBlot(node) {
  5572. var _this = _super.call(this, node) || this;
  5573. _this.scroll = _this;
  5574. _this.observer = new MutationObserver(function (mutations) {
  5575. _this.update(mutations);
  5576. });
  5577. _this.observer.observe(_this.domNode, OBSERVER_CONFIG);
  5578. _this.attach();
  5579. return _this;
  5580. }
  5581. ScrollBlot.prototype.detach = function () {
  5582. _super.prototype.detach.call(this);
  5583. this.observer.disconnect();
  5584. };
  5585. ScrollBlot.prototype.deleteAt = function (index, length) {
  5586. this.update();
  5587. if (index === 0 && length === this.length()) {
  5588. this.children.forEach(function (child) {
  5589. child.remove();
  5590. });
  5591. }
  5592. else {
  5593. _super.prototype.deleteAt.call(this, index, length);
  5594. }
  5595. };
  5596. ScrollBlot.prototype.formatAt = function (index, length, name, value) {
  5597. this.update();
  5598. _super.prototype.formatAt.call(this, index, length, name, value);
  5599. };
  5600. ScrollBlot.prototype.insertAt = function (index, value, def) {
  5601. this.update();
  5602. _super.prototype.insertAt.call(this, index, value, def);
  5603. };
  5604. ScrollBlot.prototype.optimize = function (mutations, context) {
  5605. var _this = this;
  5606. if (mutations === void 0) { mutations = []; }
  5607. if (context === void 0) { context = {}; }
  5608. _super.prototype.optimize.call(this, context);
  5609. // We must modify mutations directly, cannot make copy and then modify
  5610. var records = [].slice.call(this.observer.takeRecords());
  5611. // Array.push currently seems to be implemented by a non-tail recursive function
  5612. // so we cannot just mutations.push.apply(mutations, this.observer.takeRecords());
  5613. while (records.length > 0)
  5614. mutations.push(records.pop());
  5615. // TODO use WeakMap
  5616. var mark = function (blot, markParent) {
  5617. if (markParent === void 0) { markParent = true; }
  5618. if (blot == null || blot === _this)
  5619. return;
  5620. if (blot.domNode.parentNode == null)
  5621. return;
  5622. // @ts-ignore
  5623. if (blot.domNode[Registry.DATA_KEY].mutations == null) {
  5624. // @ts-ignore
  5625. blot.domNode[Registry.DATA_KEY].mutations = [];
  5626. }
  5627. if (markParent)
  5628. mark(blot.parent);
  5629. };
  5630. var optimize = function (blot) {
  5631. // Post-order traversal
  5632. if (
  5633. // @ts-ignore
  5634. blot.domNode[Registry.DATA_KEY] == null ||
  5635. // @ts-ignore
  5636. blot.domNode[Registry.DATA_KEY].mutations == null) {
  5637. return;
  5638. }
  5639. if (blot instanceof container_1.default) {
  5640. blot.children.forEach(optimize);
  5641. }
  5642. blot.optimize(context);
  5643. };
  5644. var remaining = mutations;
  5645. for (var i = 0; remaining.length > 0; i += 1) {
  5646. if (i >= MAX_OPTIMIZE_ITERATIONS) {
  5647. throw new Error('[Parchment] Maximum optimize iterations reached');
  5648. }
  5649. remaining.forEach(function (mutation) {
  5650. var blot = Registry.find(mutation.target, true);
  5651. if (blot == null)
  5652. return;
  5653. if (blot.domNode === mutation.target) {
  5654. if (mutation.type === 'childList') {
  5655. mark(Registry.find(mutation.previousSibling, false));
  5656. [].forEach.call(mutation.addedNodes, function (node) {
  5657. var child = Registry.find(node, false);
  5658. mark(child, false);
  5659. if (child instanceof container_1.default) {
  5660. child.children.forEach(function (grandChild) {
  5661. mark(grandChild, false);
  5662. });
  5663. }
  5664. });
  5665. }
  5666. else if (mutation.type === 'attributes') {
  5667. mark(blot.prev);
  5668. }
  5669. }
  5670. mark(blot);
  5671. });
  5672. this.children.forEach(optimize);
  5673. remaining = [].slice.call(this.observer.takeRecords());
  5674. records = remaining.slice();
  5675. while (records.length > 0)
  5676. mutations.push(records.pop());
  5677. }
  5678. };
  5679. ScrollBlot.prototype.update = function (mutations, context) {
  5680. var _this = this;
  5681. if (context === void 0) { context = {}; }
  5682. mutations = mutations || this.observer.takeRecords();
  5683. // TODO use WeakMap
  5684. mutations
  5685. .map(function (mutation) {
  5686. var blot = Registry.find(mutation.target, true);
  5687. if (blot == null)
  5688. return null;
  5689. // @ts-ignore
  5690. if (blot.domNode[Registry.DATA_KEY].mutations == null) {
  5691. // @ts-ignore
  5692. blot.domNode[Registry.DATA_KEY].mutations = [mutation];
  5693. return blot;
  5694. }
  5695. else {
  5696. // @ts-ignore
  5697. blot.domNode[Registry.DATA_KEY].mutations.push(mutation);
  5698. return null;
  5699. }
  5700. })
  5701. .forEach(function (blot) {
  5702. if (blot == null ||
  5703. blot === _this ||
  5704. //@ts-ignore
  5705. blot.domNode[Registry.DATA_KEY] == null)
  5706. return;
  5707. // @ts-ignore
  5708. blot.update(blot.domNode[Registry.DATA_KEY].mutations || [], context);
  5709. });
  5710. // @ts-ignore
  5711. if (this.domNode[Registry.DATA_KEY].mutations != null) {
  5712. // @ts-ignore
  5713. _super.prototype.update.call(this, this.domNode[Registry.DATA_KEY].mutations, context);
  5714. }
  5715. this.optimize(mutations, context);
  5716. };
  5717. ScrollBlot.blotName = 'scroll';
  5718. ScrollBlot.defaultChild = 'block';
  5719. ScrollBlot.scope = Registry.Scope.BLOCK_BLOT;
  5720. ScrollBlot.tagName = 'DIV';
  5721. return ScrollBlot;
  5722. }(container_1.default));
  5723. exports.default = ScrollBlot;
  5724. /***/ }),
  5725. /* 46 */
  5726. /***/ (function(module, exports, __webpack_require__) {
  5727. "use strict";
  5728. var __extends = (this && this.__extends) || (function () {
  5729. var extendStatics = Object.setPrototypeOf ||
  5730. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5731. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5732. return function (d, b) {
  5733. extendStatics(d, b);
  5734. function __() { this.constructor = d; }
  5735. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5736. };
  5737. })();
  5738. Object.defineProperty(exports, "__esModule", { value: true });
  5739. var format_1 = __webpack_require__(18);
  5740. var Registry = __webpack_require__(1);
  5741. // Shallow object comparison
  5742. function isEqual(obj1, obj2) {
  5743. if (Object.keys(obj1).length !== Object.keys(obj2).length)
  5744. return false;
  5745. // @ts-ignore
  5746. for (var prop in obj1) {
  5747. // @ts-ignore
  5748. if (obj1[prop] !== obj2[prop])
  5749. return false;
  5750. }
  5751. return true;
  5752. }
  5753. var InlineBlot = /** @class */ (function (_super) {
  5754. __extends(InlineBlot, _super);
  5755. function InlineBlot() {
  5756. return _super !== null && _super.apply(this, arguments) || this;
  5757. }
  5758. InlineBlot.formats = function (domNode) {
  5759. if (domNode.tagName === InlineBlot.tagName)
  5760. return undefined;
  5761. return _super.formats.call(this, domNode);
  5762. };
  5763. InlineBlot.prototype.format = function (name, value) {
  5764. var _this = this;
  5765. if (name === this.statics.blotName && !value) {
  5766. this.children.forEach(function (child) {
  5767. if (!(child instanceof format_1.default)) {
  5768. child = child.wrap(InlineBlot.blotName, true);
  5769. }
  5770. _this.attributes.copy(child);
  5771. });
  5772. this.unwrap();
  5773. }
  5774. else {
  5775. _super.prototype.format.call(this, name, value);
  5776. }
  5777. };
  5778. InlineBlot.prototype.formatAt = function (index, length, name, value) {
  5779. if (this.formats()[name] != null || Registry.query(name, Registry.Scope.ATTRIBUTE)) {
  5780. var blot = this.isolate(index, length);
  5781. blot.format(name, value);
  5782. }
  5783. else {
  5784. _super.prototype.formatAt.call(this, index, length, name, value);
  5785. }
  5786. };
  5787. InlineBlot.prototype.optimize = function (context) {
  5788. _super.prototype.optimize.call(this, context);
  5789. var formats = this.formats();
  5790. if (Object.keys(formats).length === 0) {
  5791. return this.unwrap(); // unformatted span
  5792. }
  5793. var next = this.next;
  5794. if (next instanceof InlineBlot && next.prev === this && isEqual(formats, next.formats())) {
  5795. next.moveChildren(this);
  5796. next.remove();
  5797. }
  5798. };
  5799. InlineBlot.blotName = 'inline';
  5800. InlineBlot.scope = Registry.Scope.INLINE_BLOT;
  5801. InlineBlot.tagName = 'SPAN';
  5802. return InlineBlot;
  5803. }(format_1.default));
  5804. exports.default = InlineBlot;
  5805. /***/ }),
  5806. /* 47 */
  5807. /***/ (function(module, exports, __webpack_require__) {
  5808. "use strict";
  5809. var __extends = (this && this.__extends) || (function () {
  5810. var extendStatics = Object.setPrototypeOf ||
  5811. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5812. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5813. return function (d, b) {
  5814. extendStatics(d, b);
  5815. function __() { this.constructor = d; }
  5816. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5817. };
  5818. })();
  5819. Object.defineProperty(exports, "__esModule", { value: true });
  5820. var format_1 = __webpack_require__(18);
  5821. var Registry = __webpack_require__(1);
  5822. var BlockBlot = /** @class */ (function (_super) {
  5823. __extends(BlockBlot, _super);
  5824. function BlockBlot() {
  5825. return _super !== null && _super.apply(this, arguments) || this;
  5826. }
  5827. BlockBlot.formats = function (domNode) {
  5828. var tagName = Registry.query(BlockBlot.blotName).tagName;
  5829. if (domNode.tagName === tagName)
  5830. return undefined;
  5831. return _super.formats.call(this, domNode);
  5832. };
  5833. BlockBlot.prototype.format = function (name, value) {
  5834. if (Registry.query(name, Registry.Scope.BLOCK) == null) {
  5835. return;
  5836. }
  5837. else if (name === this.statics.blotName && !value) {
  5838. this.replaceWith(BlockBlot.blotName);
  5839. }
  5840. else {
  5841. _super.prototype.format.call(this, name, value);
  5842. }
  5843. };
  5844. BlockBlot.prototype.formatAt = function (index, length, name, value) {
  5845. if (Registry.query(name, Registry.Scope.BLOCK) != null) {
  5846. this.format(name, value);
  5847. }
  5848. else {
  5849. _super.prototype.formatAt.call(this, index, length, name, value);
  5850. }
  5851. };
  5852. BlockBlot.prototype.insertAt = function (index, value, def) {
  5853. if (def == null || Registry.query(value, Registry.Scope.INLINE) != null) {
  5854. // Insert text or inline
  5855. _super.prototype.insertAt.call(this, index, value, def);
  5856. }
  5857. else {
  5858. var after = this.split(index);
  5859. var blot = Registry.create(value, def);
  5860. after.parent.insertBefore(blot, after);
  5861. }
  5862. };
  5863. BlockBlot.prototype.update = function (mutations, context) {
  5864. if (navigator.userAgent.match(/Trident/)) {
  5865. this.build();
  5866. }
  5867. else {
  5868. _super.prototype.update.call(this, mutations, context);
  5869. }
  5870. };
  5871. BlockBlot.blotName = 'block';
  5872. BlockBlot.scope = Registry.Scope.BLOCK_BLOT;
  5873. BlockBlot.tagName = 'P';
  5874. return BlockBlot;
  5875. }(format_1.default));
  5876. exports.default = BlockBlot;
  5877. /***/ }),
  5878. /* 48 */
  5879. /***/ (function(module, exports, __webpack_require__) {
  5880. "use strict";
  5881. var __extends = (this && this.__extends) || (function () {
  5882. var extendStatics = Object.setPrototypeOf ||
  5883. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5884. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5885. return function (d, b) {
  5886. extendStatics(d, b);
  5887. function __() { this.constructor = d; }
  5888. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5889. };
  5890. })();
  5891. Object.defineProperty(exports, "__esModule", { value: true });
  5892. var leaf_1 = __webpack_require__(19);
  5893. var EmbedBlot = /** @class */ (function (_super) {
  5894. __extends(EmbedBlot, _super);
  5895. function EmbedBlot() {
  5896. return _super !== null && _super.apply(this, arguments) || this;
  5897. }
  5898. EmbedBlot.formats = function (domNode) {
  5899. return undefined;
  5900. };
  5901. EmbedBlot.prototype.format = function (name, value) {
  5902. // super.formatAt wraps, which is what we want in general,
  5903. // but this allows subclasses to overwrite for formats
  5904. // that just apply to particular embeds
  5905. _super.prototype.formatAt.call(this, 0, this.length(), name, value);
  5906. };
  5907. EmbedBlot.prototype.formatAt = function (index, length, name, value) {
  5908. if (index === 0 && length === this.length()) {
  5909. this.format(name, value);
  5910. }
  5911. else {
  5912. _super.prototype.formatAt.call(this, index, length, name, value);
  5913. }
  5914. };
  5915. EmbedBlot.prototype.formats = function () {
  5916. return this.statics.formats(this.domNode);
  5917. };
  5918. return EmbedBlot;
  5919. }(leaf_1.default));
  5920. exports.default = EmbedBlot;
  5921. /***/ }),
  5922. /* 49 */
  5923. /***/ (function(module, exports, __webpack_require__) {
  5924. "use strict";
  5925. var __extends = (this && this.__extends) || (function () {
  5926. var extendStatics = Object.setPrototypeOf ||
  5927. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5928. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5929. return function (d, b) {
  5930. extendStatics(d, b);
  5931. function __() { this.constructor = d; }
  5932. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5933. };
  5934. })();
  5935. Object.defineProperty(exports, "__esModule", { value: true });
  5936. var leaf_1 = __webpack_require__(19);
  5937. var Registry = __webpack_require__(1);
  5938. var TextBlot = /** @class */ (function (_super) {
  5939. __extends(TextBlot, _super);
  5940. function TextBlot(node) {
  5941. var _this = _super.call(this, node) || this;
  5942. _this.text = _this.statics.value(_this.domNode);
  5943. return _this;
  5944. }
  5945. TextBlot.create = function (value) {
  5946. return document.createTextNode(value);
  5947. };
  5948. TextBlot.value = function (domNode) {
  5949. var text = domNode.data;
  5950. // @ts-ignore
  5951. if (text['normalize'])
  5952. text = text['normalize']();
  5953. return text;
  5954. };
  5955. TextBlot.prototype.deleteAt = function (index, length) {
  5956. this.domNode.data = this.text = this.text.slice(0, index) + this.text.slice(index + length);
  5957. };
  5958. TextBlot.prototype.index = function (node, offset) {
  5959. if (this.domNode === node) {
  5960. return offset;
  5961. }
  5962. return -1;
  5963. };
  5964. TextBlot.prototype.insertAt = function (index, value, def) {
  5965. if (def == null) {
  5966. this.text = this.text.slice(0, index) + value + this.text.slice(index);
  5967. this.domNode.data = this.text;
  5968. }
  5969. else {
  5970. _super.prototype.insertAt.call(this, index, value, def);
  5971. }
  5972. };
  5973. TextBlot.prototype.length = function () {
  5974. return this.text.length;
  5975. };
  5976. TextBlot.prototype.optimize = function (context) {
  5977. _super.prototype.optimize.call(this, context);
  5978. this.text = this.statics.value(this.domNode);
  5979. if (this.text.length === 0) {
  5980. this.remove();
  5981. }
  5982. else if (this.next instanceof TextBlot && this.next.prev === this) {
  5983. this.insertAt(this.length(), this.next.value());
  5984. this.next.remove();
  5985. }
  5986. };
  5987. TextBlot.prototype.position = function (index, inclusive) {
  5988. if (inclusive === void 0) { inclusive = false; }
  5989. return [this.domNode, index];
  5990. };
  5991. TextBlot.prototype.split = function (index, force) {
  5992. if (force === void 0) { force = false; }
  5993. if (!force) {
  5994. if (index === 0)
  5995. return this;
  5996. if (index === this.length())
  5997. return this.next;
  5998. }
  5999. var after = Registry.create(this.domNode.splitText(index));
  6000. this.parent.insertBefore(after, this.next);
  6001. this.text = this.statics.value(this.domNode);
  6002. return after;
  6003. };
  6004. TextBlot.prototype.update = function (mutations, context) {
  6005. var _this = this;
  6006. if (mutations.some(function (mutation) {
  6007. return mutation.type === 'characterData' && mutation.target === _this.domNode;
  6008. })) {
  6009. this.text = this.statics.value(this.domNode);
  6010. }
  6011. };
  6012. TextBlot.prototype.value = function () {
  6013. return this.text;
  6014. };
  6015. TextBlot.blotName = 'text';
  6016. TextBlot.scope = Registry.Scope.INLINE_BLOT;
  6017. return TextBlot;
  6018. }(leaf_1.default));
  6019. exports.default = TextBlot;
  6020. /***/ }),
  6021. /* 50 */
  6022. /***/ (function(module, exports, __webpack_require__) {
  6023. "use strict";
  6024. var elem = document.createElement('div');
  6025. elem.classList.toggle('test-class', false);
  6026. if (elem.classList.contains('test-class')) {
  6027. var _toggle = DOMTokenList.prototype.toggle;
  6028. DOMTokenList.prototype.toggle = function (token, force) {
  6029. if (arguments.length > 1 && !this.contains(token) === !force) {
  6030. return force;
  6031. } else {
  6032. return _toggle.call(this, token);
  6033. }
  6034. };
  6035. }
  6036. if (!String.prototype.startsWith) {
  6037. String.prototype.startsWith = function (searchString, position) {
  6038. position = position || 0;
  6039. return this.substr(position, searchString.length) === searchString;
  6040. };
  6041. }
  6042. if (!String.prototype.endsWith) {
  6043. String.prototype.endsWith = function (searchString, position) {
  6044. var subjectString = this.toString();
  6045. if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
  6046. position = subjectString.length;
  6047. }
  6048. position -= searchString.length;
  6049. var lastIndex = subjectString.indexOf(searchString, position);
  6050. return lastIndex !== -1 && lastIndex === position;
  6051. };
  6052. }
  6053. if (!Array.prototype.find) {
  6054. Object.defineProperty(Array.prototype, "find", {
  6055. value: function value(predicate) {
  6056. if (this === null) {
  6057. throw new TypeError('Array.prototype.find called on null or undefined');
  6058. }
  6059. if (typeof predicate !== 'function') {
  6060. throw new TypeError('predicate must be a function');
  6061. }
  6062. var list = Object(this);
  6063. var length = list.length >>> 0;
  6064. var thisArg = arguments[1];
  6065. var value;
  6066. for (var i = 0; i < length; i++) {
  6067. value = list[i];
  6068. if (predicate.call(thisArg, value, i, list)) {
  6069. return value;
  6070. }
  6071. }
  6072. return undefined;
  6073. }
  6074. });
  6075. }
  6076. document.addEventListener("DOMContentLoaded", function () {
  6077. // Disable resizing in Firefox
  6078. document.execCommand("enableObjectResizing", false, false);
  6079. // Disable automatic linkifying in IE11
  6080. document.execCommand("autoUrlDetect", false, false);
  6081. });
  6082. /***/ }),
  6083. /* 51 */
  6084. /***/ (function(module, exports) {
  6085. /**
  6086. * This library modifies the diff-patch-match library by Neil Fraser
  6087. * by removing the patch and match functionality and certain advanced
  6088. * options in the diff function. The original license is as follows:
  6089. *
  6090. * ===
  6091. *
  6092. * Diff Match and Patch
  6093. *
  6094. * Copyright 2006 Google Inc.
  6095. * http://code.google.com/p/google-diff-match-patch/
  6096. *
  6097. * Licensed under the Apache License, Version 2.0 (the "License");
  6098. * you may not use this file except in compliance with the License.
  6099. * You may obtain a copy of the License at
  6100. *
  6101. * http://www.apache.org/licenses/LICENSE-2.0
  6102. *
  6103. * Unless required by applicable law or agreed to in writing, software
  6104. * distributed under the License is distributed on an "AS IS" BASIS,
  6105. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  6106. * See the License for the specific language governing permissions and
  6107. * limitations under the License.
  6108. */
  6109. /**
  6110. * The data structure representing a diff is an array of tuples:
  6111. * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
  6112. * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
  6113. */
  6114. var DIFF_DELETE = -1;
  6115. var DIFF_INSERT = 1;
  6116. var DIFF_EQUAL = 0;
  6117. /**
  6118. * Find the differences between two texts. Simplifies the problem by stripping
  6119. * any common prefix or suffix off the texts before diffing.
  6120. * @param {string} text1 Old string to be diffed.
  6121. * @param {string} text2 New string to be diffed.
  6122. * @param {Int} cursor_pos Expected edit position in text1 (optional)
  6123. * @return {Array} Array of diff tuples.
  6124. */
  6125. function diff_main(text1, text2, cursor_pos) {
  6126. // Check for equality (speedup).
  6127. if (text1 == text2) {
  6128. if (text1) {
  6129. return [[DIFF_EQUAL, text1]];
  6130. }
  6131. return [];
  6132. }
  6133. // Check cursor_pos within bounds
  6134. if (cursor_pos < 0 || text1.length < cursor_pos) {
  6135. cursor_pos = null;
  6136. }
  6137. // Trim off common prefix (speedup).
  6138. var commonlength = diff_commonPrefix(text1, text2);
  6139. var commonprefix = text1.substring(0, commonlength);
  6140. text1 = text1.substring(commonlength);
  6141. text2 = text2.substring(commonlength);
  6142. // Trim off common suffix (speedup).
  6143. commonlength = diff_commonSuffix(text1, text2);
  6144. var commonsuffix = text1.substring(text1.length - commonlength);
  6145. text1 = text1.substring(0, text1.length - commonlength);
  6146. text2 = text2.substring(0, text2.length - commonlength);
  6147. // Compute the diff on the middle block.
  6148. var diffs = diff_compute_(text1, text2);
  6149. // Restore the prefix and suffix.
  6150. if (commonprefix) {
  6151. diffs.unshift([DIFF_EQUAL, commonprefix]);
  6152. }
  6153. if (commonsuffix) {
  6154. diffs.push([DIFF_EQUAL, commonsuffix]);
  6155. }
  6156. diff_cleanupMerge(diffs);
  6157. if (cursor_pos != null) {
  6158. diffs = fix_cursor(diffs, cursor_pos);
  6159. }
  6160. diffs = fix_emoji(diffs);
  6161. return diffs;
  6162. };
  6163. /**
  6164. * Find the differences between two texts. Assumes that the texts do not
  6165. * have any common prefix or suffix.
  6166. * @param {string} text1 Old string to be diffed.
  6167. * @param {string} text2 New string to be diffed.
  6168. * @return {Array} Array of diff tuples.
  6169. */
  6170. function diff_compute_(text1, text2) {
  6171. var diffs;
  6172. if (!text1) {
  6173. // Just add some text (speedup).
  6174. return [[DIFF_INSERT, text2]];
  6175. }
  6176. if (!text2) {
  6177. // Just delete some text (speedup).
  6178. return [[DIFF_DELETE, text1]];
  6179. }
  6180. var longtext = text1.length > text2.length ? text1 : text2;
  6181. var shorttext = text1.length > text2.length ? text2 : text1;
  6182. var i = longtext.indexOf(shorttext);
  6183. if (i != -1) {
  6184. // Shorter text is inside the longer text (speedup).
  6185. diffs = [[DIFF_INSERT, longtext.substring(0, i)],
  6186. [DIFF_EQUAL, shorttext],
  6187. [DIFF_INSERT, longtext.substring(i + shorttext.length)]];
  6188. // Swap insertions for deletions if diff is reversed.
  6189. if (text1.length > text2.length) {
  6190. diffs[0][0] = diffs[2][0] = DIFF_DELETE;
  6191. }
  6192. return diffs;
  6193. }
  6194. if (shorttext.length == 1) {
  6195. // Single character string.
  6196. // After the previous speedup, the character can't be an equality.
  6197. return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
  6198. }
  6199. // Check to see if the problem can be split in two.
  6200. var hm = diff_halfMatch_(text1, text2);
  6201. if (hm) {
  6202. // A half-match was found, sort out the return data.
  6203. var text1_a = hm[0];
  6204. var text1_b = hm[1];
  6205. var text2_a = hm[2];
  6206. var text2_b = hm[3];
  6207. var mid_common = hm[4];
  6208. // Send both pairs off for separate processing.
  6209. var diffs_a = diff_main(text1_a, text2_a);
  6210. var diffs_b = diff_main(text1_b, text2_b);
  6211. // Merge the results.
  6212. return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b);
  6213. }
  6214. return diff_bisect_(text1, text2);
  6215. };
  6216. /**
  6217. * Find the 'middle snake' of a diff, split the problem in two
  6218. * and return the recursively constructed diff.
  6219. * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
  6220. * @param {string} text1 Old string to be diffed.
  6221. * @param {string} text2 New string to be diffed.
  6222. * @return {Array} Array of diff tuples.
  6223. * @private
  6224. */
  6225. function diff_bisect_(text1, text2) {
  6226. // Cache the text lengths to prevent multiple calls.
  6227. var text1_length = text1.length;
  6228. var text2_length = text2.length;
  6229. var max_d = Math.ceil((text1_length + text2_length) / 2);
  6230. var v_offset = max_d;
  6231. var v_length = 2 * max_d;
  6232. var v1 = new Array(v_length);
  6233. var v2 = new Array(v_length);
  6234. // Setting all elements to -1 is faster in Chrome & Firefox than mixing
  6235. // integers and undefined.
  6236. for (var x = 0; x < v_length; x++) {
  6237. v1[x] = -1;
  6238. v2[x] = -1;
  6239. }
  6240. v1[v_offset + 1] = 0;
  6241. v2[v_offset + 1] = 0;
  6242. var delta = text1_length - text2_length;
  6243. // If the total number of characters is odd, then the front path will collide
  6244. // with the reverse path.
  6245. var front = (delta % 2 != 0);
  6246. // Offsets for start and end of k loop.
  6247. // Prevents mapping of space beyond the grid.
  6248. var k1start = 0;
  6249. var k1end = 0;
  6250. var k2start = 0;
  6251. var k2end = 0;
  6252. for (var d = 0; d < max_d; d++) {
  6253. // Walk the front path one step.
  6254. for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
  6255. var k1_offset = v_offset + k1;
  6256. var x1;
  6257. if (k1 == -d || (k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1])) {
  6258. x1 = v1[k1_offset + 1];
  6259. } else {
  6260. x1 = v1[k1_offset - 1] + 1;
  6261. }
  6262. var y1 = x1 - k1;
  6263. while (x1 < text1_length && y1 < text2_length &&
  6264. text1.charAt(x1) == text2.charAt(y1)) {
  6265. x1++;
  6266. y1++;
  6267. }
  6268. v1[k1_offset] = x1;
  6269. if (x1 > text1_length) {
  6270. // Ran off the right of the graph.
  6271. k1end += 2;
  6272. } else if (y1 > text2_length) {
  6273. // Ran off the bottom of the graph.
  6274. k1start += 2;
  6275. } else if (front) {
  6276. var k2_offset = v_offset + delta - k1;
  6277. if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] != -1) {
  6278. // Mirror x2 onto top-left coordinate system.
  6279. var x2 = text1_length - v2[k2_offset];
  6280. if (x1 >= x2) {
  6281. // Overlap detected.
  6282. return diff_bisectSplit_(text1, text2, x1, y1);
  6283. }
  6284. }
  6285. }
  6286. }
  6287. // Walk the reverse path one step.
  6288. for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
  6289. var k2_offset = v_offset + k2;
  6290. var x2;
  6291. if (k2 == -d || (k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1])) {
  6292. x2 = v2[k2_offset + 1];
  6293. } else {
  6294. x2 = v2[k2_offset - 1] + 1;
  6295. }
  6296. var y2 = x2 - k2;
  6297. while (x2 < text1_length && y2 < text2_length &&
  6298. text1.charAt(text1_length - x2 - 1) ==
  6299. text2.charAt(text2_length - y2 - 1)) {
  6300. x2++;
  6301. y2++;
  6302. }
  6303. v2[k2_offset] = x2;
  6304. if (x2 > text1_length) {
  6305. // Ran off the left of the graph.
  6306. k2end += 2;
  6307. } else if (y2 > text2_length) {
  6308. // Ran off the top of the graph.
  6309. k2start += 2;
  6310. } else if (!front) {
  6311. var k1_offset = v_offset + delta - k2;
  6312. if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] != -1) {
  6313. var x1 = v1[k1_offset];
  6314. var y1 = v_offset + x1 - k1_offset;
  6315. // Mirror x2 onto top-left coordinate system.
  6316. x2 = text1_length - x2;
  6317. if (x1 >= x2) {
  6318. // Overlap detected.
  6319. return diff_bisectSplit_(text1, text2, x1, y1);
  6320. }
  6321. }
  6322. }
  6323. }
  6324. }
  6325. // Diff took too long and hit the deadline or
  6326. // number of diffs equals number of characters, no commonality at all.
  6327. return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
  6328. };
  6329. /**
  6330. * Given the location of the 'middle snake', split the diff in two parts
  6331. * and recurse.
  6332. * @param {string} text1 Old string to be diffed.
  6333. * @param {string} text2 New string to be diffed.
  6334. * @param {number} x Index of split point in text1.
  6335. * @param {number} y Index of split point in text2.
  6336. * @return {Array} Array of diff tuples.
  6337. */
  6338. function diff_bisectSplit_(text1, text2, x, y) {
  6339. var text1a = text1.substring(0, x);
  6340. var text2a = text2.substring(0, y);
  6341. var text1b = text1.substring(x);
  6342. var text2b = text2.substring(y);
  6343. // Compute both diffs serially.
  6344. var diffs = diff_main(text1a, text2a);
  6345. var diffsb = diff_main(text1b, text2b);
  6346. return diffs.concat(diffsb);
  6347. };
  6348. /**
  6349. * Determine the common prefix of two strings.
  6350. * @param {string} text1 First string.
  6351. * @param {string} text2 Second string.
  6352. * @return {number} The number of characters common to the start of each
  6353. * string.
  6354. */
  6355. function diff_commonPrefix(text1, text2) {
  6356. // Quick check for common null cases.
  6357. if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) {
  6358. return 0;
  6359. }
  6360. // Binary search.
  6361. // Performance analysis: http://neil.fraser.name/news/2007/10/09/
  6362. var pointermin = 0;
  6363. var pointermax = Math.min(text1.length, text2.length);
  6364. var pointermid = pointermax;
  6365. var pointerstart = 0;
  6366. while (pointermin < pointermid) {
  6367. if (text1.substring(pointerstart, pointermid) ==
  6368. text2.substring(pointerstart, pointermid)) {
  6369. pointermin = pointermid;
  6370. pointerstart = pointermin;
  6371. } else {
  6372. pointermax = pointermid;
  6373. }
  6374. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  6375. }
  6376. return pointermid;
  6377. };
  6378. /**
  6379. * Determine the common suffix of two strings.
  6380. * @param {string} text1 First string.
  6381. * @param {string} text2 Second string.
  6382. * @return {number} The number of characters common to the end of each string.
  6383. */
  6384. function diff_commonSuffix(text1, text2) {
  6385. // Quick check for common null cases.
  6386. if (!text1 || !text2 ||
  6387. text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)) {
  6388. return 0;
  6389. }
  6390. // Binary search.
  6391. // Performance analysis: http://neil.fraser.name/news/2007/10/09/
  6392. var pointermin = 0;
  6393. var pointermax = Math.min(text1.length, text2.length);
  6394. var pointermid = pointermax;
  6395. var pointerend = 0;
  6396. while (pointermin < pointermid) {
  6397. if (text1.substring(text1.length - pointermid, text1.length - pointerend) ==
  6398. text2.substring(text2.length - pointermid, text2.length - pointerend)) {
  6399. pointermin = pointermid;
  6400. pointerend = pointermin;
  6401. } else {
  6402. pointermax = pointermid;
  6403. }
  6404. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  6405. }
  6406. return pointermid;
  6407. };
  6408. /**
  6409. * Do the two texts share a substring which is at least half the length of the
  6410. * longer text?
  6411. * This speedup can produce non-minimal diffs.
  6412. * @param {string} text1 First string.
  6413. * @param {string} text2 Second string.
  6414. * @return {Array.<string>} Five element Array, containing the prefix of
  6415. * text1, the suffix of text1, the prefix of text2, the suffix of
  6416. * text2 and the common middle. Or null if there was no match.
  6417. */
  6418. function diff_halfMatch_(text1, text2) {
  6419. var longtext = text1.length > text2.length ? text1 : text2;
  6420. var shorttext = text1.length > text2.length ? text2 : text1;
  6421. if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
  6422. return null; // Pointless.
  6423. }
  6424. /**
  6425. * Does a substring of shorttext exist within longtext such that the substring
  6426. * is at least half the length of longtext?
  6427. * Closure, but does not reference any external variables.
  6428. * @param {string} longtext Longer string.
  6429. * @param {string} shorttext Shorter string.
  6430. * @param {number} i Start index of quarter length substring within longtext.
  6431. * @return {Array.<string>} Five element Array, containing the prefix of
  6432. * longtext, the suffix of longtext, the prefix of shorttext, the suffix
  6433. * of shorttext and the common middle. Or null if there was no match.
  6434. * @private
  6435. */
  6436. function diff_halfMatchI_(longtext, shorttext, i) {
  6437. // Start with a 1/4 length substring at position i as a seed.
  6438. var seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
  6439. var j = -1;
  6440. var best_common = '';
  6441. var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
  6442. while ((j = shorttext.indexOf(seed, j + 1)) != -1) {
  6443. var prefixLength = diff_commonPrefix(longtext.substring(i),
  6444. shorttext.substring(j));
  6445. var suffixLength = diff_commonSuffix(longtext.substring(0, i),
  6446. shorttext.substring(0, j));
  6447. if (best_common.length < suffixLength + prefixLength) {
  6448. best_common = shorttext.substring(j - suffixLength, j) +
  6449. shorttext.substring(j, j + prefixLength);
  6450. best_longtext_a = longtext.substring(0, i - suffixLength);
  6451. best_longtext_b = longtext.substring(i + prefixLength);
  6452. best_shorttext_a = shorttext.substring(0, j - suffixLength);
  6453. best_shorttext_b = shorttext.substring(j + prefixLength);
  6454. }
  6455. }
  6456. if (best_common.length * 2 >= longtext.length) {
  6457. return [best_longtext_a, best_longtext_b,
  6458. best_shorttext_a, best_shorttext_b, best_common];
  6459. } else {
  6460. return null;
  6461. }
  6462. }
  6463. // First check if the second quarter is the seed for a half-match.
  6464. var hm1 = diff_halfMatchI_(longtext, shorttext,
  6465. Math.ceil(longtext.length / 4));
  6466. // Check again based on the third quarter.
  6467. var hm2 = diff_halfMatchI_(longtext, shorttext,
  6468. Math.ceil(longtext.length / 2));
  6469. var hm;
  6470. if (!hm1 && !hm2) {
  6471. return null;
  6472. } else if (!hm2) {
  6473. hm = hm1;
  6474. } else if (!hm1) {
  6475. hm = hm2;
  6476. } else {
  6477. // Both matched. Select the longest.
  6478. hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
  6479. }
  6480. // A half-match was found, sort out the return data.
  6481. var text1_a, text1_b, text2_a, text2_b;
  6482. if (text1.length > text2.length) {
  6483. text1_a = hm[0];
  6484. text1_b = hm[1];
  6485. text2_a = hm[2];
  6486. text2_b = hm[3];
  6487. } else {
  6488. text2_a = hm[0];
  6489. text2_b = hm[1];
  6490. text1_a = hm[2];
  6491. text1_b = hm[3];
  6492. }
  6493. var mid_common = hm[4];
  6494. return [text1_a, text1_b, text2_a, text2_b, mid_common];
  6495. };
  6496. /**
  6497. * Reorder and merge like edit sections. Merge equalities.
  6498. * Any edit section can move as long as it doesn't cross an equality.
  6499. * @param {Array} diffs Array of diff tuples.
  6500. */
  6501. function diff_cleanupMerge(diffs) {
  6502. diffs.push([DIFF_EQUAL, '']); // Add a dummy entry at the end.
  6503. var pointer = 0;
  6504. var count_delete = 0;
  6505. var count_insert = 0;
  6506. var text_delete = '';
  6507. var text_insert = '';
  6508. var commonlength;
  6509. while (pointer < diffs.length) {
  6510. switch (diffs[pointer][0]) {
  6511. case DIFF_INSERT:
  6512. count_insert++;
  6513. text_insert += diffs[pointer][1];
  6514. pointer++;
  6515. break;
  6516. case DIFF_DELETE:
  6517. count_delete++;
  6518. text_delete += diffs[pointer][1];
  6519. pointer++;
  6520. break;
  6521. case DIFF_EQUAL:
  6522. // Upon reaching an equality, check for prior redundancies.
  6523. if (count_delete + count_insert > 1) {
  6524. if (count_delete !== 0 && count_insert !== 0) {
  6525. // Factor out any common prefixies.
  6526. commonlength = diff_commonPrefix(text_insert, text_delete);
  6527. if (commonlength !== 0) {
  6528. if ((pointer - count_delete - count_insert) > 0 &&
  6529. diffs[pointer - count_delete - count_insert - 1][0] ==
  6530. DIFF_EQUAL) {
  6531. diffs[pointer - count_delete - count_insert - 1][1] +=
  6532. text_insert.substring(0, commonlength);
  6533. } else {
  6534. diffs.splice(0, 0, [DIFF_EQUAL,
  6535. text_insert.substring(0, commonlength)]);
  6536. pointer++;
  6537. }
  6538. text_insert = text_insert.substring(commonlength);
  6539. text_delete = text_delete.substring(commonlength);
  6540. }
  6541. // Factor out any common suffixies.
  6542. commonlength = diff_commonSuffix(text_insert, text_delete);
  6543. if (commonlength !== 0) {
  6544. diffs[pointer][1] = text_insert.substring(text_insert.length -
  6545. commonlength) + diffs[pointer][1];
  6546. text_insert = text_insert.substring(0, text_insert.length -
  6547. commonlength);
  6548. text_delete = text_delete.substring(0, text_delete.length -
  6549. commonlength);
  6550. }
  6551. }
  6552. // Delete the offending records and add the merged ones.
  6553. if (count_delete === 0) {
  6554. diffs.splice(pointer - count_insert,
  6555. count_delete + count_insert, [DIFF_INSERT, text_insert]);
  6556. } else if (count_insert === 0) {
  6557. diffs.splice(pointer - count_delete,
  6558. count_delete + count_insert, [DIFF_DELETE, text_delete]);
  6559. } else {
  6560. diffs.splice(pointer - count_delete - count_insert,
  6561. count_delete + count_insert, [DIFF_DELETE, text_delete],
  6562. [DIFF_INSERT, text_insert]);
  6563. }
  6564. pointer = pointer - count_delete - count_insert +
  6565. (count_delete ? 1 : 0) + (count_insert ? 1 : 0) + 1;
  6566. } else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) {
  6567. // Merge this equality with the previous one.
  6568. diffs[pointer - 1][1] += diffs[pointer][1];
  6569. diffs.splice(pointer, 1);
  6570. } else {
  6571. pointer++;
  6572. }
  6573. count_insert = 0;
  6574. count_delete = 0;
  6575. text_delete = '';
  6576. text_insert = '';
  6577. break;
  6578. }
  6579. }
  6580. if (diffs[diffs.length - 1][1] === '') {
  6581. diffs.pop(); // Remove the dummy entry at the end.
  6582. }
  6583. // Second pass: look for single edits surrounded on both sides by equalities
  6584. // which can be shifted sideways to eliminate an equality.
  6585. // e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
  6586. var changes = false;
  6587. pointer = 1;
  6588. // Intentionally ignore the first and last element (don't need checking).
  6589. while (pointer < diffs.length - 1) {
  6590. if (diffs[pointer - 1][0] == DIFF_EQUAL &&
  6591. diffs[pointer + 1][0] == DIFF_EQUAL) {
  6592. // This is a single edit surrounded by equalities.
  6593. if (diffs[pointer][1].substring(diffs[pointer][1].length -
  6594. diffs[pointer - 1][1].length) == diffs[pointer - 1][1]) {
  6595. // Shift the edit over the previous equality.
  6596. diffs[pointer][1] = diffs[pointer - 1][1] +
  6597. diffs[pointer][1].substring(0, diffs[pointer][1].length -
  6598. diffs[pointer - 1][1].length);
  6599. diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
  6600. diffs.splice(pointer - 1, 1);
  6601. changes = true;
  6602. } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) ==
  6603. diffs[pointer + 1][1]) {
  6604. // Shift the edit over the next equality.
  6605. diffs[pointer - 1][1] += diffs[pointer + 1][1];
  6606. diffs[pointer][1] =
  6607. diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
  6608. diffs[pointer + 1][1];
  6609. diffs.splice(pointer + 1, 1);
  6610. changes = true;
  6611. }
  6612. }
  6613. pointer++;
  6614. }
  6615. // If shifts were made, the diff needs reordering and another shift sweep.
  6616. if (changes) {
  6617. diff_cleanupMerge(diffs);
  6618. }
  6619. };
  6620. var diff = diff_main;
  6621. diff.INSERT = DIFF_INSERT;
  6622. diff.DELETE = DIFF_DELETE;
  6623. diff.EQUAL = DIFF_EQUAL;
  6624. module.exports = diff;
  6625. /*
  6626. * Modify a diff such that the cursor position points to the start of a change:
  6627. * E.g.
  6628. * cursor_normalize_diff([[DIFF_EQUAL, 'abc']], 1)
  6629. * => [1, [[DIFF_EQUAL, 'a'], [DIFF_EQUAL, 'bc']]]
  6630. * cursor_normalize_diff([[DIFF_INSERT, 'new'], [DIFF_DELETE, 'xyz']], 2)
  6631. * => [2, [[DIFF_INSERT, 'new'], [DIFF_DELETE, 'xy'], [DIFF_DELETE, 'z']]]
  6632. *
  6633. * @param {Array} diffs Array of diff tuples
  6634. * @param {Int} cursor_pos Suggested edit position. Must not be out of bounds!
  6635. * @return {Array} A tuple [cursor location in the modified diff, modified diff]
  6636. */
  6637. function cursor_normalize_diff (diffs, cursor_pos) {
  6638. if (cursor_pos === 0) {
  6639. return [DIFF_EQUAL, diffs];
  6640. }
  6641. for (var current_pos = 0, i = 0; i < diffs.length; i++) {
  6642. var d = diffs[i];
  6643. if (d[0] === DIFF_DELETE || d[0] === DIFF_EQUAL) {
  6644. var next_pos = current_pos + d[1].length;
  6645. if (cursor_pos === next_pos) {
  6646. return [i + 1, diffs];
  6647. } else if (cursor_pos < next_pos) {
  6648. // copy to prevent side effects
  6649. diffs = diffs.slice();
  6650. // split d into two diff changes
  6651. var split_pos = cursor_pos - current_pos;
  6652. var d_left = [d[0], d[1].slice(0, split_pos)];
  6653. var d_right = [d[0], d[1].slice(split_pos)];
  6654. diffs.splice(i, 1, d_left, d_right);
  6655. return [i + 1, diffs];
  6656. } else {
  6657. current_pos = next_pos;
  6658. }
  6659. }
  6660. }
  6661. throw new Error('cursor_pos is out of bounds!')
  6662. }
  6663. /*
  6664. * Modify a diff such that the edit position is "shifted" to the proposed edit location (cursor_position).
  6665. *
  6666. * Case 1)
  6667. * Check if a naive shift is possible:
  6668. * [0, X], [ 1, Y] -> [ 1, Y], [0, X] (if X + Y === Y + X)
  6669. * [0, X], [-1, Y] -> [-1, Y], [0, X] (if X + Y === Y + X) - holds same result
  6670. * Case 2)
  6671. * Check if the following shifts are possible:
  6672. * [0, 'pre'], [ 1, 'prefix'] -> [ 1, 'pre'], [0, 'pre'], [ 1, 'fix']
  6673. * [0, 'pre'], [-1, 'prefix'] -> [-1, 'pre'], [0, 'pre'], [-1, 'fix']
  6674. * ^ ^
  6675. * d d_next
  6676. *
  6677. * @param {Array} diffs Array of diff tuples
  6678. * @param {Int} cursor_pos Suggested edit position. Must not be out of bounds!
  6679. * @return {Array} Array of diff tuples
  6680. */
  6681. function fix_cursor (diffs, cursor_pos) {
  6682. var norm = cursor_normalize_diff(diffs, cursor_pos);
  6683. var ndiffs = norm[1];
  6684. var cursor_pointer = norm[0];
  6685. var d = ndiffs[cursor_pointer];
  6686. var d_next = ndiffs[cursor_pointer + 1];
  6687. if (d == null) {
  6688. // Text was deleted from end of original string,
  6689. // cursor is now out of bounds in new string
  6690. return diffs;
  6691. } else if (d[0] !== DIFF_EQUAL) {
  6692. // A modification happened at the cursor location.
  6693. // This is the expected outcome, so we can return the original diff.
  6694. return diffs;
  6695. } else {
  6696. if (d_next != null && d[1] + d_next[1] === d_next[1] + d[1]) {
  6697. // Case 1)
  6698. // It is possible to perform a naive shift
  6699. ndiffs.splice(cursor_pointer, 2, d_next, d)
  6700. return merge_tuples(ndiffs, cursor_pointer, 2)
  6701. } else if (d_next != null && d_next[1].indexOf(d[1]) === 0) {
  6702. // Case 2)
  6703. // d[1] is a prefix of d_next[1]
  6704. // We can assume that d_next[0] !== 0, since d[0] === 0
  6705. // Shift edit locations..
  6706. ndiffs.splice(cursor_pointer, 2, [d_next[0], d[1]], [0, d[1]]);
  6707. var suffix = d_next[1].slice(d[1].length);
  6708. if (suffix.length > 0) {
  6709. ndiffs.splice(cursor_pointer + 2, 0, [d_next[0], suffix]);
  6710. }
  6711. return merge_tuples(ndiffs, cursor_pointer, 3)
  6712. } else {
  6713. // Not possible to perform any modification
  6714. return diffs;
  6715. }
  6716. }
  6717. }
  6718. /*
  6719. * Check diff did not split surrogate pairs.
  6720. * Ex. [0, '\uD83D'], [-1, '\uDC36'], [1, '\uDC2F'] -> [-1, '\uD83D\uDC36'], [1, '\uD83D\uDC2F']
  6721. * '\uD83D\uDC36' === '🐶', '\uD83D\uDC2F' === '🐯'
  6722. *
  6723. * @param {Array} diffs Array of diff tuples
  6724. * @return {Array} Array of diff tuples
  6725. */
  6726. function fix_emoji (diffs) {
  6727. var compact = false;
  6728. var starts_with_pair_end = function(str) {
  6729. return str.charCodeAt(0) >= 0xDC00 && str.charCodeAt(0) <= 0xDFFF;
  6730. }
  6731. var ends_with_pair_start = function(str) {
  6732. return str.charCodeAt(str.length-1) >= 0xD800 && str.charCodeAt(str.length-1) <= 0xDBFF;
  6733. }
  6734. for (var i = 2; i < diffs.length; i += 1) {
  6735. if (diffs[i-2][0] === DIFF_EQUAL && ends_with_pair_start(diffs[i-2][1]) &&
  6736. diffs[i-1][0] === DIFF_DELETE && starts_with_pair_end(diffs[i-1][1]) &&
  6737. diffs[i][0] === DIFF_INSERT && starts_with_pair_end(diffs[i][1])) {
  6738. compact = true;
  6739. diffs[i-1][1] = diffs[i-2][1].slice(-1) + diffs[i-1][1];
  6740. diffs[i][1] = diffs[i-2][1].slice(-1) + diffs[i][1];
  6741. diffs[i-2][1] = diffs[i-2][1].slice(0, -1);
  6742. }
  6743. }
  6744. if (!compact) {
  6745. return diffs;
  6746. }
  6747. var fixed_diffs = [];
  6748. for (var i = 0; i < diffs.length; i += 1) {
  6749. if (diffs[i][1].length > 0) {
  6750. fixed_diffs.push(diffs[i]);
  6751. }
  6752. }
  6753. return fixed_diffs;
  6754. }
  6755. /*
  6756. * Try to merge tuples with their neigbors in a given range.
  6757. * E.g. [0, 'a'], [0, 'b'] -> [0, 'ab']
  6758. *
  6759. * @param {Array} diffs Array of diff tuples.
  6760. * @param {Int} start Position of the first element to merge (diffs[start] is also merged with diffs[start - 1]).
  6761. * @param {Int} length Number of consecutive elements to check.
  6762. * @return {Array} Array of merged diff tuples.
  6763. */
  6764. function merge_tuples (diffs, start, length) {
  6765. // Check from (start-1) to (start+length).
  6766. for (var i = start + length - 1; i >= 0 && i >= start - 1; i--) {
  6767. if (i + 1 < diffs.length) {
  6768. var left_d = diffs[i];
  6769. var right_d = diffs[i+1];
  6770. if (left_d[0] === right_d[1]) {
  6771. diffs.splice(i, 2, [left_d[0], left_d[1] + right_d[1]]);
  6772. }
  6773. }
  6774. }
  6775. return diffs;
  6776. }
  6777. /***/ }),
  6778. /* 52 */
  6779. /***/ (function(module, exports) {
  6780. exports = module.exports = typeof Object.keys === 'function'
  6781. ? Object.keys : shim;
  6782. exports.shim = shim;
  6783. function shim (obj) {
  6784. var keys = [];
  6785. for (var key in obj) keys.push(key);
  6786. return keys;
  6787. }
  6788. /***/ }),
  6789. /* 53 */
  6790. /***/ (function(module, exports) {
  6791. var supportsArgumentsClass = (function(){
  6792. return Object.prototype.toString.call(arguments)
  6793. })() == '[object Arguments]';
  6794. exports = module.exports = supportsArgumentsClass ? supported : unsupported;
  6795. exports.supported = supported;
  6796. function supported(object) {
  6797. return Object.prototype.toString.call(object) == '[object Arguments]';
  6798. };
  6799. exports.unsupported = unsupported;
  6800. function unsupported(object){
  6801. return object &&
  6802. typeof object == 'object' &&
  6803. typeof object.length == 'number' &&
  6804. Object.prototype.hasOwnProperty.call(object, 'callee') &&
  6805. !Object.prototype.propertyIsEnumerable.call(object, 'callee') ||
  6806. false;
  6807. };
  6808. /***/ }),
  6809. /* 54 */
  6810. /***/ (function(module, exports) {
  6811. 'use strict';
  6812. var has = Object.prototype.hasOwnProperty
  6813. , prefix = '~';
  6814. /**
  6815. * Constructor to create a storage for our `EE` objects.
  6816. * An `Events` instance is a plain object whose properties are event names.
  6817. *
  6818. * @constructor
  6819. * @api private
  6820. */
  6821. function Events() {}
  6822. //
  6823. // We try to not inherit from `Object.prototype`. In some engines creating an
  6824. // instance in this way is faster than calling `Object.create(null)` directly.
  6825. // If `Object.create(null)` is not supported we prefix the event names with a
  6826. // character to make sure that the built-in object properties are not
  6827. // overridden or used as an attack vector.
  6828. //
  6829. if (Object.create) {
  6830. Events.prototype = Object.create(null);
  6831. //
  6832. // This hack is needed because the `__proto__` property is still inherited in
  6833. // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
  6834. //
  6835. if (!new Events().__proto__) prefix = false;
  6836. }
  6837. /**
  6838. * Representation of a single event listener.
  6839. *
  6840. * @param {Function} fn The listener function.
  6841. * @param {Mixed} context The context to invoke the listener with.
  6842. * @param {Boolean} [once=false] Specify if the listener is a one-time listener.
  6843. * @constructor
  6844. * @api private
  6845. */
  6846. function EE(fn, context, once) {
  6847. this.fn = fn;
  6848. this.context = context;
  6849. this.once = once || false;
  6850. }
  6851. /**
  6852. * Minimal `EventEmitter` interface that is molded against the Node.js
  6853. * `EventEmitter` interface.
  6854. *
  6855. * @constructor
  6856. * @api public
  6857. */
  6858. function EventEmitter() {
  6859. this._events = new Events();
  6860. this._eventsCount = 0;
  6861. }
  6862. /**
  6863. * Return an array listing the events for which the emitter has registered
  6864. * listeners.
  6865. *
  6866. * @returns {Array}
  6867. * @api public
  6868. */
  6869. EventEmitter.prototype.eventNames = function eventNames() {
  6870. var names = []
  6871. , events
  6872. , name;
  6873. if (this._eventsCount === 0) return names;
  6874. for (name in (events = this._events)) {
  6875. if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
  6876. }
  6877. if (Object.getOwnPropertySymbols) {
  6878. return names.concat(Object.getOwnPropertySymbols(events));
  6879. }
  6880. return names;
  6881. };
  6882. /**
  6883. * Return the listeners registered for a given event.
  6884. *
  6885. * @param {String|Symbol} event The event name.
  6886. * @param {Boolean} exists Only check if there are listeners.
  6887. * @returns {Array|Boolean}
  6888. * @api public
  6889. */
  6890. EventEmitter.prototype.listeners = function listeners(event, exists) {
  6891. var evt = prefix ? prefix + event : event
  6892. , available = this._events[evt];
  6893. if (exists) return !!available;
  6894. if (!available) return [];
  6895. if (available.fn) return [available.fn];
  6896. for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) {
  6897. ee[i] = available[i].fn;
  6898. }
  6899. return ee;
  6900. };
  6901. /**
  6902. * Calls each of the listeners registered for a given event.
  6903. *
  6904. * @param {String|Symbol} event The event name.
  6905. * @returns {Boolean} `true` if the event had listeners, else `false`.
  6906. * @api public
  6907. */
  6908. EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
  6909. var evt = prefix ? prefix + event : event;
  6910. if (!this._events[evt]) return false;
  6911. var listeners = this._events[evt]
  6912. , len = arguments.length
  6913. , args
  6914. , i;
  6915. if (listeners.fn) {
  6916. if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
  6917. switch (len) {
  6918. case 1: return listeners.fn.call(listeners.context), true;
  6919. case 2: return listeners.fn.call(listeners.context, a1), true;
  6920. case 3: return listeners.fn.call(listeners.context, a1, a2), true;
  6921. case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
  6922. case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
  6923. case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
  6924. }
  6925. for (i = 1, args = new Array(len -1); i < len; i++) {
  6926. args[i - 1] = arguments[i];
  6927. }
  6928. listeners.fn.apply(listeners.context, args);
  6929. } else {
  6930. var length = listeners.length
  6931. , j;
  6932. for (i = 0; i < length; i++) {
  6933. if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
  6934. switch (len) {
  6935. case 1: listeners[i].fn.call(listeners[i].context); break;
  6936. case 2: listeners[i].fn.call(listeners[i].context, a1); break;
  6937. case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
  6938. case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
  6939. default:
  6940. if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
  6941. args[j - 1] = arguments[j];
  6942. }
  6943. listeners[i].fn.apply(listeners[i].context, args);
  6944. }
  6945. }
  6946. }
  6947. return true;
  6948. };
  6949. /**
  6950. * Add a listener for a given event.
  6951. *
  6952. * @param {String|Symbol} event The event name.
  6953. * @param {Function} fn The listener function.
  6954. * @param {Mixed} [context=this] The context to invoke the listener with.
  6955. * @returns {EventEmitter} `this`.
  6956. * @api public
  6957. */
  6958. EventEmitter.prototype.on = function on(event, fn, context) {
  6959. var listener = new EE(fn, context || this)
  6960. , evt = prefix ? prefix + event : event;
  6961. if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
  6962. else if (!this._events[evt].fn) this._events[evt].push(listener);
  6963. else this._events[evt] = [this._events[evt], listener];
  6964. return this;
  6965. };
  6966. /**
  6967. * Add a one-time listener for a given event.
  6968. *
  6969. * @param {String|Symbol} event The event name.
  6970. * @param {Function} fn The listener function.
  6971. * @param {Mixed} [context=this] The context to invoke the listener with.
  6972. * @returns {EventEmitter} `this`.
  6973. * @api public
  6974. */
  6975. EventEmitter.prototype.once = function once(event, fn, context) {
  6976. var listener = new EE(fn, context || this, true)
  6977. , evt = prefix ? prefix + event : event;
  6978. if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
  6979. else if (!this._events[evt].fn) this._events[evt].push(listener);
  6980. else this._events[evt] = [this._events[evt], listener];
  6981. return this;
  6982. };
  6983. /**
  6984. * Remove the listeners of a given event.
  6985. *
  6986. * @param {String|Symbol} event The event name.
  6987. * @param {Function} fn Only remove the listeners that match this function.
  6988. * @param {Mixed} context Only remove the listeners that have this context.
  6989. * @param {Boolean} once Only remove one-time listeners.
  6990. * @returns {EventEmitter} `this`.
  6991. * @api public
  6992. */
  6993. EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
  6994. var evt = prefix ? prefix + event : event;
  6995. if (!this._events[evt]) return this;
  6996. if (!fn) {
  6997. if (--this._eventsCount === 0) this._events = new Events();
  6998. else delete this._events[evt];
  6999. return this;
  7000. }
  7001. var listeners = this._events[evt];
  7002. if (listeners.fn) {
  7003. if (
  7004. listeners.fn === fn
  7005. && (!once || listeners.once)
  7006. && (!context || listeners.context === context)
  7007. ) {
  7008. if (--this._eventsCount === 0) this._events = new Events();
  7009. else delete this._events[evt];
  7010. }
  7011. } else {
  7012. for (var i = 0, events = [], length = listeners.length; i < length; i++) {
  7013. if (
  7014. listeners[i].fn !== fn
  7015. || (once && !listeners[i].once)
  7016. || (context && listeners[i].context !== context)
  7017. ) {
  7018. events.push(listeners[i]);
  7019. }
  7020. }
  7021. //
  7022. // Reset the array, or remove it completely if we have no more listeners.
  7023. //
  7024. if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
  7025. else if (--this._eventsCount === 0) this._events = new Events();
  7026. else delete this._events[evt];
  7027. }
  7028. return this;
  7029. };
  7030. /**
  7031. * Remove all listeners, or those of the specified event.
  7032. *
  7033. * @param {String|Symbol} [event] The event name.
  7034. * @returns {EventEmitter} `this`.
  7035. * @api public
  7036. */
  7037. EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
  7038. var evt;
  7039. if (event) {
  7040. evt = prefix ? prefix + event : event;
  7041. if (this._events[evt]) {
  7042. if (--this._eventsCount === 0) this._events = new Events();
  7043. else delete this._events[evt];
  7044. }
  7045. } else {
  7046. this._events = new Events();
  7047. this._eventsCount = 0;
  7048. }
  7049. return this;
  7050. };
  7051. //
  7052. // Alias methods names because people roll like that.
  7053. //
  7054. EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
  7055. EventEmitter.prototype.addListener = EventEmitter.prototype.on;
  7056. //
  7057. // This function doesn't apply anymore.
  7058. //
  7059. EventEmitter.prototype.setMaxListeners = function setMaxListeners() {
  7060. return this;
  7061. };
  7062. //
  7063. // Expose the prefix.
  7064. //
  7065. EventEmitter.prefixed = prefix;
  7066. //
  7067. // Allow `EventEmitter` to be imported as module namespace.
  7068. //
  7069. EventEmitter.EventEmitter = EventEmitter;
  7070. //
  7071. // Expose the module.
  7072. //
  7073. if ('undefined' !== typeof module) {
  7074. module.exports = EventEmitter;
  7075. }
  7076. /***/ }),
  7077. /* 55 */
  7078. /***/ (function(module, exports, __webpack_require__) {
  7079. "use strict";
  7080. Object.defineProperty(exports, "__esModule", {
  7081. value: true
  7082. });
  7083. exports.matchText = exports.matchSpacing = exports.matchNewline = exports.matchBlot = exports.matchAttributor = exports.default = undefined;
  7084. 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; };
  7085. 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"); } }; }();
  7086. 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; }; }();
  7087. var _extend2 = __webpack_require__(3);
  7088. var _extend3 = _interopRequireDefault(_extend2);
  7089. var _quillDelta = __webpack_require__(2);
  7090. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  7091. var _parchment = __webpack_require__(0);
  7092. var _parchment2 = _interopRequireDefault(_parchment);
  7093. var _quill = __webpack_require__(5);
  7094. var _quill2 = _interopRequireDefault(_quill);
  7095. var _logger = __webpack_require__(10);
  7096. var _logger2 = _interopRequireDefault(_logger);
  7097. var _module = __webpack_require__(9);
  7098. var _module2 = _interopRequireDefault(_module);
  7099. var _align = __webpack_require__(36);
  7100. var _background = __webpack_require__(37);
  7101. var _code = __webpack_require__(13);
  7102. var _code2 = _interopRequireDefault(_code);
  7103. var _color = __webpack_require__(26);
  7104. var _direction = __webpack_require__(38);
  7105. var _font = __webpack_require__(39);
  7106. var _size = __webpack_require__(40);
  7107. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7108. 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; }
  7109. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7110. 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; }
  7111. 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; }
  7112. var debug = (0, _logger2.default)('quill:clipboard');
  7113. var DOM_KEY = '__ql-matcher';
  7114. 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]];
  7115. var ATTRIBUTE_ATTRIBUTORS = [_align.AlignAttribute, _direction.DirectionAttribute].reduce(function (memo, attr) {
  7116. memo[attr.keyName] = attr;
  7117. return memo;
  7118. }, {});
  7119. var STYLE_ATTRIBUTORS = [_align.AlignStyle, _background.BackgroundStyle, _color.ColorStyle, _direction.DirectionStyle, _font.FontStyle, _size.SizeStyle].reduce(function (memo, attr) {
  7120. memo[attr.keyName] = attr;
  7121. return memo;
  7122. }, {});
  7123. var Clipboard = function (_Module) {
  7124. _inherits(Clipboard, _Module);
  7125. function Clipboard(quill, options) {
  7126. _classCallCheck(this, Clipboard);
  7127. var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this, quill, options));
  7128. _this.quill.root.addEventListener('paste', _this.onPaste.bind(_this));
  7129. _this.container = _this.quill.addContainer('ql-clipboard');
  7130. _this.container.setAttribute('contenteditable', true);
  7131. _this.container.setAttribute('tabindex', -1);
  7132. _this.matchers = [];
  7133. CLIPBOARD_CONFIG.concat(_this.options.matchers).forEach(function (_ref) {
  7134. var _ref2 = _slicedToArray(_ref, 2),
  7135. selector = _ref2[0],
  7136. matcher = _ref2[1];
  7137. if (!options.matchVisual && matcher === matchSpacing) return;
  7138. _this.addMatcher(selector, matcher);
  7139. });
  7140. return _this;
  7141. }
  7142. _createClass(Clipboard, [{
  7143. key: 'addMatcher',
  7144. value: function addMatcher(selector, matcher) {
  7145. this.matchers.push([selector, matcher]);
  7146. }
  7147. }, {
  7148. key: 'convert',
  7149. value: function convert(html) {
  7150. if (typeof html === 'string') {
  7151. this.container.innerHTML = html.replace(/\>\r?\n +\</g, '><'); // Remove spaces between tags
  7152. return this.convert();
  7153. }
  7154. var formats = this.quill.getFormat(this.quill.selection.savedRange.index);
  7155. if (formats[_code2.default.blotName]) {
  7156. var text = this.container.innerText;
  7157. this.container.innerHTML = '';
  7158. return new _quillDelta2.default().insert(text, _defineProperty({}, _code2.default.blotName, formats[_code2.default.blotName]));
  7159. }
  7160. var _prepareMatching = this.prepareMatching(),
  7161. _prepareMatching2 = _slicedToArray(_prepareMatching, 2),
  7162. elementMatchers = _prepareMatching2[0],
  7163. textMatchers = _prepareMatching2[1];
  7164. var delta = traverse(this.container, elementMatchers, textMatchers);
  7165. // Remove trailing newline
  7166. if (deltaEndsWith(delta, '\n') && delta.ops[delta.ops.length - 1].attributes == null) {
  7167. delta = delta.compose(new _quillDelta2.default().retain(delta.length() - 1).delete(1));
  7168. }
  7169. debug.log('convert', this.container.innerHTML, delta);
  7170. this.container.innerHTML = '';
  7171. return delta;
  7172. }
  7173. }, {
  7174. key: 'dangerouslyPasteHTML',
  7175. value: function dangerouslyPasteHTML(index, html) {
  7176. var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _quill2.default.sources.API;
  7177. if (typeof index === 'string') {
  7178. this.quill.setContents(this.convert(index), html);
  7179. this.quill.setSelection(0, _quill2.default.sources.SILENT);
  7180. } else {
  7181. var paste = this.convert(html);
  7182. this.quill.updateContents(new _quillDelta2.default().retain(index).concat(paste), source);
  7183. this.quill.setSelection(index + paste.length(), _quill2.default.sources.SILENT);
  7184. }
  7185. }
  7186. }, {
  7187. key: 'onPaste',
  7188. value: function onPaste(e) {
  7189. var _this2 = this;
  7190. if (e.defaultPrevented || !this.quill.isEnabled()) return;
  7191. var range = this.quill.getSelection();
  7192. var delta = new _quillDelta2.default().retain(range.index);
  7193. var scrollTop = this.quill.scrollingContainer.scrollTop;
  7194. this.container.focus();
  7195. this.quill.selection.update(_quill2.default.sources.SILENT);
  7196. setTimeout(function () {
  7197. delta = delta.concat(_this2.convert()).delete(range.length);
  7198. _this2.quill.updateContents(delta, _quill2.default.sources.USER);
  7199. // range.length contributes to delta.length()
  7200. _this2.quill.setSelection(delta.length() - range.length, _quill2.default.sources.SILENT);
  7201. _this2.quill.scrollingContainer.scrollTop = scrollTop;
  7202. _this2.quill.focus();
  7203. }, 1);
  7204. }
  7205. }, {
  7206. key: 'prepareMatching',
  7207. value: function prepareMatching() {
  7208. var _this3 = this;
  7209. var elementMatchers = [],
  7210. textMatchers = [];
  7211. this.matchers.forEach(function (pair) {
  7212. var _pair = _slicedToArray(pair, 2),
  7213. selector = _pair[0],
  7214. matcher = _pair[1];
  7215. switch (selector) {
  7216. case Node.TEXT_NODE:
  7217. textMatchers.push(matcher);
  7218. break;
  7219. case Node.ELEMENT_NODE:
  7220. elementMatchers.push(matcher);
  7221. break;
  7222. default:
  7223. [].forEach.call(_this3.container.querySelectorAll(selector), function (node) {
  7224. // TODO use weakmap
  7225. node[DOM_KEY] = node[DOM_KEY] || [];
  7226. node[DOM_KEY].push(matcher);
  7227. });
  7228. break;
  7229. }
  7230. });
  7231. return [elementMatchers, textMatchers];
  7232. }
  7233. }]);
  7234. return Clipboard;
  7235. }(_module2.default);
  7236. Clipboard.DEFAULTS = {
  7237. matchers: [],
  7238. matchVisual: true
  7239. };
  7240. function applyFormat(delta, format, value) {
  7241. if ((typeof format === 'undefined' ? 'undefined' : _typeof(format)) === 'object') {
  7242. return Object.keys(format).reduce(function (delta, key) {
  7243. return applyFormat(delta, key, format[key]);
  7244. }, delta);
  7245. } else {
  7246. return delta.reduce(function (delta, op) {
  7247. if (op.attributes && op.attributes[format]) {
  7248. return delta.push(op);
  7249. } else {
  7250. return delta.insert(op.insert, (0, _extend3.default)({}, _defineProperty({}, format, value), op.attributes));
  7251. }
  7252. }, new _quillDelta2.default());
  7253. }
  7254. }
  7255. function computeStyle(node) {
  7256. if (node.nodeType !== Node.ELEMENT_NODE) return {};
  7257. var DOM_KEY = '__ql-computed-style';
  7258. return node[DOM_KEY] || (node[DOM_KEY] = window.getComputedStyle(node));
  7259. }
  7260. function deltaEndsWith(delta, text) {
  7261. var endText = "";
  7262. for (var i = delta.ops.length - 1; i >= 0 && endText.length < text.length; --i) {
  7263. var op = delta.ops[i];
  7264. if (typeof op.insert !== 'string') break;
  7265. endText = op.insert + endText;
  7266. }
  7267. return endText.slice(-1 * text.length) === text;
  7268. }
  7269. function isLine(node) {
  7270. if (node.childNodes.length === 0) return false; // Exclude embed blocks
  7271. var style = computeStyle(node);
  7272. return ['block', 'list-item'].indexOf(style.display) > -1;
  7273. }
  7274. function traverse(node, elementMatchers, textMatchers) {
  7275. // Post-order
  7276. if (node.nodeType === node.TEXT_NODE) {
  7277. return textMatchers.reduce(function (delta, matcher) {
  7278. return matcher(node, delta);
  7279. }, new _quillDelta2.default());
  7280. } else if (node.nodeType === node.ELEMENT_NODE) {
  7281. return [].reduce.call(node.childNodes || [], function (delta, childNode) {
  7282. var childrenDelta = traverse(childNode, elementMatchers, textMatchers);
  7283. if (childNode.nodeType === node.ELEMENT_NODE) {
  7284. childrenDelta = elementMatchers.reduce(function (childrenDelta, matcher) {
  7285. return matcher(childNode, childrenDelta);
  7286. }, childrenDelta);
  7287. childrenDelta = (childNode[DOM_KEY] || []).reduce(function (childrenDelta, matcher) {
  7288. return matcher(childNode, childrenDelta);
  7289. }, childrenDelta);
  7290. }
  7291. return delta.concat(childrenDelta);
  7292. }, new _quillDelta2.default());
  7293. } else {
  7294. return new _quillDelta2.default();
  7295. }
  7296. }
  7297. function matchAlias(format, node, delta) {
  7298. return applyFormat(delta, format, true);
  7299. }
  7300. function matchAttributor(node, delta) {
  7301. var attributes = _parchment2.default.Attributor.Attribute.keys(node);
  7302. var classes = _parchment2.default.Attributor.Class.keys(node);
  7303. var styles = _parchment2.default.Attributor.Style.keys(node);
  7304. var formats = {};
  7305. attributes.concat(classes).concat(styles).forEach(function (name) {
  7306. var attr = _parchment2.default.query(name, _parchment2.default.Scope.ATTRIBUTE);
  7307. if (attr != null) {
  7308. formats[attr.attrName] = attr.value(node);
  7309. if (formats[attr.attrName]) return;
  7310. }
  7311. attr = ATTRIBUTE_ATTRIBUTORS[name];
  7312. if (attr != null && (attr.attrName === name || attr.keyName === name)) {
  7313. formats[attr.attrName] = attr.value(node) || undefined;
  7314. }
  7315. attr = STYLE_ATTRIBUTORS[name];
  7316. if (attr != null && (attr.attrName === name || attr.keyName === name)) {
  7317. attr = STYLE_ATTRIBUTORS[name];
  7318. formats[attr.attrName] = attr.value(node) || undefined;
  7319. }
  7320. });
  7321. if (Object.keys(formats).length > 0) {
  7322. delta = applyFormat(delta, formats);
  7323. }
  7324. return delta;
  7325. }
  7326. function matchBlot(node, delta) {
  7327. var match = _parchment2.default.query(node);
  7328. if (match == null) return delta;
  7329. if (match.prototype instanceof _parchment2.default.Embed) {
  7330. var embed = {};
  7331. var value = match.value(node);
  7332. if (value != null) {
  7333. embed[match.blotName] = value;
  7334. delta = new _quillDelta2.default().insert(embed, match.formats(node));
  7335. }
  7336. } else if (typeof match.formats === 'function') {
  7337. delta = applyFormat(delta, match.blotName, match.formats(node));
  7338. }
  7339. return delta;
  7340. }
  7341. function matchBreak(node, delta) {
  7342. if (!deltaEndsWith(delta, '\n')) {
  7343. delta.insert('\n');
  7344. }
  7345. return delta;
  7346. }
  7347. function matchIgnore() {
  7348. return new _quillDelta2.default();
  7349. }
  7350. function matchIndent(node, delta) {
  7351. var match = _parchment2.default.query(node);
  7352. if (match == null || match.blotName !== 'list-item' || !deltaEndsWith(delta, '\n')) {
  7353. return delta;
  7354. }
  7355. var indent = -1,
  7356. parent = node.parentNode;
  7357. while (!parent.classList.contains('ql-clipboard')) {
  7358. if ((_parchment2.default.query(parent) || {}).blotName === 'list') {
  7359. indent += 1;
  7360. }
  7361. parent = parent.parentNode;
  7362. }
  7363. if (indent <= 0) return delta;
  7364. return delta.compose(new _quillDelta2.default().retain(delta.length() - 1).retain(1, { indent: indent }));
  7365. }
  7366. function matchNewline(node, delta) {
  7367. if (!deltaEndsWith(delta, '\n')) {
  7368. if (isLine(node) || delta.length() > 0 && node.nextSibling && isLine(node.nextSibling)) {
  7369. delta.insert('\n');
  7370. }
  7371. }
  7372. return delta;
  7373. }
  7374. function matchSpacing(node, delta) {
  7375. if (isLine(node) && node.nextElementSibling != null && !deltaEndsWith(delta, '\n\n')) {
  7376. var nodeHeight = node.offsetHeight + parseFloat(computeStyle(node).marginTop) + parseFloat(computeStyle(node).marginBottom);
  7377. if (node.nextElementSibling.offsetTop > node.offsetTop + nodeHeight * 1.5) {
  7378. delta.insert('\n');
  7379. }
  7380. }
  7381. return delta;
  7382. }
  7383. function matchStyles(node, delta) {
  7384. var formats = {};
  7385. var style = node.style || {};
  7386. if (style.fontStyle && computeStyle(node).fontStyle === 'italic') {
  7387. formats.italic = true;
  7388. }
  7389. if (style.fontWeight && (computeStyle(node).fontWeight.startsWith('bold') || parseInt(computeStyle(node).fontWeight) >= 700)) {
  7390. formats.bold = true;
  7391. }
  7392. if (Object.keys(formats).length > 0) {
  7393. delta = applyFormat(delta, formats);
  7394. }
  7395. if (parseFloat(style.textIndent || 0) > 0) {
  7396. // Could be 0.5in
  7397. delta = new _quillDelta2.default().insert('\t').concat(delta);
  7398. }
  7399. return delta;
  7400. }
  7401. function matchText(node, delta) {
  7402. var text = node.data;
  7403. // Word represents empty line with <o:p>&nbsp;</o:p>
  7404. if (node.parentNode.tagName === 'O:P') {
  7405. return delta.insert(text.trim());
  7406. }
  7407. if (text.trim().length === 0 && node.parentNode.classList.contains('ql-clipboard')) {
  7408. return delta;
  7409. }
  7410. if (!computeStyle(node.parentNode).whiteSpace.startsWith('pre')) {
  7411. // eslint-disable-next-line func-style
  7412. var replacer = function replacer(collapse, match) {
  7413. match = match.replace(/[^\u00a0]/g, ''); // \u00a0 is nbsp;
  7414. return match.length < 1 && collapse ? ' ' : match;
  7415. };
  7416. text = text.replace(/\r\n/g, ' ').replace(/\n/g, ' ');
  7417. text = text.replace(/\s\s+/g, replacer.bind(replacer, true)); // collapse whitespace
  7418. if (node.previousSibling == null && isLine(node.parentNode) || node.previousSibling != null && isLine(node.previousSibling)) {
  7419. text = text.replace(/^\s+/, replacer.bind(replacer, false));
  7420. }
  7421. if (node.nextSibling == null && isLine(node.parentNode) || node.nextSibling != null && isLine(node.nextSibling)) {
  7422. text = text.replace(/\s+$/, replacer.bind(replacer, false));
  7423. }
  7424. }
  7425. return delta.insert(text);
  7426. }
  7427. exports.default = Clipboard;
  7428. exports.matchAttributor = matchAttributor;
  7429. exports.matchBlot = matchBlot;
  7430. exports.matchNewline = matchNewline;
  7431. exports.matchSpacing = matchSpacing;
  7432. exports.matchText = matchText;
  7433. /***/ }),
  7434. /* 56 */,
  7435. /* 57 */,
  7436. /* 58 */,
  7437. /* 59 */,
  7438. /* 60 */,
  7439. /* 61 */,
  7440. /* 62 */,
  7441. /* 63 */,
  7442. /* 64 */,
  7443. /* 65 */,
  7444. /* 66 */,
  7445. /* 67 */,
  7446. /* 68 */,
  7447. /* 69 */,
  7448. /* 70 */,
  7449. /* 71 */,
  7450. /* 72 */,
  7451. /* 73 */,
  7452. /* 74 */,
  7453. /* 75 */,
  7454. /* 76 */,
  7455. /* 77 */,
  7456. /* 78 */,
  7457. /* 79 */,
  7458. /* 80 */,
  7459. /* 81 */,
  7460. /* 82 */,
  7461. /* 83 */,
  7462. /* 84 */,
  7463. /* 85 */,
  7464. /* 86 */,
  7465. /* 87 */,
  7466. /* 88 */,
  7467. /* 89 */,
  7468. /* 90 */,
  7469. /* 91 */,
  7470. /* 92 */,
  7471. /* 93 */,
  7472. /* 94 */,
  7473. /* 95 */,
  7474. /* 96 */,
  7475. /* 97 */,
  7476. /* 98 */,
  7477. /* 99 */,
  7478. /* 100 */,
  7479. /* 101 */,
  7480. /* 102 */,
  7481. /* 103 */,
  7482. /* 104 */,
  7483. /* 105 */,
  7484. /* 106 */,
  7485. /* 107 */,
  7486. /* 108 */,
  7487. /* 109 */,
  7488. /* 110 */
  7489. /***/ (function(module, exports, __webpack_require__) {
  7490. module.exports = __webpack_require__(29);
  7491. /***/ })
  7492. /******/ ])["default"];
  7493. });