quill.core.js 297 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522
  1. /*!
  2. * Quill Editor v1.3.6
  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 delta = new Delta();
  414. while (thisIter.hasNext() || otherIter.hasNext()) {
  415. if (otherIter.peekType() === 'insert') {
  416. delta.push(otherIter.next());
  417. } else if (thisIter.peekType() === 'delete') {
  418. delta.push(thisIter.next());
  419. } else {
  420. var length = Math.min(thisIter.peekLength(), otherIter.peekLength());
  421. var thisOp = thisIter.next(length);
  422. var otherOp = otherIter.next(length);
  423. if (typeof otherOp.retain === 'number') {
  424. var newOp = {};
  425. if (typeof thisOp.retain === 'number') {
  426. newOp.retain = length;
  427. } else {
  428. newOp.insert = thisOp.insert;
  429. }
  430. // Preserve null when composing with a retain, otherwise remove it for inserts
  431. var attributes = op.attributes.compose(thisOp.attributes, otherOp.attributes, typeof thisOp.retain === 'number');
  432. if (attributes) newOp.attributes = attributes;
  433. delta.push(newOp);
  434. // Other op should be delete, we could be an insert or retain
  435. // Insert + delete cancels out
  436. } else if (typeof otherOp['delete'] === 'number' && typeof thisOp.retain === 'number') {
  437. delta.push(otherOp);
  438. }
  439. }
  440. }
  441. return delta.chop();
  442. };
  443. Delta.prototype.concat = function (other) {
  444. var delta = new Delta(this.ops.slice());
  445. if (other.ops.length > 0) {
  446. delta.push(other.ops[0]);
  447. delta.ops = delta.ops.concat(other.ops.slice(1));
  448. }
  449. return delta;
  450. };
  451. Delta.prototype.diff = function (other, index) {
  452. if (this.ops === other.ops) {
  453. return new Delta();
  454. }
  455. var strings = [this, other].map(function (delta) {
  456. return delta.map(function (op) {
  457. if (op.insert != null) {
  458. return typeof op.insert === 'string' ? op.insert : NULL_CHARACTER;
  459. }
  460. var prep = (delta === other) ? 'on' : 'with';
  461. throw new Error('diff() called ' + prep + ' non-document');
  462. }).join('');
  463. });
  464. var delta = new Delta();
  465. var diffResult = diff(strings[0], strings[1], index);
  466. var thisIter = op.iterator(this.ops);
  467. var otherIter = op.iterator(other.ops);
  468. diffResult.forEach(function (component) {
  469. var length = component[1].length;
  470. while (length > 0) {
  471. var opLength = 0;
  472. switch (component[0]) {
  473. case diff.INSERT:
  474. opLength = Math.min(otherIter.peekLength(), length);
  475. delta.push(otherIter.next(opLength));
  476. break;
  477. case diff.DELETE:
  478. opLength = Math.min(length, thisIter.peekLength());
  479. thisIter.next(opLength);
  480. delta['delete'](opLength);
  481. break;
  482. case diff.EQUAL:
  483. opLength = Math.min(thisIter.peekLength(), otherIter.peekLength(), length);
  484. var thisOp = thisIter.next(opLength);
  485. var otherOp = otherIter.next(opLength);
  486. if (equal(thisOp.insert, otherOp.insert)) {
  487. delta.retain(opLength, op.attributes.diff(thisOp.attributes, otherOp.attributes));
  488. } else {
  489. delta.push(otherOp)['delete'](opLength);
  490. }
  491. break;
  492. }
  493. length -= opLength;
  494. }
  495. });
  496. return delta.chop();
  497. };
  498. Delta.prototype.eachLine = function (predicate, newline) {
  499. newline = newline || '\n';
  500. var iter = op.iterator(this.ops);
  501. var line = new Delta();
  502. var i = 0;
  503. while (iter.hasNext()) {
  504. if (iter.peekType() !== 'insert') return;
  505. var thisOp = iter.peek();
  506. var start = op.length(thisOp) - iter.peekLength();
  507. var index = typeof thisOp.insert === 'string' ?
  508. thisOp.insert.indexOf(newline, start) - start : -1;
  509. if (index < 0) {
  510. line.push(iter.next());
  511. } else if (index > 0) {
  512. line.push(iter.next(index));
  513. } else {
  514. if (predicate(line, iter.next(1).attributes || {}, i) === false) {
  515. return;
  516. }
  517. i += 1;
  518. line = new Delta();
  519. }
  520. }
  521. if (line.length() > 0) {
  522. predicate(line, {}, i);
  523. }
  524. };
  525. Delta.prototype.transform = function (other, priority) {
  526. priority = !!priority;
  527. if (typeof other === 'number') {
  528. return this.transformPosition(other, priority);
  529. }
  530. var thisIter = op.iterator(this.ops);
  531. var otherIter = op.iterator(other.ops);
  532. var delta = new Delta();
  533. while (thisIter.hasNext() || otherIter.hasNext()) {
  534. if (thisIter.peekType() === 'insert' && (priority || otherIter.peekType() !== 'insert')) {
  535. delta.retain(op.length(thisIter.next()));
  536. } else if (otherIter.peekType() === 'insert') {
  537. delta.push(otherIter.next());
  538. } else {
  539. var length = Math.min(thisIter.peekLength(), otherIter.peekLength());
  540. var thisOp = thisIter.next(length);
  541. var otherOp = otherIter.next(length);
  542. if (thisOp['delete']) {
  543. // Our delete either makes their delete redundant or removes their retain
  544. continue;
  545. } else if (otherOp['delete']) {
  546. delta.push(otherOp);
  547. } else {
  548. // We retain either their retain or insert
  549. delta.retain(length, op.attributes.transform(thisOp.attributes, otherOp.attributes, priority));
  550. }
  551. }
  552. }
  553. return delta.chop();
  554. };
  555. Delta.prototype.transformPosition = function (index, priority) {
  556. priority = !!priority;
  557. var thisIter = op.iterator(this.ops);
  558. var offset = 0;
  559. while (thisIter.hasNext() && offset <= index) {
  560. var length = thisIter.peekLength();
  561. var nextType = thisIter.peekType();
  562. thisIter.next();
  563. if (nextType === 'delete') {
  564. index -= Math.min(length, index - offset);
  565. continue;
  566. } else if (nextType === 'insert' && (offset < index || !priority)) {
  567. index += length;
  568. }
  569. offset += length;
  570. }
  571. return index;
  572. };
  573. module.exports = Delta;
  574. /***/ }),
  575. /* 3 */
  576. /***/ (function(module, exports) {
  577. 'use strict';
  578. var hasOwn = Object.prototype.hasOwnProperty;
  579. var toStr = Object.prototype.toString;
  580. var isArray = function isArray(arr) {
  581. if (typeof Array.isArray === 'function') {
  582. return Array.isArray(arr);
  583. }
  584. return toStr.call(arr) === '[object Array]';
  585. };
  586. var isPlainObject = function isPlainObject(obj) {
  587. if (!obj || toStr.call(obj) !== '[object Object]') {
  588. return false;
  589. }
  590. var hasOwnConstructor = hasOwn.call(obj, 'constructor');
  591. var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
  592. // Not own constructor property must be Object
  593. if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
  594. return false;
  595. }
  596. // Own properties are enumerated firstly, so to speed up,
  597. // if last one is own, then all properties are own.
  598. var key;
  599. for (key in obj) { /**/ }
  600. return typeof key === 'undefined' || hasOwn.call(obj, key);
  601. };
  602. module.exports = function extend() {
  603. var options, name, src, copy, copyIsArray, clone;
  604. var target = arguments[0];
  605. var i = 1;
  606. var length = arguments.length;
  607. var deep = false;
  608. // Handle a deep copy situation
  609. if (typeof target === 'boolean') {
  610. deep = target;
  611. target = arguments[1] || {};
  612. // skip the boolean and the target
  613. i = 2;
  614. }
  615. if (target == null || (typeof target !== 'object' && typeof target !== 'function')) {
  616. target = {};
  617. }
  618. for (; i < length; ++i) {
  619. options = arguments[i];
  620. // Only deal with non-null/undefined values
  621. if (options != null) {
  622. // Extend the base object
  623. for (name in options) {
  624. src = target[name];
  625. copy = options[name];
  626. // Prevent never-ending loop
  627. if (target !== copy) {
  628. // Recurse if we're merging plain objects or arrays
  629. if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
  630. if (copyIsArray) {
  631. copyIsArray = false;
  632. clone = src && isArray(src) ? src : [];
  633. } else {
  634. clone = src && isPlainObject(src) ? src : {};
  635. }
  636. // Never move original objects, clone them
  637. target[name] = extend(deep, clone, copy);
  638. // Don't bring in undefined values
  639. } else if (typeof copy !== 'undefined') {
  640. target[name] = copy;
  641. }
  642. }
  643. }
  644. }
  645. }
  646. // Return the modified object
  647. return target;
  648. };
  649. /***/ }),
  650. /* 4 */
  651. /***/ (function(module, exports, __webpack_require__) {
  652. "use strict";
  653. Object.defineProperty(exports, "__esModule", {
  654. value: true
  655. });
  656. exports.default = exports.BlockEmbed = exports.bubbleFormats = undefined;
  657. 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; }; }();
  658. 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); } };
  659. var _extend = __webpack_require__(3);
  660. var _extend2 = _interopRequireDefault(_extend);
  661. var _quillDelta = __webpack_require__(2);
  662. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  663. var _parchment = __webpack_require__(0);
  664. var _parchment2 = _interopRequireDefault(_parchment);
  665. var _break = __webpack_require__(16);
  666. var _break2 = _interopRequireDefault(_break);
  667. var _inline = __webpack_require__(6);
  668. var _inline2 = _interopRequireDefault(_inline);
  669. var _text = __webpack_require__(7);
  670. var _text2 = _interopRequireDefault(_text);
  671. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  672. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  673. 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; }
  674. 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; }
  675. var NEWLINE_LENGTH = 1;
  676. var BlockEmbed = function (_Parchment$Embed) {
  677. _inherits(BlockEmbed, _Parchment$Embed);
  678. function BlockEmbed() {
  679. _classCallCheck(this, BlockEmbed);
  680. return _possibleConstructorReturn(this, (BlockEmbed.__proto__ || Object.getPrototypeOf(BlockEmbed)).apply(this, arguments));
  681. }
  682. _createClass(BlockEmbed, [{
  683. key: 'attach',
  684. value: function attach() {
  685. _get(BlockEmbed.prototype.__proto__ || Object.getPrototypeOf(BlockEmbed.prototype), 'attach', this).call(this);
  686. this.attributes = new _parchment2.default.Attributor.Store(this.domNode);
  687. }
  688. }, {
  689. key: 'delta',
  690. value: function delta() {
  691. return new _quillDelta2.default().insert(this.value(), (0, _extend2.default)(this.formats(), this.attributes.values()));
  692. }
  693. }, {
  694. key: 'format',
  695. value: function format(name, value) {
  696. var attribute = _parchment2.default.query(name, _parchment2.default.Scope.BLOCK_ATTRIBUTE);
  697. if (attribute != null) {
  698. this.attributes.attribute(attribute, value);
  699. }
  700. }
  701. }, {
  702. key: 'formatAt',
  703. value: function formatAt(index, length, name, value) {
  704. this.format(name, value);
  705. }
  706. }, {
  707. key: 'insertAt',
  708. value: function insertAt(index, value, def) {
  709. if (typeof value === 'string' && value.endsWith('\n')) {
  710. var block = _parchment2.default.create(Block.blotName);
  711. this.parent.insertBefore(block, index === 0 ? this : this.next);
  712. block.insertAt(0, value.slice(0, -1));
  713. } else {
  714. _get(BlockEmbed.prototype.__proto__ || Object.getPrototypeOf(BlockEmbed.prototype), 'insertAt', this).call(this, index, value, def);
  715. }
  716. }
  717. }]);
  718. return BlockEmbed;
  719. }(_parchment2.default.Embed);
  720. BlockEmbed.scope = _parchment2.default.Scope.BLOCK_BLOT;
  721. // It is important for cursor behavior BlockEmbeds use tags that are block level elements
  722. var Block = function (_Parchment$Block) {
  723. _inherits(Block, _Parchment$Block);
  724. function Block(domNode) {
  725. _classCallCheck(this, Block);
  726. var _this2 = _possibleConstructorReturn(this, (Block.__proto__ || Object.getPrototypeOf(Block)).call(this, domNode));
  727. _this2.cache = {};
  728. return _this2;
  729. }
  730. _createClass(Block, [{
  731. key: 'delta',
  732. value: function delta() {
  733. if (this.cache.delta == null) {
  734. this.cache.delta = this.descendants(_parchment2.default.Leaf).reduce(function (delta, leaf) {
  735. if (leaf.length() === 0) {
  736. return delta;
  737. } else {
  738. return delta.insert(leaf.value(), bubbleFormats(leaf));
  739. }
  740. }, new _quillDelta2.default()).insert('\n', bubbleFormats(this));
  741. }
  742. return this.cache.delta;
  743. }
  744. }, {
  745. key: 'deleteAt',
  746. value: function deleteAt(index, length) {
  747. _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'deleteAt', this).call(this, index, length);
  748. this.cache = {};
  749. }
  750. }, {
  751. key: 'formatAt',
  752. value: function formatAt(index, length, name, value) {
  753. if (length <= 0) return;
  754. if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK)) {
  755. if (index + length === this.length()) {
  756. this.format(name, value);
  757. }
  758. } else {
  759. _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'formatAt', this).call(this, index, Math.min(length, this.length() - index - 1), name, value);
  760. }
  761. this.cache = {};
  762. }
  763. }, {
  764. key: 'insertAt',
  765. value: function insertAt(index, value, def) {
  766. if (def != null) return _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'insertAt', this).call(this, index, value, def);
  767. if (value.length === 0) return;
  768. var lines = value.split('\n');
  769. var text = lines.shift();
  770. if (text.length > 0) {
  771. if (index < this.length() - 1 || this.children.tail == null) {
  772. _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'insertAt', this).call(this, Math.min(index, this.length() - 1), text);
  773. } else {
  774. this.children.tail.insertAt(this.children.tail.length(), text);
  775. }
  776. this.cache = {};
  777. }
  778. var block = this;
  779. lines.reduce(function (index, line) {
  780. block = block.split(index, true);
  781. block.insertAt(0, line);
  782. return line.length;
  783. }, index + text.length);
  784. }
  785. }, {
  786. key: 'insertBefore',
  787. value: function insertBefore(blot, ref) {
  788. var head = this.children.head;
  789. _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'insertBefore', this).call(this, blot, ref);
  790. if (head instanceof _break2.default) {
  791. head.remove();
  792. }
  793. this.cache = {};
  794. }
  795. }, {
  796. key: 'length',
  797. value: function length() {
  798. if (this.cache.length == null) {
  799. this.cache.length = _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'length', this).call(this) + NEWLINE_LENGTH;
  800. }
  801. return this.cache.length;
  802. }
  803. }, {
  804. key: 'moveChildren',
  805. value: function moveChildren(target, ref) {
  806. _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'moveChildren', this).call(this, target, ref);
  807. this.cache = {};
  808. }
  809. }, {
  810. key: 'optimize',
  811. value: function optimize(context) {
  812. _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'optimize', this).call(this, context);
  813. this.cache = {};
  814. }
  815. }, {
  816. key: 'path',
  817. value: function path(index) {
  818. return _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'path', this).call(this, index, true);
  819. }
  820. }, {
  821. key: 'removeChild',
  822. value: function removeChild(child) {
  823. _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'removeChild', this).call(this, child);
  824. this.cache = {};
  825. }
  826. }, {
  827. key: 'split',
  828. value: function split(index) {
  829. var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  830. if (force && (index === 0 || index >= this.length() - NEWLINE_LENGTH)) {
  831. var clone = this.clone();
  832. if (index === 0) {
  833. this.parent.insertBefore(clone, this);
  834. return this;
  835. } else {
  836. this.parent.insertBefore(clone, this.next);
  837. return clone;
  838. }
  839. } else {
  840. var next = _get(Block.prototype.__proto__ || Object.getPrototypeOf(Block.prototype), 'split', this).call(this, index, force);
  841. this.cache = {};
  842. return next;
  843. }
  844. }
  845. }]);
  846. return Block;
  847. }(_parchment2.default.Block);
  848. Block.blotName = 'block';
  849. Block.tagName = 'P';
  850. Block.defaultChild = 'break';
  851. Block.allowedChildren = [_inline2.default, _parchment2.default.Embed, _text2.default];
  852. function bubbleFormats(blot) {
  853. var formats = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  854. if (blot == null) return formats;
  855. if (typeof blot.formats === 'function') {
  856. formats = (0, _extend2.default)(formats, blot.formats());
  857. }
  858. if (blot.parent == null || blot.parent.blotName == 'scroll' || blot.parent.statics.scope !== blot.statics.scope) {
  859. return formats;
  860. }
  861. return bubbleFormats(blot.parent, formats);
  862. }
  863. exports.bubbleFormats = bubbleFormats;
  864. exports.BlockEmbed = BlockEmbed;
  865. exports.default = Block;
  866. /***/ }),
  867. /* 5 */
  868. /***/ (function(module, exports, __webpack_require__) {
  869. "use strict";
  870. Object.defineProperty(exports, "__esModule", {
  871. value: true
  872. });
  873. exports.default = exports.overload = exports.expandConfig = undefined;
  874. 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; };
  875. 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"); } }; }();
  876. 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; }; }();
  877. __webpack_require__(50);
  878. var _quillDelta = __webpack_require__(2);
  879. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  880. var _editor = __webpack_require__(14);
  881. var _editor2 = _interopRequireDefault(_editor);
  882. var _emitter3 = __webpack_require__(8);
  883. var _emitter4 = _interopRequireDefault(_emitter3);
  884. var _module = __webpack_require__(9);
  885. var _module2 = _interopRequireDefault(_module);
  886. var _parchment = __webpack_require__(0);
  887. var _parchment2 = _interopRequireDefault(_parchment);
  888. var _selection = __webpack_require__(15);
  889. var _selection2 = _interopRequireDefault(_selection);
  890. var _extend = __webpack_require__(3);
  891. var _extend2 = _interopRequireDefault(_extend);
  892. var _logger = __webpack_require__(10);
  893. var _logger2 = _interopRequireDefault(_logger);
  894. var _theme = __webpack_require__(34);
  895. var _theme2 = _interopRequireDefault(_theme);
  896. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  897. 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; }
  898. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  899. var debug = (0, _logger2.default)('quill');
  900. var Quill = function () {
  901. _createClass(Quill, null, [{
  902. key: 'debug',
  903. value: function debug(limit) {
  904. if (limit === true) {
  905. limit = 'log';
  906. }
  907. _logger2.default.level(limit);
  908. }
  909. }, {
  910. key: 'find',
  911. value: function find(node) {
  912. return node.__quill || _parchment2.default.find(node);
  913. }
  914. }, {
  915. key: 'import',
  916. value: function _import(name) {
  917. if (this.imports[name] == null) {
  918. debug.error('Cannot import ' + name + '. Are you sure it was registered?');
  919. }
  920. return this.imports[name];
  921. }
  922. }, {
  923. key: 'register',
  924. value: function register(path, target) {
  925. var _this = this;
  926. var overwrite = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  927. if (typeof path !== 'string') {
  928. var name = path.attrName || path.blotName;
  929. if (typeof name === 'string') {
  930. // register(Blot | Attributor, overwrite)
  931. this.register('formats/' + name, path, target);
  932. } else {
  933. Object.keys(path).forEach(function (key) {
  934. _this.register(key, path[key], target);
  935. });
  936. }
  937. } else {
  938. if (this.imports[path] != null && !overwrite) {
  939. debug.warn('Overwriting ' + path + ' with', target);
  940. }
  941. this.imports[path] = target;
  942. if ((path.startsWith('blots/') || path.startsWith('formats/')) && target.blotName !== 'abstract') {
  943. _parchment2.default.register(target);
  944. } else if (path.startsWith('modules') && typeof target.register === 'function') {
  945. target.register();
  946. }
  947. }
  948. }
  949. }]);
  950. function Quill(container) {
  951. var _this2 = this;
  952. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  953. _classCallCheck(this, Quill);
  954. this.options = expandConfig(container, options);
  955. this.container = this.options.container;
  956. if (this.container == null) {
  957. return debug.error('Invalid Quill container', container);
  958. }
  959. if (this.options.debug) {
  960. Quill.debug(this.options.debug);
  961. }
  962. var html = this.container.innerHTML.trim();
  963. this.container.classList.add('ql-container');
  964. this.container.innerHTML = '';
  965. this.container.__quill = this;
  966. this.root = this.addContainer('ql-editor');
  967. this.root.classList.add('ql-blank');
  968. this.root.setAttribute('data-gramm', false);
  969. this.scrollingContainer = this.options.scrollingContainer || this.root;
  970. this.emitter = new _emitter4.default();
  971. this.scroll = _parchment2.default.create(this.root, {
  972. emitter: this.emitter,
  973. whitelist: this.options.formats
  974. });
  975. this.editor = new _editor2.default(this.scroll);
  976. this.selection = new _selection2.default(this.scroll, this.emitter);
  977. this.theme = new this.options.theme(this, this.options);
  978. this.keyboard = this.theme.addModule('keyboard');
  979. this.clipboard = this.theme.addModule('clipboard');
  980. this.history = this.theme.addModule('history');
  981. this.theme.init();
  982. this.emitter.on(_emitter4.default.events.EDITOR_CHANGE, function (type) {
  983. if (type === _emitter4.default.events.TEXT_CHANGE) {
  984. _this2.root.classList.toggle('ql-blank', _this2.editor.isBlank());
  985. }
  986. });
  987. this.emitter.on(_emitter4.default.events.SCROLL_UPDATE, function (source, mutations) {
  988. var range = _this2.selection.lastRange;
  989. var index = range && range.length === 0 ? range.index : undefined;
  990. modify.call(_this2, function () {
  991. return _this2.editor.update(null, mutations, index);
  992. }, source);
  993. });
  994. var contents = this.clipboard.convert('<div class=\'ql-editor\' style="white-space: normal;">' + html + '<p><br></p></div>');
  995. this.setContents(contents);
  996. this.history.clear();
  997. if (this.options.placeholder) {
  998. this.root.setAttribute('data-placeholder', this.options.placeholder);
  999. }
  1000. if (this.options.readOnly) {
  1001. this.disable();
  1002. }
  1003. }
  1004. _createClass(Quill, [{
  1005. key: 'addContainer',
  1006. value: function addContainer(container) {
  1007. var refNode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1008. if (typeof container === 'string') {
  1009. var className = container;
  1010. container = document.createElement('div');
  1011. container.classList.add(className);
  1012. }
  1013. this.container.insertBefore(container, refNode);
  1014. return container;
  1015. }
  1016. }, {
  1017. key: 'blur',
  1018. value: function blur() {
  1019. this.selection.setRange(null);
  1020. }
  1021. }, {
  1022. key: 'deleteText',
  1023. value: function deleteText(index, length, source) {
  1024. var _this3 = this;
  1025. var _overload = overload(index, length, source);
  1026. var _overload2 = _slicedToArray(_overload, 4);
  1027. index = _overload2[0];
  1028. length = _overload2[1];
  1029. source = _overload2[3];
  1030. return modify.call(this, function () {
  1031. return _this3.editor.deleteText(index, length);
  1032. }, source, index, -1 * length);
  1033. }
  1034. }, {
  1035. key: 'disable',
  1036. value: function disable() {
  1037. this.enable(false);
  1038. }
  1039. }, {
  1040. key: 'enable',
  1041. value: function enable() {
  1042. var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  1043. this.scroll.enable(enabled);
  1044. this.container.classList.toggle('ql-disabled', !enabled);
  1045. }
  1046. }, {
  1047. key: 'focus',
  1048. value: function focus() {
  1049. var scrollTop = this.scrollingContainer.scrollTop;
  1050. this.selection.focus();
  1051. this.scrollingContainer.scrollTop = scrollTop;
  1052. this.scrollIntoView();
  1053. }
  1054. }, {
  1055. key: 'format',
  1056. value: function format(name, value) {
  1057. var _this4 = this;
  1058. var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _emitter4.default.sources.API;
  1059. return modify.call(this, function () {
  1060. var range = _this4.getSelection(true);
  1061. var change = new _quillDelta2.default();
  1062. if (range == null) {
  1063. return change;
  1064. } else if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK)) {
  1065. change = _this4.editor.formatLine(range.index, range.length, _defineProperty({}, name, value));
  1066. } else if (range.length === 0) {
  1067. _this4.selection.format(name, value);
  1068. return change;
  1069. } else {
  1070. change = _this4.editor.formatText(range.index, range.length, _defineProperty({}, name, value));
  1071. }
  1072. _this4.setSelection(range, _emitter4.default.sources.SILENT);
  1073. return change;
  1074. }, source);
  1075. }
  1076. }, {
  1077. key: 'formatLine',
  1078. value: function formatLine(index, length, name, value, source) {
  1079. var _this5 = this;
  1080. var formats = void 0;
  1081. var _overload3 = overload(index, length, name, value, source);
  1082. var _overload4 = _slicedToArray(_overload3, 4);
  1083. index = _overload4[0];
  1084. length = _overload4[1];
  1085. formats = _overload4[2];
  1086. source = _overload4[3];
  1087. return modify.call(this, function () {
  1088. return _this5.editor.formatLine(index, length, formats);
  1089. }, source, index, 0);
  1090. }
  1091. }, {
  1092. key: 'formatText',
  1093. value: function formatText(index, length, name, value, source) {
  1094. var _this6 = this;
  1095. var formats = void 0;
  1096. var _overload5 = overload(index, length, name, value, source);
  1097. var _overload6 = _slicedToArray(_overload5, 4);
  1098. index = _overload6[0];
  1099. length = _overload6[1];
  1100. formats = _overload6[2];
  1101. source = _overload6[3];
  1102. return modify.call(this, function () {
  1103. return _this6.editor.formatText(index, length, formats);
  1104. }, source, index, 0);
  1105. }
  1106. }, {
  1107. key: 'getBounds',
  1108. value: function getBounds(index) {
  1109. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  1110. var bounds = void 0;
  1111. if (typeof index === 'number') {
  1112. bounds = this.selection.getBounds(index, length);
  1113. } else {
  1114. bounds = this.selection.getBounds(index.index, index.length);
  1115. }
  1116. var containerBounds = this.container.getBoundingClientRect();
  1117. return {
  1118. bottom: bounds.bottom - containerBounds.top,
  1119. height: bounds.height,
  1120. left: bounds.left - containerBounds.left,
  1121. right: bounds.right - containerBounds.left,
  1122. top: bounds.top - containerBounds.top,
  1123. width: bounds.width
  1124. };
  1125. }
  1126. }, {
  1127. key: 'getContents',
  1128. value: function getContents() {
  1129. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1130. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getLength() - index;
  1131. var _overload7 = overload(index, length);
  1132. var _overload8 = _slicedToArray(_overload7, 2);
  1133. index = _overload8[0];
  1134. length = _overload8[1];
  1135. return this.editor.getContents(index, length);
  1136. }
  1137. }, {
  1138. key: 'getFormat',
  1139. value: function getFormat() {
  1140. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getSelection(true);
  1141. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  1142. if (typeof index === 'number') {
  1143. return this.editor.getFormat(index, length);
  1144. } else {
  1145. return this.editor.getFormat(index.index, index.length);
  1146. }
  1147. }
  1148. }, {
  1149. key: 'getIndex',
  1150. value: function getIndex(blot) {
  1151. return blot.offset(this.scroll);
  1152. }
  1153. }, {
  1154. key: 'getLength',
  1155. value: function getLength() {
  1156. return this.scroll.length();
  1157. }
  1158. }, {
  1159. key: 'getLeaf',
  1160. value: function getLeaf(index) {
  1161. return this.scroll.leaf(index);
  1162. }
  1163. }, {
  1164. key: 'getLine',
  1165. value: function getLine(index) {
  1166. return this.scroll.line(index);
  1167. }
  1168. }, {
  1169. key: 'getLines',
  1170. value: function getLines() {
  1171. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1172. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_VALUE;
  1173. if (typeof index !== 'number') {
  1174. return this.scroll.lines(index.index, index.length);
  1175. } else {
  1176. return this.scroll.lines(index, length);
  1177. }
  1178. }
  1179. }, {
  1180. key: 'getModule',
  1181. value: function getModule(name) {
  1182. return this.theme.modules[name];
  1183. }
  1184. }, {
  1185. key: 'getSelection',
  1186. value: function getSelection() {
  1187. var focus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1188. if (focus) this.focus();
  1189. this.update(); // Make sure we access getRange with editor in consistent state
  1190. return this.selection.getRange()[0];
  1191. }
  1192. }, {
  1193. key: 'getText',
  1194. value: function getText() {
  1195. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1196. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getLength() - index;
  1197. var _overload9 = overload(index, length);
  1198. var _overload10 = _slicedToArray(_overload9, 2);
  1199. index = _overload10[0];
  1200. length = _overload10[1];
  1201. return this.editor.getText(index, length);
  1202. }
  1203. }, {
  1204. key: 'hasFocus',
  1205. value: function hasFocus() {
  1206. return this.selection.hasFocus();
  1207. }
  1208. }, {
  1209. key: 'insertEmbed',
  1210. value: function insertEmbed(index, embed, value) {
  1211. var _this7 = this;
  1212. var source = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Quill.sources.API;
  1213. return modify.call(this, function () {
  1214. return _this7.editor.insertEmbed(index, embed, value);
  1215. }, source, index);
  1216. }
  1217. }, {
  1218. key: 'insertText',
  1219. value: function insertText(index, text, name, value, source) {
  1220. var _this8 = this;
  1221. var formats = void 0;
  1222. var _overload11 = overload(index, 0, name, value, source);
  1223. var _overload12 = _slicedToArray(_overload11, 4);
  1224. index = _overload12[0];
  1225. formats = _overload12[2];
  1226. source = _overload12[3];
  1227. return modify.call(this, function () {
  1228. return _this8.editor.insertText(index, text, formats);
  1229. }, source, index, text.length);
  1230. }
  1231. }, {
  1232. key: 'isEnabled',
  1233. value: function isEnabled() {
  1234. return !this.container.classList.contains('ql-disabled');
  1235. }
  1236. }, {
  1237. key: 'off',
  1238. value: function off() {
  1239. return this.emitter.off.apply(this.emitter, arguments);
  1240. }
  1241. }, {
  1242. key: 'on',
  1243. value: function on() {
  1244. return this.emitter.on.apply(this.emitter, arguments);
  1245. }
  1246. }, {
  1247. key: 'once',
  1248. value: function once() {
  1249. return this.emitter.once.apply(this.emitter, arguments);
  1250. }
  1251. }, {
  1252. key: 'pasteHTML',
  1253. value: function pasteHTML(index, html, source) {
  1254. this.clipboard.dangerouslyPasteHTML(index, html, source);
  1255. }
  1256. }, {
  1257. key: 'removeFormat',
  1258. value: function removeFormat(index, length, source) {
  1259. var _this9 = this;
  1260. var _overload13 = overload(index, length, source);
  1261. var _overload14 = _slicedToArray(_overload13, 4);
  1262. index = _overload14[0];
  1263. length = _overload14[1];
  1264. source = _overload14[3];
  1265. return modify.call(this, function () {
  1266. return _this9.editor.removeFormat(index, length);
  1267. }, source, index);
  1268. }
  1269. }, {
  1270. key: 'scrollIntoView',
  1271. value: function scrollIntoView() {
  1272. this.selection.scrollIntoView(this.scrollingContainer);
  1273. }
  1274. }, {
  1275. key: 'setContents',
  1276. value: function setContents(delta) {
  1277. var _this10 = this;
  1278. var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter4.default.sources.API;
  1279. return modify.call(this, function () {
  1280. delta = new _quillDelta2.default(delta);
  1281. var length = _this10.getLength();
  1282. var deleted = _this10.editor.deleteText(0, length);
  1283. var applied = _this10.editor.applyDelta(delta);
  1284. var lastOp = applied.ops[applied.ops.length - 1];
  1285. if (lastOp != null && typeof lastOp.insert === 'string' && lastOp.insert[lastOp.insert.length - 1] === '\n') {
  1286. _this10.editor.deleteText(_this10.getLength() - 1, 1);
  1287. applied.delete(1);
  1288. }
  1289. var ret = deleted.compose(applied);
  1290. return ret;
  1291. }, source);
  1292. }
  1293. }, {
  1294. key: 'setSelection',
  1295. value: function setSelection(index, length, source) {
  1296. if (index == null) {
  1297. this.selection.setRange(null, length || Quill.sources.API);
  1298. } else {
  1299. var _overload15 = overload(index, length, source);
  1300. var _overload16 = _slicedToArray(_overload15, 4);
  1301. index = _overload16[0];
  1302. length = _overload16[1];
  1303. source = _overload16[3];
  1304. this.selection.setRange(new _selection.Range(index, length), source);
  1305. if (source !== _emitter4.default.sources.SILENT) {
  1306. this.selection.scrollIntoView(this.scrollingContainer);
  1307. }
  1308. }
  1309. }
  1310. }, {
  1311. key: 'setText',
  1312. value: function setText(text) {
  1313. var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter4.default.sources.API;
  1314. var delta = new _quillDelta2.default().insert(text);
  1315. return this.setContents(delta, source);
  1316. }
  1317. }, {
  1318. key: 'update',
  1319. value: function update() {
  1320. var source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _emitter4.default.sources.USER;
  1321. var change = this.scroll.update(source); // Will update selection before selection.update() does if text changes
  1322. this.selection.update(source);
  1323. return change;
  1324. }
  1325. }, {
  1326. key: 'updateContents',
  1327. value: function updateContents(delta) {
  1328. var _this11 = this;
  1329. var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter4.default.sources.API;
  1330. return modify.call(this, function () {
  1331. delta = new _quillDelta2.default(delta);
  1332. return _this11.editor.applyDelta(delta, source);
  1333. }, source, true);
  1334. }
  1335. }]);
  1336. return Quill;
  1337. }();
  1338. Quill.DEFAULTS = {
  1339. bounds: null,
  1340. formats: null,
  1341. modules: {},
  1342. placeholder: '',
  1343. readOnly: false,
  1344. scrollingContainer: null,
  1345. strict: true,
  1346. theme: 'default'
  1347. };
  1348. Quill.events = _emitter4.default.events;
  1349. Quill.sources = _emitter4.default.sources;
  1350. // eslint-disable-next-line no-undef
  1351. Quill.version = false ? 'dev' : "1.3.6";
  1352. Quill.imports = {
  1353. 'delta': _quillDelta2.default,
  1354. 'parchment': _parchment2.default,
  1355. 'core/module': _module2.default,
  1356. 'core/theme': _theme2.default
  1357. };
  1358. function expandConfig(container, userConfig) {
  1359. userConfig = (0, _extend2.default)(true, {
  1360. container: container,
  1361. modules: {
  1362. clipboard: true,
  1363. keyboard: true,
  1364. history: true
  1365. }
  1366. }, userConfig);
  1367. if (!userConfig.theme || userConfig.theme === Quill.DEFAULTS.theme) {
  1368. userConfig.theme = _theme2.default;
  1369. } else {
  1370. userConfig.theme = Quill.import('themes/' + userConfig.theme);
  1371. if (userConfig.theme == null) {
  1372. throw new Error('Invalid theme ' + userConfig.theme + '. Did you register it?');
  1373. }
  1374. }
  1375. var themeConfig = (0, _extend2.default)(true, {}, userConfig.theme.DEFAULTS);
  1376. [themeConfig, userConfig].forEach(function (config) {
  1377. config.modules = config.modules || {};
  1378. Object.keys(config.modules).forEach(function (module) {
  1379. if (config.modules[module] === true) {
  1380. config.modules[module] = {};
  1381. }
  1382. });
  1383. });
  1384. var moduleNames = Object.keys(themeConfig.modules).concat(Object.keys(userConfig.modules));
  1385. var moduleConfig = moduleNames.reduce(function (config, name) {
  1386. var moduleClass = Quill.import('modules/' + name);
  1387. if (moduleClass == null) {
  1388. debug.error('Cannot load ' + name + ' module. Are you sure you registered it?');
  1389. } else {
  1390. config[name] = moduleClass.DEFAULTS || {};
  1391. }
  1392. return config;
  1393. }, {});
  1394. // Special case toolbar shorthand
  1395. if (userConfig.modules != null && userConfig.modules.toolbar && userConfig.modules.toolbar.constructor !== Object) {
  1396. userConfig.modules.toolbar = {
  1397. container: userConfig.modules.toolbar
  1398. };
  1399. }
  1400. userConfig = (0, _extend2.default)(true, {}, Quill.DEFAULTS, { modules: moduleConfig }, themeConfig, userConfig);
  1401. ['bounds', 'container', 'scrollingContainer'].forEach(function (key) {
  1402. if (typeof userConfig[key] === 'string') {
  1403. userConfig[key] = document.querySelector(userConfig[key]);
  1404. }
  1405. });
  1406. userConfig.modules = Object.keys(userConfig.modules).reduce(function (config, name) {
  1407. if (userConfig.modules[name]) {
  1408. config[name] = userConfig.modules[name];
  1409. }
  1410. return config;
  1411. }, {});
  1412. return userConfig;
  1413. }
  1414. // Handle selection preservation and TEXT_CHANGE emission
  1415. // common to modification APIs
  1416. function modify(modifier, source, index, shift) {
  1417. if (this.options.strict && !this.isEnabled() && source === _emitter4.default.sources.USER) {
  1418. return new _quillDelta2.default();
  1419. }
  1420. var range = index == null ? null : this.getSelection();
  1421. var oldDelta = this.editor.delta;
  1422. var change = modifier();
  1423. if (range != null) {
  1424. if (index === true) index = range.index;
  1425. if (shift == null) {
  1426. range = shiftRange(range, change, source);
  1427. } else if (shift !== 0) {
  1428. range = shiftRange(range, index, shift, source);
  1429. }
  1430. this.setSelection(range, _emitter4.default.sources.SILENT);
  1431. }
  1432. if (change.length() > 0) {
  1433. var _emitter;
  1434. var args = [_emitter4.default.events.TEXT_CHANGE, change, oldDelta, source];
  1435. (_emitter = this.emitter).emit.apply(_emitter, [_emitter4.default.events.EDITOR_CHANGE].concat(args));
  1436. if (source !== _emitter4.default.sources.SILENT) {
  1437. var _emitter2;
  1438. (_emitter2 = this.emitter).emit.apply(_emitter2, args);
  1439. }
  1440. }
  1441. return change;
  1442. }
  1443. function overload(index, length, name, value, source) {
  1444. var formats = {};
  1445. if (typeof index.index === 'number' && typeof index.length === 'number') {
  1446. // Allow for throwaway end (used by insertText/insertEmbed)
  1447. if (typeof length !== 'number') {
  1448. source = value, value = name, name = length, length = index.length, index = index.index;
  1449. } else {
  1450. length = index.length, index = index.index;
  1451. }
  1452. } else if (typeof length !== 'number') {
  1453. source = value, value = name, name = length, length = 0;
  1454. }
  1455. // Handle format being object, two format name/value strings or excluded
  1456. if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') {
  1457. formats = name;
  1458. source = value;
  1459. } else if (typeof name === 'string') {
  1460. if (value != null) {
  1461. formats[name] = value;
  1462. } else {
  1463. source = name;
  1464. }
  1465. }
  1466. // Handle optional source
  1467. source = source || _emitter4.default.sources.API;
  1468. return [index, length, formats, source];
  1469. }
  1470. function shiftRange(range, index, length, source) {
  1471. if (range == null) return null;
  1472. var start = void 0,
  1473. end = void 0;
  1474. if (index instanceof _quillDelta2.default) {
  1475. var _map = [range.index, range.index + range.length].map(function (pos) {
  1476. return index.transformPosition(pos, source !== _emitter4.default.sources.USER);
  1477. });
  1478. var _map2 = _slicedToArray(_map, 2);
  1479. start = _map2[0];
  1480. end = _map2[1];
  1481. } else {
  1482. var _map3 = [range.index, range.index + range.length].map(function (pos) {
  1483. if (pos < index || pos === index && source === _emitter4.default.sources.USER) return pos;
  1484. if (length >= 0) {
  1485. return pos + length;
  1486. } else {
  1487. return Math.max(index, pos + length);
  1488. }
  1489. });
  1490. var _map4 = _slicedToArray(_map3, 2);
  1491. start = _map4[0];
  1492. end = _map4[1];
  1493. }
  1494. return new _selection.Range(start, end - start);
  1495. }
  1496. exports.expandConfig = expandConfig;
  1497. exports.overload = overload;
  1498. exports.default = Quill;
  1499. /***/ }),
  1500. /* 6 */
  1501. /***/ (function(module, exports, __webpack_require__) {
  1502. "use strict";
  1503. Object.defineProperty(exports, "__esModule", {
  1504. value: true
  1505. });
  1506. 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; }; }();
  1507. 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); } };
  1508. var _text = __webpack_require__(7);
  1509. var _text2 = _interopRequireDefault(_text);
  1510. var _parchment = __webpack_require__(0);
  1511. var _parchment2 = _interopRequireDefault(_parchment);
  1512. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1513. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1514. 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; }
  1515. 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; }
  1516. var Inline = function (_Parchment$Inline) {
  1517. _inherits(Inline, _Parchment$Inline);
  1518. function Inline() {
  1519. _classCallCheck(this, Inline);
  1520. return _possibleConstructorReturn(this, (Inline.__proto__ || Object.getPrototypeOf(Inline)).apply(this, arguments));
  1521. }
  1522. _createClass(Inline, [{
  1523. key: 'formatAt',
  1524. value: function formatAt(index, length, name, value) {
  1525. if (Inline.compare(this.statics.blotName, name) < 0 && _parchment2.default.query(name, _parchment2.default.Scope.BLOT)) {
  1526. var blot = this.isolate(index, length);
  1527. if (value) {
  1528. blot.wrap(name, value);
  1529. }
  1530. } else {
  1531. _get(Inline.prototype.__proto__ || Object.getPrototypeOf(Inline.prototype), 'formatAt', this).call(this, index, length, name, value);
  1532. }
  1533. }
  1534. }, {
  1535. key: 'optimize',
  1536. value: function optimize(context) {
  1537. _get(Inline.prototype.__proto__ || Object.getPrototypeOf(Inline.prototype), 'optimize', this).call(this, context);
  1538. if (this.parent instanceof Inline && Inline.compare(this.statics.blotName, this.parent.statics.blotName) > 0) {
  1539. var parent = this.parent.isolate(this.offset(), this.length());
  1540. this.moveChildren(parent);
  1541. parent.wrap(this);
  1542. }
  1543. }
  1544. }], [{
  1545. key: 'compare',
  1546. value: function compare(self, other) {
  1547. var selfIndex = Inline.order.indexOf(self);
  1548. var otherIndex = Inline.order.indexOf(other);
  1549. if (selfIndex >= 0 || otherIndex >= 0) {
  1550. return selfIndex - otherIndex;
  1551. } else if (self === other) {
  1552. return 0;
  1553. } else if (self < other) {
  1554. return -1;
  1555. } else {
  1556. return 1;
  1557. }
  1558. }
  1559. }]);
  1560. return Inline;
  1561. }(_parchment2.default.Inline);
  1562. Inline.allowedChildren = [Inline, _parchment2.default.Embed, _text2.default];
  1563. // Lower index means deeper in the DOM tree, since not found (-1) is for embeds
  1564. Inline.order = ['cursor', 'inline', // Must be lower
  1565. 'underline', 'strike', 'italic', 'bold', 'script', 'link', 'code' // Must be higher
  1566. ];
  1567. exports.default = Inline;
  1568. /***/ }),
  1569. /* 7 */
  1570. /***/ (function(module, exports, __webpack_require__) {
  1571. "use strict";
  1572. Object.defineProperty(exports, "__esModule", {
  1573. value: true
  1574. });
  1575. var _parchment = __webpack_require__(0);
  1576. var _parchment2 = _interopRequireDefault(_parchment);
  1577. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1578. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1579. 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; }
  1580. 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; }
  1581. var TextBlot = function (_Parchment$Text) {
  1582. _inherits(TextBlot, _Parchment$Text);
  1583. function TextBlot() {
  1584. _classCallCheck(this, TextBlot);
  1585. return _possibleConstructorReturn(this, (TextBlot.__proto__ || Object.getPrototypeOf(TextBlot)).apply(this, arguments));
  1586. }
  1587. return TextBlot;
  1588. }(_parchment2.default.Text);
  1589. exports.default = TextBlot;
  1590. /***/ }),
  1591. /* 8 */
  1592. /***/ (function(module, exports, __webpack_require__) {
  1593. "use strict";
  1594. Object.defineProperty(exports, "__esModule", {
  1595. value: true
  1596. });
  1597. 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; }; }();
  1598. 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); } };
  1599. var _eventemitter = __webpack_require__(54);
  1600. var _eventemitter2 = _interopRequireDefault(_eventemitter);
  1601. var _logger = __webpack_require__(10);
  1602. var _logger2 = _interopRequireDefault(_logger);
  1603. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1604. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1605. 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; }
  1606. 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; }
  1607. var debug = (0, _logger2.default)('quill:events');
  1608. var EVENTS = ['selectionchange', 'mousedown', 'mouseup', 'click'];
  1609. EVENTS.forEach(function (eventName) {
  1610. document.addEventListener(eventName, function () {
  1611. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  1612. args[_key] = arguments[_key];
  1613. }
  1614. [].slice.call(document.querySelectorAll('.ql-container')).forEach(function (node) {
  1615. // TODO use WeakMap
  1616. if (node.__quill && node.__quill.emitter) {
  1617. var _node$__quill$emitter;
  1618. (_node$__quill$emitter = node.__quill.emitter).handleDOM.apply(_node$__quill$emitter, args);
  1619. }
  1620. });
  1621. });
  1622. });
  1623. var Emitter = function (_EventEmitter) {
  1624. _inherits(Emitter, _EventEmitter);
  1625. function Emitter() {
  1626. _classCallCheck(this, Emitter);
  1627. var _this = _possibleConstructorReturn(this, (Emitter.__proto__ || Object.getPrototypeOf(Emitter)).call(this));
  1628. _this.listeners = {};
  1629. _this.on('error', debug.error);
  1630. return _this;
  1631. }
  1632. _createClass(Emitter, [{
  1633. key: 'emit',
  1634. value: function emit() {
  1635. debug.log.apply(debug, arguments);
  1636. _get(Emitter.prototype.__proto__ || Object.getPrototypeOf(Emitter.prototype), 'emit', this).apply(this, arguments);
  1637. }
  1638. }, {
  1639. key: 'handleDOM',
  1640. value: function handleDOM(event) {
  1641. for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  1642. args[_key2 - 1] = arguments[_key2];
  1643. }
  1644. (this.listeners[event.type] || []).forEach(function (_ref) {
  1645. var node = _ref.node,
  1646. handler = _ref.handler;
  1647. if (event.target === node || node.contains(event.target)) {
  1648. handler.apply(undefined, [event].concat(args));
  1649. }
  1650. });
  1651. }
  1652. }, {
  1653. key: 'listenDOM',
  1654. value: function listenDOM(eventName, node, handler) {
  1655. if (!this.listeners[eventName]) {
  1656. this.listeners[eventName] = [];
  1657. }
  1658. this.listeners[eventName].push({ node: node, handler: handler });
  1659. }
  1660. }]);
  1661. return Emitter;
  1662. }(_eventemitter2.default);
  1663. Emitter.events = {
  1664. EDITOR_CHANGE: 'editor-change',
  1665. SCROLL_BEFORE_UPDATE: 'scroll-before-update',
  1666. SCROLL_OPTIMIZE: 'scroll-optimize',
  1667. SCROLL_UPDATE: 'scroll-update',
  1668. SELECTION_CHANGE: 'selection-change',
  1669. TEXT_CHANGE: 'text-change'
  1670. };
  1671. Emitter.sources = {
  1672. API: 'api',
  1673. SILENT: 'silent',
  1674. USER: 'user'
  1675. };
  1676. exports.default = Emitter;
  1677. /***/ }),
  1678. /* 9 */
  1679. /***/ (function(module, exports, __webpack_require__) {
  1680. "use strict";
  1681. Object.defineProperty(exports, "__esModule", {
  1682. value: true
  1683. });
  1684. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1685. var Module = function Module(quill) {
  1686. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1687. _classCallCheck(this, Module);
  1688. this.quill = quill;
  1689. this.options = options;
  1690. };
  1691. Module.DEFAULTS = {};
  1692. exports.default = Module;
  1693. /***/ }),
  1694. /* 10 */
  1695. /***/ (function(module, exports, __webpack_require__) {
  1696. "use strict";
  1697. Object.defineProperty(exports, "__esModule", {
  1698. value: true
  1699. });
  1700. var levels = ['error', 'warn', 'log', 'info'];
  1701. var level = 'warn';
  1702. function debug(method) {
  1703. if (levels.indexOf(method) <= levels.indexOf(level)) {
  1704. var _console;
  1705. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1706. args[_key - 1] = arguments[_key];
  1707. }
  1708. (_console = console)[method].apply(_console, args); // eslint-disable-line no-console
  1709. }
  1710. }
  1711. function namespace(ns) {
  1712. return levels.reduce(function (logger, method) {
  1713. logger[method] = debug.bind(console, method, ns);
  1714. return logger;
  1715. }, {});
  1716. }
  1717. debug.level = namespace.level = function (newLevel) {
  1718. level = newLevel;
  1719. };
  1720. exports.default = namespace;
  1721. /***/ }),
  1722. /* 11 */
  1723. /***/ (function(module, exports, __webpack_require__) {
  1724. var pSlice = Array.prototype.slice;
  1725. var objectKeys = __webpack_require__(52);
  1726. var isArguments = __webpack_require__(53);
  1727. var deepEqual = module.exports = function (actual, expected, opts) {
  1728. if (!opts) opts = {};
  1729. // 7.1. All identical values are equivalent, as determined by ===.
  1730. if (actual === expected) {
  1731. return true;
  1732. } else if (actual instanceof Date && expected instanceof Date) {
  1733. return actual.getTime() === expected.getTime();
  1734. // 7.3. Other pairs that do not both pass typeof value == 'object',
  1735. // equivalence is determined by ==.
  1736. } else if (!actual || !expected || typeof actual != 'object' && typeof expected != 'object') {
  1737. return opts.strict ? actual === expected : actual == expected;
  1738. // 7.4. For all other Object pairs, including Array objects, equivalence is
  1739. // determined by having the same number of owned properties (as verified
  1740. // with Object.prototype.hasOwnProperty.call), the same set of keys
  1741. // (although not necessarily the same order), equivalent values for every
  1742. // corresponding key, and an identical 'prototype' property. Note: this
  1743. // accounts for both named and indexed properties on Arrays.
  1744. } else {
  1745. return objEquiv(actual, expected, opts);
  1746. }
  1747. }
  1748. function isUndefinedOrNull(value) {
  1749. return value === null || value === undefined;
  1750. }
  1751. function isBuffer (x) {
  1752. if (!x || typeof x !== 'object' || typeof x.length !== 'number') return false;
  1753. if (typeof x.copy !== 'function' || typeof x.slice !== 'function') {
  1754. return false;
  1755. }
  1756. if (x.length > 0 && typeof x[0] !== 'number') return false;
  1757. return true;
  1758. }
  1759. function objEquiv(a, b, opts) {
  1760. var i, key;
  1761. if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
  1762. return false;
  1763. // an identical 'prototype' property.
  1764. if (a.prototype !== b.prototype) return false;
  1765. //~~~I've managed to break Object.keys through screwy arguments passing.
  1766. // Converting to array solves the problem.
  1767. if (isArguments(a)) {
  1768. if (!isArguments(b)) {
  1769. return false;
  1770. }
  1771. a = pSlice.call(a);
  1772. b = pSlice.call(b);
  1773. return deepEqual(a, b, opts);
  1774. }
  1775. if (isBuffer(a)) {
  1776. if (!isBuffer(b)) {
  1777. return false;
  1778. }
  1779. if (a.length !== b.length) return false;
  1780. for (i = 0; i < a.length; i++) {
  1781. if (a[i] !== b[i]) return false;
  1782. }
  1783. return true;
  1784. }
  1785. try {
  1786. var ka = objectKeys(a),
  1787. kb = objectKeys(b);
  1788. } catch (e) {//happens when one is a string literal and the other isn't
  1789. return false;
  1790. }
  1791. // having the same number of owned properties (keys incorporates
  1792. // hasOwnProperty)
  1793. if (ka.length != kb.length)
  1794. return false;
  1795. //the same set of keys (although not necessarily the same order),
  1796. ka.sort();
  1797. kb.sort();
  1798. //~~~cheap key test
  1799. for (i = ka.length - 1; i >= 0; i--) {
  1800. if (ka[i] != kb[i])
  1801. return false;
  1802. }
  1803. //equivalent values for every corresponding key, and
  1804. //~~~possibly expensive deep test
  1805. for (i = ka.length - 1; i >= 0; i--) {
  1806. key = ka[i];
  1807. if (!deepEqual(a[key], b[key], opts)) return false;
  1808. }
  1809. return typeof a === typeof b;
  1810. }
  1811. /***/ }),
  1812. /* 12 */
  1813. /***/ (function(module, exports, __webpack_require__) {
  1814. "use strict";
  1815. Object.defineProperty(exports, "__esModule", { value: true });
  1816. var Registry = __webpack_require__(1);
  1817. var Attributor = /** @class */ (function () {
  1818. function Attributor(attrName, keyName, options) {
  1819. if (options === void 0) { options = {}; }
  1820. this.attrName = attrName;
  1821. this.keyName = keyName;
  1822. var attributeBit = Registry.Scope.TYPE & Registry.Scope.ATTRIBUTE;
  1823. if (options.scope != null) {
  1824. // Ignore type bits, force attribute bit
  1825. this.scope = (options.scope & Registry.Scope.LEVEL) | attributeBit;
  1826. }
  1827. else {
  1828. this.scope = Registry.Scope.ATTRIBUTE;
  1829. }
  1830. if (options.whitelist != null)
  1831. this.whitelist = options.whitelist;
  1832. }
  1833. Attributor.keys = function (node) {
  1834. return [].map.call(node.attributes, function (item) {
  1835. return item.name;
  1836. });
  1837. };
  1838. Attributor.prototype.add = function (node, value) {
  1839. if (!this.canAdd(node, value))
  1840. return false;
  1841. node.setAttribute(this.keyName, value);
  1842. return true;
  1843. };
  1844. Attributor.prototype.canAdd = function (node, value) {
  1845. var match = Registry.query(node, Registry.Scope.BLOT & (this.scope | Registry.Scope.TYPE));
  1846. if (match == null)
  1847. return false;
  1848. if (this.whitelist == null)
  1849. return true;
  1850. if (typeof value === 'string') {
  1851. return this.whitelist.indexOf(value.replace(/["']/g, '')) > -1;
  1852. }
  1853. else {
  1854. return this.whitelist.indexOf(value) > -1;
  1855. }
  1856. };
  1857. Attributor.prototype.remove = function (node) {
  1858. node.removeAttribute(this.keyName);
  1859. };
  1860. Attributor.prototype.value = function (node) {
  1861. var value = node.getAttribute(this.keyName);
  1862. if (this.canAdd(node, value) && value) {
  1863. return value;
  1864. }
  1865. return '';
  1866. };
  1867. return Attributor;
  1868. }());
  1869. exports.default = Attributor;
  1870. /***/ }),
  1871. /* 13 */
  1872. /***/ (function(module, exports, __webpack_require__) {
  1873. "use strict";
  1874. Object.defineProperty(exports, "__esModule", {
  1875. value: true
  1876. });
  1877. exports.default = exports.Code = undefined;
  1878. 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"); } }; }();
  1879. 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; }; }();
  1880. 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); } };
  1881. var _quillDelta = __webpack_require__(2);
  1882. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  1883. var _parchment = __webpack_require__(0);
  1884. var _parchment2 = _interopRequireDefault(_parchment);
  1885. var _block = __webpack_require__(4);
  1886. var _block2 = _interopRequireDefault(_block);
  1887. var _inline = __webpack_require__(6);
  1888. var _inline2 = _interopRequireDefault(_inline);
  1889. var _text = __webpack_require__(7);
  1890. var _text2 = _interopRequireDefault(_text);
  1891. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1892. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1893. 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; }
  1894. 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; }
  1895. var Code = function (_Inline) {
  1896. _inherits(Code, _Inline);
  1897. function Code() {
  1898. _classCallCheck(this, Code);
  1899. return _possibleConstructorReturn(this, (Code.__proto__ || Object.getPrototypeOf(Code)).apply(this, arguments));
  1900. }
  1901. return Code;
  1902. }(_inline2.default);
  1903. Code.blotName = 'code';
  1904. Code.tagName = 'CODE';
  1905. var CodeBlock = function (_Block) {
  1906. _inherits(CodeBlock, _Block);
  1907. function CodeBlock() {
  1908. _classCallCheck(this, CodeBlock);
  1909. return _possibleConstructorReturn(this, (CodeBlock.__proto__ || Object.getPrototypeOf(CodeBlock)).apply(this, arguments));
  1910. }
  1911. _createClass(CodeBlock, [{
  1912. key: 'delta',
  1913. value: function delta() {
  1914. var _this3 = this;
  1915. var text = this.domNode.textContent;
  1916. if (text.endsWith('\n')) {
  1917. // Should always be true
  1918. text = text.slice(0, -1);
  1919. }
  1920. return text.split('\n').reduce(function (delta, frag) {
  1921. return delta.insert(frag).insert('\n', _this3.formats());
  1922. }, new _quillDelta2.default());
  1923. }
  1924. }, {
  1925. key: 'format',
  1926. value: function format(name, value) {
  1927. if (name === this.statics.blotName && value) return;
  1928. var _descendant = this.descendant(_text2.default, this.length() - 1),
  1929. _descendant2 = _slicedToArray(_descendant, 1),
  1930. text = _descendant2[0];
  1931. if (text != null) {
  1932. text.deleteAt(text.length() - 1, 1);
  1933. }
  1934. _get(CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), 'format', this).call(this, name, value);
  1935. }
  1936. }, {
  1937. key: 'formatAt',
  1938. value: function formatAt(index, length, name, value) {
  1939. if (length === 0) return;
  1940. if (_parchment2.default.query(name, _parchment2.default.Scope.BLOCK) == null || name === this.statics.blotName && value === this.statics.formats(this.domNode)) {
  1941. return;
  1942. }
  1943. var nextNewline = this.newlineIndex(index);
  1944. if (nextNewline < 0 || nextNewline >= index + length) return;
  1945. var prevNewline = this.newlineIndex(index, true) + 1;
  1946. var isolateLength = nextNewline - prevNewline + 1;
  1947. var blot = this.isolate(prevNewline, isolateLength);
  1948. var next = blot.next;
  1949. blot.format(name, value);
  1950. if (next instanceof CodeBlock) {
  1951. next.formatAt(0, index - prevNewline + length - isolateLength, name, value);
  1952. }
  1953. }
  1954. }, {
  1955. key: 'insertAt',
  1956. value: function insertAt(index, value, def) {
  1957. if (def != null) return;
  1958. var _descendant3 = this.descendant(_text2.default, index),
  1959. _descendant4 = _slicedToArray(_descendant3, 2),
  1960. text = _descendant4[0],
  1961. offset = _descendant4[1];
  1962. text.insertAt(offset, value);
  1963. }
  1964. }, {
  1965. key: 'length',
  1966. value: function length() {
  1967. var length = this.domNode.textContent.length;
  1968. if (!this.domNode.textContent.endsWith('\n')) {
  1969. return length + 1;
  1970. }
  1971. return length;
  1972. }
  1973. }, {
  1974. key: 'newlineIndex',
  1975. value: function newlineIndex(searchIndex) {
  1976. var reverse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1977. if (!reverse) {
  1978. var offset = this.domNode.textContent.slice(searchIndex).indexOf('\n');
  1979. return offset > -1 ? searchIndex + offset : -1;
  1980. } else {
  1981. return this.domNode.textContent.slice(0, searchIndex).lastIndexOf('\n');
  1982. }
  1983. }
  1984. }, {
  1985. key: 'optimize',
  1986. value: function optimize(context) {
  1987. if (!this.domNode.textContent.endsWith('\n')) {
  1988. this.appendChild(_parchment2.default.create('text', '\n'));
  1989. }
  1990. _get(CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), 'optimize', this).call(this, context);
  1991. var next = this.next;
  1992. if (next != null && next.prev === this && next.statics.blotName === this.statics.blotName && this.statics.formats(this.domNode) === next.statics.formats(next.domNode)) {
  1993. next.optimize(context);
  1994. next.moveChildren(this);
  1995. next.remove();
  1996. }
  1997. }
  1998. }, {
  1999. key: 'replace',
  2000. value: function replace(target) {
  2001. _get(CodeBlock.prototype.__proto__ || Object.getPrototypeOf(CodeBlock.prototype), 'replace', this).call(this, target);
  2002. [].slice.call(this.domNode.querySelectorAll('*')).forEach(function (node) {
  2003. var blot = _parchment2.default.find(node);
  2004. if (blot == null) {
  2005. node.parentNode.removeChild(node);
  2006. } else if (blot instanceof _parchment2.default.Embed) {
  2007. blot.remove();
  2008. } else {
  2009. blot.unwrap();
  2010. }
  2011. });
  2012. }
  2013. }], [{
  2014. key: 'create',
  2015. value: function create(value) {
  2016. var domNode = _get(CodeBlock.__proto__ || Object.getPrototypeOf(CodeBlock), 'create', this).call(this, value);
  2017. domNode.setAttribute('spellcheck', false);
  2018. return domNode;
  2019. }
  2020. }, {
  2021. key: 'formats',
  2022. value: function formats() {
  2023. return true;
  2024. }
  2025. }]);
  2026. return CodeBlock;
  2027. }(_block2.default);
  2028. CodeBlock.blotName = 'code-block';
  2029. CodeBlock.tagName = 'PRE';
  2030. CodeBlock.TAB = ' ';
  2031. exports.Code = Code;
  2032. exports.default = CodeBlock;
  2033. /***/ }),
  2034. /* 14 */
  2035. /***/ (function(module, exports, __webpack_require__) {
  2036. "use strict";
  2037. Object.defineProperty(exports, "__esModule", {
  2038. value: true
  2039. });
  2040. 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; };
  2041. 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"); } }; }();
  2042. 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; }; }();
  2043. var _quillDelta = __webpack_require__(2);
  2044. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  2045. var _op = __webpack_require__(20);
  2046. var _op2 = _interopRequireDefault(_op);
  2047. var _parchment = __webpack_require__(0);
  2048. var _parchment2 = _interopRequireDefault(_parchment);
  2049. var _code = __webpack_require__(13);
  2050. var _code2 = _interopRequireDefault(_code);
  2051. var _cursor = __webpack_require__(24);
  2052. var _cursor2 = _interopRequireDefault(_cursor);
  2053. var _block = __webpack_require__(4);
  2054. var _block2 = _interopRequireDefault(_block);
  2055. var _break = __webpack_require__(16);
  2056. var _break2 = _interopRequireDefault(_break);
  2057. var _clone = __webpack_require__(21);
  2058. var _clone2 = _interopRequireDefault(_clone);
  2059. var _deepEqual = __webpack_require__(11);
  2060. var _deepEqual2 = _interopRequireDefault(_deepEqual);
  2061. var _extend = __webpack_require__(3);
  2062. var _extend2 = _interopRequireDefault(_extend);
  2063. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2064. 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; }
  2065. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2066. var ASCII = /^[ -~]*$/;
  2067. var Editor = function () {
  2068. function Editor(scroll) {
  2069. _classCallCheck(this, Editor);
  2070. this.scroll = scroll;
  2071. this.delta = this.getDelta();
  2072. }
  2073. _createClass(Editor, [{
  2074. key: 'applyDelta',
  2075. value: function applyDelta(delta) {
  2076. var _this = this;
  2077. var consumeNextNewline = false;
  2078. this.scroll.update();
  2079. var scrollLength = this.scroll.length();
  2080. this.scroll.batchStart();
  2081. delta = normalizeDelta(delta);
  2082. delta.reduce(function (index, op) {
  2083. var length = op.retain || op.delete || op.insert.length || 1;
  2084. var attributes = op.attributes || {};
  2085. if (op.insert != null) {
  2086. if (typeof op.insert === 'string') {
  2087. var text = op.insert;
  2088. if (text.endsWith('\n') && consumeNextNewline) {
  2089. consumeNextNewline = false;
  2090. text = text.slice(0, -1);
  2091. }
  2092. if (index >= scrollLength && !text.endsWith('\n')) {
  2093. consumeNextNewline = true;
  2094. }
  2095. _this.scroll.insertAt(index, text);
  2096. var _scroll$line = _this.scroll.line(index),
  2097. _scroll$line2 = _slicedToArray(_scroll$line, 2),
  2098. line = _scroll$line2[0],
  2099. offset = _scroll$line2[1];
  2100. var formats = (0, _extend2.default)({}, (0, _block.bubbleFormats)(line));
  2101. if (line instanceof _block2.default) {
  2102. var _line$descendant = line.descendant(_parchment2.default.Leaf, offset),
  2103. _line$descendant2 = _slicedToArray(_line$descendant, 1),
  2104. leaf = _line$descendant2[0];
  2105. formats = (0, _extend2.default)(formats, (0, _block.bubbleFormats)(leaf));
  2106. }
  2107. attributes = _op2.default.attributes.diff(formats, attributes) || {};
  2108. } else if (_typeof(op.insert) === 'object') {
  2109. var key = Object.keys(op.insert)[0]; // There should only be one key
  2110. if (key == null) return index;
  2111. _this.scroll.insertAt(index, key, op.insert[key]);
  2112. }
  2113. scrollLength += length;
  2114. }
  2115. Object.keys(attributes).forEach(function (name) {
  2116. _this.scroll.formatAt(index, length, name, attributes[name]);
  2117. });
  2118. return index + length;
  2119. }, 0);
  2120. delta.reduce(function (index, op) {
  2121. if (typeof op.delete === 'number') {
  2122. _this.scroll.deleteAt(index, op.delete);
  2123. return index;
  2124. }
  2125. return index + (op.retain || op.insert.length || 1);
  2126. }, 0);
  2127. this.scroll.batchEnd();
  2128. return this.update(delta);
  2129. }
  2130. }, {
  2131. key: 'deleteText',
  2132. value: function deleteText(index, length) {
  2133. this.scroll.deleteAt(index, length);
  2134. return this.update(new _quillDelta2.default().retain(index).delete(length));
  2135. }
  2136. }, {
  2137. key: 'formatLine',
  2138. value: function formatLine(index, length) {
  2139. var _this2 = this;
  2140. var formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  2141. this.scroll.update();
  2142. Object.keys(formats).forEach(function (format) {
  2143. if (_this2.scroll.whitelist != null && !_this2.scroll.whitelist[format]) return;
  2144. var lines = _this2.scroll.lines(index, Math.max(length, 1));
  2145. var lengthRemaining = length;
  2146. lines.forEach(function (line) {
  2147. var lineLength = line.length();
  2148. if (!(line instanceof _code2.default)) {
  2149. line.format(format, formats[format]);
  2150. } else {
  2151. var codeIndex = index - line.offset(_this2.scroll);
  2152. var codeLength = line.newlineIndex(codeIndex + lengthRemaining) - codeIndex + 1;
  2153. line.formatAt(codeIndex, codeLength, format, formats[format]);
  2154. }
  2155. lengthRemaining -= lineLength;
  2156. });
  2157. });
  2158. this.scroll.optimize();
  2159. return this.update(new _quillDelta2.default().retain(index).retain(length, (0, _clone2.default)(formats)));
  2160. }
  2161. }, {
  2162. key: 'formatText',
  2163. value: function formatText(index, length) {
  2164. var _this3 = this;
  2165. var formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  2166. Object.keys(formats).forEach(function (format) {
  2167. _this3.scroll.formatAt(index, length, format, formats[format]);
  2168. });
  2169. return this.update(new _quillDelta2.default().retain(index).retain(length, (0, _clone2.default)(formats)));
  2170. }
  2171. }, {
  2172. key: 'getContents',
  2173. value: function getContents(index, length) {
  2174. return this.delta.slice(index, index + length);
  2175. }
  2176. }, {
  2177. key: 'getDelta',
  2178. value: function getDelta() {
  2179. return this.scroll.lines().reduce(function (delta, line) {
  2180. return delta.concat(line.delta());
  2181. }, new _quillDelta2.default());
  2182. }
  2183. }, {
  2184. key: 'getFormat',
  2185. value: function getFormat(index) {
  2186. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  2187. var lines = [],
  2188. leaves = [];
  2189. if (length === 0) {
  2190. this.scroll.path(index).forEach(function (path) {
  2191. var _path = _slicedToArray(path, 1),
  2192. blot = _path[0];
  2193. if (blot instanceof _block2.default) {
  2194. lines.push(blot);
  2195. } else if (blot instanceof _parchment2.default.Leaf) {
  2196. leaves.push(blot);
  2197. }
  2198. });
  2199. } else {
  2200. lines = this.scroll.lines(index, length);
  2201. leaves = this.scroll.descendants(_parchment2.default.Leaf, index, length);
  2202. }
  2203. var formatsArr = [lines, leaves].map(function (blots) {
  2204. if (blots.length === 0) return {};
  2205. var formats = (0, _block.bubbleFormats)(blots.shift());
  2206. while (Object.keys(formats).length > 0) {
  2207. var blot = blots.shift();
  2208. if (blot == null) return formats;
  2209. formats = combineFormats((0, _block.bubbleFormats)(blot), formats);
  2210. }
  2211. return formats;
  2212. });
  2213. return _extend2.default.apply(_extend2.default, formatsArr);
  2214. }
  2215. }, {
  2216. key: 'getText',
  2217. value: function getText(index, length) {
  2218. return this.getContents(index, length).filter(function (op) {
  2219. return typeof op.insert === 'string';
  2220. }).map(function (op) {
  2221. return op.insert;
  2222. }).join('');
  2223. }
  2224. }, {
  2225. key: 'insertEmbed',
  2226. value: function insertEmbed(index, embed, value) {
  2227. this.scroll.insertAt(index, embed, value);
  2228. return this.update(new _quillDelta2.default().retain(index).insert(_defineProperty({}, embed, value)));
  2229. }
  2230. }, {
  2231. key: 'insertText',
  2232. value: function insertText(index, text) {
  2233. var _this4 = this;
  2234. var formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  2235. text = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
  2236. this.scroll.insertAt(index, text);
  2237. Object.keys(formats).forEach(function (format) {
  2238. _this4.scroll.formatAt(index, text.length, format, formats[format]);
  2239. });
  2240. return this.update(new _quillDelta2.default().retain(index).insert(text, (0, _clone2.default)(formats)));
  2241. }
  2242. }, {
  2243. key: 'isBlank',
  2244. value: function isBlank() {
  2245. if (this.scroll.children.length == 0) return true;
  2246. if (this.scroll.children.length > 1) return false;
  2247. var block = this.scroll.children.head;
  2248. if (block.statics.blotName !== _block2.default.blotName) return false;
  2249. if (block.children.length > 1) return false;
  2250. return block.children.head instanceof _break2.default;
  2251. }
  2252. }, {
  2253. key: 'removeFormat',
  2254. value: function removeFormat(index, length) {
  2255. var text = this.getText(index, length);
  2256. var _scroll$line3 = this.scroll.line(index + length),
  2257. _scroll$line4 = _slicedToArray(_scroll$line3, 2),
  2258. line = _scroll$line4[0],
  2259. offset = _scroll$line4[1];
  2260. var suffixLength = 0,
  2261. suffix = new _quillDelta2.default();
  2262. if (line != null) {
  2263. if (!(line instanceof _code2.default)) {
  2264. suffixLength = line.length() - offset;
  2265. } else {
  2266. suffixLength = line.newlineIndex(offset) - offset + 1;
  2267. }
  2268. suffix = line.delta().slice(offset, offset + suffixLength - 1).insert('\n');
  2269. }
  2270. var contents = this.getContents(index, length + suffixLength);
  2271. var diff = contents.diff(new _quillDelta2.default().insert(text).concat(suffix));
  2272. var delta = new _quillDelta2.default().retain(index).concat(diff);
  2273. return this.applyDelta(delta);
  2274. }
  2275. }, {
  2276. key: 'update',
  2277. value: function update(change) {
  2278. var mutations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  2279. var cursorIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
  2280. var oldDelta = this.delta;
  2281. if (mutations.length === 1 && mutations[0].type === 'characterData' && mutations[0].target.data.match(ASCII) && _parchment2.default.find(mutations[0].target)) {
  2282. // Optimization for character changes
  2283. var textBlot = _parchment2.default.find(mutations[0].target);
  2284. var formats = (0, _block.bubbleFormats)(textBlot);
  2285. var index = textBlot.offset(this.scroll);
  2286. var oldValue = mutations[0].oldValue.replace(_cursor2.default.CONTENTS, '');
  2287. var oldText = new _quillDelta2.default().insert(oldValue);
  2288. var newText = new _quillDelta2.default().insert(textBlot.value());
  2289. var diffDelta = new _quillDelta2.default().retain(index).concat(oldText.diff(newText, cursorIndex));
  2290. change = diffDelta.reduce(function (delta, op) {
  2291. if (op.insert) {
  2292. return delta.insert(op.insert, formats);
  2293. } else {
  2294. return delta.push(op);
  2295. }
  2296. }, new _quillDelta2.default());
  2297. this.delta = oldDelta.compose(change);
  2298. } else {
  2299. this.delta = this.getDelta();
  2300. if (!change || !(0, _deepEqual2.default)(oldDelta.compose(change), this.delta)) {
  2301. change = oldDelta.diff(this.delta, cursorIndex);
  2302. }
  2303. }
  2304. return change;
  2305. }
  2306. }]);
  2307. return Editor;
  2308. }();
  2309. function combineFormats(formats, combined) {
  2310. return Object.keys(combined).reduce(function (merged, name) {
  2311. if (formats[name] == null) return merged;
  2312. if (combined[name] === formats[name]) {
  2313. merged[name] = combined[name];
  2314. } else if (Array.isArray(combined[name])) {
  2315. if (combined[name].indexOf(formats[name]) < 0) {
  2316. merged[name] = combined[name].concat([formats[name]]);
  2317. }
  2318. } else {
  2319. merged[name] = [combined[name], formats[name]];
  2320. }
  2321. return merged;
  2322. }, {});
  2323. }
  2324. function normalizeDelta(delta) {
  2325. return delta.reduce(function (delta, op) {
  2326. if (op.insert === 1) {
  2327. var attributes = (0, _clone2.default)(op.attributes);
  2328. delete attributes['image'];
  2329. return delta.insert({ image: op.attributes.image }, attributes);
  2330. }
  2331. if (op.attributes != null && (op.attributes.list === true || op.attributes.bullet === true)) {
  2332. op = (0, _clone2.default)(op);
  2333. if (op.attributes.list) {
  2334. op.attributes.list = 'ordered';
  2335. } else {
  2336. op.attributes.list = 'bullet';
  2337. delete op.attributes.bullet;
  2338. }
  2339. }
  2340. if (typeof op.insert === 'string') {
  2341. var text = op.insert.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
  2342. return delta.insert(text, op.attributes);
  2343. }
  2344. return delta.push(op);
  2345. }, new _quillDelta2.default());
  2346. }
  2347. exports.default = Editor;
  2348. /***/ }),
  2349. /* 15 */
  2350. /***/ (function(module, exports, __webpack_require__) {
  2351. "use strict";
  2352. Object.defineProperty(exports, "__esModule", {
  2353. value: true
  2354. });
  2355. exports.default = exports.Range = undefined;
  2356. 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"); } }; }();
  2357. 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; }; }();
  2358. var _parchment = __webpack_require__(0);
  2359. var _parchment2 = _interopRequireDefault(_parchment);
  2360. var _clone = __webpack_require__(21);
  2361. var _clone2 = _interopRequireDefault(_clone);
  2362. var _deepEqual = __webpack_require__(11);
  2363. var _deepEqual2 = _interopRequireDefault(_deepEqual);
  2364. var _emitter3 = __webpack_require__(8);
  2365. var _emitter4 = _interopRequireDefault(_emitter3);
  2366. var _logger = __webpack_require__(10);
  2367. var _logger2 = _interopRequireDefault(_logger);
  2368. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2369. 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); } }
  2370. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2371. var debug = (0, _logger2.default)('quill:selection');
  2372. var Range = function Range(index) {
  2373. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  2374. _classCallCheck(this, Range);
  2375. this.index = index;
  2376. this.length = length;
  2377. };
  2378. var Selection = function () {
  2379. function Selection(scroll, emitter) {
  2380. var _this = this;
  2381. _classCallCheck(this, Selection);
  2382. this.emitter = emitter;
  2383. this.scroll = scroll;
  2384. this.composing = false;
  2385. this.mouseDown = false;
  2386. this.root = this.scroll.domNode;
  2387. this.cursor = _parchment2.default.create('cursor', this);
  2388. // savedRange is last non-null range
  2389. this.lastRange = this.savedRange = new Range(0, 0);
  2390. this.handleComposition();
  2391. this.handleDragging();
  2392. this.emitter.listenDOM('selectionchange', document, function () {
  2393. if (!_this.mouseDown) {
  2394. setTimeout(_this.update.bind(_this, _emitter4.default.sources.USER), 1);
  2395. }
  2396. });
  2397. this.emitter.on(_emitter4.default.events.EDITOR_CHANGE, function (type, delta) {
  2398. if (type === _emitter4.default.events.TEXT_CHANGE && delta.length() > 0) {
  2399. _this.update(_emitter4.default.sources.SILENT);
  2400. }
  2401. });
  2402. this.emitter.on(_emitter4.default.events.SCROLL_BEFORE_UPDATE, function () {
  2403. if (!_this.hasFocus()) return;
  2404. var native = _this.getNativeRange();
  2405. if (native == null) return;
  2406. if (native.start.node === _this.cursor.textNode) return; // cursor.restore() will handle
  2407. // TODO unclear if this has negative side effects
  2408. _this.emitter.once(_emitter4.default.events.SCROLL_UPDATE, function () {
  2409. try {
  2410. _this.setNativeRange(native.start.node, native.start.offset, native.end.node, native.end.offset);
  2411. } catch (ignored) {}
  2412. });
  2413. });
  2414. this.emitter.on(_emitter4.default.events.SCROLL_OPTIMIZE, function (mutations, context) {
  2415. if (context.range) {
  2416. var _context$range = context.range,
  2417. startNode = _context$range.startNode,
  2418. startOffset = _context$range.startOffset,
  2419. endNode = _context$range.endNode,
  2420. endOffset = _context$range.endOffset;
  2421. _this.setNativeRange(startNode, startOffset, endNode, endOffset);
  2422. }
  2423. });
  2424. this.update(_emitter4.default.sources.SILENT);
  2425. }
  2426. _createClass(Selection, [{
  2427. key: 'handleComposition',
  2428. value: function handleComposition() {
  2429. var _this2 = this;
  2430. this.root.addEventListener('compositionstart', function () {
  2431. _this2.composing = true;
  2432. });
  2433. this.root.addEventListener('compositionend', function () {
  2434. _this2.composing = false;
  2435. if (_this2.cursor.parent) {
  2436. var range = _this2.cursor.restore();
  2437. if (!range) return;
  2438. setTimeout(function () {
  2439. _this2.setNativeRange(range.startNode, range.startOffset, range.endNode, range.endOffset);
  2440. }, 1);
  2441. }
  2442. });
  2443. }
  2444. }, {
  2445. key: 'handleDragging',
  2446. value: function handleDragging() {
  2447. var _this3 = this;
  2448. this.emitter.listenDOM('mousedown', document.body, function () {
  2449. _this3.mouseDown = true;
  2450. });
  2451. this.emitter.listenDOM('mouseup', document.body, function () {
  2452. _this3.mouseDown = false;
  2453. _this3.update(_emitter4.default.sources.USER);
  2454. });
  2455. }
  2456. }, {
  2457. key: 'focus',
  2458. value: function focus() {
  2459. if (this.hasFocus()) return;
  2460. this.root.focus();
  2461. this.setRange(this.savedRange);
  2462. }
  2463. }, {
  2464. key: 'format',
  2465. value: function format(_format, value) {
  2466. if (this.scroll.whitelist != null && !this.scroll.whitelist[_format]) return;
  2467. this.scroll.update();
  2468. var nativeRange = this.getNativeRange();
  2469. if (nativeRange == null || !nativeRange.native.collapsed || _parchment2.default.query(_format, _parchment2.default.Scope.BLOCK)) return;
  2470. if (nativeRange.start.node !== this.cursor.textNode) {
  2471. var blot = _parchment2.default.find(nativeRange.start.node, false);
  2472. if (blot == null) return;
  2473. // TODO Give blot ability to not split
  2474. if (blot instanceof _parchment2.default.Leaf) {
  2475. var after = blot.split(nativeRange.start.offset);
  2476. blot.parent.insertBefore(this.cursor, after);
  2477. } else {
  2478. blot.insertBefore(this.cursor, nativeRange.start.node); // Should never happen
  2479. }
  2480. this.cursor.attach();
  2481. }
  2482. this.cursor.format(_format, value);
  2483. this.scroll.optimize();
  2484. this.setNativeRange(this.cursor.textNode, this.cursor.textNode.data.length);
  2485. this.update();
  2486. }
  2487. }, {
  2488. key: 'getBounds',
  2489. value: function getBounds(index) {
  2490. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  2491. var scrollLength = this.scroll.length();
  2492. index = Math.min(index, scrollLength - 1);
  2493. length = Math.min(index + length, scrollLength - 1) - index;
  2494. var node = void 0,
  2495. _scroll$leaf = this.scroll.leaf(index),
  2496. _scroll$leaf2 = _slicedToArray(_scroll$leaf, 2),
  2497. leaf = _scroll$leaf2[0],
  2498. offset = _scroll$leaf2[1];
  2499. if (leaf == null) return null;
  2500. var _leaf$position = leaf.position(offset, true);
  2501. var _leaf$position2 = _slicedToArray(_leaf$position, 2);
  2502. node = _leaf$position2[0];
  2503. offset = _leaf$position2[1];
  2504. var range = document.createRange();
  2505. if (length > 0) {
  2506. range.setStart(node, offset);
  2507. var _scroll$leaf3 = this.scroll.leaf(index + length);
  2508. var _scroll$leaf4 = _slicedToArray(_scroll$leaf3, 2);
  2509. leaf = _scroll$leaf4[0];
  2510. offset = _scroll$leaf4[1];
  2511. if (leaf == null) return null;
  2512. var _leaf$position3 = leaf.position(offset, true);
  2513. var _leaf$position4 = _slicedToArray(_leaf$position3, 2);
  2514. node = _leaf$position4[0];
  2515. offset = _leaf$position4[1];
  2516. range.setEnd(node, offset);
  2517. return range.getBoundingClientRect();
  2518. } else {
  2519. var side = 'left';
  2520. var rect = void 0;
  2521. if (node instanceof Text) {
  2522. if (offset < node.data.length) {
  2523. range.setStart(node, offset);
  2524. range.setEnd(node, offset + 1);
  2525. } else {
  2526. range.setStart(node, offset - 1);
  2527. range.setEnd(node, offset);
  2528. side = 'right';
  2529. }
  2530. rect = range.getBoundingClientRect();
  2531. } else {
  2532. rect = leaf.domNode.getBoundingClientRect();
  2533. if (offset > 0) side = 'right';
  2534. }
  2535. return {
  2536. bottom: rect.top + rect.height,
  2537. height: rect.height,
  2538. left: rect[side],
  2539. right: rect[side],
  2540. top: rect.top,
  2541. width: 0
  2542. };
  2543. }
  2544. }
  2545. }, {
  2546. key: 'getNativeRange',
  2547. value: function getNativeRange() {
  2548. var selection = document.getSelection();
  2549. if (selection == null || selection.rangeCount <= 0) return null;
  2550. var nativeRange = selection.getRangeAt(0);
  2551. if (nativeRange == null) return null;
  2552. var range = this.normalizeNative(nativeRange);
  2553. debug.info('getNativeRange', range);
  2554. return range;
  2555. }
  2556. }, {
  2557. key: 'getRange',
  2558. value: function getRange() {
  2559. var normalized = this.getNativeRange();
  2560. if (normalized == null) return [null, null];
  2561. var range = this.normalizedToRange(normalized);
  2562. return [range, normalized];
  2563. }
  2564. }, {
  2565. key: 'hasFocus',
  2566. value: function hasFocus() {
  2567. return document.activeElement === this.root;
  2568. }
  2569. }, {
  2570. key: 'normalizedToRange',
  2571. value: function normalizedToRange(range) {
  2572. var _this4 = this;
  2573. var positions = [[range.start.node, range.start.offset]];
  2574. if (!range.native.collapsed) {
  2575. positions.push([range.end.node, range.end.offset]);
  2576. }
  2577. var indexes = positions.map(function (position) {
  2578. var _position = _slicedToArray(position, 2),
  2579. node = _position[0],
  2580. offset = _position[1];
  2581. var blot = _parchment2.default.find(node, true);
  2582. var index = blot.offset(_this4.scroll);
  2583. if (offset === 0) {
  2584. return index;
  2585. } else if (blot instanceof _parchment2.default.Container) {
  2586. return index + blot.length();
  2587. } else {
  2588. return index + blot.index(node, offset);
  2589. }
  2590. });
  2591. var end = Math.min(Math.max.apply(Math, _toConsumableArray(indexes)), this.scroll.length() - 1);
  2592. var start = Math.min.apply(Math, [end].concat(_toConsumableArray(indexes)));
  2593. return new Range(start, end - start);
  2594. }
  2595. }, {
  2596. key: 'normalizeNative',
  2597. value: function normalizeNative(nativeRange) {
  2598. if (!contains(this.root, nativeRange.startContainer) || !nativeRange.collapsed && !contains(this.root, nativeRange.endContainer)) {
  2599. return null;
  2600. }
  2601. var range = {
  2602. start: { node: nativeRange.startContainer, offset: nativeRange.startOffset },
  2603. end: { node: nativeRange.endContainer, offset: nativeRange.endOffset },
  2604. native: nativeRange
  2605. };
  2606. [range.start, range.end].forEach(function (position) {
  2607. var node = position.node,
  2608. offset = position.offset;
  2609. while (!(node instanceof Text) && node.childNodes.length > 0) {
  2610. if (node.childNodes.length > offset) {
  2611. node = node.childNodes[offset];
  2612. offset = 0;
  2613. } else if (node.childNodes.length === offset) {
  2614. node = node.lastChild;
  2615. offset = node instanceof Text ? node.data.length : node.childNodes.length + 1;
  2616. } else {
  2617. break;
  2618. }
  2619. }
  2620. position.node = node, position.offset = offset;
  2621. });
  2622. return range;
  2623. }
  2624. }, {
  2625. key: 'rangeToNative',
  2626. value: function rangeToNative(range) {
  2627. var _this5 = this;
  2628. var indexes = range.collapsed ? [range.index] : [range.index, range.index + range.length];
  2629. var args = [];
  2630. var scrollLength = this.scroll.length();
  2631. indexes.forEach(function (index, i) {
  2632. index = Math.min(scrollLength - 1, index);
  2633. var node = void 0,
  2634. _scroll$leaf5 = _this5.scroll.leaf(index),
  2635. _scroll$leaf6 = _slicedToArray(_scroll$leaf5, 2),
  2636. leaf = _scroll$leaf6[0],
  2637. offset = _scroll$leaf6[1];
  2638. var _leaf$position5 = leaf.position(offset, i !== 0);
  2639. var _leaf$position6 = _slicedToArray(_leaf$position5, 2);
  2640. node = _leaf$position6[0];
  2641. offset = _leaf$position6[1];
  2642. args.push(node, offset);
  2643. });
  2644. if (args.length < 2) {
  2645. args = args.concat(args);
  2646. }
  2647. return args;
  2648. }
  2649. }, {
  2650. key: 'scrollIntoView',
  2651. value: function scrollIntoView(scrollingContainer) {
  2652. var range = this.lastRange;
  2653. if (range == null) return;
  2654. var bounds = this.getBounds(range.index, range.length);
  2655. if (bounds == null) return;
  2656. var limit = this.scroll.length() - 1;
  2657. var _scroll$line = this.scroll.line(Math.min(range.index, limit)),
  2658. _scroll$line2 = _slicedToArray(_scroll$line, 1),
  2659. first = _scroll$line2[0];
  2660. var last = first;
  2661. if (range.length > 0) {
  2662. var _scroll$line3 = this.scroll.line(Math.min(range.index + range.length, limit));
  2663. var _scroll$line4 = _slicedToArray(_scroll$line3, 1);
  2664. last = _scroll$line4[0];
  2665. }
  2666. if (first == null || last == null) return;
  2667. var scrollBounds = scrollingContainer.getBoundingClientRect();
  2668. if (bounds.top < scrollBounds.top) {
  2669. scrollingContainer.scrollTop -= scrollBounds.top - bounds.top;
  2670. } else if (bounds.bottom > scrollBounds.bottom) {
  2671. scrollingContainer.scrollTop += bounds.bottom - scrollBounds.bottom;
  2672. }
  2673. }
  2674. }, {
  2675. key: 'setNativeRange',
  2676. value: function setNativeRange(startNode, startOffset) {
  2677. var endNode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : startNode;
  2678. var endOffset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : startOffset;
  2679. var force = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  2680. debug.info('setNativeRange', startNode, startOffset, endNode, endOffset);
  2681. if (startNode != null && (this.root.parentNode == null || startNode.parentNode == null || endNode.parentNode == null)) {
  2682. return;
  2683. }
  2684. var selection = document.getSelection();
  2685. if (selection == null) return;
  2686. if (startNode != null) {
  2687. if (!this.hasFocus()) this.root.focus();
  2688. var native = (this.getNativeRange() || {}).native;
  2689. if (native == null || force || startNode !== native.startContainer || startOffset !== native.startOffset || endNode !== native.endContainer || endOffset !== native.endOffset) {
  2690. if (startNode.tagName == "BR") {
  2691. startOffset = [].indexOf.call(startNode.parentNode.childNodes, startNode);
  2692. startNode = startNode.parentNode;
  2693. }
  2694. if (endNode.tagName == "BR") {
  2695. endOffset = [].indexOf.call(endNode.parentNode.childNodes, endNode);
  2696. endNode = endNode.parentNode;
  2697. }
  2698. var range = document.createRange();
  2699. range.setStart(startNode, startOffset);
  2700. range.setEnd(endNode, endOffset);
  2701. selection.removeAllRanges();
  2702. selection.addRange(range);
  2703. }
  2704. } else {
  2705. selection.removeAllRanges();
  2706. this.root.blur();
  2707. document.body.focus(); // root.blur() not enough on IE11+Travis+SauceLabs (but not local VMs)
  2708. }
  2709. }
  2710. }, {
  2711. key: 'setRange',
  2712. value: function setRange(range) {
  2713. var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2714. var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _emitter4.default.sources.API;
  2715. if (typeof force === 'string') {
  2716. source = force;
  2717. force = false;
  2718. }
  2719. debug.info('setRange', range);
  2720. if (range != null) {
  2721. var args = this.rangeToNative(range);
  2722. this.setNativeRange.apply(this, _toConsumableArray(args).concat([force]));
  2723. } else {
  2724. this.setNativeRange(null);
  2725. }
  2726. this.update(source);
  2727. }
  2728. }, {
  2729. key: 'update',
  2730. value: function update() {
  2731. var source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _emitter4.default.sources.USER;
  2732. var oldRange = this.lastRange;
  2733. var _getRange = this.getRange(),
  2734. _getRange2 = _slicedToArray(_getRange, 2),
  2735. lastRange = _getRange2[0],
  2736. nativeRange = _getRange2[1];
  2737. this.lastRange = lastRange;
  2738. if (this.lastRange != null) {
  2739. this.savedRange = this.lastRange;
  2740. }
  2741. if (!(0, _deepEqual2.default)(oldRange, this.lastRange)) {
  2742. var _emitter;
  2743. if (!this.composing && nativeRange != null && nativeRange.native.collapsed && nativeRange.start.node !== this.cursor.textNode) {
  2744. this.cursor.restore();
  2745. }
  2746. var args = [_emitter4.default.events.SELECTION_CHANGE, (0, _clone2.default)(this.lastRange), (0, _clone2.default)(oldRange), source];
  2747. (_emitter = this.emitter).emit.apply(_emitter, [_emitter4.default.events.EDITOR_CHANGE].concat(args));
  2748. if (source !== _emitter4.default.sources.SILENT) {
  2749. var _emitter2;
  2750. (_emitter2 = this.emitter).emit.apply(_emitter2, args);
  2751. }
  2752. }
  2753. }
  2754. }]);
  2755. return Selection;
  2756. }();
  2757. function contains(parent, descendant) {
  2758. try {
  2759. // Firefox inserts inaccessible nodes around video elements
  2760. descendant.parentNode;
  2761. } catch (e) {
  2762. return false;
  2763. }
  2764. // IE11 has bug with Text nodes
  2765. // https://connect.microsoft.com/IE/feedback/details/780874/node-contains-is-incorrect
  2766. if (descendant instanceof Text) {
  2767. descendant = descendant.parentNode;
  2768. }
  2769. return parent.contains(descendant);
  2770. }
  2771. exports.Range = Range;
  2772. exports.default = Selection;
  2773. /***/ }),
  2774. /* 16 */
  2775. /***/ (function(module, exports, __webpack_require__) {
  2776. "use strict";
  2777. Object.defineProperty(exports, "__esModule", {
  2778. value: true
  2779. });
  2780. 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; }; }();
  2781. 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); } };
  2782. var _parchment = __webpack_require__(0);
  2783. var _parchment2 = _interopRequireDefault(_parchment);
  2784. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2785. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2786. 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; }
  2787. 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; }
  2788. var Break = function (_Parchment$Embed) {
  2789. _inherits(Break, _Parchment$Embed);
  2790. function Break() {
  2791. _classCallCheck(this, Break);
  2792. return _possibleConstructorReturn(this, (Break.__proto__ || Object.getPrototypeOf(Break)).apply(this, arguments));
  2793. }
  2794. _createClass(Break, [{
  2795. key: 'insertInto',
  2796. value: function insertInto(parent, ref) {
  2797. if (parent.children.length === 0) {
  2798. _get(Break.prototype.__proto__ || Object.getPrototypeOf(Break.prototype), 'insertInto', this).call(this, parent, ref);
  2799. } else {
  2800. this.remove();
  2801. }
  2802. }
  2803. }, {
  2804. key: 'length',
  2805. value: function length() {
  2806. return 0;
  2807. }
  2808. }, {
  2809. key: 'value',
  2810. value: function value() {
  2811. return '';
  2812. }
  2813. }], [{
  2814. key: 'value',
  2815. value: function value() {
  2816. return undefined;
  2817. }
  2818. }]);
  2819. return Break;
  2820. }(_parchment2.default.Embed);
  2821. Break.blotName = 'break';
  2822. Break.tagName = 'BR';
  2823. exports.default = Break;
  2824. /***/ }),
  2825. /* 17 */
  2826. /***/ (function(module, exports, __webpack_require__) {
  2827. "use strict";
  2828. var __extends = (this && this.__extends) || (function () {
  2829. var extendStatics = Object.setPrototypeOf ||
  2830. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2831. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2832. return function (d, b) {
  2833. extendStatics(d, b);
  2834. function __() { this.constructor = d; }
  2835. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2836. };
  2837. })();
  2838. Object.defineProperty(exports, "__esModule", { value: true });
  2839. var linked_list_1 = __webpack_require__(44);
  2840. var shadow_1 = __webpack_require__(30);
  2841. var Registry = __webpack_require__(1);
  2842. var ContainerBlot = /** @class */ (function (_super) {
  2843. __extends(ContainerBlot, _super);
  2844. function ContainerBlot(domNode) {
  2845. var _this = _super.call(this, domNode) || this;
  2846. _this.build();
  2847. return _this;
  2848. }
  2849. ContainerBlot.prototype.appendChild = function (other) {
  2850. this.insertBefore(other);
  2851. };
  2852. ContainerBlot.prototype.attach = function () {
  2853. _super.prototype.attach.call(this);
  2854. this.children.forEach(function (child) {
  2855. child.attach();
  2856. });
  2857. };
  2858. ContainerBlot.prototype.build = function () {
  2859. var _this = this;
  2860. this.children = new linked_list_1.default();
  2861. // Need to be reversed for if DOM nodes already in order
  2862. [].slice
  2863. .call(this.domNode.childNodes)
  2864. .reverse()
  2865. .forEach(function (node) {
  2866. try {
  2867. var child = makeBlot(node);
  2868. _this.insertBefore(child, _this.children.head || undefined);
  2869. }
  2870. catch (err) {
  2871. if (err instanceof Registry.ParchmentError)
  2872. return;
  2873. else
  2874. throw err;
  2875. }
  2876. });
  2877. };
  2878. ContainerBlot.prototype.deleteAt = function (index, length) {
  2879. if (index === 0 && length === this.length()) {
  2880. return this.remove();
  2881. }
  2882. this.children.forEachAt(index, length, function (child, offset, length) {
  2883. child.deleteAt(offset, length);
  2884. });
  2885. };
  2886. ContainerBlot.prototype.descendant = function (criteria, index) {
  2887. var _a = this.children.find(index), child = _a[0], offset = _a[1];
  2888. if ((criteria.blotName == null && criteria(child)) ||
  2889. (criteria.blotName != null && child instanceof criteria)) {
  2890. return [child, offset];
  2891. }
  2892. else if (child instanceof ContainerBlot) {
  2893. return child.descendant(criteria, offset);
  2894. }
  2895. else {
  2896. return [null, -1];
  2897. }
  2898. };
  2899. ContainerBlot.prototype.descendants = function (criteria, index, length) {
  2900. if (index === void 0) { index = 0; }
  2901. if (length === void 0) { length = Number.MAX_VALUE; }
  2902. var descendants = [];
  2903. var lengthLeft = length;
  2904. this.children.forEachAt(index, length, function (child, index, length) {
  2905. if ((criteria.blotName == null && criteria(child)) ||
  2906. (criteria.blotName != null && child instanceof criteria)) {
  2907. descendants.push(child);
  2908. }
  2909. if (child instanceof ContainerBlot) {
  2910. descendants = descendants.concat(child.descendants(criteria, index, lengthLeft));
  2911. }
  2912. lengthLeft -= length;
  2913. });
  2914. return descendants;
  2915. };
  2916. ContainerBlot.prototype.detach = function () {
  2917. this.children.forEach(function (child) {
  2918. child.detach();
  2919. });
  2920. _super.prototype.detach.call(this);
  2921. };
  2922. ContainerBlot.prototype.formatAt = function (index, length, name, value) {
  2923. this.children.forEachAt(index, length, function (child, offset, length) {
  2924. child.formatAt(offset, length, name, value);
  2925. });
  2926. };
  2927. ContainerBlot.prototype.insertAt = function (index, value, def) {
  2928. var _a = this.children.find(index), child = _a[0], offset = _a[1];
  2929. if (child) {
  2930. child.insertAt(offset, value, def);
  2931. }
  2932. else {
  2933. var blot = def == null ? Registry.create('text', value) : Registry.create(value, def);
  2934. this.appendChild(blot);
  2935. }
  2936. };
  2937. ContainerBlot.prototype.insertBefore = function (childBlot, refBlot) {
  2938. if (this.statics.allowedChildren != null &&
  2939. !this.statics.allowedChildren.some(function (child) {
  2940. return childBlot instanceof child;
  2941. })) {
  2942. throw new Registry.ParchmentError("Cannot insert " + childBlot.statics.blotName + " into " + this.statics.blotName);
  2943. }
  2944. childBlot.insertInto(this, refBlot);
  2945. };
  2946. ContainerBlot.prototype.length = function () {
  2947. return this.children.reduce(function (memo, child) {
  2948. return memo + child.length();
  2949. }, 0);
  2950. };
  2951. ContainerBlot.prototype.moveChildren = function (targetParent, refNode) {
  2952. this.children.forEach(function (child) {
  2953. targetParent.insertBefore(child, refNode);
  2954. });
  2955. };
  2956. ContainerBlot.prototype.optimize = function (context) {
  2957. _super.prototype.optimize.call(this, context);
  2958. if (this.children.length === 0) {
  2959. if (this.statics.defaultChild != null) {
  2960. var child = Registry.create(this.statics.defaultChild);
  2961. this.appendChild(child);
  2962. child.optimize(context);
  2963. }
  2964. else {
  2965. this.remove();
  2966. }
  2967. }
  2968. };
  2969. ContainerBlot.prototype.path = function (index, inclusive) {
  2970. if (inclusive === void 0) { inclusive = false; }
  2971. var _a = this.children.find(index, inclusive), child = _a[0], offset = _a[1];
  2972. var position = [[this, index]];
  2973. if (child instanceof ContainerBlot) {
  2974. return position.concat(child.path(offset, inclusive));
  2975. }
  2976. else if (child != null) {
  2977. position.push([child, offset]);
  2978. }
  2979. return position;
  2980. };
  2981. ContainerBlot.prototype.removeChild = function (child) {
  2982. this.children.remove(child);
  2983. };
  2984. ContainerBlot.prototype.replace = function (target) {
  2985. if (target instanceof ContainerBlot) {
  2986. target.moveChildren(this);
  2987. }
  2988. _super.prototype.replace.call(this, target);
  2989. };
  2990. ContainerBlot.prototype.split = function (index, force) {
  2991. if (force === void 0) { force = false; }
  2992. if (!force) {
  2993. if (index === 0)
  2994. return this;
  2995. if (index === this.length())
  2996. return this.next;
  2997. }
  2998. var after = this.clone();
  2999. this.parent.insertBefore(after, this.next);
  3000. this.children.forEachAt(index, this.length(), function (child, offset, length) {
  3001. child = child.split(offset, force);
  3002. after.appendChild(child);
  3003. });
  3004. return after;
  3005. };
  3006. ContainerBlot.prototype.unwrap = function () {
  3007. this.moveChildren(this.parent, this.next);
  3008. this.remove();
  3009. };
  3010. ContainerBlot.prototype.update = function (mutations, context) {
  3011. var _this = this;
  3012. var addedNodes = [];
  3013. var removedNodes = [];
  3014. mutations.forEach(function (mutation) {
  3015. if (mutation.target === _this.domNode && mutation.type === 'childList') {
  3016. addedNodes.push.apply(addedNodes, mutation.addedNodes);
  3017. removedNodes.push.apply(removedNodes, mutation.removedNodes);
  3018. }
  3019. });
  3020. removedNodes.forEach(function (node) {
  3021. // Check node has actually been removed
  3022. // One exception is Chrome does not immediately remove IFRAMEs
  3023. // from DOM but MutationRecord is correct in its reported removal
  3024. if (node.parentNode != null &&
  3025. // @ts-ignore
  3026. node.tagName !== 'IFRAME' &&
  3027. document.body.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_CONTAINED_BY) {
  3028. return;
  3029. }
  3030. var blot = Registry.find(node);
  3031. if (blot == null)
  3032. return;
  3033. if (blot.domNode.parentNode == null || blot.domNode.parentNode === _this.domNode) {
  3034. blot.detach();
  3035. }
  3036. });
  3037. addedNodes
  3038. .filter(function (node) {
  3039. return node.parentNode == _this.domNode;
  3040. })
  3041. .sort(function (a, b) {
  3042. if (a === b)
  3043. return 0;
  3044. if (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING) {
  3045. return 1;
  3046. }
  3047. return -1;
  3048. })
  3049. .forEach(function (node) {
  3050. var refBlot = null;
  3051. if (node.nextSibling != null) {
  3052. refBlot = Registry.find(node.nextSibling);
  3053. }
  3054. var blot = makeBlot(node);
  3055. if (blot.next != refBlot || blot.next == null) {
  3056. if (blot.parent != null) {
  3057. blot.parent.removeChild(_this);
  3058. }
  3059. _this.insertBefore(blot, refBlot || undefined);
  3060. }
  3061. });
  3062. };
  3063. return ContainerBlot;
  3064. }(shadow_1.default));
  3065. function makeBlot(node) {
  3066. var blot = Registry.find(node);
  3067. if (blot == null) {
  3068. try {
  3069. blot = Registry.create(node);
  3070. }
  3071. catch (e) {
  3072. blot = Registry.create(Registry.Scope.INLINE);
  3073. [].slice.call(node.childNodes).forEach(function (child) {
  3074. // @ts-ignore
  3075. blot.domNode.appendChild(child);
  3076. });
  3077. if (node.parentNode) {
  3078. node.parentNode.replaceChild(blot.domNode, node);
  3079. }
  3080. blot.attach();
  3081. }
  3082. }
  3083. return blot;
  3084. }
  3085. exports.default = ContainerBlot;
  3086. /***/ }),
  3087. /* 18 */
  3088. /***/ (function(module, exports, __webpack_require__) {
  3089. "use strict";
  3090. var __extends = (this && this.__extends) || (function () {
  3091. var extendStatics = Object.setPrototypeOf ||
  3092. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3093. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3094. return function (d, b) {
  3095. extendStatics(d, b);
  3096. function __() { this.constructor = d; }
  3097. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3098. };
  3099. })();
  3100. Object.defineProperty(exports, "__esModule", { value: true });
  3101. var attributor_1 = __webpack_require__(12);
  3102. var store_1 = __webpack_require__(31);
  3103. var container_1 = __webpack_require__(17);
  3104. var Registry = __webpack_require__(1);
  3105. var FormatBlot = /** @class */ (function (_super) {
  3106. __extends(FormatBlot, _super);
  3107. function FormatBlot(domNode) {
  3108. var _this = _super.call(this, domNode) || this;
  3109. _this.attributes = new store_1.default(_this.domNode);
  3110. return _this;
  3111. }
  3112. FormatBlot.formats = function (domNode) {
  3113. if (typeof this.tagName === 'string') {
  3114. return true;
  3115. }
  3116. else if (Array.isArray(this.tagName)) {
  3117. return domNode.tagName.toLowerCase();
  3118. }
  3119. return undefined;
  3120. };
  3121. FormatBlot.prototype.format = function (name, value) {
  3122. var format = Registry.query(name);
  3123. if (format instanceof attributor_1.default) {
  3124. this.attributes.attribute(format, value);
  3125. }
  3126. else if (value) {
  3127. if (format != null && (name !== this.statics.blotName || this.formats()[name] !== value)) {
  3128. this.replaceWith(name, value);
  3129. }
  3130. }
  3131. };
  3132. FormatBlot.prototype.formats = function () {
  3133. var formats = this.attributes.values();
  3134. var format = this.statics.formats(this.domNode);
  3135. if (format != null) {
  3136. formats[this.statics.blotName] = format;
  3137. }
  3138. return formats;
  3139. };
  3140. FormatBlot.prototype.replaceWith = function (name, value) {
  3141. var replacement = _super.prototype.replaceWith.call(this, name, value);
  3142. this.attributes.copy(replacement);
  3143. return replacement;
  3144. };
  3145. FormatBlot.prototype.update = function (mutations, context) {
  3146. var _this = this;
  3147. _super.prototype.update.call(this, mutations, context);
  3148. if (mutations.some(function (mutation) {
  3149. return mutation.target === _this.domNode && mutation.type === 'attributes';
  3150. })) {
  3151. this.attributes.build();
  3152. }
  3153. };
  3154. FormatBlot.prototype.wrap = function (name, value) {
  3155. var wrapper = _super.prototype.wrap.call(this, name, value);
  3156. if (wrapper instanceof FormatBlot && wrapper.statics.scope === this.statics.scope) {
  3157. this.attributes.move(wrapper);
  3158. }
  3159. return wrapper;
  3160. };
  3161. return FormatBlot;
  3162. }(container_1.default));
  3163. exports.default = FormatBlot;
  3164. /***/ }),
  3165. /* 19 */
  3166. /***/ (function(module, exports, __webpack_require__) {
  3167. "use strict";
  3168. var __extends = (this && this.__extends) || (function () {
  3169. var extendStatics = Object.setPrototypeOf ||
  3170. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3171. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3172. return function (d, b) {
  3173. extendStatics(d, b);
  3174. function __() { this.constructor = d; }
  3175. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3176. };
  3177. })();
  3178. Object.defineProperty(exports, "__esModule", { value: true });
  3179. var shadow_1 = __webpack_require__(30);
  3180. var Registry = __webpack_require__(1);
  3181. var LeafBlot = /** @class */ (function (_super) {
  3182. __extends(LeafBlot, _super);
  3183. function LeafBlot() {
  3184. return _super !== null && _super.apply(this, arguments) || this;
  3185. }
  3186. LeafBlot.value = function (domNode) {
  3187. return true;
  3188. };
  3189. LeafBlot.prototype.index = function (node, offset) {
  3190. if (this.domNode === node ||
  3191. this.domNode.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_CONTAINED_BY) {
  3192. return Math.min(offset, 1);
  3193. }
  3194. return -1;
  3195. };
  3196. LeafBlot.prototype.position = function (index, inclusive) {
  3197. var offset = [].indexOf.call(this.parent.domNode.childNodes, this.domNode);
  3198. if (index > 0)
  3199. offset += 1;
  3200. return [this.parent.domNode, offset];
  3201. };
  3202. LeafBlot.prototype.value = function () {
  3203. return _a = {}, _a[this.statics.blotName] = this.statics.value(this.domNode) || true, _a;
  3204. var _a;
  3205. };
  3206. LeafBlot.scope = Registry.Scope.INLINE_BLOT;
  3207. return LeafBlot;
  3208. }(shadow_1.default));
  3209. exports.default = LeafBlot;
  3210. /***/ }),
  3211. /* 20 */
  3212. /***/ (function(module, exports, __webpack_require__) {
  3213. var equal = __webpack_require__(11);
  3214. var extend = __webpack_require__(3);
  3215. var lib = {
  3216. attributes: {
  3217. compose: function (a, b, keepNull) {
  3218. if (typeof a !== 'object') a = {};
  3219. if (typeof b !== 'object') b = {};
  3220. var attributes = extend(true, {}, b);
  3221. if (!keepNull) {
  3222. attributes = Object.keys(attributes).reduce(function (copy, key) {
  3223. if (attributes[key] != null) {
  3224. copy[key] = attributes[key];
  3225. }
  3226. return copy;
  3227. }, {});
  3228. }
  3229. for (var key in a) {
  3230. if (a[key] !== undefined && b[key] === undefined) {
  3231. attributes[key] = a[key];
  3232. }
  3233. }
  3234. return Object.keys(attributes).length > 0 ? attributes : undefined;
  3235. },
  3236. diff: function(a, b) {
  3237. if (typeof a !== 'object') a = {};
  3238. if (typeof b !== 'object') b = {};
  3239. var attributes = Object.keys(a).concat(Object.keys(b)).reduce(function (attributes, key) {
  3240. if (!equal(a[key], b[key])) {
  3241. attributes[key] = b[key] === undefined ? null : b[key];
  3242. }
  3243. return attributes;
  3244. }, {});
  3245. return Object.keys(attributes).length > 0 ? attributes : undefined;
  3246. },
  3247. transform: function (a, b, priority) {
  3248. if (typeof a !== 'object') return b;
  3249. if (typeof b !== 'object') return undefined;
  3250. if (!priority) return b; // b simply overwrites us without priority
  3251. var attributes = Object.keys(b).reduce(function (attributes, key) {
  3252. if (a[key] === undefined) attributes[key] = b[key]; // null is a valid value
  3253. return attributes;
  3254. }, {});
  3255. return Object.keys(attributes).length > 0 ? attributes : undefined;
  3256. }
  3257. },
  3258. iterator: function (ops) {
  3259. return new Iterator(ops);
  3260. },
  3261. length: function (op) {
  3262. if (typeof op['delete'] === 'number') {
  3263. return op['delete'];
  3264. } else if (typeof op.retain === 'number') {
  3265. return op.retain;
  3266. } else {
  3267. return typeof op.insert === 'string' ? op.insert.length : 1;
  3268. }
  3269. }
  3270. };
  3271. function Iterator(ops) {
  3272. this.ops = ops;
  3273. this.index = 0;
  3274. this.offset = 0;
  3275. };
  3276. Iterator.prototype.hasNext = function () {
  3277. return this.peekLength() < Infinity;
  3278. };
  3279. Iterator.prototype.next = function (length) {
  3280. if (!length) length = Infinity;
  3281. var nextOp = this.ops[this.index];
  3282. if (nextOp) {
  3283. var offset = this.offset;
  3284. var opLength = lib.length(nextOp)
  3285. if (length >= opLength - offset) {
  3286. length = opLength - offset;
  3287. this.index += 1;
  3288. this.offset = 0;
  3289. } else {
  3290. this.offset += length;
  3291. }
  3292. if (typeof nextOp['delete'] === 'number') {
  3293. return { 'delete': length };
  3294. } else {
  3295. var retOp = {};
  3296. if (nextOp.attributes) {
  3297. retOp.attributes = nextOp.attributes;
  3298. }
  3299. if (typeof nextOp.retain === 'number') {
  3300. retOp.retain = length;
  3301. } else if (typeof nextOp.insert === 'string') {
  3302. retOp.insert = nextOp.insert.substr(offset, length);
  3303. } else {
  3304. // offset should === 0, length should === 1
  3305. retOp.insert = nextOp.insert;
  3306. }
  3307. return retOp;
  3308. }
  3309. } else {
  3310. return { retain: Infinity };
  3311. }
  3312. };
  3313. Iterator.prototype.peek = function () {
  3314. return this.ops[this.index];
  3315. };
  3316. Iterator.prototype.peekLength = function () {
  3317. if (this.ops[this.index]) {
  3318. // Should never return 0 if our index is being managed correctly
  3319. return lib.length(this.ops[this.index]) - this.offset;
  3320. } else {
  3321. return Infinity;
  3322. }
  3323. };
  3324. Iterator.prototype.peekType = function () {
  3325. if (this.ops[this.index]) {
  3326. if (typeof this.ops[this.index]['delete'] === 'number') {
  3327. return 'delete';
  3328. } else if (typeof this.ops[this.index].retain === 'number') {
  3329. return 'retain';
  3330. } else {
  3331. return 'insert';
  3332. }
  3333. }
  3334. return 'retain';
  3335. };
  3336. module.exports = lib;
  3337. /***/ }),
  3338. /* 21 */
  3339. /***/ (function(module, exports) {
  3340. var clone = (function() {
  3341. 'use strict';
  3342. function _instanceof(obj, type) {
  3343. return type != null && obj instanceof type;
  3344. }
  3345. var nativeMap;
  3346. try {
  3347. nativeMap = Map;
  3348. } catch(_) {
  3349. // maybe a reference error because no `Map`. Give it a dummy value that no
  3350. // value will ever be an instanceof.
  3351. nativeMap = function() {};
  3352. }
  3353. var nativeSet;
  3354. try {
  3355. nativeSet = Set;
  3356. } catch(_) {
  3357. nativeSet = function() {};
  3358. }
  3359. var nativePromise;
  3360. try {
  3361. nativePromise = Promise;
  3362. } catch(_) {
  3363. nativePromise = function() {};
  3364. }
  3365. /**
  3366. * Clones (copies) an Object using deep copying.
  3367. *
  3368. * This function supports circular references by default, but if you are certain
  3369. * there are no circular references in your object, you can save some CPU time
  3370. * by calling clone(obj, false).
  3371. *
  3372. * Caution: if `circular` is false and `parent` contains circular references,
  3373. * your program may enter an infinite loop and crash.
  3374. *
  3375. * @param `parent` - the object to be cloned
  3376. * @param `circular` - set to true if the object to be cloned may contain
  3377. * circular references. (optional - true by default)
  3378. * @param `depth` - set to a number if the object is only to be cloned to
  3379. * a particular depth. (optional - defaults to Infinity)
  3380. * @param `prototype` - sets the prototype to be used when cloning an object.
  3381. * (optional - defaults to parent prototype).
  3382. * @param `includeNonEnumerable` - set to true if the non-enumerable properties
  3383. * should be cloned as well. Non-enumerable properties on the prototype
  3384. * chain will be ignored. (optional - false by default)
  3385. */
  3386. function clone(parent, circular, depth, prototype, includeNonEnumerable) {
  3387. if (typeof circular === 'object') {
  3388. depth = circular.depth;
  3389. prototype = circular.prototype;
  3390. includeNonEnumerable = circular.includeNonEnumerable;
  3391. circular = circular.circular;
  3392. }
  3393. // maintain two arrays for circular references, where corresponding parents
  3394. // and children have the same index
  3395. var allParents = [];
  3396. var allChildren = [];
  3397. var useBuffer = typeof Buffer != 'undefined';
  3398. if (typeof circular == 'undefined')
  3399. circular = true;
  3400. if (typeof depth == 'undefined')
  3401. depth = Infinity;
  3402. // recurse this function so we don't reset allParents and allChildren
  3403. function _clone(parent, depth) {
  3404. // cloning null always returns null
  3405. if (parent === null)
  3406. return null;
  3407. if (depth === 0)
  3408. return parent;
  3409. var child;
  3410. var proto;
  3411. if (typeof parent != 'object') {
  3412. return parent;
  3413. }
  3414. if (_instanceof(parent, nativeMap)) {
  3415. child = new nativeMap();
  3416. } else if (_instanceof(parent, nativeSet)) {
  3417. child = new nativeSet();
  3418. } else if (_instanceof(parent, nativePromise)) {
  3419. child = new nativePromise(function (resolve, reject) {
  3420. parent.then(function(value) {
  3421. resolve(_clone(value, depth - 1));
  3422. }, function(err) {
  3423. reject(_clone(err, depth - 1));
  3424. });
  3425. });
  3426. } else if (clone.__isArray(parent)) {
  3427. child = [];
  3428. } else if (clone.__isRegExp(parent)) {
  3429. child = new RegExp(parent.source, __getRegExpFlags(parent));
  3430. if (parent.lastIndex) child.lastIndex = parent.lastIndex;
  3431. } else if (clone.__isDate(parent)) {
  3432. child = new Date(parent.getTime());
  3433. } else if (useBuffer && Buffer.isBuffer(parent)) {
  3434. child = new Buffer(parent.length);
  3435. parent.copy(child);
  3436. return child;
  3437. } else if (_instanceof(parent, Error)) {
  3438. child = Object.create(parent);
  3439. } else {
  3440. if (typeof prototype == 'undefined') {
  3441. proto = Object.getPrototypeOf(parent);
  3442. child = Object.create(proto);
  3443. }
  3444. else {
  3445. child = Object.create(prototype);
  3446. proto = prototype;
  3447. }
  3448. }
  3449. if (circular) {
  3450. var index = allParents.indexOf(parent);
  3451. if (index != -1) {
  3452. return allChildren[index];
  3453. }
  3454. allParents.push(parent);
  3455. allChildren.push(child);
  3456. }
  3457. if (_instanceof(parent, nativeMap)) {
  3458. parent.forEach(function(value, key) {
  3459. var keyChild = _clone(key, depth - 1);
  3460. var valueChild = _clone(value, depth - 1);
  3461. child.set(keyChild, valueChild);
  3462. });
  3463. }
  3464. if (_instanceof(parent, nativeSet)) {
  3465. parent.forEach(function(value) {
  3466. var entryChild = _clone(value, depth - 1);
  3467. child.add(entryChild);
  3468. });
  3469. }
  3470. for (var i in parent) {
  3471. var attrs;
  3472. if (proto) {
  3473. attrs = Object.getOwnPropertyDescriptor(proto, i);
  3474. }
  3475. if (attrs && attrs.set == null) {
  3476. continue;
  3477. }
  3478. child[i] = _clone(parent[i], depth - 1);
  3479. }
  3480. if (Object.getOwnPropertySymbols) {
  3481. var symbols = Object.getOwnPropertySymbols(parent);
  3482. for (var i = 0; i < symbols.length; i++) {
  3483. // Don't need to worry about cloning a symbol because it is a primitive,
  3484. // like a number or string.
  3485. var symbol = symbols[i];
  3486. var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
  3487. if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
  3488. continue;
  3489. }
  3490. child[symbol] = _clone(parent[symbol], depth - 1);
  3491. if (!descriptor.enumerable) {
  3492. Object.defineProperty(child, symbol, {
  3493. enumerable: false
  3494. });
  3495. }
  3496. }
  3497. }
  3498. if (includeNonEnumerable) {
  3499. var allPropertyNames = Object.getOwnPropertyNames(parent);
  3500. for (var i = 0; i < allPropertyNames.length; i++) {
  3501. var propertyName = allPropertyNames[i];
  3502. var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
  3503. if (descriptor && descriptor.enumerable) {
  3504. continue;
  3505. }
  3506. child[propertyName] = _clone(parent[propertyName], depth - 1);
  3507. Object.defineProperty(child, propertyName, {
  3508. enumerable: false
  3509. });
  3510. }
  3511. }
  3512. return child;
  3513. }
  3514. return _clone(parent, depth);
  3515. }
  3516. /**
  3517. * Simple flat clone using prototype, accepts only objects, usefull for property
  3518. * override on FLAT configuration object (no nested props).
  3519. *
  3520. * USE WITH CAUTION! This may not behave as you wish if you do not know how this
  3521. * works.
  3522. */
  3523. clone.clonePrototype = function clonePrototype(parent) {
  3524. if (parent === null)
  3525. return null;
  3526. var c = function () {};
  3527. c.prototype = parent;
  3528. return new c();
  3529. };
  3530. // private utility functions
  3531. function __objToStr(o) {
  3532. return Object.prototype.toString.call(o);
  3533. }
  3534. clone.__objToStr = __objToStr;
  3535. function __isDate(o) {
  3536. return typeof o === 'object' && __objToStr(o) === '[object Date]';
  3537. }
  3538. clone.__isDate = __isDate;
  3539. function __isArray(o) {
  3540. return typeof o === 'object' && __objToStr(o) === '[object Array]';
  3541. }
  3542. clone.__isArray = __isArray;
  3543. function __isRegExp(o) {
  3544. return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
  3545. }
  3546. clone.__isRegExp = __isRegExp;
  3547. function __getRegExpFlags(re) {
  3548. var flags = '';
  3549. if (re.global) flags += 'g';
  3550. if (re.ignoreCase) flags += 'i';
  3551. if (re.multiline) flags += 'm';
  3552. return flags;
  3553. }
  3554. clone.__getRegExpFlags = __getRegExpFlags;
  3555. return clone;
  3556. })();
  3557. if (typeof module === 'object' && module.exports) {
  3558. module.exports = clone;
  3559. }
  3560. /***/ }),
  3561. /* 22 */
  3562. /***/ (function(module, exports, __webpack_require__) {
  3563. "use strict";
  3564. Object.defineProperty(exports, "__esModule", {
  3565. value: true
  3566. });
  3567. 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"); } }; }();
  3568. 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; }; }();
  3569. 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); } };
  3570. var _parchment = __webpack_require__(0);
  3571. var _parchment2 = _interopRequireDefault(_parchment);
  3572. var _emitter = __webpack_require__(8);
  3573. var _emitter2 = _interopRequireDefault(_emitter);
  3574. var _block = __webpack_require__(4);
  3575. var _block2 = _interopRequireDefault(_block);
  3576. var _break = __webpack_require__(16);
  3577. var _break2 = _interopRequireDefault(_break);
  3578. var _code = __webpack_require__(13);
  3579. var _code2 = _interopRequireDefault(_code);
  3580. var _container = __webpack_require__(25);
  3581. var _container2 = _interopRequireDefault(_container);
  3582. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3583. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3584. 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; }
  3585. 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; }
  3586. function isLine(blot) {
  3587. return blot instanceof _block2.default || blot instanceof _block.BlockEmbed;
  3588. }
  3589. var Scroll = function (_Parchment$Scroll) {
  3590. _inherits(Scroll, _Parchment$Scroll);
  3591. function Scroll(domNode, config) {
  3592. _classCallCheck(this, Scroll);
  3593. var _this = _possibleConstructorReturn(this, (Scroll.__proto__ || Object.getPrototypeOf(Scroll)).call(this, domNode));
  3594. _this.emitter = config.emitter;
  3595. if (Array.isArray(config.whitelist)) {
  3596. _this.whitelist = config.whitelist.reduce(function (whitelist, format) {
  3597. whitelist[format] = true;
  3598. return whitelist;
  3599. }, {});
  3600. }
  3601. // Some reason fixes composition issues with character languages in Windows/Chrome, Safari
  3602. _this.domNode.addEventListener('DOMNodeInserted', function () {});
  3603. _this.optimize();
  3604. _this.enable();
  3605. return _this;
  3606. }
  3607. _createClass(Scroll, [{
  3608. key: 'batchStart',
  3609. value: function batchStart() {
  3610. this.batch = true;
  3611. }
  3612. }, {
  3613. key: 'batchEnd',
  3614. value: function batchEnd() {
  3615. this.batch = false;
  3616. this.optimize();
  3617. }
  3618. }, {
  3619. key: 'deleteAt',
  3620. value: function deleteAt(index, length) {
  3621. var _line = this.line(index),
  3622. _line2 = _slicedToArray(_line, 2),
  3623. first = _line2[0],
  3624. offset = _line2[1];
  3625. var _line3 = this.line(index + length),
  3626. _line4 = _slicedToArray(_line3, 1),
  3627. last = _line4[0];
  3628. _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'deleteAt', this).call(this, index, length);
  3629. if (last != null && first !== last && offset > 0) {
  3630. if (first instanceof _block.BlockEmbed || last instanceof _block.BlockEmbed) {
  3631. this.optimize();
  3632. return;
  3633. }
  3634. if (first instanceof _code2.default) {
  3635. var newlineIndex = first.newlineIndex(first.length(), true);
  3636. if (newlineIndex > -1) {
  3637. first = first.split(newlineIndex + 1);
  3638. if (first === last) {
  3639. this.optimize();
  3640. return;
  3641. }
  3642. }
  3643. } else if (last instanceof _code2.default) {
  3644. var _newlineIndex = last.newlineIndex(0);
  3645. if (_newlineIndex > -1) {
  3646. last.split(_newlineIndex + 1);
  3647. }
  3648. }
  3649. var ref = last.children.head instanceof _break2.default ? null : last.children.head;
  3650. first.moveChildren(last, ref);
  3651. first.remove();
  3652. }
  3653. this.optimize();
  3654. }
  3655. }, {
  3656. key: 'enable',
  3657. value: function enable() {
  3658. var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  3659. this.domNode.setAttribute('contenteditable', enabled);
  3660. }
  3661. }, {
  3662. key: 'formatAt',
  3663. value: function formatAt(index, length, format, value) {
  3664. if (this.whitelist != null && !this.whitelist[format]) return;
  3665. _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'formatAt', this).call(this, index, length, format, value);
  3666. this.optimize();
  3667. }
  3668. }, {
  3669. key: 'insertAt',
  3670. value: function insertAt(index, value, def) {
  3671. if (def != null && this.whitelist != null && !this.whitelist[value]) return;
  3672. if (index >= this.length()) {
  3673. if (def == null || _parchment2.default.query(value, _parchment2.default.Scope.BLOCK) == null) {
  3674. var blot = _parchment2.default.create(this.statics.defaultChild);
  3675. this.appendChild(blot);
  3676. if (def == null && value.endsWith('\n')) {
  3677. value = value.slice(0, -1);
  3678. }
  3679. blot.insertAt(0, value, def);
  3680. } else {
  3681. var embed = _parchment2.default.create(value, def);
  3682. this.appendChild(embed);
  3683. }
  3684. } else {
  3685. _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'insertAt', this).call(this, index, value, def);
  3686. }
  3687. this.optimize();
  3688. }
  3689. }, {
  3690. key: 'insertBefore',
  3691. value: function insertBefore(blot, ref) {
  3692. if (blot.statics.scope === _parchment2.default.Scope.INLINE_BLOT) {
  3693. var wrapper = _parchment2.default.create(this.statics.defaultChild);
  3694. wrapper.appendChild(blot);
  3695. blot = wrapper;
  3696. }
  3697. _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'insertBefore', this).call(this, blot, ref);
  3698. }
  3699. }, {
  3700. key: 'leaf',
  3701. value: function leaf(index) {
  3702. return this.path(index).pop() || [null, -1];
  3703. }
  3704. }, {
  3705. key: 'line',
  3706. value: function line(index) {
  3707. if (index === this.length()) {
  3708. return this.line(index - 1);
  3709. }
  3710. return this.descendant(isLine, index);
  3711. }
  3712. }, {
  3713. key: 'lines',
  3714. value: function lines() {
  3715. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  3716. var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_VALUE;
  3717. var getLines = function getLines(blot, index, length) {
  3718. var lines = [],
  3719. lengthLeft = length;
  3720. blot.children.forEachAt(index, length, function (child, index, length) {
  3721. if (isLine(child)) {
  3722. lines.push(child);
  3723. } else if (child instanceof _parchment2.default.Container) {
  3724. lines = lines.concat(getLines(child, index, lengthLeft));
  3725. }
  3726. lengthLeft -= length;
  3727. });
  3728. return lines;
  3729. };
  3730. return getLines(this, index, length);
  3731. }
  3732. }, {
  3733. key: 'optimize',
  3734. value: function optimize() {
  3735. var mutations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  3736. var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  3737. if (this.batch === true) return;
  3738. _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'optimize', this).call(this, mutations, context);
  3739. if (mutations.length > 0) {
  3740. this.emitter.emit(_emitter2.default.events.SCROLL_OPTIMIZE, mutations, context);
  3741. }
  3742. }
  3743. }, {
  3744. key: 'path',
  3745. value: function path(index) {
  3746. return _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'path', this).call(this, index).slice(1); // Exclude self
  3747. }
  3748. }, {
  3749. key: 'update',
  3750. value: function update(mutations) {
  3751. if (this.batch === true) return;
  3752. var source = _emitter2.default.sources.USER;
  3753. if (typeof mutations === 'string') {
  3754. source = mutations;
  3755. }
  3756. if (!Array.isArray(mutations)) {
  3757. mutations = this.observer.takeRecords();
  3758. }
  3759. if (mutations.length > 0) {
  3760. this.emitter.emit(_emitter2.default.events.SCROLL_BEFORE_UPDATE, source, mutations);
  3761. }
  3762. _get(Scroll.prototype.__proto__ || Object.getPrototypeOf(Scroll.prototype), 'update', this).call(this, mutations.concat([])); // pass copy
  3763. if (mutations.length > 0) {
  3764. this.emitter.emit(_emitter2.default.events.SCROLL_UPDATE, source, mutations);
  3765. }
  3766. }
  3767. }]);
  3768. return Scroll;
  3769. }(_parchment2.default.Scroll);
  3770. Scroll.blotName = 'scroll';
  3771. Scroll.className = 'ql-editor';
  3772. Scroll.tagName = 'DIV';
  3773. Scroll.defaultChild = 'block';
  3774. Scroll.allowedChildren = [_block2.default, _block.BlockEmbed, _container2.default];
  3775. exports.default = Scroll;
  3776. /***/ }),
  3777. /* 23 */
  3778. /***/ (function(module, exports, __webpack_require__) {
  3779. "use strict";
  3780. Object.defineProperty(exports, "__esModule", {
  3781. value: true
  3782. });
  3783. exports.SHORTKEY = exports.default = undefined;
  3784. 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; };
  3785. 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"); } }; }();
  3786. 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; }; }();
  3787. var _clone = __webpack_require__(21);
  3788. var _clone2 = _interopRequireDefault(_clone);
  3789. var _deepEqual = __webpack_require__(11);
  3790. var _deepEqual2 = _interopRequireDefault(_deepEqual);
  3791. var _extend = __webpack_require__(3);
  3792. var _extend2 = _interopRequireDefault(_extend);
  3793. var _quillDelta = __webpack_require__(2);
  3794. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  3795. var _op = __webpack_require__(20);
  3796. var _op2 = _interopRequireDefault(_op);
  3797. var _parchment = __webpack_require__(0);
  3798. var _parchment2 = _interopRequireDefault(_parchment);
  3799. var _quill = __webpack_require__(5);
  3800. var _quill2 = _interopRequireDefault(_quill);
  3801. var _logger = __webpack_require__(10);
  3802. var _logger2 = _interopRequireDefault(_logger);
  3803. var _module = __webpack_require__(9);
  3804. var _module2 = _interopRequireDefault(_module);
  3805. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3806. 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; }
  3807. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3808. 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; }
  3809. 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; }
  3810. var debug = (0, _logger2.default)('quill:keyboard');
  3811. var SHORTKEY = /Mac/i.test(navigator.platform) ? 'metaKey' : 'ctrlKey';
  3812. var Keyboard = function (_Module) {
  3813. _inherits(Keyboard, _Module);
  3814. _createClass(Keyboard, null, [{
  3815. key: 'match',
  3816. value: function match(evt, binding) {
  3817. binding = normalize(binding);
  3818. if (['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].some(function (key) {
  3819. return !!binding[key] !== evt[key] && binding[key] !== null;
  3820. })) {
  3821. return false;
  3822. }
  3823. return binding.key === (evt.which || evt.keyCode);
  3824. }
  3825. }]);
  3826. function Keyboard(quill, options) {
  3827. _classCallCheck(this, Keyboard);
  3828. var _this = _possibleConstructorReturn(this, (Keyboard.__proto__ || Object.getPrototypeOf(Keyboard)).call(this, quill, options));
  3829. _this.bindings = {};
  3830. Object.keys(_this.options.bindings).forEach(function (name) {
  3831. if (name === 'list autofill' && quill.scroll.whitelist != null && !quill.scroll.whitelist['list']) {
  3832. return;
  3833. }
  3834. if (_this.options.bindings[name]) {
  3835. _this.addBinding(_this.options.bindings[name]);
  3836. }
  3837. });
  3838. _this.addBinding({ key: Keyboard.keys.ENTER, shiftKey: null }, handleEnter);
  3839. _this.addBinding({ key: Keyboard.keys.ENTER, metaKey: null, ctrlKey: null, altKey: null }, function () {});
  3840. if (/Firefox/i.test(navigator.userAgent)) {
  3841. // Need to handle delete and backspace for Firefox in the general case #1171
  3842. _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true }, handleBackspace);
  3843. _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true }, handleDelete);
  3844. } else {
  3845. _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true, prefix: /^.?$/ }, handleBackspace);
  3846. _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true, suffix: /^.?$/ }, handleDelete);
  3847. }
  3848. _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: false }, handleDeleteRange);
  3849. _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: false }, handleDeleteRange);
  3850. _this.addBinding({ key: Keyboard.keys.BACKSPACE, altKey: null, ctrlKey: null, metaKey: null, shiftKey: null }, { collapsed: true, offset: 0 }, handleBackspace);
  3851. _this.listen();
  3852. return _this;
  3853. }
  3854. _createClass(Keyboard, [{
  3855. key: 'addBinding',
  3856. value: function addBinding(key) {
  3857. var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  3858. var handler = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  3859. var binding = normalize(key);
  3860. if (binding == null || binding.key == null) {
  3861. return debug.warn('Attempted to add invalid keyboard binding', binding);
  3862. }
  3863. if (typeof context === 'function') {
  3864. context = { handler: context };
  3865. }
  3866. if (typeof handler === 'function') {
  3867. handler = { handler: handler };
  3868. }
  3869. binding = (0, _extend2.default)(binding, context, handler);
  3870. this.bindings[binding.key] = this.bindings[binding.key] || [];
  3871. this.bindings[binding.key].push(binding);
  3872. }
  3873. }, {
  3874. key: 'listen',
  3875. value: function listen() {
  3876. var _this2 = this;
  3877. this.quill.root.addEventListener('keydown', function (evt) {
  3878. if (evt.defaultPrevented) return;
  3879. var which = evt.which || evt.keyCode;
  3880. var bindings = (_this2.bindings[which] || []).filter(function (binding) {
  3881. return Keyboard.match(evt, binding);
  3882. });
  3883. if (bindings.length === 0) return;
  3884. var range = _this2.quill.getSelection();
  3885. if (range == null || !_this2.quill.hasFocus()) return;
  3886. var _quill$getLine = _this2.quill.getLine(range.index),
  3887. _quill$getLine2 = _slicedToArray(_quill$getLine, 2),
  3888. line = _quill$getLine2[0],
  3889. offset = _quill$getLine2[1];
  3890. var _quill$getLeaf = _this2.quill.getLeaf(range.index),
  3891. _quill$getLeaf2 = _slicedToArray(_quill$getLeaf, 2),
  3892. leafStart = _quill$getLeaf2[0],
  3893. offsetStart = _quill$getLeaf2[1];
  3894. var _ref = range.length === 0 ? [leafStart, offsetStart] : _this2.quill.getLeaf(range.index + range.length),
  3895. _ref2 = _slicedToArray(_ref, 2),
  3896. leafEnd = _ref2[0],
  3897. offsetEnd = _ref2[1];
  3898. var prefixText = leafStart instanceof _parchment2.default.Text ? leafStart.value().slice(0, offsetStart) : '';
  3899. var suffixText = leafEnd instanceof _parchment2.default.Text ? leafEnd.value().slice(offsetEnd) : '';
  3900. var curContext = {
  3901. collapsed: range.length === 0,
  3902. empty: range.length === 0 && line.length() <= 1,
  3903. format: _this2.quill.getFormat(range),
  3904. offset: offset,
  3905. prefix: prefixText,
  3906. suffix: suffixText
  3907. };
  3908. var prevented = bindings.some(function (binding) {
  3909. if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) return false;
  3910. if (binding.empty != null && binding.empty !== curContext.empty) return false;
  3911. if (binding.offset != null && binding.offset !== curContext.offset) return false;
  3912. if (Array.isArray(binding.format)) {
  3913. // any format is present
  3914. if (binding.format.every(function (name) {
  3915. return curContext.format[name] == null;
  3916. })) {
  3917. return false;
  3918. }
  3919. } else if (_typeof(binding.format) === 'object') {
  3920. // all formats must match
  3921. if (!Object.keys(binding.format).every(function (name) {
  3922. if (binding.format[name] === true) return curContext.format[name] != null;
  3923. if (binding.format[name] === false) return curContext.format[name] == null;
  3924. return (0, _deepEqual2.default)(binding.format[name], curContext.format[name]);
  3925. })) {
  3926. return false;
  3927. }
  3928. }
  3929. if (binding.prefix != null && !binding.prefix.test(curContext.prefix)) return false;
  3930. if (binding.suffix != null && !binding.suffix.test(curContext.suffix)) return false;
  3931. return binding.handler.call(_this2, range, curContext) !== true;
  3932. });
  3933. if (prevented) {
  3934. evt.preventDefault();
  3935. }
  3936. });
  3937. }
  3938. }]);
  3939. return Keyboard;
  3940. }(_module2.default);
  3941. Keyboard.keys = {
  3942. BACKSPACE: 8,
  3943. TAB: 9,
  3944. ENTER: 13,
  3945. ESCAPE: 27,
  3946. LEFT: 37,
  3947. UP: 38,
  3948. RIGHT: 39,
  3949. DOWN: 40,
  3950. DELETE: 46
  3951. };
  3952. Keyboard.DEFAULTS = {
  3953. bindings: {
  3954. 'bold': makeFormatHandler('bold'),
  3955. 'italic': makeFormatHandler('italic'),
  3956. 'underline': makeFormatHandler('underline'),
  3957. 'indent': {
  3958. // highlight tab or tab at beginning of list, indent or blockquote
  3959. key: Keyboard.keys.TAB,
  3960. format: ['blockquote', 'indent', 'list'],
  3961. handler: function handler(range, context) {
  3962. if (context.collapsed && context.offset !== 0) return true;
  3963. this.quill.format('indent', '+1', _quill2.default.sources.USER);
  3964. }
  3965. },
  3966. 'outdent': {
  3967. key: Keyboard.keys.TAB,
  3968. shiftKey: true,
  3969. format: ['blockquote', 'indent', 'list'],
  3970. // highlight tab or tab at beginning of list, indent or blockquote
  3971. handler: function handler(range, context) {
  3972. if (context.collapsed && context.offset !== 0) return true;
  3973. this.quill.format('indent', '-1', _quill2.default.sources.USER);
  3974. }
  3975. },
  3976. 'outdent backspace': {
  3977. key: Keyboard.keys.BACKSPACE,
  3978. collapsed: true,
  3979. shiftKey: null,
  3980. metaKey: null,
  3981. ctrlKey: null,
  3982. altKey: null,
  3983. format: ['indent', 'list'],
  3984. offset: 0,
  3985. handler: function handler(range, context) {
  3986. if (context.format.indent != null) {
  3987. this.quill.format('indent', '-1', _quill2.default.sources.USER);
  3988. } else if (context.format.list != null) {
  3989. this.quill.format('list', false, _quill2.default.sources.USER);
  3990. }
  3991. }
  3992. },
  3993. 'indent code-block': makeCodeBlockHandler(true),
  3994. 'outdent code-block': makeCodeBlockHandler(false),
  3995. 'remove tab': {
  3996. key: Keyboard.keys.TAB,
  3997. shiftKey: true,
  3998. collapsed: true,
  3999. prefix: /\t$/,
  4000. handler: function handler(range) {
  4001. this.quill.deleteText(range.index - 1, 1, _quill2.default.sources.USER);
  4002. }
  4003. },
  4004. 'tab': {
  4005. key: Keyboard.keys.TAB,
  4006. handler: function handler(range) {
  4007. this.quill.history.cutoff();
  4008. var delta = new _quillDelta2.default().retain(range.index).delete(range.length).insert('\t');
  4009. this.quill.updateContents(delta, _quill2.default.sources.USER);
  4010. this.quill.history.cutoff();
  4011. this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
  4012. }
  4013. },
  4014. 'list empty enter': {
  4015. key: Keyboard.keys.ENTER,
  4016. collapsed: true,
  4017. format: ['list'],
  4018. empty: true,
  4019. handler: function handler(range, context) {
  4020. this.quill.format('list', false, _quill2.default.sources.USER);
  4021. if (context.format.indent) {
  4022. this.quill.format('indent', false, _quill2.default.sources.USER);
  4023. }
  4024. }
  4025. },
  4026. 'checklist enter': {
  4027. key: Keyboard.keys.ENTER,
  4028. collapsed: true,
  4029. format: { list: 'checked' },
  4030. handler: function handler(range) {
  4031. var _quill$getLine3 = this.quill.getLine(range.index),
  4032. _quill$getLine4 = _slicedToArray(_quill$getLine3, 2),
  4033. line = _quill$getLine4[0],
  4034. offset = _quill$getLine4[1];
  4035. var formats = (0, _extend2.default)({}, line.formats(), { list: 'checked' });
  4036. var delta = new _quillDelta2.default().retain(range.index).insert('\n', formats).retain(line.length() - offset - 1).retain(1, { list: 'unchecked' });
  4037. this.quill.updateContents(delta, _quill2.default.sources.USER);
  4038. this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
  4039. this.quill.scrollIntoView();
  4040. }
  4041. },
  4042. 'header enter': {
  4043. key: Keyboard.keys.ENTER,
  4044. collapsed: true,
  4045. format: ['header'],
  4046. suffix: /^$/,
  4047. handler: function handler(range, context) {
  4048. var _quill$getLine5 = this.quill.getLine(range.index),
  4049. _quill$getLine6 = _slicedToArray(_quill$getLine5, 2),
  4050. line = _quill$getLine6[0],
  4051. offset = _quill$getLine6[1];
  4052. var delta = new _quillDelta2.default().retain(range.index).insert('\n', context.format).retain(line.length() - offset - 1).retain(1, { header: null });
  4053. this.quill.updateContents(delta, _quill2.default.sources.USER);
  4054. this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
  4055. this.quill.scrollIntoView();
  4056. }
  4057. },
  4058. 'list autofill': {
  4059. key: ' ',
  4060. collapsed: true,
  4061. format: { list: false },
  4062. prefix: /^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,
  4063. handler: function handler(range, context) {
  4064. var length = context.prefix.length;
  4065. var _quill$getLine7 = this.quill.getLine(range.index),
  4066. _quill$getLine8 = _slicedToArray(_quill$getLine7, 2),
  4067. line = _quill$getLine8[0],
  4068. offset = _quill$getLine8[1];
  4069. if (offset > length) return true;
  4070. var value = void 0;
  4071. switch (context.prefix.trim()) {
  4072. case '[]':case '[ ]':
  4073. value = 'unchecked';
  4074. break;
  4075. case '[x]':
  4076. value = 'checked';
  4077. break;
  4078. case '-':case '*':
  4079. value = 'bullet';
  4080. break;
  4081. default:
  4082. value = 'ordered';
  4083. }
  4084. this.quill.insertText(range.index, ' ', _quill2.default.sources.USER);
  4085. this.quill.history.cutoff();
  4086. var delta = new _quillDelta2.default().retain(range.index - offset).delete(length + 1).retain(line.length() - 2 - offset).retain(1, { list: value });
  4087. this.quill.updateContents(delta, _quill2.default.sources.USER);
  4088. this.quill.history.cutoff();
  4089. this.quill.setSelection(range.index - length, _quill2.default.sources.SILENT);
  4090. }
  4091. },
  4092. 'code exit': {
  4093. key: Keyboard.keys.ENTER,
  4094. collapsed: true,
  4095. format: ['code-block'],
  4096. prefix: /\n\n$/,
  4097. suffix: /^\s+$/,
  4098. handler: function handler(range) {
  4099. var _quill$getLine9 = this.quill.getLine(range.index),
  4100. _quill$getLine10 = _slicedToArray(_quill$getLine9, 2),
  4101. line = _quill$getLine10[0],
  4102. offset = _quill$getLine10[1];
  4103. var delta = new _quillDelta2.default().retain(range.index + line.length() - offset - 2).retain(1, { 'code-block': null }).delete(1);
  4104. this.quill.updateContents(delta, _quill2.default.sources.USER);
  4105. }
  4106. },
  4107. 'embed left': makeEmbedArrowHandler(Keyboard.keys.LEFT, false),
  4108. 'embed left shift': makeEmbedArrowHandler(Keyboard.keys.LEFT, true),
  4109. 'embed right': makeEmbedArrowHandler(Keyboard.keys.RIGHT, false),
  4110. 'embed right shift': makeEmbedArrowHandler(Keyboard.keys.RIGHT, true)
  4111. }
  4112. };
  4113. function makeEmbedArrowHandler(key, shiftKey) {
  4114. var _ref3;
  4115. var where = key === Keyboard.keys.LEFT ? 'prefix' : 'suffix';
  4116. return _ref3 = {
  4117. key: key,
  4118. shiftKey: shiftKey,
  4119. altKey: null
  4120. }, _defineProperty(_ref3, where, /^$/), _defineProperty(_ref3, 'handler', function handler(range) {
  4121. var index = range.index;
  4122. if (key === Keyboard.keys.RIGHT) {
  4123. index += range.length + 1;
  4124. }
  4125. var _quill$getLeaf3 = this.quill.getLeaf(index),
  4126. _quill$getLeaf4 = _slicedToArray(_quill$getLeaf3, 1),
  4127. leaf = _quill$getLeaf4[0];
  4128. if (!(leaf instanceof _parchment2.default.Embed)) return true;
  4129. if (key === Keyboard.keys.LEFT) {
  4130. if (shiftKey) {
  4131. this.quill.setSelection(range.index - 1, range.length + 1, _quill2.default.sources.USER);
  4132. } else {
  4133. this.quill.setSelection(range.index - 1, _quill2.default.sources.USER);
  4134. }
  4135. } else {
  4136. if (shiftKey) {
  4137. this.quill.setSelection(range.index, range.length + 1, _quill2.default.sources.USER);
  4138. } else {
  4139. this.quill.setSelection(range.index + range.length + 1, _quill2.default.sources.USER);
  4140. }
  4141. }
  4142. return false;
  4143. }), _ref3;
  4144. }
  4145. function handleBackspace(range, context) {
  4146. if (range.index === 0 || this.quill.getLength() <= 1) return;
  4147. var _quill$getLine11 = this.quill.getLine(range.index),
  4148. _quill$getLine12 = _slicedToArray(_quill$getLine11, 1),
  4149. line = _quill$getLine12[0];
  4150. var formats = {};
  4151. if (context.offset === 0) {
  4152. var _quill$getLine13 = this.quill.getLine(range.index - 1),
  4153. _quill$getLine14 = _slicedToArray(_quill$getLine13, 1),
  4154. prev = _quill$getLine14[0];
  4155. if (prev != null && prev.length() > 1) {
  4156. var curFormats = line.formats();
  4157. var prevFormats = this.quill.getFormat(range.index - 1, 1);
  4158. formats = _op2.default.attributes.diff(curFormats, prevFormats) || {};
  4159. }
  4160. }
  4161. // Check for astral symbols
  4162. var length = /[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(context.prefix) ? 2 : 1;
  4163. this.quill.deleteText(range.index - length, length, _quill2.default.sources.USER);
  4164. if (Object.keys(formats).length > 0) {
  4165. this.quill.formatLine(range.index - length, length, formats, _quill2.default.sources.USER);
  4166. }
  4167. this.quill.focus();
  4168. }
  4169. function handleDelete(range, context) {
  4170. // Check for astral symbols
  4171. var length = /^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(context.suffix) ? 2 : 1;
  4172. if (range.index >= this.quill.getLength() - length) return;
  4173. var formats = {},
  4174. nextLength = 0;
  4175. var _quill$getLine15 = this.quill.getLine(range.index),
  4176. _quill$getLine16 = _slicedToArray(_quill$getLine15, 1),
  4177. line = _quill$getLine16[0];
  4178. if (context.offset >= line.length() - 1) {
  4179. var _quill$getLine17 = this.quill.getLine(range.index + 1),
  4180. _quill$getLine18 = _slicedToArray(_quill$getLine17, 1),
  4181. next = _quill$getLine18[0];
  4182. if (next) {
  4183. var curFormats = line.formats();
  4184. var nextFormats = this.quill.getFormat(range.index, 1);
  4185. formats = _op2.default.attributes.diff(curFormats, nextFormats) || {};
  4186. nextLength = next.length();
  4187. }
  4188. }
  4189. this.quill.deleteText(range.index, length, _quill2.default.sources.USER);
  4190. if (Object.keys(formats).length > 0) {
  4191. this.quill.formatLine(range.index + nextLength - 1, length, formats, _quill2.default.sources.USER);
  4192. }
  4193. }
  4194. function handleDeleteRange(range) {
  4195. var lines = this.quill.getLines(range);
  4196. var formats = {};
  4197. if (lines.length > 1) {
  4198. var firstFormats = lines[0].formats();
  4199. var lastFormats = lines[lines.length - 1].formats();
  4200. formats = _op2.default.attributes.diff(lastFormats, firstFormats) || {};
  4201. }
  4202. this.quill.deleteText(range, _quill2.default.sources.USER);
  4203. if (Object.keys(formats).length > 0) {
  4204. this.quill.formatLine(range.index, 1, formats, _quill2.default.sources.USER);
  4205. }
  4206. this.quill.setSelection(range.index, _quill2.default.sources.SILENT);
  4207. this.quill.focus();
  4208. }
  4209. function handleEnter(range, context) {
  4210. var _this3 = this;
  4211. if (range.length > 0) {
  4212. this.quill.scroll.deleteAt(range.index, range.length); // So we do not trigger text-change
  4213. }
  4214. var lineFormats = Object.keys(context.format).reduce(function (lineFormats, format) {
  4215. if (_parchment2.default.query(format, _parchment2.default.Scope.BLOCK) && !Array.isArray(context.format[format])) {
  4216. lineFormats[format] = context.format[format];
  4217. }
  4218. return lineFormats;
  4219. }, {});
  4220. this.quill.insertText(range.index, '\n', lineFormats, _quill2.default.sources.USER);
  4221. // Earlier scroll.deleteAt might have messed up our selection,
  4222. // so insertText's built in selection preservation is not reliable
  4223. this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
  4224. this.quill.focus();
  4225. Object.keys(context.format).forEach(function (name) {
  4226. if (lineFormats[name] != null) return;
  4227. if (Array.isArray(context.format[name])) return;
  4228. if (name === 'link') return;
  4229. _this3.quill.format(name, context.format[name], _quill2.default.sources.USER);
  4230. });
  4231. }
  4232. function makeCodeBlockHandler(indent) {
  4233. return {
  4234. key: Keyboard.keys.TAB,
  4235. shiftKey: !indent,
  4236. format: { 'code-block': true },
  4237. handler: function handler(range) {
  4238. var CodeBlock = _parchment2.default.query('code-block');
  4239. var index = range.index,
  4240. length = range.length;
  4241. var _quill$scroll$descend = this.quill.scroll.descendant(CodeBlock, index),
  4242. _quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2),
  4243. block = _quill$scroll$descend2[0],
  4244. offset = _quill$scroll$descend2[1];
  4245. if (block == null) return;
  4246. var scrollIndex = this.quill.getIndex(block);
  4247. var start = block.newlineIndex(offset, true) + 1;
  4248. var end = block.newlineIndex(scrollIndex + offset + length);
  4249. var lines = block.domNode.textContent.slice(start, end).split('\n');
  4250. offset = 0;
  4251. lines.forEach(function (line, i) {
  4252. if (indent) {
  4253. block.insertAt(start + offset, CodeBlock.TAB);
  4254. offset += CodeBlock.TAB.length;
  4255. if (i === 0) {
  4256. index += CodeBlock.TAB.length;
  4257. } else {
  4258. length += CodeBlock.TAB.length;
  4259. }
  4260. } else if (line.startsWith(CodeBlock.TAB)) {
  4261. block.deleteAt(start + offset, CodeBlock.TAB.length);
  4262. offset -= CodeBlock.TAB.length;
  4263. if (i === 0) {
  4264. index -= CodeBlock.TAB.length;
  4265. } else {
  4266. length -= CodeBlock.TAB.length;
  4267. }
  4268. }
  4269. offset += line.length + 1;
  4270. });
  4271. this.quill.update(_quill2.default.sources.USER);
  4272. this.quill.setSelection(index, length, _quill2.default.sources.SILENT);
  4273. }
  4274. };
  4275. }
  4276. function makeFormatHandler(format) {
  4277. return {
  4278. key: format[0].toUpperCase(),
  4279. shortKey: true,
  4280. handler: function handler(range, context) {
  4281. this.quill.format(format, !context.format[format], _quill2.default.sources.USER);
  4282. }
  4283. };
  4284. }
  4285. function normalize(binding) {
  4286. if (typeof binding === 'string' || typeof binding === 'number') {
  4287. return normalize({ key: binding });
  4288. }
  4289. if ((typeof binding === 'undefined' ? 'undefined' : _typeof(binding)) === 'object') {
  4290. binding = (0, _clone2.default)(binding, false);
  4291. }
  4292. if (typeof binding.key === 'string') {
  4293. if (Keyboard.keys[binding.key.toUpperCase()] != null) {
  4294. binding.key = Keyboard.keys[binding.key.toUpperCase()];
  4295. } else if (binding.key.length === 1) {
  4296. binding.key = binding.key.toUpperCase().charCodeAt(0);
  4297. } else {
  4298. return null;
  4299. }
  4300. }
  4301. if (binding.shortKey) {
  4302. binding[SHORTKEY] = binding.shortKey;
  4303. delete binding.shortKey;
  4304. }
  4305. return binding;
  4306. }
  4307. exports.default = Keyboard;
  4308. exports.SHORTKEY = SHORTKEY;
  4309. /***/ }),
  4310. /* 24 */
  4311. /***/ (function(module, exports, __webpack_require__) {
  4312. "use strict";
  4313. Object.defineProperty(exports, "__esModule", {
  4314. value: true
  4315. });
  4316. 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"); } }; }();
  4317. 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); } };
  4318. 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; }; }();
  4319. var _parchment = __webpack_require__(0);
  4320. var _parchment2 = _interopRequireDefault(_parchment);
  4321. var _text = __webpack_require__(7);
  4322. var _text2 = _interopRequireDefault(_text);
  4323. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4324. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4325. 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; }
  4326. 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; }
  4327. var Cursor = function (_Parchment$Embed) {
  4328. _inherits(Cursor, _Parchment$Embed);
  4329. _createClass(Cursor, null, [{
  4330. key: 'value',
  4331. value: function value() {
  4332. return undefined;
  4333. }
  4334. }]);
  4335. function Cursor(domNode, selection) {
  4336. _classCallCheck(this, Cursor);
  4337. var _this = _possibleConstructorReturn(this, (Cursor.__proto__ || Object.getPrototypeOf(Cursor)).call(this, domNode));
  4338. _this.selection = selection;
  4339. _this.textNode = document.createTextNode(Cursor.CONTENTS);
  4340. _this.domNode.appendChild(_this.textNode);
  4341. _this._length = 0;
  4342. return _this;
  4343. }
  4344. _createClass(Cursor, [{
  4345. key: 'detach',
  4346. value: function detach() {
  4347. // super.detach() will also clear domNode.__blot
  4348. if (this.parent != null) this.parent.removeChild(this);
  4349. }
  4350. }, {
  4351. key: 'format',
  4352. value: function format(name, value) {
  4353. if (this._length !== 0) {
  4354. return _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'format', this).call(this, name, value);
  4355. }
  4356. var target = this,
  4357. index = 0;
  4358. while (target != null && target.statics.scope !== _parchment2.default.Scope.BLOCK_BLOT) {
  4359. index += target.offset(target.parent);
  4360. target = target.parent;
  4361. }
  4362. if (target != null) {
  4363. this._length = Cursor.CONTENTS.length;
  4364. target.optimize();
  4365. target.formatAt(index, Cursor.CONTENTS.length, name, value);
  4366. this._length = 0;
  4367. }
  4368. }
  4369. }, {
  4370. key: 'index',
  4371. value: function index(node, offset) {
  4372. if (node === this.textNode) return 0;
  4373. return _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'index', this).call(this, node, offset);
  4374. }
  4375. }, {
  4376. key: 'length',
  4377. value: function length() {
  4378. return this._length;
  4379. }
  4380. }, {
  4381. key: 'position',
  4382. value: function position() {
  4383. return [this.textNode, this.textNode.data.length];
  4384. }
  4385. }, {
  4386. key: 'remove',
  4387. value: function remove() {
  4388. _get(Cursor.prototype.__proto__ || Object.getPrototypeOf(Cursor.prototype), 'remove', this).call(this);
  4389. this.parent = null;
  4390. }
  4391. }, {
  4392. key: 'restore',
  4393. value: function restore() {
  4394. if (this.selection.composing || this.parent == null) return;
  4395. var textNode = this.textNode;
  4396. var range = this.selection.getNativeRange();
  4397. var restoreText = void 0,
  4398. start = void 0,
  4399. end = void 0;
  4400. if (range != null && range.start.node === textNode && range.end.node === textNode) {
  4401. var _ref = [textNode, range.start.offset, range.end.offset];
  4402. restoreText = _ref[0];
  4403. start = _ref[1];
  4404. end = _ref[2];
  4405. }
  4406. // Link format will insert text outside of anchor tag
  4407. while (this.domNode.lastChild != null && this.domNode.lastChild !== this.textNode) {
  4408. this.domNode.parentNode.insertBefore(this.domNode.lastChild, this.domNode);
  4409. }
  4410. if (this.textNode.data !== Cursor.CONTENTS) {
  4411. var text = this.textNode.data.split(Cursor.CONTENTS).join('');
  4412. if (this.next instanceof _text2.default) {
  4413. restoreText = this.next.domNode;
  4414. this.next.insertAt(0, text);
  4415. this.textNode.data = Cursor.CONTENTS;
  4416. } else {
  4417. this.textNode.data = text;
  4418. this.parent.insertBefore(_parchment2.default.create(this.textNode), this);
  4419. this.textNode = document.createTextNode(Cursor.CONTENTS);
  4420. this.domNode.appendChild(this.textNode);
  4421. }
  4422. }
  4423. this.remove();
  4424. if (start != null) {
  4425. var _map = [start, end].map(function (offset) {
  4426. return Math.max(0, Math.min(restoreText.data.length, offset - 1));
  4427. });
  4428. var _map2 = _slicedToArray(_map, 2);
  4429. start = _map2[0];
  4430. end = _map2[1];
  4431. return {
  4432. startNode: restoreText,
  4433. startOffset: start,
  4434. endNode: restoreText,
  4435. endOffset: end
  4436. };
  4437. }
  4438. }
  4439. }, {
  4440. key: 'update',
  4441. value: function update(mutations, context) {
  4442. var _this2 = this;
  4443. if (mutations.some(function (mutation) {
  4444. return mutation.type === 'characterData' && mutation.target === _this2.textNode;
  4445. })) {
  4446. var range = this.restore();
  4447. if (range) context.range = range;
  4448. }
  4449. }
  4450. }, {
  4451. key: 'value',
  4452. value: function value() {
  4453. return '';
  4454. }
  4455. }]);
  4456. return Cursor;
  4457. }(_parchment2.default.Embed);
  4458. Cursor.blotName = 'cursor';
  4459. Cursor.className = 'ql-cursor';
  4460. Cursor.tagName = 'span';
  4461. Cursor.CONTENTS = '\uFEFF'; // Zero width no break space
  4462. exports.default = Cursor;
  4463. /***/ }),
  4464. /* 25 */
  4465. /***/ (function(module, exports, __webpack_require__) {
  4466. "use strict";
  4467. Object.defineProperty(exports, "__esModule", {
  4468. value: true
  4469. });
  4470. var _parchment = __webpack_require__(0);
  4471. var _parchment2 = _interopRequireDefault(_parchment);
  4472. var _block = __webpack_require__(4);
  4473. var _block2 = _interopRequireDefault(_block);
  4474. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4475. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4476. 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; }
  4477. 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; }
  4478. var Container = function (_Parchment$Container) {
  4479. _inherits(Container, _Parchment$Container);
  4480. function Container() {
  4481. _classCallCheck(this, Container);
  4482. return _possibleConstructorReturn(this, (Container.__proto__ || Object.getPrototypeOf(Container)).apply(this, arguments));
  4483. }
  4484. return Container;
  4485. }(_parchment2.default.Container);
  4486. Container.allowedChildren = [_block2.default, _block.BlockEmbed, Container];
  4487. exports.default = Container;
  4488. /***/ }),
  4489. /* 26 */
  4490. /***/ (function(module, exports, __webpack_require__) {
  4491. "use strict";
  4492. Object.defineProperty(exports, "__esModule", {
  4493. value: true
  4494. });
  4495. exports.ColorStyle = exports.ColorClass = exports.ColorAttributor = undefined;
  4496. 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; }; }();
  4497. 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); } };
  4498. var _parchment = __webpack_require__(0);
  4499. var _parchment2 = _interopRequireDefault(_parchment);
  4500. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4501. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4502. 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; }
  4503. 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; }
  4504. var ColorAttributor = function (_Parchment$Attributor) {
  4505. _inherits(ColorAttributor, _Parchment$Attributor);
  4506. function ColorAttributor() {
  4507. _classCallCheck(this, ColorAttributor);
  4508. return _possibleConstructorReturn(this, (ColorAttributor.__proto__ || Object.getPrototypeOf(ColorAttributor)).apply(this, arguments));
  4509. }
  4510. _createClass(ColorAttributor, [{
  4511. key: 'value',
  4512. value: function value(domNode) {
  4513. var value = _get(ColorAttributor.prototype.__proto__ || Object.getPrototypeOf(ColorAttributor.prototype), 'value', this).call(this, domNode);
  4514. if (!value.startsWith('rgb(')) return value;
  4515. value = value.replace(/^[^\d]+/, '').replace(/[^\d]+$/, '');
  4516. return '#' + value.split(',').map(function (component) {
  4517. return ('00' + parseInt(component).toString(16)).slice(-2);
  4518. }).join('');
  4519. }
  4520. }]);
  4521. return ColorAttributor;
  4522. }(_parchment2.default.Attributor.Style);
  4523. var ColorClass = new _parchment2.default.Attributor.Class('color', 'ql-color', {
  4524. scope: _parchment2.default.Scope.INLINE
  4525. });
  4526. var ColorStyle = new ColorAttributor('color', 'color', {
  4527. scope: _parchment2.default.Scope.INLINE
  4528. });
  4529. exports.ColorAttributor = ColorAttributor;
  4530. exports.ColorClass = ColorClass;
  4531. exports.ColorStyle = ColorStyle;
  4532. /***/ }),
  4533. /* 27 */,
  4534. /* 28 */,
  4535. /* 29 */
  4536. /***/ (function(module, exports, __webpack_require__) {
  4537. "use strict";
  4538. Object.defineProperty(exports, "__esModule", {
  4539. value: true
  4540. });
  4541. var _parchment = __webpack_require__(0);
  4542. var _parchment2 = _interopRequireDefault(_parchment);
  4543. var _quill = __webpack_require__(5);
  4544. var _quill2 = _interopRequireDefault(_quill);
  4545. var _block = __webpack_require__(4);
  4546. var _block2 = _interopRequireDefault(_block);
  4547. var _break = __webpack_require__(16);
  4548. var _break2 = _interopRequireDefault(_break);
  4549. var _container = __webpack_require__(25);
  4550. var _container2 = _interopRequireDefault(_container);
  4551. var _cursor = __webpack_require__(24);
  4552. var _cursor2 = _interopRequireDefault(_cursor);
  4553. var _embed = __webpack_require__(35);
  4554. var _embed2 = _interopRequireDefault(_embed);
  4555. var _inline = __webpack_require__(6);
  4556. var _inline2 = _interopRequireDefault(_inline);
  4557. var _scroll = __webpack_require__(22);
  4558. var _scroll2 = _interopRequireDefault(_scroll);
  4559. var _text = __webpack_require__(7);
  4560. var _text2 = _interopRequireDefault(_text);
  4561. var _clipboard = __webpack_require__(55);
  4562. var _clipboard2 = _interopRequireDefault(_clipboard);
  4563. var _history = __webpack_require__(42);
  4564. var _history2 = _interopRequireDefault(_history);
  4565. var _keyboard = __webpack_require__(23);
  4566. var _keyboard2 = _interopRequireDefault(_keyboard);
  4567. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4568. _quill2.default.register({
  4569. 'blots/block': _block2.default,
  4570. 'blots/block/embed': _block.BlockEmbed,
  4571. 'blots/break': _break2.default,
  4572. 'blots/container': _container2.default,
  4573. 'blots/cursor': _cursor2.default,
  4574. 'blots/embed': _embed2.default,
  4575. 'blots/inline': _inline2.default,
  4576. 'blots/scroll': _scroll2.default,
  4577. 'blots/text': _text2.default,
  4578. 'modules/clipboard': _clipboard2.default,
  4579. 'modules/history': _history2.default,
  4580. 'modules/keyboard': _keyboard2.default
  4581. });
  4582. _parchment2.default.register(_block2.default, _break2.default, _cursor2.default, _inline2.default, _scroll2.default, _text2.default);
  4583. exports.default = _quill2.default;
  4584. /***/ }),
  4585. /* 30 */
  4586. /***/ (function(module, exports, __webpack_require__) {
  4587. "use strict";
  4588. Object.defineProperty(exports, "__esModule", { value: true });
  4589. var Registry = __webpack_require__(1);
  4590. var ShadowBlot = /** @class */ (function () {
  4591. function ShadowBlot(domNode) {
  4592. this.domNode = domNode;
  4593. // @ts-ignore
  4594. this.domNode[Registry.DATA_KEY] = { blot: this };
  4595. }
  4596. Object.defineProperty(ShadowBlot.prototype, "statics", {
  4597. // Hack for accessing inherited static methods
  4598. get: function () {
  4599. return this.constructor;
  4600. },
  4601. enumerable: true,
  4602. configurable: true
  4603. });
  4604. ShadowBlot.create = function (value) {
  4605. if (this.tagName == null) {
  4606. throw new Registry.ParchmentError('Blot definition missing tagName');
  4607. }
  4608. var node;
  4609. if (Array.isArray(this.tagName)) {
  4610. if (typeof value === 'string') {
  4611. value = value.toUpperCase();
  4612. if (parseInt(value).toString() === value) {
  4613. value = parseInt(value);
  4614. }
  4615. }
  4616. if (typeof value === 'number') {
  4617. node = document.createElement(this.tagName[value - 1]);
  4618. }
  4619. else if (this.tagName.indexOf(value) > -1) {
  4620. node = document.createElement(value);
  4621. }
  4622. else {
  4623. node = document.createElement(this.tagName[0]);
  4624. }
  4625. }
  4626. else {
  4627. node = document.createElement(this.tagName);
  4628. }
  4629. if (this.className) {
  4630. node.classList.add(this.className);
  4631. }
  4632. return node;
  4633. };
  4634. ShadowBlot.prototype.attach = function () {
  4635. if (this.parent != null) {
  4636. this.scroll = this.parent.scroll;
  4637. }
  4638. };
  4639. ShadowBlot.prototype.clone = function () {
  4640. var domNode = this.domNode.cloneNode(false);
  4641. return Registry.create(domNode);
  4642. };
  4643. ShadowBlot.prototype.detach = function () {
  4644. if (this.parent != null)
  4645. this.parent.removeChild(this);
  4646. // @ts-ignore
  4647. delete this.domNode[Registry.DATA_KEY];
  4648. };
  4649. ShadowBlot.prototype.deleteAt = function (index, length) {
  4650. var blot = this.isolate(index, length);
  4651. blot.remove();
  4652. };
  4653. ShadowBlot.prototype.formatAt = function (index, length, name, value) {
  4654. var blot = this.isolate(index, length);
  4655. if (Registry.query(name, Registry.Scope.BLOT) != null && value) {
  4656. blot.wrap(name, value);
  4657. }
  4658. else if (Registry.query(name, Registry.Scope.ATTRIBUTE) != null) {
  4659. var parent = Registry.create(this.statics.scope);
  4660. blot.wrap(parent);
  4661. parent.format(name, value);
  4662. }
  4663. };
  4664. ShadowBlot.prototype.insertAt = function (index, value, def) {
  4665. var blot = def == null ? Registry.create('text', value) : Registry.create(value, def);
  4666. var ref = this.split(index);
  4667. this.parent.insertBefore(blot, ref);
  4668. };
  4669. ShadowBlot.prototype.insertInto = function (parentBlot, refBlot) {
  4670. if (refBlot === void 0) { refBlot = null; }
  4671. if (this.parent != null) {
  4672. this.parent.children.remove(this);
  4673. }
  4674. var refDomNode = null;
  4675. parentBlot.children.insertBefore(this, refBlot);
  4676. if (refBlot != null) {
  4677. refDomNode = refBlot.domNode;
  4678. }
  4679. if (this.domNode.parentNode != parentBlot.domNode ||
  4680. this.domNode.nextSibling != refDomNode) {
  4681. parentBlot.domNode.insertBefore(this.domNode, refDomNode);
  4682. }
  4683. this.parent = parentBlot;
  4684. this.attach();
  4685. };
  4686. ShadowBlot.prototype.isolate = function (index, length) {
  4687. var target = this.split(index);
  4688. target.split(length);
  4689. return target;
  4690. };
  4691. ShadowBlot.prototype.length = function () {
  4692. return 1;
  4693. };
  4694. ShadowBlot.prototype.offset = function (root) {
  4695. if (root === void 0) { root = this.parent; }
  4696. if (this.parent == null || this == root)
  4697. return 0;
  4698. return this.parent.children.offset(this) + this.parent.offset(root);
  4699. };
  4700. ShadowBlot.prototype.optimize = function (context) {
  4701. // TODO clean up once we use WeakMap
  4702. // @ts-ignore
  4703. if (this.domNode[Registry.DATA_KEY] != null) {
  4704. // @ts-ignore
  4705. delete this.domNode[Registry.DATA_KEY].mutations;
  4706. }
  4707. };
  4708. ShadowBlot.prototype.remove = function () {
  4709. if (this.domNode.parentNode != null) {
  4710. this.domNode.parentNode.removeChild(this.domNode);
  4711. }
  4712. this.detach();
  4713. };
  4714. ShadowBlot.prototype.replace = function (target) {
  4715. if (target.parent == null)
  4716. return;
  4717. target.parent.insertBefore(this, target.next);
  4718. target.remove();
  4719. };
  4720. ShadowBlot.prototype.replaceWith = function (name, value) {
  4721. var replacement = typeof name === 'string' ? Registry.create(name, value) : name;
  4722. replacement.replace(this);
  4723. return replacement;
  4724. };
  4725. ShadowBlot.prototype.split = function (index, force) {
  4726. return index === 0 ? this : this.next;
  4727. };
  4728. ShadowBlot.prototype.update = function (mutations, context) {
  4729. // Nothing to do by default
  4730. };
  4731. ShadowBlot.prototype.wrap = function (name, value) {
  4732. var wrapper = typeof name === 'string' ? Registry.create(name, value) : name;
  4733. if (this.parent != null) {
  4734. this.parent.insertBefore(wrapper, this.next);
  4735. }
  4736. wrapper.appendChild(this);
  4737. return wrapper;
  4738. };
  4739. ShadowBlot.blotName = 'abstract';
  4740. return ShadowBlot;
  4741. }());
  4742. exports.default = ShadowBlot;
  4743. /***/ }),
  4744. /* 31 */
  4745. /***/ (function(module, exports, __webpack_require__) {
  4746. "use strict";
  4747. Object.defineProperty(exports, "__esModule", { value: true });
  4748. var attributor_1 = __webpack_require__(12);
  4749. var class_1 = __webpack_require__(32);
  4750. var style_1 = __webpack_require__(33);
  4751. var Registry = __webpack_require__(1);
  4752. var AttributorStore = /** @class */ (function () {
  4753. function AttributorStore(domNode) {
  4754. this.attributes = {};
  4755. this.domNode = domNode;
  4756. this.build();
  4757. }
  4758. AttributorStore.prototype.attribute = function (attribute, value) {
  4759. // verb
  4760. if (value) {
  4761. if (attribute.add(this.domNode, value)) {
  4762. if (attribute.value(this.domNode) != null) {
  4763. this.attributes[attribute.attrName] = attribute;
  4764. }
  4765. else {
  4766. delete this.attributes[attribute.attrName];
  4767. }
  4768. }
  4769. }
  4770. else {
  4771. attribute.remove(this.domNode);
  4772. delete this.attributes[attribute.attrName];
  4773. }
  4774. };
  4775. AttributorStore.prototype.build = function () {
  4776. var _this = this;
  4777. this.attributes = {};
  4778. var attributes = attributor_1.default.keys(this.domNode);
  4779. var classes = class_1.default.keys(this.domNode);
  4780. var styles = style_1.default.keys(this.domNode);
  4781. attributes
  4782. .concat(classes)
  4783. .concat(styles)
  4784. .forEach(function (name) {
  4785. var attr = Registry.query(name, Registry.Scope.ATTRIBUTE);
  4786. if (attr instanceof attributor_1.default) {
  4787. _this.attributes[attr.attrName] = attr;
  4788. }
  4789. });
  4790. };
  4791. AttributorStore.prototype.copy = function (target) {
  4792. var _this = this;
  4793. Object.keys(this.attributes).forEach(function (key) {
  4794. var value = _this.attributes[key].value(_this.domNode);
  4795. target.format(key, value);
  4796. });
  4797. };
  4798. AttributorStore.prototype.move = function (target) {
  4799. var _this = this;
  4800. this.copy(target);
  4801. Object.keys(this.attributes).forEach(function (key) {
  4802. _this.attributes[key].remove(_this.domNode);
  4803. });
  4804. this.attributes = {};
  4805. };
  4806. AttributorStore.prototype.values = function () {
  4807. var _this = this;
  4808. return Object.keys(this.attributes).reduce(function (attributes, name) {
  4809. attributes[name] = _this.attributes[name].value(_this.domNode);
  4810. return attributes;
  4811. }, {});
  4812. };
  4813. return AttributorStore;
  4814. }());
  4815. exports.default = AttributorStore;
  4816. /***/ }),
  4817. /* 32 */
  4818. /***/ (function(module, exports, __webpack_require__) {
  4819. "use strict";
  4820. var __extends = (this && this.__extends) || (function () {
  4821. var extendStatics = Object.setPrototypeOf ||
  4822. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4823. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4824. return function (d, b) {
  4825. extendStatics(d, b);
  4826. function __() { this.constructor = d; }
  4827. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4828. };
  4829. })();
  4830. Object.defineProperty(exports, "__esModule", { value: true });
  4831. var attributor_1 = __webpack_require__(12);
  4832. function match(node, prefix) {
  4833. var className = node.getAttribute('class') || '';
  4834. return className.split(/\s+/).filter(function (name) {
  4835. return name.indexOf(prefix + "-") === 0;
  4836. });
  4837. }
  4838. var ClassAttributor = /** @class */ (function (_super) {
  4839. __extends(ClassAttributor, _super);
  4840. function ClassAttributor() {
  4841. return _super !== null && _super.apply(this, arguments) || this;
  4842. }
  4843. ClassAttributor.keys = function (node) {
  4844. return (node.getAttribute('class') || '').split(/\s+/).map(function (name) {
  4845. return name
  4846. .split('-')
  4847. .slice(0, -1)
  4848. .join('-');
  4849. });
  4850. };
  4851. ClassAttributor.prototype.add = function (node, value) {
  4852. if (!this.canAdd(node, value))
  4853. return false;
  4854. this.remove(node);
  4855. node.classList.add(this.keyName + "-" + value);
  4856. return true;
  4857. };
  4858. ClassAttributor.prototype.remove = function (node) {
  4859. var matches = match(node, this.keyName);
  4860. matches.forEach(function (name) {
  4861. node.classList.remove(name);
  4862. });
  4863. if (node.classList.length === 0) {
  4864. node.removeAttribute('class');
  4865. }
  4866. };
  4867. ClassAttributor.prototype.value = function (node) {
  4868. var result = match(node, this.keyName)[0] || '';
  4869. var value = result.slice(this.keyName.length + 1); // +1 for hyphen
  4870. return this.canAdd(node, value) ? value : '';
  4871. };
  4872. return ClassAttributor;
  4873. }(attributor_1.default));
  4874. exports.default = ClassAttributor;
  4875. /***/ }),
  4876. /* 33 */
  4877. /***/ (function(module, exports, __webpack_require__) {
  4878. "use strict";
  4879. var __extends = (this && this.__extends) || (function () {
  4880. var extendStatics = Object.setPrototypeOf ||
  4881. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4882. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4883. return function (d, b) {
  4884. extendStatics(d, b);
  4885. function __() { this.constructor = d; }
  4886. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4887. };
  4888. })();
  4889. Object.defineProperty(exports, "__esModule", { value: true });
  4890. var attributor_1 = __webpack_require__(12);
  4891. function camelize(name) {
  4892. var parts = name.split('-');
  4893. var rest = parts
  4894. .slice(1)
  4895. .map(function (part) {
  4896. return part[0].toUpperCase() + part.slice(1);
  4897. })
  4898. .join('');
  4899. return parts[0] + rest;
  4900. }
  4901. var StyleAttributor = /** @class */ (function (_super) {
  4902. __extends(StyleAttributor, _super);
  4903. function StyleAttributor() {
  4904. return _super !== null && _super.apply(this, arguments) || this;
  4905. }
  4906. StyleAttributor.keys = function (node) {
  4907. return (node.getAttribute('style') || '').split(';').map(function (value) {
  4908. var arr = value.split(':');
  4909. return arr[0].trim();
  4910. });
  4911. };
  4912. StyleAttributor.prototype.add = function (node, value) {
  4913. if (!this.canAdd(node, value))
  4914. return false;
  4915. // @ts-ignore
  4916. node.style[camelize(this.keyName)] = value;
  4917. return true;
  4918. };
  4919. StyleAttributor.prototype.remove = function (node) {
  4920. // @ts-ignore
  4921. node.style[camelize(this.keyName)] = '';
  4922. if (!node.getAttribute('style')) {
  4923. node.removeAttribute('style');
  4924. }
  4925. };
  4926. StyleAttributor.prototype.value = function (node) {
  4927. // @ts-ignore
  4928. var value = node.style[camelize(this.keyName)];
  4929. return this.canAdd(node, value) ? value : '';
  4930. };
  4931. return StyleAttributor;
  4932. }(attributor_1.default));
  4933. exports.default = StyleAttributor;
  4934. /***/ }),
  4935. /* 34 */
  4936. /***/ (function(module, exports, __webpack_require__) {
  4937. "use strict";
  4938. Object.defineProperty(exports, "__esModule", {
  4939. value: true
  4940. });
  4941. 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; }; }();
  4942. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4943. var Theme = function () {
  4944. function Theme(quill, options) {
  4945. _classCallCheck(this, Theme);
  4946. this.quill = quill;
  4947. this.options = options;
  4948. this.modules = {};
  4949. }
  4950. _createClass(Theme, [{
  4951. key: 'init',
  4952. value: function init() {
  4953. var _this = this;
  4954. Object.keys(this.options.modules).forEach(function (name) {
  4955. if (_this.modules[name] == null) {
  4956. _this.addModule(name);
  4957. }
  4958. });
  4959. }
  4960. }, {
  4961. key: 'addModule',
  4962. value: function addModule(name) {
  4963. var moduleClass = this.quill.constructor.import('modules/' + name);
  4964. this.modules[name] = new moduleClass(this.quill, this.options.modules[name] || {});
  4965. return this.modules[name];
  4966. }
  4967. }]);
  4968. return Theme;
  4969. }();
  4970. Theme.DEFAULTS = {
  4971. modules: {}
  4972. };
  4973. Theme.themes = {
  4974. 'default': Theme
  4975. };
  4976. exports.default = Theme;
  4977. /***/ }),
  4978. /* 35 */
  4979. /***/ (function(module, exports, __webpack_require__) {
  4980. "use strict";
  4981. Object.defineProperty(exports, "__esModule", {
  4982. value: true
  4983. });
  4984. 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; }; }();
  4985. 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); } };
  4986. var _parchment = __webpack_require__(0);
  4987. var _parchment2 = _interopRequireDefault(_parchment);
  4988. var _text = __webpack_require__(7);
  4989. var _text2 = _interopRequireDefault(_text);
  4990. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4991. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4992. 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; }
  4993. 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; }
  4994. var GUARD_TEXT = '\uFEFF';
  4995. var Embed = function (_Parchment$Embed) {
  4996. _inherits(Embed, _Parchment$Embed);
  4997. function Embed(node) {
  4998. _classCallCheck(this, Embed);
  4999. var _this = _possibleConstructorReturn(this, (Embed.__proto__ || Object.getPrototypeOf(Embed)).call(this, node));
  5000. _this.contentNode = document.createElement('span');
  5001. _this.contentNode.setAttribute('contenteditable', false);
  5002. [].slice.call(_this.domNode.childNodes).forEach(function (childNode) {
  5003. _this.contentNode.appendChild(childNode);
  5004. });
  5005. _this.leftGuard = document.createTextNode(GUARD_TEXT);
  5006. _this.rightGuard = document.createTextNode(GUARD_TEXT);
  5007. _this.domNode.appendChild(_this.leftGuard);
  5008. _this.domNode.appendChild(_this.contentNode);
  5009. _this.domNode.appendChild(_this.rightGuard);
  5010. return _this;
  5011. }
  5012. _createClass(Embed, [{
  5013. key: 'index',
  5014. value: function index(node, offset) {
  5015. if (node === this.leftGuard) return 0;
  5016. if (node === this.rightGuard) return 1;
  5017. return _get(Embed.prototype.__proto__ || Object.getPrototypeOf(Embed.prototype), 'index', this).call(this, node, offset);
  5018. }
  5019. }, {
  5020. key: 'restore',
  5021. value: function restore(node) {
  5022. var range = void 0,
  5023. textNode = void 0;
  5024. var text = node.data.split(GUARD_TEXT).join('');
  5025. if (node === this.leftGuard) {
  5026. if (this.prev instanceof _text2.default) {
  5027. var prevLength = this.prev.length();
  5028. this.prev.insertAt(prevLength, text);
  5029. range = {
  5030. startNode: this.prev.domNode,
  5031. startOffset: prevLength + text.length
  5032. };
  5033. } else {
  5034. textNode = document.createTextNode(text);
  5035. this.parent.insertBefore(_parchment2.default.create(textNode), this);
  5036. range = {
  5037. startNode: textNode,
  5038. startOffset: text.length
  5039. };
  5040. }
  5041. } else if (node === this.rightGuard) {
  5042. if (this.next instanceof _text2.default) {
  5043. this.next.insertAt(0, text);
  5044. range = {
  5045. startNode: this.next.domNode,
  5046. startOffset: text.length
  5047. };
  5048. } else {
  5049. textNode = document.createTextNode(text);
  5050. this.parent.insertBefore(_parchment2.default.create(textNode), this.next);
  5051. range = {
  5052. startNode: textNode,
  5053. startOffset: text.length
  5054. };
  5055. }
  5056. }
  5057. node.data = GUARD_TEXT;
  5058. return range;
  5059. }
  5060. }, {
  5061. key: 'update',
  5062. value: function update(mutations, context) {
  5063. var _this2 = this;
  5064. mutations.forEach(function (mutation) {
  5065. if (mutation.type === 'characterData' && (mutation.target === _this2.leftGuard || mutation.target === _this2.rightGuard)) {
  5066. var range = _this2.restore(mutation.target);
  5067. if (range) context.range = range;
  5068. }
  5069. });
  5070. }
  5071. }]);
  5072. return Embed;
  5073. }(_parchment2.default.Embed);
  5074. exports.default = Embed;
  5075. /***/ }),
  5076. /* 36 */
  5077. /***/ (function(module, exports, __webpack_require__) {
  5078. "use strict";
  5079. Object.defineProperty(exports, "__esModule", {
  5080. value: true
  5081. });
  5082. exports.AlignStyle = exports.AlignClass = exports.AlignAttribute = undefined;
  5083. var _parchment = __webpack_require__(0);
  5084. var _parchment2 = _interopRequireDefault(_parchment);
  5085. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5086. var config = {
  5087. scope: _parchment2.default.Scope.BLOCK,
  5088. whitelist: ['right', 'center', 'justify']
  5089. };
  5090. var AlignAttribute = new _parchment2.default.Attributor.Attribute('align', 'align', config);
  5091. var AlignClass = new _parchment2.default.Attributor.Class('align', 'ql-align', config);
  5092. var AlignStyle = new _parchment2.default.Attributor.Style('align', 'text-align', config);
  5093. exports.AlignAttribute = AlignAttribute;
  5094. exports.AlignClass = AlignClass;
  5095. exports.AlignStyle = AlignStyle;
  5096. /***/ }),
  5097. /* 37 */
  5098. /***/ (function(module, exports, __webpack_require__) {
  5099. "use strict";
  5100. Object.defineProperty(exports, "__esModule", {
  5101. value: true
  5102. });
  5103. exports.BackgroundStyle = exports.BackgroundClass = undefined;
  5104. var _parchment = __webpack_require__(0);
  5105. var _parchment2 = _interopRequireDefault(_parchment);
  5106. var _color = __webpack_require__(26);
  5107. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5108. var BackgroundClass = new _parchment2.default.Attributor.Class('background', 'ql-bg', {
  5109. scope: _parchment2.default.Scope.INLINE
  5110. });
  5111. var BackgroundStyle = new _color.ColorAttributor('background', 'background-color', {
  5112. scope: _parchment2.default.Scope.INLINE
  5113. });
  5114. exports.BackgroundClass = BackgroundClass;
  5115. exports.BackgroundStyle = BackgroundStyle;
  5116. /***/ }),
  5117. /* 38 */
  5118. /***/ (function(module, exports, __webpack_require__) {
  5119. "use strict";
  5120. Object.defineProperty(exports, "__esModule", {
  5121. value: true
  5122. });
  5123. exports.DirectionStyle = exports.DirectionClass = exports.DirectionAttribute = undefined;
  5124. var _parchment = __webpack_require__(0);
  5125. var _parchment2 = _interopRequireDefault(_parchment);
  5126. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5127. var config = {
  5128. scope: _parchment2.default.Scope.BLOCK,
  5129. whitelist: ['rtl']
  5130. };
  5131. var DirectionAttribute = new _parchment2.default.Attributor.Attribute('direction', 'dir', config);
  5132. var DirectionClass = new _parchment2.default.Attributor.Class('direction', 'ql-direction', config);
  5133. var DirectionStyle = new _parchment2.default.Attributor.Style('direction', 'direction', config);
  5134. exports.DirectionAttribute = DirectionAttribute;
  5135. exports.DirectionClass = DirectionClass;
  5136. exports.DirectionStyle = DirectionStyle;
  5137. /***/ }),
  5138. /* 39 */
  5139. /***/ (function(module, exports, __webpack_require__) {
  5140. "use strict";
  5141. Object.defineProperty(exports, "__esModule", {
  5142. value: true
  5143. });
  5144. exports.FontClass = exports.FontStyle = undefined;
  5145. 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; }; }();
  5146. 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); } };
  5147. var _parchment = __webpack_require__(0);
  5148. var _parchment2 = _interopRequireDefault(_parchment);
  5149. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5150. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5151. 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; }
  5152. 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; }
  5153. var config = {
  5154. scope: _parchment2.default.Scope.INLINE,
  5155. whitelist: ['serif', 'monospace']
  5156. };
  5157. var FontClass = new _parchment2.default.Attributor.Class('font', 'ql-font', config);
  5158. var FontStyleAttributor = function (_Parchment$Attributor) {
  5159. _inherits(FontStyleAttributor, _Parchment$Attributor);
  5160. function FontStyleAttributor() {
  5161. _classCallCheck(this, FontStyleAttributor);
  5162. return _possibleConstructorReturn(this, (FontStyleAttributor.__proto__ || Object.getPrototypeOf(FontStyleAttributor)).apply(this, arguments));
  5163. }
  5164. _createClass(FontStyleAttributor, [{
  5165. key: 'value',
  5166. value: function value(node) {
  5167. return _get(FontStyleAttributor.prototype.__proto__ || Object.getPrototypeOf(FontStyleAttributor.prototype), 'value', this).call(this, node).replace(/["']/g, '');
  5168. }
  5169. }]);
  5170. return FontStyleAttributor;
  5171. }(_parchment2.default.Attributor.Style);
  5172. var FontStyle = new FontStyleAttributor('font', 'font-family', config);
  5173. exports.FontStyle = FontStyle;
  5174. exports.FontClass = FontClass;
  5175. /***/ }),
  5176. /* 40 */
  5177. /***/ (function(module, exports, __webpack_require__) {
  5178. "use strict";
  5179. Object.defineProperty(exports, "__esModule", {
  5180. value: true
  5181. });
  5182. exports.SizeStyle = exports.SizeClass = undefined;
  5183. var _parchment = __webpack_require__(0);
  5184. var _parchment2 = _interopRequireDefault(_parchment);
  5185. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5186. var SizeClass = new _parchment2.default.Attributor.Class('size', 'ql-size', {
  5187. scope: _parchment2.default.Scope.INLINE,
  5188. whitelist: ['small', 'large', 'huge']
  5189. });
  5190. var SizeStyle = new _parchment2.default.Attributor.Style('size', 'font-size', {
  5191. scope: _parchment2.default.Scope.INLINE,
  5192. whitelist: ['10px', '18px', '32px']
  5193. });
  5194. exports.SizeClass = SizeClass;
  5195. exports.SizeStyle = SizeStyle;
  5196. /***/ }),
  5197. /* 41 */,
  5198. /* 42 */
  5199. /***/ (function(module, exports, __webpack_require__) {
  5200. "use strict";
  5201. Object.defineProperty(exports, "__esModule", {
  5202. value: true
  5203. });
  5204. exports.getLastChangeIndex = exports.default = undefined;
  5205. 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; }; }();
  5206. var _parchment = __webpack_require__(0);
  5207. var _parchment2 = _interopRequireDefault(_parchment);
  5208. var _quill = __webpack_require__(5);
  5209. var _quill2 = _interopRequireDefault(_quill);
  5210. var _module = __webpack_require__(9);
  5211. var _module2 = _interopRequireDefault(_module);
  5212. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5213. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5214. 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; }
  5215. 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; }
  5216. var History = function (_Module) {
  5217. _inherits(History, _Module);
  5218. function History(quill, options) {
  5219. _classCallCheck(this, History);
  5220. var _this = _possibleConstructorReturn(this, (History.__proto__ || Object.getPrototypeOf(History)).call(this, quill, options));
  5221. _this.lastRecorded = 0;
  5222. _this.ignoreChange = false;
  5223. _this.clear();
  5224. _this.quill.on(_quill2.default.events.EDITOR_CHANGE, function (eventName, delta, oldDelta, source) {
  5225. if (eventName !== _quill2.default.events.TEXT_CHANGE || _this.ignoreChange) return;
  5226. if (!_this.options.userOnly || source === _quill2.default.sources.USER) {
  5227. _this.record(delta, oldDelta);
  5228. } else {
  5229. _this.transform(delta);
  5230. }
  5231. });
  5232. _this.quill.keyboard.addBinding({ key: 'Z', shortKey: true }, _this.undo.bind(_this));
  5233. _this.quill.keyboard.addBinding({ key: 'Z', shortKey: true, shiftKey: true }, _this.redo.bind(_this));
  5234. if (/Win/i.test(navigator.platform)) {
  5235. _this.quill.keyboard.addBinding({ key: 'Y', shortKey: true }, _this.redo.bind(_this));
  5236. }
  5237. return _this;
  5238. }
  5239. _createClass(History, [{
  5240. key: 'change',
  5241. value: function change(source, dest) {
  5242. if (this.stack[source].length === 0) return;
  5243. var delta = this.stack[source].pop();
  5244. this.stack[dest].push(delta);
  5245. this.lastRecorded = 0;
  5246. this.ignoreChange = true;
  5247. this.quill.updateContents(delta[source], _quill2.default.sources.USER);
  5248. this.ignoreChange = false;
  5249. var index = getLastChangeIndex(delta[source]);
  5250. this.quill.setSelection(index);
  5251. }
  5252. }, {
  5253. key: 'clear',
  5254. value: function clear() {
  5255. this.stack = { undo: [], redo: [] };
  5256. }
  5257. }, {
  5258. key: 'cutoff',
  5259. value: function cutoff() {
  5260. this.lastRecorded = 0;
  5261. }
  5262. }, {
  5263. key: 'record',
  5264. value: function record(changeDelta, oldDelta) {
  5265. if (changeDelta.ops.length === 0) return;
  5266. this.stack.redo = [];
  5267. var undoDelta = this.quill.getContents().diff(oldDelta);
  5268. var timestamp = Date.now();
  5269. if (this.lastRecorded + this.options.delay > timestamp && this.stack.undo.length > 0) {
  5270. var delta = this.stack.undo.pop();
  5271. undoDelta = undoDelta.compose(delta.undo);
  5272. changeDelta = delta.redo.compose(changeDelta);
  5273. } else {
  5274. this.lastRecorded = timestamp;
  5275. }
  5276. this.stack.undo.push({
  5277. redo: changeDelta,
  5278. undo: undoDelta
  5279. });
  5280. if (this.stack.undo.length > this.options.maxStack) {
  5281. this.stack.undo.shift();
  5282. }
  5283. }
  5284. }, {
  5285. key: 'redo',
  5286. value: function redo() {
  5287. this.change('redo', 'undo');
  5288. }
  5289. }, {
  5290. key: 'transform',
  5291. value: function transform(delta) {
  5292. this.stack.undo.forEach(function (change) {
  5293. change.undo = delta.transform(change.undo, true);
  5294. change.redo = delta.transform(change.redo, true);
  5295. });
  5296. this.stack.redo.forEach(function (change) {
  5297. change.undo = delta.transform(change.undo, true);
  5298. change.redo = delta.transform(change.redo, true);
  5299. });
  5300. }
  5301. }, {
  5302. key: 'undo',
  5303. value: function undo() {
  5304. this.change('undo', 'redo');
  5305. }
  5306. }]);
  5307. return History;
  5308. }(_module2.default);
  5309. History.DEFAULTS = {
  5310. delay: 1000,
  5311. maxStack: 100,
  5312. userOnly: false
  5313. };
  5314. function endsWithNewlineChange(delta) {
  5315. var lastOp = delta.ops[delta.ops.length - 1];
  5316. if (lastOp == null) return false;
  5317. if (lastOp.insert != null) {
  5318. return typeof lastOp.insert === 'string' && lastOp.insert.endsWith('\n');
  5319. }
  5320. if (lastOp.attributes != null) {
  5321. return Object.keys(lastOp.attributes).some(function (attr) {
  5322. return _parchment2.default.query(attr, _parchment2.default.Scope.BLOCK) != null;
  5323. });
  5324. }
  5325. return false;
  5326. }
  5327. function getLastChangeIndex(delta) {
  5328. var deleteLength = delta.reduce(function (length, op) {
  5329. length += op.delete || 0;
  5330. return length;
  5331. }, 0);
  5332. var changeIndex = delta.length() - deleteLength;
  5333. if (endsWithNewlineChange(delta)) {
  5334. changeIndex -= 1;
  5335. }
  5336. return changeIndex;
  5337. }
  5338. exports.default = History;
  5339. exports.getLastChangeIndex = getLastChangeIndex;
  5340. /***/ }),
  5341. /* 43 */,
  5342. /* 44 */
  5343. /***/ (function(module, exports, __webpack_require__) {
  5344. "use strict";
  5345. Object.defineProperty(exports, "__esModule", { value: true });
  5346. var LinkedList = /** @class */ (function () {
  5347. function LinkedList() {
  5348. this.head = this.tail = null;
  5349. this.length = 0;
  5350. }
  5351. LinkedList.prototype.append = function () {
  5352. var nodes = [];
  5353. for (var _i = 0; _i < arguments.length; _i++) {
  5354. nodes[_i] = arguments[_i];
  5355. }
  5356. this.insertBefore(nodes[0], null);
  5357. if (nodes.length > 1) {
  5358. this.append.apply(this, nodes.slice(1));
  5359. }
  5360. };
  5361. LinkedList.prototype.contains = function (node) {
  5362. var cur, next = this.iterator();
  5363. while ((cur = next())) {
  5364. if (cur === node)
  5365. return true;
  5366. }
  5367. return false;
  5368. };
  5369. LinkedList.prototype.insertBefore = function (node, refNode) {
  5370. if (!node)
  5371. return;
  5372. node.next = refNode;
  5373. if (refNode != null) {
  5374. node.prev = refNode.prev;
  5375. if (refNode.prev != null) {
  5376. refNode.prev.next = node;
  5377. }
  5378. refNode.prev = node;
  5379. if (refNode === this.head) {
  5380. this.head = node;
  5381. }
  5382. }
  5383. else if (this.tail != null) {
  5384. this.tail.next = node;
  5385. node.prev = this.tail;
  5386. this.tail = node;
  5387. }
  5388. else {
  5389. node.prev = null;
  5390. this.head = this.tail = node;
  5391. }
  5392. this.length += 1;
  5393. };
  5394. LinkedList.prototype.offset = function (target) {
  5395. var index = 0, cur = this.head;
  5396. while (cur != null) {
  5397. if (cur === target)
  5398. return index;
  5399. index += cur.length();
  5400. cur = cur.next;
  5401. }
  5402. return -1;
  5403. };
  5404. LinkedList.prototype.remove = function (node) {
  5405. if (!this.contains(node))
  5406. return;
  5407. if (node.prev != null)
  5408. node.prev.next = node.next;
  5409. if (node.next != null)
  5410. node.next.prev = node.prev;
  5411. if (node === this.head)
  5412. this.head = node.next;
  5413. if (node === this.tail)
  5414. this.tail = node.prev;
  5415. this.length -= 1;
  5416. };
  5417. LinkedList.prototype.iterator = function (curNode) {
  5418. if (curNode === void 0) { curNode = this.head; }
  5419. // TODO use yield when we can
  5420. return function () {
  5421. var ret = curNode;
  5422. if (curNode != null)
  5423. curNode = curNode.next;
  5424. return ret;
  5425. };
  5426. };
  5427. LinkedList.prototype.find = function (index, inclusive) {
  5428. if (inclusive === void 0) { inclusive = false; }
  5429. var cur, next = this.iterator();
  5430. while ((cur = next())) {
  5431. var length = cur.length();
  5432. if (index < length ||
  5433. (inclusive && index === length && (cur.next == null || cur.next.length() !== 0))) {
  5434. return [cur, index];
  5435. }
  5436. index -= length;
  5437. }
  5438. return [null, 0];
  5439. };
  5440. LinkedList.prototype.forEach = function (callback) {
  5441. var cur, next = this.iterator();
  5442. while ((cur = next())) {
  5443. callback(cur);
  5444. }
  5445. };
  5446. LinkedList.prototype.forEachAt = function (index, length, callback) {
  5447. if (length <= 0)
  5448. return;
  5449. var _a = this.find(index), startNode = _a[0], offset = _a[1];
  5450. var cur, curIndex = index - offset, next = this.iterator(startNode);
  5451. while ((cur = next()) && curIndex < index + length) {
  5452. var curLength = cur.length();
  5453. if (index > curIndex) {
  5454. callback(cur, index - curIndex, Math.min(length, curIndex + curLength - index));
  5455. }
  5456. else {
  5457. callback(cur, 0, Math.min(curLength, index + length - curIndex));
  5458. }
  5459. curIndex += curLength;
  5460. }
  5461. };
  5462. LinkedList.prototype.map = function (callback) {
  5463. return this.reduce(function (memo, cur) {
  5464. memo.push(callback(cur));
  5465. return memo;
  5466. }, []);
  5467. };
  5468. LinkedList.prototype.reduce = function (callback, memo) {
  5469. var cur, next = this.iterator();
  5470. while ((cur = next())) {
  5471. memo = callback(memo, cur);
  5472. }
  5473. return memo;
  5474. };
  5475. return LinkedList;
  5476. }());
  5477. exports.default = LinkedList;
  5478. /***/ }),
  5479. /* 45 */
  5480. /***/ (function(module, exports, __webpack_require__) {
  5481. "use strict";
  5482. var __extends = (this && this.__extends) || (function () {
  5483. var extendStatics = Object.setPrototypeOf ||
  5484. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5485. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5486. return function (d, b) {
  5487. extendStatics(d, b);
  5488. function __() { this.constructor = d; }
  5489. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5490. };
  5491. })();
  5492. Object.defineProperty(exports, "__esModule", { value: true });
  5493. var container_1 = __webpack_require__(17);
  5494. var Registry = __webpack_require__(1);
  5495. var OBSERVER_CONFIG = {
  5496. attributes: true,
  5497. characterData: true,
  5498. characterDataOldValue: true,
  5499. childList: true,
  5500. subtree: true,
  5501. };
  5502. var MAX_OPTIMIZE_ITERATIONS = 100;
  5503. var ScrollBlot = /** @class */ (function (_super) {
  5504. __extends(ScrollBlot, _super);
  5505. function ScrollBlot(node) {
  5506. var _this = _super.call(this, node) || this;
  5507. _this.scroll = _this;
  5508. _this.observer = new MutationObserver(function (mutations) {
  5509. _this.update(mutations);
  5510. });
  5511. _this.observer.observe(_this.domNode, OBSERVER_CONFIG);
  5512. _this.attach();
  5513. return _this;
  5514. }
  5515. ScrollBlot.prototype.detach = function () {
  5516. _super.prototype.detach.call(this);
  5517. this.observer.disconnect();
  5518. };
  5519. ScrollBlot.prototype.deleteAt = function (index, length) {
  5520. this.update();
  5521. if (index === 0 && length === this.length()) {
  5522. this.children.forEach(function (child) {
  5523. child.remove();
  5524. });
  5525. }
  5526. else {
  5527. _super.prototype.deleteAt.call(this, index, length);
  5528. }
  5529. };
  5530. ScrollBlot.prototype.formatAt = function (index, length, name, value) {
  5531. this.update();
  5532. _super.prototype.formatAt.call(this, index, length, name, value);
  5533. };
  5534. ScrollBlot.prototype.insertAt = function (index, value, def) {
  5535. this.update();
  5536. _super.prototype.insertAt.call(this, index, value, def);
  5537. };
  5538. ScrollBlot.prototype.optimize = function (mutations, context) {
  5539. var _this = this;
  5540. if (mutations === void 0) { mutations = []; }
  5541. if (context === void 0) { context = {}; }
  5542. _super.prototype.optimize.call(this, context);
  5543. // We must modify mutations directly, cannot make copy and then modify
  5544. var records = [].slice.call(this.observer.takeRecords());
  5545. // Array.push currently seems to be implemented by a non-tail recursive function
  5546. // so we cannot just mutations.push.apply(mutations, this.observer.takeRecords());
  5547. while (records.length > 0)
  5548. mutations.push(records.pop());
  5549. // TODO use WeakMap
  5550. var mark = function (blot, markParent) {
  5551. if (markParent === void 0) { markParent = true; }
  5552. if (blot == null || blot === _this)
  5553. return;
  5554. if (blot.domNode.parentNode == null)
  5555. return;
  5556. // @ts-ignore
  5557. if (blot.domNode[Registry.DATA_KEY].mutations == null) {
  5558. // @ts-ignore
  5559. blot.domNode[Registry.DATA_KEY].mutations = [];
  5560. }
  5561. if (markParent)
  5562. mark(blot.parent);
  5563. };
  5564. var optimize = function (blot) {
  5565. // Post-order traversal
  5566. if (
  5567. // @ts-ignore
  5568. blot.domNode[Registry.DATA_KEY] == null ||
  5569. // @ts-ignore
  5570. blot.domNode[Registry.DATA_KEY].mutations == null) {
  5571. return;
  5572. }
  5573. if (blot instanceof container_1.default) {
  5574. blot.children.forEach(optimize);
  5575. }
  5576. blot.optimize(context);
  5577. };
  5578. var remaining = mutations;
  5579. for (var i = 0; remaining.length > 0; i += 1) {
  5580. if (i >= MAX_OPTIMIZE_ITERATIONS) {
  5581. throw new Error('[Parchment] Maximum optimize iterations reached');
  5582. }
  5583. remaining.forEach(function (mutation) {
  5584. var blot = Registry.find(mutation.target, true);
  5585. if (blot == null)
  5586. return;
  5587. if (blot.domNode === mutation.target) {
  5588. if (mutation.type === 'childList') {
  5589. mark(Registry.find(mutation.previousSibling, false));
  5590. [].forEach.call(mutation.addedNodes, function (node) {
  5591. var child = Registry.find(node, false);
  5592. mark(child, false);
  5593. if (child instanceof container_1.default) {
  5594. child.children.forEach(function (grandChild) {
  5595. mark(grandChild, false);
  5596. });
  5597. }
  5598. });
  5599. }
  5600. else if (mutation.type === 'attributes') {
  5601. mark(blot.prev);
  5602. }
  5603. }
  5604. mark(blot);
  5605. });
  5606. this.children.forEach(optimize);
  5607. remaining = [].slice.call(this.observer.takeRecords());
  5608. records = remaining.slice();
  5609. while (records.length > 0)
  5610. mutations.push(records.pop());
  5611. }
  5612. };
  5613. ScrollBlot.prototype.update = function (mutations, context) {
  5614. var _this = this;
  5615. if (context === void 0) { context = {}; }
  5616. mutations = mutations || this.observer.takeRecords();
  5617. // TODO use WeakMap
  5618. mutations
  5619. .map(function (mutation) {
  5620. var blot = Registry.find(mutation.target, true);
  5621. if (blot == null)
  5622. return null;
  5623. // @ts-ignore
  5624. if (blot.domNode[Registry.DATA_KEY].mutations == null) {
  5625. // @ts-ignore
  5626. blot.domNode[Registry.DATA_KEY].mutations = [mutation];
  5627. return blot;
  5628. }
  5629. else {
  5630. // @ts-ignore
  5631. blot.domNode[Registry.DATA_KEY].mutations.push(mutation);
  5632. return null;
  5633. }
  5634. })
  5635. .forEach(function (blot) {
  5636. if (blot == null ||
  5637. blot === _this ||
  5638. //@ts-ignore
  5639. blot.domNode[Registry.DATA_KEY] == null)
  5640. return;
  5641. // @ts-ignore
  5642. blot.update(blot.domNode[Registry.DATA_KEY].mutations || [], context);
  5643. });
  5644. // @ts-ignore
  5645. if (this.domNode[Registry.DATA_KEY].mutations != null) {
  5646. // @ts-ignore
  5647. _super.prototype.update.call(this, this.domNode[Registry.DATA_KEY].mutations, context);
  5648. }
  5649. this.optimize(mutations, context);
  5650. };
  5651. ScrollBlot.blotName = 'scroll';
  5652. ScrollBlot.defaultChild = 'block';
  5653. ScrollBlot.scope = Registry.Scope.BLOCK_BLOT;
  5654. ScrollBlot.tagName = 'DIV';
  5655. return ScrollBlot;
  5656. }(container_1.default));
  5657. exports.default = ScrollBlot;
  5658. /***/ }),
  5659. /* 46 */
  5660. /***/ (function(module, exports, __webpack_require__) {
  5661. "use strict";
  5662. var __extends = (this && this.__extends) || (function () {
  5663. var extendStatics = Object.setPrototypeOf ||
  5664. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5665. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5666. return function (d, b) {
  5667. extendStatics(d, b);
  5668. function __() { this.constructor = d; }
  5669. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5670. };
  5671. })();
  5672. Object.defineProperty(exports, "__esModule", { value: true });
  5673. var format_1 = __webpack_require__(18);
  5674. var Registry = __webpack_require__(1);
  5675. // Shallow object comparison
  5676. function isEqual(obj1, obj2) {
  5677. if (Object.keys(obj1).length !== Object.keys(obj2).length)
  5678. return false;
  5679. // @ts-ignore
  5680. for (var prop in obj1) {
  5681. // @ts-ignore
  5682. if (obj1[prop] !== obj2[prop])
  5683. return false;
  5684. }
  5685. return true;
  5686. }
  5687. var InlineBlot = /** @class */ (function (_super) {
  5688. __extends(InlineBlot, _super);
  5689. function InlineBlot() {
  5690. return _super !== null && _super.apply(this, arguments) || this;
  5691. }
  5692. InlineBlot.formats = function (domNode) {
  5693. if (domNode.tagName === InlineBlot.tagName)
  5694. return undefined;
  5695. return _super.formats.call(this, domNode);
  5696. };
  5697. InlineBlot.prototype.format = function (name, value) {
  5698. var _this = this;
  5699. if (name === this.statics.blotName && !value) {
  5700. this.children.forEach(function (child) {
  5701. if (!(child instanceof format_1.default)) {
  5702. child = child.wrap(InlineBlot.blotName, true);
  5703. }
  5704. _this.attributes.copy(child);
  5705. });
  5706. this.unwrap();
  5707. }
  5708. else {
  5709. _super.prototype.format.call(this, name, value);
  5710. }
  5711. };
  5712. InlineBlot.prototype.formatAt = function (index, length, name, value) {
  5713. if (this.formats()[name] != null || Registry.query(name, Registry.Scope.ATTRIBUTE)) {
  5714. var blot = this.isolate(index, length);
  5715. blot.format(name, value);
  5716. }
  5717. else {
  5718. _super.prototype.formatAt.call(this, index, length, name, value);
  5719. }
  5720. };
  5721. InlineBlot.prototype.optimize = function (context) {
  5722. _super.prototype.optimize.call(this, context);
  5723. var formats = this.formats();
  5724. if (Object.keys(formats).length === 0) {
  5725. return this.unwrap(); // unformatted span
  5726. }
  5727. var next = this.next;
  5728. if (next instanceof InlineBlot && next.prev === this && isEqual(formats, next.formats())) {
  5729. next.moveChildren(this);
  5730. next.remove();
  5731. }
  5732. };
  5733. InlineBlot.blotName = 'inline';
  5734. InlineBlot.scope = Registry.Scope.INLINE_BLOT;
  5735. InlineBlot.tagName = 'SPAN';
  5736. return InlineBlot;
  5737. }(format_1.default));
  5738. exports.default = InlineBlot;
  5739. /***/ }),
  5740. /* 47 */
  5741. /***/ (function(module, exports, __webpack_require__) {
  5742. "use strict";
  5743. var __extends = (this && this.__extends) || (function () {
  5744. var extendStatics = Object.setPrototypeOf ||
  5745. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5746. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5747. return function (d, b) {
  5748. extendStatics(d, b);
  5749. function __() { this.constructor = d; }
  5750. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5751. };
  5752. })();
  5753. Object.defineProperty(exports, "__esModule", { value: true });
  5754. var format_1 = __webpack_require__(18);
  5755. var Registry = __webpack_require__(1);
  5756. var BlockBlot = /** @class */ (function (_super) {
  5757. __extends(BlockBlot, _super);
  5758. function BlockBlot() {
  5759. return _super !== null && _super.apply(this, arguments) || this;
  5760. }
  5761. BlockBlot.formats = function (domNode) {
  5762. var tagName = Registry.query(BlockBlot.blotName).tagName;
  5763. if (domNode.tagName === tagName)
  5764. return undefined;
  5765. return _super.formats.call(this, domNode);
  5766. };
  5767. BlockBlot.prototype.format = function (name, value) {
  5768. if (Registry.query(name, Registry.Scope.BLOCK) == null) {
  5769. return;
  5770. }
  5771. else if (name === this.statics.blotName && !value) {
  5772. this.replaceWith(BlockBlot.blotName);
  5773. }
  5774. else {
  5775. _super.prototype.format.call(this, name, value);
  5776. }
  5777. };
  5778. BlockBlot.prototype.formatAt = function (index, length, name, value) {
  5779. if (Registry.query(name, Registry.Scope.BLOCK) != null) {
  5780. this.format(name, value);
  5781. }
  5782. else {
  5783. _super.prototype.formatAt.call(this, index, length, name, value);
  5784. }
  5785. };
  5786. BlockBlot.prototype.insertAt = function (index, value, def) {
  5787. if (def == null || Registry.query(value, Registry.Scope.INLINE) != null) {
  5788. // Insert text or inline
  5789. _super.prototype.insertAt.call(this, index, value, def);
  5790. }
  5791. else {
  5792. var after = this.split(index);
  5793. var blot = Registry.create(value, def);
  5794. after.parent.insertBefore(blot, after);
  5795. }
  5796. };
  5797. BlockBlot.prototype.update = function (mutations, context) {
  5798. if (navigator.userAgent.match(/Trident/)) {
  5799. this.build();
  5800. }
  5801. else {
  5802. _super.prototype.update.call(this, mutations, context);
  5803. }
  5804. };
  5805. BlockBlot.blotName = 'block';
  5806. BlockBlot.scope = Registry.Scope.BLOCK_BLOT;
  5807. BlockBlot.tagName = 'P';
  5808. return BlockBlot;
  5809. }(format_1.default));
  5810. exports.default = BlockBlot;
  5811. /***/ }),
  5812. /* 48 */
  5813. /***/ (function(module, exports, __webpack_require__) {
  5814. "use strict";
  5815. var __extends = (this && this.__extends) || (function () {
  5816. var extendStatics = Object.setPrototypeOf ||
  5817. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5818. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5819. return function (d, b) {
  5820. extendStatics(d, b);
  5821. function __() { this.constructor = d; }
  5822. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5823. };
  5824. })();
  5825. Object.defineProperty(exports, "__esModule", { value: true });
  5826. var leaf_1 = __webpack_require__(19);
  5827. var EmbedBlot = /** @class */ (function (_super) {
  5828. __extends(EmbedBlot, _super);
  5829. function EmbedBlot() {
  5830. return _super !== null && _super.apply(this, arguments) || this;
  5831. }
  5832. EmbedBlot.formats = function (domNode) {
  5833. return undefined;
  5834. };
  5835. EmbedBlot.prototype.format = function (name, value) {
  5836. // super.formatAt wraps, which is what we want in general,
  5837. // but this allows subclasses to overwrite for formats
  5838. // that just apply to particular embeds
  5839. _super.prototype.formatAt.call(this, 0, this.length(), name, value);
  5840. };
  5841. EmbedBlot.prototype.formatAt = function (index, length, name, value) {
  5842. if (index === 0 && length === this.length()) {
  5843. this.format(name, value);
  5844. }
  5845. else {
  5846. _super.prototype.formatAt.call(this, index, length, name, value);
  5847. }
  5848. };
  5849. EmbedBlot.prototype.formats = function () {
  5850. return this.statics.formats(this.domNode);
  5851. };
  5852. return EmbedBlot;
  5853. }(leaf_1.default));
  5854. exports.default = EmbedBlot;
  5855. /***/ }),
  5856. /* 49 */
  5857. /***/ (function(module, exports, __webpack_require__) {
  5858. "use strict";
  5859. var __extends = (this && this.__extends) || (function () {
  5860. var extendStatics = Object.setPrototypeOf ||
  5861. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5862. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5863. return function (d, b) {
  5864. extendStatics(d, b);
  5865. function __() { this.constructor = d; }
  5866. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5867. };
  5868. })();
  5869. Object.defineProperty(exports, "__esModule", { value: true });
  5870. var leaf_1 = __webpack_require__(19);
  5871. var Registry = __webpack_require__(1);
  5872. var TextBlot = /** @class */ (function (_super) {
  5873. __extends(TextBlot, _super);
  5874. function TextBlot(node) {
  5875. var _this = _super.call(this, node) || this;
  5876. _this.text = _this.statics.value(_this.domNode);
  5877. return _this;
  5878. }
  5879. TextBlot.create = function (value) {
  5880. return document.createTextNode(value);
  5881. };
  5882. TextBlot.value = function (domNode) {
  5883. var text = domNode.data;
  5884. // @ts-ignore
  5885. if (text['normalize'])
  5886. text = text['normalize']();
  5887. return text;
  5888. };
  5889. TextBlot.prototype.deleteAt = function (index, length) {
  5890. this.domNode.data = this.text = this.text.slice(0, index) + this.text.slice(index + length);
  5891. };
  5892. TextBlot.prototype.index = function (node, offset) {
  5893. if (this.domNode === node) {
  5894. return offset;
  5895. }
  5896. return -1;
  5897. };
  5898. TextBlot.prototype.insertAt = function (index, value, def) {
  5899. if (def == null) {
  5900. this.text = this.text.slice(0, index) + value + this.text.slice(index);
  5901. this.domNode.data = this.text;
  5902. }
  5903. else {
  5904. _super.prototype.insertAt.call(this, index, value, def);
  5905. }
  5906. };
  5907. TextBlot.prototype.length = function () {
  5908. return this.text.length;
  5909. };
  5910. TextBlot.prototype.optimize = function (context) {
  5911. _super.prototype.optimize.call(this, context);
  5912. this.text = this.statics.value(this.domNode);
  5913. if (this.text.length === 0) {
  5914. this.remove();
  5915. }
  5916. else if (this.next instanceof TextBlot && this.next.prev === this) {
  5917. this.insertAt(this.length(), this.next.value());
  5918. this.next.remove();
  5919. }
  5920. };
  5921. TextBlot.prototype.position = function (index, inclusive) {
  5922. if (inclusive === void 0) { inclusive = false; }
  5923. return [this.domNode, index];
  5924. };
  5925. TextBlot.prototype.split = function (index, force) {
  5926. if (force === void 0) { force = false; }
  5927. if (!force) {
  5928. if (index === 0)
  5929. return this;
  5930. if (index === this.length())
  5931. return this.next;
  5932. }
  5933. var after = Registry.create(this.domNode.splitText(index));
  5934. this.parent.insertBefore(after, this.next);
  5935. this.text = this.statics.value(this.domNode);
  5936. return after;
  5937. };
  5938. TextBlot.prototype.update = function (mutations, context) {
  5939. var _this = this;
  5940. if (mutations.some(function (mutation) {
  5941. return mutation.type === 'characterData' && mutation.target === _this.domNode;
  5942. })) {
  5943. this.text = this.statics.value(this.domNode);
  5944. }
  5945. };
  5946. TextBlot.prototype.value = function () {
  5947. return this.text;
  5948. };
  5949. TextBlot.blotName = 'text';
  5950. TextBlot.scope = Registry.Scope.INLINE_BLOT;
  5951. return TextBlot;
  5952. }(leaf_1.default));
  5953. exports.default = TextBlot;
  5954. /***/ }),
  5955. /* 50 */
  5956. /***/ (function(module, exports, __webpack_require__) {
  5957. "use strict";
  5958. var elem = document.createElement('div');
  5959. elem.classList.toggle('test-class', false);
  5960. if (elem.classList.contains('test-class')) {
  5961. var _toggle = DOMTokenList.prototype.toggle;
  5962. DOMTokenList.prototype.toggle = function (token, force) {
  5963. if (arguments.length > 1 && !this.contains(token) === !force) {
  5964. return force;
  5965. } else {
  5966. return _toggle.call(this, token);
  5967. }
  5968. };
  5969. }
  5970. if (!String.prototype.startsWith) {
  5971. String.prototype.startsWith = function (searchString, position) {
  5972. position = position || 0;
  5973. return this.substr(position, searchString.length) === searchString;
  5974. };
  5975. }
  5976. if (!String.prototype.endsWith) {
  5977. String.prototype.endsWith = function (searchString, position) {
  5978. var subjectString = this.toString();
  5979. if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
  5980. position = subjectString.length;
  5981. }
  5982. position -= searchString.length;
  5983. var lastIndex = subjectString.indexOf(searchString, position);
  5984. return lastIndex !== -1 && lastIndex === position;
  5985. };
  5986. }
  5987. if (!Array.prototype.find) {
  5988. Object.defineProperty(Array.prototype, "find", {
  5989. value: function value(predicate) {
  5990. if (this === null) {
  5991. throw new TypeError('Array.prototype.find called on null or undefined');
  5992. }
  5993. if (typeof predicate !== 'function') {
  5994. throw new TypeError('predicate must be a function');
  5995. }
  5996. var list = Object(this);
  5997. var length = list.length >>> 0;
  5998. var thisArg = arguments[1];
  5999. var value;
  6000. for (var i = 0; i < length; i++) {
  6001. value = list[i];
  6002. if (predicate.call(thisArg, value, i, list)) {
  6003. return value;
  6004. }
  6005. }
  6006. return undefined;
  6007. }
  6008. });
  6009. }
  6010. document.addEventListener("DOMContentLoaded", function () {
  6011. // Disable resizing in Firefox
  6012. document.execCommand("enableObjectResizing", false, false);
  6013. // Disable automatic linkifying in IE11
  6014. document.execCommand("autoUrlDetect", false, false);
  6015. });
  6016. /***/ }),
  6017. /* 51 */
  6018. /***/ (function(module, exports) {
  6019. /**
  6020. * This library modifies the diff-patch-match library by Neil Fraser
  6021. * by removing the patch and match functionality and certain advanced
  6022. * options in the diff function. The original license is as follows:
  6023. *
  6024. * ===
  6025. *
  6026. * Diff Match and Patch
  6027. *
  6028. * Copyright 2006 Google Inc.
  6029. * http://code.google.com/p/google-diff-match-patch/
  6030. *
  6031. * Licensed under the Apache License, Version 2.0 (the "License");
  6032. * you may not use this file except in compliance with the License.
  6033. * You may obtain a copy of the License at
  6034. *
  6035. * http://www.apache.org/licenses/LICENSE-2.0
  6036. *
  6037. * Unless required by applicable law or agreed to in writing, software
  6038. * distributed under the License is distributed on an "AS IS" BASIS,
  6039. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  6040. * See the License for the specific language governing permissions and
  6041. * limitations under the License.
  6042. */
  6043. /**
  6044. * The data structure representing a diff is an array of tuples:
  6045. * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
  6046. * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
  6047. */
  6048. var DIFF_DELETE = -1;
  6049. var DIFF_INSERT = 1;
  6050. var DIFF_EQUAL = 0;
  6051. /**
  6052. * Find the differences between two texts. Simplifies the problem by stripping
  6053. * any common prefix or suffix off the texts before diffing.
  6054. * @param {string} text1 Old string to be diffed.
  6055. * @param {string} text2 New string to be diffed.
  6056. * @param {Int} cursor_pos Expected edit position in text1 (optional)
  6057. * @return {Array} Array of diff tuples.
  6058. */
  6059. function diff_main(text1, text2, cursor_pos) {
  6060. // Check for equality (speedup).
  6061. if (text1 == text2) {
  6062. if (text1) {
  6063. return [[DIFF_EQUAL, text1]];
  6064. }
  6065. return [];
  6066. }
  6067. // Check cursor_pos within bounds
  6068. if (cursor_pos < 0 || text1.length < cursor_pos) {
  6069. cursor_pos = null;
  6070. }
  6071. // Trim off common prefix (speedup).
  6072. var commonlength = diff_commonPrefix(text1, text2);
  6073. var commonprefix = text1.substring(0, commonlength);
  6074. text1 = text1.substring(commonlength);
  6075. text2 = text2.substring(commonlength);
  6076. // Trim off common suffix (speedup).
  6077. commonlength = diff_commonSuffix(text1, text2);
  6078. var commonsuffix = text1.substring(text1.length - commonlength);
  6079. text1 = text1.substring(0, text1.length - commonlength);
  6080. text2 = text2.substring(0, text2.length - commonlength);
  6081. // Compute the diff on the middle block.
  6082. var diffs = diff_compute_(text1, text2);
  6083. // Restore the prefix and suffix.
  6084. if (commonprefix) {
  6085. diffs.unshift([DIFF_EQUAL, commonprefix]);
  6086. }
  6087. if (commonsuffix) {
  6088. diffs.push([DIFF_EQUAL, commonsuffix]);
  6089. }
  6090. diff_cleanupMerge(diffs);
  6091. if (cursor_pos != null) {
  6092. diffs = fix_cursor(diffs, cursor_pos);
  6093. }
  6094. diffs = fix_emoji(diffs);
  6095. return diffs;
  6096. };
  6097. /**
  6098. * Find the differences between two texts. Assumes that the texts do not
  6099. * have any common prefix or suffix.
  6100. * @param {string} text1 Old string to be diffed.
  6101. * @param {string} text2 New string to be diffed.
  6102. * @return {Array} Array of diff tuples.
  6103. */
  6104. function diff_compute_(text1, text2) {
  6105. var diffs;
  6106. if (!text1) {
  6107. // Just add some text (speedup).
  6108. return [[DIFF_INSERT, text2]];
  6109. }
  6110. if (!text2) {
  6111. // Just delete some text (speedup).
  6112. return [[DIFF_DELETE, text1]];
  6113. }
  6114. var longtext = text1.length > text2.length ? text1 : text2;
  6115. var shorttext = text1.length > text2.length ? text2 : text1;
  6116. var i = longtext.indexOf(shorttext);
  6117. if (i != -1) {
  6118. // Shorter text is inside the longer text (speedup).
  6119. diffs = [[DIFF_INSERT, longtext.substring(0, i)],
  6120. [DIFF_EQUAL, shorttext],
  6121. [DIFF_INSERT, longtext.substring(i + shorttext.length)]];
  6122. // Swap insertions for deletions if diff is reversed.
  6123. if (text1.length > text2.length) {
  6124. diffs[0][0] = diffs[2][0] = DIFF_DELETE;
  6125. }
  6126. return diffs;
  6127. }
  6128. if (shorttext.length == 1) {
  6129. // Single character string.
  6130. // After the previous speedup, the character can't be an equality.
  6131. return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
  6132. }
  6133. // Check to see if the problem can be split in two.
  6134. var hm = diff_halfMatch_(text1, text2);
  6135. if (hm) {
  6136. // A half-match was found, sort out the return data.
  6137. var text1_a = hm[0];
  6138. var text1_b = hm[1];
  6139. var text2_a = hm[2];
  6140. var text2_b = hm[3];
  6141. var mid_common = hm[4];
  6142. // Send both pairs off for separate processing.
  6143. var diffs_a = diff_main(text1_a, text2_a);
  6144. var diffs_b = diff_main(text1_b, text2_b);
  6145. // Merge the results.
  6146. return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b);
  6147. }
  6148. return diff_bisect_(text1, text2);
  6149. };
  6150. /**
  6151. * Find the 'middle snake' of a diff, split the problem in two
  6152. * and return the recursively constructed diff.
  6153. * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
  6154. * @param {string} text1 Old string to be diffed.
  6155. * @param {string} text2 New string to be diffed.
  6156. * @return {Array} Array of diff tuples.
  6157. * @private
  6158. */
  6159. function diff_bisect_(text1, text2) {
  6160. // Cache the text lengths to prevent multiple calls.
  6161. var text1_length = text1.length;
  6162. var text2_length = text2.length;
  6163. var max_d = Math.ceil((text1_length + text2_length) / 2);
  6164. var v_offset = max_d;
  6165. var v_length = 2 * max_d;
  6166. var v1 = new Array(v_length);
  6167. var v2 = new Array(v_length);
  6168. // Setting all elements to -1 is faster in Chrome & Firefox than mixing
  6169. // integers and undefined.
  6170. for (var x = 0; x < v_length; x++) {
  6171. v1[x] = -1;
  6172. v2[x] = -1;
  6173. }
  6174. v1[v_offset + 1] = 0;
  6175. v2[v_offset + 1] = 0;
  6176. var delta = text1_length - text2_length;
  6177. // If the total number of characters is odd, then the front path will collide
  6178. // with the reverse path.
  6179. var front = (delta % 2 != 0);
  6180. // Offsets for start and end of k loop.
  6181. // Prevents mapping of space beyond the grid.
  6182. var k1start = 0;
  6183. var k1end = 0;
  6184. var k2start = 0;
  6185. var k2end = 0;
  6186. for (var d = 0; d < max_d; d++) {
  6187. // Walk the front path one step.
  6188. for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
  6189. var k1_offset = v_offset + k1;
  6190. var x1;
  6191. if (k1 == -d || (k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1])) {
  6192. x1 = v1[k1_offset + 1];
  6193. } else {
  6194. x1 = v1[k1_offset - 1] + 1;
  6195. }
  6196. var y1 = x1 - k1;
  6197. while (x1 < text1_length && y1 < text2_length &&
  6198. text1.charAt(x1) == text2.charAt(y1)) {
  6199. x1++;
  6200. y1++;
  6201. }
  6202. v1[k1_offset] = x1;
  6203. if (x1 > text1_length) {
  6204. // Ran off the right of the graph.
  6205. k1end += 2;
  6206. } else if (y1 > text2_length) {
  6207. // Ran off the bottom of the graph.
  6208. k1start += 2;
  6209. } else if (front) {
  6210. var k2_offset = v_offset + delta - k1;
  6211. if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] != -1) {
  6212. // Mirror x2 onto top-left coordinate system.
  6213. var x2 = text1_length - v2[k2_offset];
  6214. if (x1 >= x2) {
  6215. // Overlap detected.
  6216. return diff_bisectSplit_(text1, text2, x1, y1);
  6217. }
  6218. }
  6219. }
  6220. }
  6221. // Walk the reverse path one step.
  6222. for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
  6223. var k2_offset = v_offset + k2;
  6224. var x2;
  6225. if (k2 == -d || (k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1])) {
  6226. x2 = v2[k2_offset + 1];
  6227. } else {
  6228. x2 = v2[k2_offset - 1] + 1;
  6229. }
  6230. var y2 = x2 - k2;
  6231. while (x2 < text1_length && y2 < text2_length &&
  6232. text1.charAt(text1_length - x2 - 1) ==
  6233. text2.charAt(text2_length - y2 - 1)) {
  6234. x2++;
  6235. y2++;
  6236. }
  6237. v2[k2_offset] = x2;
  6238. if (x2 > text1_length) {
  6239. // Ran off the left of the graph.
  6240. k2end += 2;
  6241. } else if (y2 > text2_length) {
  6242. // Ran off the top of the graph.
  6243. k2start += 2;
  6244. } else if (!front) {
  6245. var k1_offset = v_offset + delta - k2;
  6246. if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] != -1) {
  6247. var x1 = v1[k1_offset];
  6248. var y1 = v_offset + x1 - k1_offset;
  6249. // Mirror x2 onto top-left coordinate system.
  6250. x2 = text1_length - x2;
  6251. if (x1 >= x2) {
  6252. // Overlap detected.
  6253. return diff_bisectSplit_(text1, text2, x1, y1);
  6254. }
  6255. }
  6256. }
  6257. }
  6258. }
  6259. // Diff took too long and hit the deadline or
  6260. // number of diffs equals number of characters, no commonality at all.
  6261. return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
  6262. };
  6263. /**
  6264. * Given the location of the 'middle snake', split the diff in two parts
  6265. * and recurse.
  6266. * @param {string} text1 Old string to be diffed.
  6267. * @param {string} text2 New string to be diffed.
  6268. * @param {number} x Index of split point in text1.
  6269. * @param {number} y Index of split point in text2.
  6270. * @return {Array} Array of diff tuples.
  6271. */
  6272. function diff_bisectSplit_(text1, text2, x, y) {
  6273. var text1a = text1.substring(0, x);
  6274. var text2a = text2.substring(0, y);
  6275. var text1b = text1.substring(x);
  6276. var text2b = text2.substring(y);
  6277. // Compute both diffs serially.
  6278. var diffs = diff_main(text1a, text2a);
  6279. var diffsb = diff_main(text1b, text2b);
  6280. return diffs.concat(diffsb);
  6281. };
  6282. /**
  6283. * Determine the common prefix of two strings.
  6284. * @param {string} text1 First string.
  6285. * @param {string} text2 Second string.
  6286. * @return {number} The number of characters common to the start of each
  6287. * string.
  6288. */
  6289. function diff_commonPrefix(text1, text2) {
  6290. // Quick check for common null cases.
  6291. if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) {
  6292. return 0;
  6293. }
  6294. // Binary search.
  6295. // Performance analysis: http://neil.fraser.name/news/2007/10/09/
  6296. var pointermin = 0;
  6297. var pointermax = Math.min(text1.length, text2.length);
  6298. var pointermid = pointermax;
  6299. var pointerstart = 0;
  6300. while (pointermin < pointermid) {
  6301. if (text1.substring(pointerstart, pointermid) ==
  6302. text2.substring(pointerstart, pointermid)) {
  6303. pointermin = pointermid;
  6304. pointerstart = pointermin;
  6305. } else {
  6306. pointermax = pointermid;
  6307. }
  6308. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  6309. }
  6310. return pointermid;
  6311. };
  6312. /**
  6313. * Determine the common suffix of two strings.
  6314. * @param {string} text1 First string.
  6315. * @param {string} text2 Second string.
  6316. * @return {number} The number of characters common to the end of each string.
  6317. */
  6318. function diff_commonSuffix(text1, text2) {
  6319. // Quick check for common null cases.
  6320. if (!text1 || !text2 ||
  6321. text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)) {
  6322. return 0;
  6323. }
  6324. // Binary search.
  6325. // Performance analysis: http://neil.fraser.name/news/2007/10/09/
  6326. var pointermin = 0;
  6327. var pointermax = Math.min(text1.length, text2.length);
  6328. var pointermid = pointermax;
  6329. var pointerend = 0;
  6330. while (pointermin < pointermid) {
  6331. if (text1.substring(text1.length - pointermid, text1.length - pointerend) ==
  6332. text2.substring(text2.length - pointermid, text2.length - pointerend)) {
  6333. pointermin = pointermid;
  6334. pointerend = pointermin;
  6335. } else {
  6336. pointermax = pointermid;
  6337. }
  6338. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  6339. }
  6340. return pointermid;
  6341. };
  6342. /**
  6343. * Do the two texts share a substring which is at least half the length of the
  6344. * longer text?
  6345. * This speedup can produce non-minimal diffs.
  6346. * @param {string} text1 First string.
  6347. * @param {string} text2 Second string.
  6348. * @return {Array.<string>} Five element Array, containing the prefix of
  6349. * text1, the suffix of text1, the prefix of text2, the suffix of
  6350. * text2 and the common middle. Or null if there was no match.
  6351. */
  6352. function diff_halfMatch_(text1, text2) {
  6353. var longtext = text1.length > text2.length ? text1 : text2;
  6354. var shorttext = text1.length > text2.length ? text2 : text1;
  6355. if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
  6356. return null; // Pointless.
  6357. }
  6358. /**
  6359. * Does a substring of shorttext exist within longtext such that the substring
  6360. * is at least half the length of longtext?
  6361. * Closure, but does not reference any external variables.
  6362. * @param {string} longtext Longer string.
  6363. * @param {string} shorttext Shorter string.
  6364. * @param {number} i Start index of quarter length substring within longtext.
  6365. * @return {Array.<string>} Five element Array, containing the prefix of
  6366. * longtext, the suffix of longtext, the prefix of shorttext, the suffix
  6367. * of shorttext and the common middle. Or null if there was no match.
  6368. * @private
  6369. */
  6370. function diff_halfMatchI_(longtext, shorttext, i) {
  6371. // Start with a 1/4 length substring at position i as a seed.
  6372. var seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
  6373. var j = -1;
  6374. var best_common = '';
  6375. var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
  6376. while ((j = shorttext.indexOf(seed, j + 1)) != -1) {
  6377. var prefixLength = diff_commonPrefix(longtext.substring(i),
  6378. shorttext.substring(j));
  6379. var suffixLength = diff_commonSuffix(longtext.substring(0, i),
  6380. shorttext.substring(0, j));
  6381. if (best_common.length < suffixLength + prefixLength) {
  6382. best_common = shorttext.substring(j - suffixLength, j) +
  6383. shorttext.substring(j, j + prefixLength);
  6384. best_longtext_a = longtext.substring(0, i - suffixLength);
  6385. best_longtext_b = longtext.substring(i + prefixLength);
  6386. best_shorttext_a = shorttext.substring(0, j - suffixLength);
  6387. best_shorttext_b = shorttext.substring(j + prefixLength);
  6388. }
  6389. }
  6390. if (best_common.length * 2 >= longtext.length) {
  6391. return [best_longtext_a, best_longtext_b,
  6392. best_shorttext_a, best_shorttext_b, best_common];
  6393. } else {
  6394. return null;
  6395. }
  6396. }
  6397. // First check if the second quarter is the seed for a half-match.
  6398. var hm1 = diff_halfMatchI_(longtext, shorttext,
  6399. Math.ceil(longtext.length / 4));
  6400. // Check again based on the third quarter.
  6401. var hm2 = diff_halfMatchI_(longtext, shorttext,
  6402. Math.ceil(longtext.length / 2));
  6403. var hm;
  6404. if (!hm1 && !hm2) {
  6405. return null;
  6406. } else if (!hm2) {
  6407. hm = hm1;
  6408. } else if (!hm1) {
  6409. hm = hm2;
  6410. } else {
  6411. // Both matched. Select the longest.
  6412. hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
  6413. }
  6414. // A half-match was found, sort out the return data.
  6415. var text1_a, text1_b, text2_a, text2_b;
  6416. if (text1.length > text2.length) {
  6417. text1_a = hm[0];
  6418. text1_b = hm[1];
  6419. text2_a = hm[2];
  6420. text2_b = hm[3];
  6421. } else {
  6422. text2_a = hm[0];
  6423. text2_b = hm[1];
  6424. text1_a = hm[2];
  6425. text1_b = hm[3];
  6426. }
  6427. var mid_common = hm[4];
  6428. return [text1_a, text1_b, text2_a, text2_b, mid_common];
  6429. };
  6430. /**
  6431. * Reorder and merge like edit sections. Merge equalities.
  6432. * Any edit section can move as long as it doesn't cross an equality.
  6433. * @param {Array} diffs Array of diff tuples.
  6434. */
  6435. function diff_cleanupMerge(diffs) {
  6436. diffs.push([DIFF_EQUAL, '']); // Add a dummy entry at the end.
  6437. var pointer = 0;
  6438. var count_delete = 0;
  6439. var count_insert = 0;
  6440. var text_delete = '';
  6441. var text_insert = '';
  6442. var commonlength;
  6443. while (pointer < diffs.length) {
  6444. switch (diffs[pointer][0]) {
  6445. case DIFF_INSERT:
  6446. count_insert++;
  6447. text_insert += diffs[pointer][1];
  6448. pointer++;
  6449. break;
  6450. case DIFF_DELETE:
  6451. count_delete++;
  6452. text_delete += diffs[pointer][1];
  6453. pointer++;
  6454. break;
  6455. case DIFF_EQUAL:
  6456. // Upon reaching an equality, check for prior redundancies.
  6457. if (count_delete + count_insert > 1) {
  6458. if (count_delete !== 0 && count_insert !== 0) {
  6459. // Factor out any common prefixies.
  6460. commonlength = diff_commonPrefix(text_insert, text_delete);
  6461. if (commonlength !== 0) {
  6462. if ((pointer - count_delete - count_insert) > 0 &&
  6463. diffs[pointer - count_delete - count_insert - 1][0] ==
  6464. DIFF_EQUAL) {
  6465. diffs[pointer - count_delete - count_insert - 1][1] +=
  6466. text_insert.substring(0, commonlength);
  6467. } else {
  6468. diffs.splice(0, 0, [DIFF_EQUAL,
  6469. text_insert.substring(0, commonlength)]);
  6470. pointer++;
  6471. }
  6472. text_insert = text_insert.substring(commonlength);
  6473. text_delete = text_delete.substring(commonlength);
  6474. }
  6475. // Factor out any common suffixies.
  6476. commonlength = diff_commonSuffix(text_insert, text_delete);
  6477. if (commonlength !== 0) {
  6478. diffs[pointer][1] = text_insert.substring(text_insert.length -
  6479. commonlength) + diffs[pointer][1];
  6480. text_insert = text_insert.substring(0, text_insert.length -
  6481. commonlength);
  6482. text_delete = text_delete.substring(0, text_delete.length -
  6483. commonlength);
  6484. }
  6485. }
  6486. // Delete the offending records and add the merged ones.
  6487. if (count_delete === 0) {
  6488. diffs.splice(pointer - count_insert,
  6489. count_delete + count_insert, [DIFF_INSERT, text_insert]);
  6490. } else if (count_insert === 0) {
  6491. diffs.splice(pointer - count_delete,
  6492. count_delete + count_insert, [DIFF_DELETE, text_delete]);
  6493. } else {
  6494. diffs.splice(pointer - count_delete - count_insert,
  6495. count_delete + count_insert, [DIFF_DELETE, text_delete],
  6496. [DIFF_INSERT, text_insert]);
  6497. }
  6498. pointer = pointer - count_delete - count_insert +
  6499. (count_delete ? 1 : 0) + (count_insert ? 1 : 0) + 1;
  6500. } else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) {
  6501. // Merge this equality with the previous one.
  6502. diffs[pointer - 1][1] += diffs[pointer][1];
  6503. diffs.splice(pointer, 1);
  6504. } else {
  6505. pointer++;
  6506. }
  6507. count_insert = 0;
  6508. count_delete = 0;
  6509. text_delete = '';
  6510. text_insert = '';
  6511. break;
  6512. }
  6513. }
  6514. if (diffs[diffs.length - 1][1] === '') {
  6515. diffs.pop(); // Remove the dummy entry at the end.
  6516. }
  6517. // Second pass: look for single edits surrounded on both sides by equalities
  6518. // which can be shifted sideways to eliminate an equality.
  6519. // e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
  6520. var changes = false;
  6521. pointer = 1;
  6522. // Intentionally ignore the first and last element (don't need checking).
  6523. while (pointer < diffs.length - 1) {
  6524. if (diffs[pointer - 1][0] == DIFF_EQUAL &&
  6525. diffs[pointer + 1][0] == DIFF_EQUAL) {
  6526. // This is a single edit surrounded by equalities.
  6527. if (diffs[pointer][1].substring(diffs[pointer][1].length -
  6528. diffs[pointer - 1][1].length) == diffs[pointer - 1][1]) {
  6529. // Shift the edit over the previous equality.
  6530. diffs[pointer][1] = diffs[pointer - 1][1] +
  6531. diffs[pointer][1].substring(0, diffs[pointer][1].length -
  6532. diffs[pointer - 1][1].length);
  6533. diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
  6534. diffs.splice(pointer - 1, 1);
  6535. changes = true;
  6536. } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) ==
  6537. diffs[pointer + 1][1]) {
  6538. // Shift the edit over the next equality.
  6539. diffs[pointer - 1][1] += diffs[pointer + 1][1];
  6540. diffs[pointer][1] =
  6541. diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
  6542. diffs[pointer + 1][1];
  6543. diffs.splice(pointer + 1, 1);
  6544. changes = true;
  6545. }
  6546. }
  6547. pointer++;
  6548. }
  6549. // If shifts were made, the diff needs reordering and another shift sweep.
  6550. if (changes) {
  6551. diff_cleanupMerge(diffs);
  6552. }
  6553. };
  6554. var diff = diff_main;
  6555. diff.INSERT = DIFF_INSERT;
  6556. diff.DELETE = DIFF_DELETE;
  6557. diff.EQUAL = DIFF_EQUAL;
  6558. module.exports = diff;
  6559. /*
  6560. * Modify a diff such that the cursor position points to the start of a change:
  6561. * E.g.
  6562. * cursor_normalize_diff([[DIFF_EQUAL, 'abc']], 1)
  6563. * => [1, [[DIFF_EQUAL, 'a'], [DIFF_EQUAL, 'bc']]]
  6564. * cursor_normalize_diff([[DIFF_INSERT, 'new'], [DIFF_DELETE, 'xyz']], 2)
  6565. * => [2, [[DIFF_INSERT, 'new'], [DIFF_DELETE, 'xy'], [DIFF_DELETE, 'z']]]
  6566. *
  6567. * @param {Array} diffs Array of diff tuples
  6568. * @param {Int} cursor_pos Suggested edit position. Must not be out of bounds!
  6569. * @return {Array} A tuple [cursor location in the modified diff, modified diff]
  6570. */
  6571. function cursor_normalize_diff (diffs, cursor_pos) {
  6572. if (cursor_pos === 0) {
  6573. return [DIFF_EQUAL, diffs];
  6574. }
  6575. for (var current_pos = 0, i = 0; i < diffs.length; i++) {
  6576. var d = diffs[i];
  6577. if (d[0] === DIFF_DELETE || d[0] === DIFF_EQUAL) {
  6578. var next_pos = current_pos + d[1].length;
  6579. if (cursor_pos === next_pos) {
  6580. return [i + 1, diffs];
  6581. } else if (cursor_pos < next_pos) {
  6582. // copy to prevent side effects
  6583. diffs = diffs.slice();
  6584. // split d into two diff changes
  6585. var split_pos = cursor_pos - current_pos;
  6586. var d_left = [d[0], d[1].slice(0, split_pos)];
  6587. var d_right = [d[0], d[1].slice(split_pos)];
  6588. diffs.splice(i, 1, d_left, d_right);
  6589. return [i + 1, diffs];
  6590. } else {
  6591. current_pos = next_pos;
  6592. }
  6593. }
  6594. }
  6595. throw new Error('cursor_pos is out of bounds!')
  6596. }
  6597. /*
  6598. * Modify a diff such that the edit position is "shifted" to the proposed edit location (cursor_position).
  6599. *
  6600. * Case 1)
  6601. * Check if a naive shift is possible:
  6602. * [0, X], [ 1, Y] -> [ 1, Y], [0, X] (if X + Y === Y + X)
  6603. * [0, X], [-1, Y] -> [-1, Y], [0, X] (if X + Y === Y + X) - holds same result
  6604. * Case 2)
  6605. * Check if the following shifts are possible:
  6606. * [0, 'pre'], [ 1, 'prefix'] -> [ 1, 'pre'], [0, 'pre'], [ 1, 'fix']
  6607. * [0, 'pre'], [-1, 'prefix'] -> [-1, 'pre'], [0, 'pre'], [-1, 'fix']
  6608. * ^ ^
  6609. * d d_next
  6610. *
  6611. * @param {Array} diffs Array of diff tuples
  6612. * @param {Int} cursor_pos Suggested edit position. Must not be out of bounds!
  6613. * @return {Array} Array of diff tuples
  6614. */
  6615. function fix_cursor (diffs, cursor_pos) {
  6616. var norm = cursor_normalize_diff(diffs, cursor_pos);
  6617. var ndiffs = norm[1];
  6618. var cursor_pointer = norm[0];
  6619. var d = ndiffs[cursor_pointer];
  6620. var d_next = ndiffs[cursor_pointer + 1];
  6621. if (d == null) {
  6622. // Text was deleted from end of original string,
  6623. // cursor is now out of bounds in new string
  6624. return diffs;
  6625. } else if (d[0] !== DIFF_EQUAL) {
  6626. // A modification happened at the cursor location.
  6627. // This is the expected outcome, so we can return the original diff.
  6628. return diffs;
  6629. } else {
  6630. if (d_next != null && d[1] + d_next[1] === d_next[1] + d[1]) {
  6631. // Case 1)
  6632. // It is possible to perform a naive shift
  6633. ndiffs.splice(cursor_pointer, 2, d_next, d)
  6634. return merge_tuples(ndiffs, cursor_pointer, 2)
  6635. } else if (d_next != null && d_next[1].indexOf(d[1]) === 0) {
  6636. // Case 2)
  6637. // d[1] is a prefix of d_next[1]
  6638. // We can assume that d_next[0] !== 0, since d[0] === 0
  6639. // Shift edit locations..
  6640. ndiffs.splice(cursor_pointer, 2, [d_next[0], d[1]], [0, d[1]]);
  6641. var suffix = d_next[1].slice(d[1].length);
  6642. if (suffix.length > 0) {
  6643. ndiffs.splice(cursor_pointer + 2, 0, [d_next[0], suffix]);
  6644. }
  6645. return merge_tuples(ndiffs, cursor_pointer, 3)
  6646. } else {
  6647. // Not possible to perform any modification
  6648. return diffs;
  6649. }
  6650. }
  6651. }
  6652. /*
  6653. * Check diff did not split surrogate pairs.
  6654. * Ex. [0, '\uD83D'], [-1, '\uDC36'], [1, '\uDC2F'] -> [-1, '\uD83D\uDC36'], [1, '\uD83D\uDC2F']
  6655. * '\uD83D\uDC36' === '🐶', '\uD83D\uDC2F' === '🐯'
  6656. *
  6657. * @param {Array} diffs Array of diff tuples
  6658. * @return {Array} Array of diff tuples
  6659. */
  6660. function fix_emoji (diffs) {
  6661. var compact = false;
  6662. var starts_with_pair_end = function(str) {
  6663. return str.charCodeAt(0) >= 0xDC00 && str.charCodeAt(0) <= 0xDFFF;
  6664. }
  6665. var ends_with_pair_start = function(str) {
  6666. return str.charCodeAt(str.length-1) >= 0xD800 && str.charCodeAt(str.length-1) <= 0xDBFF;
  6667. }
  6668. for (var i = 2; i < diffs.length; i += 1) {
  6669. if (diffs[i-2][0] === DIFF_EQUAL && ends_with_pair_start(diffs[i-2][1]) &&
  6670. diffs[i-1][0] === DIFF_DELETE && starts_with_pair_end(diffs[i-1][1]) &&
  6671. diffs[i][0] === DIFF_INSERT && starts_with_pair_end(diffs[i][1])) {
  6672. compact = true;
  6673. diffs[i-1][1] = diffs[i-2][1].slice(-1) + diffs[i-1][1];
  6674. diffs[i][1] = diffs[i-2][1].slice(-1) + diffs[i][1];
  6675. diffs[i-2][1] = diffs[i-2][1].slice(0, -1);
  6676. }
  6677. }
  6678. if (!compact) {
  6679. return diffs;
  6680. }
  6681. var fixed_diffs = [];
  6682. for (var i = 0; i < diffs.length; i += 1) {
  6683. if (diffs[i][1].length > 0) {
  6684. fixed_diffs.push(diffs[i]);
  6685. }
  6686. }
  6687. return fixed_diffs;
  6688. }
  6689. /*
  6690. * Try to merge tuples with their neigbors in a given range.
  6691. * E.g. [0, 'a'], [0, 'b'] -> [0, 'ab']
  6692. *
  6693. * @param {Array} diffs Array of diff tuples.
  6694. * @param {Int} start Position of the first element to merge (diffs[start] is also merged with diffs[start - 1]).
  6695. * @param {Int} length Number of consecutive elements to check.
  6696. * @return {Array} Array of merged diff tuples.
  6697. */
  6698. function merge_tuples (diffs, start, length) {
  6699. // Check from (start-1) to (start+length).
  6700. for (var i = start + length - 1; i >= 0 && i >= start - 1; i--) {
  6701. if (i + 1 < diffs.length) {
  6702. var left_d = diffs[i];
  6703. var right_d = diffs[i+1];
  6704. if (left_d[0] === right_d[1]) {
  6705. diffs.splice(i, 2, [left_d[0], left_d[1] + right_d[1]]);
  6706. }
  6707. }
  6708. }
  6709. return diffs;
  6710. }
  6711. /***/ }),
  6712. /* 52 */
  6713. /***/ (function(module, exports) {
  6714. exports = module.exports = typeof Object.keys === 'function'
  6715. ? Object.keys : shim;
  6716. exports.shim = shim;
  6717. function shim (obj) {
  6718. var keys = [];
  6719. for (var key in obj) keys.push(key);
  6720. return keys;
  6721. }
  6722. /***/ }),
  6723. /* 53 */
  6724. /***/ (function(module, exports) {
  6725. var supportsArgumentsClass = (function(){
  6726. return Object.prototype.toString.call(arguments)
  6727. })() == '[object Arguments]';
  6728. exports = module.exports = supportsArgumentsClass ? supported : unsupported;
  6729. exports.supported = supported;
  6730. function supported(object) {
  6731. return Object.prototype.toString.call(object) == '[object Arguments]';
  6732. };
  6733. exports.unsupported = unsupported;
  6734. function unsupported(object){
  6735. return object &&
  6736. typeof object == 'object' &&
  6737. typeof object.length == 'number' &&
  6738. Object.prototype.hasOwnProperty.call(object, 'callee') &&
  6739. !Object.prototype.propertyIsEnumerable.call(object, 'callee') ||
  6740. false;
  6741. };
  6742. /***/ }),
  6743. /* 54 */
  6744. /***/ (function(module, exports) {
  6745. 'use strict';
  6746. var has = Object.prototype.hasOwnProperty
  6747. , prefix = '~';
  6748. /**
  6749. * Constructor to create a storage for our `EE` objects.
  6750. * An `Events` instance is a plain object whose properties are event names.
  6751. *
  6752. * @constructor
  6753. * @api private
  6754. */
  6755. function Events() {}
  6756. //
  6757. // We try to not inherit from `Object.prototype`. In some engines creating an
  6758. // instance in this way is faster than calling `Object.create(null)` directly.
  6759. // If `Object.create(null)` is not supported we prefix the event names with a
  6760. // character to make sure that the built-in object properties are not
  6761. // overridden or used as an attack vector.
  6762. //
  6763. if (Object.create) {
  6764. Events.prototype = Object.create(null);
  6765. //
  6766. // This hack is needed because the `__proto__` property is still inherited in
  6767. // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
  6768. //
  6769. if (!new Events().__proto__) prefix = false;
  6770. }
  6771. /**
  6772. * Representation of a single event listener.
  6773. *
  6774. * @param {Function} fn The listener function.
  6775. * @param {Mixed} context The context to invoke the listener with.
  6776. * @param {Boolean} [once=false] Specify if the listener is a one-time listener.
  6777. * @constructor
  6778. * @api private
  6779. */
  6780. function EE(fn, context, once) {
  6781. this.fn = fn;
  6782. this.context = context;
  6783. this.once = once || false;
  6784. }
  6785. /**
  6786. * Minimal `EventEmitter` interface that is molded against the Node.js
  6787. * `EventEmitter` interface.
  6788. *
  6789. * @constructor
  6790. * @api public
  6791. */
  6792. function EventEmitter() {
  6793. this._events = new Events();
  6794. this._eventsCount = 0;
  6795. }
  6796. /**
  6797. * Return an array listing the events for which the emitter has registered
  6798. * listeners.
  6799. *
  6800. * @returns {Array}
  6801. * @api public
  6802. */
  6803. EventEmitter.prototype.eventNames = function eventNames() {
  6804. var names = []
  6805. , events
  6806. , name;
  6807. if (this._eventsCount === 0) return names;
  6808. for (name in (events = this._events)) {
  6809. if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
  6810. }
  6811. if (Object.getOwnPropertySymbols) {
  6812. return names.concat(Object.getOwnPropertySymbols(events));
  6813. }
  6814. return names;
  6815. };
  6816. /**
  6817. * Return the listeners registered for a given event.
  6818. *
  6819. * @param {String|Symbol} event The event name.
  6820. * @param {Boolean} exists Only check if there are listeners.
  6821. * @returns {Array|Boolean}
  6822. * @api public
  6823. */
  6824. EventEmitter.prototype.listeners = function listeners(event, exists) {
  6825. var evt = prefix ? prefix + event : event
  6826. , available = this._events[evt];
  6827. if (exists) return !!available;
  6828. if (!available) return [];
  6829. if (available.fn) return [available.fn];
  6830. for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) {
  6831. ee[i] = available[i].fn;
  6832. }
  6833. return ee;
  6834. };
  6835. /**
  6836. * Calls each of the listeners registered for a given event.
  6837. *
  6838. * @param {String|Symbol} event The event name.
  6839. * @returns {Boolean} `true` if the event had listeners, else `false`.
  6840. * @api public
  6841. */
  6842. EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
  6843. var evt = prefix ? prefix + event : event;
  6844. if (!this._events[evt]) return false;
  6845. var listeners = this._events[evt]
  6846. , len = arguments.length
  6847. , args
  6848. , i;
  6849. if (listeners.fn) {
  6850. if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
  6851. switch (len) {
  6852. case 1: return listeners.fn.call(listeners.context), true;
  6853. case 2: return listeners.fn.call(listeners.context, a1), true;
  6854. case 3: return listeners.fn.call(listeners.context, a1, a2), true;
  6855. case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
  6856. case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
  6857. case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
  6858. }
  6859. for (i = 1, args = new Array(len -1); i < len; i++) {
  6860. args[i - 1] = arguments[i];
  6861. }
  6862. listeners.fn.apply(listeners.context, args);
  6863. } else {
  6864. var length = listeners.length
  6865. , j;
  6866. for (i = 0; i < length; i++) {
  6867. if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
  6868. switch (len) {
  6869. case 1: listeners[i].fn.call(listeners[i].context); break;
  6870. case 2: listeners[i].fn.call(listeners[i].context, a1); break;
  6871. case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
  6872. case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
  6873. default:
  6874. if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
  6875. args[j - 1] = arguments[j];
  6876. }
  6877. listeners[i].fn.apply(listeners[i].context, args);
  6878. }
  6879. }
  6880. }
  6881. return true;
  6882. };
  6883. /**
  6884. * Add a listener for a given event.
  6885. *
  6886. * @param {String|Symbol} event The event name.
  6887. * @param {Function} fn The listener function.
  6888. * @param {Mixed} [context=this] The context to invoke the listener with.
  6889. * @returns {EventEmitter} `this`.
  6890. * @api public
  6891. */
  6892. EventEmitter.prototype.on = function on(event, fn, context) {
  6893. var listener = new EE(fn, context || this)
  6894. , evt = prefix ? prefix + event : event;
  6895. if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
  6896. else if (!this._events[evt].fn) this._events[evt].push(listener);
  6897. else this._events[evt] = [this._events[evt], listener];
  6898. return this;
  6899. };
  6900. /**
  6901. * Add a one-time listener for a given event.
  6902. *
  6903. * @param {String|Symbol} event The event name.
  6904. * @param {Function} fn The listener function.
  6905. * @param {Mixed} [context=this] The context to invoke the listener with.
  6906. * @returns {EventEmitter} `this`.
  6907. * @api public
  6908. */
  6909. EventEmitter.prototype.once = function once(event, fn, context) {
  6910. var listener = new EE(fn, context || this, true)
  6911. , evt = prefix ? prefix + event : event;
  6912. if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
  6913. else if (!this._events[evt].fn) this._events[evt].push(listener);
  6914. else this._events[evt] = [this._events[evt], listener];
  6915. return this;
  6916. };
  6917. /**
  6918. * Remove the listeners of a given event.
  6919. *
  6920. * @param {String|Symbol} event The event name.
  6921. * @param {Function} fn Only remove the listeners that match this function.
  6922. * @param {Mixed} context Only remove the listeners that have this context.
  6923. * @param {Boolean} once Only remove one-time listeners.
  6924. * @returns {EventEmitter} `this`.
  6925. * @api public
  6926. */
  6927. EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
  6928. var evt = prefix ? prefix + event : event;
  6929. if (!this._events[evt]) return this;
  6930. if (!fn) {
  6931. if (--this._eventsCount === 0) this._events = new Events();
  6932. else delete this._events[evt];
  6933. return this;
  6934. }
  6935. var listeners = this._events[evt];
  6936. if (listeners.fn) {
  6937. if (
  6938. listeners.fn === fn
  6939. && (!once || listeners.once)
  6940. && (!context || listeners.context === context)
  6941. ) {
  6942. if (--this._eventsCount === 0) this._events = new Events();
  6943. else delete this._events[evt];
  6944. }
  6945. } else {
  6946. for (var i = 0, events = [], length = listeners.length; i < length; i++) {
  6947. if (
  6948. listeners[i].fn !== fn
  6949. || (once && !listeners[i].once)
  6950. || (context && listeners[i].context !== context)
  6951. ) {
  6952. events.push(listeners[i]);
  6953. }
  6954. }
  6955. //
  6956. // Reset the array, or remove it completely if we have no more listeners.
  6957. //
  6958. if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
  6959. else if (--this._eventsCount === 0) this._events = new Events();
  6960. else delete this._events[evt];
  6961. }
  6962. return this;
  6963. };
  6964. /**
  6965. * Remove all listeners, or those of the specified event.
  6966. *
  6967. * @param {String|Symbol} [event] The event name.
  6968. * @returns {EventEmitter} `this`.
  6969. * @api public
  6970. */
  6971. EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
  6972. var evt;
  6973. if (event) {
  6974. evt = prefix ? prefix + event : event;
  6975. if (this._events[evt]) {
  6976. if (--this._eventsCount === 0) this._events = new Events();
  6977. else delete this._events[evt];
  6978. }
  6979. } else {
  6980. this._events = new Events();
  6981. this._eventsCount = 0;
  6982. }
  6983. return this;
  6984. };
  6985. //
  6986. // Alias methods names because people roll like that.
  6987. //
  6988. EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
  6989. EventEmitter.prototype.addListener = EventEmitter.prototype.on;
  6990. //
  6991. // This function doesn't apply anymore.
  6992. //
  6993. EventEmitter.prototype.setMaxListeners = function setMaxListeners() {
  6994. return this;
  6995. };
  6996. //
  6997. // Expose the prefix.
  6998. //
  6999. EventEmitter.prefixed = prefix;
  7000. //
  7001. // Allow `EventEmitter` to be imported as module namespace.
  7002. //
  7003. EventEmitter.EventEmitter = EventEmitter;
  7004. //
  7005. // Expose the module.
  7006. //
  7007. if ('undefined' !== typeof module) {
  7008. module.exports = EventEmitter;
  7009. }
  7010. /***/ }),
  7011. /* 55 */
  7012. /***/ (function(module, exports, __webpack_require__) {
  7013. "use strict";
  7014. Object.defineProperty(exports, "__esModule", {
  7015. value: true
  7016. });
  7017. exports.matchText = exports.matchSpacing = exports.matchNewline = exports.matchBlot = exports.matchAttributor = exports.default = undefined;
  7018. 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; };
  7019. 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"); } }; }();
  7020. 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; }; }();
  7021. var _extend2 = __webpack_require__(3);
  7022. var _extend3 = _interopRequireDefault(_extend2);
  7023. var _quillDelta = __webpack_require__(2);
  7024. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  7025. var _parchment = __webpack_require__(0);
  7026. var _parchment2 = _interopRequireDefault(_parchment);
  7027. var _quill = __webpack_require__(5);
  7028. var _quill2 = _interopRequireDefault(_quill);
  7029. var _logger = __webpack_require__(10);
  7030. var _logger2 = _interopRequireDefault(_logger);
  7031. var _module = __webpack_require__(9);
  7032. var _module2 = _interopRequireDefault(_module);
  7033. var _align = __webpack_require__(36);
  7034. var _background = __webpack_require__(37);
  7035. var _code = __webpack_require__(13);
  7036. var _code2 = _interopRequireDefault(_code);
  7037. var _color = __webpack_require__(26);
  7038. var _direction = __webpack_require__(38);
  7039. var _font = __webpack_require__(39);
  7040. var _size = __webpack_require__(40);
  7041. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7042. 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; }
  7043. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7044. 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; }
  7045. 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; }
  7046. var debug = (0, _logger2.default)('quill:clipboard');
  7047. var DOM_KEY = '__ql-matcher';
  7048. 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]];
  7049. var ATTRIBUTE_ATTRIBUTORS = [_align.AlignAttribute, _direction.DirectionAttribute].reduce(function (memo, attr) {
  7050. memo[attr.keyName] = attr;
  7051. return memo;
  7052. }, {});
  7053. var STYLE_ATTRIBUTORS = [_align.AlignStyle, _background.BackgroundStyle, _color.ColorStyle, _direction.DirectionStyle, _font.FontStyle, _size.SizeStyle].reduce(function (memo, attr) {
  7054. memo[attr.keyName] = attr;
  7055. return memo;
  7056. }, {});
  7057. var Clipboard = function (_Module) {
  7058. _inherits(Clipboard, _Module);
  7059. function Clipboard(quill, options) {
  7060. _classCallCheck(this, Clipboard);
  7061. var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this, quill, options));
  7062. _this.quill.root.addEventListener('paste', _this.onPaste.bind(_this));
  7063. _this.container = _this.quill.addContainer('ql-clipboard');
  7064. _this.container.setAttribute('contenteditable', true);
  7065. _this.container.setAttribute('tabindex', -1);
  7066. _this.matchers = [];
  7067. CLIPBOARD_CONFIG.concat(_this.options.matchers).forEach(function (_ref) {
  7068. var _ref2 = _slicedToArray(_ref, 2),
  7069. selector = _ref2[0],
  7070. matcher = _ref2[1];
  7071. if (!options.matchVisual && matcher === matchSpacing) return;
  7072. _this.addMatcher(selector, matcher);
  7073. });
  7074. return _this;
  7075. }
  7076. _createClass(Clipboard, [{
  7077. key: 'addMatcher',
  7078. value: function addMatcher(selector, matcher) {
  7079. this.matchers.push([selector, matcher]);
  7080. }
  7081. }, {
  7082. key: 'convert',
  7083. value: function convert(html) {
  7084. if (typeof html === 'string') {
  7085. this.container.innerHTML = html.replace(/\>\r?\n +\</g, '><'); // Remove spaces between tags
  7086. return this.convert();
  7087. }
  7088. var formats = this.quill.getFormat(this.quill.selection.savedRange.index);
  7089. if (formats[_code2.default.blotName]) {
  7090. var text = this.container.innerText;
  7091. this.container.innerHTML = '';
  7092. return new _quillDelta2.default().insert(text, _defineProperty({}, _code2.default.blotName, formats[_code2.default.blotName]));
  7093. }
  7094. var _prepareMatching = this.prepareMatching(),
  7095. _prepareMatching2 = _slicedToArray(_prepareMatching, 2),
  7096. elementMatchers = _prepareMatching2[0],
  7097. textMatchers = _prepareMatching2[1];
  7098. var delta = traverse(this.container, elementMatchers, textMatchers);
  7099. // Remove trailing newline
  7100. if (deltaEndsWith(delta, '\n') && delta.ops[delta.ops.length - 1].attributes == null) {
  7101. delta = delta.compose(new _quillDelta2.default().retain(delta.length() - 1).delete(1));
  7102. }
  7103. debug.log('convert', this.container.innerHTML, delta);
  7104. this.container.innerHTML = '';
  7105. return delta;
  7106. }
  7107. }, {
  7108. key: 'dangerouslyPasteHTML',
  7109. value: function dangerouslyPasteHTML(index, html) {
  7110. var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _quill2.default.sources.API;
  7111. if (typeof index === 'string') {
  7112. this.quill.setContents(this.convert(index), html);
  7113. this.quill.setSelection(0, _quill2.default.sources.SILENT);
  7114. } else {
  7115. var paste = this.convert(html);
  7116. this.quill.updateContents(new _quillDelta2.default().retain(index).concat(paste), source);
  7117. this.quill.setSelection(index + paste.length(), _quill2.default.sources.SILENT);
  7118. }
  7119. }
  7120. }, {
  7121. key: 'onPaste',
  7122. value: function onPaste(e) {
  7123. var _this2 = this;
  7124. if (e.defaultPrevented || !this.quill.isEnabled()) return;
  7125. var range = this.quill.getSelection();
  7126. var delta = new _quillDelta2.default().retain(range.index);
  7127. var scrollTop = this.quill.scrollingContainer.scrollTop;
  7128. this.container.focus();
  7129. this.quill.selection.update(_quill2.default.sources.SILENT);
  7130. setTimeout(function () {
  7131. delta = delta.concat(_this2.convert()).delete(range.length);
  7132. _this2.quill.updateContents(delta, _quill2.default.sources.USER);
  7133. // range.length contributes to delta.length()
  7134. _this2.quill.setSelection(delta.length() - range.length, _quill2.default.sources.SILENT);
  7135. _this2.quill.scrollingContainer.scrollTop = scrollTop;
  7136. _this2.quill.focus();
  7137. }, 1);
  7138. }
  7139. }, {
  7140. key: 'prepareMatching',
  7141. value: function prepareMatching() {
  7142. var _this3 = this;
  7143. var elementMatchers = [],
  7144. textMatchers = [];
  7145. this.matchers.forEach(function (pair) {
  7146. var _pair = _slicedToArray(pair, 2),
  7147. selector = _pair[0],
  7148. matcher = _pair[1];
  7149. switch (selector) {
  7150. case Node.TEXT_NODE:
  7151. textMatchers.push(matcher);
  7152. break;
  7153. case Node.ELEMENT_NODE:
  7154. elementMatchers.push(matcher);
  7155. break;
  7156. default:
  7157. [].forEach.call(_this3.container.querySelectorAll(selector), function (node) {
  7158. // TODO use weakmap
  7159. node[DOM_KEY] = node[DOM_KEY] || [];
  7160. node[DOM_KEY].push(matcher);
  7161. });
  7162. break;
  7163. }
  7164. });
  7165. return [elementMatchers, textMatchers];
  7166. }
  7167. }]);
  7168. return Clipboard;
  7169. }(_module2.default);
  7170. Clipboard.DEFAULTS = {
  7171. matchers: [],
  7172. matchVisual: true
  7173. };
  7174. function applyFormat(delta, format, value) {
  7175. if ((typeof format === 'undefined' ? 'undefined' : _typeof(format)) === 'object') {
  7176. return Object.keys(format).reduce(function (delta, key) {
  7177. return applyFormat(delta, key, format[key]);
  7178. }, delta);
  7179. } else {
  7180. return delta.reduce(function (delta, op) {
  7181. if (op.attributes && op.attributes[format]) {
  7182. return delta.push(op);
  7183. } else {
  7184. return delta.insert(op.insert, (0, _extend3.default)({}, _defineProperty({}, format, value), op.attributes));
  7185. }
  7186. }, new _quillDelta2.default());
  7187. }
  7188. }
  7189. function computeStyle(node) {
  7190. if (node.nodeType !== Node.ELEMENT_NODE) return {};
  7191. var DOM_KEY = '__ql-computed-style';
  7192. return node[DOM_KEY] || (node[DOM_KEY] = window.getComputedStyle(node));
  7193. }
  7194. function deltaEndsWith(delta, text) {
  7195. var endText = "";
  7196. for (var i = delta.ops.length - 1; i >= 0 && endText.length < text.length; --i) {
  7197. var op = delta.ops[i];
  7198. if (typeof op.insert !== 'string') break;
  7199. endText = op.insert + endText;
  7200. }
  7201. return endText.slice(-1 * text.length) === text;
  7202. }
  7203. function isLine(node) {
  7204. if (node.childNodes.length === 0) return false; // Exclude embed blocks
  7205. var style = computeStyle(node);
  7206. return ['block', 'list-item'].indexOf(style.display) > -1;
  7207. }
  7208. function traverse(node, elementMatchers, textMatchers) {
  7209. // Post-order
  7210. if (node.nodeType === node.TEXT_NODE) {
  7211. return textMatchers.reduce(function (delta, matcher) {
  7212. return matcher(node, delta);
  7213. }, new _quillDelta2.default());
  7214. } else if (node.nodeType === node.ELEMENT_NODE) {
  7215. return [].reduce.call(node.childNodes || [], function (delta, childNode) {
  7216. var childrenDelta = traverse(childNode, elementMatchers, textMatchers);
  7217. if (childNode.nodeType === node.ELEMENT_NODE) {
  7218. childrenDelta = elementMatchers.reduce(function (childrenDelta, matcher) {
  7219. return matcher(childNode, childrenDelta);
  7220. }, childrenDelta);
  7221. childrenDelta = (childNode[DOM_KEY] || []).reduce(function (childrenDelta, matcher) {
  7222. return matcher(childNode, childrenDelta);
  7223. }, childrenDelta);
  7224. }
  7225. return delta.concat(childrenDelta);
  7226. }, new _quillDelta2.default());
  7227. } else {
  7228. return new _quillDelta2.default();
  7229. }
  7230. }
  7231. function matchAlias(format, node, delta) {
  7232. return applyFormat(delta, format, true);
  7233. }
  7234. function matchAttributor(node, delta) {
  7235. var attributes = _parchment2.default.Attributor.Attribute.keys(node);
  7236. var classes = _parchment2.default.Attributor.Class.keys(node);
  7237. var styles = _parchment2.default.Attributor.Style.keys(node);
  7238. var formats = {};
  7239. attributes.concat(classes).concat(styles).forEach(function (name) {
  7240. var attr = _parchment2.default.query(name, _parchment2.default.Scope.ATTRIBUTE);
  7241. if (attr != null) {
  7242. formats[attr.attrName] = attr.value(node);
  7243. if (formats[attr.attrName]) return;
  7244. }
  7245. attr = ATTRIBUTE_ATTRIBUTORS[name];
  7246. if (attr != null && (attr.attrName === name || attr.keyName === name)) {
  7247. formats[attr.attrName] = attr.value(node) || undefined;
  7248. }
  7249. attr = STYLE_ATTRIBUTORS[name];
  7250. if (attr != null && (attr.attrName === name || attr.keyName === name)) {
  7251. attr = STYLE_ATTRIBUTORS[name];
  7252. formats[attr.attrName] = attr.value(node) || undefined;
  7253. }
  7254. });
  7255. if (Object.keys(formats).length > 0) {
  7256. delta = applyFormat(delta, formats);
  7257. }
  7258. return delta;
  7259. }
  7260. function matchBlot(node, delta) {
  7261. var match = _parchment2.default.query(node);
  7262. if (match == null) return delta;
  7263. if (match.prototype instanceof _parchment2.default.Embed) {
  7264. var embed = {};
  7265. var value = match.value(node);
  7266. if (value != null) {
  7267. embed[match.blotName] = value;
  7268. delta = new _quillDelta2.default().insert(embed, match.formats(node));
  7269. }
  7270. } else if (typeof match.formats === 'function') {
  7271. delta = applyFormat(delta, match.blotName, match.formats(node));
  7272. }
  7273. return delta;
  7274. }
  7275. function matchBreak(node, delta) {
  7276. if (!deltaEndsWith(delta, '\n')) {
  7277. delta.insert('\n');
  7278. }
  7279. return delta;
  7280. }
  7281. function matchIgnore() {
  7282. return new _quillDelta2.default();
  7283. }
  7284. function matchIndent(node, delta) {
  7285. var match = _parchment2.default.query(node);
  7286. if (match == null || match.blotName !== 'list-item' || !deltaEndsWith(delta, '\n')) {
  7287. return delta;
  7288. }
  7289. var indent = -1,
  7290. parent = node.parentNode;
  7291. while (!parent.classList.contains('ql-clipboard')) {
  7292. if ((_parchment2.default.query(parent) || {}).blotName === 'list') {
  7293. indent += 1;
  7294. }
  7295. parent = parent.parentNode;
  7296. }
  7297. if (indent <= 0) return delta;
  7298. return delta.compose(new _quillDelta2.default().retain(delta.length() - 1).retain(1, { indent: indent }));
  7299. }
  7300. function matchNewline(node, delta) {
  7301. if (!deltaEndsWith(delta, '\n')) {
  7302. if (isLine(node) || delta.length() > 0 && node.nextSibling && isLine(node.nextSibling)) {
  7303. delta.insert('\n');
  7304. }
  7305. }
  7306. return delta;
  7307. }
  7308. function matchSpacing(node, delta) {
  7309. if (isLine(node) && node.nextElementSibling != null && !deltaEndsWith(delta, '\n\n')) {
  7310. var nodeHeight = node.offsetHeight + parseFloat(computeStyle(node).marginTop) + parseFloat(computeStyle(node).marginBottom);
  7311. if (node.nextElementSibling.offsetTop > node.offsetTop + nodeHeight * 1.5) {
  7312. delta.insert('\n');
  7313. }
  7314. }
  7315. return delta;
  7316. }
  7317. function matchStyles(node, delta) {
  7318. var formats = {};
  7319. var style = node.style || {};
  7320. if (style.fontStyle && computeStyle(node).fontStyle === 'italic') {
  7321. formats.italic = true;
  7322. }
  7323. if (style.fontWeight && (computeStyle(node).fontWeight.startsWith('bold') || parseInt(computeStyle(node).fontWeight) >= 700)) {
  7324. formats.bold = true;
  7325. }
  7326. if (Object.keys(formats).length > 0) {
  7327. delta = applyFormat(delta, formats);
  7328. }
  7329. if (parseFloat(style.textIndent || 0) > 0) {
  7330. // Could be 0.5in
  7331. delta = new _quillDelta2.default().insert('\t').concat(delta);
  7332. }
  7333. return delta;
  7334. }
  7335. function matchText(node, delta) {
  7336. var text = node.data;
  7337. // Word represents empty line with <o:p>&nbsp;</o:p>
  7338. if (node.parentNode.tagName === 'O:P') {
  7339. return delta.insert(text.trim());
  7340. }
  7341. if (text.trim().length === 0 && node.parentNode.classList.contains('ql-clipboard')) {
  7342. return delta;
  7343. }
  7344. if (!computeStyle(node.parentNode).whiteSpace.startsWith('pre')) {
  7345. // eslint-disable-next-line func-style
  7346. var replacer = function replacer(collapse, match) {
  7347. match = match.replace(/[^\u00a0]/g, ''); // \u00a0 is nbsp;
  7348. return match.length < 1 && collapse ? ' ' : match;
  7349. };
  7350. text = text.replace(/\r\n/g, ' ').replace(/\n/g, ' ');
  7351. text = text.replace(/\s\s+/g, replacer.bind(replacer, true)); // collapse whitespace
  7352. if (node.previousSibling == null && isLine(node.parentNode) || node.previousSibling != null && isLine(node.previousSibling)) {
  7353. text = text.replace(/^\s+/, replacer.bind(replacer, false));
  7354. }
  7355. if (node.nextSibling == null && isLine(node.parentNode) || node.nextSibling != null && isLine(node.nextSibling)) {
  7356. text = text.replace(/\s+$/, replacer.bind(replacer, false));
  7357. }
  7358. }
  7359. return delta.insert(text);
  7360. }
  7361. exports.default = Clipboard;
  7362. exports.matchAttributor = matchAttributor;
  7363. exports.matchBlot = matchBlot;
  7364. exports.matchNewline = matchNewline;
  7365. exports.matchSpacing = matchSpacing;
  7366. exports.matchText = matchText;
  7367. /***/ }),
  7368. /* 56 */,
  7369. /* 57 */,
  7370. /* 58 */,
  7371. /* 59 */,
  7372. /* 60 */,
  7373. /* 61 */,
  7374. /* 62 */,
  7375. /* 63 */,
  7376. /* 64 */,
  7377. /* 65 */,
  7378. /* 66 */,
  7379. /* 67 */,
  7380. /* 68 */,
  7381. /* 69 */,
  7382. /* 70 */,
  7383. /* 71 */,
  7384. /* 72 */,
  7385. /* 73 */,
  7386. /* 74 */,
  7387. /* 75 */,
  7388. /* 76 */,
  7389. /* 77 */,
  7390. /* 78 */,
  7391. /* 79 */,
  7392. /* 80 */,
  7393. /* 81 */,
  7394. /* 82 */,
  7395. /* 83 */,
  7396. /* 84 */,
  7397. /* 85 */,
  7398. /* 86 */,
  7399. /* 87 */,
  7400. /* 88 */,
  7401. /* 89 */,
  7402. /* 90 */,
  7403. /* 91 */,
  7404. /* 92 */,
  7405. /* 93 */,
  7406. /* 94 */,
  7407. /* 95 */,
  7408. /* 96 */,
  7409. /* 97 */,
  7410. /* 98 */,
  7411. /* 99 */,
  7412. /* 100 */,
  7413. /* 101 */,
  7414. /* 102 */,
  7415. /* 103 */,
  7416. /* 104 */,
  7417. /* 105 */,
  7418. /* 106 */,
  7419. /* 107 */,
  7420. /* 108 */,
  7421. /* 109 */,
  7422. /* 110 */
  7423. /***/ (function(module, exports, __webpack_require__) {
  7424. module.exports = __webpack_require__(29);
  7425. /***/ })
  7426. /******/ ])["default"];
  7427. });