quill.core.js 297 KB

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