quill.js 424 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405
  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 = 109);
  80. /******/ })
  81. /************************************************************************/
  82. /******/ ([
  83. /* 0 */
  84. /***/ (function(module, exports, __webpack_require__) {
  85. "use strict";
  86. Object.defineProperty(exports, "__esModule", { value: true });
  87. var container_1 = __webpack_require__(17);
  88. var format_1 = __webpack_require__(18);
  89. var leaf_1 = __webpack_require__(19);
  90. var scroll_1 = __webpack_require__(45);
  91. var inline_1 = __webpack_require__(46);
  92. var block_1 = __webpack_require__(47);
  93. var embed_1 = __webpack_require__(48);
  94. var text_1 = __webpack_require__(49);
  95. var attributor_1 = __webpack_require__(12);
  96. var class_1 = __webpack_require__(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. /***/ (function(module, exports, __webpack_require__) {
  4002. "use strict";
  4003. Object.defineProperty(exports, "__esModule", {
  4004. value: true
  4005. });
  4006. exports.sanitize = exports.default = undefined;
  4007. 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; }; }();
  4008. 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); } };
  4009. var _inline = __webpack_require__(6);
  4010. var _inline2 = _interopRequireDefault(_inline);
  4011. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4012. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4013. 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; }
  4014. 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; }
  4015. var Link = function (_Inline) {
  4016. _inherits(Link, _Inline);
  4017. function Link() {
  4018. _classCallCheck(this, Link);
  4019. return _possibleConstructorReturn(this, (Link.__proto__ || Object.getPrototypeOf(Link)).apply(this, arguments));
  4020. }
  4021. _createClass(Link, [{
  4022. key: 'format',
  4023. value: function format(name, value) {
  4024. if (name !== this.statics.blotName || !value) return _get(Link.prototype.__proto__ || Object.getPrototypeOf(Link.prototype), 'format', this).call(this, name, value);
  4025. value = this.constructor.sanitize(value);
  4026. this.domNode.setAttribute('href', value);
  4027. }
  4028. }], [{
  4029. key: 'create',
  4030. value: function create(value) {
  4031. var node = _get(Link.__proto__ || Object.getPrototypeOf(Link), 'create', this).call(this, value);
  4032. value = this.sanitize(value);
  4033. node.setAttribute('href', value);
  4034. node.setAttribute('target', '_blank');
  4035. return node;
  4036. }
  4037. }, {
  4038. key: 'formats',
  4039. value: function formats(domNode) {
  4040. return domNode.getAttribute('href');
  4041. }
  4042. }, {
  4043. key: 'sanitize',
  4044. value: function sanitize(url) {
  4045. return _sanitize(url, this.PROTOCOL_WHITELIST) ? url : this.SANITIZED_URL;
  4046. }
  4047. }]);
  4048. return Link;
  4049. }(_inline2.default);
  4050. Link.blotName = 'link';
  4051. Link.tagName = 'A';
  4052. Link.SANITIZED_URL = 'about:blank';
  4053. Link.PROTOCOL_WHITELIST = ['http', 'https', 'mailto', 'tel'];
  4054. function _sanitize(url, protocols) {
  4055. var anchor = document.createElement('a');
  4056. anchor.href = url;
  4057. var protocol = anchor.href.slice(0, anchor.href.indexOf(':'));
  4058. return protocols.indexOf(protocol) > -1;
  4059. }
  4060. exports.default = Link;
  4061. exports.sanitize = _sanitize;
  4062. /***/ }),
  4063. /* 27 */
  4064. /***/ (function(module, exports, __webpack_require__) {
  4065. "use strict";
  4066. Object.defineProperty(exports, "__esModule", {
  4067. value: true
  4068. });
  4069. 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; };
  4070. 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; }; }();
  4071. var _dropdown = __webpack_require__(107);
  4072. var _dropdown2 = _interopRequireDefault(_dropdown);
  4073. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4074. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4075. var Picker = function () {
  4076. function Picker(select) {
  4077. var _this = this;
  4078. _classCallCheck(this, Picker);
  4079. this.select = select;
  4080. this.container = document.createElement('span');
  4081. this.buildPicker();
  4082. this.select.style.display = 'none';
  4083. this.select.parentNode.insertBefore(this.container, this.select);
  4084. this.label.addEventListener('mousedown', function () {
  4085. _this.container.classList.toggle('ql-expanded');
  4086. });
  4087. this.select.addEventListener('change', this.update.bind(this));
  4088. }
  4089. _createClass(Picker, [{
  4090. key: 'buildItem',
  4091. value: function buildItem(option) {
  4092. var _this2 = this;
  4093. var item = document.createElement('span');
  4094. item.classList.add('ql-picker-item');
  4095. if (option.hasAttribute('value')) {
  4096. item.setAttribute('data-value', option.getAttribute('value'));
  4097. }
  4098. if (option.textContent) {
  4099. item.setAttribute('data-label', option.textContent);
  4100. }
  4101. item.addEventListener('click', function () {
  4102. _this2.selectItem(item, true);
  4103. });
  4104. return item;
  4105. }
  4106. }, {
  4107. key: 'buildLabel',
  4108. value: function buildLabel() {
  4109. var label = document.createElement('span');
  4110. label.classList.add('ql-picker-label');
  4111. label.innerHTML = _dropdown2.default;
  4112. this.container.appendChild(label);
  4113. return label;
  4114. }
  4115. }, {
  4116. key: 'buildOptions',
  4117. value: function buildOptions() {
  4118. var _this3 = this;
  4119. var options = document.createElement('span');
  4120. options.classList.add('ql-picker-options');
  4121. [].slice.call(this.select.options).forEach(function (option) {
  4122. var item = _this3.buildItem(option);
  4123. options.appendChild(item);
  4124. if (option.selected === true) {
  4125. _this3.selectItem(item);
  4126. }
  4127. });
  4128. this.container.appendChild(options);
  4129. }
  4130. }, {
  4131. key: 'buildPicker',
  4132. value: function buildPicker() {
  4133. var _this4 = this;
  4134. [].slice.call(this.select.attributes).forEach(function (item) {
  4135. _this4.container.setAttribute(item.name, item.value);
  4136. });
  4137. this.container.classList.add('ql-picker');
  4138. this.label = this.buildLabel();
  4139. this.buildOptions();
  4140. }
  4141. }, {
  4142. key: 'close',
  4143. value: function close() {
  4144. this.container.classList.remove('ql-expanded');
  4145. }
  4146. }, {
  4147. key: 'selectItem',
  4148. value: function selectItem(item) {
  4149. var trigger = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4150. var selected = this.container.querySelector('.ql-selected');
  4151. if (item === selected) return;
  4152. if (selected != null) {
  4153. selected.classList.remove('ql-selected');
  4154. }
  4155. if (item == null) return;
  4156. item.classList.add('ql-selected');
  4157. this.select.selectedIndex = [].indexOf.call(item.parentNode.children, item);
  4158. if (item.hasAttribute('data-value')) {
  4159. this.label.setAttribute('data-value', item.getAttribute('data-value'));
  4160. } else {
  4161. this.label.removeAttribute('data-value');
  4162. }
  4163. if (item.hasAttribute('data-label')) {
  4164. this.label.setAttribute('data-label', item.getAttribute('data-label'));
  4165. } else {
  4166. this.label.removeAttribute('data-label');
  4167. }
  4168. if (trigger) {
  4169. if (typeof Event === 'function') {
  4170. this.select.dispatchEvent(new Event('change'));
  4171. } else if ((typeof Event === 'undefined' ? 'undefined' : _typeof(Event)) === 'object') {
  4172. // IE11
  4173. var event = document.createEvent('Event');
  4174. event.initEvent('change', true, true);
  4175. this.select.dispatchEvent(event);
  4176. }
  4177. this.close();
  4178. }
  4179. }
  4180. }, {
  4181. key: 'update',
  4182. value: function update() {
  4183. var option = void 0;
  4184. if (this.select.selectedIndex > -1) {
  4185. var item = this.container.querySelector('.ql-picker-options').children[this.select.selectedIndex];
  4186. option = this.select.options[this.select.selectedIndex];
  4187. this.selectItem(item);
  4188. } else {
  4189. this.selectItem(null);
  4190. }
  4191. var isActive = option != null && option !== this.select.querySelector('option[selected]');
  4192. this.label.classList.toggle('ql-active', isActive);
  4193. }
  4194. }]);
  4195. return Picker;
  4196. }();
  4197. exports.default = Picker;
  4198. /***/ }),
  4199. /* 28 */
  4200. /***/ (function(module, exports, __webpack_require__) {
  4201. "use strict";
  4202. Object.defineProperty(exports, "__esModule", {
  4203. value: true
  4204. });
  4205. var _parchment = __webpack_require__(0);
  4206. var _parchment2 = _interopRequireDefault(_parchment);
  4207. var _quill = __webpack_require__(5);
  4208. var _quill2 = _interopRequireDefault(_quill);
  4209. var _block = __webpack_require__(4);
  4210. var _block2 = _interopRequireDefault(_block);
  4211. var _break = __webpack_require__(16);
  4212. var _break2 = _interopRequireDefault(_break);
  4213. var _container = __webpack_require__(24);
  4214. var _container2 = _interopRequireDefault(_container);
  4215. var _cursor = __webpack_require__(23);
  4216. var _cursor2 = _interopRequireDefault(_cursor);
  4217. var _embed = __webpack_require__(35);
  4218. var _embed2 = _interopRequireDefault(_embed);
  4219. var _inline = __webpack_require__(6);
  4220. var _inline2 = _interopRequireDefault(_inline);
  4221. var _scroll = __webpack_require__(22);
  4222. var _scroll2 = _interopRequireDefault(_scroll);
  4223. var _text = __webpack_require__(7);
  4224. var _text2 = _interopRequireDefault(_text);
  4225. var _clipboard = __webpack_require__(55);
  4226. var _clipboard2 = _interopRequireDefault(_clipboard);
  4227. var _history = __webpack_require__(42);
  4228. var _history2 = _interopRequireDefault(_history);
  4229. var _keyboard = __webpack_require__(34);
  4230. var _keyboard2 = _interopRequireDefault(_keyboard);
  4231. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4232. _quill2.default.register({
  4233. 'blots/block': _block2.default,
  4234. 'blots/block/embed': _block.BlockEmbed,
  4235. 'blots/break': _break2.default,
  4236. 'blots/container': _container2.default,
  4237. 'blots/cursor': _cursor2.default,
  4238. 'blots/embed': _embed2.default,
  4239. 'blots/inline': _inline2.default,
  4240. 'blots/scroll': _scroll2.default,
  4241. 'blots/text': _text2.default,
  4242. 'modules/clipboard': _clipboard2.default,
  4243. 'modules/history': _history2.default,
  4244. 'modules/keyboard': _keyboard2.default
  4245. });
  4246. _parchment2.default.register(_block2.default, _break2.default, _cursor2.default, _inline2.default, _scroll2.default, _text2.default);
  4247. exports.default = _quill2.default;
  4248. /***/ }),
  4249. /* 29 */
  4250. /***/ (function(module, exports, __webpack_require__) {
  4251. "use strict";
  4252. Object.defineProperty(exports, "__esModule", { value: true });
  4253. var Registry = __webpack_require__(1);
  4254. var ShadowBlot = /** @class */ (function () {
  4255. function ShadowBlot(domNode) {
  4256. this.domNode = domNode;
  4257. // @ts-ignore
  4258. this.domNode[Registry.DATA_KEY] = { blot: this };
  4259. }
  4260. Object.defineProperty(ShadowBlot.prototype, "statics", {
  4261. // Hack for accessing inherited static methods
  4262. get: function () {
  4263. return this.constructor;
  4264. },
  4265. enumerable: true,
  4266. configurable: true
  4267. });
  4268. ShadowBlot.create = function (value) {
  4269. if (this.tagName == null) {
  4270. throw new Registry.ParchmentError('Blot definition missing tagName');
  4271. }
  4272. var node;
  4273. if (Array.isArray(this.tagName)) {
  4274. if (typeof value === 'string') {
  4275. value = value.toUpperCase();
  4276. if (parseInt(value).toString() === value) {
  4277. value = parseInt(value);
  4278. }
  4279. }
  4280. if (typeof value === 'number') {
  4281. node = document.createElement(this.tagName[value - 1]);
  4282. }
  4283. else if (this.tagName.indexOf(value) > -1) {
  4284. node = document.createElement(value);
  4285. }
  4286. else {
  4287. node = document.createElement(this.tagName[0]);
  4288. }
  4289. }
  4290. else {
  4291. node = document.createElement(this.tagName);
  4292. }
  4293. if (this.className) {
  4294. node.classList.add(this.className);
  4295. }
  4296. return node;
  4297. };
  4298. ShadowBlot.prototype.attach = function () {
  4299. if (this.parent != null) {
  4300. this.scroll = this.parent.scroll;
  4301. }
  4302. };
  4303. ShadowBlot.prototype.clone = function () {
  4304. var domNode = this.domNode.cloneNode(false);
  4305. return Registry.create(domNode);
  4306. };
  4307. ShadowBlot.prototype.detach = function () {
  4308. if (this.parent != null)
  4309. this.parent.removeChild(this);
  4310. // @ts-ignore
  4311. delete this.domNode[Registry.DATA_KEY];
  4312. };
  4313. ShadowBlot.prototype.deleteAt = function (index, length) {
  4314. var blot = this.isolate(index, length);
  4315. blot.remove();
  4316. };
  4317. ShadowBlot.prototype.formatAt = function (index, length, name, value) {
  4318. var blot = this.isolate(index, length);
  4319. if (Registry.query(name, Registry.Scope.BLOT) != null && value) {
  4320. blot.wrap(name, value);
  4321. }
  4322. else if (Registry.query(name, Registry.Scope.ATTRIBUTE) != null) {
  4323. var parent = Registry.create(this.statics.scope);
  4324. blot.wrap(parent);
  4325. parent.format(name, value);
  4326. }
  4327. };
  4328. ShadowBlot.prototype.insertAt = function (index, value, def) {
  4329. var blot = def == null ? Registry.create('text', value) : Registry.create(value, def);
  4330. var ref = this.split(index);
  4331. this.parent.insertBefore(blot, ref);
  4332. };
  4333. ShadowBlot.prototype.insertInto = function (parentBlot, refBlot) {
  4334. if (refBlot === void 0) { refBlot = null; }
  4335. if (this.parent != null) {
  4336. this.parent.children.remove(this);
  4337. }
  4338. var refDomNode = null;
  4339. parentBlot.children.insertBefore(this, refBlot);
  4340. if (refBlot != null) {
  4341. refDomNode = refBlot.domNode;
  4342. }
  4343. if (this.next == null || this.domNode.nextSibling != refDomNode) {
  4344. parentBlot.domNode.insertBefore(this.domNode, refDomNode);
  4345. }
  4346. this.parent = parentBlot;
  4347. this.attach();
  4348. };
  4349. ShadowBlot.prototype.isolate = function (index, length) {
  4350. var target = this.split(index);
  4351. target.split(length);
  4352. return target;
  4353. };
  4354. ShadowBlot.prototype.length = function () {
  4355. return 1;
  4356. };
  4357. ShadowBlot.prototype.offset = function (root) {
  4358. if (root === void 0) { root = this.parent; }
  4359. if (this.parent == null || this == root)
  4360. return 0;
  4361. return this.parent.children.offset(this) + this.parent.offset(root);
  4362. };
  4363. ShadowBlot.prototype.optimize = function (context) {
  4364. // TODO clean up once we use WeakMap
  4365. // @ts-ignore
  4366. if (this.domNode[Registry.DATA_KEY] != null) {
  4367. // @ts-ignore
  4368. delete this.domNode[Registry.DATA_KEY].mutations;
  4369. }
  4370. };
  4371. ShadowBlot.prototype.remove = function () {
  4372. if (this.domNode.parentNode != null) {
  4373. this.domNode.parentNode.removeChild(this.domNode);
  4374. }
  4375. this.detach();
  4376. };
  4377. ShadowBlot.prototype.replace = function (target) {
  4378. if (target.parent == null)
  4379. return;
  4380. target.parent.insertBefore(this, target.next);
  4381. target.remove();
  4382. };
  4383. ShadowBlot.prototype.replaceWith = function (name, value) {
  4384. var replacement = typeof name === 'string' ? Registry.create(name, value) : name;
  4385. replacement.replace(this);
  4386. return replacement;
  4387. };
  4388. ShadowBlot.prototype.split = function (index, force) {
  4389. return index === 0 ? this : this.next;
  4390. };
  4391. ShadowBlot.prototype.update = function (mutations, context) {
  4392. // Nothing to do by default
  4393. };
  4394. ShadowBlot.prototype.wrap = function (name, value) {
  4395. var wrapper = typeof name === 'string' ? Registry.create(name, value) : name;
  4396. if (this.parent != null) {
  4397. this.parent.insertBefore(wrapper, this.next);
  4398. }
  4399. wrapper.appendChild(this);
  4400. return wrapper;
  4401. };
  4402. ShadowBlot.blotName = 'abstract';
  4403. return ShadowBlot;
  4404. }());
  4405. exports.default = ShadowBlot;
  4406. /***/ }),
  4407. /* 30 */
  4408. /***/ (function(module, exports, __webpack_require__) {
  4409. "use strict";
  4410. Object.defineProperty(exports, "__esModule", { value: true });
  4411. var attributor_1 = __webpack_require__(12);
  4412. var class_1 = __webpack_require__(31);
  4413. var style_1 = __webpack_require__(32);
  4414. var Registry = __webpack_require__(1);
  4415. var AttributorStore = /** @class */ (function () {
  4416. function AttributorStore(domNode) {
  4417. this.attributes = {};
  4418. this.domNode = domNode;
  4419. this.build();
  4420. }
  4421. AttributorStore.prototype.attribute = function (attribute, value) {
  4422. // verb
  4423. if (value) {
  4424. if (attribute.add(this.domNode, value)) {
  4425. if (attribute.value(this.domNode) != null) {
  4426. this.attributes[attribute.attrName] = attribute;
  4427. }
  4428. else {
  4429. delete this.attributes[attribute.attrName];
  4430. }
  4431. }
  4432. }
  4433. else {
  4434. attribute.remove(this.domNode);
  4435. delete this.attributes[attribute.attrName];
  4436. }
  4437. };
  4438. AttributorStore.prototype.build = function () {
  4439. var _this = this;
  4440. this.attributes = {};
  4441. var attributes = attributor_1.default.keys(this.domNode);
  4442. var classes = class_1.default.keys(this.domNode);
  4443. var styles = style_1.default.keys(this.domNode);
  4444. attributes
  4445. .concat(classes)
  4446. .concat(styles)
  4447. .forEach(function (name) {
  4448. var attr = Registry.query(name, Registry.Scope.ATTRIBUTE);
  4449. if (attr instanceof attributor_1.default) {
  4450. _this.attributes[attr.attrName] = attr;
  4451. }
  4452. });
  4453. };
  4454. AttributorStore.prototype.copy = function (target) {
  4455. var _this = this;
  4456. Object.keys(this.attributes).forEach(function (key) {
  4457. var value = _this.attributes[key].value(_this.domNode);
  4458. target.format(key, value);
  4459. });
  4460. };
  4461. AttributorStore.prototype.move = function (target) {
  4462. var _this = this;
  4463. this.copy(target);
  4464. Object.keys(this.attributes).forEach(function (key) {
  4465. _this.attributes[key].remove(_this.domNode);
  4466. });
  4467. this.attributes = {};
  4468. };
  4469. AttributorStore.prototype.values = function () {
  4470. var _this = this;
  4471. return Object.keys(this.attributes).reduce(function (attributes, name) {
  4472. attributes[name] = _this.attributes[name].value(_this.domNode);
  4473. return attributes;
  4474. }, {});
  4475. };
  4476. return AttributorStore;
  4477. }());
  4478. exports.default = AttributorStore;
  4479. /***/ }),
  4480. /* 31 */
  4481. /***/ (function(module, exports, __webpack_require__) {
  4482. "use strict";
  4483. var __extends = (this && this.__extends) || (function () {
  4484. var extendStatics = Object.setPrototypeOf ||
  4485. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4486. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4487. return function (d, b) {
  4488. extendStatics(d, b);
  4489. function __() { this.constructor = d; }
  4490. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4491. };
  4492. })();
  4493. Object.defineProperty(exports, "__esModule", { value: true });
  4494. var attributor_1 = __webpack_require__(12);
  4495. function match(node, prefix) {
  4496. var className = node.getAttribute('class') || '';
  4497. return className.split(/\s+/).filter(function (name) {
  4498. return name.indexOf(prefix + "-") === 0;
  4499. });
  4500. }
  4501. var ClassAttributor = /** @class */ (function (_super) {
  4502. __extends(ClassAttributor, _super);
  4503. function ClassAttributor() {
  4504. return _super !== null && _super.apply(this, arguments) || this;
  4505. }
  4506. ClassAttributor.keys = function (node) {
  4507. return (node.getAttribute('class') || '').split(/\s+/).map(function (name) {
  4508. return name
  4509. .split('-')
  4510. .slice(0, -1)
  4511. .join('-');
  4512. });
  4513. };
  4514. ClassAttributor.prototype.add = function (node, value) {
  4515. if (!this.canAdd(node, value))
  4516. return false;
  4517. this.remove(node);
  4518. node.classList.add(this.keyName + "-" + value);
  4519. return true;
  4520. };
  4521. ClassAttributor.prototype.remove = function (node) {
  4522. var matches = match(node, this.keyName);
  4523. matches.forEach(function (name) {
  4524. node.classList.remove(name);
  4525. });
  4526. if (node.classList.length === 0) {
  4527. node.removeAttribute('class');
  4528. }
  4529. };
  4530. ClassAttributor.prototype.value = function (node) {
  4531. var result = match(node, this.keyName)[0] || '';
  4532. var value = result.slice(this.keyName.length + 1); // +1 for hyphen
  4533. return this.canAdd(node, value) ? value : '';
  4534. };
  4535. return ClassAttributor;
  4536. }(attributor_1.default));
  4537. exports.default = ClassAttributor;
  4538. /***/ }),
  4539. /* 32 */
  4540. /***/ (function(module, exports, __webpack_require__) {
  4541. "use strict";
  4542. var __extends = (this && this.__extends) || (function () {
  4543. var extendStatics = Object.setPrototypeOf ||
  4544. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4545. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4546. return function (d, b) {
  4547. extendStatics(d, b);
  4548. function __() { this.constructor = d; }
  4549. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4550. };
  4551. })();
  4552. Object.defineProperty(exports, "__esModule", { value: true });
  4553. var attributor_1 = __webpack_require__(12);
  4554. function camelize(name) {
  4555. var parts = name.split('-');
  4556. var rest = parts
  4557. .slice(1)
  4558. .map(function (part) {
  4559. return part[0].toUpperCase() + part.slice(1);
  4560. })
  4561. .join('');
  4562. return parts[0] + rest;
  4563. }
  4564. var StyleAttributor = /** @class */ (function (_super) {
  4565. __extends(StyleAttributor, _super);
  4566. function StyleAttributor() {
  4567. return _super !== null && _super.apply(this, arguments) || this;
  4568. }
  4569. StyleAttributor.keys = function (node) {
  4570. return (node.getAttribute('style') || '').split(';').map(function (value) {
  4571. var arr = value.split(':');
  4572. return arr[0].trim();
  4573. });
  4574. };
  4575. StyleAttributor.prototype.add = function (node, value) {
  4576. if (!this.canAdd(node, value))
  4577. return false;
  4578. // @ts-ignore
  4579. node.style[camelize(this.keyName)] = value;
  4580. return true;
  4581. };
  4582. StyleAttributor.prototype.remove = function (node) {
  4583. // @ts-ignore
  4584. node.style[camelize(this.keyName)] = '';
  4585. if (!node.getAttribute('style')) {
  4586. node.removeAttribute('style');
  4587. }
  4588. };
  4589. StyleAttributor.prototype.value = function (node) {
  4590. // @ts-ignore
  4591. var value = node.style[camelize(this.keyName)];
  4592. return this.canAdd(node, value) ? value : '';
  4593. };
  4594. return StyleAttributor;
  4595. }(attributor_1.default));
  4596. exports.default = StyleAttributor;
  4597. /***/ }),
  4598. /* 33 */
  4599. /***/ (function(module, exports, __webpack_require__) {
  4600. "use strict";
  4601. Object.defineProperty(exports, "__esModule", {
  4602. value: true
  4603. });
  4604. 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; }; }();
  4605. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4606. var Theme = function () {
  4607. function Theme(quill, options) {
  4608. _classCallCheck(this, Theme);
  4609. this.quill = quill;
  4610. this.options = options;
  4611. this.modules = {};
  4612. }
  4613. _createClass(Theme, [{
  4614. key: 'init',
  4615. value: function init() {
  4616. var _this = this;
  4617. Object.keys(this.options.modules).forEach(function (name) {
  4618. if (_this.modules[name] == null) {
  4619. _this.addModule(name);
  4620. }
  4621. });
  4622. }
  4623. }, {
  4624. key: 'addModule',
  4625. value: function addModule(name) {
  4626. var moduleClass = this.quill.constructor.import('modules/' + name);
  4627. this.modules[name] = new moduleClass(this.quill, this.options.modules[name] || {});
  4628. return this.modules[name];
  4629. }
  4630. }]);
  4631. return Theme;
  4632. }();
  4633. Theme.DEFAULTS = {
  4634. modules: {}
  4635. };
  4636. Theme.themes = {
  4637. 'default': Theme
  4638. };
  4639. exports.default = Theme;
  4640. /***/ }),
  4641. /* 34 */
  4642. /***/ (function(module, exports, __webpack_require__) {
  4643. "use strict";
  4644. Object.defineProperty(exports, "__esModule", {
  4645. value: true
  4646. });
  4647. exports.SHORTKEY = exports.default = undefined;
  4648. 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; };
  4649. 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"); } }; }();
  4650. 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; }; }();
  4651. var _clone = __webpack_require__(21);
  4652. var _clone2 = _interopRequireDefault(_clone);
  4653. var _deepEqual = __webpack_require__(11);
  4654. var _deepEqual2 = _interopRequireDefault(_deepEqual);
  4655. var _extend = __webpack_require__(3);
  4656. var _extend2 = _interopRequireDefault(_extend);
  4657. var _quillDelta = __webpack_require__(2);
  4658. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  4659. var _op = __webpack_require__(20);
  4660. var _op2 = _interopRequireDefault(_op);
  4661. var _parchment = __webpack_require__(0);
  4662. var _parchment2 = _interopRequireDefault(_parchment);
  4663. var _quill = __webpack_require__(5);
  4664. var _quill2 = _interopRequireDefault(_quill);
  4665. var _logger = __webpack_require__(10);
  4666. var _logger2 = _interopRequireDefault(_logger);
  4667. var _module = __webpack_require__(9);
  4668. var _module2 = _interopRequireDefault(_module);
  4669. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4670. 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; }
  4671. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4672. 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; }
  4673. 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; }
  4674. var debug = (0, _logger2.default)('quill:keyboard');
  4675. var SHORTKEY = /Mac/i.test(navigator.platform) ? 'metaKey' : 'ctrlKey';
  4676. var Keyboard = function (_Module) {
  4677. _inherits(Keyboard, _Module);
  4678. _createClass(Keyboard, null, [{
  4679. key: 'match',
  4680. value: function match(evt, binding) {
  4681. binding = normalize(binding);
  4682. if (['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].some(function (key) {
  4683. return !!binding[key] !== evt[key] && binding[key] !== null;
  4684. })) {
  4685. return false;
  4686. }
  4687. return binding.key === (evt.which || evt.keyCode);
  4688. }
  4689. }]);
  4690. function Keyboard(quill, options) {
  4691. _classCallCheck(this, Keyboard);
  4692. var _this = _possibleConstructorReturn(this, (Keyboard.__proto__ || Object.getPrototypeOf(Keyboard)).call(this, quill, options));
  4693. _this.bindings = {};
  4694. Object.keys(_this.options.bindings).forEach(function (name) {
  4695. if (name === 'list autofill' && quill.scroll.whitelist != null && !quill.scroll.whitelist['list']) {
  4696. return;
  4697. }
  4698. if (_this.options.bindings[name]) {
  4699. _this.addBinding(_this.options.bindings[name]);
  4700. }
  4701. });
  4702. _this.addBinding({ key: Keyboard.keys.ENTER, shiftKey: null }, handleEnter);
  4703. _this.addBinding({ key: Keyboard.keys.ENTER, metaKey: null, ctrlKey: null, altKey: null }, function () {});
  4704. if (/Firefox/i.test(navigator.userAgent)) {
  4705. // Need to handle delete and backspace for Firefox in the general case #1171
  4706. _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true }, handleBackspace);
  4707. _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true }, handleDelete);
  4708. } else {
  4709. _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: true, prefix: /^.?$/ }, handleBackspace);
  4710. _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: true, suffix: /^.?$/ }, handleDelete);
  4711. }
  4712. _this.addBinding({ key: Keyboard.keys.BACKSPACE }, { collapsed: false }, handleDeleteRange);
  4713. _this.addBinding({ key: Keyboard.keys.DELETE }, { collapsed: false }, handleDeleteRange);
  4714. _this.addBinding({ key: Keyboard.keys.BACKSPACE, altKey: null, ctrlKey: null, metaKey: null, shiftKey: null }, { collapsed: true, offset: 0 }, handleBackspace);
  4715. _this.listen();
  4716. return _this;
  4717. }
  4718. _createClass(Keyboard, [{
  4719. key: 'addBinding',
  4720. value: function addBinding(key) {
  4721. var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  4722. var handler = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  4723. var binding = normalize(key);
  4724. if (binding == null || binding.key == null) {
  4725. return debug.warn('Attempted to add invalid keyboard binding', binding);
  4726. }
  4727. if (typeof context === 'function') {
  4728. context = { handler: context };
  4729. }
  4730. if (typeof handler === 'function') {
  4731. handler = { handler: handler };
  4732. }
  4733. binding = (0, _extend2.default)(binding, context, handler);
  4734. this.bindings[binding.key] = this.bindings[binding.key] || [];
  4735. this.bindings[binding.key].push(binding);
  4736. }
  4737. }, {
  4738. key: 'listen',
  4739. value: function listen() {
  4740. var _this2 = this;
  4741. this.quill.root.addEventListener('keydown', function (evt) {
  4742. if (evt.defaultPrevented) return;
  4743. var which = evt.which || evt.keyCode;
  4744. var bindings = (_this2.bindings[which] || []).filter(function (binding) {
  4745. return Keyboard.match(evt, binding);
  4746. });
  4747. if (bindings.length === 0) return;
  4748. var range = _this2.quill.getSelection();
  4749. if (range == null || !_this2.quill.hasFocus()) return;
  4750. var _quill$getLine = _this2.quill.getLine(range.index),
  4751. _quill$getLine2 = _slicedToArray(_quill$getLine, 2),
  4752. line = _quill$getLine2[0],
  4753. offset = _quill$getLine2[1];
  4754. var _quill$getLeaf = _this2.quill.getLeaf(range.index),
  4755. _quill$getLeaf2 = _slicedToArray(_quill$getLeaf, 2),
  4756. leafStart = _quill$getLeaf2[0],
  4757. offsetStart = _quill$getLeaf2[1];
  4758. var _ref = range.length === 0 ? [leafStart, offsetStart] : _this2.quill.getLeaf(range.index + range.length),
  4759. _ref2 = _slicedToArray(_ref, 2),
  4760. leafEnd = _ref2[0],
  4761. offsetEnd = _ref2[1];
  4762. var prefixText = leafStart instanceof _parchment2.default.Text ? leafStart.value().slice(0, offsetStart) : '';
  4763. var suffixText = leafEnd instanceof _parchment2.default.Text ? leafEnd.value().slice(offsetEnd) : '';
  4764. var curContext = {
  4765. collapsed: range.length === 0,
  4766. empty: range.length === 0 && line.length() <= 1,
  4767. format: _this2.quill.getFormat(range),
  4768. offset: offset,
  4769. prefix: prefixText,
  4770. suffix: suffixText
  4771. };
  4772. var prevented = bindings.some(function (binding) {
  4773. if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) return false;
  4774. if (binding.empty != null && binding.empty !== curContext.empty) return false;
  4775. if (binding.offset != null && binding.offset !== curContext.offset) return false;
  4776. if (Array.isArray(binding.format)) {
  4777. // any format is present
  4778. if (binding.format.every(function (name) {
  4779. return curContext.format[name] == null;
  4780. })) {
  4781. return false;
  4782. }
  4783. } else if (_typeof(binding.format) === 'object') {
  4784. // all formats must match
  4785. if (!Object.keys(binding.format).every(function (name) {
  4786. if (binding.format[name] === true) return curContext.format[name] != null;
  4787. if (binding.format[name] === false) return curContext.format[name] == null;
  4788. return (0, _deepEqual2.default)(binding.format[name], curContext.format[name]);
  4789. })) {
  4790. return false;
  4791. }
  4792. }
  4793. if (binding.prefix != null && !binding.prefix.test(curContext.prefix)) return false;
  4794. if (binding.suffix != null && !binding.suffix.test(curContext.suffix)) return false;
  4795. return binding.handler.call(_this2, range, curContext) !== true;
  4796. });
  4797. if (prevented) {
  4798. evt.preventDefault();
  4799. }
  4800. });
  4801. }
  4802. }]);
  4803. return Keyboard;
  4804. }(_module2.default);
  4805. Keyboard.keys = {
  4806. BACKSPACE: 8,
  4807. TAB: 9,
  4808. ENTER: 13,
  4809. ESCAPE: 27,
  4810. LEFT: 37,
  4811. UP: 38,
  4812. RIGHT: 39,
  4813. DOWN: 40,
  4814. DELETE: 46
  4815. };
  4816. Keyboard.DEFAULTS = {
  4817. bindings: {
  4818. 'bold': makeFormatHandler('bold'),
  4819. 'italic': makeFormatHandler('italic'),
  4820. 'underline': makeFormatHandler('underline'),
  4821. 'indent': {
  4822. // highlight tab or tab at beginning of list, indent or blockquote
  4823. key: Keyboard.keys.TAB,
  4824. format: ['blockquote', 'indent', 'list'],
  4825. handler: function handler(range, context) {
  4826. if (context.collapsed && context.offset !== 0) return true;
  4827. this.quill.format('indent', '+1', _quill2.default.sources.USER);
  4828. }
  4829. },
  4830. 'outdent': {
  4831. key: Keyboard.keys.TAB,
  4832. shiftKey: true,
  4833. format: ['blockquote', 'indent', 'list'],
  4834. // highlight tab or tab at beginning of list, indent or blockquote
  4835. handler: function handler(range, context) {
  4836. if (context.collapsed && context.offset !== 0) return true;
  4837. this.quill.format('indent', '-1', _quill2.default.sources.USER);
  4838. }
  4839. },
  4840. 'outdent backspace': {
  4841. key: Keyboard.keys.BACKSPACE,
  4842. collapsed: true,
  4843. shiftKey: null,
  4844. metaKey: null,
  4845. ctrlKey: null,
  4846. altKey: null,
  4847. format: ['indent', 'list'],
  4848. offset: 0,
  4849. handler: function handler(range, context) {
  4850. if (context.format.indent != null) {
  4851. this.quill.format('indent', '-1', _quill2.default.sources.USER);
  4852. } else if (context.format.list != null) {
  4853. this.quill.format('list', false, _quill2.default.sources.USER);
  4854. }
  4855. }
  4856. },
  4857. 'indent code-block': makeCodeBlockHandler(true),
  4858. 'outdent code-block': makeCodeBlockHandler(false),
  4859. 'remove tab': {
  4860. key: Keyboard.keys.TAB,
  4861. shiftKey: true,
  4862. collapsed: true,
  4863. prefix: /\t$/,
  4864. handler: function handler(range) {
  4865. this.quill.deleteText(range.index - 1, 1, _quill2.default.sources.USER);
  4866. }
  4867. },
  4868. 'tab': {
  4869. key: Keyboard.keys.TAB,
  4870. handler: function handler(range) {
  4871. this.quill.history.cutoff();
  4872. var delta = new _quillDelta2.default().retain(range.index).delete(range.length).insert('\t');
  4873. this.quill.updateContents(delta, _quill2.default.sources.USER);
  4874. this.quill.history.cutoff();
  4875. this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
  4876. }
  4877. },
  4878. 'list empty enter': {
  4879. key: Keyboard.keys.ENTER,
  4880. collapsed: true,
  4881. format: ['list'],
  4882. empty: true,
  4883. handler: function handler(range, context) {
  4884. this.quill.format('list', false, _quill2.default.sources.USER);
  4885. if (context.format.indent) {
  4886. this.quill.format('indent', false, _quill2.default.sources.USER);
  4887. }
  4888. }
  4889. },
  4890. 'checklist enter': {
  4891. key: Keyboard.keys.ENTER,
  4892. collapsed: true,
  4893. format: { list: 'checked' },
  4894. handler: function handler(range) {
  4895. var _quill$getLine3 = this.quill.getLine(range.index),
  4896. _quill$getLine4 = _slicedToArray(_quill$getLine3, 2),
  4897. line = _quill$getLine4[0],
  4898. offset = _quill$getLine4[1];
  4899. var formats = (0, _extend2.default)({}, line.formats(), { list: 'checked' });
  4900. var delta = new _quillDelta2.default().retain(range.index).insert('\n', formats).retain(line.length() - offset - 1).retain(1, { list: 'unchecked' });
  4901. this.quill.updateContents(delta, _quill2.default.sources.USER);
  4902. this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
  4903. this.quill.scrollIntoView();
  4904. }
  4905. },
  4906. 'header enter': {
  4907. key: Keyboard.keys.ENTER,
  4908. collapsed: true,
  4909. format: ['header'],
  4910. suffix: /^$/,
  4911. handler: function handler(range, context) {
  4912. var _quill$getLine5 = this.quill.getLine(range.index),
  4913. _quill$getLine6 = _slicedToArray(_quill$getLine5, 2),
  4914. line = _quill$getLine6[0],
  4915. offset = _quill$getLine6[1];
  4916. var delta = new _quillDelta2.default().retain(range.index).insert('\n', context.format).retain(line.length() - offset - 1).retain(1, { header: null });
  4917. this.quill.updateContents(delta, _quill2.default.sources.USER);
  4918. this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
  4919. this.quill.scrollIntoView();
  4920. }
  4921. },
  4922. 'list autofill': {
  4923. key: ' ',
  4924. collapsed: true,
  4925. format: { list: false },
  4926. prefix: /^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,
  4927. handler: function handler(range, context) {
  4928. var length = context.prefix.length;
  4929. var _quill$getLine7 = this.quill.getLine(range.index),
  4930. _quill$getLine8 = _slicedToArray(_quill$getLine7, 2),
  4931. line = _quill$getLine8[0],
  4932. offset = _quill$getLine8[1];
  4933. if (offset > length) return true;
  4934. var value = void 0;
  4935. switch (context.prefix.trim()) {
  4936. case '[]':case '[ ]':
  4937. value = 'unchecked';
  4938. break;
  4939. case '[x]':
  4940. value = 'checked';
  4941. break;
  4942. case '-':case '*':
  4943. value = 'bullet';
  4944. break;
  4945. default:
  4946. value = 'ordered';
  4947. }
  4948. this.quill.insertText(range.index, ' ', _quill2.default.sources.USER);
  4949. this.quill.history.cutoff();
  4950. var delta = new _quillDelta2.default().retain(range.index - offset).delete(length + 1).retain(line.length() - 2 - offset).retain(1, { list: value });
  4951. this.quill.updateContents(delta, _quill2.default.sources.USER);
  4952. this.quill.history.cutoff();
  4953. this.quill.setSelection(range.index - length, _quill2.default.sources.SILENT);
  4954. }
  4955. },
  4956. 'code exit': {
  4957. key: Keyboard.keys.ENTER,
  4958. collapsed: true,
  4959. format: ['code-block'],
  4960. prefix: /\n\n$/,
  4961. suffix: /^\s+$/,
  4962. handler: function handler(range) {
  4963. var _quill$getLine9 = this.quill.getLine(range.index),
  4964. _quill$getLine10 = _slicedToArray(_quill$getLine9, 2),
  4965. line = _quill$getLine10[0],
  4966. offset = _quill$getLine10[1];
  4967. var delta = new _quillDelta2.default().retain(range.index + line.length() - offset - 2).retain(1, { 'code-block': null }).delete(1);
  4968. this.quill.updateContents(delta, _quill2.default.sources.USER);
  4969. }
  4970. },
  4971. 'embed left': makeEmbedArrowHandler(Keyboard.keys.LEFT, false),
  4972. 'embed left shift': makeEmbedArrowHandler(Keyboard.keys.LEFT, true),
  4973. 'embed right': makeEmbedArrowHandler(Keyboard.keys.RIGHT, false),
  4974. 'embed right shift': makeEmbedArrowHandler(Keyboard.keys.RIGHT, true)
  4975. }
  4976. };
  4977. function makeEmbedArrowHandler(key, shiftKey) {
  4978. var _ref3;
  4979. var where = key === Keyboard.keys.LEFT ? 'prefix' : 'suffix';
  4980. return _ref3 = {
  4981. key: key,
  4982. shiftKey: shiftKey,
  4983. altKey: null
  4984. }, _defineProperty(_ref3, where, /^$/), _defineProperty(_ref3, 'handler', function handler(range) {
  4985. var index = range.index;
  4986. if (key === Keyboard.keys.RIGHT) {
  4987. index += range.length + 1;
  4988. }
  4989. var _quill$getLeaf3 = this.quill.getLeaf(index),
  4990. _quill$getLeaf4 = _slicedToArray(_quill$getLeaf3, 1),
  4991. leaf = _quill$getLeaf4[0];
  4992. if (!(leaf instanceof _parchment2.default.Embed)) return true;
  4993. if (key === Keyboard.keys.LEFT) {
  4994. if (shiftKey) {
  4995. this.quill.setSelection(range.index - 1, range.length + 1, _quill2.default.sources.USER);
  4996. } else {
  4997. this.quill.setSelection(range.index - 1, _quill2.default.sources.USER);
  4998. }
  4999. } else {
  5000. if (shiftKey) {
  5001. this.quill.setSelection(range.index, range.length + 1, _quill2.default.sources.USER);
  5002. } else {
  5003. this.quill.setSelection(range.index + range.length + 1, _quill2.default.sources.USER);
  5004. }
  5005. }
  5006. return false;
  5007. }), _ref3;
  5008. }
  5009. function handleBackspace(range, context) {
  5010. if (range.index === 0 || this.quill.getLength() <= 1) return;
  5011. var _quill$getLine11 = this.quill.getLine(range.index),
  5012. _quill$getLine12 = _slicedToArray(_quill$getLine11, 1),
  5013. line = _quill$getLine12[0];
  5014. var formats = {};
  5015. if (context.offset === 0) {
  5016. var _quill$getLine13 = this.quill.getLine(range.index - 1),
  5017. _quill$getLine14 = _slicedToArray(_quill$getLine13, 1),
  5018. prev = _quill$getLine14[0];
  5019. if (prev != null && prev.length() > 1) {
  5020. var curFormats = line.formats();
  5021. var prevFormats = this.quill.getFormat(range.index - 1, 1);
  5022. formats = _op2.default.attributes.diff(curFormats, prevFormats) || {};
  5023. }
  5024. }
  5025. // Check for astral symbols
  5026. var length = /[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(context.prefix) ? 2 : 1;
  5027. this.quill.deleteText(range.index - length, length, _quill2.default.sources.USER);
  5028. if (Object.keys(formats).length > 0) {
  5029. this.quill.formatLine(range.index - length, length, formats, _quill2.default.sources.USER);
  5030. }
  5031. this.quill.focus();
  5032. }
  5033. function handleDelete(range, context) {
  5034. // Check for astral symbols
  5035. var length = /^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(context.suffix) ? 2 : 1;
  5036. if (range.index >= this.quill.getLength() - length) return;
  5037. var formats = {},
  5038. nextLength = 0;
  5039. var _quill$getLine15 = this.quill.getLine(range.index),
  5040. _quill$getLine16 = _slicedToArray(_quill$getLine15, 1),
  5041. line = _quill$getLine16[0];
  5042. if (context.offset >= line.length() - 1) {
  5043. var _quill$getLine17 = this.quill.getLine(range.index + 1),
  5044. _quill$getLine18 = _slicedToArray(_quill$getLine17, 1),
  5045. next = _quill$getLine18[0];
  5046. if (next) {
  5047. var curFormats = line.formats();
  5048. var nextFormats = this.quill.getFormat(range.index, 1);
  5049. formats = _op2.default.attributes.diff(curFormats, nextFormats) || {};
  5050. nextLength = next.length();
  5051. }
  5052. }
  5053. this.quill.deleteText(range.index, length, _quill2.default.sources.USER);
  5054. if (Object.keys(formats).length > 0) {
  5055. this.quill.formatLine(range.index + nextLength - 1, length, formats, _quill2.default.sources.USER);
  5056. }
  5057. }
  5058. function handleDeleteRange(range) {
  5059. var lines = this.quill.getLines(range);
  5060. var formats = {};
  5061. if (lines.length > 1) {
  5062. var firstFormats = lines[0].formats();
  5063. var lastFormats = lines[lines.length - 1].formats();
  5064. formats = _op2.default.attributes.diff(lastFormats, firstFormats) || {};
  5065. }
  5066. this.quill.deleteText(range, _quill2.default.sources.USER);
  5067. if (Object.keys(formats).length > 0) {
  5068. this.quill.formatLine(range.index, 1, formats, _quill2.default.sources.USER);
  5069. }
  5070. this.quill.setSelection(range.index, _quill2.default.sources.SILENT);
  5071. this.quill.focus();
  5072. }
  5073. function handleEnter(range, context) {
  5074. var _this3 = this;
  5075. if (range.length > 0) {
  5076. this.quill.scroll.deleteAt(range.index, range.length); // So we do not trigger text-change
  5077. }
  5078. var lineFormats = Object.keys(context.format).reduce(function (lineFormats, format) {
  5079. if (_parchment2.default.query(format, _parchment2.default.Scope.BLOCK) && !Array.isArray(context.format[format])) {
  5080. lineFormats[format] = context.format[format];
  5081. }
  5082. return lineFormats;
  5083. }, {});
  5084. this.quill.insertText(range.index, '\n', lineFormats, _quill2.default.sources.USER);
  5085. // Earlier scroll.deleteAt might have messed up our selection,
  5086. // so insertText's built in selection preservation is not reliable
  5087. this.quill.setSelection(range.index + 1, _quill2.default.sources.SILENT);
  5088. this.quill.focus();
  5089. Object.keys(context.format).forEach(function (name) {
  5090. if (lineFormats[name] != null) return;
  5091. if (Array.isArray(context.format[name])) return;
  5092. if (name === 'link') return;
  5093. _this3.quill.format(name, context.format[name], _quill2.default.sources.USER);
  5094. });
  5095. }
  5096. function makeCodeBlockHandler(indent) {
  5097. return {
  5098. key: Keyboard.keys.TAB,
  5099. shiftKey: !indent,
  5100. format: { 'code-block': true },
  5101. handler: function handler(range) {
  5102. var CodeBlock = _parchment2.default.query('code-block');
  5103. var index = range.index,
  5104. length = range.length;
  5105. var _quill$scroll$descend = this.quill.scroll.descendant(CodeBlock, index),
  5106. _quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2),
  5107. block = _quill$scroll$descend2[0],
  5108. offset = _quill$scroll$descend2[1];
  5109. if (block == null) return;
  5110. var scrollIndex = this.quill.getIndex(block);
  5111. var start = block.newlineIndex(offset, true) + 1;
  5112. var end = block.newlineIndex(scrollIndex + offset + length);
  5113. var lines = block.domNode.textContent.slice(start, end).split('\n');
  5114. offset = 0;
  5115. lines.forEach(function (line, i) {
  5116. if (indent) {
  5117. block.insertAt(start + offset, CodeBlock.TAB);
  5118. offset += CodeBlock.TAB.length;
  5119. if (i === 0) {
  5120. index += CodeBlock.TAB.length;
  5121. } else {
  5122. length += CodeBlock.TAB.length;
  5123. }
  5124. } else if (line.startsWith(CodeBlock.TAB)) {
  5125. block.deleteAt(start + offset, CodeBlock.TAB.length);
  5126. offset -= CodeBlock.TAB.length;
  5127. if (i === 0) {
  5128. index -= CodeBlock.TAB.length;
  5129. } else {
  5130. length -= CodeBlock.TAB.length;
  5131. }
  5132. }
  5133. offset += line.length + 1;
  5134. });
  5135. this.quill.update(_quill2.default.sources.USER);
  5136. this.quill.setSelection(index, length, _quill2.default.sources.SILENT);
  5137. }
  5138. };
  5139. }
  5140. function makeFormatHandler(format) {
  5141. return {
  5142. key: format[0].toUpperCase(),
  5143. shortKey: true,
  5144. handler: function handler(range, context) {
  5145. this.quill.format(format, !context.format[format], _quill2.default.sources.USER);
  5146. }
  5147. };
  5148. }
  5149. function normalize(binding) {
  5150. if (typeof binding === 'string' || typeof binding === 'number') {
  5151. return normalize({ key: binding });
  5152. }
  5153. if ((typeof binding === 'undefined' ? 'undefined' : _typeof(binding)) === 'object') {
  5154. binding = (0, _clone2.default)(binding, false);
  5155. }
  5156. if (typeof binding.key === 'string') {
  5157. if (Keyboard.keys[binding.key.toUpperCase()] != null) {
  5158. binding.key = Keyboard.keys[binding.key.toUpperCase()];
  5159. } else if (binding.key.length === 1) {
  5160. binding.key = binding.key.toUpperCase().charCodeAt(0);
  5161. } else {
  5162. return null;
  5163. }
  5164. }
  5165. if (binding.shortKey) {
  5166. binding[SHORTKEY] = binding.shortKey;
  5167. delete binding.shortKey;
  5168. }
  5169. return binding;
  5170. }
  5171. exports.default = Keyboard;
  5172. exports.SHORTKEY = SHORTKEY;
  5173. /***/ }),
  5174. /* 35 */
  5175. /***/ (function(module, exports, __webpack_require__) {
  5176. "use strict";
  5177. Object.defineProperty(exports, "__esModule", {
  5178. value: true
  5179. });
  5180. 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; }; }();
  5181. 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); } };
  5182. var _parchment = __webpack_require__(0);
  5183. var _parchment2 = _interopRequireDefault(_parchment);
  5184. var _text = __webpack_require__(7);
  5185. var _text2 = _interopRequireDefault(_text);
  5186. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5187. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5188. 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; }
  5189. 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; }
  5190. var GUARD_TEXT = '\uFEFF';
  5191. var Embed = function (_Parchment$Embed) {
  5192. _inherits(Embed, _Parchment$Embed);
  5193. function Embed(node) {
  5194. _classCallCheck(this, Embed);
  5195. var _this = _possibleConstructorReturn(this, (Embed.__proto__ || Object.getPrototypeOf(Embed)).call(this, node));
  5196. _this.contentNode = document.createElement('span');
  5197. _this.contentNode.setAttribute('contenteditable', false);
  5198. [].slice.call(_this.domNode.childNodes).forEach(function (childNode) {
  5199. _this.contentNode.appendChild(childNode);
  5200. });
  5201. _this.leftGuard = document.createTextNode(GUARD_TEXT);
  5202. _this.rightGuard = document.createTextNode(GUARD_TEXT);
  5203. _this.domNode.appendChild(_this.leftGuard);
  5204. _this.domNode.appendChild(_this.contentNode);
  5205. _this.domNode.appendChild(_this.rightGuard);
  5206. return _this;
  5207. }
  5208. _createClass(Embed, [{
  5209. key: 'index',
  5210. value: function index(node, offset) {
  5211. if (node === this.leftGuard) return 0;
  5212. if (node === this.rightGuard) return 1;
  5213. return _get(Embed.prototype.__proto__ || Object.getPrototypeOf(Embed.prototype), 'index', this).call(this, node, offset);
  5214. }
  5215. }, {
  5216. key: 'restore',
  5217. value: function restore(node) {
  5218. var range = void 0,
  5219. textNode = void 0;
  5220. var text = node.data.split(GUARD_TEXT).join('');
  5221. if (node === this.leftGuard) {
  5222. if (this.prev instanceof _text2.default) {
  5223. var prevLength = this.prev.length();
  5224. this.prev.insertAt(prevLength, text);
  5225. range = {
  5226. startNode: this.prev.domNode,
  5227. startOffset: prevLength + text.length
  5228. };
  5229. } else {
  5230. textNode = document.createTextNode(text);
  5231. this.parent.insertBefore(_parchment2.default.create(textNode), this);
  5232. range = {
  5233. startNode: textNode,
  5234. startOffset: text.length
  5235. };
  5236. }
  5237. } else if (node === this.rightGuard) {
  5238. if (this.next instanceof _text2.default) {
  5239. this.next.insertAt(0, text);
  5240. range = {
  5241. startNode: this.next.domNode,
  5242. startOffset: text.length
  5243. };
  5244. } else {
  5245. textNode = document.createTextNode(text);
  5246. this.parent.insertBefore(_parchment2.default.create(textNode), this.next);
  5247. range = {
  5248. startNode: textNode,
  5249. startOffset: text.length
  5250. };
  5251. }
  5252. }
  5253. node.data = GUARD_TEXT;
  5254. return range;
  5255. }
  5256. }, {
  5257. key: 'update',
  5258. value: function update(mutations, context) {
  5259. var _this2 = this;
  5260. mutations.forEach(function (mutation) {
  5261. if (mutation.type === 'characterData' && (mutation.target === _this2.leftGuard || mutation.target === _this2.rightGuard)) {
  5262. var range = _this2.restore(mutation.target);
  5263. if (range) context.range = range;
  5264. }
  5265. });
  5266. }
  5267. }]);
  5268. return Embed;
  5269. }(_parchment2.default.Embed);
  5270. exports.default = Embed;
  5271. /***/ }),
  5272. /* 36 */
  5273. /***/ (function(module, exports, __webpack_require__) {
  5274. "use strict";
  5275. Object.defineProperty(exports, "__esModule", {
  5276. value: true
  5277. });
  5278. exports.AlignStyle = exports.AlignClass = exports.AlignAttribute = undefined;
  5279. var _parchment = __webpack_require__(0);
  5280. var _parchment2 = _interopRequireDefault(_parchment);
  5281. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5282. var config = {
  5283. scope: _parchment2.default.Scope.BLOCK,
  5284. whitelist: ['right', 'center', 'justify']
  5285. };
  5286. var AlignAttribute = new _parchment2.default.Attributor.Attribute('align', 'align', config);
  5287. var AlignClass = new _parchment2.default.Attributor.Class('align', 'ql-align', config);
  5288. var AlignStyle = new _parchment2.default.Attributor.Style('align', 'text-align', config);
  5289. exports.AlignAttribute = AlignAttribute;
  5290. exports.AlignClass = AlignClass;
  5291. exports.AlignStyle = AlignStyle;
  5292. /***/ }),
  5293. /* 37 */
  5294. /***/ (function(module, exports, __webpack_require__) {
  5295. "use strict";
  5296. Object.defineProperty(exports, "__esModule", {
  5297. value: true
  5298. });
  5299. exports.BackgroundStyle = exports.BackgroundClass = undefined;
  5300. var _parchment = __webpack_require__(0);
  5301. var _parchment2 = _interopRequireDefault(_parchment);
  5302. var _color = __webpack_require__(25);
  5303. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5304. var BackgroundClass = new _parchment2.default.Attributor.Class('background', 'ql-bg', {
  5305. scope: _parchment2.default.Scope.INLINE
  5306. });
  5307. var BackgroundStyle = new _color.ColorAttributor('background', 'background-color', {
  5308. scope: _parchment2.default.Scope.INLINE
  5309. });
  5310. exports.BackgroundClass = BackgroundClass;
  5311. exports.BackgroundStyle = BackgroundStyle;
  5312. /***/ }),
  5313. /* 38 */
  5314. /***/ (function(module, exports, __webpack_require__) {
  5315. "use strict";
  5316. Object.defineProperty(exports, "__esModule", {
  5317. value: true
  5318. });
  5319. exports.DirectionStyle = exports.DirectionClass = exports.DirectionAttribute = undefined;
  5320. var _parchment = __webpack_require__(0);
  5321. var _parchment2 = _interopRequireDefault(_parchment);
  5322. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5323. var config = {
  5324. scope: _parchment2.default.Scope.BLOCK,
  5325. whitelist: ['rtl']
  5326. };
  5327. var DirectionAttribute = new _parchment2.default.Attributor.Attribute('direction', 'dir', config);
  5328. var DirectionClass = new _parchment2.default.Attributor.Class('direction', 'ql-direction', config);
  5329. var DirectionStyle = new _parchment2.default.Attributor.Style('direction', 'direction', config);
  5330. exports.DirectionAttribute = DirectionAttribute;
  5331. exports.DirectionClass = DirectionClass;
  5332. exports.DirectionStyle = DirectionStyle;
  5333. /***/ }),
  5334. /* 39 */
  5335. /***/ (function(module, exports, __webpack_require__) {
  5336. "use strict";
  5337. Object.defineProperty(exports, "__esModule", {
  5338. value: true
  5339. });
  5340. exports.FontClass = exports.FontStyle = undefined;
  5341. 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; }; }();
  5342. 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); } };
  5343. var _parchment = __webpack_require__(0);
  5344. var _parchment2 = _interopRequireDefault(_parchment);
  5345. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5346. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5347. 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; }
  5348. 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; }
  5349. var config = {
  5350. scope: _parchment2.default.Scope.INLINE,
  5351. whitelist: ['serif', 'monospace']
  5352. };
  5353. var FontClass = new _parchment2.default.Attributor.Class('font', 'ql-font', config);
  5354. var FontStyleAttributor = function (_Parchment$Attributor) {
  5355. _inherits(FontStyleAttributor, _Parchment$Attributor);
  5356. function FontStyleAttributor() {
  5357. _classCallCheck(this, FontStyleAttributor);
  5358. return _possibleConstructorReturn(this, (FontStyleAttributor.__proto__ || Object.getPrototypeOf(FontStyleAttributor)).apply(this, arguments));
  5359. }
  5360. _createClass(FontStyleAttributor, [{
  5361. key: 'value',
  5362. value: function value(node) {
  5363. return _get(FontStyleAttributor.prototype.__proto__ || Object.getPrototypeOf(FontStyleAttributor.prototype), 'value', this).call(this, node).replace(/["']/g, '');
  5364. }
  5365. }]);
  5366. return FontStyleAttributor;
  5367. }(_parchment2.default.Attributor.Style);
  5368. var FontStyle = new FontStyleAttributor('font', 'font-family', config);
  5369. exports.FontStyle = FontStyle;
  5370. exports.FontClass = FontClass;
  5371. /***/ }),
  5372. /* 40 */
  5373. /***/ (function(module, exports, __webpack_require__) {
  5374. "use strict";
  5375. Object.defineProperty(exports, "__esModule", {
  5376. value: true
  5377. });
  5378. exports.SizeStyle = exports.SizeClass = undefined;
  5379. var _parchment = __webpack_require__(0);
  5380. var _parchment2 = _interopRequireDefault(_parchment);
  5381. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5382. var SizeClass = new _parchment2.default.Attributor.Class('size', 'ql-size', {
  5383. scope: _parchment2.default.Scope.INLINE,
  5384. whitelist: ['small', 'large', 'huge']
  5385. });
  5386. var SizeStyle = new _parchment2.default.Attributor.Style('size', 'font-size', {
  5387. scope: _parchment2.default.Scope.INLINE,
  5388. whitelist: ['10px', '18px', '32px']
  5389. });
  5390. exports.SizeClass = SizeClass;
  5391. exports.SizeStyle = SizeStyle;
  5392. /***/ }),
  5393. /* 41 */
  5394. /***/ (function(module, exports, __webpack_require__) {
  5395. "use strict";
  5396. module.exports = {
  5397. 'align': {
  5398. '': __webpack_require__(76),
  5399. 'center': __webpack_require__(77),
  5400. 'right': __webpack_require__(78),
  5401. 'justify': __webpack_require__(79)
  5402. },
  5403. 'background': __webpack_require__(80),
  5404. 'blockquote': __webpack_require__(81),
  5405. 'bold': __webpack_require__(82),
  5406. 'clean': __webpack_require__(83),
  5407. 'code': __webpack_require__(58),
  5408. 'code-block': __webpack_require__(58),
  5409. 'color': __webpack_require__(84),
  5410. 'direction': {
  5411. '': __webpack_require__(85),
  5412. 'rtl': __webpack_require__(86)
  5413. },
  5414. 'float': {
  5415. 'center': __webpack_require__(87),
  5416. 'full': __webpack_require__(88),
  5417. 'left': __webpack_require__(89),
  5418. 'right': __webpack_require__(90)
  5419. },
  5420. 'formula': __webpack_require__(91),
  5421. 'header': {
  5422. '1': __webpack_require__(92),
  5423. '2': __webpack_require__(93)
  5424. },
  5425. 'italic': __webpack_require__(94),
  5426. 'image': __webpack_require__(95),
  5427. 'indent': {
  5428. '+1': __webpack_require__(96),
  5429. '-1': __webpack_require__(97)
  5430. },
  5431. 'link': __webpack_require__(98),
  5432. 'list': {
  5433. 'ordered': __webpack_require__(99),
  5434. 'bullet': __webpack_require__(100),
  5435. 'check': __webpack_require__(101)
  5436. },
  5437. 'script': {
  5438. 'sub': __webpack_require__(102),
  5439. 'super': __webpack_require__(103)
  5440. },
  5441. 'strike': __webpack_require__(104),
  5442. 'underline': __webpack_require__(105),
  5443. 'video': __webpack_require__(106)
  5444. };
  5445. /***/ }),
  5446. /* 42 */
  5447. /***/ (function(module, exports, __webpack_require__) {
  5448. "use strict";
  5449. Object.defineProperty(exports, "__esModule", {
  5450. value: true
  5451. });
  5452. exports.getLastChangeIndex = exports.default = undefined;
  5453. 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; }; }();
  5454. var _parchment = __webpack_require__(0);
  5455. var _parchment2 = _interopRequireDefault(_parchment);
  5456. var _quill = __webpack_require__(5);
  5457. var _quill2 = _interopRequireDefault(_quill);
  5458. var _module = __webpack_require__(9);
  5459. var _module2 = _interopRequireDefault(_module);
  5460. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5461. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5462. 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; }
  5463. 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; }
  5464. var History = function (_Module) {
  5465. _inherits(History, _Module);
  5466. function History(quill, options) {
  5467. _classCallCheck(this, History);
  5468. var _this = _possibleConstructorReturn(this, (History.__proto__ || Object.getPrototypeOf(History)).call(this, quill, options));
  5469. _this.lastRecorded = 0;
  5470. _this.ignoreChange = false;
  5471. _this.clear();
  5472. _this.quill.on(_quill2.default.events.EDITOR_CHANGE, function (eventName, delta, oldDelta, source) {
  5473. if (eventName !== _quill2.default.events.TEXT_CHANGE || _this.ignoreChange) return;
  5474. if (!_this.options.userOnly || source === _quill2.default.sources.USER) {
  5475. _this.record(delta, oldDelta);
  5476. } else {
  5477. _this.transform(delta);
  5478. }
  5479. });
  5480. _this.quill.keyboard.addBinding({ key: 'Z', shortKey: true }, _this.undo.bind(_this));
  5481. _this.quill.keyboard.addBinding({ key: 'Z', shortKey: true, shiftKey: true }, _this.redo.bind(_this));
  5482. if (/Win/i.test(navigator.platform)) {
  5483. _this.quill.keyboard.addBinding({ key: 'Y', shortKey: true }, _this.redo.bind(_this));
  5484. }
  5485. return _this;
  5486. }
  5487. _createClass(History, [{
  5488. key: 'change',
  5489. value: function change(source, dest) {
  5490. if (this.stack[source].length === 0) return;
  5491. var delta = this.stack[source].pop();
  5492. this.stack[dest].push(delta);
  5493. this.lastRecorded = 0;
  5494. this.ignoreChange = true;
  5495. this.quill.updateContents(delta[source], _quill2.default.sources.USER);
  5496. this.ignoreChange = false;
  5497. var index = getLastChangeIndex(delta[source]);
  5498. this.quill.setSelection(index);
  5499. }
  5500. }, {
  5501. key: 'clear',
  5502. value: function clear() {
  5503. this.stack = { undo: [], redo: [] };
  5504. }
  5505. }, {
  5506. key: 'cutoff',
  5507. value: function cutoff() {
  5508. this.lastRecorded = 0;
  5509. }
  5510. }, {
  5511. key: 'record',
  5512. value: function record(changeDelta, oldDelta) {
  5513. if (changeDelta.ops.length === 0) return;
  5514. this.stack.redo = [];
  5515. var undoDelta = this.quill.getContents().diff(oldDelta);
  5516. var timestamp = Date.now();
  5517. if (this.lastRecorded + this.options.delay > timestamp && this.stack.undo.length > 0) {
  5518. var delta = this.stack.undo.pop();
  5519. undoDelta = undoDelta.compose(delta.undo);
  5520. changeDelta = delta.redo.compose(changeDelta);
  5521. } else {
  5522. this.lastRecorded = timestamp;
  5523. }
  5524. this.stack.undo.push({
  5525. redo: changeDelta,
  5526. undo: undoDelta
  5527. });
  5528. if (this.stack.undo.length > this.options.maxStack) {
  5529. this.stack.undo.shift();
  5530. }
  5531. }
  5532. }, {
  5533. key: 'redo',
  5534. value: function redo() {
  5535. this.change('redo', 'undo');
  5536. }
  5537. }, {
  5538. key: 'transform',
  5539. value: function transform(delta) {
  5540. this.stack.undo.forEach(function (change) {
  5541. change.undo = delta.transform(change.undo, true);
  5542. change.redo = delta.transform(change.redo, true);
  5543. });
  5544. this.stack.redo.forEach(function (change) {
  5545. change.undo = delta.transform(change.undo, true);
  5546. change.redo = delta.transform(change.redo, true);
  5547. });
  5548. }
  5549. }, {
  5550. key: 'undo',
  5551. value: function undo() {
  5552. this.change('undo', 'redo');
  5553. }
  5554. }]);
  5555. return History;
  5556. }(_module2.default);
  5557. History.DEFAULTS = {
  5558. delay: 1000,
  5559. maxStack: 100,
  5560. userOnly: false
  5561. };
  5562. function endsWithNewlineChange(delta) {
  5563. var lastOp = delta.ops[delta.ops.length - 1];
  5564. if (lastOp == null) return false;
  5565. if (lastOp.insert != null) {
  5566. return typeof lastOp.insert === 'string' && lastOp.insert.endsWith('\n');
  5567. }
  5568. if (lastOp.attributes != null) {
  5569. return Object.keys(lastOp.attributes).some(function (attr) {
  5570. return _parchment2.default.query(attr, _parchment2.default.Scope.BLOCK) != null;
  5571. });
  5572. }
  5573. return false;
  5574. }
  5575. function getLastChangeIndex(delta) {
  5576. var deleteLength = delta.reduce(function (length, op) {
  5577. length += op.delete || 0;
  5578. return length;
  5579. }, 0);
  5580. var changeIndex = delta.length() - deleteLength;
  5581. if (endsWithNewlineChange(delta)) {
  5582. changeIndex -= 1;
  5583. }
  5584. return changeIndex;
  5585. }
  5586. exports.default = History;
  5587. exports.getLastChangeIndex = getLastChangeIndex;
  5588. /***/ }),
  5589. /* 43 */
  5590. /***/ (function(module, exports, __webpack_require__) {
  5591. "use strict";
  5592. Object.defineProperty(exports, "__esModule", {
  5593. value: true
  5594. });
  5595. exports.default = exports.BaseTooltip = undefined;
  5596. 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; }; }();
  5597. 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); } };
  5598. var _extend = __webpack_require__(3);
  5599. var _extend2 = _interopRequireDefault(_extend);
  5600. var _quillDelta = __webpack_require__(2);
  5601. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  5602. var _emitter = __webpack_require__(8);
  5603. var _emitter2 = _interopRequireDefault(_emitter);
  5604. var _keyboard = __webpack_require__(34);
  5605. var _keyboard2 = _interopRequireDefault(_keyboard);
  5606. var _theme = __webpack_require__(33);
  5607. var _theme2 = _interopRequireDefault(_theme);
  5608. var _colorPicker = __webpack_require__(59);
  5609. var _colorPicker2 = _interopRequireDefault(_colorPicker);
  5610. var _iconPicker = __webpack_require__(60);
  5611. var _iconPicker2 = _interopRequireDefault(_iconPicker);
  5612. var _picker = __webpack_require__(27);
  5613. var _picker2 = _interopRequireDefault(_picker);
  5614. var _tooltip = __webpack_require__(61);
  5615. var _tooltip2 = _interopRequireDefault(_tooltip);
  5616. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5617. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5618. 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; }
  5619. 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; }
  5620. var ALIGNS = [false, 'center', 'right', 'justify'];
  5621. var COLORS = ["#000000", "#e60000", "#ff9900", "#ffff00", "#008a00", "#0066cc", "#9933ff", "#ffffff", "#facccc", "#ffebcc", "#ffffcc", "#cce8cc", "#cce0f5", "#ebd6ff", "#bbbbbb", "#f06666", "#ffc266", "#ffff66", "#66b966", "#66a3e0", "#c285ff", "#888888", "#a10000", "#b26b00", "#b2b200", "#006100", "#0047b2", "#6b24b2", "#444444", "#5c0000", "#663d00", "#666600", "#003700", "#002966", "#3d1466"];
  5622. var FONTS = [false, 'serif', 'monospace'];
  5623. var HEADERS = ['1', '2', '3', false];
  5624. var SIZES = ['small', false, 'large', 'huge'];
  5625. var BaseTheme = function (_Theme) {
  5626. _inherits(BaseTheme, _Theme);
  5627. function BaseTheme(quill, options) {
  5628. _classCallCheck(this, BaseTheme);
  5629. var _this = _possibleConstructorReturn(this, (BaseTheme.__proto__ || Object.getPrototypeOf(BaseTheme)).call(this, quill, options));
  5630. var listener = function listener(e) {
  5631. if (!document.body.contains(quill.root)) {
  5632. return document.body.removeEventListener('click', listener);
  5633. }
  5634. if (_this.tooltip != null && !_this.tooltip.root.contains(e.target) && document.activeElement !== _this.tooltip.textbox && !_this.quill.hasFocus()) {
  5635. _this.tooltip.hide();
  5636. }
  5637. if (_this.pickers != null) {
  5638. _this.pickers.forEach(function (picker) {
  5639. if (!picker.container.contains(e.target)) {
  5640. picker.close();
  5641. }
  5642. });
  5643. }
  5644. };
  5645. quill.emitter.listenDOM('click', document.body, listener);
  5646. return _this;
  5647. }
  5648. _createClass(BaseTheme, [{
  5649. key: 'addModule',
  5650. value: function addModule(name) {
  5651. var module = _get(BaseTheme.prototype.__proto__ || Object.getPrototypeOf(BaseTheme.prototype), 'addModule', this).call(this, name);
  5652. if (name === 'toolbar') {
  5653. this.extendToolbar(module);
  5654. }
  5655. return module;
  5656. }
  5657. }, {
  5658. key: 'buildButtons',
  5659. value: function buildButtons(buttons, icons) {
  5660. buttons.forEach(function (button) {
  5661. var className = button.getAttribute('class') || '';
  5662. className.split(/\s+/).forEach(function (name) {
  5663. if (!name.startsWith('ql-')) return;
  5664. name = name.slice('ql-'.length);
  5665. if (icons[name] == null) return;
  5666. if (name === 'direction') {
  5667. button.innerHTML = icons[name][''] + icons[name]['rtl'];
  5668. } else if (typeof icons[name] === 'string') {
  5669. button.innerHTML = icons[name];
  5670. } else {
  5671. var value = button.value || '';
  5672. if (value != null && icons[name][value]) {
  5673. button.innerHTML = icons[name][value];
  5674. }
  5675. }
  5676. });
  5677. });
  5678. }
  5679. }, {
  5680. key: 'buildPickers',
  5681. value: function buildPickers(selects, icons) {
  5682. var _this2 = this;
  5683. this.pickers = selects.map(function (select) {
  5684. if (select.classList.contains('ql-align')) {
  5685. if (select.querySelector('option') == null) {
  5686. fillSelect(select, ALIGNS);
  5687. }
  5688. return new _iconPicker2.default(select, icons.align);
  5689. } else if (select.classList.contains('ql-background') || select.classList.contains('ql-color')) {
  5690. var format = select.classList.contains('ql-background') ? 'background' : 'color';
  5691. if (select.querySelector('option') == null) {
  5692. fillSelect(select, COLORS, format === 'background' ? '#ffffff' : '#000000');
  5693. }
  5694. return new _colorPicker2.default(select, icons[format]);
  5695. } else {
  5696. if (select.querySelector('option') == null) {
  5697. if (select.classList.contains('ql-font')) {
  5698. fillSelect(select, FONTS);
  5699. } else if (select.classList.contains('ql-header')) {
  5700. fillSelect(select, HEADERS);
  5701. } else if (select.classList.contains('ql-size')) {
  5702. fillSelect(select, SIZES);
  5703. }
  5704. }
  5705. return new _picker2.default(select);
  5706. }
  5707. });
  5708. var update = function update() {
  5709. _this2.pickers.forEach(function (picker) {
  5710. picker.update();
  5711. });
  5712. };
  5713. this.quill.on(_emitter2.default.events.EDITOR_CHANGE, update);
  5714. }
  5715. }]);
  5716. return BaseTheme;
  5717. }(_theme2.default);
  5718. BaseTheme.DEFAULTS = (0, _extend2.default)(true, {}, _theme2.default.DEFAULTS, {
  5719. modules: {
  5720. toolbar: {
  5721. handlers: {
  5722. formula: function formula() {
  5723. this.quill.theme.tooltip.edit('formula');
  5724. },
  5725. image: function image() {
  5726. var _this3 = this;
  5727. var fileInput = this.container.querySelector('input.ql-image[type=file]');
  5728. if (fileInput == null) {
  5729. fileInput = document.createElement('input');
  5730. fileInput.setAttribute('type', 'file');
  5731. fileInput.setAttribute('accept', 'image/png, image/gif, image/jpeg, image/bmp, image/x-icon');
  5732. fileInput.classList.add('ql-image');
  5733. fileInput.addEventListener('change', function () {
  5734. if (fileInput.files != null && fileInput.files[0] != null) {
  5735. var reader = new FileReader();
  5736. reader.onload = function (e) {
  5737. var range = _this3.quill.getSelection(true);
  5738. _this3.quill.updateContents(new _quillDelta2.default().retain(range.index).delete(range.length).insert({ image: e.target.result }), _emitter2.default.sources.USER);
  5739. _this3.quill.setSelection(range.index + 1, _emitter2.default.sources.SILENT);
  5740. fileInput.value = "";
  5741. };
  5742. reader.readAsDataURL(fileInput.files[0]);
  5743. }
  5744. });
  5745. this.container.appendChild(fileInput);
  5746. }
  5747. fileInput.click();
  5748. },
  5749. video: function video() {
  5750. this.quill.theme.tooltip.edit('video');
  5751. }
  5752. }
  5753. }
  5754. }
  5755. });
  5756. var BaseTooltip = function (_Tooltip) {
  5757. _inherits(BaseTooltip, _Tooltip);
  5758. function BaseTooltip(quill, boundsContainer) {
  5759. _classCallCheck(this, BaseTooltip);
  5760. var _this4 = _possibleConstructorReturn(this, (BaseTooltip.__proto__ || Object.getPrototypeOf(BaseTooltip)).call(this, quill, boundsContainer));
  5761. _this4.textbox = _this4.root.querySelector('input[type="text"]');
  5762. _this4.listen();
  5763. return _this4;
  5764. }
  5765. _createClass(BaseTooltip, [{
  5766. key: 'listen',
  5767. value: function listen() {
  5768. var _this5 = this;
  5769. this.textbox.addEventListener('keydown', function (event) {
  5770. if (_keyboard2.default.match(event, 'enter')) {
  5771. _this5.save();
  5772. event.preventDefault();
  5773. } else if (_keyboard2.default.match(event, 'escape')) {
  5774. _this5.cancel();
  5775. event.preventDefault();
  5776. }
  5777. });
  5778. }
  5779. }, {
  5780. key: 'cancel',
  5781. value: function cancel() {
  5782. this.hide();
  5783. }
  5784. }, {
  5785. key: 'edit',
  5786. value: function edit() {
  5787. var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'link';
  5788. var preview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5789. this.root.classList.remove('ql-hidden');
  5790. this.root.classList.add('ql-editing');
  5791. if (preview != null) {
  5792. this.textbox.value = preview;
  5793. } else if (mode !== this.root.getAttribute('data-mode')) {
  5794. this.textbox.value = '';
  5795. }
  5796. this.position(this.quill.getBounds(this.quill.selection.savedRange));
  5797. this.textbox.select();
  5798. this.textbox.setAttribute('placeholder', this.textbox.getAttribute('data-' + mode) || '');
  5799. this.root.setAttribute('data-mode', mode);
  5800. }
  5801. }, {
  5802. key: 'restoreFocus',
  5803. value: function restoreFocus() {
  5804. var scrollTop = this.quill.scrollingContainer.scrollTop;
  5805. this.quill.focus();
  5806. this.quill.scrollingContainer.scrollTop = scrollTop;
  5807. }
  5808. }, {
  5809. key: 'save',
  5810. value: function save() {
  5811. var value = this.textbox.value;
  5812. switch (this.root.getAttribute('data-mode')) {
  5813. case 'link':
  5814. {
  5815. var scrollTop = this.quill.root.scrollTop;
  5816. if (this.linkRange) {
  5817. this.quill.formatText(this.linkRange, 'link', value, _emitter2.default.sources.USER);
  5818. delete this.linkRange;
  5819. } else {
  5820. this.restoreFocus();
  5821. this.quill.format('link', value, _emitter2.default.sources.USER);
  5822. }
  5823. this.quill.root.scrollTop = scrollTop;
  5824. break;
  5825. }
  5826. case 'video':
  5827. {
  5828. value = extractVideoUrl(value);
  5829. } // eslint-disable-next-line no-fallthrough
  5830. case 'formula':
  5831. {
  5832. if (!value) break;
  5833. var range = this.quill.getSelection(true);
  5834. if (range != null) {
  5835. var index = range.index + range.length;
  5836. this.quill.insertEmbed(index, this.root.getAttribute('data-mode'), value, _emitter2.default.sources.USER);
  5837. if (this.root.getAttribute('data-mode') === 'formula') {
  5838. this.quill.insertText(index + 1, ' ', _emitter2.default.sources.USER);
  5839. }
  5840. this.quill.setSelection(index + 2, _emitter2.default.sources.USER);
  5841. }
  5842. break;
  5843. }
  5844. default:
  5845. }
  5846. this.textbox.value = '';
  5847. this.hide();
  5848. }
  5849. }]);
  5850. return BaseTooltip;
  5851. }(_tooltip2.default);
  5852. function extractVideoUrl(url) {
  5853. var match = url.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/) || url.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);
  5854. if (match) {
  5855. return (match[1] || 'https') + '://www.youtube.com/embed/' + match[2] + '?showinfo=0';
  5856. }
  5857. if (match = url.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/)) {
  5858. // eslint-disable-line no-cond-assign
  5859. return (match[1] || 'https') + '://player.vimeo.com/video/' + match[2] + '/';
  5860. }
  5861. return url;
  5862. }
  5863. function fillSelect(select, values) {
  5864. var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5865. values.forEach(function (value) {
  5866. var option = document.createElement('option');
  5867. if (value === defaultValue) {
  5868. option.setAttribute('selected', 'selected');
  5869. } else {
  5870. option.setAttribute('value', value);
  5871. }
  5872. select.appendChild(option);
  5873. });
  5874. }
  5875. exports.BaseTooltip = BaseTooltip;
  5876. exports.default = BaseTheme;
  5877. /***/ }),
  5878. /* 44 */
  5879. /***/ (function(module, exports, __webpack_require__) {
  5880. "use strict";
  5881. Object.defineProperty(exports, "__esModule", { value: true });
  5882. var LinkedList = /** @class */ (function () {
  5883. function LinkedList() {
  5884. this.head = this.tail = null;
  5885. this.length = 0;
  5886. }
  5887. LinkedList.prototype.append = function () {
  5888. var nodes = [];
  5889. for (var _i = 0; _i < arguments.length; _i++) {
  5890. nodes[_i] = arguments[_i];
  5891. }
  5892. this.insertBefore(nodes[0], null);
  5893. if (nodes.length > 1) {
  5894. this.append.apply(this, nodes.slice(1));
  5895. }
  5896. };
  5897. LinkedList.prototype.contains = function (node) {
  5898. var cur, next = this.iterator();
  5899. while ((cur = next())) {
  5900. if (cur === node)
  5901. return true;
  5902. }
  5903. return false;
  5904. };
  5905. LinkedList.prototype.insertBefore = function (node, refNode) {
  5906. if (!node)
  5907. return;
  5908. node.next = refNode;
  5909. if (refNode != null) {
  5910. node.prev = refNode.prev;
  5911. if (refNode.prev != null) {
  5912. refNode.prev.next = node;
  5913. }
  5914. refNode.prev = node;
  5915. if (refNode === this.head) {
  5916. this.head = node;
  5917. }
  5918. }
  5919. else if (this.tail != null) {
  5920. this.tail.next = node;
  5921. node.prev = this.tail;
  5922. this.tail = node;
  5923. }
  5924. else {
  5925. node.prev = null;
  5926. this.head = this.tail = node;
  5927. }
  5928. this.length += 1;
  5929. };
  5930. LinkedList.prototype.offset = function (target) {
  5931. var index = 0, cur = this.head;
  5932. while (cur != null) {
  5933. if (cur === target)
  5934. return index;
  5935. index += cur.length();
  5936. cur = cur.next;
  5937. }
  5938. return -1;
  5939. };
  5940. LinkedList.prototype.remove = function (node) {
  5941. if (!this.contains(node))
  5942. return;
  5943. if (node.prev != null)
  5944. node.prev.next = node.next;
  5945. if (node.next != null)
  5946. node.next.prev = node.prev;
  5947. if (node === this.head)
  5948. this.head = node.next;
  5949. if (node === this.tail)
  5950. this.tail = node.prev;
  5951. this.length -= 1;
  5952. };
  5953. LinkedList.prototype.iterator = function (curNode) {
  5954. if (curNode === void 0) { curNode = this.head; }
  5955. // TODO use yield when we can
  5956. return function () {
  5957. var ret = curNode;
  5958. if (curNode != null)
  5959. curNode = curNode.next;
  5960. return ret;
  5961. };
  5962. };
  5963. LinkedList.prototype.find = function (index, inclusive) {
  5964. if (inclusive === void 0) { inclusive = false; }
  5965. var cur, next = this.iterator();
  5966. while ((cur = next())) {
  5967. var length = cur.length();
  5968. if (index < length ||
  5969. (inclusive && index === length && (cur.next == null || cur.next.length() !== 0))) {
  5970. return [cur, index];
  5971. }
  5972. index -= length;
  5973. }
  5974. return [null, 0];
  5975. };
  5976. LinkedList.prototype.forEach = function (callback) {
  5977. var cur, next = this.iterator();
  5978. while ((cur = next())) {
  5979. callback(cur);
  5980. }
  5981. };
  5982. LinkedList.prototype.forEachAt = function (index, length, callback) {
  5983. if (length <= 0)
  5984. return;
  5985. var _a = this.find(index), startNode = _a[0], offset = _a[1];
  5986. var cur, curIndex = index - offset, next = this.iterator(startNode);
  5987. while ((cur = next()) && curIndex < index + length) {
  5988. var curLength = cur.length();
  5989. if (index > curIndex) {
  5990. callback(cur, index - curIndex, Math.min(length, curIndex + curLength - index));
  5991. }
  5992. else {
  5993. callback(cur, 0, Math.min(curLength, index + length - curIndex));
  5994. }
  5995. curIndex += curLength;
  5996. }
  5997. };
  5998. LinkedList.prototype.map = function (callback) {
  5999. return this.reduce(function (memo, cur) {
  6000. memo.push(callback(cur));
  6001. return memo;
  6002. }, []);
  6003. };
  6004. LinkedList.prototype.reduce = function (callback, memo) {
  6005. var cur, next = this.iterator();
  6006. while ((cur = next())) {
  6007. memo = callback(memo, cur);
  6008. }
  6009. return memo;
  6010. };
  6011. return LinkedList;
  6012. }());
  6013. exports.default = LinkedList;
  6014. /***/ }),
  6015. /* 45 */
  6016. /***/ (function(module, exports, __webpack_require__) {
  6017. "use strict";
  6018. var __extends = (this && this.__extends) || (function () {
  6019. var extendStatics = Object.setPrototypeOf ||
  6020. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6021. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6022. return function (d, b) {
  6023. extendStatics(d, b);
  6024. function __() { this.constructor = d; }
  6025. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6026. };
  6027. })();
  6028. Object.defineProperty(exports, "__esModule", { value: true });
  6029. var container_1 = __webpack_require__(17);
  6030. var Registry = __webpack_require__(1);
  6031. var OBSERVER_CONFIG = {
  6032. attributes: true,
  6033. characterData: true,
  6034. characterDataOldValue: true,
  6035. childList: true,
  6036. subtree: true,
  6037. };
  6038. var MAX_OPTIMIZE_ITERATIONS = 100;
  6039. var ScrollBlot = /** @class */ (function (_super) {
  6040. __extends(ScrollBlot, _super);
  6041. function ScrollBlot(node) {
  6042. var _this = _super.call(this, node) || this;
  6043. _this.scroll = _this;
  6044. _this.observer = new MutationObserver(function (mutations) {
  6045. _this.update(mutations);
  6046. });
  6047. _this.observer.observe(_this.domNode, OBSERVER_CONFIG);
  6048. _this.attach();
  6049. return _this;
  6050. }
  6051. ScrollBlot.prototype.detach = function () {
  6052. _super.prototype.detach.call(this);
  6053. this.observer.disconnect();
  6054. };
  6055. ScrollBlot.prototype.deleteAt = function (index, length) {
  6056. this.update();
  6057. if (index === 0 && length === this.length()) {
  6058. this.children.forEach(function (child) {
  6059. child.remove();
  6060. });
  6061. }
  6062. else {
  6063. _super.prototype.deleteAt.call(this, index, length);
  6064. }
  6065. };
  6066. ScrollBlot.prototype.formatAt = function (index, length, name, value) {
  6067. this.update();
  6068. _super.prototype.formatAt.call(this, index, length, name, value);
  6069. };
  6070. ScrollBlot.prototype.insertAt = function (index, value, def) {
  6071. this.update();
  6072. _super.prototype.insertAt.call(this, index, value, def);
  6073. };
  6074. ScrollBlot.prototype.optimize = function (mutations, context) {
  6075. var _this = this;
  6076. if (mutations === void 0) { mutations = []; }
  6077. if (context === void 0) { context = {}; }
  6078. _super.prototype.optimize.call(this, context);
  6079. // We must modify mutations directly, cannot make copy and then modify
  6080. var records = [].slice.call(this.observer.takeRecords());
  6081. // Array.push currently seems to be implemented by a non-tail recursive function
  6082. // so we cannot just mutations.push.apply(mutations, this.observer.takeRecords());
  6083. while (records.length > 0)
  6084. mutations.push(records.pop());
  6085. // TODO use WeakMap
  6086. var mark = function (blot, markParent) {
  6087. if (markParent === void 0) { markParent = true; }
  6088. if (blot == null || blot === _this)
  6089. return;
  6090. if (blot.domNode.parentNode == null)
  6091. return;
  6092. // @ts-ignore
  6093. if (blot.domNode[Registry.DATA_KEY].mutations == null) {
  6094. // @ts-ignore
  6095. blot.domNode[Registry.DATA_KEY].mutations = [];
  6096. }
  6097. if (markParent)
  6098. mark(blot.parent);
  6099. };
  6100. var optimize = function (blot) {
  6101. // Post-order traversal
  6102. if (
  6103. // @ts-ignore
  6104. blot.domNode[Registry.DATA_KEY] == null ||
  6105. // @ts-ignore
  6106. blot.domNode[Registry.DATA_KEY].mutations == null) {
  6107. return;
  6108. }
  6109. if (blot instanceof container_1.default) {
  6110. blot.children.forEach(optimize);
  6111. }
  6112. blot.optimize(context);
  6113. };
  6114. var remaining = mutations;
  6115. for (var i = 0; remaining.length > 0; i += 1) {
  6116. if (i >= MAX_OPTIMIZE_ITERATIONS) {
  6117. throw new Error('[Parchment] Maximum optimize iterations reached');
  6118. }
  6119. remaining.forEach(function (mutation) {
  6120. var blot = Registry.find(mutation.target, true);
  6121. if (blot == null)
  6122. return;
  6123. if (blot.domNode === mutation.target) {
  6124. if (mutation.type === 'childList') {
  6125. mark(Registry.find(mutation.previousSibling, false));
  6126. [].forEach.call(mutation.addedNodes, function (node) {
  6127. var child = Registry.find(node, false);
  6128. mark(child, false);
  6129. if (child instanceof container_1.default) {
  6130. child.children.forEach(function (grandChild) {
  6131. mark(grandChild, false);
  6132. });
  6133. }
  6134. });
  6135. }
  6136. else if (mutation.type === 'attributes') {
  6137. mark(blot.prev);
  6138. }
  6139. }
  6140. mark(blot);
  6141. });
  6142. this.children.forEach(optimize);
  6143. remaining = [].slice.call(this.observer.takeRecords());
  6144. records = remaining.slice();
  6145. while (records.length > 0)
  6146. mutations.push(records.pop());
  6147. }
  6148. };
  6149. ScrollBlot.prototype.update = function (mutations, context) {
  6150. var _this = this;
  6151. if (context === void 0) { context = {}; }
  6152. mutations = mutations || this.observer.takeRecords();
  6153. // TODO use WeakMap
  6154. mutations
  6155. .map(function (mutation) {
  6156. var blot = Registry.find(mutation.target, true);
  6157. if (blot == null)
  6158. return null;
  6159. // @ts-ignore
  6160. if (blot.domNode[Registry.DATA_KEY].mutations == null) {
  6161. // @ts-ignore
  6162. blot.domNode[Registry.DATA_KEY].mutations = [mutation];
  6163. return blot;
  6164. }
  6165. else {
  6166. // @ts-ignore
  6167. blot.domNode[Registry.DATA_KEY].mutations.push(mutation);
  6168. return null;
  6169. }
  6170. })
  6171. .forEach(function (blot) {
  6172. // @ts-ignore
  6173. if (blot == null || blot === _this || blot.domNode[Registry.DATA_KEY] == null)
  6174. return;
  6175. // @ts-ignore
  6176. blot.update(blot.domNode[Registry.DATA_KEY].mutations || [], context);
  6177. });
  6178. // @ts-ignore
  6179. if (this.domNode[Registry.DATA_KEY].mutations != null) {
  6180. // @ts-ignore
  6181. _super.prototype.update.call(this, this.domNode[Registry.DATA_KEY].mutations, context);
  6182. }
  6183. this.optimize(mutations, context);
  6184. };
  6185. ScrollBlot.blotName = 'scroll';
  6186. ScrollBlot.defaultChild = 'block';
  6187. ScrollBlot.scope = Registry.Scope.BLOCK_BLOT;
  6188. ScrollBlot.tagName = 'DIV';
  6189. return ScrollBlot;
  6190. }(container_1.default));
  6191. exports.default = ScrollBlot;
  6192. /***/ }),
  6193. /* 46 */
  6194. /***/ (function(module, exports, __webpack_require__) {
  6195. "use strict";
  6196. var __extends = (this && this.__extends) || (function () {
  6197. var extendStatics = Object.setPrototypeOf ||
  6198. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6199. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6200. return function (d, b) {
  6201. extendStatics(d, b);
  6202. function __() { this.constructor = d; }
  6203. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6204. };
  6205. })();
  6206. Object.defineProperty(exports, "__esModule", { value: true });
  6207. var format_1 = __webpack_require__(18);
  6208. var Registry = __webpack_require__(1);
  6209. // Shallow object comparison
  6210. function isEqual(obj1, obj2) {
  6211. if (Object.keys(obj1).length !== Object.keys(obj2).length)
  6212. return false;
  6213. // @ts-ignore
  6214. for (var prop in obj1) {
  6215. // @ts-ignore
  6216. if (obj1[prop] !== obj2[prop])
  6217. return false;
  6218. }
  6219. return true;
  6220. }
  6221. var InlineBlot = /** @class */ (function (_super) {
  6222. __extends(InlineBlot, _super);
  6223. function InlineBlot() {
  6224. return _super !== null && _super.apply(this, arguments) || this;
  6225. }
  6226. InlineBlot.formats = function (domNode) {
  6227. if (domNode.tagName === InlineBlot.tagName)
  6228. return undefined;
  6229. return _super.formats.call(this, domNode);
  6230. };
  6231. InlineBlot.prototype.format = function (name, value) {
  6232. var _this = this;
  6233. if (name === this.statics.blotName && !value) {
  6234. this.children.forEach(function (child) {
  6235. if (!(child instanceof format_1.default)) {
  6236. child = child.wrap(InlineBlot.blotName, true);
  6237. }
  6238. _this.attributes.copy(child);
  6239. });
  6240. this.unwrap();
  6241. }
  6242. else {
  6243. _super.prototype.format.call(this, name, value);
  6244. }
  6245. };
  6246. InlineBlot.prototype.formatAt = function (index, length, name, value) {
  6247. if (this.formats()[name] != null || Registry.query(name, Registry.Scope.ATTRIBUTE)) {
  6248. var blot = this.isolate(index, length);
  6249. blot.format(name, value);
  6250. }
  6251. else {
  6252. _super.prototype.formatAt.call(this, index, length, name, value);
  6253. }
  6254. };
  6255. InlineBlot.prototype.optimize = function (context) {
  6256. _super.prototype.optimize.call(this, context);
  6257. var formats = this.formats();
  6258. if (Object.keys(formats).length === 0) {
  6259. return this.unwrap(); // unformatted span
  6260. }
  6261. var next = this.next;
  6262. if (next instanceof InlineBlot && next.prev === this && isEqual(formats, next.formats())) {
  6263. next.moveChildren(this);
  6264. next.remove();
  6265. }
  6266. };
  6267. InlineBlot.blotName = 'inline';
  6268. InlineBlot.scope = Registry.Scope.INLINE_BLOT;
  6269. InlineBlot.tagName = 'SPAN';
  6270. return InlineBlot;
  6271. }(format_1.default));
  6272. exports.default = InlineBlot;
  6273. /***/ }),
  6274. /* 47 */
  6275. /***/ (function(module, exports, __webpack_require__) {
  6276. "use strict";
  6277. var __extends = (this && this.__extends) || (function () {
  6278. var extendStatics = Object.setPrototypeOf ||
  6279. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6280. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6281. return function (d, b) {
  6282. extendStatics(d, b);
  6283. function __() { this.constructor = d; }
  6284. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6285. };
  6286. })();
  6287. Object.defineProperty(exports, "__esModule", { value: true });
  6288. var format_1 = __webpack_require__(18);
  6289. var Registry = __webpack_require__(1);
  6290. var BlockBlot = /** @class */ (function (_super) {
  6291. __extends(BlockBlot, _super);
  6292. function BlockBlot() {
  6293. return _super !== null && _super.apply(this, arguments) || this;
  6294. }
  6295. BlockBlot.formats = function (domNode) {
  6296. var tagName = Registry.query(BlockBlot.blotName).tagName;
  6297. if (domNode.tagName === tagName)
  6298. return undefined;
  6299. return _super.formats.call(this, domNode);
  6300. };
  6301. BlockBlot.prototype.format = function (name, value) {
  6302. if (Registry.query(name, Registry.Scope.BLOCK) == null) {
  6303. return;
  6304. }
  6305. else if (name === this.statics.blotName && !value) {
  6306. this.replaceWith(BlockBlot.blotName);
  6307. }
  6308. else {
  6309. _super.prototype.format.call(this, name, value);
  6310. }
  6311. };
  6312. BlockBlot.prototype.formatAt = function (index, length, name, value) {
  6313. if (Registry.query(name, Registry.Scope.BLOCK) != null) {
  6314. this.format(name, value);
  6315. }
  6316. else {
  6317. _super.prototype.formatAt.call(this, index, length, name, value);
  6318. }
  6319. };
  6320. BlockBlot.prototype.insertAt = function (index, value, def) {
  6321. if (def == null || Registry.query(value, Registry.Scope.INLINE) != null) {
  6322. // Insert text or inline
  6323. _super.prototype.insertAt.call(this, index, value, def);
  6324. }
  6325. else {
  6326. var after = this.split(index);
  6327. var blot = Registry.create(value, def);
  6328. after.parent.insertBefore(blot, after);
  6329. }
  6330. };
  6331. BlockBlot.prototype.update = function (mutations, context) {
  6332. if (navigator.userAgent.match(/Trident/)) {
  6333. this.build();
  6334. }
  6335. else {
  6336. _super.prototype.update.call(this, mutations, context);
  6337. }
  6338. };
  6339. BlockBlot.blotName = 'block';
  6340. BlockBlot.scope = Registry.Scope.BLOCK_BLOT;
  6341. BlockBlot.tagName = 'P';
  6342. return BlockBlot;
  6343. }(format_1.default));
  6344. exports.default = BlockBlot;
  6345. /***/ }),
  6346. /* 48 */
  6347. /***/ (function(module, exports, __webpack_require__) {
  6348. "use strict";
  6349. var __extends = (this && this.__extends) || (function () {
  6350. var extendStatics = Object.setPrototypeOf ||
  6351. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6352. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6353. return function (d, b) {
  6354. extendStatics(d, b);
  6355. function __() { this.constructor = d; }
  6356. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6357. };
  6358. })();
  6359. Object.defineProperty(exports, "__esModule", { value: true });
  6360. var leaf_1 = __webpack_require__(19);
  6361. var EmbedBlot = /** @class */ (function (_super) {
  6362. __extends(EmbedBlot, _super);
  6363. function EmbedBlot() {
  6364. return _super !== null && _super.apply(this, arguments) || this;
  6365. }
  6366. EmbedBlot.formats = function (domNode) {
  6367. return undefined;
  6368. };
  6369. EmbedBlot.prototype.format = function (name, value) {
  6370. // super.formatAt wraps, which is what we want in general,
  6371. // but this allows subclasses to overwrite for formats
  6372. // that just apply to particular embeds
  6373. _super.prototype.formatAt.call(this, 0, this.length(), name, value);
  6374. };
  6375. EmbedBlot.prototype.formatAt = function (index, length, name, value) {
  6376. if (index === 0 && length === this.length()) {
  6377. this.format(name, value);
  6378. }
  6379. else {
  6380. _super.prototype.formatAt.call(this, index, length, name, value);
  6381. }
  6382. };
  6383. EmbedBlot.prototype.formats = function () {
  6384. return this.statics.formats(this.domNode);
  6385. };
  6386. return EmbedBlot;
  6387. }(leaf_1.default));
  6388. exports.default = EmbedBlot;
  6389. /***/ }),
  6390. /* 49 */
  6391. /***/ (function(module, exports, __webpack_require__) {
  6392. "use strict";
  6393. var __extends = (this && this.__extends) || (function () {
  6394. var extendStatics = Object.setPrototypeOf ||
  6395. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6396. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6397. return function (d, b) {
  6398. extendStatics(d, b);
  6399. function __() { this.constructor = d; }
  6400. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6401. };
  6402. })();
  6403. Object.defineProperty(exports, "__esModule", { value: true });
  6404. var leaf_1 = __webpack_require__(19);
  6405. var Registry = __webpack_require__(1);
  6406. var TextBlot = /** @class */ (function (_super) {
  6407. __extends(TextBlot, _super);
  6408. function TextBlot(node) {
  6409. var _this = _super.call(this, node) || this;
  6410. _this.text = _this.statics.value(_this.domNode);
  6411. return _this;
  6412. }
  6413. TextBlot.create = function (value) {
  6414. return document.createTextNode(value);
  6415. };
  6416. TextBlot.value = function (domNode) {
  6417. var text = domNode.data;
  6418. // @ts-ignore
  6419. if (text['normalize'])
  6420. text = text['normalize']();
  6421. return text;
  6422. };
  6423. TextBlot.prototype.deleteAt = function (index, length) {
  6424. this.domNode.data = this.text = this.text.slice(0, index) + this.text.slice(index + length);
  6425. };
  6426. TextBlot.prototype.index = function (node, offset) {
  6427. if (this.domNode === node) {
  6428. return offset;
  6429. }
  6430. return -1;
  6431. };
  6432. TextBlot.prototype.insertAt = function (index, value, def) {
  6433. if (def == null) {
  6434. this.text = this.text.slice(0, index) + value + this.text.slice(index);
  6435. this.domNode.data = this.text;
  6436. }
  6437. else {
  6438. _super.prototype.insertAt.call(this, index, value, def);
  6439. }
  6440. };
  6441. TextBlot.prototype.length = function () {
  6442. return this.text.length;
  6443. };
  6444. TextBlot.prototype.optimize = function (context) {
  6445. _super.prototype.optimize.call(this, context);
  6446. this.text = this.statics.value(this.domNode);
  6447. if (this.text.length === 0) {
  6448. this.remove();
  6449. }
  6450. else if (this.next instanceof TextBlot && this.next.prev === this) {
  6451. this.insertAt(this.length(), this.next.value());
  6452. this.next.remove();
  6453. }
  6454. };
  6455. TextBlot.prototype.position = function (index, inclusive) {
  6456. if (inclusive === void 0) { inclusive = false; }
  6457. return [this.domNode, index];
  6458. };
  6459. TextBlot.prototype.split = function (index, force) {
  6460. if (force === void 0) { force = false; }
  6461. if (!force) {
  6462. if (index === 0)
  6463. return this;
  6464. if (index === this.length())
  6465. return this.next;
  6466. }
  6467. var after = Registry.create(this.domNode.splitText(index));
  6468. this.parent.insertBefore(after, this.next);
  6469. this.text = this.statics.value(this.domNode);
  6470. return after;
  6471. };
  6472. TextBlot.prototype.update = function (mutations, context) {
  6473. var _this = this;
  6474. if (mutations.some(function (mutation) {
  6475. return mutation.type === 'characterData' && mutation.target === _this.domNode;
  6476. })) {
  6477. this.text = this.statics.value(this.domNode);
  6478. }
  6479. };
  6480. TextBlot.prototype.value = function () {
  6481. return this.text;
  6482. };
  6483. TextBlot.blotName = 'text';
  6484. TextBlot.scope = Registry.Scope.INLINE_BLOT;
  6485. return TextBlot;
  6486. }(leaf_1.default));
  6487. exports.default = TextBlot;
  6488. /***/ }),
  6489. /* 50 */
  6490. /***/ (function(module, exports, __webpack_require__) {
  6491. "use strict";
  6492. var elem = document.createElement('div');
  6493. elem.classList.toggle('test-class', false);
  6494. if (elem.classList.contains('test-class')) {
  6495. var _toggle = DOMTokenList.prototype.toggle;
  6496. DOMTokenList.prototype.toggle = function (token, force) {
  6497. if (arguments.length > 1 && !this.contains(token) === !force) {
  6498. return force;
  6499. } else {
  6500. return _toggle.call(this, token);
  6501. }
  6502. };
  6503. }
  6504. if (!String.prototype.startsWith) {
  6505. String.prototype.startsWith = function (searchString, position) {
  6506. position = position || 0;
  6507. return this.substr(position, searchString.length) === searchString;
  6508. };
  6509. }
  6510. if (!String.prototype.endsWith) {
  6511. String.prototype.endsWith = function (searchString, position) {
  6512. var subjectString = this.toString();
  6513. if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
  6514. position = subjectString.length;
  6515. }
  6516. position -= searchString.length;
  6517. var lastIndex = subjectString.indexOf(searchString, position);
  6518. return lastIndex !== -1 && lastIndex === position;
  6519. };
  6520. }
  6521. if (!Array.prototype.find) {
  6522. Object.defineProperty(Array.prototype, "find", {
  6523. value: function value(predicate) {
  6524. if (this === null) {
  6525. throw new TypeError('Array.prototype.find called on null or undefined');
  6526. }
  6527. if (typeof predicate !== 'function') {
  6528. throw new TypeError('predicate must be a function');
  6529. }
  6530. var list = Object(this);
  6531. var length = list.length >>> 0;
  6532. var thisArg = arguments[1];
  6533. var value;
  6534. for (var i = 0; i < length; i++) {
  6535. value = list[i];
  6536. if (predicate.call(thisArg, value, i, list)) {
  6537. return value;
  6538. }
  6539. }
  6540. return undefined;
  6541. }
  6542. });
  6543. }
  6544. document.addEventListener("DOMContentLoaded", function () {
  6545. // Disable resizing in Firefox
  6546. document.execCommand("enableObjectResizing", false, false);
  6547. // Disable automatic linkifying in IE11
  6548. document.execCommand("autoUrlDetect", false, false);
  6549. });
  6550. /***/ }),
  6551. /* 51 */
  6552. /***/ (function(module, exports) {
  6553. /**
  6554. * This library modifies the diff-patch-match library by Neil Fraser
  6555. * by removing the patch and match functionality and certain advanced
  6556. * options in the diff function. The original license is as follows:
  6557. *
  6558. * ===
  6559. *
  6560. * Diff Match and Patch
  6561. *
  6562. * Copyright 2006 Google Inc.
  6563. * http://code.google.com/p/google-diff-match-patch/
  6564. *
  6565. * Licensed under the Apache License, Version 2.0 (the "License");
  6566. * you may not use this file except in compliance with the License.
  6567. * You may obtain a copy of the License at
  6568. *
  6569. * http://www.apache.org/licenses/LICENSE-2.0
  6570. *
  6571. * Unless required by applicable law or agreed to in writing, software
  6572. * distributed under the License is distributed on an "AS IS" BASIS,
  6573. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  6574. * See the License for the specific language governing permissions and
  6575. * limitations under the License.
  6576. */
  6577. /**
  6578. * The data structure representing a diff is an array of tuples:
  6579. * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
  6580. * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
  6581. */
  6582. var DIFF_DELETE = -1;
  6583. var DIFF_INSERT = 1;
  6584. var DIFF_EQUAL = 0;
  6585. /**
  6586. * Find the differences between two texts. Simplifies the problem by stripping
  6587. * any common prefix or suffix off the texts before diffing.
  6588. * @param {string} text1 Old string to be diffed.
  6589. * @param {string} text2 New string to be diffed.
  6590. * @param {Int} cursor_pos Expected edit position in text1 (optional)
  6591. * @return {Array} Array of diff tuples.
  6592. */
  6593. function diff_main(text1, text2, cursor_pos) {
  6594. // Check for equality (speedup).
  6595. if (text1 == text2) {
  6596. if (text1) {
  6597. return [[DIFF_EQUAL, text1]];
  6598. }
  6599. return [];
  6600. }
  6601. // Check cursor_pos within bounds
  6602. if (cursor_pos < 0 || text1.length < cursor_pos) {
  6603. cursor_pos = null;
  6604. }
  6605. // Trim off common prefix (speedup).
  6606. var commonlength = diff_commonPrefix(text1, text2);
  6607. var commonprefix = text1.substring(0, commonlength);
  6608. text1 = text1.substring(commonlength);
  6609. text2 = text2.substring(commonlength);
  6610. // Trim off common suffix (speedup).
  6611. commonlength = diff_commonSuffix(text1, text2);
  6612. var commonsuffix = text1.substring(text1.length - commonlength);
  6613. text1 = text1.substring(0, text1.length - commonlength);
  6614. text2 = text2.substring(0, text2.length - commonlength);
  6615. // Compute the diff on the middle block.
  6616. var diffs = diff_compute_(text1, text2);
  6617. // Restore the prefix and suffix.
  6618. if (commonprefix) {
  6619. diffs.unshift([DIFF_EQUAL, commonprefix]);
  6620. }
  6621. if (commonsuffix) {
  6622. diffs.push([DIFF_EQUAL, commonsuffix]);
  6623. }
  6624. diff_cleanupMerge(diffs);
  6625. if (cursor_pos != null) {
  6626. diffs = fix_cursor(diffs, cursor_pos);
  6627. }
  6628. diffs = fix_emoji(diffs);
  6629. return diffs;
  6630. };
  6631. /**
  6632. * Find the differences between two texts. Assumes that the texts do not
  6633. * have any common prefix or suffix.
  6634. * @param {string} text1 Old string to be diffed.
  6635. * @param {string} text2 New string to be diffed.
  6636. * @return {Array} Array of diff tuples.
  6637. */
  6638. function diff_compute_(text1, text2) {
  6639. var diffs;
  6640. if (!text1) {
  6641. // Just add some text (speedup).
  6642. return [[DIFF_INSERT, text2]];
  6643. }
  6644. if (!text2) {
  6645. // Just delete some text (speedup).
  6646. return [[DIFF_DELETE, text1]];
  6647. }
  6648. var longtext = text1.length > text2.length ? text1 : text2;
  6649. var shorttext = text1.length > text2.length ? text2 : text1;
  6650. var i = longtext.indexOf(shorttext);
  6651. if (i != -1) {
  6652. // Shorter text is inside the longer text (speedup).
  6653. diffs = [[DIFF_INSERT, longtext.substring(0, i)],
  6654. [DIFF_EQUAL, shorttext],
  6655. [DIFF_INSERT, longtext.substring(i + shorttext.length)]];
  6656. // Swap insertions for deletions if diff is reversed.
  6657. if (text1.length > text2.length) {
  6658. diffs[0][0] = diffs[2][0] = DIFF_DELETE;
  6659. }
  6660. return diffs;
  6661. }
  6662. if (shorttext.length == 1) {
  6663. // Single character string.
  6664. // After the previous speedup, the character can't be an equality.
  6665. return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
  6666. }
  6667. // Check to see if the problem can be split in two.
  6668. var hm = diff_halfMatch_(text1, text2);
  6669. if (hm) {
  6670. // A half-match was found, sort out the return data.
  6671. var text1_a = hm[0];
  6672. var text1_b = hm[1];
  6673. var text2_a = hm[2];
  6674. var text2_b = hm[3];
  6675. var mid_common = hm[4];
  6676. // Send both pairs off for separate processing.
  6677. var diffs_a = diff_main(text1_a, text2_a);
  6678. var diffs_b = diff_main(text1_b, text2_b);
  6679. // Merge the results.
  6680. return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b);
  6681. }
  6682. return diff_bisect_(text1, text2);
  6683. };
  6684. /**
  6685. * Find the 'middle snake' of a diff, split the problem in two
  6686. * and return the recursively constructed diff.
  6687. * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
  6688. * @param {string} text1 Old string to be diffed.
  6689. * @param {string} text2 New string to be diffed.
  6690. * @return {Array} Array of diff tuples.
  6691. * @private
  6692. */
  6693. function diff_bisect_(text1, text2) {
  6694. // Cache the text lengths to prevent multiple calls.
  6695. var text1_length = text1.length;
  6696. var text2_length = text2.length;
  6697. var max_d = Math.ceil((text1_length + text2_length) / 2);
  6698. var v_offset = max_d;
  6699. var v_length = 2 * max_d;
  6700. var v1 = new Array(v_length);
  6701. var v2 = new Array(v_length);
  6702. // Setting all elements to -1 is faster in Chrome & Firefox than mixing
  6703. // integers and undefined.
  6704. for (var x = 0; x < v_length; x++) {
  6705. v1[x] = -1;
  6706. v2[x] = -1;
  6707. }
  6708. v1[v_offset + 1] = 0;
  6709. v2[v_offset + 1] = 0;
  6710. var delta = text1_length - text2_length;
  6711. // If the total number of characters is odd, then the front path will collide
  6712. // with the reverse path.
  6713. var front = (delta % 2 != 0);
  6714. // Offsets for start and end of k loop.
  6715. // Prevents mapping of space beyond the grid.
  6716. var k1start = 0;
  6717. var k1end = 0;
  6718. var k2start = 0;
  6719. var k2end = 0;
  6720. for (var d = 0; d < max_d; d++) {
  6721. // Walk the front path one step.
  6722. for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
  6723. var k1_offset = v_offset + k1;
  6724. var x1;
  6725. if (k1 == -d || (k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1])) {
  6726. x1 = v1[k1_offset + 1];
  6727. } else {
  6728. x1 = v1[k1_offset - 1] + 1;
  6729. }
  6730. var y1 = x1 - k1;
  6731. while (x1 < text1_length && y1 < text2_length &&
  6732. text1.charAt(x1) == text2.charAt(y1)) {
  6733. x1++;
  6734. y1++;
  6735. }
  6736. v1[k1_offset] = x1;
  6737. if (x1 > text1_length) {
  6738. // Ran off the right of the graph.
  6739. k1end += 2;
  6740. } else if (y1 > text2_length) {
  6741. // Ran off the bottom of the graph.
  6742. k1start += 2;
  6743. } else if (front) {
  6744. var k2_offset = v_offset + delta - k1;
  6745. if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] != -1) {
  6746. // Mirror x2 onto top-left coordinate system.
  6747. var x2 = text1_length - v2[k2_offset];
  6748. if (x1 >= x2) {
  6749. // Overlap detected.
  6750. return diff_bisectSplit_(text1, text2, x1, y1);
  6751. }
  6752. }
  6753. }
  6754. }
  6755. // Walk the reverse path one step.
  6756. for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
  6757. var k2_offset = v_offset + k2;
  6758. var x2;
  6759. if (k2 == -d || (k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1])) {
  6760. x2 = v2[k2_offset + 1];
  6761. } else {
  6762. x2 = v2[k2_offset - 1] + 1;
  6763. }
  6764. var y2 = x2 - k2;
  6765. while (x2 < text1_length && y2 < text2_length &&
  6766. text1.charAt(text1_length - x2 - 1) ==
  6767. text2.charAt(text2_length - y2 - 1)) {
  6768. x2++;
  6769. y2++;
  6770. }
  6771. v2[k2_offset] = x2;
  6772. if (x2 > text1_length) {
  6773. // Ran off the left of the graph.
  6774. k2end += 2;
  6775. } else if (y2 > text2_length) {
  6776. // Ran off the top of the graph.
  6777. k2start += 2;
  6778. } else if (!front) {
  6779. var k1_offset = v_offset + delta - k2;
  6780. if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] != -1) {
  6781. var x1 = v1[k1_offset];
  6782. var y1 = v_offset + x1 - k1_offset;
  6783. // Mirror x2 onto top-left coordinate system.
  6784. x2 = text1_length - x2;
  6785. if (x1 >= x2) {
  6786. // Overlap detected.
  6787. return diff_bisectSplit_(text1, text2, x1, y1);
  6788. }
  6789. }
  6790. }
  6791. }
  6792. }
  6793. // Diff took too long and hit the deadline or
  6794. // number of diffs equals number of characters, no commonality at all.
  6795. return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
  6796. };
  6797. /**
  6798. * Given the location of the 'middle snake', split the diff in two parts
  6799. * and recurse.
  6800. * @param {string} text1 Old string to be diffed.
  6801. * @param {string} text2 New string to be diffed.
  6802. * @param {number} x Index of split point in text1.
  6803. * @param {number} y Index of split point in text2.
  6804. * @return {Array} Array of diff tuples.
  6805. */
  6806. function diff_bisectSplit_(text1, text2, x, y) {
  6807. var text1a = text1.substring(0, x);
  6808. var text2a = text2.substring(0, y);
  6809. var text1b = text1.substring(x);
  6810. var text2b = text2.substring(y);
  6811. // Compute both diffs serially.
  6812. var diffs = diff_main(text1a, text2a);
  6813. var diffsb = diff_main(text1b, text2b);
  6814. return diffs.concat(diffsb);
  6815. };
  6816. /**
  6817. * Determine the common prefix of two strings.
  6818. * @param {string} text1 First string.
  6819. * @param {string} text2 Second string.
  6820. * @return {number} The number of characters common to the start of each
  6821. * string.
  6822. */
  6823. function diff_commonPrefix(text1, text2) {
  6824. // Quick check for common null cases.
  6825. if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) {
  6826. return 0;
  6827. }
  6828. // Binary search.
  6829. // Performance analysis: http://neil.fraser.name/news/2007/10/09/
  6830. var pointermin = 0;
  6831. var pointermax = Math.min(text1.length, text2.length);
  6832. var pointermid = pointermax;
  6833. var pointerstart = 0;
  6834. while (pointermin < pointermid) {
  6835. if (text1.substring(pointerstart, pointermid) ==
  6836. text2.substring(pointerstart, pointermid)) {
  6837. pointermin = pointermid;
  6838. pointerstart = pointermin;
  6839. } else {
  6840. pointermax = pointermid;
  6841. }
  6842. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  6843. }
  6844. return pointermid;
  6845. };
  6846. /**
  6847. * Determine the common suffix of two strings.
  6848. * @param {string} text1 First string.
  6849. * @param {string} text2 Second string.
  6850. * @return {number} The number of characters common to the end of each string.
  6851. */
  6852. function diff_commonSuffix(text1, text2) {
  6853. // Quick check for common null cases.
  6854. if (!text1 || !text2 ||
  6855. text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)) {
  6856. return 0;
  6857. }
  6858. // Binary search.
  6859. // Performance analysis: http://neil.fraser.name/news/2007/10/09/
  6860. var pointermin = 0;
  6861. var pointermax = Math.min(text1.length, text2.length);
  6862. var pointermid = pointermax;
  6863. var pointerend = 0;
  6864. while (pointermin < pointermid) {
  6865. if (text1.substring(text1.length - pointermid, text1.length - pointerend) ==
  6866. text2.substring(text2.length - pointermid, text2.length - pointerend)) {
  6867. pointermin = pointermid;
  6868. pointerend = pointermin;
  6869. } else {
  6870. pointermax = pointermid;
  6871. }
  6872. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  6873. }
  6874. return pointermid;
  6875. };
  6876. /**
  6877. * Do the two texts share a substring which is at least half the length of the
  6878. * longer text?
  6879. * This speedup can produce non-minimal diffs.
  6880. * @param {string} text1 First string.
  6881. * @param {string} text2 Second string.
  6882. * @return {Array.<string>} Five element Array, containing the prefix of
  6883. * text1, the suffix of text1, the prefix of text2, the suffix of
  6884. * text2 and the common middle. Or null if there was no match.
  6885. */
  6886. function diff_halfMatch_(text1, text2) {
  6887. var longtext = text1.length > text2.length ? text1 : text2;
  6888. var shorttext = text1.length > text2.length ? text2 : text1;
  6889. if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
  6890. return null; // Pointless.
  6891. }
  6892. /**
  6893. * Does a substring of shorttext exist within longtext such that the substring
  6894. * is at least half the length of longtext?
  6895. * Closure, but does not reference any external variables.
  6896. * @param {string} longtext Longer string.
  6897. * @param {string} shorttext Shorter string.
  6898. * @param {number} i Start index of quarter length substring within longtext.
  6899. * @return {Array.<string>} Five element Array, containing the prefix of
  6900. * longtext, the suffix of longtext, the prefix of shorttext, the suffix
  6901. * of shorttext and the common middle. Or null if there was no match.
  6902. * @private
  6903. */
  6904. function diff_halfMatchI_(longtext, shorttext, i) {
  6905. // Start with a 1/4 length substring at position i as a seed.
  6906. var seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
  6907. var j = -1;
  6908. var best_common = '';
  6909. var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
  6910. while ((j = shorttext.indexOf(seed, j + 1)) != -1) {
  6911. var prefixLength = diff_commonPrefix(longtext.substring(i),
  6912. shorttext.substring(j));
  6913. var suffixLength = diff_commonSuffix(longtext.substring(0, i),
  6914. shorttext.substring(0, j));
  6915. if (best_common.length < suffixLength + prefixLength) {
  6916. best_common = shorttext.substring(j - suffixLength, j) +
  6917. shorttext.substring(j, j + prefixLength);
  6918. best_longtext_a = longtext.substring(0, i - suffixLength);
  6919. best_longtext_b = longtext.substring(i + prefixLength);
  6920. best_shorttext_a = shorttext.substring(0, j - suffixLength);
  6921. best_shorttext_b = shorttext.substring(j + prefixLength);
  6922. }
  6923. }
  6924. if (best_common.length * 2 >= longtext.length) {
  6925. return [best_longtext_a, best_longtext_b,
  6926. best_shorttext_a, best_shorttext_b, best_common];
  6927. } else {
  6928. return null;
  6929. }
  6930. }
  6931. // First check if the second quarter is the seed for a half-match.
  6932. var hm1 = diff_halfMatchI_(longtext, shorttext,
  6933. Math.ceil(longtext.length / 4));
  6934. // Check again based on the third quarter.
  6935. var hm2 = diff_halfMatchI_(longtext, shorttext,
  6936. Math.ceil(longtext.length / 2));
  6937. var hm;
  6938. if (!hm1 && !hm2) {
  6939. return null;
  6940. } else if (!hm2) {
  6941. hm = hm1;
  6942. } else if (!hm1) {
  6943. hm = hm2;
  6944. } else {
  6945. // Both matched. Select the longest.
  6946. hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
  6947. }
  6948. // A half-match was found, sort out the return data.
  6949. var text1_a, text1_b, text2_a, text2_b;
  6950. if (text1.length > text2.length) {
  6951. text1_a = hm[0];
  6952. text1_b = hm[1];
  6953. text2_a = hm[2];
  6954. text2_b = hm[3];
  6955. } else {
  6956. text2_a = hm[0];
  6957. text2_b = hm[1];
  6958. text1_a = hm[2];
  6959. text1_b = hm[3];
  6960. }
  6961. var mid_common = hm[4];
  6962. return [text1_a, text1_b, text2_a, text2_b, mid_common];
  6963. };
  6964. /**
  6965. * Reorder and merge like edit sections. Merge equalities.
  6966. * Any edit section can move as long as it doesn't cross an equality.
  6967. * @param {Array} diffs Array of diff tuples.
  6968. */
  6969. function diff_cleanupMerge(diffs) {
  6970. diffs.push([DIFF_EQUAL, '']); // Add a dummy entry at the end.
  6971. var pointer = 0;
  6972. var count_delete = 0;
  6973. var count_insert = 0;
  6974. var text_delete = '';
  6975. var text_insert = '';
  6976. var commonlength;
  6977. while (pointer < diffs.length) {
  6978. switch (diffs[pointer][0]) {
  6979. case DIFF_INSERT:
  6980. count_insert++;
  6981. text_insert += diffs[pointer][1];
  6982. pointer++;
  6983. break;
  6984. case DIFF_DELETE:
  6985. count_delete++;
  6986. text_delete += diffs[pointer][1];
  6987. pointer++;
  6988. break;
  6989. case DIFF_EQUAL:
  6990. // Upon reaching an equality, check for prior redundancies.
  6991. if (count_delete + count_insert > 1) {
  6992. if (count_delete !== 0 && count_insert !== 0) {
  6993. // Factor out any common prefixies.
  6994. commonlength = diff_commonPrefix(text_insert, text_delete);
  6995. if (commonlength !== 0) {
  6996. if ((pointer - count_delete - count_insert) > 0 &&
  6997. diffs[pointer - count_delete - count_insert - 1][0] ==
  6998. DIFF_EQUAL) {
  6999. diffs[pointer - count_delete - count_insert - 1][1] +=
  7000. text_insert.substring(0, commonlength);
  7001. } else {
  7002. diffs.splice(0, 0, [DIFF_EQUAL,
  7003. text_insert.substring(0, commonlength)]);
  7004. pointer++;
  7005. }
  7006. text_insert = text_insert.substring(commonlength);
  7007. text_delete = text_delete.substring(commonlength);
  7008. }
  7009. // Factor out any common suffixies.
  7010. commonlength = diff_commonSuffix(text_insert, text_delete);
  7011. if (commonlength !== 0) {
  7012. diffs[pointer][1] = text_insert.substring(text_insert.length -
  7013. commonlength) + diffs[pointer][1];
  7014. text_insert = text_insert.substring(0, text_insert.length -
  7015. commonlength);
  7016. text_delete = text_delete.substring(0, text_delete.length -
  7017. commonlength);
  7018. }
  7019. }
  7020. // Delete the offending records and add the merged ones.
  7021. if (count_delete === 0) {
  7022. diffs.splice(pointer - count_insert,
  7023. count_delete + count_insert, [DIFF_INSERT, text_insert]);
  7024. } else if (count_insert === 0) {
  7025. diffs.splice(pointer - count_delete,
  7026. count_delete + count_insert, [DIFF_DELETE, text_delete]);
  7027. } else {
  7028. diffs.splice(pointer - count_delete - count_insert,
  7029. count_delete + count_insert, [DIFF_DELETE, text_delete],
  7030. [DIFF_INSERT, text_insert]);
  7031. }
  7032. pointer = pointer - count_delete - count_insert +
  7033. (count_delete ? 1 : 0) + (count_insert ? 1 : 0) + 1;
  7034. } else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) {
  7035. // Merge this equality with the previous one.
  7036. diffs[pointer - 1][1] += diffs[pointer][1];
  7037. diffs.splice(pointer, 1);
  7038. } else {
  7039. pointer++;
  7040. }
  7041. count_insert = 0;
  7042. count_delete = 0;
  7043. text_delete = '';
  7044. text_insert = '';
  7045. break;
  7046. }
  7047. }
  7048. if (diffs[diffs.length - 1][1] === '') {
  7049. diffs.pop(); // Remove the dummy entry at the end.
  7050. }
  7051. // Second pass: look for single edits surrounded on both sides by equalities
  7052. // which can be shifted sideways to eliminate an equality.
  7053. // e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
  7054. var changes = false;
  7055. pointer = 1;
  7056. // Intentionally ignore the first and last element (don't need checking).
  7057. while (pointer < diffs.length - 1) {
  7058. if (diffs[pointer - 1][0] == DIFF_EQUAL &&
  7059. diffs[pointer + 1][0] == DIFF_EQUAL) {
  7060. // This is a single edit surrounded by equalities.
  7061. if (diffs[pointer][1].substring(diffs[pointer][1].length -
  7062. diffs[pointer - 1][1].length) == diffs[pointer - 1][1]) {
  7063. // Shift the edit over the previous equality.
  7064. diffs[pointer][1] = diffs[pointer - 1][1] +
  7065. diffs[pointer][1].substring(0, diffs[pointer][1].length -
  7066. diffs[pointer - 1][1].length);
  7067. diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
  7068. diffs.splice(pointer - 1, 1);
  7069. changes = true;
  7070. } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) ==
  7071. diffs[pointer + 1][1]) {
  7072. // Shift the edit over the next equality.
  7073. diffs[pointer - 1][1] += diffs[pointer + 1][1];
  7074. diffs[pointer][1] =
  7075. diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
  7076. diffs[pointer + 1][1];
  7077. diffs.splice(pointer + 1, 1);
  7078. changes = true;
  7079. }
  7080. }
  7081. pointer++;
  7082. }
  7083. // If shifts were made, the diff needs reordering and another shift sweep.
  7084. if (changes) {
  7085. diff_cleanupMerge(diffs);
  7086. }
  7087. };
  7088. var diff = diff_main;
  7089. diff.INSERT = DIFF_INSERT;
  7090. diff.DELETE = DIFF_DELETE;
  7091. diff.EQUAL = DIFF_EQUAL;
  7092. module.exports = diff;
  7093. /*
  7094. * Modify a diff such that the cursor position points to the start of a change:
  7095. * E.g.
  7096. * cursor_normalize_diff([[DIFF_EQUAL, 'abc']], 1)
  7097. * => [1, [[DIFF_EQUAL, 'a'], [DIFF_EQUAL, 'bc']]]
  7098. * cursor_normalize_diff([[DIFF_INSERT, 'new'], [DIFF_DELETE, 'xyz']], 2)
  7099. * => [2, [[DIFF_INSERT, 'new'], [DIFF_DELETE, 'xy'], [DIFF_DELETE, 'z']]]
  7100. *
  7101. * @param {Array} diffs Array of diff tuples
  7102. * @param {Int} cursor_pos Suggested edit position. Must not be out of bounds!
  7103. * @return {Array} A tuple [cursor location in the modified diff, modified diff]
  7104. */
  7105. function cursor_normalize_diff (diffs, cursor_pos) {
  7106. if (cursor_pos === 0) {
  7107. return [DIFF_EQUAL, diffs];
  7108. }
  7109. for (var current_pos = 0, i = 0; i < diffs.length; i++) {
  7110. var d = diffs[i];
  7111. if (d[0] === DIFF_DELETE || d[0] === DIFF_EQUAL) {
  7112. var next_pos = current_pos + d[1].length;
  7113. if (cursor_pos === next_pos) {
  7114. return [i + 1, diffs];
  7115. } else if (cursor_pos < next_pos) {
  7116. // copy to prevent side effects
  7117. diffs = diffs.slice();
  7118. // split d into two diff changes
  7119. var split_pos = cursor_pos - current_pos;
  7120. var d_left = [d[0], d[1].slice(0, split_pos)];
  7121. var d_right = [d[0], d[1].slice(split_pos)];
  7122. diffs.splice(i, 1, d_left, d_right);
  7123. return [i + 1, diffs];
  7124. } else {
  7125. current_pos = next_pos;
  7126. }
  7127. }
  7128. }
  7129. throw new Error('cursor_pos is out of bounds!')
  7130. }
  7131. /*
  7132. * Modify a diff such that the edit position is "shifted" to the proposed edit location (cursor_position).
  7133. *
  7134. * Case 1)
  7135. * Check if a naive shift is possible:
  7136. * [0, X], [ 1, Y] -> [ 1, Y], [0, X] (if X + Y === Y + X)
  7137. * [0, X], [-1, Y] -> [-1, Y], [0, X] (if X + Y === Y + X) - holds same result
  7138. * Case 2)
  7139. * Check if the following shifts are possible:
  7140. * [0, 'pre'], [ 1, 'prefix'] -> [ 1, 'pre'], [0, 'pre'], [ 1, 'fix']
  7141. * [0, 'pre'], [-1, 'prefix'] -> [-1, 'pre'], [0, 'pre'], [-1, 'fix']
  7142. * ^ ^
  7143. * d d_next
  7144. *
  7145. * @param {Array} diffs Array of diff tuples
  7146. * @param {Int} cursor_pos Suggested edit position. Must not be out of bounds!
  7147. * @return {Array} Array of diff tuples
  7148. */
  7149. function fix_cursor (diffs, cursor_pos) {
  7150. var norm = cursor_normalize_diff(diffs, cursor_pos);
  7151. var ndiffs = norm[1];
  7152. var cursor_pointer = norm[0];
  7153. var d = ndiffs[cursor_pointer];
  7154. var d_next = ndiffs[cursor_pointer + 1];
  7155. if (d == null) {
  7156. // Text was deleted from end of original string,
  7157. // cursor is now out of bounds in new string
  7158. return diffs;
  7159. } else if (d[0] !== DIFF_EQUAL) {
  7160. // A modification happened at the cursor location.
  7161. // This is the expected outcome, so we can return the original diff.
  7162. return diffs;
  7163. } else {
  7164. if (d_next != null && d[1] + d_next[1] === d_next[1] + d[1]) {
  7165. // Case 1)
  7166. // It is possible to perform a naive shift
  7167. ndiffs.splice(cursor_pointer, 2, d_next, d)
  7168. return merge_tuples(ndiffs, cursor_pointer, 2)
  7169. } else if (d_next != null && d_next[1].indexOf(d[1]) === 0) {
  7170. // Case 2)
  7171. // d[1] is a prefix of d_next[1]
  7172. // We can assume that d_next[0] !== 0, since d[0] === 0
  7173. // Shift edit locations..
  7174. ndiffs.splice(cursor_pointer, 2, [d_next[0], d[1]], [0, d[1]]);
  7175. var suffix = d_next[1].slice(d[1].length);
  7176. if (suffix.length > 0) {
  7177. ndiffs.splice(cursor_pointer + 2, 0, [d_next[0], suffix]);
  7178. }
  7179. return merge_tuples(ndiffs, cursor_pointer, 3)
  7180. } else {
  7181. // Not possible to perform any modification
  7182. return diffs;
  7183. }
  7184. }
  7185. }
  7186. /*
  7187. * Check diff did not split surrogate pairs.
  7188. * Ex. [0, '\uD83D'], [-1, '\uDC36'], [1, '\uDC2F'] -> [-1, '\uD83D\uDC36'], [1, '\uD83D\uDC2F']
  7189. * '\uD83D\uDC36' === '🐶', '\uD83D\uDC2F' === '🐯'
  7190. *
  7191. * @param {Array} diffs Array of diff tuples
  7192. * @return {Array} Array of diff tuples
  7193. */
  7194. function fix_emoji (diffs) {
  7195. var compact = false;
  7196. var starts_with_pair_end = function(str) {
  7197. return str.charCodeAt(0) >= 0xDC00 && str.charCodeAt(0) <= 0xDFFF;
  7198. }
  7199. var ends_with_pair_start = function(str) {
  7200. return str.charCodeAt(str.length-1) >= 0xD800 && str.charCodeAt(str.length-1) <= 0xDBFF;
  7201. }
  7202. for (var i = 2; i < diffs.length; i += 1) {
  7203. if (diffs[i-2][0] === DIFF_EQUAL && ends_with_pair_start(diffs[i-2][1]) &&
  7204. diffs[i-1][0] === DIFF_DELETE && starts_with_pair_end(diffs[i-1][1]) &&
  7205. diffs[i][0] === DIFF_INSERT && starts_with_pair_end(diffs[i][1])) {
  7206. compact = true;
  7207. diffs[i-1][1] = diffs[i-2][1].slice(-1) + diffs[i-1][1];
  7208. diffs[i][1] = diffs[i-2][1].slice(-1) + diffs[i][1];
  7209. diffs[i-2][1] = diffs[i-2][1].slice(0, -1);
  7210. }
  7211. }
  7212. if (!compact) {
  7213. return diffs;
  7214. }
  7215. var fixed_diffs = [];
  7216. for (var i = 0; i < diffs.length; i += 1) {
  7217. if (diffs[i][1].length > 0) {
  7218. fixed_diffs.push(diffs[i]);
  7219. }
  7220. }
  7221. return fixed_diffs;
  7222. }
  7223. /*
  7224. * Try to merge tuples with their neigbors in a given range.
  7225. * E.g. [0, 'a'], [0, 'b'] -> [0, 'ab']
  7226. *
  7227. * @param {Array} diffs Array of diff tuples.
  7228. * @param {Int} start Position of the first element to merge (diffs[start] is also merged with diffs[start - 1]).
  7229. * @param {Int} length Number of consecutive elements to check.
  7230. * @return {Array} Array of merged diff tuples.
  7231. */
  7232. function merge_tuples (diffs, start, length) {
  7233. // Check from (start-1) to (start+length).
  7234. for (var i = start + length - 1; i >= 0 && i >= start - 1; i--) {
  7235. if (i + 1 < diffs.length) {
  7236. var left_d = diffs[i];
  7237. var right_d = diffs[i+1];
  7238. if (left_d[0] === right_d[1]) {
  7239. diffs.splice(i, 2, [left_d[0], left_d[1] + right_d[1]]);
  7240. }
  7241. }
  7242. }
  7243. return diffs;
  7244. }
  7245. /***/ }),
  7246. /* 52 */
  7247. /***/ (function(module, exports) {
  7248. exports = module.exports = typeof Object.keys === 'function'
  7249. ? Object.keys : shim;
  7250. exports.shim = shim;
  7251. function shim (obj) {
  7252. var keys = [];
  7253. for (var key in obj) keys.push(key);
  7254. return keys;
  7255. }
  7256. /***/ }),
  7257. /* 53 */
  7258. /***/ (function(module, exports) {
  7259. var supportsArgumentsClass = (function(){
  7260. return Object.prototype.toString.call(arguments)
  7261. })() == '[object Arguments]';
  7262. exports = module.exports = supportsArgumentsClass ? supported : unsupported;
  7263. exports.supported = supported;
  7264. function supported(object) {
  7265. return Object.prototype.toString.call(object) == '[object Arguments]';
  7266. };
  7267. exports.unsupported = unsupported;
  7268. function unsupported(object){
  7269. return object &&
  7270. typeof object == 'object' &&
  7271. typeof object.length == 'number' &&
  7272. Object.prototype.hasOwnProperty.call(object, 'callee') &&
  7273. !Object.prototype.propertyIsEnumerable.call(object, 'callee') ||
  7274. false;
  7275. };
  7276. /***/ }),
  7277. /* 54 */
  7278. /***/ (function(module, exports) {
  7279. 'use strict';
  7280. var has = Object.prototype.hasOwnProperty
  7281. , prefix = '~';
  7282. /**
  7283. * Constructor to create a storage for our `EE` objects.
  7284. * An `Events` instance is a plain object whose properties are event names.
  7285. *
  7286. * @constructor
  7287. * @api private
  7288. */
  7289. function Events() {}
  7290. //
  7291. // We try to not inherit from `Object.prototype`. In some engines creating an
  7292. // instance in this way is faster than calling `Object.create(null)` directly.
  7293. // If `Object.create(null)` is not supported we prefix the event names with a
  7294. // character to make sure that the built-in object properties are not
  7295. // overridden or used as an attack vector.
  7296. //
  7297. if (Object.create) {
  7298. Events.prototype = Object.create(null);
  7299. //
  7300. // This hack is needed because the `__proto__` property is still inherited in
  7301. // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
  7302. //
  7303. if (!new Events().__proto__) prefix = false;
  7304. }
  7305. /**
  7306. * Representation of a single event listener.
  7307. *
  7308. * @param {Function} fn The listener function.
  7309. * @param {Mixed} context The context to invoke the listener with.
  7310. * @param {Boolean} [once=false] Specify if the listener is a one-time listener.
  7311. * @constructor
  7312. * @api private
  7313. */
  7314. function EE(fn, context, once) {
  7315. this.fn = fn;
  7316. this.context = context;
  7317. this.once = once || false;
  7318. }
  7319. /**
  7320. * Minimal `EventEmitter` interface that is molded against the Node.js
  7321. * `EventEmitter` interface.
  7322. *
  7323. * @constructor
  7324. * @api public
  7325. */
  7326. function EventEmitter() {
  7327. this._events = new Events();
  7328. this._eventsCount = 0;
  7329. }
  7330. /**
  7331. * Return an array listing the events for which the emitter has registered
  7332. * listeners.
  7333. *
  7334. * @returns {Array}
  7335. * @api public
  7336. */
  7337. EventEmitter.prototype.eventNames = function eventNames() {
  7338. var names = []
  7339. , events
  7340. , name;
  7341. if (this._eventsCount === 0) return names;
  7342. for (name in (events = this._events)) {
  7343. if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
  7344. }
  7345. if (Object.getOwnPropertySymbols) {
  7346. return names.concat(Object.getOwnPropertySymbols(events));
  7347. }
  7348. return names;
  7349. };
  7350. /**
  7351. * Return the listeners registered for a given event.
  7352. *
  7353. * @param {String|Symbol} event The event name.
  7354. * @param {Boolean} exists Only check if there are listeners.
  7355. * @returns {Array|Boolean}
  7356. * @api public
  7357. */
  7358. EventEmitter.prototype.listeners = function listeners(event, exists) {
  7359. var evt = prefix ? prefix + event : event
  7360. , available = this._events[evt];
  7361. if (exists) return !!available;
  7362. if (!available) return [];
  7363. if (available.fn) return [available.fn];
  7364. for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) {
  7365. ee[i] = available[i].fn;
  7366. }
  7367. return ee;
  7368. };
  7369. /**
  7370. * Calls each of the listeners registered for a given event.
  7371. *
  7372. * @param {String|Symbol} event The event name.
  7373. * @returns {Boolean} `true` if the event had listeners, else `false`.
  7374. * @api public
  7375. */
  7376. EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
  7377. var evt = prefix ? prefix + event : event;
  7378. if (!this._events[evt]) return false;
  7379. var listeners = this._events[evt]
  7380. , len = arguments.length
  7381. , args
  7382. , i;
  7383. if (listeners.fn) {
  7384. if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
  7385. switch (len) {
  7386. case 1: return listeners.fn.call(listeners.context), true;
  7387. case 2: return listeners.fn.call(listeners.context, a1), true;
  7388. case 3: return listeners.fn.call(listeners.context, a1, a2), true;
  7389. case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
  7390. case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
  7391. case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
  7392. }
  7393. for (i = 1, args = new Array(len -1); i < len; i++) {
  7394. args[i - 1] = arguments[i];
  7395. }
  7396. listeners.fn.apply(listeners.context, args);
  7397. } else {
  7398. var length = listeners.length
  7399. , j;
  7400. for (i = 0; i < length; i++) {
  7401. if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
  7402. switch (len) {
  7403. case 1: listeners[i].fn.call(listeners[i].context); break;
  7404. case 2: listeners[i].fn.call(listeners[i].context, a1); break;
  7405. case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
  7406. case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
  7407. default:
  7408. if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
  7409. args[j - 1] = arguments[j];
  7410. }
  7411. listeners[i].fn.apply(listeners[i].context, args);
  7412. }
  7413. }
  7414. }
  7415. return true;
  7416. };
  7417. /**
  7418. * Add a listener for a given event.
  7419. *
  7420. * @param {String|Symbol} event The event name.
  7421. * @param {Function} fn The listener function.
  7422. * @param {Mixed} [context=this] The context to invoke the listener with.
  7423. * @returns {EventEmitter} `this`.
  7424. * @api public
  7425. */
  7426. EventEmitter.prototype.on = function on(event, fn, context) {
  7427. var listener = new EE(fn, context || this)
  7428. , evt = prefix ? prefix + event : event;
  7429. if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
  7430. else if (!this._events[evt].fn) this._events[evt].push(listener);
  7431. else this._events[evt] = [this._events[evt], listener];
  7432. return this;
  7433. };
  7434. /**
  7435. * Add a one-time listener for a given event.
  7436. *
  7437. * @param {String|Symbol} event The event name.
  7438. * @param {Function} fn The listener function.
  7439. * @param {Mixed} [context=this] The context to invoke the listener with.
  7440. * @returns {EventEmitter} `this`.
  7441. * @api public
  7442. */
  7443. EventEmitter.prototype.once = function once(event, fn, context) {
  7444. var listener = new EE(fn, context || this, true)
  7445. , evt = prefix ? prefix + event : event;
  7446. if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
  7447. else if (!this._events[evt].fn) this._events[evt].push(listener);
  7448. else this._events[evt] = [this._events[evt], listener];
  7449. return this;
  7450. };
  7451. /**
  7452. * Remove the listeners of a given event.
  7453. *
  7454. * @param {String|Symbol} event The event name.
  7455. * @param {Function} fn Only remove the listeners that match this function.
  7456. * @param {Mixed} context Only remove the listeners that have this context.
  7457. * @param {Boolean} once Only remove one-time listeners.
  7458. * @returns {EventEmitter} `this`.
  7459. * @api public
  7460. */
  7461. EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
  7462. var evt = prefix ? prefix + event : event;
  7463. if (!this._events[evt]) return this;
  7464. if (!fn) {
  7465. if (--this._eventsCount === 0) this._events = new Events();
  7466. else delete this._events[evt];
  7467. return this;
  7468. }
  7469. var listeners = this._events[evt];
  7470. if (listeners.fn) {
  7471. if (
  7472. listeners.fn === fn
  7473. && (!once || listeners.once)
  7474. && (!context || listeners.context === context)
  7475. ) {
  7476. if (--this._eventsCount === 0) this._events = new Events();
  7477. else delete this._events[evt];
  7478. }
  7479. } else {
  7480. for (var i = 0, events = [], length = listeners.length; i < length; i++) {
  7481. if (
  7482. listeners[i].fn !== fn
  7483. || (once && !listeners[i].once)
  7484. || (context && listeners[i].context !== context)
  7485. ) {
  7486. events.push(listeners[i]);
  7487. }
  7488. }
  7489. //
  7490. // Reset the array, or remove it completely if we have no more listeners.
  7491. //
  7492. if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
  7493. else if (--this._eventsCount === 0) this._events = new Events();
  7494. else delete this._events[evt];
  7495. }
  7496. return this;
  7497. };
  7498. /**
  7499. * Remove all listeners, or those of the specified event.
  7500. *
  7501. * @param {String|Symbol} [event] The event name.
  7502. * @returns {EventEmitter} `this`.
  7503. * @api public
  7504. */
  7505. EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
  7506. var evt;
  7507. if (event) {
  7508. evt = prefix ? prefix + event : event;
  7509. if (this._events[evt]) {
  7510. if (--this._eventsCount === 0) this._events = new Events();
  7511. else delete this._events[evt];
  7512. }
  7513. } else {
  7514. this._events = new Events();
  7515. this._eventsCount = 0;
  7516. }
  7517. return this;
  7518. };
  7519. //
  7520. // Alias methods names because people roll like that.
  7521. //
  7522. EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
  7523. EventEmitter.prototype.addListener = EventEmitter.prototype.on;
  7524. //
  7525. // This function doesn't apply anymore.
  7526. //
  7527. EventEmitter.prototype.setMaxListeners = function setMaxListeners() {
  7528. return this;
  7529. };
  7530. //
  7531. // Expose the prefix.
  7532. //
  7533. EventEmitter.prefixed = prefix;
  7534. //
  7535. // Allow `EventEmitter` to be imported as module namespace.
  7536. //
  7537. EventEmitter.EventEmitter = EventEmitter;
  7538. //
  7539. // Expose the module.
  7540. //
  7541. if ('undefined' !== typeof module) {
  7542. module.exports = EventEmitter;
  7543. }
  7544. /***/ }),
  7545. /* 55 */
  7546. /***/ (function(module, exports, __webpack_require__) {
  7547. "use strict";
  7548. Object.defineProperty(exports, "__esModule", {
  7549. value: true
  7550. });
  7551. exports.matchText = exports.matchSpacing = exports.matchNewline = exports.matchBlot = exports.matchAttributor = exports.default = undefined;
  7552. 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; };
  7553. 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"); } }; }();
  7554. 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; }; }();
  7555. var _extend2 = __webpack_require__(3);
  7556. var _extend3 = _interopRequireDefault(_extend2);
  7557. var _quillDelta = __webpack_require__(2);
  7558. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  7559. var _parchment = __webpack_require__(0);
  7560. var _parchment2 = _interopRequireDefault(_parchment);
  7561. var _quill = __webpack_require__(5);
  7562. var _quill2 = _interopRequireDefault(_quill);
  7563. var _logger = __webpack_require__(10);
  7564. var _logger2 = _interopRequireDefault(_logger);
  7565. var _module = __webpack_require__(9);
  7566. var _module2 = _interopRequireDefault(_module);
  7567. var _align = __webpack_require__(36);
  7568. var _background = __webpack_require__(37);
  7569. var _code = __webpack_require__(13);
  7570. var _code2 = _interopRequireDefault(_code);
  7571. var _color = __webpack_require__(25);
  7572. var _direction = __webpack_require__(38);
  7573. var _font = __webpack_require__(39);
  7574. var _size = __webpack_require__(40);
  7575. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7576. 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; }
  7577. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7578. 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; }
  7579. 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; }
  7580. var debug = (0, _logger2.default)('quill:clipboard');
  7581. var DOM_KEY = '__ql-matcher';
  7582. 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]];
  7583. var ATTRIBUTE_ATTRIBUTORS = [_align.AlignAttribute, _direction.DirectionAttribute].reduce(function (memo, attr) {
  7584. memo[attr.keyName] = attr;
  7585. return memo;
  7586. }, {});
  7587. var STYLE_ATTRIBUTORS = [_align.AlignStyle, _background.BackgroundStyle, _color.ColorStyle, _direction.DirectionStyle, _font.FontStyle, _size.SizeStyle].reduce(function (memo, attr) {
  7588. memo[attr.keyName] = attr;
  7589. return memo;
  7590. }, {});
  7591. var Clipboard = function (_Module) {
  7592. _inherits(Clipboard, _Module);
  7593. function Clipboard(quill, options) {
  7594. _classCallCheck(this, Clipboard);
  7595. var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this, quill, options));
  7596. _this.quill.root.addEventListener('paste', _this.onPaste.bind(_this));
  7597. _this.container = _this.quill.addContainer('ql-clipboard');
  7598. _this.container.setAttribute('contenteditable', true);
  7599. _this.container.setAttribute('tabindex', -1);
  7600. _this.matchers = [];
  7601. CLIPBOARD_CONFIG.concat(_this.options.matchers).forEach(function (_ref) {
  7602. var _ref2 = _slicedToArray(_ref, 2),
  7603. selector = _ref2[0],
  7604. matcher = _ref2[1];
  7605. if (!options.matchVisual && matcher === matchSpacing) return;
  7606. _this.addMatcher(selector, matcher);
  7607. });
  7608. return _this;
  7609. }
  7610. _createClass(Clipboard, [{
  7611. key: 'addMatcher',
  7612. value: function addMatcher(selector, matcher) {
  7613. this.matchers.push([selector, matcher]);
  7614. }
  7615. }, {
  7616. key: 'convert',
  7617. value: function convert(html) {
  7618. if (typeof html === 'string') {
  7619. this.container.innerHTML = html.replace(/\>\r?\n +\</g, '><'); // Remove spaces between tags
  7620. return this.convert();
  7621. }
  7622. var formats = this.quill.getFormat(this.quill.selection.savedRange.index);
  7623. if (formats[_code2.default.blotName]) {
  7624. var text = this.container.innerText;
  7625. this.container.innerHTML = '';
  7626. return new _quillDelta2.default().insert(text, _defineProperty({}, _code2.default.blotName, formats[_code2.default.blotName]));
  7627. }
  7628. var _prepareMatching = this.prepareMatching(),
  7629. _prepareMatching2 = _slicedToArray(_prepareMatching, 2),
  7630. elementMatchers = _prepareMatching2[0],
  7631. textMatchers = _prepareMatching2[1];
  7632. var delta = traverse(this.container, elementMatchers, textMatchers);
  7633. // Remove trailing newline
  7634. if (deltaEndsWith(delta, '\n') && delta.ops[delta.ops.length - 1].attributes == null) {
  7635. delta = delta.compose(new _quillDelta2.default().retain(delta.length() - 1).delete(1));
  7636. }
  7637. debug.log('convert', this.container.innerHTML, delta);
  7638. this.container.innerHTML = '';
  7639. return delta;
  7640. }
  7641. }, {
  7642. key: 'dangerouslyPasteHTML',
  7643. value: function dangerouslyPasteHTML(index, html) {
  7644. var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _quill2.default.sources.API;
  7645. if (typeof index === 'string') {
  7646. this.quill.setContents(this.convert(index), html);
  7647. this.quill.setSelection(0, _quill2.default.sources.SILENT);
  7648. } else {
  7649. var paste = this.convert(html);
  7650. this.quill.updateContents(new _quillDelta2.default().retain(index).concat(paste), source);
  7651. this.quill.setSelection(index + paste.length(), _quill2.default.sources.SILENT);
  7652. }
  7653. }
  7654. }, {
  7655. key: 'onPaste',
  7656. value: function onPaste(e) {
  7657. var _this2 = this;
  7658. if (e.defaultPrevented || !this.quill.isEnabled()) return;
  7659. var range = this.quill.getSelection();
  7660. var delta = new _quillDelta2.default().retain(range.index);
  7661. var scrollTop = this.quill.scrollingContainer.scrollTop;
  7662. this.container.focus();
  7663. this.quill.selection.update(_quill2.default.sources.SILENT);
  7664. setTimeout(function () {
  7665. delta = delta.concat(_this2.convert()).delete(range.length);
  7666. _this2.quill.updateContents(delta, _quill2.default.sources.USER);
  7667. // range.length contributes to delta.length()
  7668. _this2.quill.setSelection(delta.length() - range.length, _quill2.default.sources.SILENT);
  7669. _this2.quill.scrollingContainer.scrollTop = scrollTop;
  7670. _this2.quill.focus();
  7671. }, 1);
  7672. }
  7673. }, {
  7674. key: 'prepareMatching',
  7675. value: function prepareMatching() {
  7676. var _this3 = this;
  7677. var elementMatchers = [],
  7678. textMatchers = [];
  7679. this.matchers.forEach(function (pair) {
  7680. var _pair = _slicedToArray(pair, 2),
  7681. selector = _pair[0],
  7682. matcher = _pair[1];
  7683. switch (selector) {
  7684. case Node.TEXT_NODE:
  7685. textMatchers.push(matcher);
  7686. break;
  7687. case Node.ELEMENT_NODE:
  7688. elementMatchers.push(matcher);
  7689. break;
  7690. default:
  7691. [].forEach.call(_this3.container.querySelectorAll(selector), function (node) {
  7692. // TODO use weakmap
  7693. node[DOM_KEY] = node[DOM_KEY] || [];
  7694. node[DOM_KEY].push(matcher);
  7695. });
  7696. break;
  7697. }
  7698. });
  7699. return [elementMatchers, textMatchers];
  7700. }
  7701. }]);
  7702. return Clipboard;
  7703. }(_module2.default);
  7704. Clipboard.DEFAULTS = {
  7705. matchers: [],
  7706. matchVisual: true
  7707. };
  7708. function applyFormat(delta, format, value) {
  7709. if ((typeof format === 'undefined' ? 'undefined' : _typeof(format)) === 'object') {
  7710. return Object.keys(format).reduce(function (delta, key) {
  7711. return applyFormat(delta, key, format[key]);
  7712. }, delta);
  7713. } else {
  7714. return delta.reduce(function (delta, op) {
  7715. if (op.attributes && op.attributes[format]) {
  7716. return delta.push(op);
  7717. } else {
  7718. return delta.insert(op.insert, (0, _extend3.default)({}, _defineProperty({}, format, value), op.attributes));
  7719. }
  7720. }, new _quillDelta2.default());
  7721. }
  7722. }
  7723. function computeStyle(node) {
  7724. if (node.nodeType !== Node.ELEMENT_NODE) return {};
  7725. var DOM_KEY = '__ql-computed-style';
  7726. return node[DOM_KEY] || (node[DOM_KEY] = window.getComputedStyle(node));
  7727. }
  7728. function deltaEndsWith(delta, text) {
  7729. var endText = "";
  7730. for (var i = delta.ops.length - 1; i >= 0 && endText.length < text.length; --i) {
  7731. var op = delta.ops[i];
  7732. if (typeof op.insert !== 'string') break;
  7733. endText = op.insert + endText;
  7734. }
  7735. return endText.slice(-1 * text.length) === text;
  7736. }
  7737. function isLine(node) {
  7738. if (node.childNodes.length === 0) return false; // Exclude embed blocks
  7739. var style = computeStyle(node);
  7740. return ['block', 'list-item'].indexOf(style.display) > -1;
  7741. }
  7742. function traverse(node, elementMatchers, textMatchers) {
  7743. // Post-order
  7744. if (node.nodeType === node.TEXT_NODE) {
  7745. return textMatchers.reduce(function (delta, matcher) {
  7746. return matcher(node, delta);
  7747. }, new _quillDelta2.default());
  7748. } else if (node.nodeType === node.ELEMENT_NODE) {
  7749. return [].reduce.call(node.childNodes || [], function (delta, childNode) {
  7750. var childrenDelta = traverse(childNode, elementMatchers, textMatchers);
  7751. if (childNode.nodeType === node.ELEMENT_NODE) {
  7752. childrenDelta = elementMatchers.reduce(function (childrenDelta, matcher) {
  7753. return matcher(childNode, childrenDelta);
  7754. }, childrenDelta);
  7755. childrenDelta = (childNode[DOM_KEY] || []).reduce(function (childrenDelta, matcher) {
  7756. return matcher(childNode, childrenDelta);
  7757. }, childrenDelta);
  7758. }
  7759. return delta.concat(childrenDelta);
  7760. }, new _quillDelta2.default());
  7761. } else {
  7762. return new _quillDelta2.default();
  7763. }
  7764. }
  7765. function matchAlias(format, node, delta) {
  7766. return applyFormat(delta, format, true);
  7767. }
  7768. function matchAttributor(node, delta) {
  7769. var attributes = _parchment2.default.Attributor.Attribute.keys(node);
  7770. var classes = _parchment2.default.Attributor.Class.keys(node);
  7771. var styles = _parchment2.default.Attributor.Style.keys(node);
  7772. var formats = {};
  7773. attributes.concat(classes).concat(styles).forEach(function (name) {
  7774. var attr = _parchment2.default.query(name, _parchment2.default.Scope.ATTRIBUTE);
  7775. if (attr != null) {
  7776. formats[attr.attrName] = attr.value(node);
  7777. if (formats[attr.attrName]) return;
  7778. }
  7779. attr = ATTRIBUTE_ATTRIBUTORS[name];
  7780. if (attr != null && (attr.attrName === name || attr.keyName === name)) {
  7781. formats[attr.attrName] = attr.value(node) || undefined;
  7782. }
  7783. attr = STYLE_ATTRIBUTORS[name];
  7784. if (attr != null && (attr.attrName === name || attr.keyName === name)) {
  7785. attr = STYLE_ATTRIBUTORS[name];
  7786. formats[attr.attrName] = attr.value(node) || undefined;
  7787. }
  7788. });
  7789. if (Object.keys(formats).length > 0) {
  7790. delta = applyFormat(delta, formats);
  7791. }
  7792. return delta;
  7793. }
  7794. function matchBlot(node, delta) {
  7795. var match = _parchment2.default.query(node);
  7796. if (match == null) return delta;
  7797. if (match.prototype instanceof _parchment2.default.Embed) {
  7798. var embed = {};
  7799. var value = match.value(node);
  7800. if (value != null) {
  7801. embed[match.blotName] = value;
  7802. delta = new _quillDelta2.default().insert(embed, match.formats(node));
  7803. }
  7804. } else if (typeof match.formats === 'function') {
  7805. delta = applyFormat(delta, match.blotName, match.formats(node));
  7806. }
  7807. return delta;
  7808. }
  7809. function matchBreak(node, delta) {
  7810. if (!deltaEndsWith(delta, '\n')) {
  7811. delta.insert('\n');
  7812. }
  7813. return delta;
  7814. }
  7815. function matchIgnore() {
  7816. return new _quillDelta2.default();
  7817. }
  7818. function matchIndent(node, delta) {
  7819. var match = _parchment2.default.query(node);
  7820. if (match == null || match.blotName !== 'list-item' || !deltaEndsWith(delta, '\n')) {
  7821. return delta;
  7822. }
  7823. var indent = -1,
  7824. parent = node.parentNode;
  7825. while (!parent.classList.contains('ql-clipboard')) {
  7826. if ((_parchment2.default.query(parent) || {}).blotName === 'list') {
  7827. indent += 1;
  7828. }
  7829. parent = parent.parentNode;
  7830. }
  7831. if (indent <= 0) return delta;
  7832. return delta.compose(new _quillDelta2.default().retain(delta.length() - 1).retain(1, { indent: indent }));
  7833. }
  7834. function matchNewline(node, delta) {
  7835. if (!deltaEndsWith(delta, '\n')) {
  7836. if (isLine(node) || delta.length() > 0 && node.nextSibling && isLine(node.nextSibling)) {
  7837. delta.insert('\n');
  7838. }
  7839. }
  7840. return delta;
  7841. }
  7842. function matchSpacing(node, delta) {
  7843. if (isLine(node) && node.nextElementSibling != null && !deltaEndsWith(delta, '\n\n')) {
  7844. var nodeHeight = node.offsetHeight + parseFloat(computeStyle(node).marginTop) + parseFloat(computeStyle(node).marginBottom);
  7845. if (node.nextElementSibling.offsetTop > node.offsetTop + nodeHeight * 1.5) {
  7846. delta.insert('\n');
  7847. }
  7848. }
  7849. return delta;
  7850. }
  7851. function matchStyles(node, delta) {
  7852. var formats = {};
  7853. var style = node.style || {};
  7854. if (style.fontStyle && computeStyle(node).fontStyle === 'italic') {
  7855. formats.italic = true;
  7856. }
  7857. if (style.fontWeight && (computeStyle(node).fontWeight.startsWith('bold') || parseInt(computeStyle(node).fontWeight) >= 700)) {
  7858. formats.bold = true;
  7859. }
  7860. if (Object.keys(formats).length > 0) {
  7861. delta = applyFormat(delta, formats);
  7862. }
  7863. if (parseFloat(style.textIndent || 0) > 0) {
  7864. // Could be 0.5in
  7865. delta = new _quillDelta2.default().insert('\t').concat(delta);
  7866. }
  7867. return delta;
  7868. }
  7869. function matchText(node, delta) {
  7870. var text = node.data;
  7871. // Word represents empty line with <o:p>&nbsp;</o:p>
  7872. if (node.parentNode.tagName === 'O:P') {
  7873. return delta.insert(text.trim());
  7874. }
  7875. if (text.trim().length === 0 && node.parentNode.classList.contains('ql-clipboard')) {
  7876. return delta;
  7877. }
  7878. if (!computeStyle(node.parentNode).whiteSpace.startsWith('pre')) {
  7879. // eslint-disable-next-line func-style
  7880. var replacer = function replacer(collapse, match) {
  7881. match = match.replace(/[^\u00a0]/g, ''); // \u00a0 is nbsp;
  7882. return match.length < 1 && collapse ? ' ' : match;
  7883. };
  7884. text = text.replace(/\r\n/g, ' ').replace(/\n/g, ' ');
  7885. text = text.replace(/\s\s+/g, replacer.bind(replacer, true)); // collapse whitespace
  7886. if (node.previousSibling == null && isLine(node.parentNode) || node.previousSibling != null && isLine(node.previousSibling)) {
  7887. text = text.replace(/^\s+/, replacer.bind(replacer, false));
  7888. }
  7889. if (node.nextSibling == null && isLine(node.parentNode) || node.nextSibling != null && isLine(node.nextSibling)) {
  7890. text = text.replace(/\s+$/, replacer.bind(replacer, false));
  7891. }
  7892. }
  7893. return delta.insert(text);
  7894. }
  7895. exports.default = Clipboard;
  7896. exports.matchAttributor = matchAttributor;
  7897. exports.matchBlot = matchBlot;
  7898. exports.matchNewline = matchNewline;
  7899. exports.matchSpacing = matchSpacing;
  7900. exports.matchText = matchText;
  7901. /***/ }),
  7902. /* 56 */
  7903. /***/ (function(module, exports, __webpack_require__) {
  7904. "use strict";
  7905. Object.defineProperty(exports, "__esModule", {
  7906. value: true
  7907. });
  7908. 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; }; }();
  7909. 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); } };
  7910. var _inline = __webpack_require__(6);
  7911. var _inline2 = _interopRequireDefault(_inline);
  7912. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7913. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7914. 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; }
  7915. 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; }
  7916. var Bold = function (_Inline) {
  7917. _inherits(Bold, _Inline);
  7918. function Bold() {
  7919. _classCallCheck(this, Bold);
  7920. return _possibleConstructorReturn(this, (Bold.__proto__ || Object.getPrototypeOf(Bold)).apply(this, arguments));
  7921. }
  7922. _createClass(Bold, [{
  7923. key: 'optimize',
  7924. value: function optimize(context) {
  7925. _get(Bold.prototype.__proto__ || Object.getPrototypeOf(Bold.prototype), 'optimize', this).call(this, context);
  7926. if (this.domNode.tagName !== this.statics.tagName[0]) {
  7927. this.replaceWith(this.statics.blotName);
  7928. }
  7929. }
  7930. }], [{
  7931. key: 'create',
  7932. value: function create() {
  7933. return _get(Bold.__proto__ || Object.getPrototypeOf(Bold), 'create', this).call(this);
  7934. }
  7935. }, {
  7936. key: 'formats',
  7937. value: function formats() {
  7938. return true;
  7939. }
  7940. }]);
  7941. return Bold;
  7942. }(_inline2.default);
  7943. Bold.blotName = 'bold';
  7944. Bold.tagName = ['STRONG', 'B'];
  7945. exports.default = Bold;
  7946. /***/ }),
  7947. /* 57 */
  7948. /***/ (function(module, exports, __webpack_require__) {
  7949. "use strict";
  7950. Object.defineProperty(exports, "__esModule", {
  7951. value: true
  7952. });
  7953. exports.addControls = exports.default = undefined;
  7954. 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"); } }; }();
  7955. 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; }; }();
  7956. var _quillDelta = __webpack_require__(2);
  7957. var _quillDelta2 = _interopRequireDefault(_quillDelta);
  7958. var _parchment = __webpack_require__(0);
  7959. var _parchment2 = _interopRequireDefault(_parchment);
  7960. var _quill = __webpack_require__(5);
  7961. var _quill2 = _interopRequireDefault(_quill);
  7962. var _logger = __webpack_require__(10);
  7963. var _logger2 = _interopRequireDefault(_logger);
  7964. var _module = __webpack_require__(9);
  7965. var _module2 = _interopRequireDefault(_module);
  7966. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7967. 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; }
  7968. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7969. 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; }
  7970. 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; }
  7971. var debug = (0, _logger2.default)('quill:toolbar');
  7972. var Toolbar = function (_Module) {
  7973. _inherits(Toolbar, _Module);
  7974. function Toolbar(quill, options) {
  7975. _classCallCheck(this, Toolbar);
  7976. var _this = _possibleConstructorReturn(this, (Toolbar.__proto__ || Object.getPrototypeOf(Toolbar)).call(this, quill, options));
  7977. if (Array.isArray(_this.options.container)) {
  7978. var container = document.createElement('div');
  7979. addControls(container, _this.options.container);
  7980. quill.container.parentNode.insertBefore(container, quill.container);
  7981. _this.container = container;
  7982. } else if (typeof _this.options.container === 'string') {
  7983. _this.container = document.querySelector(_this.options.container);
  7984. } else {
  7985. _this.container = _this.options.container;
  7986. }
  7987. if (!(_this.container instanceof HTMLElement)) {
  7988. var _ret;
  7989. return _ret = debug.error('Container required for toolbar', _this.options), _possibleConstructorReturn(_this, _ret);
  7990. }
  7991. _this.container.classList.add('ql-toolbar');
  7992. _this.controls = [];
  7993. _this.handlers = {};
  7994. Object.keys(_this.options.handlers).forEach(function (format) {
  7995. _this.addHandler(format, _this.options.handlers[format]);
  7996. });
  7997. [].forEach.call(_this.container.querySelectorAll('button, select'), function (input) {
  7998. _this.attach(input);
  7999. });
  8000. _this.quill.on(_quill2.default.events.EDITOR_CHANGE, function (type, range) {
  8001. if (type === _quill2.default.events.SELECTION_CHANGE) {
  8002. _this.update(range);
  8003. }
  8004. });
  8005. _this.quill.on(_quill2.default.events.SCROLL_OPTIMIZE, function () {
  8006. var _this$quill$selection = _this.quill.selection.getRange(),
  8007. _this$quill$selection2 = _slicedToArray(_this$quill$selection, 1),
  8008. range = _this$quill$selection2[0]; // quill.getSelection triggers update
  8009. _this.update(range);
  8010. });
  8011. return _this;
  8012. }
  8013. _createClass(Toolbar, [{
  8014. key: 'addHandler',
  8015. value: function addHandler(format, handler) {
  8016. this.handlers[format] = handler;
  8017. }
  8018. }, {
  8019. key: 'attach',
  8020. value: function attach(input) {
  8021. var _this2 = this;
  8022. var format = [].find.call(input.classList, function (className) {
  8023. return className.indexOf('ql-') === 0;
  8024. });
  8025. if (!format) return;
  8026. format = format.slice('ql-'.length);
  8027. if (input.tagName === 'BUTTON') {
  8028. input.setAttribute('type', 'button');
  8029. }
  8030. if (this.handlers[format] == null) {
  8031. if (this.quill.scroll.whitelist != null && this.quill.scroll.whitelist[format] == null) {
  8032. debug.warn('ignoring attaching to disabled format', format, input);
  8033. return;
  8034. }
  8035. if (_parchment2.default.query(format) == null) {
  8036. debug.warn('ignoring attaching to nonexistent format', format, input);
  8037. return;
  8038. }
  8039. }
  8040. var eventName = input.tagName === 'SELECT' ? 'change' : 'click';
  8041. input.addEventListener(eventName, function (e) {
  8042. var value = void 0;
  8043. if (input.tagName === 'SELECT') {
  8044. if (input.selectedIndex < 0) return;
  8045. var selected = input.options[input.selectedIndex];
  8046. if (selected.hasAttribute('selected')) {
  8047. value = false;
  8048. } else {
  8049. value = selected.value || false;
  8050. }
  8051. } else {
  8052. if (input.classList.contains('ql-active')) {
  8053. value = false;
  8054. } else {
  8055. value = input.value || !input.hasAttribute('value');
  8056. }
  8057. e.preventDefault();
  8058. }
  8059. _this2.quill.focus();
  8060. var _quill$selection$getR = _this2.quill.selection.getRange(),
  8061. _quill$selection$getR2 = _slicedToArray(_quill$selection$getR, 1),
  8062. range = _quill$selection$getR2[0];
  8063. if (_this2.handlers[format] != null) {
  8064. _this2.handlers[format].call(_this2, value);
  8065. } else if (_parchment2.default.query(format).prototype instanceof _parchment2.default.Embed) {
  8066. value = prompt('Enter ' + format);
  8067. if (!value) return;
  8068. _this2.quill.updateContents(new _quillDelta2.default().retain(range.index).delete(range.length).insert(_defineProperty({}, format, value)), _quill2.default.sources.USER);
  8069. } else {
  8070. _this2.quill.format(format, value, _quill2.default.sources.USER);
  8071. }
  8072. _this2.update(range);
  8073. });
  8074. // TODO use weakmap
  8075. this.controls.push([format, input]);
  8076. }
  8077. }, {
  8078. key: 'update',
  8079. value: function update(range) {
  8080. var formats = range == null ? {} : this.quill.getFormat(range);
  8081. this.controls.forEach(function (pair) {
  8082. var _pair = _slicedToArray(pair, 2),
  8083. format = _pair[0],
  8084. input = _pair[1];
  8085. if (input.tagName === 'SELECT') {
  8086. var option = void 0;
  8087. if (range == null) {
  8088. option = null;
  8089. } else if (formats[format] == null) {
  8090. option = input.querySelector('option[selected]');
  8091. } else if (!Array.isArray(formats[format])) {
  8092. var value = formats[format];
  8093. if (typeof value === 'string') {
  8094. value = value.replace(/\"/g, '\\"');
  8095. }
  8096. option = input.querySelector('option[value="' + value + '"]');
  8097. }
  8098. if (option == null) {
  8099. input.value = ''; // TODO make configurable?
  8100. input.selectedIndex = -1;
  8101. } else {
  8102. option.selected = true;
  8103. }
  8104. } else {
  8105. if (range == null) {
  8106. input.classList.remove('ql-active');
  8107. } else if (input.hasAttribute('value')) {
  8108. // both being null should match (default values)
  8109. // '1' should match with 1 (headers)
  8110. var isActive = formats[format] === input.getAttribute('value') || formats[format] != null && formats[format].toString() === input.getAttribute('value') || formats[format] == null && !input.getAttribute('value');
  8111. input.classList.toggle('ql-active', isActive);
  8112. } else {
  8113. input.classList.toggle('ql-active', formats[format] != null);
  8114. }
  8115. }
  8116. });
  8117. }
  8118. }]);
  8119. return Toolbar;
  8120. }(_module2.default);
  8121. Toolbar.DEFAULTS = {};
  8122. function addButton(container, format, value) {
  8123. var input = document.createElement('button');
  8124. input.setAttribute('type', 'button');
  8125. input.classList.add('ql-' + format);
  8126. if (value != null) {
  8127. input.value = value;
  8128. }
  8129. container.appendChild(input);
  8130. }
  8131. function addControls(container, groups) {
  8132. if (!Array.isArray(groups[0])) {
  8133. groups = [groups];
  8134. }
  8135. groups.forEach(function (controls) {
  8136. var group = document.createElement('span');
  8137. group.classList.add('ql-formats');
  8138. controls.forEach(function (control) {
  8139. if (typeof control === 'string') {
  8140. addButton(group, control);
  8141. } else {
  8142. var format = Object.keys(control)[0];
  8143. var value = control[format];
  8144. if (Array.isArray(value)) {
  8145. addSelect(group, format, value);
  8146. } else {
  8147. addButton(group, format, value);
  8148. }
  8149. }
  8150. });
  8151. container.appendChild(group);
  8152. });
  8153. }
  8154. function addSelect(container, format, values) {
  8155. var input = document.createElement('select');
  8156. input.classList.add('ql-' + format);
  8157. values.forEach(function (value) {
  8158. var option = document.createElement('option');
  8159. if (value !== false) {
  8160. option.setAttribute('value', value);
  8161. } else {
  8162. option.setAttribute('selected', 'selected');
  8163. }
  8164. input.appendChild(option);
  8165. });
  8166. container.appendChild(input);
  8167. }
  8168. Toolbar.DEFAULTS = {
  8169. container: null,
  8170. handlers: {
  8171. clean: function clean() {
  8172. var _this3 = this;
  8173. var range = this.quill.getSelection();
  8174. if (range == null) return;
  8175. if (range.length == 0) {
  8176. var formats = this.quill.getFormat();
  8177. Object.keys(formats).forEach(function (name) {
  8178. // Clean functionality in existing apps only clean inline formats
  8179. if (_parchment2.default.query(name, _parchment2.default.Scope.INLINE) != null) {
  8180. _this3.quill.format(name, false);
  8181. }
  8182. });
  8183. } else {
  8184. this.quill.removeFormat(range, _quill2.default.sources.USER);
  8185. }
  8186. },
  8187. direction: function direction(value) {
  8188. var align = this.quill.getFormat()['align'];
  8189. if (value === 'rtl' && align == null) {
  8190. this.quill.format('align', 'right', _quill2.default.sources.USER);
  8191. } else if (!value && align === 'right') {
  8192. this.quill.format('align', false, _quill2.default.sources.USER);
  8193. }
  8194. this.quill.format('direction', value, _quill2.default.sources.USER);
  8195. },
  8196. indent: function indent(value) {
  8197. var range = this.quill.getSelection();
  8198. var formats = this.quill.getFormat(range);
  8199. var indent = parseInt(formats.indent || 0);
  8200. if (value === '+1' || value === '-1') {
  8201. var modifier = value === '+1' ? 1 : -1;
  8202. if (formats.direction === 'rtl') modifier *= -1;
  8203. this.quill.format('indent', indent + modifier, _quill2.default.sources.USER);
  8204. }
  8205. },
  8206. link: function link(value) {
  8207. if (value === true) {
  8208. value = prompt('Enter link URL:');
  8209. }
  8210. this.quill.format('link', value, _quill2.default.sources.USER);
  8211. },
  8212. list: function list(value) {
  8213. var range = this.quill.getSelection();
  8214. var formats = this.quill.getFormat(range);
  8215. if (value === 'check') {
  8216. if (formats['list'] === 'checked' || formats['list'] === 'unchecked') {
  8217. this.quill.format('list', false, _quill2.default.sources.USER);
  8218. } else {
  8219. this.quill.format('list', 'unchecked', _quill2.default.sources.USER);
  8220. }
  8221. } else {
  8222. this.quill.format('list', value, _quill2.default.sources.USER);
  8223. }
  8224. }
  8225. }
  8226. };
  8227. exports.default = Toolbar;
  8228. exports.addControls = addControls;
  8229. /***/ }),
  8230. /* 58 */
  8231. /***/ (function(module, exports) {
  8232. module.exports = "<svg viewbox=\"0 0 18 18\"> <polyline class=\"ql-even ql-stroke\" points=\"5 7 3 9 5 11\"></polyline> <polyline class=\"ql-even ql-stroke\" points=\"13 7 15 9 13 11\"></polyline> <line class=ql-stroke x1=10 x2=8 y1=5 y2=13></line> </svg>";
  8233. /***/ }),
  8234. /* 59 */
  8235. /***/ (function(module, exports, __webpack_require__) {
  8236. "use strict";
  8237. Object.defineProperty(exports, "__esModule", {
  8238. value: true
  8239. });
  8240. 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; }; }();
  8241. 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); } };
  8242. var _picker = __webpack_require__(27);
  8243. var _picker2 = _interopRequireDefault(_picker);
  8244. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8245. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8246. 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; }
  8247. 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; }
  8248. var ColorPicker = function (_Picker) {
  8249. _inherits(ColorPicker, _Picker);
  8250. function ColorPicker(select, label) {
  8251. _classCallCheck(this, ColorPicker);
  8252. var _this = _possibleConstructorReturn(this, (ColorPicker.__proto__ || Object.getPrototypeOf(ColorPicker)).call(this, select));
  8253. _this.label.innerHTML = label;
  8254. _this.container.classList.add('ql-color-picker');
  8255. [].slice.call(_this.container.querySelectorAll('.ql-picker-item'), 0, 7).forEach(function (item) {
  8256. item.classList.add('ql-primary');
  8257. });
  8258. return _this;
  8259. }
  8260. _createClass(ColorPicker, [{
  8261. key: 'buildItem',
  8262. value: function buildItem(option) {
  8263. var item = _get(ColorPicker.prototype.__proto__ || Object.getPrototypeOf(ColorPicker.prototype), 'buildItem', this).call(this, option);
  8264. item.style.backgroundColor = option.getAttribute('value') || '';
  8265. return item;
  8266. }
  8267. }, {
  8268. key: 'selectItem',
  8269. value: function selectItem(item, trigger) {
  8270. _get(ColorPicker.prototype.__proto__ || Object.getPrototypeOf(ColorPicker.prototype), 'selectItem', this).call(this, item, trigger);
  8271. var colorLabel = this.label.querySelector('.ql-color-label');
  8272. var value = item ? item.getAttribute('data-value') || '' : '';
  8273. if (colorLabel) {
  8274. if (colorLabel.tagName === 'line') {
  8275. colorLabel.style.stroke = value;
  8276. } else {
  8277. colorLabel.style.fill = value;
  8278. }
  8279. }
  8280. }
  8281. }]);
  8282. return ColorPicker;
  8283. }(_picker2.default);
  8284. exports.default = ColorPicker;
  8285. /***/ }),
  8286. /* 60 */
  8287. /***/ (function(module, exports, __webpack_require__) {
  8288. "use strict";
  8289. Object.defineProperty(exports, "__esModule", {
  8290. value: true
  8291. });
  8292. 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; }; }();
  8293. 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); } };
  8294. var _picker = __webpack_require__(27);
  8295. var _picker2 = _interopRequireDefault(_picker);
  8296. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8297. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8298. 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; }
  8299. 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; }
  8300. var IconPicker = function (_Picker) {
  8301. _inherits(IconPicker, _Picker);
  8302. function IconPicker(select, icons) {
  8303. _classCallCheck(this, IconPicker);
  8304. var _this = _possibleConstructorReturn(this, (IconPicker.__proto__ || Object.getPrototypeOf(IconPicker)).call(this, select));
  8305. _this.container.classList.add('ql-icon-picker');
  8306. [].forEach.call(_this.container.querySelectorAll('.ql-picker-item'), function (item) {
  8307. item.innerHTML = icons[item.getAttribute('data-value') || ''];
  8308. });
  8309. _this.defaultItem = _this.container.querySelector('.ql-selected');
  8310. _this.selectItem(_this.defaultItem);
  8311. return _this;
  8312. }
  8313. _createClass(IconPicker, [{
  8314. key: 'selectItem',
  8315. value: function selectItem(item, trigger) {
  8316. _get(IconPicker.prototype.__proto__ || Object.getPrototypeOf(IconPicker.prototype), 'selectItem', this).call(this, item, trigger);
  8317. item = item || this.defaultItem;
  8318. this.label.innerHTML = item.innerHTML;
  8319. }
  8320. }]);
  8321. return IconPicker;
  8322. }(_picker2.default);
  8323. exports.default = IconPicker;
  8324. /***/ }),
  8325. /* 61 */
  8326. /***/ (function(module, exports, __webpack_require__) {
  8327. "use strict";
  8328. Object.defineProperty(exports, "__esModule", {
  8329. value: true
  8330. });
  8331. 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; }; }();
  8332. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8333. var Tooltip = function () {
  8334. function Tooltip(quill, boundsContainer) {
  8335. var _this = this;
  8336. _classCallCheck(this, Tooltip);
  8337. this.quill = quill;
  8338. this.boundsContainer = boundsContainer || document.body;
  8339. this.root = quill.addContainer('ql-tooltip');
  8340. this.root.innerHTML = this.constructor.TEMPLATE;
  8341. if (this.quill.root === this.quill.scrollingContainer) {
  8342. this.quill.root.addEventListener('scroll', function () {
  8343. _this.root.style.marginTop = -1 * _this.quill.root.scrollTop + 'px';
  8344. });
  8345. }
  8346. this.hide();
  8347. }
  8348. _createClass(Tooltip, [{
  8349. key: 'hide',
  8350. value: function hide() {
  8351. this.root.classList.add('ql-hidden');
  8352. }
  8353. }, {
  8354. key: 'position',
  8355. value: function position(reference) {
  8356. var left = reference.left + reference.width / 2 - this.root.offsetWidth / 2;
  8357. if(left <= 0){
  8358. left = 0;
  8359. }
  8360. // root.scrollTop should be 0 if scrollContainer !== root
  8361. var top = reference.bottom + this.quill.root.scrollTop;
  8362. this.root.style.left = left + 'px';
  8363. this.root.style.top = top + 'px';
  8364. this.root.classList.remove('ql-flip');
  8365. var containerBounds = this.boundsContainer.getBoundingClientRect();
  8366. var rootBounds = this.root.getBoundingClientRect();
  8367. var shift = 0;
  8368. if (rootBounds.right > containerBounds.right) {
  8369. shift = containerBounds.right - rootBounds.right;
  8370. this.root.style.left = left + shift + 'px';
  8371. }
  8372. if (rootBounds.left < containerBounds.left) {
  8373. shift = containerBounds.left - rootBounds.left;
  8374. this.root.style.left = left + shift + 'px';
  8375. }
  8376. if (rootBounds.bottom > containerBounds.bottom) {
  8377. var height = rootBounds.bottom - rootBounds.top;
  8378. var verticalShift = reference.bottom - reference.top + height;
  8379. this.root.style.top = top - verticalShift + 'px';
  8380. this.root.classList.add('ql-flip');
  8381. }
  8382. return shift;
  8383. }
  8384. }, {
  8385. key: 'show',
  8386. value: function show() {
  8387. this.root.classList.remove('ql-editing');
  8388. this.root.classList.remove('ql-hidden');
  8389. }
  8390. }]);
  8391. return Tooltip;
  8392. }();
  8393. exports.default = Tooltip;
  8394. /***/ }),
  8395. /* 62 */
  8396. /***/ (function(module, exports, __webpack_require__) {
  8397. "use strict";
  8398. Object.defineProperty(exports, "__esModule", {
  8399. value: true
  8400. });
  8401. 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"); } }; }();
  8402. 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); } };
  8403. 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; }; }();
  8404. var _extend = __webpack_require__(3);
  8405. var _extend2 = _interopRequireDefault(_extend);
  8406. var _emitter = __webpack_require__(8);
  8407. var _emitter2 = _interopRequireDefault(_emitter);
  8408. var _base = __webpack_require__(43);
  8409. var _base2 = _interopRequireDefault(_base);
  8410. var _link = __webpack_require__(26);
  8411. var _link2 = _interopRequireDefault(_link);
  8412. var _selection = __webpack_require__(15);
  8413. var _icons = __webpack_require__(41);
  8414. var _icons2 = _interopRequireDefault(_icons);
  8415. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8416. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8417. 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; }
  8418. 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; }
  8419. var TOOLBAR_CONFIG = [[{ header: ['1', '2', '3', false] }], ['bold', 'italic', 'underline', 'link'], [{ list: 'ordered' }, { list: 'bullet' }], ['clean']];
  8420. var SnowTheme = function (_BaseTheme) {
  8421. _inherits(SnowTheme, _BaseTheme);
  8422. function SnowTheme(quill, options) {
  8423. _classCallCheck(this, SnowTheme);
  8424. if (options.modules.toolbar != null && options.modules.toolbar.container == null) {
  8425. options.modules.toolbar.container = TOOLBAR_CONFIG;
  8426. }
  8427. var _this = _possibleConstructorReturn(this, (SnowTheme.__proto__ || Object.getPrototypeOf(SnowTheme)).call(this, quill, options));
  8428. _this.quill.container.classList.add('ql-snow');
  8429. return _this;
  8430. }
  8431. _createClass(SnowTheme, [{
  8432. key: 'extendToolbar',
  8433. value: function extendToolbar(toolbar) {
  8434. toolbar.container.classList.add('ql-snow');
  8435. this.buildButtons([].slice.call(toolbar.container.querySelectorAll('button')), _icons2.default);
  8436. this.buildPickers([].slice.call(toolbar.container.querySelectorAll('select')), _icons2.default);
  8437. this.tooltip = new SnowTooltip(this.quill, this.options.bounds);
  8438. if (toolbar.container.querySelector('.ql-link')) {
  8439. this.quill.keyboard.addBinding({ key: 'K', shortKey: true }, function (range, context) {
  8440. toolbar.handlers['link'].call(toolbar, !context.format.link);
  8441. });
  8442. }
  8443. }
  8444. }]);
  8445. return SnowTheme;
  8446. }(_base2.default);
  8447. SnowTheme.DEFAULTS = (0, _extend2.default)(true, {}, _base2.default.DEFAULTS, {
  8448. modules: {
  8449. toolbar: {
  8450. handlers: {
  8451. link: function link(value) {
  8452. if (value) {
  8453. var range = this.quill.getSelection();
  8454. if (range == null || range.length == 0) return;
  8455. var preview = this.quill.getText(range);
  8456. if (/^\S+@\S+\.\S+$/.test(preview) && preview.indexOf('mailto:') !== 0) {
  8457. preview = 'mailto:' + preview;
  8458. }
  8459. var tooltip = this.quill.theme.tooltip;
  8460. tooltip.edit('link', preview);
  8461. } else {
  8462. this.quill.format('link', false);
  8463. }
  8464. }
  8465. }
  8466. }
  8467. }
  8468. });
  8469. var SnowTooltip = function (_BaseTooltip) {
  8470. _inherits(SnowTooltip, _BaseTooltip);
  8471. function SnowTooltip(quill, bounds) {
  8472. _classCallCheck(this, SnowTooltip);
  8473. var _this2 = _possibleConstructorReturn(this, (SnowTooltip.__proto__ || Object.getPrototypeOf(SnowTooltip)).call(this, quill, bounds));
  8474. _this2.preview = _this2.root.querySelector('a.ql-preview');
  8475. return _this2;
  8476. }
  8477. _createClass(SnowTooltip, [{
  8478. key: 'listen',
  8479. value: function listen() {
  8480. var _this3 = this;
  8481. _get(SnowTooltip.prototype.__proto__ || Object.getPrototypeOf(SnowTooltip.prototype), 'listen', this).call(this);
  8482. this.root.querySelector('a.ql-action').addEventListener('click', function (event) {
  8483. if (_this3.root.classList.contains('ql-editing')) {
  8484. _this3.save();
  8485. } else {
  8486. _this3.edit('link', _this3.preview.textContent);
  8487. }
  8488. event.preventDefault();
  8489. });
  8490. this.root.querySelector('a.ql-remove').addEventListener('click', function (event) {
  8491. if (_this3.linkRange != null) {
  8492. var range = _this3.linkRange;
  8493. _this3.restoreFocus();
  8494. _this3.quill.formatText(range, 'link', false, _emitter2.default.sources.USER);
  8495. delete _this3.linkRange;
  8496. }
  8497. event.preventDefault();
  8498. _this3.hide();
  8499. });
  8500. this.quill.on(_emitter2.default.events.SELECTION_CHANGE, function (range, oldRange, source) {
  8501. if (range == null) return;
  8502. if (range.length === 0 && source === _emitter2.default.sources.USER) {
  8503. var _quill$scroll$descend = _this3.quill.scroll.descendant(_link2.default, range.index),
  8504. _quill$scroll$descend2 = _slicedToArray(_quill$scroll$descend, 2),
  8505. link = _quill$scroll$descend2[0],
  8506. offset = _quill$scroll$descend2[1];
  8507. if (link != null) {
  8508. _this3.linkRange = new _selection.Range(range.index - offset, link.length());
  8509. var preview = _link2.default.formats(link.domNode);
  8510. _this3.preview.textContent = preview;
  8511. _this3.preview.setAttribute('href', preview);
  8512. _this3.show();
  8513. _this3.position(_this3.quill.getBounds(_this3.linkRange));
  8514. return;
  8515. }
  8516. } else {
  8517. delete _this3.linkRange;
  8518. }
  8519. _this3.hide();
  8520. });
  8521. }
  8522. }, {
  8523. key: 'show',
  8524. value: function show() {
  8525. _get(SnowTooltip.prototype.__proto__ || Object.getPrototypeOf(SnowTooltip.prototype), 'show', this).call(this);
  8526. this.root.removeAttribute('data-mode');
  8527. }
  8528. }]);
  8529. return SnowTooltip;
  8530. }(_base.BaseTooltip);
  8531. SnowTooltip.TEMPLATE = ['<a class="ql-preview" target="_blank" href="about:blank"></a>', '<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">', '<a class="ql-action"></a>', '<a class="ql-remove"></a>'].join('');
  8532. exports.default = SnowTheme;
  8533. /***/ }),
  8534. /* 63 */
  8535. /***/ (function(module, exports, __webpack_require__) {
  8536. "use strict";
  8537. Object.defineProperty(exports, "__esModule", {
  8538. value: true
  8539. });
  8540. var _core = __webpack_require__(28);
  8541. var _core2 = _interopRequireDefault(_core);
  8542. var _align = __webpack_require__(36);
  8543. var _direction = __webpack_require__(38);
  8544. var _indent = __webpack_require__(64);
  8545. var _blockquote = __webpack_require__(65);
  8546. var _blockquote2 = _interopRequireDefault(_blockquote);
  8547. var _header = __webpack_require__(66);
  8548. var _header2 = _interopRequireDefault(_header);
  8549. var _list = __webpack_require__(67);
  8550. var _list2 = _interopRequireDefault(_list);
  8551. var _background = __webpack_require__(37);
  8552. var _color = __webpack_require__(25);
  8553. var _font = __webpack_require__(39);
  8554. var _size = __webpack_require__(40);
  8555. var _bold = __webpack_require__(56);
  8556. var _bold2 = _interopRequireDefault(_bold);
  8557. var _italic = __webpack_require__(68);
  8558. var _italic2 = _interopRequireDefault(_italic);
  8559. var _link = __webpack_require__(26);
  8560. var _link2 = _interopRequireDefault(_link);
  8561. var _script = __webpack_require__(69);
  8562. var _script2 = _interopRequireDefault(_script);
  8563. var _strike = __webpack_require__(70);
  8564. var _strike2 = _interopRequireDefault(_strike);
  8565. var _underline = __webpack_require__(71);
  8566. var _underline2 = _interopRequireDefault(_underline);
  8567. var _image = __webpack_require__(72);
  8568. var _image2 = _interopRequireDefault(_image);
  8569. var _video = __webpack_require__(73);
  8570. var _video2 = _interopRequireDefault(_video);
  8571. var _code = __webpack_require__(13);
  8572. var _code2 = _interopRequireDefault(_code);
  8573. var _formula = __webpack_require__(74);
  8574. var _formula2 = _interopRequireDefault(_formula);
  8575. var _syntax = __webpack_require__(75);
  8576. var _syntax2 = _interopRequireDefault(_syntax);
  8577. var _toolbar = __webpack_require__(57);
  8578. var _toolbar2 = _interopRequireDefault(_toolbar);
  8579. var _icons = __webpack_require__(41);
  8580. var _icons2 = _interopRequireDefault(_icons);
  8581. var _picker = __webpack_require__(27);
  8582. var _picker2 = _interopRequireDefault(_picker);
  8583. var _colorPicker = __webpack_require__(59);
  8584. var _colorPicker2 = _interopRequireDefault(_colorPicker);
  8585. var _iconPicker = __webpack_require__(60);
  8586. var _iconPicker2 = _interopRequireDefault(_iconPicker);
  8587. var _tooltip = __webpack_require__(61);
  8588. var _tooltip2 = _interopRequireDefault(_tooltip);
  8589. var _bubble = __webpack_require__(108);
  8590. var _bubble2 = _interopRequireDefault(_bubble);
  8591. var _snow = __webpack_require__(62);
  8592. var _snow2 = _interopRequireDefault(_snow);
  8593. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8594. _core2.default.register({
  8595. 'attributors/attribute/direction': _direction.DirectionAttribute,
  8596. 'attributors/class/align': _align.AlignClass,
  8597. 'attributors/class/background': _background.BackgroundClass,
  8598. 'attributors/class/color': _color.ColorClass,
  8599. 'attributors/class/direction': _direction.DirectionClass,
  8600. 'attributors/class/font': _font.FontClass,
  8601. 'attributors/class/size': _size.SizeClass,
  8602. 'attributors/style/align': _align.AlignStyle,
  8603. 'attributors/style/background': _background.BackgroundStyle,
  8604. 'attributors/style/color': _color.ColorStyle,
  8605. 'attributors/style/direction': _direction.DirectionStyle,
  8606. 'attributors/style/font': _font.FontStyle,
  8607. 'attributors/style/size': _size.SizeStyle
  8608. }, true);
  8609. _core2.default.register({
  8610. 'formats/align': _align.AlignClass,
  8611. 'formats/direction': _direction.DirectionClass,
  8612. 'formats/indent': _indent.IndentClass,
  8613. 'formats/background': _background.BackgroundStyle,
  8614. 'formats/color': _color.ColorStyle,
  8615. 'formats/font': _font.FontClass,
  8616. 'formats/size': _size.SizeClass,
  8617. 'formats/blockquote': _blockquote2.default,
  8618. 'formats/code-block': _code2.default,
  8619. 'formats/header': _header2.default,
  8620. 'formats/list': _list2.default,
  8621. 'formats/bold': _bold2.default,
  8622. 'formats/code': _code.Code,
  8623. 'formats/italic': _italic2.default,
  8624. 'formats/link': _link2.default,
  8625. 'formats/script': _script2.default,
  8626. 'formats/strike': _strike2.default,
  8627. 'formats/underline': _underline2.default,
  8628. 'formats/image': _image2.default,
  8629. 'formats/video': _video2.default,
  8630. 'formats/list/item': _list.ListItem,
  8631. 'modules/formula': _formula2.default,
  8632. 'modules/syntax': _syntax2.default,
  8633. 'modules/toolbar': _toolbar2.default,
  8634. 'themes/bubble': _bubble2.default,
  8635. 'themes/snow': _snow2.default,
  8636. 'ui/icons': _icons2.default,
  8637. 'ui/picker': _picker2.default,
  8638. 'ui/icon-picker': _iconPicker2.default,
  8639. 'ui/color-picker': _colorPicker2.default,
  8640. 'ui/tooltip': _tooltip2.default
  8641. }, true);
  8642. exports.default = _core2.default;
  8643. /***/ }),
  8644. /* 64 */
  8645. /***/ (function(module, exports, __webpack_require__) {
  8646. "use strict";
  8647. Object.defineProperty(exports, "__esModule", {
  8648. value: true
  8649. });
  8650. exports.IndentClass = undefined;
  8651. 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; }; }();
  8652. 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); } };
  8653. var _parchment = __webpack_require__(0);
  8654. var _parchment2 = _interopRequireDefault(_parchment);
  8655. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8656. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8657. 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; }
  8658. 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; }
  8659. var IdentAttributor = function (_Parchment$Attributor) {
  8660. _inherits(IdentAttributor, _Parchment$Attributor);
  8661. function IdentAttributor() {
  8662. _classCallCheck(this, IdentAttributor);
  8663. return _possibleConstructorReturn(this, (IdentAttributor.__proto__ || Object.getPrototypeOf(IdentAttributor)).apply(this, arguments));
  8664. }
  8665. _createClass(IdentAttributor, [{
  8666. key: 'add',
  8667. value: function add(node, value) {
  8668. if (value === '+1' || value === '-1') {
  8669. var indent = this.value(node) || 0;
  8670. value = value === '+1' ? indent + 1 : indent - 1;
  8671. }
  8672. if (value === 0) {
  8673. this.remove(node);
  8674. return true;
  8675. } else {
  8676. return _get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'add', this).call(this, node, value);
  8677. }
  8678. }
  8679. }, {
  8680. key: 'canAdd',
  8681. value: function canAdd(node, value) {
  8682. return _get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'canAdd', this).call(this, node, value) || _get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'canAdd', this).call(this, node, parseInt(value));
  8683. }
  8684. }, {
  8685. key: 'value',
  8686. value: function value(node) {
  8687. return parseInt(_get(IdentAttributor.prototype.__proto__ || Object.getPrototypeOf(IdentAttributor.prototype), 'value', this).call(this, node)) || undefined; // Don't return NaN
  8688. }
  8689. }]);
  8690. return IdentAttributor;
  8691. }(_parchment2.default.Attributor.Class);
  8692. var IndentClass = new IdentAttributor('indent', 'ql-indent', {
  8693. scope: _parchment2.default.Scope.BLOCK,
  8694. whitelist: [1, 2, 3, 4, 5, 6, 7, 8]
  8695. });
  8696. exports.IndentClass = IndentClass;
  8697. /***/ }),
  8698. /* 65 */
  8699. /***/ (function(module, exports, __webpack_require__) {
  8700. "use strict";
  8701. Object.defineProperty(exports, "__esModule", {
  8702. value: true
  8703. });
  8704. var _block = __webpack_require__(4);
  8705. var _block2 = _interopRequireDefault(_block);
  8706. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8707. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8708. 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; }
  8709. 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; }
  8710. var Blockquote = function (_Block) {
  8711. _inherits(Blockquote, _Block);
  8712. function Blockquote() {
  8713. _classCallCheck(this, Blockquote);
  8714. return _possibleConstructorReturn(this, (Blockquote.__proto__ || Object.getPrototypeOf(Blockquote)).apply(this, arguments));
  8715. }
  8716. return Blockquote;
  8717. }(_block2.default);
  8718. Blockquote.blotName = 'blockquote';
  8719. Blockquote.tagName = 'blockquote';
  8720. exports.default = Blockquote;
  8721. /***/ }),
  8722. /* 66 */
  8723. /***/ (function(module, exports, __webpack_require__) {
  8724. "use strict";
  8725. Object.defineProperty(exports, "__esModule", {
  8726. value: true
  8727. });
  8728. 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; }; }();
  8729. var _block = __webpack_require__(4);
  8730. var _block2 = _interopRequireDefault(_block);
  8731. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8732. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8733. 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; }
  8734. 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; }
  8735. var Header = function (_Block) {
  8736. _inherits(Header, _Block);
  8737. function Header() {
  8738. _classCallCheck(this, Header);
  8739. return _possibleConstructorReturn(this, (Header.__proto__ || Object.getPrototypeOf(Header)).apply(this, arguments));
  8740. }
  8741. _createClass(Header, null, [{
  8742. key: 'formats',
  8743. value: function formats(domNode) {
  8744. return this.tagName.indexOf(domNode.tagName) + 1;
  8745. }
  8746. }]);
  8747. return Header;
  8748. }(_block2.default);
  8749. Header.blotName = 'header';
  8750. Header.tagName = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
  8751. exports.default = Header;
  8752. /***/ }),
  8753. /* 67 */
  8754. /***/ (function(module, exports, __webpack_require__) {
  8755. "use strict";
  8756. Object.defineProperty(exports, "__esModule", {
  8757. value: true
  8758. });
  8759. exports.default = exports.ListItem = undefined;
  8760. 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; }; }();
  8761. 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); } };
  8762. var _parchment = __webpack_require__(0);
  8763. var _parchment2 = _interopRequireDefault(_parchment);
  8764. var _block = __webpack_require__(4);
  8765. var _block2 = _interopRequireDefault(_block);
  8766. var _container = __webpack_require__(24);
  8767. var _container2 = _interopRequireDefault(_container);
  8768. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8769. 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; }
  8770. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8771. 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; }
  8772. 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; }
  8773. var ListItem = function (_Block) {
  8774. _inherits(ListItem, _Block);
  8775. function ListItem() {
  8776. _classCallCheck(this, ListItem);
  8777. return _possibleConstructorReturn(this, (ListItem.__proto__ || Object.getPrototypeOf(ListItem)).apply(this, arguments));
  8778. }
  8779. _createClass(ListItem, [{
  8780. key: 'format',
  8781. value: function format(name, value) {
  8782. if (name === List.blotName && !value) {
  8783. this.replaceWith(_parchment2.default.create(this.statics.scope));
  8784. } else {
  8785. _get(ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), 'format', this).call(this, name, value);
  8786. }
  8787. }
  8788. }, {
  8789. key: 'remove',
  8790. value: function remove() {
  8791. if (this.prev == null && this.next == null) {
  8792. this.parent.remove();
  8793. } else {
  8794. _get(ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), 'remove', this).call(this);
  8795. }
  8796. }
  8797. }, {
  8798. key: 'replaceWith',
  8799. value: function replaceWith(name, value) {
  8800. this.parent.isolate(this.offset(this.parent), this.length());
  8801. if (name === this.parent.statics.blotName) {
  8802. this.parent.replaceWith(name, value);
  8803. return this;
  8804. } else {
  8805. this.parent.unwrap();
  8806. return _get(ListItem.prototype.__proto__ || Object.getPrototypeOf(ListItem.prototype), 'replaceWith', this).call(this, name, value);
  8807. }
  8808. }
  8809. }], [{
  8810. key: 'formats',
  8811. value: function formats(domNode) {
  8812. return domNode.tagName === this.tagName ? undefined : _get(ListItem.__proto__ || Object.getPrototypeOf(ListItem), 'formats', this).call(this, domNode);
  8813. }
  8814. }]);
  8815. return ListItem;
  8816. }(_block2.default);
  8817. ListItem.blotName = 'list-item';
  8818. ListItem.tagName = 'LI';
  8819. var List = function (_Container) {
  8820. _inherits(List, _Container);
  8821. _createClass(List, null, [{
  8822. key: 'create',
  8823. value: function create(value) {
  8824. var tagName = value === 'ordered' ? 'OL' : 'UL';
  8825. var node = _get(List.__proto__ || Object.getPrototypeOf(List), 'create', this).call(this, tagName);
  8826. if (value === 'checked' || value === 'unchecked') {
  8827. node.setAttribute('data-checked', value === 'checked');
  8828. }
  8829. return node;
  8830. }
  8831. }, {
  8832. key: 'formats',
  8833. value: function formats(domNode) {
  8834. if (domNode.tagName === 'OL') return 'ordered';
  8835. if (domNode.tagName === 'UL') {
  8836. if (domNode.hasAttribute('data-checked')) {
  8837. return domNode.getAttribute('data-checked') === 'true' ? 'checked' : 'unchecked';
  8838. } else {
  8839. return 'bullet';
  8840. }
  8841. }
  8842. return undefined;
  8843. }
  8844. }]);
  8845. function List(domNode) {
  8846. _classCallCheck(this, List);
  8847. var _this2 = _possibleConstructorReturn(this, (List.__proto__ || Object.getPrototypeOf(List)).call(this, domNode));
  8848. var listEventHandler = function listEventHandler(e) {
  8849. if (e.target.parentNode !== domNode) return;
  8850. var format = _this2.statics.formats(domNode);
  8851. var blot = _parchment2.default.find(e.target);
  8852. if (format === 'checked') {
  8853. blot.format('list', 'unchecked');
  8854. } else if (format === 'unchecked') {
  8855. blot.format('list', 'checked');
  8856. }
  8857. };
  8858. domNode.addEventListener('touchstart', listEventHandler);
  8859. domNode.addEventListener('mousedown', listEventHandler);
  8860. return _this2;
  8861. }
  8862. _createClass(List, [{
  8863. key: 'format',
  8864. value: function format(name, value) {
  8865. if (this.children.length > 0) {
  8866. this.children.tail.format(name, value);
  8867. }
  8868. }
  8869. }, {
  8870. key: 'formats',
  8871. value: function formats() {
  8872. // We don't inherit from FormatBlot
  8873. return _defineProperty({}, this.statics.blotName, this.statics.formats(this.domNode));
  8874. }
  8875. }, {
  8876. key: 'insertBefore',
  8877. value: function insertBefore(blot, ref) {
  8878. if (blot instanceof ListItem) {
  8879. _get(List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), 'insertBefore', this).call(this, blot, ref);
  8880. } else {
  8881. var index = ref == null ? this.length() : ref.offset(this);
  8882. var after = this.split(index);
  8883. after.parent.insertBefore(blot, after);
  8884. }
  8885. }
  8886. }, {
  8887. key: 'optimize',
  8888. value: function optimize(context) {
  8889. _get(List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), 'optimize', this).call(this, context);
  8890. var next = this.next;
  8891. if (next != null && next.prev === this && next.statics.blotName === this.statics.blotName && next.domNode.tagName === this.domNode.tagName && next.domNode.getAttribute('data-checked') === this.domNode.getAttribute('data-checked')) {
  8892. next.moveChildren(this);
  8893. next.remove();
  8894. }
  8895. }
  8896. }, {
  8897. key: 'replace',
  8898. value: function replace(target) {
  8899. if (target.statics.blotName !== this.statics.blotName) {
  8900. var item = _parchment2.default.create(this.statics.defaultChild);
  8901. target.moveChildren(item);
  8902. this.appendChild(item);
  8903. }
  8904. _get(List.prototype.__proto__ || Object.getPrototypeOf(List.prototype), 'replace', this).call(this, target);
  8905. }
  8906. }]);
  8907. return List;
  8908. }(_container2.default);
  8909. List.blotName = 'list';
  8910. List.scope = _parchment2.default.Scope.BLOCK_BLOT;
  8911. List.tagName = ['OL', 'UL'];
  8912. List.defaultChild = 'list-item';
  8913. List.allowedChildren = [ListItem];
  8914. exports.ListItem = ListItem;
  8915. exports.default = List;
  8916. /***/ }),
  8917. /* 68 */
  8918. /***/ (function(module, exports, __webpack_require__) {
  8919. "use strict";
  8920. Object.defineProperty(exports, "__esModule", {
  8921. value: true
  8922. });
  8923. var _bold = __webpack_require__(56);
  8924. var _bold2 = _interopRequireDefault(_bold);
  8925. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8926. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8927. 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; }
  8928. 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; }
  8929. var Italic = function (_Bold) {
  8930. _inherits(Italic, _Bold);
  8931. function Italic() {
  8932. _classCallCheck(this, Italic);
  8933. return _possibleConstructorReturn(this, (Italic.__proto__ || Object.getPrototypeOf(Italic)).apply(this, arguments));
  8934. }
  8935. return Italic;
  8936. }(_bold2.default);
  8937. Italic.blotName = 'italic';
  8938. Italic.tagName = ['EM', 'I'];
  8939. exports.default = Italic;
  8940. /***/ }),
  8941. /* 69 */
  8942. /***/ (function(module, exports, __webpack_require__) {
  8943. "use strict";
  8944. Object.defineProperty(exports, "__esModule", {
  8945. value: true
  8946. });
  8947. 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; }; }();
  8948. 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); } };
  8949. var _inline = __webpack_require__(6);
  8950. var _inline2 = _interopRequireDefault(_inline);
  8951. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8952. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8953. 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; }
  8954. 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; }
  8955. var Script = function (_Inline) {
  8956. _inherits(Script, _Inline);
  8957. function Script() {
  8958. _classCallCheck(this, Script);
  8959. return _possibleConstructorReturn(this, (Script.__proto__ || Object.getPrototypeOf(Script)).apply(this, arguments));
  8960. }
  8961. _createClass(Script, null, [{
  8962. key: 'create',
  8963. value: function create(value) {
  8964. if (value === 'super') {
  8965. return document.createElement('sup');
  8966. } else if (value === 'sub') {
  8967. return document.createElement('sub');
  8968. } else {
  8969. return _get(Script.__proto__ || Object.getPrototypeOf(Script), 'create', this).call(this, value);
  8970. }
  8971. }
  8972. }, {
  8973. key: 'formats',
  8974. value: function formats(domNode) {
  8975. if (domNode.tagName === 'SUB') return 'sub';
  8976. if (domNode.tagName === 'SUP') return 'super';
  8977. return undefined;
  8978. }
  8979. }]);
  8980. return Script;
  8981. }(_inline2.default);
  8982. Script.blotName = 'script';
  8983. Script.tagName = ['SUB', 'SUP'];
  8984. exports.default = Script;
  8985. /***/ }),
  8986. /* 70 */
  8987. /***/ (function(module, exports, __webpack_require__) {
  8988. "use strict";
  8989. Object.defineProperty(exports, "__esModule", {
  8990. value: true
  8991. });
  8992. var _inline = __webpack_require__(6);
  8993. var _inline2 = _interopRequireDefault(_inline);
  8994. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8995. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8996. 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; }
  8997. 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; }
  8998. var Strike = function (_Inline) {
  8999. _inherits(Strike, _Inline);
  9000. function Strike() {
  9001. _classCallCheck(this, Strike);
  9002. return _possibleConstructorReturn(this, (Strike.__proto__ || Object.getPrototypeOf(Strike)).apply(this, arguments));
  9003. }
  9004. return Strike;
  9005. }(_inline2.default);
  9006. Strike.blotName = 'strike';
  9007. Strike.tagName = 'S';
  9008. exports.default = Strike;
  9009. /***/ }),
  9010. /* 71 */
  9011. /***/ (function(module, exports, __webpack_require__) {
  9012. "use strict";
  9013. Object.defineProperty(exports, "__esModule", {
  9014. value: true
  9015. });
  9016. var _inline = __webpack_require__(6);
  9017. var _inline2 = _interopRequireDefault(_inline);
  9018. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9019. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9020. 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; }
  9021. 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; }
  9022. var Underline = function (_Inline) {
  9023. _inherits(Underline, _Inline);
  9024. function Underline() {
  9025. _classCallCheck(this, Underline);
  9026. return _possibleConstructorReturn(this, (Underline.__proto__ || Object.getPrototypeOf(Underline)).apply(this, arguments));
  9027. }
  9028. return Underline;
  9029. }(_inline2.default);
  9030. Underline.blotName = 'underline';
  9031. Underline.tagName = 'U';
  9032. exports.default = Underline;
  9033. /***/ }),
  9034. /* 72 */
  9035. /***/ (function(module, exports, __webpack_require__) {
  9036. "use strict";
  9037. Object.defineProperty(exports, "__esModule", {
  9038. value: true
  9039. });
  9040. 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; }; }();
  9041. 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); } };
  9042. var _parchment = __webpack_require__(0);
  9043. var _parchment2 = _interopRequireDefault(_parchment);
  9044. var _link = __webpack_require__(26);
  9045. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9046. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9047. 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; }
  9048. 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; }
  9049. var ATTRIBUTES = ['alt', 'height', 'width'];
  9050. var Image = function (_Parchment$Embed) {
  9051. _inherits(Image, _Parchment$Embed);
  9052. function Image() {
  9053. _classCallCheck(this, Image);
  9054. return _possibleConstructorReturn(this, (Image.__proto__ || Object.getPrototypeOf(Image)).apply(this, arguments));
  9055. }
  9056. _createClass(Image, [{
  9057. key: 'format',
  9058. value: function format(name, value) {
  9059. if (ATTRIBUTES.indexOf(name) > -1) {
  9060. if (value) {
  9061. this.domNode.setAttribute(name, value);
  9062. } else {
  9063. this.domNode.removeAttribute(name);
  9064. }
  9065. } else {
  9066. _get(Image.prototype.__proto__ || Object.getPrototypeOf(Image.prototype), 'format', this).call(this, name, value);
  9067. }
  9068. }
  9069. }], [{
  9070. key: 'create',
  9071. value: function create(value) {
  9072. var node = _get(Image.__proto__ || Object.getPrototypeOf(Image), 'create', this).call(this, value);
  9073. if (typeof value === 'string') {
  9074. node.setAttribute('src', this.sanitize(value));
  9075. }
  9076. return node;
  9077. }
  9078. }, {
  9079. key: 'formats',
  9080. value: function formats(domNode) {
  9081. return ATTRIBUTES.reduce(function (formats, attribute) {
  9082. if (domNode.hasAttribute(attribute)) {
  9083. formats[attribute] = domNode.getAttribute(attribute);
  9084. }
  9085. return formats;
  9086. }, {});
  9087. }
  9088. }, {
  9089. key: 'match',
  9090. value: function match(url) {
  9091. return (/\.(jpe?g|gif|png)$/.test(url) || /^data:image\/.+;base64/.test(url)
  9092. );
  9093. }
  9094. }, {
  9095. key: 'sanitize',
  9096. value: function sanitize(url) {
  9097. return (0, _link.sanitize)(url, ['http', 'https', 'data']) ? url : '//:0';
  9098. }
  9099. }, {
  9100. key: 'value',
  9101. value: function value(domNode) {
  9102. return domNode.getAttribute('src');
  9103. }
  9104. }]);
  9105. return Image;
  9106. }(_parchment2.default.Embed);
  9107. Image.blotName = 'image';
  9108. Image.tagName = 'IMG';
  9109. exports.default = Image;
  9110. /***/ }),
  9111. /* 73 */
  9112. /***/ (function(module, exports, __webpack_require__) {
  9113. "use strict";
  9114. Object.defineProperty(exports, "__esModule", {
  9115. value: true
  9116. });
  9117. 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; }; }();
  9118. 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); } };
  9119. var _block = __webpack_require__(4);
  9120. var _link = __webpack_require__(26);
  9121. var _link2 = _interopRequireDefault(_link);
  9122. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9123. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9124. 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; }
  9125. 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; }
  9126. var ATTRIBUTES = ['height', 'width'];
  9127. var Video = function (_BlockEmbed) {
  9128. _inherits(Video, _BlockEmbed);
  9129. function Video() {
  9130. _classCallCheck(this, Video);
  9131. return _possibleConstructorReturn(this, (Video.__proto__ || Object.getPrototypeOf(Video)).apply(this, arguments));
  9132. }
  9133. _createClass(Video, [{
  9134. key: 'format',
  9135. value: function format(name, value) {
  9136. if (ATTRIBUTES.indexOf(name) > -1) {
  9137. if (value) {
  9138. this.domNode.setAttribute(name, value);
  9139. } else {
  9140. this.domNode.removeAttribute(name);
  9141. }
  9142. } else {
  9143. _get(Video.prototype.__proto__ || Object.getPrototypeOf(Video.prototype), 'format', this).call(this, name, value);
  9144. }
  9145. }
  9146. }], [{
  9147. key: 'create',
  9148. value: function create(value) {
  9149. var node = _get(Video.__proto__ || Object.getPrototypeOf(Video), 'create', this).call(this, value);
  9150. node.setAttribute('frameborder', '0');
  9151. node.setAttribute('allowfullscreen', true);
  9152. node.setAttribute('src', this.sanitize(value));
  9153. return node;
  9154. }
  9155. }, {
  9156. key: 'formats',
  9157. value: function formats(domNode) {
  9158. return ATTRIBUTES.reduce(function (formats, attribute) {
  9159. if (domNode.hasAttribute(attribute)) {
  9160. formats[attribute] = domNode.getAttribute(attribute);
  9161. }
  9162. return formats;
  9163. }, {});
  9164. }
  9165. }, {
  9166. key: 'sanitize',
  9167. value: function sanitize(url) {
  9168. return _link2.default.sanitize(url);
  9169. }
  9170. }, {
  9171. key: 'value',
  9172. value: function value(domNode) {
  9173. return domNode.getAttribute('src');
  9174. }
  9175. }]);
  9176. return Video;
  9177. }(_block.BlockEmbed);
  9178. Video.blotName = 'video';
  9179. Video.className = 'ql-video';
  9180. Video.tagName = 'IFRAME';
  9181. exports.default = Video;
  9182. /***/ }),
  9183. /* 74 */
  9184. /***/ (function(module, exports, __webpack_require__) {
  9185. "use strict";
  9186. Object.defineProperty(exports, "__esModule", {
  9187. value: true
  9188. });
  9189. exports.default = exports.FormulaBlot = undefined;
  9190. 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; }; }();
  9191. 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); } };
  9192. var _embed = __webpack_require__(35);
  9193. var _embed2 = _interopRequireDefault(_embed);
  9194. var _quill = __webpack_require__(5);
  9195. var _quill2 = _interopRequireDefault(_quill);
  9196. var _module = __webpack_require__(9);
  9197. var _module2 = _interopRequireDefault(_module);
  9198. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9199. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9200. 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; }
  9201. 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; }
  9202. var FormulaBlot = function (_Embed) {
  9203. _inherits(FormulaBlot, _Embed);
  9204. function FormulaBlot() {
  9205. _classCallCheck(this, FormulaBlot);
  9206. return _possibleConstructorReturn(this, (FormulaBlot.__proto__ || Object.getPrototypeOf(FormulaBlot)).apply(this, arguments));
  9207. }
  9208. _createClass(FormulaBlot, null, [{
  9209. key: 'create',
  9210. value: function create(value) {
  9211. var node = _get(FormulaBlot.__proto__ || Object.getPrototypeOf(FormulaBlot), 'create', this).call(this, value);
  9212. if (typeof value === 'string') {
  9213. window.katex.render(value, node, {
  9214. throwOnError: false,
  9215. errorColor: '#f00'
  9216. });
  9217. node.setAttribute('data-value', value);
  9218. }
  9219. return node;
  9220. }
  9221. }, {
  9222. key: 'value',
  9223. value: function value(domNode) {
  9224. return domNode.getAttribute('data-value');
  9225. }
  9226. }]);
  9227. return FormulaBlot;
  9228. }(_embed2.default);
  9229. FormulaBlot.blotName = 'formula';
  9230. FormulaBlot.className = 'ql-formula';
  9231. FormulaBlot.tagName = 'SPAN';
  9232. var Formula = function (_Module) {
  9233. _inherits(Formula, _Module);
  9234. _createClass(Formula, null, [{
  9235. key: 'register',
  9236. value: function register() {
  9237. _quill2.default.register(FormulaBlot, true);
  9238. }
  9239. }]);
  9240. function Formula() {
  9241. _classCallCheck(this, Formula);
  9242. var _this2 = _possibleConstructorReturn(this, (Formula.__proto__ || Object.getPrototypeOf(Formula)).call(this));
  9243. if (window.katex == null) {
  9244. throw new Error('Formula module requires KaTeX.');
  9245. }
  9246. return _this2;
  9247. }
  9248. return Formula;
  9249. }(_module2.default);
  9250. exports.FormulaBlot = FormulaBlot;
  9251. exports.default = Formula;
  9252. /***/ }),
  9253. /* 75 */
  9254. /***/ (function(module, exports, __webpack_require__) {
  9255. "use strict";
  9256. Object.defineProperty(exports, "__esModule", {
  9257. value: true
  9258. });
  9259. exports.default = exports.CodeToken = exports.CodeBlock = undefined;
  9260. 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; }; }();
  9261. 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); } };
  9262. var _parchment = __webpack_require__(0);
  9263. var _parchment2 = _interopRequireDefault(_parchment);
  9264. var _quill = __webpack_require__(5);
  9265. var _quill2 = _interopRequireDefault(_quill);
  9266. var _module = __webpack_require__(9);
  9267. var _module2 = _interopRequireDefault(_module);
  9268. var _code = __webpack_require__(13);
  9269. var _code2 = _interopRequireDefault(_code);
  9270. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9271. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9272. 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; }
  9273. 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; }
  9274. var SyntaxCodeBlock = function (_CodeBlock) {
  9275. _inherits(SyntaxCodeBlock, _CodeBlock);
  9276. function SyntaxCodeBlock() {
  9277. _classCallCheck(this, SyntaxCodeBlock);
  9278. return _possibleConstructorReturn(this, (SyntaxCodeBlock.__proto__ || Object.getPrototypeOf(SyntaxCodeBlock)).apply(this, arguments));
  9279. }
  9280. _createClass(SyntaxCodeBlock, [{
  9281. key: 'replaceWith',
  9282. value: function replaceWith(block) {
  9283. this.domNode.textContent = this.domNode.textContent;
  9284. this.attach();
  9285. _get(SyntaxCodeBlock.prototype.__proto__ || Object.getPrototypeOf(SyntaxCodeBlock.prototype), 'replaceWith', this).call(this, block);
  9286. }
  9287. }, {
  9288. key: 'highlight',
  9289. value: function highlight(_highlight) {
  9290. var text = this.domNode.textContent;
  9291. if (this.cachedText !== text) {
  9292. if (text.trim().length > 0 || this.cachedText == null) {
  9293. this.domNode.innerHTML = _highlight(text);
  9294. this.domNode.normalize();
  9295. this.attach();
  9296. }
  9297. this.cachedText = text;
  9298. }
  9299. }
  9300. }]);
  9301. return SyntaxCodeBlock;
  9302. }(_code2.default);
  9303. SyntaxCodeBlock.className = 'ql-syntax';
  9304. var CodeToken = new _parchment2.default.Attributor.Class('token', 'hljs', {
  9305. scope: _parchment2.default.Scope.INLINE
  9306. });
  9307. var Syntax = function (_Module) {
  9308. _inherits(Syntax, _Module);
  9309. _createClass(Syntax, null, [{
  9310. key: 'register',
  9311. value: function register() {
  9312. _quill2.default.register(CodeToken, true);
  9313. _quill2.default.register(SyntaxCodeBlock, true);
  9314. }
  9315. }]);
  9316. function Syntax(quill, options) {
  9317. _classCallCheck(this, Syntax);
  9318. var _this2 = _possibleConstructorReturn(this, (Syntax.__proto__ || Object.getPrototypeOf(Syntax)).call(this, quill, options));
  9319. if (typeof _this2.options.highlight !== 'function') {
  9320. throw new Error('Syntax module requires highlight.js. Please include the library on the page before Quill.');
  9321. }
  9322. var timer = null;
  9323. _this2.quill.on(_quill2.default.events.SCROLL_OPTIMIZE, function () {
  9324. clearTimeout(timer);
  9325. timer = setTimeout(function () {
  9326. _this2.highlight();
  9327. timer = null;
  9328. }, _this2.options.interval);
  9329. });
  9330. _this2.highlight();
  9331. return _this2;
  9332. }
  9333. _createClass(Syntax, [{
  9334. key: 'highlight',
  9335. value: function highlight() {
  9336. var _this3 = this;
  9337. if (this.quill.selection.composing) return;
  9338. this.quill.update(_quill2.default.sources.USER);
  9339. var range = this.quill.getSelection();
  9340. this.quill.scroll.descendants(SyntaxCodeBlock).forEach(function (code) {
  9341. code.highlight(_this3.options.highlight);
  9342. });
  9343. this.quill.update(_quill2.default.sources.SILENT);
  9344. if (range != null) {
  9345. this.quill.setSelection(range, _quill2.default.sources.SILENT);
  9346. }
  9347. }
  9348. }]);
  9349. return Syntax;
  9350. }(_module2.default);
  9351. Syntax.DEFAULTS = {
  9352. highlight: function () {
  9353. if (window.hljs == null) return null;
  9354. return function (text) {
  9355. var result = window.hljs.highlightAuto(text);
  9356. return result.value;
  9357. };
  9358. }(),
  9359. interval: 1000
  9360. };
  9361. exports.CodeBlock = SyntaxCodeBlock;
  9362. exports.CodeToken = CodeToken;
  9363. exports.default = Syntax;
  9364. /***/ }),
  9365. /* 76 */
  9366. /***/ (function(module, exports) {
  9367. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=3 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=3 x2=13 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=9 y1=4 y2=4></line> </svg>";
  9368. /***/ }),
  9369. /* 77 */
  9370. /***/ (function(module, exports) {
  9371. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=14 x2=4 y1=14 y2=14></line> <line class=ql-stroke x1=12 x2=6 y1=4 y2=4></line> </svg>";
  9372. /***/ }),
  9373. /* 78 */
  9374. /***/ (function(module, exports) {
  9375. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=15 x2=5 y1=14 y2=14></line> <line class=ql-stroke x1=15 x2=9 y1=4 y2=4></line> </svg>";
  9376. /***/ }),
  9377. /* 79 */
  9378. /***/ (function(module, exports) {
  9379. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=15 x2=3 y1=14 y2=14></line> <line class=ql-stroke x1=15 x2=3 y1=4 y2=4></line> </svg>";
  9380. /***/ }),
  9381. /* 80 */
  9382. /***/ (function(module, exports) {
  9383. module.exports = "<svg viewbox=\"0 0 18 18\"> <g class=\"ql-fill ql-color-label\"> <polygon points=\"6 6.868 6 6 5 6 5 7 5.942 7 6 6.868\"></polygon> <rect height=1 width=1 x=4 y=4></rect> <polygon points=\"6.817 5 6 5 6 6 6.38 6 6.817 5\"></polygon> <rect height=1 width=1 x=2 y=6></rect> <rect height=1 width=1 x=3 y=5></rect> <rect height=1 width=1 x=4 y=7></rect> <polygon points=\"4 11.439 4 11 3 11 3 12 3.755 12 4 11.439\"></polygon> <rect height=1 width=1 x=2 y=12></rect> <rect height=1 width=1 x=2 y=9></rect> <rect height=1 width=1 x=2 y=15></rect> <polygon points=\"4.63 10 4 10 4 11 4.192 11 4.63 10\"></polygon> <rect height=1 width=1 x=3 y=8></rect> <path d=M10.832,4.2L11,4.582V4H10.708A1.948,1.948,0,0,1,10.832,4.2Z></path> <path d=M7,4.582L7.168,4.2A1.929,1.929,0,0,1,7.292,4H7V4.582Z></path> <path d=M8,13H7.683l-0.351.8a1.933,1.933,0,0,1-.124.2H8V13Z></path> <rect height=1 width=1 x=12 y=2></rect> <rect height=1 width=1 x=11 y=3></rect> <path d=M9,3H8V3.282A1.985,1.985,0,0,1,9,3Z></path> <rect height=1 width=1 x=2 y=3></rect> <rect height=1 width=1 x=6 y=2></rect> <rect height=1 width=1 x=3 y=2></rect> <rect height=1 width=1 x=5 y=3></rect> <rect height=1 width=1 x=9 y=2></rect> <rect height=1 width=1 x=15 y=14></rect> <polygon points=\"13.447 10.174 13.469 10.225 13.472 10.232 13.808 11 14 11 14 10 13.37 10 13.447 10.174\"></polygon> <rect height=1 width=1 x=13 y=7></rect> <rect height=1 width=1 x=15 y=5></rect> <rect height=1 width=1 x=14 y=6></rect> <rect height=1 width=1 x=15 y=8></rect> <rect height=1 width=1 x=14 y=9></rect> <path d=M3.775,14H3v1H4V14.314A1.97,1.97,0,0,1,3.775,14Z></path> <rect height=1 width=1 x=14 y=3></rect> <polygon points=\"12 6.868 12 6 11.62 6 12 6.868\"></polygon> <rect height=1 width=1 x=15 y=2></rect> <rect height=1 width=1 x=12 y=5></rect> <rect height=1 width=1 x=13 y=4></rect> <polygon points=\"12.933 9 13 9 13 8 12.495 8 12.933 9\"></polygon> <rect height=1 width=1 x=9 y=14></rect> <rect height=1 width=1 x=8 y=15></rect> <path d=M6,14.926V15H7V14.316A1.993,1.993,0,0,1,6,14.926Z></path> <rect height=1 width=1 x=5 y=15></rect> <path d=M10.668,13.8L10.317,13H10v1h0.792A1.947,1.947,0,0,1,10.668,13.8Z></path> <rect height=1 width=1 x=11 y=15></rect> <path d=M14.332,12.2a1.99,1.99,0,0,1,.166.8H15V12H14.245Z></path> <rect height=1 width=1 x=14 y=15></rect> <rect height=1 width=1 x=15 y=11></rect> </g> <polyline class=ql-stroke points=\"5.5 13 9 5 12.5 13\"></polyline> <line class=ql-stroke x1=11.63 x2=6.38 y1=11 y2=11></line> </svg>";
  9384. /***/ }),
  9385. /* 81 */
  9386. /***/ (function(module, exports) {
  9387. module.exports = "<svg viewbox=\"0 0 18 18\"> <rect class=\"ql-fill ql-stroke\" height=3 width=3 x=4 y=5></rect> <rect class=\"ql-fill ql-stroke\" height=3 width=3 x=11 y=5></rect> <path class=\"ql-even ql-fill ql-stroke\" d=M7,8c0,4.031-3,5-3,5></path> <path class=\"ql-even ql-fill ql-stroke\" d=M14,8c0,4.031-3,5-3,5></path> </svg>";
  9388. /***/ }),
  9389. /* 82 */
  9390. /***/ (function(module, exports) {
  9391. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-stroke d=M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z></path> <path class=ql-stroke d=M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z></path> </svg>";
  9392. /***/ }),
  9393. /* 83 */
  9394. /***/ (function(module, exports) {
  9395. module.exports = "<svg class=\"\" viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=5 x2=13 y1=3 y2=3></line> <line class=ql-stroke x1=6 x2=9.35 y1=12 y2=3></line> <line class=ql-stroke x1=11 x2=15 y1=11 y2=15></line> <line class=ql-stroke x1=15 x2=11 y1=11 y2=15></line> <rect class=ql-fill height=1 rx=0.5 ry=0.5 width=7 x=2 y=14></rect> </svg>";
  9396. /***/ }),
  9397. /* 84 */
  9398. /***/ (function(module, exports) {
  9399. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=\"ql-color-label ql-stroke ql-transparent\" x1=3 x2=15 y1=15 y2=15></line> <polyline class=ql-stroke points=\"5.5 11 9 3 12.5 11\"></polyline> <line class=ql-stroke x1=11.63 x2=6.38 y1=9 y2=9></line> </svg>";
  9400. /***/ }),
  9401. /* 85 */
  9402. /***/ (function(module, exports) {
  9403. module.exports = "<svg viewbox=\"0 0 18 18\"> <polygon class=\"ql-stroke ql-fill\" points=\"3 11 5 9 3 7 3 11\"></polygon> <line class=\"ql-stroke ql-fill\" x1=15 x2=11 y1=4 y2=4></line> <path class=ql-fill d=M11,3a3,3,0,0,0,0,6h1V3H11Z></path> <rect class=ql-fill height=11 width=1 x=11 y=4></rect> <rect class=ql-fill height=11 width=1 x=13 y=4></rect> </svg>";
  9404. /***/ }),
  9405. /* 86 */
  9406. /***/ (function(module, exports) {
  9407. module.exports = "<svg viewbox=\"0 0 18 18\"> <polygon class=\"ql-stroke ql-fill\" points=\"15 12 13 10 15 8 15 12\"></polygon> <line class=\"ql-stroke ql-fill\" x1=9 x2=5 y1=4 y2=4></line> <path class=ql-fill d=M5,3A3,3,0,0,0,5,9H6V3H5Z></path> <rect class=ql-fill height=11 width=1 x=5 y=4></rect> <rect class=ql-fill height=11 width=1 x=7 y=4></rect> </svg>";
  9408. /***/ }),
  9409. /* 87 */
  9410. /***/ (function(module, exports) {
  9411. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M14,16H4a1,1,0,0,1,0-2H14A1,1,0,0,1,14,16Z /> <path class=ql-fill d=M14,4H4A1,1,0,0,1,4,2H14A1,1,0,0,1,14,4Z /> <rect class=ql-fill x=3 y=6 width=12 height=6 rx=1 ry=1 /> </svg>";
  9412. /***/ }),
  9413. /* 88 */
  9414. /***/ (function(module, exports) {
  9415. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M13,16H5a1,1,0,0,1,0-2h8A1,1,0,0,1,13,16Z /> <path class=ql-fill d=M13,4H5A1,1,0,0,1,5,2h8A1,1,0,0,1,13,4Z /> <rect class=ql-fill x=2 y=6 width=14 height=6 rx=1 ry=1 /> </svg>";
  9416. /***/ }),
  9417. /* 89 */
  9418. /***/ (function(module, exports) {
  9419. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M15,8H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,8Z /> <path class=ql-fill d=M15,12H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,12Z /> <path class=ql-fill d=M15,16H5a1,1,0,0,1,0-2H15A1,1,0,0,1,15,16Z /> <path class=ql-fill d=M15,4H5A1,1,0,0,1,5,2H15A1,1,0,0,1,15,4Z /> <rect class=ql-fill x=2 y=6 width=8 height=6 rx=1 ry=1 /> </svg>";
  9420. /***/ }),
  9421. /* 90 */
  9422. /***/ (function(module, exports) {
  9423. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M5,8H3A1,1,0,0,1,3,6H5A1,1,0,0,1,5,8Z /> <path class=ql-fill d=M5,12H3a1,1,0,0,1,0-2H5A1,1,0,0,1,5,12Z /> <path class=ql-fill d=M13,16H3a1,1,0,0,1,0-2H13A1,1,0,0,1,13,16Z /> <path class=ql-fill d=M13,4H3A1,1,0,0,1,3,2H13A1,1,0,0,1,13,4Z /> <rect class=ql-fill x=8 y=6 width=8 height=6 rx=1 ry=1 transform=\"translate(24 18) rotate(-180)\"/> </svg>";
  9424. /***/ }),
  9425. /* 91 */
  9426. /***/ (function(module, exports) {
  9427. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M11.759,2.482a2.561,2.561,0,0,0-3.53.607A7.656,7.656,0,0,0,6.8,6.2C6.109,9.188,5.275,14.677,4.15,14.927a1.545,1.545,0,0,0-1.3-.933A0.922,0.922,0,0,0,2,15.036S1.954,16,4.119,16s3.091-2.691,3.7-5.553c0.177-.826.36-1.726,0.554-2.6L8.775,6.2c0.381-1.421.807-2.521,1.306-2.676a1.014,1.014,0,0,0,1.02.56A0.966,0.966,0,0,0,11.759,2.482Z></path> <rect class=ql-fill height=1.6 rx=0.8 ry=0.8 width=5 x=5.15 y=6.2></rect> <path class=ql-fill d=M13.663,12.027a1.662,1.662,0,0,1,.266-0.276q0.193,0.069.456,0.138a2.1,2.1,0,0,0,.535.069,1.075,1.075,0,0,0,.767-0.3,1.044,1.044,0,0,0,.314-0.8,0.84,0.84,0,0,0-.238-0.619,0.8,0.8,0,0,0-.594-0.239,1.154,1.154,0,0,0-.781.3,4.607,4.607,0,0,0-.781,1q-0.091.15-.218,0.346l-0.246.38c-0.068-.288-0.137-0.582-0.212-0.885-0.459-1.847-2.494-.984-2.941-0.8-0.482.2-.353,0.647-0.094,0.529a0.869,0.869,0,0,1,1.281.585c0.217,0.751.377,1.436,0.527,2.038a5.688,5.688,0,0,1-.362.467,2.69,2.69,0,0,1-.264.271q-0.221-.08-0.471-0.147a2.029,2.029,0,0,0-.522-0.066,1.079,1.079,0,0,0-.768.3A1.058,1.058,0,0,0,9,15.131a0.82,0.82,0,0,0,.832.852,1.134,1.134,0,0,0,.787-0.3,5.11,5.11,0,0,0,.776-0.993q0.141-.219.215-0.34c0.046-.076.122-0.194,0.223-0.346a2.786,2.786,0,0,0,.918,1.726,2.582,2.582,0,0,0,2.376-.185c0.317-.181.212-0.565,0-0.494A0.807,0.807,0,0,1,14.176,15a5.159,5.159,0,0,1-.913-2.446l0,0Q13.487,12.24,13.663,12.027Z></path> </svg>";
  9428. /***/ }),
  9429. /* 92 */
  9430. /***/ (function(module, exports) {
  9431. module.exports = "<svg viewBox=\"0 0 18 18\"> <path class=ql-fill d=M10,4V14a1,1,0,0,1-2,0V10H3v4a1,1,0,0,1-2,0V4A1,1,0,0,1,3,4V8H8V4a1,1,0,0,1,2,0Zm6.06787,9.209H14.98975V7.59863a.54085.54085,0,0,0-.605-.60547h-.62744a1.01119,1.01119,0,0,0-.748.29688L11.645,8.56641a.5435.5435,0,0,0-.022.8584l.28613.30762a.53861.53861,0,0,0,.84717.0332l.09912-.08789a1.2137,1.2137,0,0,0,.2417-.35254h.02246s-.01123.30859-.01123.60547V13.209H12.041a.54085.54085,0,0,0-.605.60547v.43945a.54085.54085,0,0,0,.605.60547h4.02686a.54085.54085,0,0,0,.605-.60547v-.43945A.54085.54085,0,0,0,16.06787,13.209Z /> </svg>";
  9432. /***/ }),
  9433. /* 93 */
  9434. /***/ (function(module, exports) {
  9435. module.exports = "<svg viewBox=\"0 0 18 18\"> <path class=ql-fill d=M16.73975,13.81445v.43945a.54085.54085,0,0,1-.605.60547H11.855a.58392.58392,0,0,1-.64893-.60547V14.0127c0-2.90527,3.39941-3.42187,3.39941-4.55469a.77675.77675,0,0,0-.84717-.78125,1.17684,1.17684,0,0,0-.83594.38477c-.2749.26367-.561.374-.85791.13184l-.4292-.34082c-.30811-.24219-.38525-.51758-.1543-.81445a2.97155,2.97155,0,0,1,2.45361-1.17676,2.45393,2.45393,0,0,1,2.68408,2.40918c0,2.45312-3.1792,2.92676-3.27832,3.93848h2.79443A.54085.54085,0,0,1,16.73975,13.81445ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z /> </svg>";
  9436. /***/ }),
  9437. /* 94 */
  9438. /***/ (function(module, exports) {
  9439. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=7 x2=13 y1=4 y2=4></line> <line class=ql-stroke x1=5 x2=11 y1=14 y2=14></line> <line class=ql-stroke x1=8 x2=10 y1=14 y2=4></line> </svg>";
  9440. /***/ }),
  9441. /* 95 */
  9442. /***/ (function(module, exports) {
  9443. module.exports = "<svg viewbox=\"0 0 18 18\"> <rect class=ql-stroke height=10 width=12 x=3 y=4></rect> <circle class=ql-fill cx=6 cy=7 r=1></circle> <polyline class=\"ql-even ql-fill\" points=\"5 12 5 11 7 9 8 10 11 7 13 9 13 12 5 12\"></polyline> </svg>";
  9444. /***/ }),
  9445. /* 96 */
  9446. /***/ (function(module, exports) {
  9447. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=3 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=\"ql-fill ql-stroke\" points=\"3 7 3 11 5 9 3 7\"></polyline> </svg>";
  9448. /***/ }),
  9449. /* 97 */
  9450. /***/ (function(module, exports) {
  9451. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=3 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=ql-stroke points=\"5 7 5 11 3 9 5 7\"></polyline> </svg>";
  9452. /***/ }),
  9453. /* 98 */
  9454. /***/ (function(module, exports) {
  9455. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=7 x2=11 y1=7 y2=11></line> <path class=\"ql-even ql-stroke\" d=M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z></path> <path class=\"ql-even ql-stroke\" d=M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z></path> </svg>";
  9456. /***/ }),
  9457. /* 99 */
  9458. /***/ (function(module, exports) {
  9459. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=7 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=7 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=7 x2=15 y1=14 y2=14></line> <line class=\"ql-stroke ql-thin\" x1=2.5 x2=4.5 y1=5.5 y2=5.5></line> <path class=ql-fill d=M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z></path> <path class=\"ql-stroke ql-thin\" d=M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156></path> <path class=\"ql-stroke ql-thin\" d=M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109></path> </svg>";
  9460. /***/ }),
  9461. /* 100 */
  9462. /***/ (function(module, exports) {
  9463. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=6 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=6 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=6 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=3 y1=4 y2=4></line> <line class=ql-stroke x1=3 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=3 x2=3 y1=14 y2=14></line> </svg>";
  9464. /***/ }),
  9465. /* 101 */
  9466. /***/ (function(module, exports) {
  9467. module.exports = "<svg class=\"\" viewbox=\"0 0 18 18\"> <line class=ql-stroke x1=9 x2=15 y1=4 y2=4></line> <polyline class=ql-stroke points=\"3 4 4 5 6 3\"></polyline> <line class=ql-stroke x1=9 x2=15 y1=14 y2=14></line> <polyline class=ql-stroke points=\"3 14 4 15 6 13\"></polyline> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=ql-stroke points=\"3 9 4 10 6 8\"></polyline> </svg>";
  9468. /***/ }),
  9469. /* 102 */
  9470. /***/ (function(module, exports) {
  9471. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M15.5,15H13.861a3.858,3.858,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.921,1.921,0,0,0,12.021,11.7a0.50013,0.50013,0,1,0,.957.291h0a0.914,0.914,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.076-1.16971,1.86982-1.93971,2.43082A1.45639,1.45639,0,0,0,12,15.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,15Z /> <path class=ql-fill d=M9.65,5.241a1,1,0,0,0-1.409.108L6,7.964,3.759,5.349A1,1,0,0,0,2.192,6.59178Q2.21541,6.6213,2.241,6.649L4.684,9.5,2.241,12.35A1,1,0,0,0,3.71,13.70722q0.02557-.02768.049-0.05722L6,11.036,8.241,13.65a1,1,0,1,0,1.567-1.24277Q9.78459,12.3777,9.759,12.35L7.316,9.5,9.759,6.651A1,1,0,0,0,9.65,5.241Z /> </svg>";
  9472. /***/ }),
  9473. /* 103 */
  9474. /***/ (function(module, exports) {
  9475. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-fill d=M15.5,7H13.861a4.015,4.015,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.922,1.922,0,0,0,12.021,3.7a0.5,0.5,0,1,0,.957.291,0.917,0.917,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.077-1.164,1.925-1.934,2.486A1.423,1.423,0,0,0,12,7.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,7Z /> <path class=ql-fill d=M9.651,5.241a1,1,0,0,0-1.41.108L6,7.964,3.759,5.349a1,1,0,1,0-1.519,1.3L4.683,9.5,2.241,12.35a1,1,0,1,0,1.519,1.3L6,11.036,8.241,13.65a1,1,0,0,0,1.519-1.3L7.317,9.5,9.759,6.651A1,1,0,0,0,9.651,5.241Z /> </svg>";
  9476. /***/ }),
  9477. /* 104 */
  9478. /***/ (function(module, exports) {
  9479. module.exports = "<svg viewbox=\"0 0 18 18\"> <line class=\"ql-stroke ql-thin\" x1=15.5 x2=2.5 y1=8.5 y2=9.5></line> <path class=ql-fill d=M9.007,8C6.542,7.791,6,7.519,6,6.5,6,5.792,7.283,5,9,5c1.571,0,2.765.679,2.969,1.309a1,1,0,0,0,1.9-.617C13.356,4.106,11.354,3,9,3,6.2,3,4,4.538,4,6.5a3.2,3.2,0,0,0,.5,1.843Z></path> <path class=ql-fill d=M8.984,10C11.457,10.208,12,10.479,12,11.5c0,0.708-1.283,1.5-3,1.5-1.571,0-2.765-.679-2.969-1.309a1,1,0,1,0-1.9.617C4.644,13.894,6.646,15,9,15c2.8,0,5-1.538,5-3.5a3.2,3.2,0,0,0-.5-1.843Z></path> </svg>";
  9480. /***/ }),
  9481. /* 105 */
  9482. /***/ (function(module, exports) {
  9483. module.exports = "<svg viewbox=\"0 0 18 18\"> <path class=ql-stroke d=M5,3V9a4.012,4.012,0,0,0,4,4H9a4.012,4.012,0,0,0,4-4V3></path> <rect class=ql-fill height=1 rx=0.5 ry=0.5 width=12 x=3 y=15></rect> </svg>";
  9484. /***/ }),
  9485. /* 106 */
  9486. /***/ (function(module, exports) {
  9487. module.exports = "<svg viewbox=\"0 0 18 18\"> <rect class=ql-stroke height=12 width=12 x=3 y=3></rect> <rect class=ql-fill height=12 width=1 x=5 y=3></rect> <rect class=ql-fill height=12 width=1 x=12 y=3></rect> <rect class=ql-fill height=2 width=8 x=5 y=8></rect> <rect class=ql-fill height=1 width=3 x=3 y=5></rect> <rect class=ql-fill height=1 width=3 x=3 y=7></rect> <rect class=ql-fill height=1 width=3 x=3 y=10></rect> <rect class=ql-fill height=1 width=3 x=3 y=12></rect> <rect class=ql-fill height=1 width=3 x=12 y=5></rect> <rect class=ql-fill height=1 width=3 x=12 y=7></rect> <rect class=ql-fill height=1 width=3 x=12 y=10></rect> <rect class=ql-fill height=1 width=3 x=12 y=12></rect> </svg>";
  9488. /***/ }),
  9489. /* 107 */
  9490. /***/ (function(module, exports) {
  9491. module.exports = "<svg viewbox=\"0 0 18 18\"> <polygon class=ql-stroke points=\"7 11 9 13 11 11 7 11\"></polygon> <polygon class=ql-stroke points=\"7 7 9 5 11 7 7 7\"></polygon> </svg>";
  9492. /***/ }),
  9493. /* 108 */
  9494. /***/ (function(module, exports, __webpack_require__) {
  9495. "use strict";
  9496. Object.defineProperty(exports, "__esModule", {
  9497. value: true
  9498. });
  9499. exports.default = exports.BubbleTooltip = undefined;
  9500. 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); } };
  9501. 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; }; }();
  9502. var _extend = __webpack_require__(3);
  9503. var _extend2 = _interopRequireDefault(_extend);
  9504. var _emitter = __webpack_require__(8);
  9505. var _emitter2 = _interopRequireDefault(_emitter);
  9506. var _base = __webpack_require__(43);
  9507. var _base2 = _interopRequireDefault(_base);
  9508. var _selection = __webpack_require__(15);
  9509. var _icons = __webpack_require__(41);
  9510. var _icons2 = _interopRequireDefault(_icons);
  9511. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9512. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9513. 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; }
  9514. 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; }
  9515. var TOOLBAR_CONFIG = [['bold', 'italic', 'link'], [{ header: 1 }, { header: 2 }, 'blockquote']];
  9516. var BubbleTheme = function (_BaseTheme) {
  9517. _inherits(BubbleTheme, _BaseTheme);
  9518. function BubbleTheme(quill, options) {
  9519. _classCallCheck(this, BubbleTheme);
  9520. if (options.modules.toolbar != null && options.modules.toolbar.container == null) {
  9521. options.modules.toolbar.container = TOOLBAR_CONFIG;
  9522. }
  9523. var _this = _possibleConstructorReturn(this, (BubbleTheme.__proto__ || Object.getPrototypeOf(BubbleTheme)).call(this, quill, options));
  9524. _this.quill.container.classList.add('ql-bubble');
  9525. return _this;
  9526. }
  9527. _createClass(BubbleTheme, [{
  9528. key: 'extendToolbar',
  9529. value: function extendToolbar(toolbar) {
  9530. this.tooltip = new BubbleTooltip(this.quill, this.options.bounds);
  9531. this.tooltip.root.appendChild(toolbar.container);
  9532. this.buildButtons([].slice.call(toolbar.container.querySelectorAll('button')), _icons2.default);
  9533. this.buildPickers([].slice.call(toolbar.container.querySelectorAll('select')), _icons2.default);
  9534. }
  9535. }]);
  9536. return BubbleTheme;
  9537. }(_base2.default);
  9538. BubbleTheme.DEFAULTS = (0, _extend2.default)(true, {}, _base2.default.DEFAULTS, {
  9539. modules: {
  9540. toolbar: {
  9541. handlers: {
  9542. link: function link(value) {
  9543. if (!value) {
  9544. this.quill.format('link', false);
  9545. } else {
  9546. this.quill.theme.tooltip.edit();
  9547. }
  9548. }
  9549. }
  9550. }
  9551. }
  9552. });
  9553. var BubbleTooltip = function (_BaseTooltip) {
  9554. _inherits(BubbleTooltip, _BaseTooltip);
  9555. function BubbleTooltip(quill, bounds) {
  9556. _classCallCheck(this, BubbleTooltip);
  9557. var _this2 = _possibleConstructorReturn(this, (BubbleTooltip.__proto__ || Object.getPrototypeOf(BubbleTooltip)).call(this, quill, bounds));
  9558. _this2.quill.on(_emitter2.default.events.EDITOR_CHANGE, function (type, range, oldRange, source) {
  9559. if (type !== _emitter2.default.events.SELECTION_CHANGE) return;
  9560. if (range != null && range.length > 0 && source === _emitter2.default.sources.USER) {
  9561. _this2.show();
  9562. // Lock our width so we will expand beyond our offsetParent boundaries
  9563. _this2.root.style.left = '0px';
  9564. _this2.root.style.width = '';
  9565. _this2.root.style.width = _this2.root.offsetWidth + 'px';
  9566. var lines = _this2.quill.getLines(range.index, range.length);
  9567. if (lines.length === 1) {
  9568. _this2.position(_this2.quill.getBounds(range));
  9569. } else {
  9570. var lastLine = lines[lines.length - 1];
  9571. var index = _this2.quill.getIndex(lastLine);
  9572. var length = Math.min(lastLine.length() - 1, range.index + range.length - index);
  9573. var _bounds = _this2.quill.getBounds(new _selection.Range(index, length));
  9574. _this2.position(_bounds);
  9575. }
  9576. } else if (document.activeElement !== _this2.textbox && _this2.quill.hasFocus()) {
  9577. _this2.hide();
  9578. }
  9579. });
  9580. return _this2;
  9581. }
  9582. _createClass(BubbleTooltip, [{
  9583. key: 'listen',
  9584. value: function listen() {
  9585. var _this3 = this;
  9586. _get(BubbleTooltip.prototype.__proto__ || Object.getPrototypeOf(BubbleTooltip.prototype), 'listen', this).call(this);
  9587. this.root.querySelector('.ql-close').addEventListener('click', function () {
  9588. _this3.root.classList.remove('ql-editing');
  9589. });
  9590. this.quill.on(_emitter2.default.events.SCROLL_OPTIMIZE, function () {
  9591. // Let selection be restored by toolbar handlers before repositioning
  9592. setTimeout(function () {
  9593. if (_this3.root.classList.contains('ql-hidden')) return;
  9594. var range = _this3.quill.getSelection();
  9595. if (range != null) {
  9596. _this3.position(_this3.quill.getBounds(range));
  9597. }
  9598. }, 1);
  9599. });
  9600. }
  9601. }, {
  9602. key: 'cancel',
  9603. value: function cancel() {
  9604. this.show();
  9605. }
  9606. }, {
  9607. key: 'position',
  9608. value: function position(reference) {
  9609. var shift = _get(BubbleTooltip.prototype.__proto__ || Object.getPrototypeOf(BubbleTooltip.prototype), 'position', this).call(this, reference);
  9610. var arrow = this.root.querySelector('.ql-tooltip-arrow');
  9611. arrow.style.marginLeft = '';
  9612. if (shift === 0) return shift;
  9613. arrow.style.marginLeft = -1 * shift - arrow.offsetWidth / 2 + 'px';
  9614. }
  9615. }]);
  9616. return BubbleTooltip;
  9617. }(_base.BaseTooltip);
  9618. BubbleTooltip.TEMPLATE = ['<span class="ql-tooltip-arrow"></span>', '<div class="ql-tooltip-editor">', '<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">', '<a class="ql-close"></a>', '</div>'].join('');
  9619. exports.BubbleTooltip = BubbleTooltip;
  9620. exports.default = BubbleTheme;
  9621. /***/ }),
  9622. /* 109 */
  9623. /***/ (function(module, exports, __webpack_require__) {
  9624. module.exports = __webpack_require__(63);
  9625. /***/ })
  9626. /******/ ])["default"];
  9627. });