summernote.js 320 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137
  1. /*!
  2. *
  3. * Super simple wysiwyg editor v0.8.16
  4. * https://summernote.org
  5. *
  6. *
  7. * Copyright 2013- Alan Hong. and other contributors
  8. * summernote may be freely distributed under the MIT license.
  9. *
  10. * Date: 2020-02-19T09:12Z
  11. *
  12. */
  13. (function webpackUniversalModuleDefinition(root, factory) {
  14. if(typeof exports === 'object' && typeof module === 'object')
  15. module.exports = factory(require("jquery"));
  16. else if(typeof define === 'function' && define.amd)
  17. define(["jquery"], factory);
  18. else {
  19. var a = typeof exports === 'object' ? factory(require("jquery")) : factory(root["jQuery"]);
  20. for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
  21. }
  22. })(window, function(__WEBPACK_EXTERNAL_MODULE__0__) {
  23. return /******/ (function(modules) { // webpackBootstrap
  24. /******/ // The module cache
  25. /******/ var installedModules = {};
  26. /******/
  27. /******/ // The require function
  28. /******/ function __webpack_require__(moduleId) {
  29. /******/
  30. /******/ // Check if module is in cache
  31. /******/ if(installedModules[moduleId]) {
  32. /******/ return installedModules[moduleId].exports;
  33. /******/ }
  34. /******/ // Create a new module (and put it into the cache)
  35. /******/ var module = installedModules[moduleId] = {
  36. /******/ i: moduleId,
  37. /******/ l: false,
  38. /******/ exports: {}
  39. /******/ };
  40. /******/
  41. /******/ // Execute the module function
  42. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  43. /******/
  44. /******/ // Flag the module as loaded
  45. /******/ module.l = true;
  46. /******/
  47. /******/ // Return the exports of the module
  48. /******/ return module.exports;
  49. /******/ }
  50. /******/
  51. /******/
  52. /******/ // expose the modules object (__webpack_modules__)
  53. /******/ __webpack_require__.m = modules;
  54. /******/
  55. /******/ // expose the module cache
  56. /******/ __webpack_require__.c = installedModules;
  57. /******/
  58. /******/ // define getter function for harmony exports
  59. /******/ __webpack_require__.d = function(exports, name, getter) {
  60. /******/ if(!__webpack_require__.o(exports, name)) {
  61. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  62. /******/ }
  63. /******/ };
  64. /******/
  65. /******/ // define __esModule on exports
  66. /******/ __webpack_require__.r = function(exports) {
  67. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  68. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  69. /******/ }
  70. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  71. /******/ };
  72. /******/
  73. /******/ // create a fake namespace object
  74. /******/ // mode & 1: value is a module id, require it
  75. /******/ // mode & 2: merge all properties of value into the ns
  76. /******/ // mode & 4: return value when already ns object
  77. /******/ // mode & 8|1: behave like require
  78. /******/ __webpack_require__.t = function(value, mode) {
  79. /******/ if(mode & 1) value = __webpack_require__(value);
  80. /******/ if(mode & 8) return value;
  81. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  82. /******/ var ns = Object.create(null);
  83. /******/ __webpack_require__.r(ns);
  84. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  85. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  86. /******/ return ns;
  87. /******/ };
  88. /******/
  89. /******/ // getDefaultExport function for compatibility with non-harmony modules
  90. /******/ __webpack_require__.n = function(module) {
  91. /******/ var getter = module && module.__esModule ?
  92. /******/ function getDefault() { return module['default']; } :
  93. /******/ function getModuleExports() { return module; };
  94. /******/ __webpack_require__.d(getter, 'a', getter);
  95. /******/ return getter;
  96. /******/ };
  97. /******/
  98. /******/ // Object.prototype.hasOwnProperty.call
  99. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  100. /******/
  101. /******/ // __webpack_public_path__
  102. /******/ __webpack_require__.p = "";
  103. /******/
  104. /******/
  105. /******/ // Load entry module and return exports
  106. /******/ return __webpack_require__(__webpack_require__.s = 53);
  107. /******/ })
  108. /************************************************************************/
  109. /******/ ({
  110. /***/ 0:
  111. /***/ (function(module, exports) {
  112. module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
  113. /***/ }),
  114. /***/ 1:
  115. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116. "use strict";
  117. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
  118. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
  119. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  120. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  121. 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); } }
  122. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  123. var Renderer =
  124. /*#__PURE__*/
  125. function () {
  126. function Renderer(markup, children, options, callback) {
  127. _classCallCheck(this, Renderer);
  128. this.markup = markup;
  129. this.children = children;
  130. this.options = options;
  131. this.callback = callback;
  132. }
  133. _createClass(Renderer, [{
  134. key: "render",
  135. value: function render($parent) {
  136. var $node = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this.markup);
  137. if (this.options && this.options.contents) {
  138. $node.html(this.options.contents);
  139. }
  140. if (this.options && this.options.className) {
  141. $node.addClass(this.options.className);
  142. }
  143. if (this.options && this.options.data) {
  144. jquery__WEBPACK_IMPORTED_MODULE_0___default.a.each(this.options.data, function (k, v) {
  145. $node.attr('data-' + k, v);
  146. });
  147. }
  148. if (this.options && this.options.click) {
  149. $node.on('click', this.options.click);
  150. }
  151. if (this.children) {
  152. var $container = $node.find('.note-children-container');
  153. this.children.forEach(function (child) {
  154. child.render($container.length ? $container : $node);
  155. });
  156. }
  157. if (this.callback) {
  158. this.callback($node, this.options);
  159. }
  160. if (this.options && this.options.callback) {
  161. this.options.callback($node);
  162. }
  163. if ($parent) {
  164. $parent.append($node);
  165. }
  166. return $node;
  167. }
  168. }]);
  169. return Renderer;
  170. }();
  171. /* harmony default export */ __webpack_exports__["a"] = ({
  172. create: function create(markup, callback) {
  173. return function () {
  174. var options = _typeof(arguments[1]) === 'object' ? arguments[1] : arguments[0];
  175. var children = Array.isArray(arguments[0]) ? arguments[0] : [];
  176. if (options && options.children) {
  177. children = options.children;
  178. }
  179. return new Renderer(markup, children, options, callback);
  180. };
  181. }
  182. });
  183. /***/ }),
  184. /***/ 2:
  185. /***/ (function(module, exports) {
  186. /* WEBPACK VAR INJECTION */(function(__webpack_amd_options__) {/* globals __webpack_amd_options__ */
  187. module.exports = __webpack_amd_options__;
  188. /* WEBPACK VAR INJECTION */}.call(this, {}))
  189. /***/ }),
  190. /***/ 3:
  191. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  192. "use strict";
  193. // EXTERNAL MODULE: external {"root":"jQuery","commonjs2":"jquery","commonjs":"jquery","amd":"jquery"}
  194. var external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_ = __webpack_require__(0);
  195. var external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default = /*#__PURE__*/__webpack_require__.n(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_);
  196. // CONCATENATED MODULE: ./src/js/base/summernote-en-US.js
  197. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote || {
  198. lang: {}
  199. };
  200. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.lang, {
  201. 'en-US': {
  202. font: {
  203. bold: 'Bold',
  204. italic: 'Italic',
  205. underline: 'Underline',
  206. clear: 'Remove Font Style',
  207. height: 'Line Height',
  208. name: 'Font Family',
  209. strikethrough: 'Strikethrough',
  210. subscript: 'Subscript',
  211. superscript: 'Superscript',
  212. size: 'Font Size',
  213. sizeunit: 'Font Size Unit'
  214. },
  215. image: {
  216. image: 'Picture',
  217. insert: 'Insert Image',
  218. resizeFull: 'Resize full',
  219. resizeHalf: 'Resize half',
  220. resizeQuarter: 'Resize quarter',
  221. resizeNone: 'Original size',
  222. floatLeft: 'Float Left',
  223. floatRight: 'Float Right',
  224. floatNone: 'Remove float',
  225. shapeRounded: 'Shape: Rounded',
  226. shapeCircle: 'Shape: Circle',
  227. shapeThumbnail: 'Shape: Thumbnail',
  228. shapeNone: 'Shape: None',
  229. dragImageHere: 'Drag image or text here',
  230. dropImage: 'Drop image or Text',
  231. selectFromFiles: 'Select from files',
  232. maximumFileSize: 'Maximum file size',
  233. maximumFileSizeError: 'Maximum file size exceeded.',
  234. url: 'Image URL',
  235. remove: 'Remove Image',
  236. original: 'Original'
  237. },
  238. video: {
  239. video: 'Video',
  240. videoLink: 'Video Link',
  241. insert: 'Insert Video',
  242. url: 'Video URL',
  243. providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion or Youku)'
  244. },
  245. link: {
  246. link: 'Link',
  247. insert: 'Insert Link',
  248. unlink: 'Unlink',
  249. edit: 'Edit',
  250. textToDisplay: 'Text to display',
  251. url: 'To what URL should this link go?',
  252. openInNewWindow: 'Open in new window',
  253. useProtocol: 'Use default protocol'
  254. },
  255. table: {
  256. table: 'Table',
  257. addRowAbove: 'Add row above',
  258. addRowBelow: 'Add row below',
  259. addColLeft: 'Add column left',
  260. addColRight: 'Add column right',
  261. delRow: 'Delete row',
  262. delCol: 'Delete column',
  263. delTable: 'Delete table'
  264. },
  265. hr: {
  266. insert: 'Insert Horizontal Rule'
  267. },
  268. style: {
  269. style: 'Style',
  270. p: 'Normal',
  271. blockquote: 'Quote',
  272. pre: 'Code',
  273. h1: 'Header 1',
  274. h2: 'Header 2',
  275. h3: 'Header 3',
  276. h4: 'Header 4',
  277. h5: 'Header 5',
  278. h6: 'Header 6'
  279. },
  280. lists: {
  281. unordered: 'Unordered list',
  282. ordered: 'Ordered list'
  283. },
  284. options: {
  285. help: 'Help',
  286. fullscreen: 'Full Screen',
  287. codeview: 'Code View'
  288. },
  289. paragraph: {
  290. paragraph: 'Paragraph',
  291. outdent: 'Outdent',
  292. indent: 'Indent',
  293. left: 'Align left',
  294. center: 'Align center',
  295. right: 'Align right',
  296. justify: 'Justify full'
  297. },
  298. color: {
  299. recent: 'Recent Color',
  300. more: 'More Color',
  301. background: 'Background Color',
  302. foreground: 'Text Color',
  303. transparent: 'Transparent',
  304. setTransparent: 'Set transparent',
  305. reset: 'Reset',
  306. resetToDefault: 'Reset to default',
  307. cpSelect: 'Select'
  308. },
  309. shortcut: {
  310. shortcuts: 'Keyboard shortcuts',
  311. close: 'Close',
  312. textFormatting: 'Text formatting',
  313. action: 'Action',
  314. paragraphFormatting: 'Paragraph formatting',
  315. documentStyle: 'Document Style',
  316. extraKeys: 'Extra keys'
  317. },
  318. help: {
  319. 'insertParagraph': 'Insert Paragraph',
  320. 'undo': 'Undoes the last command',
  321. 'redo': 'Redoes the last command',
  322. 'tab': 'Tab',
  323. 'untab': 'Untab',
  324. 'bold': 'Set a bold style',
  325. 'italic': 'Set a italic style',
  326. 'underline': 'Set a underline style',
  327. 'strikethrough': 'Set a strikethrough style',
  328. 'removeFormat': 'Clean a style',
  329. 'justifyLeft': 'Set left align',
  330. 'justifyCenter': 'Set center align',
  331. 'justifyRight': 'Set right align',
  332. 'justifyFull': 'Set full align',
  333. 'insertUnorderedList': 'Toggle unordered list',
  334. 'insertOrderedList': 'Toggle ordered list',
  335. 'outdent': 'Outdent on current paragraph',
  336. 'indent': 'Indent on current paragraph',
  337. 'formatPara': 'Change current block\'s format as a paragraph(P tag)',
  338. 'formatH1': 'Change current block\'s format as H1',
  339. 'formatH2': 'Change current block\'s format as H2',
  340. 'formatH3': 'Change current block\'s format as H3',
  341. 'formatH4': 'Change current block\'s format as H4',
  342. 'formatH5': 'Change current block\'s format as H5',
  343. 'formatH6': 'Change current block\'s format as H6',
  344. 'insertHorizontalRule': 'Insert horizontal rule',
  345. 'linkDialog.show': 'Show Link Dialog'
  346. },
  347. history: {
  348. undo: 'Undo',
  349. redo: 'Redo'
  350. },
  351. specialChar: {
  352. specialChar: 'SPECIAL CHARACTERS',
  353. select: 'Select Special characters'
  354. },
  355. output: {
  356. noSelection: 'No Selection Made!'
  357. }
  358. }
  359. });
  360. // CONCATENATED MODULE: ./src/js/base/core/env.js
  361. var isSupportAmd = typeof define === 'function' && __webpack_require__(2); // eslint-disable-line
  362. /**
  363. * returns whether font is installed or not.
  364. *
  365. * @param {String} fontName
  366. * @return {Boolean}
  367. */
  368. var genericFontFamilies = ['sans-serif', 'serif', 'monospace', 'cursive', 'fantasy'];
  369. function validFontName(fontName) {
  370. return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.inArray(fontName.toLowerCase(), genericFontFamilies) === -1 ? "'".concat(fontName, "'") : fontName;
  371. }
  372. function env_isFontInstalled(fontName) {
  373. var testFontName = fontName === 'Comic Sans MS' ? 'Courier New' : 'Comic Sans MS';
  374. var testText = 'mmmmmmmmmmwwwww';
  375. var testSize = '200px';
  376. var canvas = document.createElement('canvas');
  377. var context = canvas.getContext('2d');
  378. context.font = testSize + " '" + testFontName + "'";
  379. var originalWidth = context.measureText(testText).width;
  380. context.font = testSize + ' ' + validFontName(fontName) + ', "' + testFontName + '"';
  381. var width = context.measureText(testText).width;
  382. return originalWidth !== width;
  383. }
  384. var userAgent = navigator.userAgent;
  385. var isMSIE = /MSIE|Trident/i.test(userAgent);
  386. var browserVersion;
  387. if (isMSIE) {
  388. var matches = /MSIE (\d+[.]\d+)/.exec(userAgent);
  389. if (matches) {
  390. browserVersion = parseFloat(matches[1]);
  391. }
  392. matches = /Trident\/.*rv:([0-9]{1,}[.0-9]{0,})/.exec(userAgent);
  393. if (matches) {
  394. browserVersion = parseFloat(matches[1]);
  395. }
  396. }
  397. var isEdge = /Edge\/\d+/.test(userAgent);
  398. var hasCodeMirror = !!window.CodeMirror;
  399. var isSupportTouch = 'ontouchstart' in window || navigator.MaxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; // [workaround] IE doesn't have input events for contentEditable
  400. // - see: https://goo.gl/4bfIvA
  401. var inputEventName = isMSIE ? 'DOMCharacterDataModified DOMSubtreeModified DOMNodeInserted' : 'input';
  402. /**
  403. * @class core.env
  404. *
  405. * Object which check platform and agent
  406. *
  407. * @singleton
  408. * @alternateClassName env
  409. */
  410. /* harmony default export */ var env = ({
  411. isMac: navigator.appVersion.indexOf('Mac') > -1,
  412. isMSIE: isMSIE,
  413. isEdge: isEdge,
  414. isFF: !isEdge && /firefox/i.test(userAgent),
  415. isPhantom: /PhantomJS/i.test(userAgent),
  416. isWebkit: !isEdge && /webkit/i.test(userAgent),
  417. isChrome: !isEdge && /chrome/i.test(userAgent),
  418. isSafari: !isEdge && /safari/i.test(userAgent) && !/chrome/i.test(userAgent),
  419. browserVersion: browserVersion,
  420. jqueryVersion: parseFloat(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.fn.jquery),
  421. isSupportAmd: isSupportAmd,
  422. isSupportTouch: isSupportTouch,
  423. hasCodeMirror: hasCodeMirror,
  424. isFontInstalled: env_isFontInstalled,
  425. isW3CRangeSupport: !!document.createRange,
  426. inputEventName: inputEventName,
  427. genericFontFamilies: genericFontFamilies,
  428. validFontName: validFontName
  429. });
  430. // CONCATENATED MODULE: ./src/js/base/core/func.js
  431. /**
  432. * @class core.func
  433. *
  434. * func utils (for high-order func's arg)
  435. *
  436. * @singleton
  437. * @alternateClassName func
  438. */
  439. function eq(itemA) {
  440. return function (itemB) {
  441. return itemA === itemB;
  442. };
  443. }
  444. function eq2(itemA, itemB) {
  445. return itemA === itemB;
  446. }
  447. function peq2(propName) {
  448. return function (itemA, itemB) {
  449. return itemA[propName] === itemB[propName];
  450. };
  451. }
  452. function ok() {
  453. return true;
  454. }
  455. function fail() {
  456. return false;
  457. }
  458. function not(f) {
  459. return function () {
  460. return !f.apply(f, arguments);
  461. };
  462. }
  463. function and(fA, fB) {
  464. return function (item) {
  465. return fA(item) && fB(item);
  466. };
  467. }
  468. function func_self(a) {
  469. return a;
  470. }
  471. function func_invoke(obj, method) {
  472. return function () {
  473. return obj[method].apply(obj, arguments);
  474. };
  475. }
  476. var idCounter = 0;
  477. /**
  478. * reset globally-unique id
  479. *
  480. */
  481. function resetUniqueId() {
  482. idCounter = 0;
  483. }
  484. /**
  485. * generate a globally-unique id
  486. *
  487. * @param {String} [prefix]
  488. */
  489. function uniqueId(prefix) {
  490. var id = ++idCounter + '';
  491. return prefix ? prefix + id : id;
  492. }
  493. /**
  494. * returns bnd (bounds) from rect
  495. *
  496. * - IE Compatibility Issue: http://goo.gl/sRLOAo
  497. * - Scroll Issue: http://goo.gl/sNjUc
  498. *
  499. * @param {Rect} rect
  500. * @return {Object} bounds
  501. * @return {Number} bounds.top
  502. * @return {Number} bounds.left
  503. * @return {Number} bounds.width
  504. * @return {Number} bounds.height
  505. */
  506. function rect2bnd(rect) {
  507. var $document = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document);
  508. return {
  509. top: rect.top + $document.scrollTop(),
  510. left: rect.left + $document.scrollLeft(),
  511. width: rect.right - rect.left,
  512. height: rect.bottom - rect.top
  513. };
  514. }
  515. /**
  516. * returns a copy of the object where the keys have become the values and the values the keys.
  517. * @param {Object} obj
  518. * @return {Object}
  519. */
  520. function invertObject(obj) {
  521. var inverted = {};
  522. for (var key in obj) {
  523. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  524. inverted[obj[key]] = key;
  525. }
  526. }
  527. return inverted;
  528. }
  529. /**
  530. * @param {String} namespace
  531. * @param {String} [prefix]
  532. * @return {String}
  533. */
  534. function namespaceToCamel(namespace, prefix) {
  535. prefix = prefix || '';
  536. return prefix + namespace.split('.').map(function (name) {
  537. return name.substring(0, 1).toUpperCase() + name.substring(1);
  538. }).join('');
  539. }
  540. /**
  541. * Returns a function, that, as long as it continues to be invoked, will not
  542. * be triggered. The function will be called after it stops being called for
  543. * N milliseconds. If `immediate` is passed, trigger the function on the
  544. * leading edge, instead of the trailing.
  545. * @param {Function} func
  546. * @param {Number} wait
  547. * @param {Boolean} immediate
  548. * @return {Function}
  549. */
  550. function debounce(func, wait, immediate) {
  551. var timeout;
  552. return function () {
  553. var context = this;
  554. var args = arguments;
  555. var later = function later() {
  556. timeout = null;
  557. if (!immediate) {
  558. func.apply(context, args);
  559. }
  560. };
  561. var callNow = immediate && !timeout;
  562. clearTimeout(timeout);
  563. timeout = setTimeout(later, wait);
  564. if (callNow) {
  565. func.apply(context, args);
  566. }
  567. };
  568. }
  569. /**
  570. *
  571. * @param {String} url
  572. * @return {Boolean}
  573. */
  574. function isValidUrl(url) {
  575. var expression = /[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/gi;
  576. return expression.test(url);
  577. }
  578. /* harmony default export */ var func = ({
  579. eq: eq,
  580. eq2: eq2,
  581. peq2: peq2,
  582. ok: ok,
  583. fail: fail,
  584. self: func_self,
  585. not: not,
  586. and: and,
  587. invoke: func_invoke,
  588. resetUniqueId: resetUniqueId,
  589. uniqueId: uniqueId,
  590. rect2bnd: rect2bnd,
  591. invertObject: invertObject,
  592. namespaceToCamel: namespaceToCamel,
  593. debounce: debounce,
  594. isValidUrl: isValidUrl
  595. });
  596. // CONCATENATED MODULE: ./src/js/base/core/lists.js
  597. /**
  598. * returns the first item of an array.
  599. *
  600. * @param {Array} array
  601. */
  602. function lists_head(array) {
  603. return array[0];
  604. }
  605. /**
  606. * returns the last item of an array.
  607. *
  608. * @param {Array} array
  609. */
  610. function lists_last(array) {
  611. return array[array.length - 1];
  612. }
  613. /**
  614. * returns everything but the last entry of the array.
  615. *
  616. * @param {Array} array
  617. */
  618. function initial(array) {
  619. return array.slice(0, array.length - 1);
  620. }
  621. /**
  622. * returns the rest of the items in an array.
  623. *
  624. * @param {Array} array
  625. */
  626. function tail(array) {
  627. return array.slice(1);
  628. }
  629. /**
  630. * returns item of array
  631. */
  632. function find(array, pred) {
  633. for (var idx = 0, len = array.length; idx < len; idx++) {
  634. var item = array[idx];
  635. if (pred(item)) {
  636. return item;
  637. }
  638. }
  639. }
  640. /**
  641. * returns true if all of the values in the array pass the predicate truth test.
  642. */
  643. function lists_all(array, pred) {
  644. for (var idx = 0, len = array.length; idx < len; idx++) {
  645. if (!pred(array[idx])) {
  646. return false;
  647. }
  648. }
  649. return true;
  650. }
  651. /**
  652. * returns true if the value is present in the list.
  653. */
  654. function contains(array, item) {
  655. if (array && array.length && item) {
  656. if (array.indexOf) {
  657. return array.indexOf(item) !== -1;
  658. } else if (array.contains) {
  659. // `DOMTokenList` doesn't implement `.indexOf`, but it implements `.contains`
  660. return array.contains(item);
  661. }
  662. }
  663. return false;
  664. }
  665. /**
  666. * get sum from a list
  667. *
  668. * @param {Array} array - array
  669. * @param {Function} fn - iterator
  670. */
  671. function sum(array, fn) {
  672. fn = fn || func.self;
  673. return array.reduce(function (memo, v) {
  674. return memo + fn(v);
  675. }, 0);
  676. }
  677. /**
  678. * returns a copy of the collection with array type.
  679. * @param {Collection} collection - collection eg) node.childNodes, ...
  680. */
  681. function from(collection) {
  682. var result = [];
  683. var length = collection.length;
  684. var idx = -1;
  685. while (++idx < length) {
  686. result[idx] = collection[idx];
  687. }
  688. return result;
  689. }
  690. /**
  691. * returns whether list is empty or not
  692. */
  693. function lists_isEmpty(array) {
  694. return !array || !array.length;
  695. }
  696. /**
  697. * cluster elements by predicate function.
  698. *
  699. * @param {Array} array - array
  700. * @param {Function} fn - predicate function for cluster rule
  701. * @param {Array[]}
  702. */
  703. function clusterBy(array, fn) {
  704. if (!array.length) {
  705. return [];
  706. }
  707. var aTail = tail(array);
  708. return aTail.reduce(function (memo, v) {
  709. var aLast = lists_last(memo);
  710. if (fn(lists_last(aLast), v)) {
  711. aLast[aLast.length] = v;
  712. } else {
  713. memo[memo.length] = [v];
  714. }
  715. return memo;
  716. }, [[lists_head(array)]]);
  717. }
  718. /**
  719. * returns a copy of the array with all false values removed
  720. *
  721. * @param {Array} array - array
  722. * @param {Function} fn - predicate function for cluster rule
  723. */
  724. function compact(array) {
  725. var aResult = [];
  726. for (var idx = 0, len = array.length; idx < len; idx++) {
  727. if (array[idx]) {
  728. aResult.push(array[idx]);
  729. }
  730. }
  731. return aResult;
  732. }
  733. /**
  734. * produces a duplicate-free version of the array
  735. *
  736. * @param {Array} array
  737. */
  738. function unique(array) {
  739. var results = [];
  740. for (var idx = 0, len = array.length; idx < len; idx++) {
  741. if (!contains(results, array[idx])) {
  742. results.push(array[idx]);
  743. }
  744. }
  745. return results;
  746. }
  747. /**
  748. * returns next item.
  749. * @param {Array} array
  750. */
  751. function lists_next(array, item) {
  752. if (array && array.length && item) {
  753. var idx = array.indexOf(item);
  754. return idx === -1 ? null : array[idx + 1];
  755. }
  756. return null;
  757. }
  758. /**
  759. * returns prev item.
  760. * @param {Array} array
  761. */
  762. function prev(array, item) {
  763. if (array && array.length && item) {
  764. var idx = array.indexOf(item);
  765. return idx === -1 ? null : array[idx - 1];
  766. }
  767. return null;
  768. }
  769. /**
  770. * @class core.list
  771. *
  772. * list utils
  773. *
  774. * @singleton
  775. * @alternateClassName list
  776. */
  777. /* harmony default export */ var lists = ({
  778. head: lists_head,
  779. last: lists_last,
  780. initial: initial,
  781. tail: tail,
  782. prev: prev,
  783. next: lists_next,
  784. find: find,
  785. contains: contains,
  786. all: lists_all,
  787. sum: sum,
  788. from: from,
  789. isEmpty: lists_isEmpty,
  790. clusterBy: clusterBy,
  791. compact: compact,
  792. unique: unique
  793. });
  794. // CONCATENATED MODULE: ./src/js/base/core/dom.js
  795. var NBSP_CHAR = String.fromCharCode(160);
  796. var ZERO_WIDTH_NBSP_CHAR = "\uFEFF";
  797. /**
  798. * @method isEditable
  799. *
  800. * returns whether node is `note-editable` or not.
  801. *
  802. * @param {Node} node
  803. * @return {Boolean}
  804. */
  805. function isEditable(node) {
  806. return node && external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(node).hasClass('note-editable');
  807. }
  808. /**
  809. * @method isControlSizing
  810. *
  811. * returns whether node is `note-control-sizing` or not.
  812. *
  813. * @param {Node} node
  814. * @return {Boolean}
  815. */
  816. function isControlSizing(node) {
  817. return node && external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(node).hasClass('note-control-sizing');
  818. }
  819. /**
  820. * @method makePredByNodeName
  821. *
  822. * returns predicate which judge whether nodeName is same
  823. *
  824. * @param {String} nodeName
  825. * @return {Function}
  826. */
  827. function makePredByNodeName(nodeName) {
  828. nodeName = nodeName.toUpperCase();
  829. return function (node) {
  830. return node && node.nodeName.toUpperCase() === nodeName;
  831. };
  832. }
  833. /**
  834. * @method isText
  835. *
  836. *
  837. *
  838. * @param {Node} node
  839. * @return {Boolean} true if node's type is text(3)
  840. */
  841. function isText(node) {
  842. return node && node.nodeType === 3;
  843. }
  844. /**
  845. * @method isElement
  846. *
  847. *
  848. *
  849. * @param {Node} node
  850. * @return {Boolean} true if node's type is element(1)
  851. */
  852. function isElement(node) {
  853. return node && node.nodeType === 1;
  854. }
  855. /**
  856. * ex) br, col, embed, hr, img, input, ...
  857. * @see http://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
  858. */
  859. function isVoid(node) {
  860. return node && /^BR|^IMG|^HR|^IFRAME|^BUTTON|^INPUT|^AUDIO|^VIDEO|^EMBED/.test(node.nodeName.toUpperCase());
  861. }
  862. function isPara(node) {
  863. if (isEditable(node)) {
  864. return false;
  865. } // Chrome(v31.0), FF(v25.0.1) use DIV for paragraph
  866. return node && /^DIV|^P|^LI|^H[1-7]/.test(node.nodeName.toUpperCase());
  867. }
  868. function isHeading(node) {
  869. return node && /^H[1-7]/.test(node.nodeName.toUpperCase());
  870. }
  871. var isPre = makePredByNodeName('PRE');
  872. var isLi = makePredByNodeName('LI');
  873. function isPurePara(node) {
  874. return isPara(node) && !isLi(node);
  875. }
  876. var isTable = makePredByNodeName('TABLE');
  877. var isData = makePredByNodeName('DATA');
  878. function dom_isInline(node) {
  879. return !isBodyContainer(node) && !isList(node) && !isHr(node) && !isPara(node) && !isTable(node) && !isBlockquote(node) && !isData(node);
  880. }
  881. function isList(node) {
  882. return node && /^UL|^OL/.test(node.nodeName.toUpperCase());
  883. }
  884. var isHr = makePredByNodeName('HR');
  885. function dom_isCell(node) {
  886. return node && /^TD|^TH/.test(node.nodeName.toUpperCase());
  887. }
  888. var isBlockquote = makePredByNodeName('BLOCKQUOTE');
  889. function isBodyContainer(node) {
  890. return dom_isCell(node) || isBlockquote(node) || isEditable(node);
  891. }
  892. var isAnchor = makePredByNodeName('A');
  893. function isParaInline(node) {
  894. return dom_isInline(node) && !!dom_ancestor(node, isPara);
  895. }
  896. function isBodyInline(node) {
  897. return dom_isInline(node) && !dom_ancestor(node, isPara);
  898. }
  899. var isBody = makePredByNodeName('BODY');
  900. /**
  901. * returns whether nodeB is closest sibling of nodeA
  902. *
  903. * @param {Node} nodeA
  904. * @param {Node} nodeB
  905. * @return {Boolean}
  906. */
  907. function isClosestSibling(nodeA, nodeB) {
  908. return nodeA.nextSibling === nodeB || nodeA.previousSibling === nodeB;
  909. }
  910. /**
  911. * returns array of closest siblings with node
  912. *
  913. * @param {Node} node
  914. * @param {function} [pred] - predicate function
  915. * @return {Node[]}
  916. */
  917. function withClosestSiblings(node, pred) {
  918. pred = pred || func.ok;
  919. var siblings = [];
  920. if (node.previousSibling && pred(node.previousSibling)) {
  921. siblings.push(node.previousSibling);
  922. }
  923. siblings.push(node);
  924. if (node.nextSibling && pred(node.nextSibling)) {
  925. siblings.push(node.nextSibling);
  926. }
  927. return siblings;
  928. }
  929. /**
  930. * blank HTML for cursor position
  931. * - [workaround] old IE only works with &nbsp;
  932. * - [workaround] IE11 and other browser works with bogus br
  933. */
  934. var blankHTML = env.isMSIE && env.browserVersion < 11 ? '&nbsp;' : '<br>';
  935. /**
  936. * @method nodeLength
  937. *
  938. * returns #text's text size or element's childNodes size
  939. *
  940. * @param {Node} node
  941. */
  942. function nodeLength(node) {
  943. if (isText(node)) {
  944. return node.nodeValue.length;
  945. }
  946. if (node) {
  947. return node.childNodes.length;
  948. }
  949. return 0;
  950. }
  951. /**
  952. * returns whether deepest child node is empty or not.
  953. *
  954. * @param {Node} node
  955. * @return {Boolean}
  956. */
  957. function deepestChildIsEmpty(node) {
  958. do {
  959. if (node.firstElementChild === null || node.firstElementChild.innerHTML === '') break;
  960. } while (node = node.firstElementChild);
  961. return dom_isEmpty(node);
  962. }
  963. /**
  964. * returns whether node is empty or not.
  965. *
  966. * @param {Node} node
  967. * @return {Boolean}
  968. */
  969. function dom_isEmpty(node) {
  970. var len = nodeLength(node);
  971. if (len === 0) {
  972. return true;
  973. } else if (!isText(node) && len === 1 && node.innerHTML === blankHTML) {
  974. // ex) <p><br></p>, <span><br></span>
  975. return true;
  976. } else if (lists.all(node.childNodes, isText) && node.innerHTML === '') {
  977. // ex) <p></p>, <span></span>
  978. return true;
  979. }
  980. return false;
  981. }
  982. /**
  983. * padding blankHTML if node is empty (for cursor position)
  984. */
  985. function paddingBlankHTML(node) {
  986. if (!isVoid(node) && !nodeLength(node)) {
  987. node.innerHTML = blankHTML;
  988. }
  989. }
  990. /**
  991. * find nearest ancestor predicate hit
  992. *
  993. * @param {Node} node
  994. * @param {Function} pred - predicate function
  995. */
  996. function dom_ancestor(node, pred) {
  997. while (node) {
  998. if (pred(node)) {
  999. return node;
  1000. }
  1001. if (isEditable(node)) {
  1002. break;
  1003. }
  1004. node = node.parentNode;
  1005. }
  1006. return null;
  1007. }
  1008. /**
  1009. * find nearest ancestor only single child blood line and predicate hit
  1010. *
  1011. * @param {Node} node
  1012. * @param {Function} pred - predicate function
  1013. */
  1014. function singleChildAncestor(node, pred) {
  1015. node = node.parentNode;
  1016. while (node) {
  1017. if (nodeLength(node) !== 1) {
  1018. break;
  1019. }
  1020. if (pred(node)) {
  1021. return node;
  1022. }
  1023. if (isEditable(node)) {
  1024. break;
  1025. }
  1026. node = node.parentNode;
  1027. }
  1028. return null;
  1029. }
  1030. /**
  1031. * returns new array of ancestor nodes (until predicate hit).
  1032. *
  1033. * @param {Node} node
  1034. * @param {Function} [optional] pred - predicate function
  1035. */
  1036. function listAncestor(node, pred) {
  1037. pred = pred || func.fail;
  1038. var ancestors = [];
  1039. dom_ancestor(node, function (el) {
  1040. if (!isEditable(el)) {
  1041. ancestors.push(el);
  1042. }
  1043. return pred(el);
  1044. });
  1045. return ancestors;
  1046. }
  1047. /**
  1048. * find farthest ancestor predicate hit
  1049. */
  1050. function lastAncestor(node, pred) {
  1051. var ancestors = listAncestor(node);
  1052. return lists.last(ancestors.filter(pred));
  1053. }
  1054. /**
  1055. * returns common ancestor node between two nodes.
  1056. *
  1057. * @param {Node} nodeA
  1058. * @param {Node} nodeB
  1059. */
  1060. function dom_commonAncestor(nodeA, nodeB) {
  1061. var ancestors = listAncestor(nodeA);
  1062. for (var n = nodeB; n; n = n.parentNode) {
  1063. if (ancestors.indexOf(n) > -1) return n;
  1064. }
  1065. return null; // difference document area
  1066. }
  1067. /**
  1068. * listing all previous siblings (until predicate hit).
  1069. *
  1070. * @param {Node} node
  1071. * @param {Function} [optional] pred - predicate function
  1072. */
  1073. function listPrev(node, pred) {
  1074. pred = pred || func.fail;
  1075. var nodes = [];
  1076. while (node) {
  1077. if (pred(node)) {
  1078. break;
  1079. }
  1080. nodes.push(node);
  1081. node = node.previousSibling;
  1082. }
  1083. return nodes;
  1084. }
  1085. /**
  1086. * listing next siblings (until predicate hit).
  1087. *
  1088. * @param {Node} node
  1089. * @param {Function} [pred] - predicate function
  1090. */
  1091. function listNext(node, pred) {
  1092. pred = pred || func.fail;
  1093. var nodes = [];
  1094. while (node) {
  1095. if (pred(node)) {
  1096. break;
  1097. }
  1098. nodes.push(node);
  1099. node = node.nextSibling;
  1100. }
  1101. return nodes;
  1102. }
  1103. /**
  1104. * listing descendant nodes
  1105. *
  1106. * @param {Node} node
  1107. * @param {Function} [pred] - predicate function
  1108. */
  1109. function listDescendant(node, pred) {
  1110. var descendants = [];
  1111. pred = pred || func.ok; // start DFS(depth first search) with node
  1112. (function fnWalk(current) {
  1113. if (node !== current && pred(current)) {
  1114. descendants.push(current);
  1115. }
  1116. for (var idx = 0, len = current.childNodes.length; idx < len; idx++) {
  1117. fnWalk(current.childNodes[idx]);
  1118. }
  1119. })(node);
  1120. return descendants;
  1121. }
  1122. /**
  1123. * wrap node with new tag.
  1124. *
  1125. * @param {Node} node
  1126. * @param {Node} tagName of wrapper
  1127. * @return {Node} - wrapper
  1128. */
  1129. function wrap(node, wrapperName) {
  1130. var parent = node.parentNode;
  1131. var wrapper = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<' + wrapperName + '>')[0];
  1132. parent.insertBefore(wrapper, node);
  1133. wrapper.appendChild(node);
  1134. return wrapper;
  1135. }
  1136. /**
  1137. * insert node after preceding
  1138. *
  1139. * @param {Node} node
  1140. * @param {Node} preceding - predicate function
  1141. */
  1142. function insertAfter(node, preceding) {
  1143. var next = preceding.nextSibling;
  1144. var parent = preceding.parentNode;
  1145. if (next) {
  1146. parent.insertBefore(node, next);
  1147. } else {
  1148. parent.appendChild(node);
  1149. }
  1150. return node;
  1151. }
  1152. /**
  1153. * append elements.
  1154. *
  1155. * @param {Node} node
  1156. * @param {Collection} aChild
  1157. */
  1158. function appendChildNodes(node, aChild) {
  1159. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(aChild, function (idx, child) {
  1160. node.appendChild(child);
  1161. });
  1162. return node;
  1163. }
  1164. /**
  1165. * returns whether boundaryPoint is left edge or not.
  1166. *
  1167. * @param {BoundaryPoint} point
  1168. * @return {Boolean}
  1169. */
  1170. function isLeftEdgePoint(point) {
  1171. return point.offset === 0;
  1172. }
  1173. /**
  1174. * returns whether boundaryPoint is right edge or not.
  1175. *
  1176. * @param {BoundaryPoint} point
  1177. * @return {Boolean}
  1178. */
  1179. function isRightEdgePoint(point) {
  1180. return point.offset === nodeLength(point.node);
  1181. }
  1182. /**
  1183. * returns whether boundaryPoint is edge or not.
  1184. *
  1185. * @param {BoundaryPoint} point
  1186. * @return {Boolean}
  1187. */
  1188. function isEdgePoint(point) {
  1189. return isLeftEdgePoint(point) || isRightEdgePoint(point);
  1190. }
  1191. /**
  1192. * returns whether node is left edge of ancestor or not.
  1193. *
  1194. * @param {Node} node
  1195. * @param {Node} ancestor
  1196. * @return {Boolean}
  1197. */
  1198. function dom_isLeftEdgeOf(node, ancestor) {
  1199. while (node && node !== ancestor) {
  1200. if (dom_position(node) !== 0) {
  1201. return false;
  1202. }
  1203. node = node.parentNode;
  1204. }
  1205. return true;
  1206. }
  1207. /**
  1208. * returns whether node is right edge of ancestor or not.
  1209. *
  1210. * @param {Node} node
  1211. * @param {Node} ancestor
  1212. * @return {Boolean}
  1213. */
  1214. function isRightEdgeOf(node, ancestor) {
  1215. if (!ancestor) {
  1216. return false;
  1217. }
  1218. while (node && node !== ancestor) {
  1219. if (dom_position(node) !== nodeLength(node.parentNode) - 1) {
  1220. return false;
  1221. }
  1222. node = node.parentNode;
  1223. }
  1224. return true;
  1225. }
  1226. /**
  1227. * returns whether point is left edge of ancestor or not.
  1228. * @param {BoundaryPoint} point
  1229. * @param {Node} ancestor
  1230. * @return {Boolean}
  1231. */
  1232. function isLeftEdgePointOf(point, ancestor) {
  1233. return isLeftEdgePoint(point) && dom_isLeftEdgeOf(point.node, ancestor);
  1234. }
  1235. /**
  1236. * returns whether point is right edge of ancestor or not.
  1237. * @param {BoundaryPoint} point
  1238. * @param {Node} ancestor
  1239. * @return {Boolean}
  1240. */
  1241. function isRightEdgePointOf(point, ancestor) {
  1242. return isRightEdgePoint(point) && isRightEdgeOf(point.node, ancestor);
  1243. }
  1244. /**
  1245. * returns offset from parent.
  1246. *
  1247. * @param {Node} node
  1248. */
  1249. function dom_position(node) {
  1250. var offset = 0;
  1251. while (node = node.previousSibling) {
  1252. offset += 1;
  1253. }
  1254. return offset;
  1255. }
  1256. function hasChildren(node) {
  1257. return !!(node && node.childNodes && node.childNodes.length);
  1258. }
  1259. /**
  1260. * returns previous boundaryPoint
  1261. *
  1262. * @param {BoundaryPoint} point
  1263. * @param {Boolean} isSkipInnerOffset
  1264. * @return {BoundaryPoint}
  1265. */
  1266. function dom_prevPoint(point, isSkipInnerOffset) {
  1267. var node;
  1268. var offset;
  1269. if (point.offset === 0) {
  1270. if (isEditable(point.node)) {
  1271. return null;
  1272. }
  1273. node = point.node.parentNode;
  1274. offset = dom_position(point.node);
  1275. } else if (hasChildren(point.node)) {
  1276. node = point.node.childNodes[point.offset - 1];
  1277. offset = nodeLength(node);
  1278. } else {
  1279. node = point.node;
  1280. offset = isSkipInnerOffset ? 0 : point.offset - 1;
  1281. }
  1282. return {
  1283. node: node,
  1284. offset: offset
  1285. };
  1286. }
  1287. /**
  1288. * returns next boundaryPoint
  1289. *
  1290. * @param {BoundaryPoint} point
  1291. * @param {Boolean} isSkipInnerOffset
  1292. * @return {BoundaryPoint}
  1293. */
  1294. function dom_nextPoint(point, isSkipInnerOffset) {
  1295. var node, offset;
  1296. if (dom_isEmpty(point.node)) {
  1297. return null;
  1298. }
  1299. if (nodeLength(point.node) === point.offset) {
  1300. if (isEditable(point.node)) {
  1301. return null;
  1302. }
  1303. node = point.node.parentNode;
  1304. offset = dom_position(point.node) + 1;
  1305. } else if (hasChildren(point.node)) {
  1306. node = point.node.childNodes[point.offset];
  1307. offset = 0;
  1308. if (dom_isEmpty(node)) {
  1309. return null;
  1310. }
  1311. } else {
  1312. node = point.node;
  1313. offset = isSkipInnerOffset ? nodeLength(point.node) : point.offset + 1;
  1314. if (dom_isEmpty(node)) {
  1315. return null;
  1316. }
  1317. }
  1318. return {
  1319. node: node,
  1320. offset: offset
  1321. };
  1322. }
  1323. /**
  1324. * returns whether pointA and pointB is same or not.
  1325. *
  1326. * @param {BoundaryPoint} pointA
  1327. * @param {BoundaryPoint} pointB
  1328. * @return {Boolean}
  1329. */
  1330. function isSamePoint(pointA, pointB) {
  1331. return pointA.node === pointB.node && pointA.offset === pointB.offset;
  1332. }
  1333. /**
  1334. * returns whether point is visible (can set cursor) or not.
  1335. *
  1336. * @param {BoundaryPoint} point
  1337. * @return {Boolean}
  1338. */
  1339. function isVisiblePoint(point) {
  1340. if (isText(point.node) || !hasChildren(point.node) || dom_isEmpty(point.node)) {
  1341. return true;
  1342. }
  1343. var leftNode = point.node.childNodes[point.offset - 1];
  1344. var rightNode = point.node.childNodes[point.offset];
  1345. if ((!leftNode || isVoid(leftNode)) && (!rightNode || isVoid(rightNode))) {
  1346. return true;
  1347. }
  1348. return false;
  1349. }
  1350. /**
  1351. * @method prevPointUtil
  1352. *
  1353. * @param {BoundaryPoint} point
  1354. * @param {Function} pred
  1355. * @return {BoundaryPoint}
  1356. */
  1357. function prevPointUntil(point, pred) {
  1358. while (point) {
  1359. if (pred(point)) {
  1360. return point;
  1361. }
  1362. point = dom_prevPoint(point);
  1363. }
  1364. return null;
  1365. }
  1366. /**
  1367. * @method nextPointUntil
  1368. *
  1369. * @param {BoundaryPoint} point
  1370. * @param {Function} pred
  1371. * @return {BoundaryPoint}
  1372. */
  1373. function nextPointUntil(point, pred) {
  1374. while (point) {
  1375. if (pred(point)) {
  1376. return point;
  1377. }
  1378. point = dom_nextPoint(point);
  1379. }
  1380. return null;
  1381. }
  1382. /**
  1383. * returns whether point has character or not.
  1384. *
  1385. * @param {Point} point
  1386. * @return {Boolean}
  1387. */
  1388. function isCharPoint(point) {
  1389. if (!isText(point.node)) {
  1390. return false;
  1391. }
  1392. var ch = point.node.nodeValue.charAt(point.offset - 1);
  1393. return ch && ch !== ' ' && ch !== NBSP_CHAR;
  1394. }
  1395. /**
  1396. * returns whether point has space or not.
  1397. *
  1398. * @param {Point} point
  1399. * @return {Boolean}
  1400. */
  1401. function isSpacePoint(point) {
  1402. if (!isText(point.node)) {
  1403. return false;
  1404. }
  1405. var ch = point.node.nodeValue.charAt(point.offset - 1);
  1406. return ch === ' ' || ch === NBSP_CHAR;
  1407. }
  1408. /**
  1409. * @method walkPoint
  1410. *
  1411. * @param {BoundaryPoint} startPoint
  1412. * @param {BoundaryPoint} endPoint
  1413. * @param {Function} handler
  1414. * @param {Boolean} isSkipInnerOffset
  1415. */
  1416. function walkPoint(startPoint, endPoint, handler, isSkipInnerOffset) {
  1417. var point = startPoint;
  1418. while (point) {
  1419. handler(point);
  1420. if (isSamePoint(point, endPoint)) {
  1421. break;
  1422. }
  1423. var isSkipOffset = isSkipInnerOffset && startPoint.node !== point.node && endPoint.node !== point.node;
  1424. point = dom_nextPoint(point, isSkipOffset);
  1425. }
  1426. }
  1427. /**
  1428. * @method makeOffsetPath
  1429. *
  1430. * return offsetPath(array of offset) from ancestor
  1431. *
  1432. * @param {Node} ancestor - ancestor node
  1433. * @param {Node} node
  1434. */
  1435. function makeOffsetPath(ancestor, node) {
  1436. var ancestors = listAncestor(node, func.eq(ancestor));
  1437. return ancestors.map(dom_position).reverse();
  1438. }
  1439. /**
  1440. * @method fromOffsetPath
  1441. *
  1442. * return element from offsetPath(array of offset)
  1443. *
  1444. * @param {Node} ancestor - ancestor node
  1445. * @param {array} offsets - offsetPath
  1446. */
  1447. function fromOffsetPath(ancestor, offsets) {
  1448. var current = ancestor;
  1449. for (var i = 0, len = offsets.length; i < len; i++) {
  1450. if (current.childNodes.length <= offsets[i]) {
  1451. current = current.childNodes[current.childNodes.length - 1];
  1452. } else {
  1453. current = current.childNodes[offsets[i]];
  1454. }
  1455. }
  1456. return current;
  1457. }
  1458. /**
  1459. * @method splitNode
  1460. *
  1461. * split element or #text
  1462. *
  1463. * @param {BoundaryPoint} point
  1464. * @param {Object} [options]
  1465. * @param {Boolean} [options.isSkipPaddingBlankHTML] - default: false
  1466. * @param {Boolean} [options.isNotSplitEdgePoint] - default: false
  1467. * @param {Boolean} [options.isDiscardEmptySplits] - default: false
  1468. * @return {Node} right node of boundaryPoint
  1469. */
  1470. function splitNode(point, options) {
  1471. var isSkipPaddingBlankHTML = options && options.isSkipPaddingBlankHTML;
  1472. var isNotSplitEdgePoint = options && options.isNotSplitEdgePoint;
  1473. var isDiscardEmptySplits = options && options.isDiscardEmptySplits;
  1474. if (isDiscardEmptySplits) {
  1475. isSkipPaddingBlankHTML = true;
  1476. } // edge case
  1477. if (isEdgePoint(point) && (isText(point.node) || isNotSplitEdgePoint)) {
  1478. if (isLeftEdgePoint(point)) {
  1479. return point.node;
  1480. } else if (isRightEdgePoint(point)) {
  1481. return point.node.nextSibling;
  1482. }
  1483. } // split #text
  1484. if (isText(point.node)) {
  1485. return point.node.splitText(point.offset);
  1486. } else {
  1487. var childNode = point.node.childNodes[point.offset];
  1488. var clone = insertAfter(point.node.cloneNode(false), point.node);
  1489. appendChildNodes(clone, listNext(childNode));
  1490. if (!isSkipPaddingBlankHTML) {
  1491. paddingBlankHTML(point.node);
  1492. paddingBlankHTML(clone);
  1493. }
  1494. if (isDiscardEmptySplits) {
  1495. if (dom_isEmpty(point.node)) {
  1496. remove(point.node);
  1497. }
  1498. if (dom_isEmpty(clone)) {
  1499. remove(clone);
  1500. return point.node.nextSibling;
  1501. }
  1502. }
  1503. return clone;
  1504. }
  1505. }
  1506. /**
  1507. * @method splitTree
  1508. *
  1509. * split tree by point
  1510. *
  1511. * @param {Node} root - split root
  1512. * @param {BoundaryPoint} point
  1513. * @param {Object} [options]
  1514. * @param {Boolean} [options.isSkipPaddingBlankHTML] - default: false
  1515. * @param {Boolean} [options.isNotSplitEdgePoint] - default: false
  1516. * @return {Node} right node of boundaryPoint
  1517. */
  1518. function splitTree(root, point, options) {
  1519. // ex) [#text, <span>, <p>]
  1520. var ancestors = listAncestor(point.node, func.eq(root));
  1521. if (!ancestors.length) {
  1522. return null;
  1523. } else if (ancestors.length === 1) {
  1524. return splitNode(point, options);
  1525. }
  1526. return ancestors.reduce(function (node, parent) {
  1527. if (node === point.node) {
  1528. node = splitNode(point, options);
  1529. }
  1530. return splitNode({
  1531. node: parent,
  1532. offset: node ? dom_position(node) : nodeLength(parent)
  1533. }, options);
  1534. });
  1535. }
  1536. /**
  1537. * split point
  1538. *
  1539. * @param {Point} point
  1540. * @param {Boolean} isInline
  1541. * @return {Object}
  1542. */
  1543. function splitPoint(point, isInline) {
  1544. // find splitRoot, container
  1545. // - inline: splitRoot is a child of paragraph
  1546. // - block: splitRoot is a child of bodyContainer
  1547. var pred = isInline ? isPara : isBodyContainer;
  1548. var ancestors = listAncestor(point.node, pred);
  1549. var topAncestor = lists.last(ancestors) || point.node;
  1550. var splitRoot, container;
  1551. if (pred(topAncestor)) {
  1552. splitRoot = ancestors[ancestors.length - 2];
  1553. container = topAncestor;
  1554. } else {
  1555. splitRoot = topAncestor;
  1556. container = splitRoot.parentNode;
  1557. } // if splitRoot is exists, split with splitTree
  1558. var pivot = splitRoot && splitTree(splitRoot, point, {
  1559. isSkipPaddingBlankHTML: isInline,
  1560. isNotSplitEdgePoint: isInline
  1561. }); // if container is point.node, find pivot with point.offset
  1562. if (!pivot && container === point.node) {
  1563. pivot = point.node.childNodes[point.offset];
  1564. }
  1565. return {
  1566. rightNode: pivot,
  1567. container: container
  1568. };
  1569. }
  1570. function dom_create(nodeName) {
  1571. return document.createElement(nodeName);
  1572. }
  1573. function createText(text) {
  1574. return document.createTextNode(text);
  1575. }
  1576. /**
  1577. * @method remove
  1578. *
  1579. * remove node, (isRemoveChild: remove child or not)
  1580. *
  1581. * @param {Node} node
  1582. * @param {Boolean} isRemoveChild
  1583. */
  1584. function remove(node, isRemoveChild) {
  1585. if (!node || !node.parentNode) {
  1586. return;
  1587. }
  1588. if (node.removeNode) {
  1589. return node.removeNode(isRemoveChild);
  1590. }
  1591. var parent = node.parentNode;
  1592. if (!isRemoveChild) {
  1593. var nodes = [];
  1594. for (var i = 0, len = node.childNodes.length; i < len; i++) {
  1595. nodes.push(node.childNodes[i]);
  1596. }
  1597. for (var _i = 0, _len = nodes.length; _i < _len; _i++) {
  1598. parent.insertBefore(nodes[_i], node);
  1599. }
  1600. }
  1601. parent.removeChild(node);
  1602. }
  1603. /**
  1604. * @method removeWhile
  1605. *
  1606. * @param {Node} node
  1607. * @param {Function} pred
  1608. */
  1609. function removeWhile(node, pred) {
  1610. while (node) {
  1611. if (isEditable(node) || !pred(node)) {
  1612. break;
  1613. }
  1614. var parent = node.parentNode;
  1615. remove(node);
  1616. node = parent;
  1617. }
  1618. }
  1619. /**
  1620. * @method replace
  1621. *
  1622. * replace node with provided nodeName
  1623. *
  1624. * @param {Node} node
  1625. * @param {String} nodeName
  1626. * @return {Node} - new node
  1627. */
  1628. function dom_replace(node, nodeName) {
  1629. if (node.nodeName.toUpperCase() === nodeName.toUpperCase()) {
  1630. return node;
  1631. }
  1632. var newNode = dom_create(nodeName);
  1633. if (node.style.cssText) {
  1634. newNode.style.cssText = node.style.cssText;
  1635. }
  1636. appendChildNodes(newNode, lists.from(node.childNodes));
  1637. insertAfter(newNode, node);
  1638. remove(node);
  1639. return newNode;
  1640. }
  1641. var isTextarea = makePredByNodeName('TEXTAREA');
  1642. /**
  1643. * @param {jQuery} $node
  1644. * @param {Boolean} [stripLinebreaks] - default: false
  1645. */
  1646. function dom_value($node, stripLinebreaks) {
  1647. var val = isTextarea($node[0]) ? $node.val() : $node.html();
  1648. if (stripLinebreaks) {
  1649. return val.replace(/[\n\r]/g, '');
  1650. }
  1651. return val;
  1652. }
  1653. /**
  1654. * @method html
  1655. *
  1656. * get the HTML contents of node
  1657. *
  1658. * @param {jQuery} $node
  1659. * @param {Boolean} [isNewlineOnBlock]
  1660. */
  1661. function dom_html($node, isNewlineOnBlock) {
  1662. var markup = dom_value($node);
  1663. if (isNewlineOnBlock) {
  1664. var regexTag = /<(\/?)(\b(?!!)[^>\s]*)(.*?)(\s*\/?>)/g;
  1665. markup = markup.replace(regexTag, function (match, endSlash, name) {
  1666. name = name.toUpperCase();
  1667. var isEndOfInlineContainer = /^DIV|^TD|^TH|^P|^LI|^H[1-7]/.test(name) && !!endSlash;
  1668. var isBlockNode = /^BLOCKQUOTE|^TABLE|^TBODY|^TR|^HR|^UL|^OL/.test(name);
  1669. return match + (isEndOfInlineContainer || isBlockNode ? '\n' : '');
  1670. });
  1671. markup = markup.trim();
  1672. }
  1673. return markup;
  1674. }
  1675. function posFromPlaceholder(placeholder) {
  1676. var $placeholder = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(placeholder);
  1677. var pos = $placeholder.offset();
  1678. var height = $placeholder.outerHeight(true); // include margin
  1679. return {
  1680. left: pos.left,
  1681. top: pos.top + height
  1682. };
  1683. }
  1684. function attachEvents($node, events) {
  1685. Object.keys(events).forEach(function (key) {
  1686. $node.on(key, events[key]);
  1687. });
  1688. }
  1689. function detachEvents($node, events) {
  1690. Object.keys(events).forEach(function (key) {
  1691. $node.off(key, events[key]);
  1692. });
  1693. }
  1694. /**
  1695. * @method isCustomStyleTag
  1696. *
  1697. * assert if a node contains a "note-styletag" class,
  1698. * which implies that's a custom-made style tag node
  1699. *
  1700. * @param {Node} an HTML DOM node
  1701. */
  1702. function isCustomStyleTag(node) {
  1703. return node && !isText(node) && lists.contains(node.classList, 'note-styletag');
  1704. }
  1705. /* harmony default export */ var dom = ({
  1706. /** @property {String} NBSP_CHAR */
  1707. NBSP_CHAR: NBSP_CHAR,
  1708. /** @property {String} ZERO_WIDTH_NBSP_CHAR */
  1709. ZERO_WIDTH_NBSP_CHAR: ZERO_WIDTH_NBSP_CHAR,
  1710. /** @property {String} blank */
  1711. blank: blankHTML,
  1712. /** @property {String} emptyPara */
  1713. emptyPara: "<p>".concat(blankHTML, "</p>"),
  1714. makePredByNodeName: makePredByNodeName,
  1715. isEditable: isEditable,
  1716. isControlSizing: isControlSizing,
  1717. isText: isText,
  1718. isElement: isElement,
  1719. isVoid: isVoid,
  1720. isPara: isPara,
  1721. isPurePara: isPurePara,
  1722. isHeading: isHeading,
  1723. isInline: dom_isInline,
  1724. isBlock: func.not(dom_isInline),
  1725. isBodyInline: isBodyInline,
  1726. isBody: isBody,
  1727. isParaInline: isParaInline,
  1728. isPre: isPre,
  1729. isList: isList,
  1730. isTable: isTable,
  1731. isData: isData,
  1732. isCell: dom_isCell,
  1733. isBlockquote: isBlockquote,
  1734. isBodyContainer: isBodyContainer,
  1735. isAnchor: isAnchor,
  1736. isDiv: makePredByNodeName('DIV'),
  1737. isLi: isLi,
  1738. isBR: makePredByNodeName('BR'),
  1739. isSpan: makePredByNodeName('SPAN'),
  1740. isB: makePredByNodeName('B'),
  1741. isU: makePredByNodeName('U'),
  1742. isS: makePredByNodeName('S'),
  1743. isI: makePredByNodeName('I'),
  1744. isImg: makePredByNodeName('IMG'),
  1745. isTextarea: isTextarea,
  1746. deepestChildIsEmpty: deepestChildIsEmpty,
  1747. isEmpty: dom_isEmpty,
  1748. isEmptyAnchor: func.and(isAnchor, dom_isEmpty),
  1749. isClosestSibling: isClosestSibling,
  1750. withClosestSiblings: withClosestSiblings,
  1751. nodeLength: nodeLength,
  1752. isLeftEdgePoint: isLeftEdgePoint,
  1753. isRightEdgePoint: isRightEdgePoint,
  1754. isEdgePoint: isEdgePoint,
  1755. isLeftEdgeOf: dom_isLeftEdgeOf,
  1756. isRightEdgeOf: isRightEdgeOf,
  1757. isLeftEdgePointOf: isLeftEdgePointOf,
  1758. isRightEdgePointOf: isRightEdgePointOf,
  1759. prevPoint: dom_prevPoint,
  1760. nextPoint: dom_nextPoint,
  1761. isSamePoint: isSamePoint,
  1762. isVisiblePoint: isVisiblePoint,
  1763. prevPointUntil: prevPointUntil,
  1764. nextPointUntil: nextPointUntil,
  1765. isCharPoint: isCharPoint,
  1766. isSpacePoint: isSpacePoint,
  1767. walkPoint: walkPoint,
  1768. ancestor: dom_ancestor,
  1769. singleChildAncestor: singleChildAncestor,
  1770. listAncestor: listAncestor,
  1771. lastAncestor: lastAncestor,
  1772. listNext: listNext,
  1773. listPrev: listPrev,
  1774. listDescendant: listDescendant,
  1775. commonAncestor: dom_commonAncestor,
  1776. wrap: wrap,
  1777. insertAfter: insertAfter,
  1778. appendChildNodes: appendChildNodes,
  1779. position: dom_position,
  1780. hasChildren: hasChildren,
  1781. makeOffsetPath: makeOffsetPath,
  1782. fromOffsetPath: fromOffsetPath,
  1783. splitTree: splitTree,
  1784. splitPoint: splitPoint,
  1785. create: dom_create,
  1786. createText: createText,
  1787. remove: remove,
  1788. removeWhile: removeWhile,
  1789. replace: dom_replace,
  1790. html: dom_html,
  1791. value: dom_value,
  1792. posFromPlaceholder: posFromPlaceholder,
  1793. attachEvents: attachEvents,
  1794. detachEvents: detachEvents,
  1795. isCustomStyleTag: isCustomStyleTag
  1796. });
  1797. // CONCATENATED MODULE: ./src/js/base/Context.js
  1798. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1799. 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); } }
  1800. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  1801. var Context_Context =
  1802. /*#__PURE__*/
  1803. function () {
  1804. /**
  1805. * @param {jQuery} $note
  1806. * @param {Object} options
  1807. */
  1808. function Context($note, options) {
  1809. _classCallCheck(this, Context);
  1810. this.$note = $note;
  1811. this.memos = {};
  1812. this.modules = {};
  1813. this.layoutInfo = {};
  1814. this.options = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(true, {}, options); // init ui with options
  1815. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui_template(this.options);
  1816. this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
  1817. this.initialize();
  1818. }
  1819. /**
  1820. * create layout and initialize modules and other resources
  1821. */
  1822. _createClass(Context, [{
  1823. key: "initialize",
  1824. value: function initialize() {
  1825. this.layoutInfo = this.ui.createLayout(this.$note);
  1826. this._initialize();
  1827. this.$note.hide();
  1828. return this;
  1829. }
  1830. /**
  1831. * destroy modules and other resources and remove layout
  1832. */
  1833. }, {
  1834. key: "destroy",
  1835. value: function destroy() {
  1836. this._destroy();
  1837. this.$note.removeData('summernote');
  1838. this.ui.removeLayout(this.$note, this.layoutInfo);
  1839. }
  1840. /**
  1841. * destory modules and other resources and initialize it again
  1842. */
  1843. }, {
  1844. key: "reset",
  1845. value: function reset() {
  1846. var disabled = this.isDisabled();
  1847. this.code(dom.emptyPara);
  1848. this._destroy();
  1849. this._initialize();
  1850. if (disabled) {
  1851. this.disable();
  1852. }
  1853. }
  1854. }, {
  1855. key: "_initialize",
  1856. value: function _initialize() {
  1857. var _this = this;
  1858. // set own id
  1859. this.options.id = func.uniqueId(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.now()); // set default container for tooltips, popovers, and dialogs
  1860. this.options.container = this.options.container || this.layoutInfo.editor; // add optional buttons
  1861. var buttons = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend({}, this.options.buttons);
  1862. Object.keys(buttons).forEach(function (key) {
  1863. _this.memo('button.' + key, buttons[key]);
  1864. });
  1865. var modules = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend({}, this.options.modules, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.plugins || {}); // add and initialize modules
  1866. Object.keys(modules).forEach(function (key) {
  1867. _this.module(key, modules[key], true);
  1868. });
  1869. Object.keys(this.modules).forEach(function (key) {
  1870. _this.initializeModule(key);
  1871. });
  1872. }
  1873. }, {
  1874. key: "_destroy",
  1875. value: function _destroy() {
  1876. var _this2 = this;
  1877. // destroy modules with reversed order
  1878. Object.keys(this.modules).reverse().forEach(function (key) {
  1879. _this2.removeModule(key);
  1880. });
  1881. Object.keys(this.memos).forEach(function (key) {
  1882. _this2.removeMemo(key);
  1883. }); // trigger custom onDestroy callback
  1884. this.triggerEvent('destroy', this);
  1885. }
  1886. }, {
  1887. key: "code",
  1888. value: function code(html) {
  1889. var isActivated = this.invoke('codeview.isActivated');
  1890. if (html === undefined) {
  1891. this.invoke('codeview.sync');
  1892. return isActivated ? this.layoutInfo.codable.val() : this.layoutInfo.editable.html();
  1893. } else {
  1894. if (isActivated) {
  1895. this.layoutInfo.codable.val(html);
  1896. } else {
  1897. this.layoutInfo.editable.html(html);
  1898. }
  1899. this.$note.val(html);
  1900. this.triggerEvent('change', html, this.layoutInfo.editable);
  1901. }
  1902. }
  1903. }, {
  1904. key: "isDisabled",
  1905. value: function isDisabled() {
  1906. return this.layoutInfo.editable.attr('contenteditable') === 'false';
  1907. }
  1908. }, {
  1909. key: "enable",
  1910. value: function enable() {
  1911. this.layoutInfo.editable.attr('contenteditable', true);
  1912. this.invoke('toolbar.activate', true);
  1913. this.triggerEvent('disable', false);
  1914. this.options.editing = true;
  1915. }
  1916. }, {
  1917. key: "disable",
  1918. value: function disable() {
  1919. // close codeview if codeview is opend
  1920. if (this.invoke('codeview.isActivated')) {
  1921. this.invoke('codeview.deactivate');
  1922. }
  1923. this.layoutInfo.editable.attr('contenteditable', false);
  1924. this.options.editing = false;
  1925. this.invoke('toolbar.deactivate', true);
  1926. this.triggerEvent('disable', true);
  1927. }
  1928. }, {
  1929. key: "triggerEvent",
  1930. value: function triggerEvent() {
  1931. var namespace = lists.head(arguments);
  1932. var args = lists.tail(lists.from(arguments));
  1933. var callback = this.options.callbacks[func.namespaceToCamel(namespace, 'on')];
  1934. if (callback) {
  1935. callback.apply(this.$note[0], args);
  1936. }
  1937. this.$note.trigger('summernote.' + namespace, args);
  1938. }
  1939. }, {
  1940. key: "initializeModule",
  1941. value: function initializeModule(key) {
  1942. var module = this.modules[key];
  1943. module.shouldInitialize = module.shouldInitialize || func.ok;
  1944. if (!module.shouldInitialize()) {
  1945. return;
  1946. } // initialize module
  1947. if (module.initialize) {
  1948. module.initialize();
  1949. } // attach events
  1950. if (module.events) {
  1951. dom.attachEvents(this.$note, module.events);
  1952. }
  1953. }
  1954. }, {
  1955. key: "module",
  1956. value: function module(key, ModuleClass, withoutIntialize) {
  1957. if (arguments.length === 1) {
  1958. return this.modules[key];
  1959. }
  1960. this.modules[key] = new ModuleClass(this);
  1961. if (!withoutIntialize) {
  1962. this.initializeModule(key);
  1963. }
  1964. }
  1965. }, {
  1966. key: "removeModule",
  1967. value: function removeModule(key) {
  1968. var module = this.modules[key];
  1969. if (module.shouldInitialize()) {
  1970. if (module.events) {
  1971. dom.detachEvents(this.$note, module.events);
  1972. }
  1973. if (module.destroy) {
  1974. module.destroy();
  1975. }
  1976. }
  1977. delete this.modules[key];
  1978. }
  1979. }, {
  1980. key: "memo",
  1981. value: function memo(key, obj) {
  1982. if (arguments.length === 1) {
  1983. return this.memos[key];
  1984. }
  1985. this.memos[key] = obj;
  1986. }
  1987. }, {
  1988. key: "removeMemo",
  1989. value: function removeMemo(key) {
  1990. if (this.memos[key] && this.memos[key].destroy) {
  1991. this.memos[key].destroy();
  1992. }
  1993. delete this.memos[key];
  1994. }
  1995. /**
  1996. * Some buttons need to change their visual style immediately once they get pressed
  1997. */
  1998. }, {
  1999. key: "createInvokeHandlerAndUpdateState",
  2000. value: function createInvokeHandlerAndUpdateState(namespace, value) {
  2001. var _this3 = this;
  2002. return function (event) {
  2003. _this3.createInvokeHandler(namespace, value)(event);
  2004. _this3.invoke('buttons.updateCurrentStyle');
  2005. };
  2006. }
  2007. }, {
  2008. key: "createInvokeHandler",
  2009. value: function createInvokeHandler(namespace, value) {
  2010. var _this4 = this;
  2011. return function (event) {
  2012. event.preventDefault();
  2013. var $target = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(event.target);
  2014. _this4.invoke(namespace, value || $target.closest('[data-value]').data('value'), $target);
  2015. };
  2016. }
  2017. }, {
  2018. key: "invoke",
  2019. value: function invoke() {
  2020. var namespace = lists.head(arguments);
  2021. var args = lists.tail(lists.from(arguments));
  2022. var splits = namespace.split('.');
  2023. var hasSeparator = splits.length > 1;
  2024. var moduleName = hasSeparator && lists.head(splits);
  2025. var methodName = hasSeparator ? lists.last(splits) : lists.head(splits);
  2026. var module = this.modules[moduleName || 'editor'];
  2027. if (!moduleName && this[methodName]) {
  2028. return this[methodName].apply(this, args);
  2029. } else if (module && module[methodName] && module.shouldInitialize()) {
  2030. return module[methodName].apply(module, args);
  2031. }
  2032. }
  2033. }]);
  2034. return Context;
  2035. }();
  2036. // CONCATENATED MODULE: ./src/js/summernote.js
  2037. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.fn.extend({
  2038. /**
  2039. * Summernote API
  2040. *
  2041. * @param {Object|String}
  2042. * @return {this}
  2043. */
  2044. summernote: function summernote() {
  2045. var type = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.type(lists.head(arguments));
  2046. var isExternalAPICalled = type === 'string';
  2047. var hasInitOptions = type === 'object';
  2048. var options = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend({}, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.options, hasInitOptions ? lists.head(arguments) : {}); // Update options
  2049. options.langInfo = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(true, {}, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.lang['en-US'], external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.lang[options.lang]);
  2050. options.icons = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(true, {}, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.options.icons, options.icons);
  2051. options.tooltip = options.tooltip === 'auto' ? !env.isSupportTouch : options.tooltip;
  2052. this.each(function (idx, note) {
  2053. var $note = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(note);
  2054. if (!$note.data('summernote')) {
  2055. var context = new Context_Context($note, options);
  2056. $note.data('summernote', context);
  2057. $note.data('summernote').triggerEvent('init', context.layoutInfo);
  2058. }
  2059. });
  2060. var $note = this.first();
  2061. if ($note.length) {
  2062. var context = $note.data('summernote');
  2063. if (isExternalAPICalled) {
  2064. return context.invoke.apply(context, lists.from(arguments));
  2065. } else if (options.focus) {
  2066. context.invoke('editor.focus');
  2067. }
  2068. }
  2069. return this;
  2070. }
  2071. });
  2072. // CONCATENATED MODULE: ./src/js/base/core/range.js
  2073. function range_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2074. function range_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); } }
  2075. function range_createClass(Constructor, protoProps, staticProps) { if (protoProps) range_defineProperties(Constructor.prototype, protoProps); if (staticProps) range_defineProperties(Constructor, staticProps); return Constructor; }
  2076. /**
  2077. * return boundaryPoint from TextRange, inspired by Andy Na's HuskyRange.js
  2078. *
  2079. * @param {TextRange} textRange
  2080. * @param {Boolean} isStart
  2081. * @return {BoundaryPoint}
  2082. *
  2083. * @see http://msdn.microsoft.com/en-us/library/ie/ms535872(v=vs.85).aspx
  2084. */
  2085. function textRangeToPoint(textRange, isStart) {
  2086. var container = textRange.parentElement();
  2087. var offset;
  2088. var tester = document.body.createTextRange();
  2089. var prevContainer;
  2090. var childNodes = lists.from(container.childNodes);
  2091. for (offset = 0; offset < childNodes.length; offset++) {
  2092. if (dom.isText(childNodes[offset])) {
  2093. continue;
  2094. }
  2095. tester.moveToElementText(childNodes[offset]);
  2096. if (tester.compareEndPoints('StartToStart', textRange) >= 0) {
  2097. break;
  2098. }
  2099. prevContainer = childNodes[offset];
  2100. }
  2101. if (offset !== 0 && dom.isText(childNodes[offset - 1])) {
  2102. var textRangeStart = document.body.createTextRange();
  2103. var curTextNode = null;
  2104. textRangeStart.moveToElementText(prevContainer || container);
  2105. textRangeStart.collapse(!prevContainer);
  2106. curTextNode = prevContainer ? prevContainer.nextSibling : container.firstChild;
  2107. var pointTester = textRange.duplicate();
  2108. pointTester.setEndPoint('StartToStart', textRangeStart);
  2109. var textCount = pointTester.text.replace(/[\r\n]/g, '').length;
  2110. while (textCount > curTextNode.nodeValue.length && curTextNode.nextSibling) {
  2111. textCount -= curTextNode.nodeValue.length;
  2112. curTextNode = curTextNode.nextSibling;
  2113. } // [workaround] enforce IE to re-reference curTextNode, hack
  2114. var dummy = curTextNode.nodeValue; // eslint-disable-line
  2115. if (isStart && curTextNode.nextSibling && dom.isText(curTextNode.nextSibling) && textCount === curTextNode.nodeValue.length) {
  2116. textCount -= curTextNode.nodeValue.length;
  2117. curTextNode = curTextNode.nextSibling;
  2118. }
  2119. container = curTextNode;
  2120. offset = textCount;
  2121. }
  2122. return {
  2123. cont: container,
  2124. offset: offset
  2125. };
  2126. }
  2127. /**
  2128. * return TextRange from boundary point (inspired by google closure-library)
  2129. * @param {BoundaryPoint} point
  2130. * @return {TextRange}
  2131. */
  2132. function pointToTextRange(point) {
  2133. var textRangeInfo = function textRangeInfo(container, offset) {
  2134. var node, isCollapseToStart;
  2135. if (dom.isText(container)) {
  2136. var prevTextNodes = dom.listPrev(container, func.not(dom.isText));
  2137. var prevContainer = lists.last(prevTextNodes).previousSibling;
  2138. node = prevContainer || container.parentNode;
  2139. offset += lists.sum(lists.tail(prevTextNodes), dom.nodeLength);
  2140. isCollapseToStart = !prevContainer;
  2141. } else {
  2142. node = container.childNodes[offset] || container;
  2143. if (dom.isText(node)) {
  2144. return textRangeInfo(node, 0);
  2145. }
  2146. offset = 0;
  2147. isCollapseToStart = false;
  2148. }
  2149. return {
  2150. node: node,
  2151. collapseToStart: isCollapseToStart,
  2152. offset: offset
  2153. };
  2154. };
  2155. var textRange = document.body.createTextRange();
  2156. var info = textRangeInfo(point.node, point.offset);
  2157. textRange.moveToElementText(info.node);
  2158. textRange.collapse(info.collapseToStart);
  2159. textRange.moveStart('character', info.offset);
  2160. return textRange;
  2161. }
  2162. /**
  2163. * Wrapped Range
  2164. *
  2165. * @constructor
  2166. * @param {Node} sc - start container
  2167. * @param {Number} so - start offset
  2168. * @param {Node} ec - end container
  2169. * @param {Number} eo - end offset
  2170. */
  2171. var range_WrappedRange =
  2172. /*#__PURE__*/
  2173. function () {
  2174. function WrappedRange(sc, so, ec, eo) {
  2175. range_classCallCheck(this, WrappedRange);
  2176. this.sc = sc;
  2177. this.so = so;
  2178. this.ec = ec;
  2179. this.eo = eo; // isOnEditable: judge whether range is on editable or not
  2180. this.isOnEditable = this.makeIsOn(dom.isEditable); // isOnList: judge whether range is on list node or not
  2181. this.isOnList = this.makeIsOn(dom.isList); // isOnAnchor: judge whether range is on anchor node or not
  2182. this.isOnAnchor = this.makeIsOn(dom.isAnchor); // isOnCell: judge whether range is on cell node or not
  2183. this.isOnCell = this.makeIsOn(dom.isCell); // isOnData: judge whether range is on data node or not
  2184. this.isOnData = this.makeIsOn(dom.isData);
  2185. } // nativeRange: get nativeRange from sc, so, ec, eo
  2186. range_createClass(WrappedRange, [{
  2187. key: "nativeRange",
  2188. value: function nativeRange() {
  2189. if (env.isW3CRangeSupport) {
  2190. var w3cRange = document.createRange();
  2191. w3cRange.setStart(this.sc, this.sc.data && this.so > this.sc.data.length ? 0 : this.so);
  2192. w3cRange.setEnd(this.ec, this.sc.data ? Math.min(this.eo, this.sc.data.length) : this.eo);
  2193. return w3cRange;
  2194. } else {
  2195. var textRange = pointToTextRange({
  2196. node: this.sc,
  2197. offset: this.so
  2198. });
  2199. textRange.setEndPoint('EndToEnd', pointToTextRange({
  2200. node: this.ec,
  2201. offset: this.eo
  2202. }));
  2203. return textRange;
  2204. }
  2205. }
  2206. }, {
  2207. key: "getPoints",
  2208. value: function getPoints() {
  2209. return {
  2210. sc: this.sc,
  2211. so: this.so,
  2212. ec: this.ec,
  2213. eo: this.eo
  2214. };
  2215. }
  2216. }, {
  2217. key: "getStartPoint",
  2218. value: function getStartPoint() {
  2219. return {
  2220. node: this.sc,
  2221. offset: this.so
  2222. };
  2223. }
  2224. }, {
  2225. key: "getEndPoint",
  2226. value: function getEndPoint() {
  2227. return {
  2228. node: this.ec,
  2229. offset: this.eo
  2230. };
  2231. }
  2232. /**
  2233. * select update visible range
  2234. */
  2235. }, {
  2236. key: "select",
  2237. value: function select() {
  2238. var nativeRng = this.nativeRange();
  2239. if (env.isW3CRangeSupport) {
  2240. var selection = document.getSelection();
  2241. if (selection.rangeCount > 0) {
  2242. selection.removeAllRanges();
  2243. }
  2244. selection.addRange(nativeRng);
  2245. } else {
  2246. nativeRng.select();
  2247. }
  2248. return this;
  2249. }
  2250. /**
  2251. * Moves the scrollbar to start container(sc) of current range
  2252. *
  2253. * @return {WrappedRange}
  2254. */
  2255. }, {
  2256. key: "scrollIntoView",
  2257. value: function scrollIntoView(container) {
  2258. var height = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(container).height();
  2259. if (container.scrollTop + height < this.sc.offsetTop) {
  2260. container.scrollTop += Math.abs(container.scrollTop + height - this.sc.offsetTop);
  2261. }
  2262. return this;
  2263. }
  2264. /**
  2265. * @return {WrappedRange}
  2266. */
  2267. }, {
  2268. key: "normalize",
  2269. value: function normalize() {
  2270. /**
  2271. * @param {BoundaryPoint} point
  2272. * @param {Boolean} isLeftToRight - true: prefer to choose right node
  2273. * - false: prefer to choose left node
  2274. * @return {BoundaryPoint}
  2275. */
  2276. var getVisiblePoint = function getVisiblePoint(point, isLeftToRight) {
  2277. if (!point) {
  2278. return point;
  2279. } // Just use the given point [XXX:Adhoc]
  2280. // - case 01. if the point is on the middle of the node
  2281. // - case 02. if the point is on the right edge and prefer to choose left node
  2282. // - case 03. if the point is on the left edge and prefer to choose right node
  2283. // - case 04. if the point is on the right edge and prefer to choose right node but the node is void
  2284. // - case 05. if the point is on the left edge and prefer to choose left node but the node is void
  2285. // - case 06. if the point is on the block node and there is no children
  2286. if (dom.isVisiblePoint(point)) {
  2287. if (!dom.isEdgePoint(point) || dom.isRightEdgePoint(point) && !isLeftToRight || dom.isLeftEdgePoint(point) && isLeftToRight || dom.isRightEdgePoint(point) && isLeftToRight && dom.isVoid(point.node.nextSibling) || dom.isLeftEdgePoint(point) && !isLeftToRight && dom.isVoid(point.node.previousSibling) || dom.isBlock(point.node) && dom.isEmpty(point.node)) {
  2288. return point;
  2289. }
  2290. } // point on block's edge
  2291. var block = dom.ancestor(point.node, dom.isBlock);
  2292. var hasRightNode = false;
  2293. if (!hasRightNode) {
  2294. var prevPoint = dom.prevPoint(point) || {
  2295. node: null
  2296. };
  2297. hasRightNode = (dom.isLeftEdgePointOf(point, block) || dom.isVoid(prevPoint.node)) && !isLeftToRight;
  2298. }
  2299. var hasLeftNode = false;
  2300. if (!hasLeftNode) {
  2301. var _nextPoint = dom.nextPoint(point) || {
  2302. node: null
  2303. };
  2304. hasLeftNode = (dom.isRightEdgePointOf(point, block) || dom.isVoid(_nextPoint.node)) && isLeftToRight;
  2305. }
  2306. if (hasRightNode || hasLeftNode) {
  2307. // returns point already on visible point
  2308. if (dom.isVisiblePoint(point)) {
  2309. return point;
  2310. } // reverse direction
  2311. isLeftToRight = !isLeftToRight;
  2312. }
  2313. var nextPoint = isLeftToRight ? dom.nextPointUntil(dom.nextPoint(point), dom.isVisiblePoint) : dom.prevPointUntil(dom.prevPoint(point), dom.isVisiblePoint);
  2314. return nextPoint || point;
  2315. };
  2316. var endPoint = getVisiblePoint(this.getEndPoint(), false);
  2317. var startPoint = this.isCollapsed() ? endPoint : getVisiblePoint(this.getStartPoint(), true);
  2318. return new WrappedRange(startPoint.node, startPoint.offset, endPoint.node, endPoint.offset);
  2319. }
  2320. /**
  2321. * returns matched nodes on range
  2322. *
  2323. * @param {Function} [pred] - predicate function
  2324. * @param {Object} [options]
  2325. * @param {Boolean} [options.includeAncestor]
  2326. * @param {Boolean} [options.fullyContains]
  2327. * @return {Node[]}
  2328. */
  2329. }, {
  2330. key: "nodes",
  2331. value: function nodes(pred, options) {
  2332. pred = pred || func.ok;
  2333. var includeAncestor = options && options.includeAncestor;
  2334. var fullyContains = options && options.fullyContains; // TODO compare points and sort
  2335. var startPoint = this.getStartPoint();
  2336. var endPoint = this.getEndPoint();
  2337. var nodes = [];
  2338. var leftEdgeNodes = [];
  2339. dom.walkPoint(startPoint, endPoint, function (point) {
  2340. if (dom.isEditable(point.node)) {
  2341. return;
  2342. }
  2343. var node;
  2344. if (fullyContains) {
  2345. if (dom.isLeftEdgePoint(point)) {
  2346. leftEdgeNodes.push(point.node);
  2347. }
  2348. if (dom.isRightEdgePoint(point) && lists.contains(leftEdgeNodes, point.node)) {
  2349. node = point.node;
  2350. }
  2351. } else if (includeAncestor) {
  2352. node = dom.ancestor(point.node, pred);
  2353. } else {
  2354. node = point.node;
  2355. }
  2356. if (node && pred(node)) {
  2357. nodes.push(node);
  2358. }
  2359. }, true);
  2360. return lists.unique(nodes);
  2361. }
  2362. /**
  2363. * returns commonAncestor of range
  2364. * @return {Element} - commonAncestor
  2365. */
  2366. }, {
  2367. key: "commonAncestor",
  2368. value: function commonAncestor() {
  2369. return dom.commonAncestor(this.sc, this.ec);
  2370. }
  2371. /**
  2372. * returns expanded range by pred
  2373. *
  2374. * @param {Function} pred - predicate function
  2375. * @return {WrappedRange}
  2376. */
  2377. }, {
  2378. key: "expand",
  2379. value: function expand(pred) {
  2380. var startAncestor = dom.ancestor(this.sc, pred);
  2381. var endAncestor = dom.ancestor(this.ec, pred);
  2382. if (!startAncestor && !endAncestor) {
  2383. return new WrappedRange(this.sc, this.so, this.ec, this.eo);
  2384. }
  2385. var boundaryPoints = this.getPoints();
  2386. if (startAncestor) {
  2387. boundaryPoints.sc = startAncestor;
  2388. boundaryPoints.so = 0;
  2389. }
  2390. if (endAncestor) {
  2391. boundaryPoints.ec = endAncestor;
  2392. boundaryPoints.eo = dom.nodeLength(endAncestor);
  2393. }
  2394. return new WrappedRange(boundaryPoints.sc, boundaryPoints.so, boundaryPoints.ec, boundaryPoints.eo);
  2395. }
  2396. /**
  2397. * @param {Boolean} isCollapseToStart
  2398. * @return {WrappedRange}
  2399. */
  2400. }, {
  2401. key: "collapse",
  2402. value: function collapse(isCollapseToStart) {
  2403. if (isCollapseToStart) {
  2404. return new WrappedRange(this.sc, this.so, this.sc, this.so);
  2405. } else {
  2406. return new WrappedRange(this.ec, this.eo, this.ec, this.eo);
  2407. }
  2408. }
  2409. /**
  2410. * splitText on range
  2411. */
  2412. }, {
  2413. key: "splitText",
  2414. value: function splitText() {
  2415. var isSameContainer = this.sc === this.ec;
  2416. var boundaryPoints = this.getPoints();
  2417. if (dom.isText(this.ec) && !dom.isEdgePoint(this.getEndPoint())) {
  2418. this.ec.splitText(this.eo);
  2419. }
  2420. if (dom.isText(this.sc) && !dom.isEdgePoint(this.getStartPoint())) {
  2421. boundaryPoints.sc = this.sc.splitText(this.so);
  2422. boundaryPoints.so = 0;
  2423. if (isSameContainer) {
  2424. boundaryPoints.ec = boundaryPoints.sc;
  2425. boundaryPoints.eo = this.eo - this.so;
  2426. }
  2427. }
  2428. return new WrappedRange(boundaryPoints.sc, boundaryPoints.so, boundaryPoints.ec, boundaryPoints.eo);
  2429. }
  2430. /**
  2431. * delete contents on range
  2432. * @return {WrappedRange}
  2433. */
  2434. }, {
  2435. key: "deleteContents",
  2436. value: function deleteContents() {
  2437. if (this.isCollapsed()) {
  2438. return this;
  2439. }
  2440. var rng = this.splitText();
  2441. var nodes = rng.nodes(null, {
  2442. fullyContains: true
  2443. }); // find new cursor point
  2444. var point = dom.prevPointUntil(rng.getStartPoint(), function (point) {
  2445. return !lists.contains(nodes, point.node);
  2446. });
  2447. var emptyParents = [];
  2448. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(nodes, function (idx, node) {
  2449. // find empty parents
  2450. var parent = node.parentNode;
  2451. if (point.node !== parent && dom.nodeLength(parent) === 1) {
  2452. emptyParents.push(parent);
  2453. }
  2454. dom.remove(node, false);
  2455. }); // remove empty parents
  2456. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(emptyParents, function (idx, node) {
  2457. dom.remove(node, false);
  2458. });
  2459. return new WrappedRange(point.node, point.offset, point.node, point.offset).normalize();
  2460. }
  2461. /**
  2462. * makeIsOn: return isOn(pred) function
  2463. */
  2464. }, {
  2465. key: "makeIsOn",
  2466. value: function makeIsOn(pred) {
  2467. return function () {
  2468. var ancestor = dom.ancestor(this.sc, pred);
  2469. return !!ancestor && ancestor === dom.ancestor(this.ec, pred);
  2470. };
  2471. }
  2472. /**
  2473. * @param {Function} pred
  2474. * @return {Boolean}
  2475. */
  2476. }, {
  2477. key: "isLeftEdgeOf",
  2478. value: function isLeftEdgeOf(pred) {
  2479. if (!dom.isLeftEdgePoint(this.getStartPoint())) {
  2480. return false;
  2481. }
  2482. var node = dom.ancestor(this.sc, pred);
  2483. return node && dom.isLeftEdgeOf(this.sc, node);
  2484. }
  2485. /**
  2486. * returns whether range was collapsed or not
  2487. */
  2488. }, {
  2489. key: "isCollapsed",
  2490. value: function isCollapsed() {
  2491. return this.sc === this.ec && this.so === this.eo;
  2492. }
  2493. /**
  2494. * wrap inline nodes which children of body with paragraph
  2495. *
  2496. * @return {WrappedRange}
  2497. */
  2498. }, {
  2499. key: "wrapBodyInlineWithPara",
  2500. value: function wrapBodyInlineWithPara() {
  2501. if (dom.isBodyContainer(this.sc) && dom.isEmpty(this.sc)) {
  2502. this.sc.innerHTML = dom.emptyPara;
  2503. return new WrappedRange(this.sc.firstChild, 0, this.sc.firstChild, 0);
  2504. }
  2505. /**
  2506. * [workaround] firefox often create range on not visible point. so normalize here.
  2507. * - firefox: |<p>text</p>|
  2508. * - chrome: <p>|text|</p>
  2509. */
  2510. var rng = this.normalize();
  2511. if (dom.isParaInline(this.sc) || dom.isPara(this.sc)) {
  2512. return rng;
  2513. } // find inline top ancestor
  2514. var topAncestor;
  2515. if (dom.isInline(rng.sc)) {
  2516. var ancestors = dom.listAncestor(rng.sc, func.not(dom.isInline));
  2517. topAncestor = lists.last(ancestors);
  2518. if (!dom.isInline(topAncestor)) {
  2519. topAncestor = ancestors[ancestors.length - 2] || rng.sc.childNodes[rng.so];
  2520. }
  2521. } else {
  2522. topAncestor = rng.sc.childNodes[rng.so > 0 ? rng.so - 1 : 0];
  2523. }
  2524. if (topAncestor) {
  2525. // siblings not in paragraph
  2526. var inlineSiblings = dom.listPrev(topAncestor, dom.isParaInline).reverse();
  2527. inlineSiblings = inlineSiblings.concat(dom.listNext(topAncestor.nextSibling, dom.isParaInline)); // wrap with paragraph
  2528. if (inlineSiblings.length) {
  2529. var para = dom.wrap(lists.head(inlineSiblings), 'p');
  2530. dom.appendChildNodes(para, lists.tail(inlineSiblings));
  2531. }
  2532. }
  2533. return this.normalize();
  2534. }
  2535. /**
  2536. * insert node at current cursor
  2537. *
  2538. * @param {Node} node
  2539. * @return {Node}
  2540. */
  2541. }, {
  2542. key: "insertNode",
  2543. value: function insertNode(node) {
  2544. var rng = this;
  2545. if (dom.isText(node) || dom.isInline(node)) {
  2546. rng = this.wrapBodyInlineWithPara().deleteContents();
  2547. }
  2548. var info = dom.splitPoint(rng.getStartPoint(), dom.isInline(node));
  2549. if (info.rightNode) {
  2550. info.rightNode.parentNode.insertBefore(node, info.rightNode);
  2551. } else {
  2552. info.container.appendChild(node);
  2553. }
  2554. return node;
  2555. }
  2556. /**
  2557. * insert html at current cursor
  2558. */
  2559. }, {
  2560. key: "pasteHTML",
  2561. value: function pasteHTML(markup) {
  2562. markup = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.trim(markup);
  2563. var contentsContainer = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div></div>').html(markup)[0];
  2564. var childNodes = lists.from(contentsContainer.childNodes); // const rng = this.wrapBodyInlineWithPara().deleteContents();
  2565. var rng = this;
  2566. if (rng.so >= 0) {
  2567. childNodes = childNodes.reverse();
  2568. }
  2569. childNodes = childNodes.map(function (childNode) {
  2570. return rng.insertNode(childNode);
  2571. });
  2572. if (rng.so > 0) {
  2573. childNodes = childNodes.reverse();
  2574. }
  2575. return childNodes;
  2576. }
  2577. /**
  2578. * returns text in range
  2579. *
  2580. * @return {String}
  2581. */
  2582. }, {
  2583. key: "toString",
  2584. value: function toString() {
  2585. var nativeRng = this.nativeRange();
  2586. return env.isW3CRangeSupport ? nativeRng.toString() : nativeRng.text;
  2587. }
  2588. /**
  2589. * returns range for word before cursor
  2590. *
  2591. * @param {Boolean} [findAfter] - find after cursor, default: false
  2592. * @return {WrappedRange}
  2593. */
  2594. }, {
  2595. key: "getWordRange",
  2596. value: function getWordRange(findAfter) {
  2597. var endPoint = this.getEndPoint();
  2598. if (!dom.isCharPoint(endPoint)) {
  2599. return this;
  2600. }
  2601. var startPoint = dom.prevPointUntil(endPoint, function (point) {
  2602. return !dom.isCharPoint(point);
  2603. });
  2604. if (findAfter) {
  2605. endPoint = dom.nextPointUntil(endPoint, function (point) {
  2606. return !dom.isCharPoint(point);
  2607. });
  2608. }
  2609. return new WrappedRange(startPoint.node, startPoint.offset, endPoint.node, endPoint.offset);
  2610. }
  2611. /**
  2612. * returns range for words before cursor
  2613. *
  2614. * @param {Boolean} [findAfter] - find after cursor, default: false
  2615. * @return {WrappedRange}
  2616. */
  2617. }, {
  2618. key: "getWordsRange",
  2619. value: function getWordsRange(findAfter) {
  2620. var endPoint = this.getEndPoint();
  2621. var isNotTextPoint = function isNotTextPoint(point) {
  2622. return !dom.isCharPoint(point) && !dom.isSpacePoint(point);
  2623. };
  2624. if (isNotTextPoint(endPoint)) {
  2625. return this;
  2626. }
  2627. var startPoint = dom.prevPointUntil(endPoint, isNotTextPoint);
  2628. if (findAfter) {
  2629. endPoint = dom.nextPointUntil(endPoint, isNotTextPoint);
  2630. }
  2631. return new WrappedRange(startPoint.node, startPoint.offset, endPoint.node, endPoint.offset);
  2632. }
  2633. /**
  2634. * returns range for words before cursor that match with a Regex
  2635. *
  2636. * example:
  2637. * range: 'hi @Peter Pan'
  2638. * regex: '/@[a-z ]+/i'
  2639. * return range: '@Peter Pan'
  2640. *
  2641. * @param {RegExp} [regex]
  2642. * @return {WrappedRange|null}
  2643. */
  2644. }, {
  2645. key: "getWordsMatchRange",
  2646. value: function getWordsMatchRange(regex) {
  2647. var endPoint = this.getEndPoint();
  2648. var startPoint = dom.prevPointUntil(endPoint, function (point) {
  2649. if (!dom.isCharPoint(point) && !dom.isSpacePoint(point)) {
  2650. return true;
  2651. }
  2652. var rng = new WrappedRange(point.node, point.offset, endPoint.node, endPoint.offset);
  2653. var result = regex.exec(rng.toString());
  2654. return result && result.index === 0;
  2655. });
  2656. var rng = new WrappedRange(startPoint.node, startPoint.offset, endPoint.node, endPoint.offset);
  2657. var text = rng.toString();
  2658. var result = regex.exec(text);
  2659. if (result && result[0].length === text.length) {
  2660. return rng;
  2661. } else {
  2662. return null;
  2663. }
  2664. }
  2665. /**
  2666. * create offsetPath bookmark
  2667. *
  2668. * @param {Node} editable
  2669. */
  2670. }, {
  2671. key: "bookmark",
  2672. value: function bookmark(editable) {
  2673. return {
  2674. s: {
  2675. path: dom.makeOffsetPath(editable, this.sc),
  2676. offset: this.so
  2677. },
  2678. e: {
  2679. path: dom.makeOffsetPath(editable, this.ec),
  2680. offset: this.eo
  2681. }
  2682. };
  2683. }
  2684. /**
  2685. * create offsetPath bookmark base on paragraph
  2686. *
  2687. * @param {Node[]} paras
  2688. */
  2689. }, {
  2690. key: "paraBookmark",
  2691. value: function paraBookmark(paras) {
  2692. return {
  2693. s: {
  2694. path: lists.tail(dom.makeOffsetPath(lists.head(paras), this.sc)),
  2695. offset: this.so
  2696. },
  2697. e: {
  2698. path: lists.tail(dom.makeOffsetPath(lists.last(paras), this.ec)),
  2699. offset: this.eo
  2700. }
  2701. };
  2702. }
  2703. /**
  2704. * getClientRects
  2705. * @return {Rect[]}
  2706. */
  2707. }, {
  2708. key: "getClientRects",
  2709. value: function getClientRects() {
  2710. var nativeRng = this.nativeRange();
  2711. return nativeRng.getClientRects();
  2712. }
  2713. }]);
  2714. return WrappedRange;
  2715. }();
  2716. /**
  2717. * Data structure
  2718. * * BoundaryPoint: a point of dom tree
  2719. * * BoundaryPoints: two boundaryPoints corresponding to the start and the end of the Range
  2720. *
  2721. * See to http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html#Level-2-Range-Position
  2722. */
  2723. /* harmony default export */ var range = ({
  2724. /**
  2725. * create Range Object From arguments or Browser Selection
  2726. *
  2727. * @param {Node} sc - start container
  2728. * @param {Number} so - start offset
  2729. * @param {Node} ec - end container
  2730. * @param {Number} eo - end offset
  2731. * @return {WrappedRange}
  2732. */
  2733. create: function create(sc, so, ec, eo) {
  2734. if (arguments.length === 4) {
  2735. return new range_WrappedRange(sc, so, ec, eo);
  2736. } else if (arguments.length === 2) {
  2737. // collapsed
  2738. ec = sc;
  2739. eo = so;
  2740. return new range_WrappedRange(sc, so, ec, eo);
  2741. } else {
  2742. var wrappedRange = this.createFromSelection();
  2743. if (!wrappedRange && arguments.length === 1) {
  2744. var bodyElement = arguments[0];
  2745. if (dom.isEditable(bodyElement)) {
  2746. bodyElement = bodyElement.lastChild;
  2747. }
  2748. return this.createFromBodyElement(bodyElement, dom.emptyPara === arguments[0].innerHTML);
  2749. }
  2750. return wrappedRange;
  2751. }
  2752. },
  2753. createFromBodyElement: function createFromBodyElement(bodyElement) {
  2754. var isCollapseToStart = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2755. var wrappedRange = this.createFromNode(bodyElement);
  2756. return wrappedRange.collapse(isCollapseToStart);
  2757. },
  2758. createFromSelection: function createFromSelection() {
  2759. var sc, so, ec, eo;
  2760. if (env.isW3CRangeSupport) {
  2761. var selection = document.getSelection();
  2762. if (!selection || selection.rangeCount === 0) {
  2763. return null;
  2764. } else if (dom.isBody(selection.anchorNode)) {
  2765. // Firefox: returns entire body as range on initialization.
  2766. // We won't never need it.
  2767. return null;
  2768. }
  2769. var nativeRng = selection.getRangeAt(0);
  2770. sc = nativeRng.startContainer;
  2771. so = nativeRng.startOffset;
  2772. ec = nativeRng.endContainer;
  2773. eo = nativeRng.endOffset;
  2774. } else {
  2775. // IE8: TextRange
  2776. var textRange = document.selection.createRange();
  2777. var textRangeEnd = textRange.duplicate();
  2778. textRangeEnd.collapse(false);
  2779. var textRangeStart = textRange;
  2780. textRangeStart.collapse(true);
  2781. var startPoint = textRangeToPoint(textRangeStart, true);
  2782. var endPoint = textRangeToPoint(textRangeEnd, false); // same visible point case: range was collapsed.
  2783. if (dom.isText(startPoint.node) && dom.isLeftEdgePoint(startPoint) && dom.isTextNode(endPoint.node) && dom.isRightEdgePoint(endPoint) && endPoint.node.nextSibling === startPoint.node) {
  2784. startPoint = endPoint;
  2785. }
  2786. sc = startPoint.cont;
  2787. so = startPoint.offset;
  2788. ec = endPoint.cont;
  2789. eo = endPoint.offset;
  2790. }
  2791. return new range_WrappedRange(sc, so, ec, eo);
  2792. },
  2793. /**
  2794. * @method
  2795. *
  2796. * create WrappedRange from node
  2797. *
  2798. * @param {Node} node
  2799. * @return {WrappedRange}
  2800. */
  2801. createFromNode: function createFromNode(node) {
  2802. var sc = node;
  2803. var so = 0;
  2804. var ec = node;
  2805. var eo = dom.nodeLength(ec); // browsers can't target a picture or void node
  2806. if (dom.isVoid(sc)) {
  2807. so = dom.listPrev(sc).length - 1;
  2808. sc = sc.parentNode;
  2809. }
  2810. if (dom.isBR(ec)) {
  2811. eo = dom.listPrev(ec).length - 1;
  2812. ec = ec.parentNode;
  2813. } else if (dom.isVoid(ec)) {
  2814. eo = dom.listPrev(ec).length;
  2815. ec = ec.parentNode;
  2816. }
  2817. return this.create(sc, so, ec, eo);
  2818. },
  2819. /**
  2820. * create WrappedRange from node after position
  2821. *
  2822. * @param {Node} node
  2823. * @return {WrappedRange}
  2824. */
  2825. createFromNodeBefore: function createFromNodeBefore(node) {
  2826. return this.createFromNode(node).collapse(true);
  2827. },
  2828. /**
  2829. * create WrappedRange from node after position
  2830. *
  2831. * @param {Node} node
  2832. * @return {WrappedRange}
  2833. */
  2834. createFromNodeAfter: function createFromNodeAfter(node) {
  2835. return this.createFromNode(node).collapse();
  2836. },
  2837. /**
  2838. * @method
  2839. *
  2840. * create WrappedRange from bookmark
  2841. *
  2842. * @param {Node} editable
  2843. * @param {Object} bookmark
  2844. * @return {WrappedRange}
  2845. */
  2846. createFromBookmark: function createFromBookmark(editable, bookmark) {
  2847. var sc = dom.fromOffsetPath(editable, bookmark.s.path);
  2848. var so = bookmark.s.offset;
  2849. var ec = dom.fromOffsetPath(editable, bookmark.e.path);
  2850. var eo = bookmark.e.offset;
  2851. return new range_WrappedRange(sc, so, ec, eo);
  2852. },
  2853. /**
  2854. * @method
  2855. *
  2856. * create WrappedRange from paraBookmark
  2857. *
  2858. * @param {Object} bookmark
  2859. * @param {Node[]} paras
  2860. * @return {WrappedRange}
  2861. */
  2862. createFromParaBookmark: function createFromParaBookmark(bookmark, paras) {
  2863. var so = bookmark.s.offset;
  2864. var eo = bookmark.e.offset;
  2865. var sc = dom.fromOffsetPath(lists.head(paras), bookmark.s.path);
  2866. var ec = dom.fromOffsetPath(lists.last(paras), bookmark.e.path);
  2867. return new range_WrappedRange(sc, so, ec, eo);
  2868. }
  2869. });
  2870. // CONCATENATED MODULE: ./src/js/base/core/key.js
  2871. var KEY_MAP = {
  2872. 'BACKSPACE': 8,
  2873. 'TAB': 9,
  2874. 'ENTER': 13,
  2875. 'SPACE': 32,
  2876. 'DELETE': 46,
  2877. // Arrow
  2878. 'LEFT': 37,
  2879. 'UP': 38,
  2880. 'RIGHT': 39,
  2881. 'DOWN': 40,
  2882. // Number: 0-9
  2883. 'NUM0': 48,
  2884. 'NUM1': 49,
  2885. 'NUM2': 50,
  2886. 'NUM3': 51,
  2887. 'NUM4': 52,
  2888. 'NUM5': 53,
  2889. 'NUM6': 54,
  2890. 'NUM7': 55,
  2891. 'NUM8': 56,
  2892. // Alphabet: a-z
  2893. 'B': 66,
  2894. 'E': 69,
  2895. 'I': 73,
  2896. 'J': 74,
  2897. 'K': 75,
  2898. 'L': 76,
  2899. 'R': 82,
  2900. 'S': 83,
  2901. 'U': 85,
  2902. 'V': 86,
  2903. 'Y': 89,
  2904. 'Z': 90,
  2905. 'SLASH': 191,
  2906. 'LEFTBRACKET': 219,
  2907. 'BACKSLASH': 220,
  2908. 'RIGHTBRACKET': 221,
  2909. // Navigation
  2910. 'HOME': 36,
  2911. 'END': 35,
  2912. 'PAGEUP': 33,
  2913. 'PAGEDOWN': 34
  2914. };
  2915. /**
  2916. * @class core.key
  2917. *
  2918. * Object for keycodes.
  2919. *
  2920. * @singleton
  2921. * @alternateClassName key
  2922. */
  2923. /* harmony default export */ var core_key = ({
  2924. /**
  2925. * @method isEdit
  2926. *
  2927. * @param {Number} keyCode
  2928. * @return {Boolean}
  2929. */
  2930. isEdit: function isEdit(keyCode) {
  2931. return lists.contains([KEY_MAP.BACKSPACE, KEY_MAP.TAB, KEY_MAP.ENTER, KEY_MAP.SPACE, KEY_MAP.DELETE], keyCode);
  2932. },
  2933. /**
  2934. * @method isMove
  2935. *
  2936. * @param {Number} keyCode
  2937. * @return {Boolean}
  2938. */
  2939. isMove: function isMove(keyCode) {
  2940. return lists.contains([KEY_MAP.LEFT, KEY_MAP.UP, KEY_MAP.RIGHT, KEY_MAP.DOWN], keyCode);
  2941. },
  2942. /**
  2943. * @method isNavigation
  2944. *
  2945. * @param {Number} keyCode
  2946. * @return {Boolean}
  2947. */
  2948. isNavigation: function isNavigation(keyCode) {
  2949. return lists.contains([KEY_MAP.HOME, KEY_MAP.END, KEY_MAP.PAGEUP, KEY_MAP.PAGEDOWN], keyCode);
  2950. },
  2951. /**
  2952. * @property {Object} nameFromCode
  2953. * @property {String} nameFromCode.8 "BACKSPACE"
  2954. */
  2955. nameFromCode: func.invertObject(KEY_MAP),
  2956. code: KEY_MAP
  2957. });
  2958. // CONCATENATED MODULE: ./src/js/base/core/async.js
  2959. /**
  2960. * @method readFileAsDataURL
  2961. *
  2962. * read contents of file as representing URL
  2963. *
  2964. * @param {File} file
  2965. * @return {Promise} - then: dataUrl
  2966. */
  2967. function readFileAsDataURL(file) {
  2968. return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.Deferred(function (deferred) {
  2969. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(new FileReader(), {
  2970. onload: function onload(e) {
  2971. var dataURL = e.target.result;
  2972. deferred.resolve(dataURL);
  2973. },
  2974. onerror: function onerror(err) {
  2975. deferred.reject(err);
  2976. }
  2977. }).readAsDataURL(file);
  2978. }).promise();
  2979. }
  2980. /**
  2981. * @method createImage
  2982. *
  2983. * create `<image>` from url string
  2984. *
  2985. * @param {String} url
  2986. * @return {Promise} - then: $image
  2987. */
  2988. function createImage(url) {
  2989. return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.Deferred(function (deferred) {
  2990. var $img = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<img>');
  2991. $img.one('load', function () {
  2992. $img.off('error abort');
  2993. deferred.resolve($img);
  2994. }).one('error abort', function () {
  2995. $img.off('load').detach();
  2996. deferred.reject($img);
  2997. }).css({
  2998. display: 'none'
  2999. }).appendTo(document.body).attr('src', url);
  3000. }).promise();
  3001. }
  3002. // CONCATENATED MODULE: ./src/js/base/editing/History.js
  3003. function History_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3004. function History_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); } }
  3005. function History_createClass(Constructor, protoProps, staticProps) { if (protoProps) History_defineProperties(Constructor.prototype, protoProps); if (staticProps) History_defineProperties(Constructor, staticProps); return Constructor; }
  3006. var History_History =
  3007. /*#__PURE__*/
  3008. function () {
  3009. function History(context) {
  3010. History_classCallCheck(this, History);
  3011. this.stack = [];
  3012. this.stackOffset = -1;
  3013. this.context = context;
  3014. this.$editable = context.layoutInfo.editable;
  3015. this.editable = this.$editable[0];
  3016. }
  3017. History_createClass(History, [{
  3018. key: "makeSnapshot",
  3019. value: function makeSnapshot() {
  3020. var rng = range.create(this.editable);
  3021. var emptyBookmark = {
  3022. s: {
  3023. path: [],
  3024. offset: 0
  3025. },
  3026. e: {
  3027. path: [],
  3028. offset: 0
  3029. }
  3030. };
  3031. return {
  3032. contents: this.$editable.html(),
  3033. bookmark: rng && rng.isOnEditable() ? rng.bookmark(this.editable) : emptyBookmark
  3034. };
  3035. }
  3036. }, {
  3037. key: "applySnapshot",
  3038. value: function applySnapshot(snapshot) {
  3039. if (snapshot.contents !== null) {
  3040. this.$editable.html(snapshot.contents);
  3041. }
  3042. if (snapshot.bookmark !== null) {
  3043. range.createFromBookmark(this.editable, snapshot.bookmark).select();
  3044. }
  3045. }
  3046. /**
  3047. * @method rewind
  3048. * Rewinds the history stack back to the first snapshot taken.
  3049. * Leaves the stack intact, so that "Redo" can still be used.
  3050. */
  3051. }, {
  3052. key: "rewind",
  3053. value: function rewind() {
  3054. // Create snap shot if not yet recorded
  3055. if (this.$editable.html() !== this.stack[this.stackOffset].contents) {
  3056. this.recordUndo();
  3057. } // Return to the first available snapshot.
  3058. this.stackOffset = 0; // Apply that snapshot.
  3059. this.applySnapshot(this.stack[this.stackOffset]);
  3060. }
  3061. /**
  3062. * @method commit
  3063. * Resets history stack, but keeps current editor's content.
  3064. */
  3065. }, {
  3066. key: "commit",
  3067. value: function commit() {
  3068. // Clear the stack.
  3069. this.stack = []; // Restore stackOffset to its original value.
  3070. this.stackOffset = -1; // Record our first snapshot (of nothing).
  3071. this.recordUndo();
  3072. }
  3073. /**
  3074. * @method reset
  3075. * Resets the history stack completely; reverting to an empty editor.
  3076. */
  3077. }, {
  3078. key: "reset",
  3079. value: function reset() {
  3080. // Clear the stack.
  3081. this.stack = []; // Restore stackOffset to its original value.
  3082. this.stackOffset = -1; // Clear the editable area.
  3083. this.$editable.html(''); // Record our first snapshot (of nothing).
  3084. this.recordUndo();
  3085. }
  3086. /**
  3087. * undo
  3088. */
  3089. }, {
  3090. key: "undo",
  3091. value: function undo() {
  3092. // Create snap shot if not yet recorded
  3093. if (this.$editable.html() !== this.stack[this.stackOffset].contents) {
  3094. this.recordUndo();
  3095. }
  3096. if (this.stackOffset > 0) {
  3097. this.stackOffset--;
  3098. this.applySnapshot(this.stack[this.stackOffset]);
  3099. }
  3100. }
  3101. /**
  3102. * redo
  3103. */
  3104. }, {
  3105. key: "redo",
  3106. value: function redo() {
  3107. if (this.stack.length - 1 > this.stackOffset) {
  3108. this.stackOffset++;
  3109. this.applySnapshot(this.stack[this.stackOffset]);
  3110. }
  3111. }
  3112. /**
  3113. * recorded undo
  3114. */
  3115. }, {
  3116. key: "recordUndo",
  3117. value: function recordUndo() {
  3118. this.stackOffset++; // Wash out stack after stackOffset
  3119. if (this.stack.length > this.stackOffset) {
  3120. this.stack = this.stack.slice(0, this.stackOffset);
  3121. } // Create new snapshot and push it to the end
  3122. this.stack.push(this.makeSnapshot()); // If the stack size reachs to the limit, then slice it
  3123. if (this.stack.length > this.context.options.historyLimit) {
  3124. this.stack.shift();
  3125. this.stackOffset -= 1;
  3126. }
  3127. }
  3128. }]);
  3129. return History;
  3130. }();
  3131. // CONCATENATED MODULE: ./src/js/base/editing/Style.js
  3132. function Style_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3133. function Style_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); } }
  3134. function Style_createClass(Constructor, protoProps, staticProps) { if (protoProps) Style_defineProperties(Constructor.prototype, protoProps); if (staticProps) Style_defineProperties(Constructor, staticProps); return Constructor; }
  3135. var Style_Style =
  3136. /*#__PURE__*/
  3137. function () {
  3138. function Style() {
  3139. Style_classCallCheck(this, Style);
  3140. }
  3141. Style_createClass(Style, [{
  3142. key: "jQueryCSS",
  3143. /**
  3144. * @method jQueryCSS
  3145. *
  3146. * [workaround] for old jQuery
  3147. * passing an array of style properties to .css()
  3148. * will result in an object of property-value pairs.
  3149. * (compability with version < 1.9)
  3150. *
  3151. * @private
  3152. * @param {jQuery} $obj
  3153. * @param {Array} propertyNames - An array of one or more CSS properties.
  3154. * @return {Object}
  3155. */
  3156. value: function jQueryCSS($obj, propertyNames) {
  3157. if (env.jqueryVersion < 1.9) {
  3158. var result = {};
  3159. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(propertyNames, function (idx, propertyName) {
  3160. result[propertyName] = $obj.css(propertyName);
  3161. });
  3162. return result;
  3163. }
  3164. return $obj.css(propertyNames);
  3165. }
  3166. /**
  3167. * returns style object from node
  3168. *
  3169. * @param {jQuery} $node
  3170. * @return {Object}
  3171. */
  3172. }, {
  3173. key: "fromNode",
  3174. value: function fromNode($node) {
  3175. var properties = ['font-family', 'font-size', 'text-align', 'list-style-type', 'line-height'];
  3176. var styleInfo = this.jQueryCSS($node, properties) || {};
  3177. var fontSize = $node[0].style.fontSize || styleInfo['font-size'];
  3178. styleInfo['font-size'] = parseInt(fontSize, 10);
  3179. styleInfo['font-size-unit'] = fontSize.match(/[a-z%]+$/);
  3180. return styleInfo;
  3181. }
  3182. /**
  3183. * paragraph level style
  3184. *
  3185. * @param {WrappedRange} rng
  3186. * @param {Object} styleInfo
  3187. */
  3188. }, {
  3189. key: "stylePara",
  3190. value: function stylePara(rng, styleInfo) {
  3191. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(rng.nodes(dom.isPara, {
  3192. includeAncestor: true
  3193. }), function (idx, para) {
  3194. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(para).css(styleInfo);
  3195. });
  3196. }
  3197. /**
  3198. * insert and returns styleNodes on range.
  3199. *
  3200. * @param {WrappedRange} rng
  3201. * @param {Object} [options] - options for styleNodes
  3202. * @param {String} [options.nodeName] - default: `SPAN`
  3203. * @param {Boolean} [options.expandClosestSibling] - default: `false`
  3204. * @param {Boolean} [options.onlyPartialContains] - default: `false`
  3205. * @return {Node[]}
  3206. */
  3207. }, {
  3208. key: "styleNodes",
  3209. value: function styleNodes(rng, options) {
  3210. rng = rng.splitText();
  3211. var nodeName = options && options.nodeName || 'SPAN';
  3212. var expandClosestSibling = !!(options && options.expandClosestSibling);
  3213. var onlyPartialContains = !!(options && options.onlyPartialContains);
  3214. if (rng.isCollapsed()) {
  3215. return [rng.insertNode(dom.create(nodeName))];
  3216. }
  3217. var pred = dom.makePredByNodeName(nodeName);
  3218. var nodes = rng.nodes(dom.isText, {
  3219. fullyContains: true
  3220. }).map(function (text) {
  3221. return dom.singleChildAncestor(text, pred) || dom.wrap(text, nodeName);
  3222. });
  3223. if (expandClosestSibling) {
  3224. if (onlyPartialContains) {
  3225. var nodesInRange = rng.nodes(); // compose with partial contains predication
  3226. pred = func.and(pred, function (node) {
  3227. return lists.contains(nodesInRange, node);
  3228. });
  3229. }
  3230. return nodes.map(function (node) {
  3231. var siblings = dom.withClosestSiblings(node, pred);
  3232. var head = lists.head(siblings);
  3233. var tails = lists.tail(siblings);
  3234. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(tails, function (idx, elem) {
  3235. dom.appendChildNodes(head, elem.childNodes);
  3236. dom.remove(elem);
  3237. });
  3238. return lists.head(siblings);
  3239. });
  3240. } else {
  3241. return nodes;
  3242. }
  3243. }
  3244. /**
  3245. * get current style on cursor
  3246. *
  3247. * @param {WrappedRange} rng
  3248. * @return {Object} - object contains style properties.
  3249. */
  3250. }, {
  3251. key: "current",
  3252. value: function current(rng) {
  3253. var $cont = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(!dom.isElement(rng.sc) ? rng.sc.parentNode : rng.sc);
  3254. var styleInfo = this.fromNode($cont); // document.queryCommandState for toggle state
  3255. // [workaround] prevent Firefox nsresult: "0x80004005 (NS_ERROR_FAILURE)"
  3256. try {
  3257. styleInfo = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(styleInfo, {
  3258. 'font-bold': document.queryCommandState('bold') ? 'bold' : 'normal',
  3259. 'font-italic': document.queryCommandState('italic') ? 'italic' : 'normal',
  3260. 'font-underline': document.queryCommandState('underline') ? 'underline' : 'normal',
  3261. 'font-subscript': document.queryCommandState('subscript') ? 'subscript' : 'normal',
  3262. 'font-superscript': document.queryCommandState('superscript') ? 'superscript' : 'normal',
  3263. 'font-strikethrough': document.queryCommandState('strikethrough') ? 'strikethrough' : 'normal',
  3264. 'font-family': document.queryCommandValue('fontname') || styleInfo['font-family']
  3265. });
  3266. } catch (e) {} // eslint-disable-next-line
  3267. // list-style-type to list-style(unordered, ordered)
  3268. if (!rng.isOnList()) {
  3269. styleInfo['list-style'] = 'none';
  3270. } else {
  3271. var orderedTypes = ['circle', 'disc', 'disc-leading-zero', 'square'];
  3272. var isUnordered = orderedTypes.indexOf(styleInfo['list-style-type']) > -1;
  3273. styleInfo['list-style'] = isUnordered ? 'unordered' : 'ordered';
  3274. }
  3275. var para = dom.ancestor(rng.sc, dom.isPara);
  3276. if (para && para.style['line-height']) {
  3277. styleInfo['line-height'] = para.style.lineHeight;
  3278. } else {
  3279. var lineHeight = parseInt(styleInfo['line-height'], 10) / parseInt(styleInfo['font-size'], 10);
  3280. styleInfo['line-height'] = lineHeight.toFixed(1);
  3281. }
  3282. styleInfo.anchor = rng.isOnAnchor() && dom.ancestor(rng.sc, dom.isAnchor);
  3283. styleInfo.ancestors = dom.listAncestor(rng.sc, dom.isEditable);
  3284. styleInfo.range = rng;
  3285. return styleInfo;
  3286. }
  3287. }]);
  3288. return Style;
  3289. }();
  3290. // CONCATENATED MODULE: ./src/js/base/editing/Bullet.js
  3291. function Bullet_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3292. function Bullet_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); } }
  3293. function Bullet_createClass(Constructor, protoProps, staticProps) { if (protoProps) Bullet_defineProperties(Constructor.prototype, protoProps); if (staticProps) Bullet_defineProperties(Constructor, staticProps); return Constructor; }
  3294. var Bullet_Bullet =
  3295. /*#__PURE__*/
  3296. function () {
  3297. function Bullet() {
  3298. Bullet_classCallCheck(this, Bullet);
  3299. }
  3300. Bullet_createClass(Bullet, [{
  3301. key: "insertOrderedList",
  3302. /**
  3303. * toggle ordered list
  3304. */
  3305. value: function insertOrderedList(editable) {
  3306. this.toggleList('OL', editable);
  3307. }
  3308. /**
  3309. * toggle unordered list
  3310. */
  3311. }, {
  3312. key: "insertUnorderedList",
  3313. value: function insertUnorderedList(editable) {
  3314. this.toggleList('UL', editable);
  3315. }
  3316. /**
  3317. * indent
  3318. */
  3319. }, {
  3320. key: "indent",
  3321. value: function indent(editable) {
  3322. var _this = this;
  3323. var rng = range.create(editable).wrapBodyInlineWithPara();
  3324. var paras = rng.nodes(dom.isPara, {
  3325. includeAncestor: true
  3326. });
  3327. var clustereds = lists.clusterBy(paras, func.peq2('parentNode'));
  3328. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(clustereds, function (idx, paras) {
  3329. var head = lists.head(paras);
  3330. if (dom.isLi(head)) {
  3331. var previousList = _this.findList(head.previousSibling);
  3332. if (previousList) {
  3333. paras.map(function (para) {
  3334. return previousList.appendChild(para);
  3335. });
  3336. } else {
  3337. _this.wrapList(paras, head.parentNode.nodeName);
  3338. paras.map(function (para) {
  3339. return para.parentNode;
  3340. }).map(function (para) {
  3341. return _this.appendToPrevious(para);
  3342. });
  3343. }
  3344. } else {
  3345. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(paras, function (idx, para) {
  3346. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(para).css('marginLeft', function (idx, val) {
  3347. return (parseInt(val, 10) || 0) + 25;
  3348. });
  3349. });
  3350. }
  3351. });
  3352. rng.select();
  3353. }
  3354. /**
  3355. * outdent
  3356. */
  3357. }, {
  3358. key: "outdent",
  3359. value: function outdent(editable) {
  3360. var _this2 = this;
  3361. var rng = range.create(editable).wrapBodyInlineWithPara();
  3362. var paras = rng.nodes(dom.isPara, {
  3363. includeAncestor: true
  3364. });
  3365. var clustereds = lists.clusterBy(paras, func.peq2('parentNode'));
  3366. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(clustereds, function (idx, paras) {
  3367. var head = lists.head(paras);
  3368. if (dom.isLi(head)) {
  3369. _this2.releaseList([paras]);
  3370. } else {
  3371. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(paras, function (idx, para) {
  3372. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(para).css('marginLeft', function (idx, val) {
  3373. val = parseInt(val, 10) || 0;
  3374. return val > 25 ? val - 25 : '';
  3375. });
  3376. });
  3377. }
  3378. });
  3379. rng.select();
  3380. }
  3381. /**
  3382. * toggle list
  3383. *
  3384. * @param {String} listName - OL or UL
  3385. */
  3386. }, {
  3387. key: "toggleList",
  3388. value: function toggleList(listName, editable) {
  3389. var _this3 = this;
  3390. var rng = range.create(editable).wrapBodyInlineWithPara();
  3391. var paras = rng.nodes(dom.isPara, {
  3392. includeAncestor: true
  3393. });
  3394. var bookmark = rng.paraBookmark(paras);
  3395. var clustereds = lists.clusterBy(paras, func.peq2('parentNode')); // paragraph to list
  3396. if (lists.find(paras, dom.isPurePara)) {
  3397. var wrappedParas = [];
  3398. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(clustereds, function (idx, paras) {
  3399. wrappedParas = wrappedParas.concat(_this3.wrapList(paras, listName));
  3400. });
  3401. paras = wrappedParas; // list to paragraph or change list style
  3402. } else {
  3403. var diffLists = rng.nodes(dom.isList, {
  3404. includeAncestor: true
  3405. }).filter(function (listNode) {
  3406. return !external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.nodeName(listNode, listName);
  3407. });
  3408. if (diffLists.length) {
  3409. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(diffLists, function (idx, listNode) {
  3410. dom.replace(listNode, listName);
  3411. });
  3412. } else {
  3413. paras = this.releaseList(clustereds, true);
  3414. }
  3415. }
  3416. range.createFromParaBookmark(bookmark, paras).select();
  3417. }
  3418. /**
  3419. * @param {Node[]} paras
  3420. * @param {String} listName
  3421. * @return {Node[]}
  3422. */
  3423. }, {
  3424. key: "wrapList",
  3425. value: function wrapList(paras, listName) {
  3426. var head = lists.head(paras);
  3427. var last = lists.last(paras);
  3428. var prevList = dom.isList(head.previousSibling) && head.previousSibling;
  3429. var nextList = dom.isList(last.nextSibling) && last.nextSibling;
  3430. var listNode = prevList || dom.insertAfter(dom.create(listName || 'UL'), last); // P to LI
  3431. paras = paras.map(function (para) {
  3432. return dom.isPurePara(para) ? dom.replace(para, 'LI') : para;
  3433. }); // append to list(<ul>, <ol>)
  3434. dom.appendChildNodes(listNode, paras);
  3435. if (nextList) {
  3436. dom.appendChildNodes(listNode, lists.from(nextList.childNodes));
  3437. dom.remove(nextList);
  3438. }
  3439. return paras;
  3440. }
  3441. /**
  3442. * @method releaseList
  3443. *
  3444. * @param {Array[]} clustereds
  3445. * @param {Boolean} isEscapseToBody
  3446. * @return {Node[]}
  3447. */
  3448. }, {
  3449. key: "releaseList",
  3450. value: function releaseList(clustereds, isEscapseToBody) {
  3451. var _this4 = this;
  3452. var releasedParas = [];
  3453. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(clustereds, function (idx, paras) {
  3454. var head = lists.head(paras);
  3455. var last = lists.last(paras);
  3456. var headList = isEscapseToBody ? dom.lastAncestor(head, dom.isList) : head.parentNode;
  3457. var parentItem = headList.parentNode;
  3458. if (headList.parentNode.nodeName === 'LI') {
  3459. paras.map(function (para) {
  3460. var newList = _this4.findNextSiblings(para);
  3461. if (parentItem.nextSibling) {
  3462. parentItem.parentNode.insertBefore(para, parentItem.nextSibling);
  3463. } else {
  3464. parentItem.parentNode.appendChild(para);
  3465. }
  3466. if (newList.length) {
  3467. _this4.wrapList(newList, headList.nodeName);
  3468. para.appendChild(newList[0].parentNode);
  3469. }
  3470. });
  3471. if (headList.children.length === 0) {
  3472. parentItem.removeChild(headList);
  3473. }
  3474. if (parentItem.childNodes.length === 0) {
  3475. parentItem.parentNode.removeChild(parentItem);
  3476. }
  3477. } else {
  3478. var lastList = headList.childNodes.length > 1 ? dom.splitTree(headList, {
  3479. node: last.parentNode,
  3480. offset: dom.position(last) + 1
  3481. }, {
  3482. isSkipPaddingBlankHTML: true
  3483. }) : null;
  3484. var middleList = dom.splitTree(headList, {
  3485. node: head.parentNode,
  3486. offset: dom.position(head)
  3487. }, {
  3488. isSkipPaddingBlankHTML: true
  3489. });
  3490. paras = isEscapseToBody ? dom.listDescendant(middleList, dom.isLi) : lists.from(middleList.childNodes).filter(dom.isLi); // LI to P
  3491. if (isEscapseToBody || !dom.isList(headList.parentNode)) {
  3492. paras = paras.map(function (para) {
  3493. return dom.replace(para, 'P');
  3494. });
  3495. }
  3496. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(lists.from(paras).reverse(), function (idx, para) {
  3497. dom.insertAfter(para, headList);
  3498. }); // remove empty lists
  3499. var rootLists = lists.compact([headList, middleList, lastList]);
  3500. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(rootLists, function (idx, rootList) {
  3501. var listNodes = [rootList].concat(dom.listDescendant(rootList, dom.isList));
  3502. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(listNodes.reverse(), function (idx, listNode) {
  3503. if (!dom.nodeLength(listNode)) {
  3504. dom.remove(listNode, true);
  3505. }
  3506. });
  3507. });
  3508. }
  3509. releasedParas = releasedParas.concat(paras);
  3510. });
  3511. return releasedParas;
  3512. }
  3513. /**
  3514. * @method appendToPrevious
  3515. *
  3516. * Appends list to previous list item, if
  3517. * none exist it wraps the list in a new list item.
  3518. *
  3519. * @param {HTMLNode} ListItem
  3520. * @return {HTMLNode}
  3521. */
  3522. }, {
  3523. key: "appendToPrevious",
  3524. value: function appendToPrevious(node) {
  3525. return node.previousSibling ? dom.appendChildNodes(node.previousSibling, [node]) : this.wrapList([node], 'LI');
  3526. }
  3527. /**
  3528. * @method findList
  3529. *
  3530. * Finds an existing list in list item
  3531. *
  3532. * @param {HTMLNode} ListItem
  3533. * @return {Array[]}
  3534. */
  3535. }, {
  3536. key: "findList",
  3537. value: function findList(node) {
  3538. return node ? lists.find(node.children, function (child) {
  3539. return ['OL', 'UL'].indexOf(child.nodeName) > -1;
  3540. }) : null;
  3541. }
  3542. /**
  3543. * @method findNextSiblings
  3544. *
  3545. * Finds all list item siblings that follow it
  3546. *
  3547. * @param {HTMLNode} ListItem
  3548. * @return {HTMLNode}
  3549. */
  3550. }, {
  3551. key: "findNextSiblings",
  3552. value: function findNextSiblings(node) {
  3553. var siblings = [];
  3554. while (node.nextSibling) {
  3555. siblings.push(node.nextSibling);
  3556. node = node.nextSibling;
  3557. }
  3558. return siblings;
  3559. }
  3560. }]);
  3561. return Bullet;
  3562. }();
  3563. // CONCATENATED MODULE: ./src/js/base/editing/Typing.js
  3564. function Typing_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3565. function Typing_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); } }
  3566. function Typing_createClass(Constructor, protoProps, staticProps) { if (protoProps) Typing_defineProperties(Constructor.prototype, protoProps); if (staticProps) Typing_defineProperties(Constructor, staticProps); return Constructor; }
  3567. /**
  3568. * @class editing.Typing
  3569. *
  3570. * Typing
  3571. *
  3572. */
  3573. var Typing_Typing =
  3574. /*#__PURE__*/
  3575. function () {
  3576. function Typing(context) {
  3577. Typing_classCallCheck(this, Typing);
  3578. // a Bullet instance to toggle lists off
  3579. this.bullet = new Bullet_Bullet();
  3580. this.options = context.options;
  3581. }
  3582. /**
  3583. * insert tab
  3584. *
  3585. * @param {WrappedRange} rng
  3586. * @param {Number} tabsize
  3587. */
  3588. Typing_createClass(Typing, [{
  3589. key: "insertTab",
  3590. value: function insertTab(rng, tabsize) {
  3591. var tab = dom.createText(new Array(tabsize + 1).join(dom.NBSP_CHAR));
  3592. rng = rng.deleteContents();
  3593. rng.insertNode(tab, true);
  3594. rng = range.create(tab, tabsize);
  3595. rng.select();
  3596. }
  3597. /**
  3598. * insert paragraph
  3599. *
  3600. * @param {jQuery} $editable
  3601. * @param {WrappedRange} rng Can be used in unit tests to "mock" the range
  3602. *
  3603. * blockquoteBreakingLevel
  3604. * 0 - No break, the new paragraph remains inside the quote
  3605. * 1 - Break the first blockquote in the ancestors list
  3606. * 2 - Break all blockquotes, so that the new paragraph is not quoted (this is the default)
  3607. */
  3608. }, {
  3609. key: "insertParagraph",
  3610. value: function insertParagraph(editable, rng) {
  3611. rng = rng || range.create(editable); // deleteContents on range.
  3612. rng = rng.deleteContents(); // Wrap range if it needs to be wrapped by paragraph
  3613. rng = rng.wrapBodyInlineWithPara(); // finding paragraph
  3614. var splitRoot = dom.ancestor(rng.sc, dom.isPara);
  3615. var nextPara; // on paragraph: split paragraph
  3616. if (splitRoot) {
  3617. // if it is an empty line with li
  3618. if (dom.isLi(splitRoot) && (dom.isEmpty(splitRoot) || dom.deepestChildIsEmpty(splitRoot))) {
  3619. // toogle UL/OL and escape
  3620. this.bullet.toggleList(splitRoot.parentNode.nodeName);
  3621. return;
  3622. } else {
  3623. var blockquote = null;
  3624. if (this.options.blockquoteBreakingLevel === 1) {
  3625. blockquote = dom.ancestor(splitRoot, dom.isBlockquote);
  3626. } else if (this.options.blockquoteBreakingLevel === 2) {
  3627. blockquote = dom.lastAncestor(splitRoot, dom.isBlockquote);
  3628. }
  3629. if (blockquote) {
  3630. // We're inside a blockquote and options ask us to break it
  3631. nextPara = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(dom.emptyPara)[0]; // If the split is right before a <br>, remove it so that there's no "empty line"
  3632. // after the split in the new blockquote created
  3633. if (dom.isRightEdgePoint(rng.getStartPoint()) && dom.isBR(rng.sc.nextSibling)) {
  3634. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(rng.sc.nextSibling).remove();
  3635. }
  3636. var split = dom.splitTree(blockquote, rng.getStartPoint(), {
  3637. isDiscardEmptySplits: true
  3638. });
  3639. if (split) {
  3640. split.parentNode.insertBefore(nextPara, split);
  3641. } else {
  3642. dom.insertAfter(nextPara, blockquote); // There's no split if we were at the end of the blockquote
  3643. }
  3644. } else {
  3645. nextPara = dom.splitTree(splitRoot, rng.getStartPoint()); // not a blockquote, just insert the paragraph
  3646. var emptyAnchors = dom.listDescendant(splitRoot, dom.isEmptyAnchor);
  3647. emptyAnchors = emptyAnchors.concat(dom.listDescendant(nextPara, dom.isEmptyAnchor));
  3648. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(emptyAnchors, function (idx, anchor) {
  3649. dom.remove(anchor);
  3650. }); // replace empty heading, pre or custom-made styleTag with P tag
  3651. if ((dom.isHeading(nextPara) || dom.isPre(nextPara) || dom.isCustomStyleTag(nextPara)) && dom.isEmpty(nextPara)) {
  3652. nextPara = dom.replace(nextPara, 'p');
  3653. }
  3654. }
  3655. } // no paragraph: insert empty paragraph
  3656. } else {
  3657. var next = rng.sc.childNodes[rng.so];
  3658. nextPara = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(dom.emptyPara)[0];
  3659. if (next) {
  3660. rng.sc.insertBefore(nextPara, next);
  3661. } else {
  3662. rng.sc.appendChild(nextPara);
  3663. }
  3664. }
  3665. range.create(nextPara, 0).normalize().select().scrollIntoView(editable);
  3666. }
  3667. }]);
  3668. return Typing;
  3669. }();
  3670. // CONCATENATED MODULE: ./src/js/base/editing/Table.js
  3671. function Table_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3672. function Table_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); } }
  3673. function Table_createClass(Constructor, protoProps, staticProps) { if (protoProps) Table_defineProperties(Constructor.prototype, protoProps); if (staticProps) Table_defineProperties(Constructor, staticProps); return Constructor; }
  3674. /**
  3675. * @class Create a virtual table to create what actions to do in change.
  3676. * @param {object} startPoint Cell selected to apply change.
  3677. * @param {enum} where Where change will be applied Row or Col. Use enum: TableResultAction.where
  3678. * @param {enum} action Action to be applied. Use enum: TableResultAction.requestAction
  3679. * @param {object} domTable Dom element of table to make changes.
  3680. */
  3681. var TableResultAction = function TableResultAction(startPoint, where, action, domTable) {
  3682. var _startPoint = {
  3683. 'colPos': 0,
  3684. 'rowPos': 0
  3685. };
  3686. var _virtualTable = [];
  3687. var _actionCellList = []; /// ///////////////////////////////////////////
  3688. // Private functions
  3689. /// ///////////////////////////////////////////
  3690. /**
  3691. * Set the startPoint of action.
  3692. */
  3693. function setStartPoint() {
  3694. if (!startPoint || !startPoint.tagName || startPoint.tagName.toLowerCase() !== 'td' && startPoint.tagName.toLowerCase() !== 'th') {
  3695. // Impossible to identify start Cell point
  3696. return;
  3697. }
  3698. _startPoint.colPos = startPoint.cellIndex;
  3699. if (!startPoint.parentElement || !startPoint.parentElement.tagName || startPoint.parentElement.tagName.toLowerCase() !== 'tr') {
  3700. // Impossible to identify start Row point
  3701. return;
  3702. }
  3703. _startPoint.rowPos = startPoint.parentElement.rowIndex;
  3704. }
  3705. /**
  3706. * Define virtual table position info object.
  3707. *
  3708. * @param {int} rowIndex Index position in line of virtual table.
  3709. * @param {int} cellIndex Index position in column of virtual table.
  3710. * @param {object} baseRow Row affected by this position.
  3711. * @param {object} baseCell Cell affected by this position.
  3712. * @param {bool} isSpan Inform if it is an span cell/row.
  3713. */
  3714. function setVirtualTablePosition(rowIndex, cellIndex, baseRow, baseCell, isRowSpan, isColSpan, isVirtualCell) {
  3715. var objPosition = {
  3716. 'baseRow': baseRow,
  3717. 'baseCell': baseCell,
  3718. 'isRowSpan': isRowSpan,
  3719. 'isColSpan': isColSpan,
  3720. 'isVirtual': isVirtualCell
  3721. };
  3722. if (!_virtualTable[rowIndex]) {
  3723. _virtualTable[rowIndex] = [];
  3724. }
  3725. _virtualTable[rowIndex][cellIndex] = objPosition;
  3726. }
  3727. /**
  3728. * Create action cell object.
  3729. *
  3730. * @param {object} virtualTableCellObj Object of specific position on virtual table.
  3731. * @param {enum} resultAction Action to be applied in that item.
  3732. */
  3733. function getActionCell(virtualTableCellObj, resultAction, virtualRowPosition, virtualColPosition) {
  3734. return {
  3735. 'baseCell': virtualTableCellObj.baseCell,
  3736. 'action': resultAction,
  3737. 'virtualTable': {
  3738. 'rowIndex': virtualRowPosition,
  3739. 'cellIndex': virtualColPosition
  3740. }
  3741. };
  3742. }
  3743. /**
  3744. * Recover free index of row to append Cell.
  3745. *
  3746. * @param {int} rowIndex Index of row to find free space.
  3747. * @param {int} cellIndex Index of cell to find free space in table.
  3748. */
  3749. function recoverCellIndex(rowIndex, cellIndex) {
  3750. if (!_virtualTable[rowIndex]) {
  3751. return cellIndex;
  3752. }
  3753. if (!_virtualTable[rowIndex][cellIndex]) {
  3754. return cellIndex;
  3755. }
  3756. var newCellIndex = cellIndex;
  3757. while (_virtualTable[rowIndex][newCellIndex]) {
  3758. newCellIndex++;
  3759. if (!_virtualTable[rowIndex][newCellIndex]) {
  3760. return newCellIndex;
  3761. }
  3762. }
  3763. }
  3764. /**
  3765. * Recover info about row and cell and add information to virtual table.
  3766. *
  3767. * @param {object} row Row to recover information.
  3768. * @param {object} cell Cell to recover information.
  3769. */
  3770. function addCellInfoToVirtual(row, cell) {
  3771. var cellIndex = recoverCellIndex(row.rowIndex, cell.cellIndex);
  3772. var cellHasColspan = cell.colSpan > 1;
  3773. var cellHasRowspan = cell.rowSpan > 1;
  3774. var isThisSelectedCell = row.rowIndex === _startPoint.rowPos && cell.cellIndex === _startPoint.colPos;
  3775. setVirtualTablePosition(row.rowIndex, cellIndex, row, cell, cellHasRowspan, cellHasColspan, false); // Add span rows to virtual Table.
  3776. var rowspanNumber = cell.attributes.rowSpan ? parseInt(cell.attributes.rowSpan.value, 10) : 0;
  3777. if (rowspanNumber > 1) {
  3778. for (var rp = 1; rp < rowspanNumber; rp++) {
  3779. var rowspanIndex = row.rowIndex + rp;
  3780. adjustStartPoint(rowspanIndex, cellIndex, cell, isThisSelectedCell);
  3781. setVirtualTablePosition(rowspanIndex, cellIndex, row, cell, true, cellHasColspan, true);
  3782. }
  3783. } // Add span cols to virtual table.
  3784. var colspanNumber = cell.attributes.colSpan ? parseInt(cell.attributes.colSpan.value, 10) : 0;
  3785. if (colspanNumber > 1) {
  3786. for (var cp = 1; cp < colspanNumber; cp++) {
  3787. var cellspanIndex = recoverCellIndex(row.rowIndex, cellIndex + cp);
  3788. adjustStartPoint(row.rowIndex, cellspanIndex, cell, isThisSelectedCell);
  3789. setVirtualTablePosition(row.rowIndex, cellspanIndex, row, cell, cellHasRowspan, true, true);
  3790. }
  3791. }
  3792. }
  3793. /**
  3794. * Process validation and adjust of start point if needed
  3795. *
  3796. * @param {int} rowIndex
  3797. * @param {int} cellIndex
  3798. * @param {object} cell
  3799. * @param {bool} isSelectedCell
  3800. */
  3801. function adjustStartPoint(rowIndex, cellIndex, cell, isSelectedCell) {
  3802. if (rowIndex === _startPoint.rowPos && _startPoint.colPos >= cell.cellIndex && cell.cellIndex <= cellIndex && !isSelectedCell) {
  3803. _startPoint.colPos++;
  3804. }
  3805. }
  3806. /**
  3807. * Create virtual table of cells with all cells, including span cells.
  3808. */
  3809. function createVirtualTable() {
  3810. var rows = domTable.rows;
  3811. for (var rowIndex = 0; rowIndex < rows.length; rowIndex++) {
  3812. var cells = rows[rowIndex].cells;
  3813. for (var cellIndex = 0; cellIndex < cells.length; cellIndex++) {
  3814. addCellInfoToVirtual(rows[rowIndex], cells[cellIndex]);
  3815. }
  3816. }
  3817. }
  3818. /**
  3819. * Get action to be applied on the cell.
  3820. *
  3821. * @param {object} cell virtual table cell to apply action
  3822. */
  3823. function getDeleteResultActionToCell(cell) {
  3824. switch (where) {
  3825. case TableResultAction.where.Column:
  3826. if (cell.isColSpan) {
  3827. return TableResultAction.resultAction.SubtractSpanCount;
  3828. }
  3829. break;
  3830. case TableResultAction.where.Row:
  3831. if (!cell.isVirtual && cell.isRowSpan) {
  3832. return TableResultAction.resultAction.AddCell;
  3833. } else if (cell.isRowSpan) {
  3834. return TableResultAction.resultAction.SubtractSpanCount;
  3835. }
  3836. break;
  3837. }
  3838. return TableResultAction.resultAction.RemoveCell;
  3839. }
  3840. /**
  3841. * Get action to be applied on the cell.
  3842. *
  3843. * @param {object} cell virtual table cell to apply action
  3844. */
  3845. function getAddResultActionToCell(cell) {
  3846. switch (where) {
  3847. case TableResultAction.where.Column:
  3848. if (cell.isColSpan) {
  3849. return TableResultAction.resultAction.SumSpanCount;
  3850. } else if (cell.isRowSpan && cell.isVirtual) {
  3851. return TableResultAction.resultAction.Ignore;
  3852. }
  3853. break;
  3854. case TableResultAction.where.Row:
  3855. if (cell.isRowSpan) {
  3856. return TableResultAction.resultAction.SumSpanCount;
  3857. } else if (cell.isColSpan && cell.isVirtual) {
  3858. return TableResultAction.resultAction.Ignore;
  3859. }
  3860. break;
  3861. }
  3862. return TableResultAction.resultAction.AddCell;
  3863. }
  3864. function init() {
  3865. setStartPoint();
  3866. createVirtualTable();
  3867. } /// ///////////////////////////////////////////
  3868. // Public functions
  3869. /// ///////////////////////////////////////////
  3870. /**
  3871. * Recover array os what to do in table.
  3872. */
  3873. this.getActionList = function () {
  3874. var fixedRow = where === TableResultAction.where.Row ? _startPoint.rowPos : -1;
  3875. var fixedCol = where === TableResultAction.where.Column ? _startPoint.colPos : -1;
  3876. var actualPosition = 0;
  3877. var canContinue = true;
  3878. while (canContinue) {
  3879. var rowPosition = fixedRow >= 0 ? fixedRow : actualPosition;
  3880. var colPosition = fixedCol >= 0 ? fixedCol : actualPosition;
  3881. var row = _virtualTable[rowPosition];
  3882. if (!row) {
  3883. canContinue = false;
  3884. return _actionCellList;
  3885. }
  3886. var cell = row[colPosition];
  3887. if (!cell) {
  3888. canContinue = false;
  3889. return _actionCellList;
  3890. } // Define action to be applied in this cell
  3891. var resultAction = TableResultAction.resultAction.Ignore;
  3892. switch (action) {
  3893. case TableResultAction.requestAction.Add:
  3894. resultAction = getAddResultActionToCell(cell);
  3895. break;
  3896. case TableResultAction.requestAction.Delete:
  3897. resultAction = getDeleteResultActionToCell(cell);
  3898. break;
  3899. }
  3900. _actionCellList.push(getActionCell(cell, resultAction, rowPosition, colPosition));
  3901. actualPosition++;
  3902. }
  3903. return _actionCellList;
  3904. };
  3905. init();
  3906. };
  3907. /**
  3908. *
  3909. * Where action occours enum.
  3910. */
  3911. TableResultAction.where = {
  3912. 'Row': 0,
  3913. 'Column': 1
  3914. };
  3915. /**
  3916. *
  3917. * Requested action to apply enum.
  3918. */
  3919. TableResultAction.requestAction = {
  3920. 'Add': 0,
  3921. 'Delete': 1
  3922. };
  3923. /**
  3924. *
  3925. * Result action to be executed enum.
  3926. */
  3927. TableResultAction.resultAction = {
  3928. 'Ignore': 0,
  3929. 'SubtractSpanCount': 1,
  3930. 'RemoveCell': 2,
  3931. 'AddCell': 3,
  3932. 'SumSpanCount': 4
  3933. };
  3934. /**
  3935. *
  3936. * @class editing.Table
  3937. *
  3938. * Table
  3939. *
  3940. */
  3941. var Table_Table =
  3942. /*#__PURE__*/
  3943. function () {
  3944. function Table() {
  3945. Table_classCallCheck(this, Table);
  3946. }
  3947. Table_createClass(Table, [{
  3948. key: "tab",
  3949. /**
  3950. * handle tab key
  3951. *
  3952. * @param {WrappedRange} rng
  3953. * @param {Boolean} isShift
  3954. */
  3955. value: function tab(rng, isShift) {
  3956. var cell = dom.ancestor(rng.commonAncestor(), dom.isCell);
  3957. var table = dom.ancestor(cell, dom.isTable);
  3958. var cells = dom.listDescendant(table, dom.isCell);
  3959. var nextCell = lists[isShift ? 'prev' : 'next'](cells, cell);
  3960. if (nextCell) {
  3961. range.create(nextCell, 0).select();
  3962. }
  3963. }
  3964. /**
  3965. * Add a new row
  3966. *
  3967. * @param {WrappedRange} rng
  3968. * @param {String} position (top/bottom)
  3969. * @return {Node}
  3970. */
  3971. }, {
  3972. key: "addRow",
  3973. value: function addRow(rng, position) {
  3974. var cell = dom.ancestor(rng.commonAncestor(), dom.isCell);
  3975. var currentTr = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(cell).closest('tr');
  3976. var trAttributes = this.recoverAttributes(currentTr);
  3977. var html = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<tr' + trAttributes + '></tr>');
  3978. var vTable = new TableResultAction(cell, TableResultAction.where.Row, TableResultAction.requestAction.Add, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(currentTr).closest('table')[0]);
  3979. var actions = vTable.getActionList();
  3980. for (var idCell = 0; idCell < actions.length; idCell++) {
  3981. var currentCell = actions[idCell];
  3982. var tdAttributes = this.recoverAttributes(currentCell.baseCell);
  3983. switch (currentCell.action) {
  3984. case TableResultAction.resultAction.AddCell:
  3985. html.append('<td' + tdAttributes + '>' + dom.blank + '</td>');
  3986. break;
  3987. case TableResultAction.resultAction.SumSpanCount:
  3988. {
  3989. if (position === 'top') {
  3990. var baseCellTr = currentCell.baseCell.parent;
  3991. var isTopFromRowSpan = (!baseCellTr ? 0 : currentCell.baseCell.closest('tr').rowIndex) <= currentTr[0].rowIndex;
  3992. if (isTopFromRowSpan) {
  3993. var newTd = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div></div>').append(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<td' + tdAttributes + '>' + dom.blank + '</td>').removeAttr('rowspan')).html();
  3994. html.append(newTd);
  3995. break;
  3996. }
  3997. }
  3998. var rowspanNumber = parseInt(currentCell.baseCell.rowSpan, 10);
  3999. rowspanNumber++;
  4000. currentCell.baseCell.setAttribute('rowSpan', rowspanNumber);
  4001. }
  4002. break;
  4003. }
  4004. }
  4005. if (position === 'top') {
  4006. currentTr.before(html);
  4007. } else {
  4008. var cellHasRowspan = cell.rowSpan > 1;
  4009. if (cellHasRowspan) {
  4010. var lastTrIndex = currentTr[0].rowIndex + (cell.rowSpan - 2);
  4011. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(currentTr).parent().find('tr')[lastTrIndex]).after(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(html));
  4012. return;
  4013. }
  4014. currentTr.after(html);
  4015. }
  4016. }
  4017. /**
  4018. * Add a new col
  4019. *
  4020. * @param {WrappedRange} rng
  4021. * @param {String} position (left/right)
  4022. * @return {Node}
  4023. */
  4024. }, {
  4025. key: "addCol",
  4026. value: function addCol(rng, position) {
  4027. var cell = dom.ancestor(rng.commonAncestor(), dom.isCell);
  4028. var row = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(cell).closest('tr');
  4029. var rowsGroup = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(row).siblings();
  4030. rowsGroup.push(row);
  4031. var vTable = new TableResultAction(cell, TableResultAction.where.Column, TableResultAction.requestAction.Add, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(row).closest('table')[0]);
  4032. var actions = vTable.getActionList();
  4033. for (var actionIndex = 0; actionIndex < actions.length; actionIndex++) {
  4034. var currentCell = actions[actionIndex];
  4035. var tdAttributes = this.recoverAttributes(currentCell.baseCell);
  4036. switch (currentCell.action) {
  4037. case TableResultAction.resultAction.AddCell:
  4038. if (position === 'right') {
  4039. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(currentCell.baseCell).after('<td' + tdAttributes + '>' + dom.blank + '</td>');
  4040. } else {
  4041. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(currentCell.baseCell).before('<td' + tdAttributes + '>' + dom.blank + '</td>');
  4042. }
  4043. break;
  4044. case TableResultAction.resultAction.SumSpanCount:
  4045. if (position === 'right') {
  4046. var colspanNumber = parseInt(currentCell.baseCell.colSpan, 10);
  4047. colspanNumber++;
  4048. currentCell.baseCell.setAttribute('colSpan', colspanNumber);
  4049. } else {
  4050. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(currentCell.baseCell).before('<td' + tdAttributes + '>' + dom.blank + '</td>');
  4051. }
  4052. break;
  4053. }
  4054. }
  4055. }
  4056. /*
  4057. * Copy attributes from element.
  4058. *
  4059. * @param {object} Element to recover attributes.
  4060. * @return {string} Copied string elements.
  4061. */
  4062. }, {
  4063. key: "recoverAttributes",
  4064. value: function recoverAttributes(el) {
  4065. var resultStr = '';
  4066. if (!el) {
  4067. return resultStr;
  4068. }
  4069. var attrList = el.attributes || [];
  4070. for (var i = 0; i < attrList.length; i++) {
  4071. if (attrList[i].name.toLowerCase() === 'id') {
  4072. continue;
  4073. }
  4074. if (attrList[i].specified) {
  4075. resultStr += ' ' + attrList[i].name + '=\'' + attrList[i].value + '\'';
  4076. }
  4077. }
  4078. return resultStr;
  4079. }
  4080. /**
  4081. * Delete current row
  4082. *
  4083. * @param {WrappedRange} rng
  4084. * @return {Node}
  4085. */
  4086. }, {
  4087. key: "deleteRow",
  4088. value: function deleteRow(rng) {
  4089. var cell = dom.ancestor(rng.commonAncestor(), dom.isCell);
  4090. var row = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(cell).closest('tr');
  4091. var cellPos = row.children('td, th').index(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(cell));
  4092. var rowPos = row[0].rowIndex;
  4093. var vTable = new TableResultAction(cell, TableResultAction.where.Row, TableResultAction.requestAction.Delete, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(row).closest('table')[0]);
  4094. var actions = vTable.getActionList();
  4095. for (var actionIndex = 0; actionIndex < actions.length; actionIndex++) {
  4096. if (!actions[actionIndex]) {
  4097. continue;
  4098. }
  4099. var baseCell = actions[actionIndex].baseCell;
  4100. var virtualPosition = actions[actionIndex].virtualTable;
  4101. var hasRowspan = baseCell.rowSpan && baseCell.rowSpan > 1;
  4102. var rowspanNumber = hasRowspan ? parseInt(baseCell.rowSpan, 10) : 0;
  4103. switch (actions[actionIndex].action) {
  4104. case TableResultAction.resultAction.Ignore:
  4105. continue;
  4106. case TableResultAction.resultAction.AddCell:
  4107. {
  4108. var nextRow = row.next('tr')[0];
  4109. if (!nextRow) {
  4110. continue;
  4111. }
  4112. var cloneRow = row[0].cells[cellPos];
  4113. if (hasRowspan) {
  4114. if (rowspanNumber > 2) {
  4115. rowspanNumber--;
  4116. nextRow.insertBefore(cloneRow, nextRow.cells[cellPos]);
  4117. nextRow.cells[cellPos].setAttribute('rowSpan', rowspanNumber);
  4118. nextRow.cells[cellPos].innerHTML = '';
  4119. } else if (rowspanNumber === 2) {
  4120. nextRow.insertBefore(cloneRow, nextRow.cells[cellPos]);
  4121. nextRow.cells[cellPos].removeAttribute('rowSpan');
  4122. nextRow.cells[cellPos].innerHTML = '';
  4123. }
  4124. }
  4125. }
  4126. continue;
  4127. case TableResultAction.resultAction.SubtractSpanCount:
  4128. if (hasRowspan) {
  4129. if (rowspanNumber > 2) {
  4130. rowspanNumber--;
  4131. baseCell.setAttribute('rowSpan', rowspanNumber);
  4132. if (virtualPosition.rowIndex !== rowPos && baseCell.cellIndex === cellPos) {
  4133. baseCell.innerHTML = '';
  4134. }
  4135. } else if (rowspanNumber === 2) {
  4136. baseCell.removeAttribute('rowSpan');
  4137. if (virtualPosition.rowIndex !== rowPos && baseCell.cellIndex === cellPos) {
  4138. baseCell.innerHTML = '';
  4139. }
  4140. }
  4141. }
  4142. continue;
  4143. case TableResultAction.resultAction.RemoveCell:
  4144. // Do not need remove cell because row will be deleted.
  4145. continue;
  4146. }
  4147. }
  4148. row.remove();
  4149. }
  4150. /**
  4151. * Delete current col
  4152. *
  4153. * @param {WrappedRange} rng
  4154. * @return {Node}
  4155. */
  4156. }, {
  4157. key: "deleteCol",
  4158. value: function deleteCol(rng) {
  4159. var cell = dom.ancestor(rng.commonAncestor(), dom.isCell);
  4160. var row = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(cell).closest('tr');
  4161. var cellPos = row.children('td, th').index(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(cell));
  4162. var vTable = new TableResultAction(cell, TableResultAction.where.Column, TableResultAction.requestAction.Delete, external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(row).closest('table')[0]);
  4163. var actions = vTable.getActionList();
  4164. for (var actionIndex = 0; actionIndex < actions.length; actionIndex++) {
  4165. if (!actions[actionIndex]) {
  4166. continue;
  4167. }
  4168. switch (actions[actionIndex].action) {
  4169. case TableResultAction.resultAction.Ignore:
  4170. continue;
  4171. case TableResultAction.resultAction.SubtractSpanCount:
  4172. {
  4173. var baseCell = actions[actionIndex].baseCell;
  4174. var hasColspan = baseCell.colSpan && baseCell.colSpan > 1;
  4175. if (hasColspan) {
  4176. var colspanNumber = baseCell.colSpan ? parseInt(baseCell.colSpan, 10) : 0;
  4177. if (colspanNumber > 2) {
  4178. colspanNumber--;
  4179. baseCell.setAttribute('colSpan', colspanNumber);
  4180. if (baseCell.cellIndex === cellPos) {
  4181. baseCell.innerHTML = '';
  4182. }
  4183. } else if (colspanNumber === 2) {
  4184. baseCell.removeAttribute('colSpan');
  4185. if (baseCell.cellIndex === cellPos) {
  4186. baseCell.innerHTML = '';
  4187. }
  4188. }
  4189. }
  4190. }
  4191. continue;
  4192. case TableResultAction.resultAction.RemoveCell:
  4193. dom.remove(actions[actionIndex].baseCell, true);
  4194. continue;
  4195. }
  4196. }
  4197. }
  4198. /**
  4199. * create empty table element
  4200. *
  4201. * @param {Number} rowCount
  4202. * @param {Number} colCount
  4203. * @return {Node}
  4204. */
  4205. }, {
  4206. key: "createTable",
  4207. value: function createTable(colCount, rowCount, options) {
  4208. var tds = [];
  4209. var tdHTML;
  4210. for (var idxCol = 0; idxCol < colCount; idxCol++) {
  4211. tds.push('<td>' + dom.blank + '</td>');
  4212. }
  4213. tdHTML = tds.join('');
  4214. var trs = [];
  4215. var trHTML;
  4216. for (var idxRow = 0; idxRow < rowCount; idxRow++) {
  4217. trs.push('<tr>' + tdHTML + '</tr>');
  4218. }
  4219. trHTML = trs.join('');
  4220. var $table = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<table>' + trHTML + '</table>');
  4221. if (options && options.tableClassName) {
  4222. $table.addClass(options.tableClassName);
  4223. }
  4224. return $table[0];
  4225. }
  4226. /**
  4227. * Delete current table
  4228. *
  4229. * @param {WrappedRange} rng
  4230. * @return {Node}
  4231. */
  4232. }, {
  4233. key: "deleteTable",
  4234. value: function deleteTable(rng) {
  4235. var cell = dom.ancestor(rng.commonAncestor(), dom.isCell);
  4236. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(cell).closest('table').remove();
  4237. }
  4238. }]);
  4239. return Table;
  4240. }();
  4241. // CONCATENATED MODULE: ./src/js/base/module/Editor.js
  4242. function Editor_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4243. function Editor_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); } }
  4244. function Editor_createClass(Constructor, protoProps, staticProps) { if (protoProps) Editor_defineProperties(Constructor.prototype, protoProps); if (staticProps) Editor_defineProperties(Constructor, staticProps); return Constructor; }
  4245. var KEY_BOGUS = 'bogus';
  4246. /**
  4247. * @class Editor
  4248. */
  4249. var Editor_Editor =
  4250. /*#__PURE__*/
  4251. function () {
  4252. function Editor(context) {
  4253. var _this = this;
  4254. Editor_classCallCheck(this, Editor);
  4255. this.context = context;
  4256. this.$note = context.layoutInfo.note;
  4257. this.$editor = context.layoutInfo.editor;
  4258. this.$editable = context.layoutInfo.editable;
  4259. this.options = context.options;
  4260. this.lang = this.options.langInfo;
  4261. this.editable = this.$editable[0];
  4262. this.lastRange = null;
  4263. this.snapshot = null;
  4264. this.style = new Style_Style();
  4265. this.table = new Table_Table();
  4266. this.typing = new Typing_Typing(context);
  4267. this.bullet = new Bullet_Bullet();
  4268. this.history = new History_History(context);
  4269. this.context.memo('help.undo', this.lang.help.undo);
  4270. this.context.memo('help.redo', this.lang.help.redo);
  4271. this.context.memo('help.tab', this.lang.help.tab);
  4272. this.context.memo('help.untab', this.lang.help.untab);
  4273. this.context.memo('help.insertParagraph', this.lang.help.insertParagraph);
  4274. this.context.memo('help.insertOrderedList', this.lang.help.insertOrderedList);
  4275. this.context.memo('help.insertUnorderedList', this.lang.help.insertUnorderedList);
  4276. this.context.memo('help.indent', this.lang.help.indent);
  4277. this.context.memo('help.outdent', this.lang.help.outdent);
  4278. this.context.memo('help.formatPara', this.lang.help.formatPara);
  4279. this.context.memo('help.insertHorizontalRule', this.lang.help.insertHorizontalRule);
  4280. this.context.memo('help.fontName', this.lang.help.fontName); // native commands(with execCommand), generate function for execCommand
  4281. var commands = ['bold', 'italic', 'underline', 'strikethrough', 'superscript', 'subscript', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'formatBlock', 'removeFormat', 'backColor'];
  4282. for (var idx = 0, len = commands.length; idx < len; idx++) {
  4283. this[commands[idx]] = function (sCmd) {
  4284. return function (value) {
  4285. _this.beforeCommand();
  4286. document.execCommand(sCmd, false, value);
  4287. _this.afterCommand(true);
  4288. };
  4289. }(commands[idx]);
  4290. this.context.memo('help.' + commands[idx], this.lang.help[commands[idx]]);
  4291. }
  4292. this.fontName = this.wrapCommand(function (value) {
  4293. return _this.fontStyling('font-family', env.validFontName(value));
  4294. });
  4295. this.fontSize = this.wrapCommand(function (value) {
  4296. var unit = _this.currentStyle()['font-size-unit'];
  4297. return _this.fontStyling('font-size', value + unit);
  4298. });
  4299. this.fontSizeUnit = this.wrapCommand(function (value) {
  4300. var size = _this.currentStyle()['font-size'];
  4301. return _this.fontStyling('font-size', size + value);
  4302. });
  4303. for (var _idx = 1; _idx <= 6; _idx++) {
  4304. this['formatH' + _idx] = function (idx) {
  4305. return function () {
  4306. _this.formatBlock('H' + idx);
  4307. };
  4308. }(_idx);
  4309. this.context.memo('help.formatH' + _idx, this.lang.help['formatH' + _idx]);
  4310. }
  4311. this.insertParagraph = this.wrapCommand(function () {
  4312. _this.typing.insertParagraph(_this.editable);
  4313. });
  4314. this.insertOrderedList = this.wrapCommand(function () {
  4315. _this.bullet.insertOrderedList(_this.editable);
  4316. });
  4317. this.insertUnorderedList = this.wrapCommand(function () {
  4318. _this.bullet.insertUnorderedList(_this.editable);
  4319. });
  4320. this.indent = this.wrapCommand(function () {
  4321. _this.bullet.indent(_this.editable);
  4322. });
  4323. this.outdent = this.wrapCommand(function () {
  4324. _this.bullet.outdent(_this.editable);
  4325. });
  4326. /**
  4327. * insertNode
  4328. * insert node
  4329. * @param {Node} node
  4330. */
  4331. this.insertNode = this.wrapCommand(function (node) {
  4332. if (_this.isLimited(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(node).text().length)) {
  4333. return;
  4334. }
  4335. var rng = _this.getLastRange();
  4336. rng.insertNode(node);
  4337. _this.setLastRange(range.createFromNodeAfter(node).select());
  4338. });
  4339. /**
  4340. * insert text
  4341. * @param {String} text
  4342. */
  4343. this.insertText = this.wrapCommand(function (text) {
  4344. if (_this.isLimited(text.length)) {
  4345. return;
  4346. }
  4347. var rng = _this.getLastRange();
  4348. var textNode = rng.insertNode(dom.createText(text));
  4349. _this.setLastRange(range.create(textNode, dom.nodeLength(textNode)).select());
  4350. });
  4351. /**
  4352. * paste HTML
  4353. * @param {String} markup
  4354. */
  4355. this.pasteHTML = this.wrapCommand(function (markup) {
  4356. if (_this.isLimited(markup.length)) {
  4357. return;
  4358. }
  4359. markup = _this.context.invoke('codeview.purify', markup);
  4360. var contents = _this.getLastRange().pasteHTML(markup);
  4361. _this.setLastRange(range.createFromNodeAfter(lists.last(contents)).select());
  4362. });
  4363. /**
  4364. * formatBlock
  4365. *
  4366. * @param {String} tagName
  4367. */
  4368. this.formatBlock = this.wrapCommand(function (tagName, $target) {
  4369. var onApplyCustomStyle = _this.options.callbacks.onApplyCustomStyle;
  4370. if (onApplyCustomStyle) {
  4371. onApplyCustomStyle.call(_this, $target, _this.context, _this.onFormatBlock);
  4372. } else {
  4373. _this.onFormatBlock(tagName, $target);
  4374. }
  4375. });
  4376. /**
  4377. * insert horizontal rule
  4378. */
  4379. this.insertHorizontalRule = this.wrapCommand(function () {
  4380. var hrNode = _this.getLastRange().insertNode(dom.create('HR'));
  4381. if (hrNode.nextSibling) {
  4382. _this.setLastRange(range.create(hrNode.nextSibling, 0).normalize().select());
  4383. }
  4384. });
  4385. /**
  4386. * lineHeight
  4387. * @param {String} value
  4388. */
  4389. this.lineHeight = this.wrapCommand(function (value) {
  4390. _this.style.stylePara(_this.getLastRange(), {
  4391. lineHeight: value
  4392. });
  4393. });
  4394. /**
  4395. * create link (command)
  4396. *
  4397. * @param {Object} linkInfo
  4398. */
  4399. this.createLink = this.wrapCommand(function (linkInfo) {
  4400. var linkUrl = linkInfo.url;
  4401. var linkText = linkInfo.text;
  4402. var isNewWindow = linkInfo.isNewWindow;
  4403. var checkProtocol = linkInfo.checkProtocol;
  4404. var rng = linkInfo.range || _this.getLastRange();
  4405. var additionalTextLength = linkText.length - rng.toString().length;
  4406. if (additionalTextLength > 0 && _this.isLimited(additionalTextLength)) {
  4407. return;
  4408. }
  4409. var isTextChanged = rng.toString() !== linkText; // handle spaced urls from input
  4410. if (typeof linkUrl === 'string') {
  4411. linkUrl = linkUrl.trim();
  4412. }
  4413. if (_this.options.onCreateLink) {
  4414. linkUrl = _this.options.onCreateLink(linkUrl);
  4415. } else if (checkProtocol) {
  4416. // if url doesn't have any protocol and not even a relative or a label, use http:// as default
  4417. linkUrl = /^([A-Za-z][A-Za-z0-9+-.]*\:|#|\/)/.test(linkUrl) ? linkUrl : _this.options.defaultProtocol + linkUrl;
  4418. }
  4419. var anchors = [];
  4420. if (isTextChanged) {
  4421. rng = rng.deleteContents();
  4422. var anchor = rng.insertNode(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<A>' + linkText + '</A>')[0]);
  4423. anchors.push(anchor);
  4424. } else {
  4425. anchors = _this.style.styleNodes(rng, {
  4426. nodeName: 'A',
  4427. expandClosestSibling: true,
  4428. onlyPartialContains: true
  4429. });
  4430. }
  4431. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(anchors, function (idx, anchor) {
  4432. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(anchor).attr('href', linkUrl);
  4433. if (isNewWindow) {
  4434. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(anchor).attr('target', '_blank');
  4435. } else {
  4436. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(anchor).removeAttr('target');
  4437. }
  4438. });
  4439. var startRange = range.createFromNodeBefore(lists.head(anchors));
  4440. var startPoint = startRange.getStartPoint();
  4441. var endRange = range.createFromNodeAfter(lists.last(anchors));
  4442. var endPoint = endRange.getEndPoint();
  4443. _this.setLastRange(range.create(startPoint.node, startPoint.offset, endPoint.node, endPoint.offset).select());
  4444. });
  4445. /**
  4446. * setting color
  4447. *
  4448. * @param {Object} sObjColor color code
  4449. * @param {String} sObjColor.foreColor foreground color
  4450. * @param {String} sObjColor.backColor background color
  4451. */
  4452. this.color = this.wrapCommand(function (colorInfo) {
  4453. var foreColor = colorInfo.foreColor;
  4454. var backColor = colorInfo.backColor;
  4455. if (foreColor) {
  4456. document.execCommand('foreColor', false, foreColor);
  4457. }
  4458. if (backColor) {
  4459. document.execCommand('backColor', false, backColor);
  4460. }
  4461. });
  4462. /**
  4463. * Set foreground color
  4464. *
  4465. * @param {String} colorCode foreground color code
  4466. */
  4467. this.foreColor = this.wrapCommand(function (colorInfo) {
  4468. document.execCommand('foreColor', false, colorInfo);
  4469. });
  4470. /**
  4471. * insert Table
  4472. *
  4473. * @param {String} dimension of table (ex : "5x5")
  4474. */
  4475. this.insertTable = this.wrapCommand(function (dim) {
  4476. var dimension = dim.split('x');
  4477. var rng = _this.getLastRange().deleteContents();
  4478. rng.insertNode(_this.table.createTable(dimension[0], dimension[1], _this.options));
  4479. });
  4480. /**
  4481. * remove media object and Figure Elements if media object is img with Figure.
  4482. */
  4483. this.removeMedia = this.wrapCommand(function () {
  4484. var $target = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(_this.restoreTarget()).parent();
  4485. if ($target.closest('figure').length) {
  4486. $target.closest('figure').remove();
  4487. } else {
  4488. $target = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(_this.restoreTarget()).detach();
  4489. }
  4490. _this.context.triggerEvent('media.delete', $target, _this.$editable);
  4491. });
  4492. /**
  4493. * float me
  4494. *
  4495. * @param {String} value
  4496. */
  4497. this.floatMe = this.wrapCommand(function (value) {
  4498. var $target = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(_this.restoreTarget());
  4499. $target.toggleClass('note-float-left', value === 'left');
  4500. $target.toggleClass('note-float-right', value === 'right');
  4501. $target.css('float', value === 'none' ? '' : value);
  4502. });
  4503. /**
  4504. * resize overlay element
  4505. * @param {String} value
  4506. */
  4507. this.resize = this.wrapCommand(function (value) {
  4508. var $target = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(_this.restoreTarget());
  4509. value = parseFloat(value);
  4510. if (value === 0) {
  4511. $target.css('width', '');
  4512. } else {
  4513. $target.css({
  4514. width: value * 100 + '%',
  4515. height: ''
  4516. });
  4517. }
  4518. });
  4519. }
  4520. Editor_createClass(Editor, [{
  4521. key: "initialize",
  4522. value: function initialize() {
  4523. var _this2 = this;
  4524. // bind custom events
  4525. this.$editable.on('keydown', function (event) {
  4526. if (event.keyCode === core_key.code.ENTER) {
  4527. _this2.context.triggerEvent('enter', event);
  4528. }
  4529. _this2.context.triggerEvent('keydown', event); // keep a snapshot to limit text on input event
  4530. _this2.snapshot = _this2.history.makeSnapshot();
  4531. _this2.hasKeyShortCut = false;
  4532. if (!event.isDefaultPrevented()) {
  4533. if (_this2.options.shortcuts) {
  4534. _this2.hasKeyShortCut = _this2.handleKeyMap(event);
  4535. } else {
  4536. _this2.preventDefaultEditableShortCuts(event);
  4537. }
  4538. }
  4539. if (_this2.isLimited(1, event)) {
  4540. var lastRange = _this2.getLastRange();
  4541. if (lastRange.eo - lastRange.so === 0) {
  4542. return false;
  4543. }
  4544. }
  4545. _this2.setLastRange(); // record undo in the key event except keyMap.
  4546. if (_this2.options.recordEveryKeystroke) {
  4547. if (_this2.hasKeyShortCut === false) {
  4548. _this2.history.recordUndo();
  4549. }
  4550. }
  4551. }).on('keyup', function (event) {
  4552. _this2.setLastRange();
  4553. _this2.context.triggerEvent('keyup', event);
  4554. }).on('focus', function (event) {
  4555. _this2.setLastRange();
  4556. _this2.context.triggerEvent('focus', event);
  4557. }).on('blur', function (event) {
  4558. _this2.context.triggerEvent('blur', event);
  4559. }).on('mousedown', function (event) {
  4560. _this2.context.triggerEvent('mousedown', event);
  4561. }).on('mouseup', function (event) {
  4562. _this2.setLastRange();
  4563. _this2.history.recordUndo();
  4564. _this2.context.triggerEvent('mouseup', event);
  4565. }).on('scroll', function (event) {
  4566. _this2.context.triggerEvent('scroll', event);
  4567. }).on('paste', function (event) {
  4568. _this2.setLastRange();
  4569. _this2.context.triggerEvent('paste', event);
  4570. }).on('input', function () {
  4571. // To limit composition characters (e.g. Korean)
  4572. if (_this2.isLimited(0) && _this2.snapshot) {
  4573. _this2.history.applySnapshot(_this2.snapshot);
  4574. }
  4575. });
  4576. this.$editable.attr('spellcheck', this.options.spellCheck);
  4577. this.$editable.attr('autocorrect', this.options.spellCheck);
  4578. if (this.options.disableGrammar) {
  4579. this.$editable.attr('data-gramm', false);
  4580. } // init content before set event
  4581. this.$editable.html(dom.html(this.$note) || dom.emptyPara);
  4582. this.$editable.on(env.inputEventName, func.debounce(function () {
  4583. _this2.context.triggerEvent('change', _this2.$editable.html(), _this2.$editable);
  4584. }, 10));
  4585. this.$editable.on('focusin', function (event) {
  4586. _this2.context.triggerEvent('focusin', event);
  4587. }).on('focusout', function (event) {
  4588. _this2.context.triggerEvent('focusout', event);
  4589. });
  4590. if (this.options.airMode) {
  4591. if (this.options.overrideContextMenu) {
  4592. this.$editor.on('contextmenu', function (event) {
  4593. _this2.context.triggerEvent('contextmenu', event);
  4594. return false;
  4595. });
  4596. }
  4597. } else {
  4598. if (this.options.width) {
  4599. this.$editor.outerWidth(this.options.width);
  4600. }
  4601. if (this.options.height) {
  4602. this.$editable.outerHeight(this.options.height);
  4603. }
  4604. if (this.options.maxHeight) {
  4605. this.$editable.css('max-height', this.options.maxHeight);
  4606. }
  4607. if (this.options.minHeight) {
  4608. this.$editable.css('min-height', this.options.minHeight);
  4609. }
  4610. }
  4611. this.history.recordUndo();
  4612. this.setLastRange();
  4613. }
  4614. }, {
  4615. key: "destroy",
  4616. value: function destroy() {
  4617. this.$editable.off();
  4618. }
  4619. }, {
  4620. key: "handleKeyMap",
  4621. value: function handleKeyMap(event) {
  4622. var keyMap = this.options.keyMap[env.isMac ? 'mac' : 'pc'];
  4623. var keys = [];
  4624. if (event.metaKey) {
  4625. keys.push('CMD');
  4626. }
  4627. if (event.ctrlKey && !event.altKey) {
  4628. keys.push('CTRL');
  4629. }
  4630. if (event.shiftKey) {
  4631. keys.push('SHIFT');
  4632. }
  4633. var keyName = core_key.nameFromCode[event.keyCode];
  4634. if (keyName) {
  4635. keys.push(keyName);
  4636. }
  4637. var eventName = keyMap[keys.join('+')];
  4638. if (keyName === 'TAB' && !this.options.tabDisable) {
  4639. this.afterCommand();
  4640. } else if (eventName) {
  4641. if (this.context.invoke(eventName) !== false) {
  4642. event.preventDefault(); // if keyMap action was invoked
  4643. return true;
  4644. }
  4645. } else if (core_key.isEdit(event.keyCode)) {
  4646. this.afterCommand();
  4647. }
  4648. return false;
  4649. }
  4650. }, {
  4651. key: "preventDefaultEditableShortCuts",
  4652. value: function preventDefaultEditableShortCuts(event) {
  4653. // B(Bold, 66) / I(Italic, 73) / U(Underline, 85)
  4654. if ((event.ctrlKey || event.metaKey) && lists.contains([66, 73, 85], event.keyCode)) {
  4655. event.preventDefault();
  4656. }
  4657. }
  4658. }, {
  4659. key: "isLimited",
  4660. value: function isLimited(pad, event) {
  4661. pad = pad || 0;
  4662. if (typeof event !== 'undefined') {
  4663. if (core_key.isMove(event.keyCode) || core_key.isNavigation(event.keyCode) || event.ctrlKey || event.metaKey || lists.contains([core_key.code.BACKSPACE, core_key.code.DELETE], event.keyCode)) {
  4664. return false;
  4665. }
  4666. }
  4667. if (this.options.maxTextLength > 0) {
  4668. if (this.$editable.text().length + pad > this.options.maxTextLength) {
  4669. return true;
  4670. }
  4671. }
  4672. return false;
  4673. }
  4674. /**
  4675. * create range
  4676. * @return {WrappedRange}
  4677. */
  4678. }, {
  4679. key: "createRange",
  4680. value: function createRange() {
  4681. this.focus();
  4682. this.setLastRange();
  4683. return this.getLastRange();
  4684. }
  4685. }, {
  4686. key: "setLastRange",
  4687. value: function setLastRange(rng) {
  4688. if (rng) {
  4689. this.lastRange = rng;
  4690. } else {
  4691. this.lastRange = range.create(this.editable);
  4692. if (external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.lastRange.sc).closest('.note-editable').length === 0) {
  4693. this.lastRange = range.createFromBodyElement(this.editable);
  4694. }
  4695. }
  4696. }
  4697. }, {
  4698. key: "getLastRange",
  4699. value: function getLastRange() {
  4700. if (!this.lastRange) {
  4701. this.setLastRange();
  4702. }
  4703. return this.lastRange;
  4704. }
  4705. /**
  4706. * saveRange
  4707. *
  4708. * save current range
  4709. *
  4710. * @param {Boolean} [thenCollapse=false]
  4711. */
  4712. }, {
  4713. key: "saveRange",
  4714. value: function saveRange(thenCollapse) {
  4715. if (thenCollapse) {
  4716. this.getLastRange().collapse().select();
  4717. }
  4718. }
  4719. /**
  4720. * restoreRange
  4721. *
  4722. * restore lately range
  4723. */
  4724. }, {
  4725. key: "restoreRange",
  4726. value: function restoreRange() {
  4727. if (this.lastRange) {
  4728. this.lastRange.select();
  4729. this.focus();
  4730. }
  4731. }
  4732. }, {
  4733. key: "saveTarget",
  4734. value: function saveTarget(node) {
  4735. this.$editable.data('target', node);
  4736. }
  4737. }, {
  4738. key: "clearTarget",
  4739. value: function clearTarget() {
  4740. this.$editable.removeData('target');
  4741. }
  4742. }, {
  4743. key: "restoreTarget",
  4744. value: function restoreTarget() {
  4745. return this.$editable.data('target');
  4746. }
  4747. /**
  4748. * currentStyle
  4749. *
  4750. * current style
  4751. * @return {Object|Boolean} unfocus
  4752. */
  4753. }, {
  4754. key: "currentStyle",
  4755. value: function currentStyle() {
  4756. var rng = range.create();
  4757. if (rng) {
  4758. rng = rng.normalize();
  4759. }
  4760. return rng ? this.style.current(rng) : this.style.fromNode(this.$editable);
  4761. }
  4762. /**
  4763. * style from node
  4764. *
  4765. * @param {jQuery} $node
  4766. * @return {Object}
  4767. */
  4768. }, {
  4769. key: "styleFromNode",
  4770. value: function styleFromNode($node) {
  4771. return this.style.fromNode($node);
  4772. }
  4773. /**
  4774. * undo
  4775. */
  4776. }, {
  4777. key: "undo",
  4778. value: function undo() {
  4779. this.context.triggerEvent('before.command', this.$editable.html());
  4780. this.history.undo();
  4781. this.context.triggerEvent('change', this.$editable.html(), this.$editable);
  4782. }
  4783. /*
  4784. * commit
  4785. */
  4786. }, {
  4787. key: "commit",
  4788. value: function commit() {
  4789. this.context.triggerEvent('before.command', this.$editable.html());
  4790. this.history.commit();
  4791. this.context.triggerEvent('change', this.$editable.html(), this.$editable);
  4792. }
  4793. /**
  4794. * redo
  4795. */
  4796. }, {
  4797. key: "redo",
  4798. value: function redo() {
  4799. this.context.triggerEvent('before.command', this.$editable.html());
  4800. this.history.redo();
  4801. this.context.triggerEvent('change', this.$editable.html(), this.$editable);
  4802. }
  4803. /**
  4804. * before command
  4805. */
  4806. }, {
  4807. key: "beforeCommand",
  4808. value: function beforeCommand() {
  4809. this.context.triggerEvent('before.command', this.$editable.html()); // Set styleWithCSS before run a command
  4810. document.execCommand('styleWithCSS', false, this.options.styleWithCSS); // keep focus on editable before command execution
  4811. this.focus();
  4812. }
  4813. /**
  4814. * after command
  4815. * @param {Boolean} isPreventTrigger
  4816. */
  4817. }, {
  4818. key: "afterCommand",
  4819. value: function afterCommand(isPreventTrigger) {
  4820. this.normalizeContent();
  4821. this.history.recordUndo();
  4822. if (!isPreventTrigger) {
  4823. this.context.triggerEvent('change', this.$editable.html(), this.$editable);
  4824. }
  4825. }
  4826. /**
  4827. * handle tab key
  4828. */
  4829. }, {
  4830. key: "tab",
  4831. value: function tab() {
  4832. var rng = this.getLastRange();
  4833. if (rng.isCollapsed() && rng.isOnCell()) {
  4834. this.table.tab(rng);
  4835. } else {
  4836. if (this.options.tabSize === 0) {
  4837. return false;
  4838. }
  4839. if (!this.isLimited(this.options.tabSize)) {
  4840. this.beforeCommand();
  4841. this.typing.insertTab(rng, this.options.tabSize);
  4842. this.afterCommand();
  4843. }
  4844. }
  4845. }
  4846. /**
  4847. * handle shift+tab key
  4848. */
  4849. }, {
  4850. key: "untab",
  4851. value: function untab() {
  4852. var rng = this.getLastRange();
  4853. if (rng.isCollapsed() && rng.isOnCell()) {
  4854. this.table.tab(rng, true);
  4855. } else {
  4856. if (this.options.tabSize === 0) {
  4857. return false;
  4858. }
  4859. }
  4860. }
  4861. /**
  4862. * run given function between beforeCommand and afterCommand
  4863. */
  4864. }, {
  4865. key: "wrapCommand",
  4866. value: function wrapCommand(fn) {
  4867. return function () {
  4868. this.beforeCommand();
  4869. fn.apply(this, arguments);
  4870. this.afterCommand();
  4871. };
  4872. }
  4873. /**
  4874. * insert image
  4875. *
  4876. * @param {String} src
  4877. * @param {String|Function} param
  4878. * @return {Promise}
  4879. */
  4880. }, {
  4881. key: "insertImage",
  4882. value: function insertImage(src, param) {
  4883. var _this3 = this;
  4884. return createImage(src, param).then(function ($image) {
  4885. _this3.beforeCommand();
  4886. if (typeof param === 'function') {
  4887. param($image);
  4888. } else {
  4889. if (typeof param === 'string') {
  4890. $image.attr('data-filename', param);
  4891. }
  4892. $image.css('width', Math.min(_this3.$editable.width(), $image.width()));
  4893. }
  4894. $image.show();
  4895. _this3.getLastRange().insertNode($image[0]);
  4896. _this3.setLastRange(range.createFromNodeAfter($image[0]).select());
  4897. _this3.afterCommand();
  4898. }).fail(function (e) {
  4899. _this3.context.triggerEvent('image.upload.error', e);
  4900. });
  4901. }
  4902. /**
  4903. * insertImages
  4904. * @param {File[]} files
  4905. */
  4906. }, {
  4907. key: "insertImagesAsDataURL",
  4908. value: function insertImagesAsDataURL(files) {
  4909. var _this4 = this;
  4910. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(files, function (idx, file) {
  4911. var filename = file.name;
  4912. if (_this4.options.maximumImageFileSize && _this4.options.maximumImageFileSize < file.size) {
  4913. _this4.context.triggerEvent('image.upload.error', _this4.lang.image.maximumFileSizeError);
  4914. } else {
  4915. readFileAsDataURL(file).then(function (dataURL) {
  4916. return _this4.insertImage(dataURL, filename);
  4917. }).fail(function () {
  4918. _this4.context.triggerEvent('image.upload.error');
  4919. });
  4920. }
  4921. });
  4922. }
  4923. /**
  4924. * insertImagesOrCallback
  4925. * @param {File[]} files
  4926. */
  4927. }, {
  4928. key: "insertImagesOrCallback",
  4929. value: function insertImagesOrCallback(files) {
  4930. var callbacks = this.options.callbacks; // If onImageUpload set,
  4931. if (callbacks.onImageUpload) {
  4932. this.context.triggerEvent('image.upload', files); // else insert Image as dataURL
  4933. } else {
  4934. this.insertImagesAsDataURL(files);
  4935. }
  4936. }
  4937. /**
  4938. * return selected plain text
  4939. * @return {String} text
  4940. */
  4941. }, {
  4942. key: "getSelectedText",
  4943. value: function getSelectedText() {
  4944. var rng = this.getLastRange(); // if range on anchor, expand range with anchor
  4945. if (rng.isOnAnchor()) {
  4946. rng = range.createFromNode(dom.ancestor(rng.sc, dom.isAnchor));
  4947. }
  4948. return rng.toString();
  4949. }
  4950. }, {
  4951. key: "onFormatBlock",
  4952. value: function onFormatBlock(tagName, $target) {
  4953. // [workaround] for MSIE, IE need `<`
  4954. document.execCommand('FormatBlock', false, env.isMSIE ? '<' + tagName + '>' : tagName); // support custom class
  4955. if ($target && $target.length) {
  4956. // find the exact element has given tagName
  4957. if ($target[0].tagName.toUpperCase() !== tagName.toUpperCase()) {
  4958. $target = $target.find(tagName);
  4959. }
  4960. if ($target && $target.length) {
  4961. var className = $target[0].className || '';
  4962. if (className) {
  4963. var currentRange = this.createRange();
  4964. var $parent = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()([currentRange.sc, currentRange.ec]).closest(tagName);
  4965. $parent.addClass(className);
  4966. }
  4967. }
  4968. }
  4969. }
  4970. }, {
  4971. key: "formatPara",
  4972. value: function formatPara() {
  4973. this.formatBlock('P');
  4974. }
  4975. }, {
  4976. key: "fontStyling",
  4977. value: function fontStyling(target, value) {
  4978. var rng = this.getLastRange();
  4979. if (rng !== '') {
  4980. var spans = this.style.styleNodes(rng);
  4981. this.$editor.find('.note-status-output').html('');
  4982. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(spans).css(target, value); // [workaround] added styled bogus span for style
  4983. // - also bogus character needed for cursor position
  4984. if (rng.isCollapsed()) {
  4985. var firstSpan = lists.head(spans);
  4986. if (firstSpan && !dom.nodeLength(firstSpan)) {
  4987. firstSpan.innerHTML = dom.ZERO_WIDTH_NBSP_CHAR;
  4988. range.createFromNodeAfter(firstSpan.firstChild).select();
  4989. this.setLastRange();
  4990. this.$editable.data(KEY_BOGUS, firstSpan);
  4991. }
  4992. }
  4993. } else {
  4994. var noteStatusOutput = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.now();
  4995. this.$editor.find('.note-status-output').html('<div id="note-status-output-' + noteStatusOutput + '" class="alert alert-info">' + this.lang.output.noSelection + '</div>');
  4996. setTimeout(function () {
  4997. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('#note-status-output-' + noteStatusOutput).remove();
  4998. }, 5000);
  4999. }
  5000. }
  5001. /**
  5002. * unlink
  5003. *
  5004. * @type command
  5005. */
  5006. }, {
  5007. key: "unlink",
  5008. value: function unlink() {
  5009. var rng = this.getLastRange();
  5010. if (rng.isOnAnchor()) {
  5011. var anchor = dom.ancestor(rng.sc, dom.isAnchor);
  5012. rng = range.createFromNode(anchor);
  5013. rng.select();
  5014. this.setLastRange();
  5015. this.beforeCommand();
  5016. document.execCommand('unlink');
  5017. this.afterCommand();
  5018. }
  5019. }
  5020. /**
  5021. * returns link info
  5022. *
  5023. * @return {Object}
  5024. * @return {WrappedRange} return.range
  5025. * @return {String} return.text
  5026. * @return {Boolean} [return.isNewWindow=true]
  5027. * @return {String} [return.url=""]
  5028. */
  5029. }, {
  5030. key: "getLinkInfo",
  5031. value: function getLinkInfo() {
  5032. var rng = this.getLastRange().expand(dom.isAnchor); // Get the first anchor on range(for edit).
  5033. var $anchor = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(lists.head(rng.nodes(dom.isAnchor)));
  5034. var linkInfo = {
  5035. range: rng,
  5036. text: rng.toString(),
  5037. url: $anchor.length ? $anchor.attr('href') : ''
  5038. }; // When anchor exists,
  5039. if ($anchor.length) {
  5040. // Set isNewWindow by checking its target.
  5041. linkInfo.isNewWindow = $anchor.attr('target') === '_blank';
  5042. }
  5043. return linkInfo;
  5044. }
  5045. }, {
  5046. key: "addRow",
  5047. value: function addRow(position) {
  5048. var rng = this.getLastRange(this.$editable);
  5049. if (rng.isCollapsed() && rng.isOnCell()) {
  5050. this.beforeCommand();
  5051. this.table.addRow(rng, position);
  5052. this.afterCommand();
  5053. }
  5054. }
  5055. }, {
  5056. key: "addCol",
  5057. value: function addCol(position) {
  5058. var rng = this.getLastRange(this.$editable);
  5059. if (rng.isCollapsed() && rng.isOnCell()) {
  5060. this.beforeCommand();
  5061. this.table.addCol(rng, position);
  5062. this.afterCommand();
  5063. }
  5064. }
  5065. }, {
  5066. key: "deleteRow",
  5067. value: function deleteRow() {
  5068. var rng = this.getLastRange(this.$editable);
  5069. if (rng.isCollapsed() && rng.isOnCell()) {
  5070. this.beforeCommand();
  5071. this.table.deleteRow(rng);
  5072. this.afterCommand();
  5073. }
  5074. }
  5075. }, {
  5076. key: "deleteCol",
  5077. value: function deleteCol() {
  5078. var rng = this.getLastRange(this.$editable);
  5079. if (rng.isCollapsed() && rng.isOnCell()) {
  5080. this.beforeCommand();
  5081. this.table.deleteCol(rng);
  5082. this.afterCommand();
  5083. }
  5084. }
  5085. }, {
  5086. key: "deleteTable",
  5087. value: function deleteTable() {
  5088. var rng = this.getLastRange(this.$editable);
  5089. if (rng.isCollapsed() && rng.isOnCell()) {
  5090. this.beforeCommand();
  5091. this.table.deleteTable(rng);
  5092. this.afterCommand();
  5093. }
  5094. }
  5095. /**
  5096. * @param {Position} pos
  5097. * @param {jQuery} $target - target element
  5098. * @param {Boolean} [bKeepRatio] - keep ratio
  5099. */
  5100. }, {
  5101. key: "resizeTo",
  5102. value: function resizeTo(pos, $target, bKeepRatio) {
  5103. var imageSize;
  5104. if (bKeepRatio) {
  5105. var newRatio = pos.y / pos.x;
  5106. var ratio = $target.data('ratio');
  5107. imageSize = {
  5108. width: ratio > newRatio ? pos.x : pos.y / ratio,
  5109. height: ratio > newRatio ? pos.x * ratio : pos.y
  5110. };
  5111. } else {
  5112. imageSize = {
  5113. width: pos.x,
  5114. height: pos.y
  5115. };
  5116. }
  5117. $target.css(imageSize);
  5118. }
  5119. /**
  5120. * returns whether editable area has focus or not.
  5121. */
  5122. }, {
  5123. key: "hasFocus",
  5124. value: function hasFocus() {
  5125. return this.$editable.is(':focus');
  5126. }
  5127. /**
  5128. * set focus
  5129. */
  5130. }, {
  5131. key: "focus",
  5132. value: function focus() {
  5133. // [workaround] Screen will move when page is scolled in IE.
  5134. // - do focus when not focused
  5135. if (!this.hasFocus()) {
  5136. this.$editable.focus();
  5137. }
  5138. }
  5139. /**
  5140. * returns whether contents is empty or not.
  5141. * @return {Boolean}
  5142. */
  5143. }, {
  5144. key: "isEmpty",
  5145. value: function isEmpty() {
  5146. return dom.isEmpty(this.$editable[0]) || dom.emptyPara === this.$editable.html();
  5147. }
  5148. /**
  5149. * Removes all contents and restores the editable instance to an _emptyPara_.
  5150. */
  5151. }, {
  5152. key: "empty",
  5153. value: function empty() {
  5154. this.context.invoke('code', dom.emptyPara);
  5155. }
  5156. /**
  5157. * normalize content
  5158. */
  5159. }, {
  5160. key: "normalizeContent",
  5161. value: function normalizeContent() {
  5162. this.$editable[0].normalize();
  5163. }
  5164. }]);
  5165. return Editor;
  5166. }();
  5167. // CONCATENATED MODULE: ./src/js/base/module/Clipboard.js
  5168. function Clipboard_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5169. function Clipboard_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); } }
  5170. function Clipboard_createClass(Constructor, protoProps, staticProps) { if (protoProps) Clipboard_defineProperties(Constructor.prototype, protoProps); if (staticProps) Clipboard_defineProperties(Constructor, staticProps); return Constructor; }
  5171. var Clipboard_Clipboard =
  5172. /*#__PURE__*/
  5173. function () {
  5174. function Clipboard(context) {
  5175. Clipboard_classCallCheck(this, Clipboard);
  5176. this.context = context;
  5177. this.$editable = context.layoutInfo.editable;
  5178. }
  5179. Clipboard_createClass(Clipboard, [{
  5180. key: "initialize",
  5181. value: function initialize() {
  5182. this.$editable.on('paste', this.pasteByEvent.bind(this));
  5183. }
  5184. /**
  5185. * paste by clipboard event
  5186. *
  5187. * @param {Event} event
  5188. */
  5189. }, {
  5190. key: "pasteByEvent",
  5191. value: function pasteByEvent(event) {
  5192. var _this = this;
  5193. var clipboardData = event.originalEvent.clipboardData;
  5194. if (clipboardData && clipboardData.items && clipboardData.items.length) {
  5195. var item = clipboardData.items.length > 1 ? clipboardData.items[1] : lists.head(clipboardData.items);
  5196. if (item.kind === 'file' && item.type.indexOf('image/') !== -1) {
  5197. // paste img file
  5198. this.context.invoke('editor.insertImagesOrCallback', [item.getAsFile()]);
  5199. event.preventDefault();
  5200. } else if (item.kind === 'string') {
  5201. // paste text with maxTextLength check
  5202. if (this.context.invoke('editor.isLimited', clipboardData.getData('Text').length)) {
  5203. event.preventDefault();
  5204. }
  5205. }
  5206. } else if (window.clipboardData) {
  5207. // for IE
  5208. var text = window.clipboardData.getData('text');
  5209. if (this.context.invoke('editor.isLimited', text.length)) {
  5210. event.preventDefault();
  5211. }
  5212. } // Call editor.afterCommand after proceeding default event handler
  5213. setTimeout(function () {
  5214. _this.context.invoke('editor.afterCommand');
  5215. }, 10);
  5216. }
  5217. }]);
  5218. return Clipboard;
  5219. }();
  5220. // CONCATENATED MODULE: ./src/js/base/module/Dropzone.js
  5221. function Dropzone_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5222. function Dropzone_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); } }
  5223. function Dropzone_createClass(Constructor, protoProps, staticProps) { if (protoProps) Dropzone_defineProperties(Constructor.prototype, protoProps); if (staticProps) Dropzone_defineProperties(Constructor, staticProps); return Constructor; }
  5224. var Dropzone_Dropzone =
  5225. /*#__PURE__*/
  5226. function () {
  5227. function Dropzone(context) {
  5228. Dropzone_classCallCheck(this, Dropzone);
  5229. this.context = context;
  5230. this.$eventListener = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document);
  5231. this.$editor = context.layoutInfo.editor;
  5232. this.$editable = context.layoutInfo.editable;
  5233. this.options = context.options;
  5234. this.lang = this.options.langInfo;
  5235. this.documentEventHandlers = {};
  5236. this.$dropzone = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(['<div class="note-dropzone">', '<div class="note-dropzone-message"/>', '</div>'].join('')).prependTo(this.$editor);
  5237. }
  5238. /**
  5239. * attach Drag and Drop Events
  5240. */
  5241. Dropzone_createClass(Dropzone, [{
  5242. key: "initialize",
  5243. value: function initialize() {
  5244. if (this.options.disableDragAndDrop) {
  5245. // prevent default drop event
  5246. this.documentEventHandlers.onDrop = function (e) {
  5247. e.preventDefault();
  5248. }; // do not consider outside of dropzone
  5249. this.$eventListener = this.$dropzone;
  5250. this.$eventListener.on('drop', this.documentEventHandlers.onDrop);
  5251. } else {
  5252. this.attachDragAndDropEvent();
  5253. }
  5254. }
  5255. /**
  5256. * attach Drag and Drop Events
  5257. */
  5258. }, {
  5259. key: "attachDragAndDropEvent",
  5260. value: function attachDragAndDropEvent() {
  5261. var _this = this;
  5262. var collection = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()();
  5263. var $dropzoneMessage = this.$dropzone.find('.note-dropzone-message');
  5264. this.documentEventHandlers.onDragenter = function (e) {
  5265. var isCodeview = _this.context.invoke('codeview.isActivated');
  5266. var hasEditorSize = _this.$editor.width() > 0 && _this.$editor.height() > 0;
  5267. if (!isCodeview && !collection.length && hasEditorSize) {
  5268. _this.$editor.addClass('dragover');
  5269. _this.$dropzone.width(_this.$editor.width());
  5270. _this.$dropzone.height(_this.$editor.height());
  5271. $dropzoneMessage.text(_this.lang.image.dragImageHere);
  5272. }
  5273. collection = collection.add(e.target);
  5274. };
  5275. this.documentEventHandlers.onDragleave = function (e) {
  5276. collection = collection.not(e.target); // If nodeName is BODY, then just make it over (fix for IE)
  5277. if (!collection.length || e.target.nodeName === 'BODY') {
  5278. collection = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()();
  5279. _this.$editor.removeClass('dragover');
  5280. }
  5281. };
  5282. this.documentEventHandlers.onDrop = function () {
  5283. collection = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()();
  5284. _this.$editor.removeClass('dragover');
  5285. }; // show dropzone on dragenter when dragging a object to document
  5286. // -but only if the editor is visible, i.e. has a positive width and height
  5287. this.$eventListener.on('dragenter', this.documentEventHandlers.onDragenter).on('dragleave', this.documentEventHandlers.onDragleave).on('drop', this.documentEventHandlers.onDrop); // change dropzone's message on hover.
  5288. this.$dropzone.on('dragenter', function () {
  5289. _this.$dropzone.addClass('hover');
  5290. $dropzoneMessage.text(_this.lang.image.dropImage);
  5291. }).on('dragleave', function () {
  5292. _this.$dropzone.removeClass('hover');
  5293. $dropzoneMessage.text(_this.lang.image.dragImageHere);
  5294. }); // attach dropImage
  5295. this.$dropzone.on('drop', function (event) {
  5296. var dataTransfer = event.originalEvent.dataTransfer; // stop the browser from opening the dropped content
  5297. event.preventDefault();
  5298. if (dataTransfer && dataTransfer.files && dataTransfer.files.length) {
  5299. _this.$editable.focus();
  5300. _this.context.invoke('editor.insertImagesOrCallback', dataTransfer.files);
  5301. } else {
  5302. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(dataTransfer.types, function (idx, type) {
  5303. // skip moz-specific types
  5304. if (type.toLowerCase().indexOf('_moz_') > -1) {
  5305. return;
  5306. }
  5307. var content = dataTransfer.getData(type);
  5308. if (type.toLowerCase().indexOf('text') > -1) {
  5309. _this.context.invoke('editor.pasteHTML', content);
  5310. } else {
  5311. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(content).each(function (idx, item) {
  5312. _this.context.invoke('editor.insertNode', item);
  5313. });
  5314. }
  5315. });
  5316. }
  5317. }).on('dragover', false); // prevent default dragover event
  5318. }
  5319. }, {
  5320. key: "destroy",
  5321. value: function destroy() {
  5322. var _this2 = this;
  5323. Object.keys(this.documentEventHandlers).forEach(function (key) {
  5324. _this2.$eventListener.off(key.substr(2).toLowerCase(), _this2.documentEventHandlers[key]);
  5325. });
  5326. this.documentEventHandlers = {};
  5327. }
  5328. }]);
  5329. return Dropzone;
  5330. }();
  5331. // CONCATENATED MODULE: ./src/js/base/module/Codeview.js
  5332. function Codeview_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5333. function Codeview_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); } }
  5334. function Codeview_createClass(Constructor, protoProps, staticProps) { if (protoProps) Codeview_defineProperties(Constructor.prototype, protoProps); if (staticProps) Codeview_defineProperties(Constructor, staticProps); return Constructor; }
  5335. var CodeMirror;
  5336. if (env.hasCodeMirror) {
  5337. CodeMirror = window.CodeMirror;
  5338. }
  5339. /**
  5340. * @class Codeview
  5341. */
  5342. var Codeview_CodeView =
  5343. /*#__PURE__*/
  5344. function () {
  5345. function CodeView(context) {
  5346. Codeview_classCallCheck(this, CodeView);
  5347. this.context = context;
  5348. this.$editor = context.layoutInfo.editor;
  5349. this.$editable = context.layoutInfo.editable;
  5350. this.$codable = context.layoutInfo.codable;
  5351. this.options = context.options;
  5352. }
  5353. Codeview_createClass(CodeView, [{
  5354. key: "sync",
  5355. value: function sync() {
  5356. var isCodeview = this.isActivated();
  5357. if (isCodeview && env.hasCodeMirror) {
  5358. this.$codable.data('cmEditor').save();
  5359. }
  5360. }
  5361. /**
  5362. * @return {Boolean}
  5363. */
  5364. }, {
  5365. key: "isActivated",
  5366. value: function isActivated() {
  5367. return this.$editor.hasClass('codeview');
  5368. }
  5369. /**
  5370. * toggle codeview
  5371. */
  5372. }, {
  5373. key: "toggle",
  5374. value: function toggle() {
  5375. if (this.isActivated()) {
  5376. this.deactivate();
  5377. } else {
  5378. this.activate();
  5379. }
  5380. this.context.triggerEvent('codeview.toggled');
  5381. }
  5382. /**
  5383. * purify input value
  5384. * @param value
  5385. * @returns {*}
  5386. */
  5387. }, {
  5388. key: "purify",
  5389. value: function purify(value) {
  5390. if (this.options.codeviewFilter) {
  5391. // filter code view regex
  5392. value = value.replace(this.options.codeviewFilterRegex, ''); // allow specific iframe tag
  5393. if (this.options.codeviewIframeFilter) {
  5394. var whitelist = this.options.codeviewIframeWhitelistSrc.concat(this.options.codeviewIframeWhitelistSrcBase);
  5395. value = value.replace(/(<iframe.*?>.*?(?:<\/iframe>)?)/gi, function (tag) {
  5396. // remove if src attribute is duplicated
  5397. if (/<.+src(?==?('|"|\s)?)[\s\S]+src(?=('|"|\s)?)[^>]*?>/i.test(tag)) {
  5398. return '';
  5399. }
  5400. var _iteratorNormalCompletion = true;
  5401. var _didIteratorError = false;
  5402. var _iteratorError = undefined;
  5403. try {
  5404. for (var _iterator = whitelist[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  5405. var src = _step.value;
  5406. // pass if src is trusted
  5407. if (new RegExp('src="(https?:)?\/\/' + src.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + '\/(.+)"').test(tag)) {
  5408. return tag;
  5409. }
  5410. }
  5411. } catch (err) {
  5412. _didIteratorError = true;
  5413. _iteratorError = err;
  5414. } finally {
  5415. try {
  5416. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  5417. _iterator["return"]();
  5418. }
  5419. } finally {
  5420. if (_didIteratorError) {
  5421. throw _iteratorError;
  5422. }
  5423. }
  5424. }
  5425. return '';
  5426. });
  5427. }
  5428. }
  5429. return value;
  5430. }
  5431. /**
  5432. * activate code view
  5433. */
  5434. }, {
  5435. key: "activate",
  5436. value: function activate() {
  5437. var _this = this;
  5438. this.$codable.val(dom.html(this.$editable, this.options.prettifyHtml));
  5439. this.$codable.height(this.$editable.height());
  5440. this.context.invoke('toolbar.updateCodeview', true);
  5441. this.$editor.addClass('codeview');
  5442. this.$codable.focus(); // activate CodeMirror as codable
  5443. if (env.hasCodeMirror) {
  5444. var cmEditor = CodeMirror.fromTextArea(this.$codable[0], this.options.codemirror); // CodeMirror TernServer
  5445. if (this.options.codemirror.tern) {
  5446. var server = new CodeMirror.TernServer(this.options.codemirror.tern);
  5447. cmEditor.ternServer = server;
  5448. cmEditor.on('cursorActivity', function (cm) {
  5449. server.updateArgHints(cm);
  5450. });
  5451. }
  5452. cmEditor.on('blur', function (event) {
  5453. _this.context.triggerEvent('blur.codeview', cmEditor.getValue(), event);
  5454. });
  5455. cmEditor.on('change', function () {
  5456. _this.context.triggerEvent('change.codeview', cmEditor.getValue(), cmEditor);
  5457. }); // CodeMirror hasn't Padding.
  5458. cmEditor.setSize(null, this.$editable.outerHeight());
  5459. this.$codable.data('cmEditor', cmEditor);
  5460. } else {
  5461. this.$codable.on('blur', function (event) {
  5462. _this.context.triggerEvent('blur.codeview', _this.$codable.val(), event);
  5463. });
  5464. this.$codable.on('input', function () {
  5465. _this.context.triggerEvent('change.codeview', _this.$codable.val(), _this.$codable);
  5466. });
  5467. }
  5468. }
  5469. /**
  5470. * deactivate code view
  5471. */
  5472. }, {
  5473. key: "deactivate",
  5474. value: function deactivate() {
  5475. // deactivate CodeMirror as codable
  5476. if (env.hasCodeMirror) {
  5477. var cmEditor = this.$codable.data('cmEditor');
  5478. this.$codable.val(cmEditor.getValue());
  5479. cmEditor.toTextArea();
  5480. }
  5481. var value = this.purify(dom.value(this.$codable, this.options.prettifyHtml) || dom.emptyPara);
  5482. var isChange = this.$editable.html() !== value;
  5483. this.$editable.html(value);
  5484. this.$editable.height(this.options.height ? this.$codable.height() : 'auto');
  5485. this.$editor.removeClass('codeview');
  5486. if (isChange) {
  5487. this.context.triggerEvent('change', this.$editable.html(), this.$editable);
  5488. }
  5489. this.$editable.focus();
  5490. this.context.invoke('toolbar.updateCodeview', false);
  5491. }
  5492. }, {
  5493. key: "destroy",
  5494. value: function destroy() {
  5495. if (this.isActivated()) {
  5496. this.deactivate();
  5497. }
  5498. }
  5499. }]);
  5500. return CodeView;
  5501. }();
  5502. // CONCATENATED MODULE: ./src/js/base/module/Statusbar.js
  5503. function Statusbar_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5504. function Statusbar_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); } }
  5505. function Statusbar_createClass(Constructor, protoProps, staticProps) { if (protoProps) Statusbar_defineProperties(Constructor.prototype, protoProps); if (staticProps) Statusbar_defineProperties(Constructor, staticProps); return Constructor; }
  5506. var EDITABLE_PADDING = 24;
  5507. var Statusbar_Statusbar =
  5508. /*#__PURE__*/
  5509. function () {
  5510. function Statusbar(context) {
  5511. Statusbar_classCallCheck(this, Statusbar);
  5512. this.$document = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document);
  5513. this.$statusbar = context.layoutInfo.statusbar;
  5514. this.$editable = context.layoutInfo.editable;
  5515. this.options = context.options;
  5516. }
  5517. Statusbar_createClass(Statusbar, [{
  5518. key: "initialize",
  5519. value: function initialize() {
  5520. var _this = this;
  5521. if (this.options.airMode || this.options.disableResizeEditor) {
  5522. this.destroy();
  5523. return;
  5524. }
  5525. this.$statusbar.on('mousedown', function (event) {
  5526. event.preventDefault();
  5527. event.stopPropagation();
  5528. var editableTop = _this.$editable.offset().top - _this.$document.scrollTop();
  5529. var onMouseMove = function onMouseMove(event) {
  5530. var height = event.clientY - (editableTop + EDITABLE_PADDING);
  5531. height = _this.options.minheight > 0 ? Math.max(height, _this.options.minheight) : height;
  5532. height = _this.options.maxHeight > 0 ? Math.min(height, _this.options.maxHeight) : height;
  5533. _this.$editable.height(height);
  5534. };
  5535. _this.$document.on('mousemove', onMouseMove).one('mouseup', function () {
  5536. _this.$document.off('mousemove', onMouseMove);
  5537. });
  5538. });
  5539. }
  5540. }, {
  5541. key: "destroy",
  5542. value: function destroy() {
  5543. this.$statusbar.off();
  5544. this.$statusbar.addClass('locked');
  5545. }
  5546. }]);
  5547. return Statusbar;
  5548. }();
  5549. // CONCATENATED MODULE: ./src/js/base/module/Fullscreen.js
  5550. function Fullscreen_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5551. function Fullscreen_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); } }
  5552. function Fullscreen_createClass(Constructor, protoProps, staticProps) { if (protoProps) Fullscreen_defineProperties(Constructor.prototype, protoProps); if (staticProps) Fullscreen_defineProperties(Constructor, staticProps); return Constructor; }
  5553. var Fullscreen_Fullscreen =
  5554. /*#__PURE__*/
  5555. function () {
  5556. function Fullscreen(context) {
  5557. var _this = this;
  5558. Fullscreen_classCallCheck(this, Fullscreen);
  5559. this.context = context;
  5560. this.$editor = context.layoutInfo.editor;
  5561. this.$toolbar = context.layoutInfo.toolbar;
  5562. this.$editable = context.layoutInfo.editable;
  5563. this.$codable = context.layoutInfo.codable;
  5564. this.$window = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(window);
  5565. this.$scrollbar = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('html, body');
  5566. this.onResize = function () {
  5567. _this.resizeTo({
  5568. h: _this.$window.height() - _this.$toolbar.outerHeight()
  5569. });
  5570. };
  5571. }
  5572. Fullscreen_createClass(Fullscreen, [{
  5573. key: "resizeTo",
  5574. value: function resizeTo(size) {
  5575. this.$editable.css('height', size.h);
  5576. this.$codable.css('height', size.h);
  5577. if (this.$codable.data('cmeditor')) {
  5578. this.$codable.data('cmeditor').setsize(null, size.h);
  5579. }
  5580. }
  5581. /**
  5582. * toggle fullscreen
  5583. */
  5584. }, {
  5585. key: "toggle",
  5586. value: function toggle() {
  5587. this.$editor.toggleClass('fullscreen');
  5588. if (this.isFullscreen()) {
  5589. this.$editable.data('orgHeight', this.$editable.css('height'));
  5590. this.$editable.data('orgMaxHeight', this.$editable.css('maxHeight'));
  5591. this.$editable.css('maxHeight', '');
  5592. this.$window.on('resize', this.onResize).trigger('resize');
  5593. this.$scrollbar.css('overflow', 'hidden');
  5594. } else {
  5595. this.$window.off('resize', this.onResize);
  5596. this.resizeTo({
  5597. h: this.$editable.data('orgHeight')
  5598. });
  5599. this.$editable.css('maxHeight', this.$editable.css('orgMaxHeight'));
  5600. this.$scrollbar.css('overflow', 'visible');
  5601. }
  5602. this.context.invoke('toolbar.updateFullscreen', this.isFullscreen());
  5603. }
  5604. }, {
  5605. key: "isFullscreen",
  5606. value: function isFullscreen() {
  5607. return this.$editor.hasClass('fullscreen');
  5608. }
  5609. }]);
  5610. return Fullscreen;
  5611. }();
  5612. // CONCATENATED MODULE: ./src/js/base/module/Handle.js
  5613. function Handle_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5614. function Handle_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); } }
  5615. function Handle_createClass(Constructor, protoProps, staticProps) { if (protoProps) Handle_defineProperties(Constructor.prototype, protoProps); if (staticProps) Handle_defineProperties(Constructor, staticProps); return Constructor; }
  5616. var Handle_Handle =
  5617. /*#__PURE__*/
  5618. function () {
  5619. function Handle(context) {
  5620. var _this = this;
  5621. Handle_classCallCheck(this, Handle);
  5622. this.context = context;
  5623. this.$document = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document);
  5624. this.$editingArea = context.layoutInfo.editingArea;
  5625. this.options = context.options;
  5626. this.lang = this.options.langInfo;
  5627. this.events = {
  5628. 'summernote.mousedown': function summernoteMousedown(we, e) {
  5629. if (_this.update(e.target, e)) {
  5630. e.preventDefault();
  5631. }
  5632. },
  5633. 'summernote.keyup summernote.scroll summernote.change summernote.dialog.shown': function summernoteKeyupSummernoteScrollSummernoteChangeSummernoteDialogShown() {
  5634. _this.update();
  5635. },
  5636. 'summernote.disable summernote.blur': function summernoteDisableSummernoteBlur() {
  5637. _this.hide();
  5638. },
  5639. 'summernote.codeview.toggled': function summernoteCodeviewToggled() {
  5640. _this.update();
  5641. }
  5642. };
  5643. }
  5644. Handle_createClass(Handle, [{
  5645. key: "initialize",
  5646. value: function initialize() {
  5647. var _this2 = this;
  5648. this.$handle = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(['<div class="note-handle">', '<div class="note-control-selection">', '<div class="note-control-selection-bg"></div>', '<div class="note-control-holder note-control-nw"></div>', '<div class="note-control-holder note-control-ne"></div>', '<div class="note-control-holder note-control-sw"></div>', '<div class="', this.options.disableResizeImage ? 'note-control-holder' : 'note-control-sizing', ' note-control-se"></div>', this.options.disableResizeImage ? '' : '<div class="note-control-selection-info"></div>', '</div>', '</div>'].join('')).prependTo(this.$editingArea);
  5649. this.$handle.on('mousedown', function (event) {
  5650. if (dom.isControlSizing(event.target)) {
  5651. event.preventDefault();
  5652. event.stopPropagation();
  5653. var $target = _this2.$handle.find('.note-control-selection').data('target');
  5654. var posStart = $target.offset();
  5655. var scrollTop = _this2.$document.scrollTop();
  5656. var onMouseMove = function onMouseMove(event) {
  5657. _this2.context.invoke('editor.resizeTo', {
  5658. x: event.clientX - posStart.left,
  5659. y: event.clientY - (posStart.top - scrollTop)
  5660. }, $target, !event.shiftKey);
  5661. _this2.update($target[0], event);
  5662. };
  5663. _this2.$document.on('mousemove', onMouseMove).one('mouseup', function (e) {
  5664. e.preventDefault();
  5665. _this2.$document.off('mousemove', onMouseMove);
  5666. _this2.context.invoke('editor.afterCommand');
  5667. });
  5668. if (!$target.data('ratio')) {
  5669. // original ratio.
  5670. $target.data('ratio', $target.height() / $target.width());
  5671. }
  5672. }
  5673. }); // Listen for scrolling on the handle overlay.
  5674. this.$handle.on('wheel', function (e) {
  5675. e.preventDefault();
  5676. _this2.update();
  5677. });
  5678. }
  5679. }, {
  5680. key: "destroy",
  5681. value: function destroy() {
  5682. this.$handle.remove();
  5683. }
  5684. }, {
  5685. key: "update",
  5686. value: function update(target, event) {
  5687. if (this.context.isDisabled()) {
  5688. return false;
  5689. }
  5690. var isImage = dom.isImg(target);
  5691. var $selection = this.$handle.find('.note-control-selection');
  5692. this.context.invoke('imagePopover.update', target, event);
  5693. if (isImage) {
  5694. var $image = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(target);
  5695. var position = $image.position();
  5696. var pos = {
  5697. left: position.left + parseInt($image.css('marginLeft'), 10),
  5698. top: position.top + parseInt($image.css('marginTop'), 10)
  5699. }; // exclude margin
  5700. var imageSize = {
  5701. w: $image.outerWidth(false),
  5702. h: $image.outerHeight(false)
  5703. };
  5704. $selection.css({
  5705. display: 'block',
  5706. left: pos.left,
  5707. top: pos.top,
  5708. width: imageSize.w,
  5709. height: imageSize.h
  5710. }).data('target', $image); // save current image element.
  5711. var origImageObj = new Image();
  5712. origImageObj.src = $image.attr('src');
  5713. var sizingText = imageSize.w + 'x' + imageSize.h + ' (' + this.lang.image.original + ': ' + origImageObj.width + 'x' + origImageObj.height + ')';
  5714. $selection.find('.note-control-selection-info').text(sizingText);
  5715. this.context.invoke('editor.saveTarget', target);
  5716. } else {
  5717. this.hide();
  5718. }
  5719. return isImage;
  5720. }
  5721. /**
  5722. * hide
  5723. *
  5724. * @param {jQuery} $handle
  5725. */
  5726. }, {
  5727. key: "hide",
  5728. value: function hide() {
  5729. this.context.invoke('editor.clearTarget');
  5730. this.$handle.children().hide();
  5731. }
  5732. }]);
  5733. return Handle;
  5734. }();
  5735. // CONCATENATED MODULE: ./src/js/base/module/AutoLink.js
  5736. function AutoLink_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5737. function AutoLink_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); } }
  5738. function AutoLink_createClass(Constructor, protoProps, staticProps) { if (protoProps) AutoLink_defineProperties(Constructor.prototype, protoProps); if (staticProps) AutoLink_defineProperties(Constructor, staticProps); return Constructor; }
  5739. var defaultScheme = 'http://';
  5740. var linkPattern = /^([A-Za-z][A-Za-z0-9+-.]*\:[\/]{2}|tel:|mailto:[A-Z0-9._%+-]+@)?(www\.)?(.+)$/i;
  5741. var AutoLink_AutoLink =
  5742. /*#__PURE__*/
  5743. function () {
  5744. function AutoLink(context) {
  5745. var _this = this;
  5746. AutoLink_classCallCheck(this, AutoLink);
  5747. this.context = context;
  5748. this.events = {
  5749. 'summernote.keyup': function summernoteKeyup(we, e) {
  5750. if (!e.isDefaultPrevented()) {
  5751. _this.handleKeyup(e);
  5752. }
  5753. },
  5754. 'summernote.keydown': function summernoteKeydown(we, e) {
  5755. _this.handleKeydown(e);
  5756. }
  5757. };
  5758. }
  5759. AutoLink_createClass(AutoLink, [{
  5760. key: "initialize",
  5761. value: function initialize() {
  5762. this.lastWordRange = null;
  5763. }
  5764. }, {
  5765. key: "destroy",
  5766. value: function destroy() {
  5767. this.lastWordRange = null;
  5768. }
  5769. }, {
  5770. key: "replace",
  5771. value: function replace() {
  5772. if (!this.lastWordRange) {
  5773. return;
  5774. }
  5775. var keyword = this.lastWordRange.toString();
  5776. var match = keyword.match(linkPattern);
  5777. if (match && (match[1] || match[2])) {
  5778. var link = match[1] ? keyword : defaultScheme + keyword;
  5779. var urlText = keyword.replace(/^(?:https?:\/\/)?(?:tel?:?)?(?:mailto?:?)?(?:www\.)?/i, '').split('/')[0];
  5780. var node = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<a />').html(urlText).attr('href', link)[0];
  5781. if (this.context.options.linkTargetBlank) {
  5782. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(node).attr('target', '_blank');
  5783. }
  5784. this.lastWordRange.insertNode(node);
  5785. this.lastWordRange = null;
  5786. this.context.invoke('editor.focus');
  5787. }
  5788. }
  5789. }, {
  5790. key: "handleKeydown",
  5791. value: function handleKeydown(e) {
  5792. if (lists.contains([core_key.code.ENTER, core_key.code.SPACE], e.keyCode)) {
  5793. var wordRange = this.context.invoke('editor.createRange').getWordRange();
  5794. this.lastWordRange = wordRange;
  5795. }
  5796. }
  5797. }, {
  5798. key: "handleKeyup",
  5799. value: function handleKeyup(e) {
  5800. if (lists.contains([core_key.code.ENTER, core_key.code.SPACE], e.keyCode)) {
  5801. this.replace();
  5802. }
  5803. }
  5804. }]);
  5805. return AutoLink;
  5806. }();
  5807. // CONCATENATED MODULE: ./src/js/base/module/AutoSync.js
  5808. function AutoSync_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5809. function AutoSync_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); } }
  5810. function AutoSync_createClass(Constructor, protoProps, staticProps) { if (protoProps) AutoSync_defineProperties(Constructor.prototype, protoProps); if (staticProps) AutoSync_defineProperties(Constructor, staticProps); return Constructor; }
  5811. /**
  5812. * textarea auto sync.
  5813. */
  5814. var AutoSync_AutoSync =
  5815. /*#__PURE__*/
  5816. function () {
  5817. function AutoSync(context) {
  5818. var _this = this;
  5819. AutoSync_classCallCheck(this, AutoSync);
  5820. this.$note = context.layoutInfo.note;
  5821. this.events = {
  5822. 'summernote.change': function summernoteChange() {
  5823. _this.$note.val(context.invoke('code'));
  5824. }
  5825. };
  5826. }
  5827. AutoSync_createClass(AutoSync, [{
  5828. key: "shouldInitialize",
  5829. value: function shouldInitialize() {
  5830. return dom.isTextarea(this.$note[0]);
  5831. }
  5832. }]);
  5833. return AutoSync;
  5834. }();
  5835. // CONCATENATED MODULE: ./src/js/base/module/AutoReplace.js
  5836. function AutoReplace_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5837. function AutoReplace_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); } }
  5838. function AutoReplace_createClass(Constructor, protoProps, staticProps) { if (protoProps) AutoReplace_defineProperties(Constructor.prototype, protoProps); if (staticProps) AutoReplace_defineProperties(Constructor, staticProps); return Constructor; }
  5839. var AutoReplace_AutoReplace =
  5840. /*#__PURE__*/
  5841. function () {
  5842. function AutoReplace(context) {
  5843. var _this = this;
  5844. AutoReplace_classCallCheck(this, AutoReplace);
  5845. this.context = context;
  5846. this.options = context.options.replace || {};
  5847. this.keys = [core_key.code.ENTER, core_key.code.SPACE, core_key.code.PERIOD, core_key.code.COMMA, core_key.code.SEMICOLON, core_key.code.SLASH];
  5848. this.previousKeydownCode = null;
  5849. this.events = {
  5850. 'summernote.keyup': function summernoteKeyup(we, e) {
  5851. if (!e.isDefaultPrevented()) {
  5852. _this.handleKeyup(e);
  5853. }
  5854. },
  5855. 'summernote.keydown': function summernoteKeydown(we, e) {
  5856. _this.handleKeydown(e);
  5857. }
  5858. };
  5859. }
  5860. AutoReplace_createClass(AutoReplace, [{
  5861. key: "shouldInitialize",
  5862. value: function shouldInitialize() {
  5863. return !!this.options.match;
  5864. }
  5865. }, {
  5866. key: "initialize",
  5867. value: function initialize() {
  5868. this.lastWord = null;
  5869. }
  5870. }, {
  5871. key: "destroy",
  5872. value: function destroy() {
  5873. this.lastWord = null;
  5874. }
  5875. }, {
  5876. key: "replace",
  5877. value: function replace() {
  5878. if (!this.lastWord) {
  5879. return;
  5880. }
  5881. var self = this;
  5882. var keyword = this.lastWord.toString();
  5883. this.options.match(keyword, function (match) {
  5884. if (match) {
  5885. var node = '';
  5886. if (typeof match === 'string') {
  5887. node = dom.createText(match);
  5888. } else if (match instanceof jQuery) {
  5889. node = match[0];
  5890. } else if (match instanceof Node) {
  5891. node = match;
  5892. }
  5893. if (!node) return;
  5894. self.lastWord.insertNode(node);
  5895. self.lastWord = null;
  5896. self.context.invoke('editor.focus');
  5897. }
  5898. });
  5899. }
  5900. }, {
  5901. key: "handleKeydown",
  5902. value: function handleKeydown(e) {
  5903. // this forces it to remember the last whole word, even if multiple termination keys are pressed
  5904. // before the previous key is let go.
  5905. if (this.previousKeydownCode && lists.contains(this.keys, this.previousKeydownCode)) {
  5906. this.previousKeydownCode = e.keyCode;
  5907. return;
  5908. }
  5909. if (lists.contains(this.keys, e.keyCode)) {
  5910. var wordRange = this.context.invoke('editor.createRange').getWordRange();
  5911. this.lastWord = wordRange;
  5912. }
  5913. this.previousKeydownCode = e.keyCode;
  5914. }
  5915. }, {
  5916. key: "handleKeyup",
  5917. value: function handleKeyup(e) {
  5918. if (lists.contains(this.keys, e.keyCode)) {
  5919. this.replace();
  5920. }
  5921. }
  5922. }]);
  5923. return AutoReplace;
  5924. }();
  5925. // CONCATENATED MODULE: ./src/js/base/module/Placeholder.js
  5926. function Placeholder_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5927. function Placeholder_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); } }
  5928. function Placeholder_createClass(Constructor, protoProps, staticProps) { if (protoProps) Placeholder_defineProperties(Constructor.prototype, protoProps); if (staticProps) Placeholder_defineProperties(Constructor, staticProps); return Constructor; }
  5929. var Placeholder_Placeholder =
  5930. /*#__PURE__*/
  5931. function () {
  5932. function Placeholder(context) {
  5933. var _this = this;
  5934. Placeholder_classCallCheck(this, Placeholder);
  5935. this.context = context;
  5936. this.$editingArea = context.layoutInfo.editingArea;
  5937. this.options = context.options;
  5938. if (this.options.inheritPlaceholder === true) {
  5939. // get placeholder value from the original element
  5940. this.options.placeholder = this.context.$note.attr('placeholder') || this.options.placeholder;
  5941. }
  5942. this.events = {
  5943. 'summernote.init summernote.change': function summernoteInitSummernoteChange() {
  5944. _this.update();
  5945. },
  5946. 'summernote.codeview.toggled': function summernoteCodeviewToggled() {
  5947. _this.update();
  5948. }
  5949. };
  5950. }
  5951. Placeholder_createClass(Placeholder, [{
  5952. key: "shouldInitialize",
  5953. value: function shouldInitialize() {
  5954. return !!this.options.placeholder;
  5955. }
  5956. }, {
  5957. key: "initialize",
  5958. value: function initialize() {
  5959. var _this2 = this;
  5960. this.$placeholder = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div class="note-placeholder">');
  5961. this.$placeholder.on('click', function () {
  5962. _this2.context.invoke('focus');
  5963. }).html(this.options.placeholder).prependTo(this.$editingArea);
  5964. this.update();
  5965. }
  5966. }, {
  5967. key: "destroy",
  5968. value: function destroy() {
  5969. this.$placeholder.remove();
  5970. }
  5971. }, {
  5972. key: "update",
  5973. value: function update() {
  5974. var isShow = !this.context.invoke('codeview.isActivated') && this.context.invoke('editor.isEmpty');
  5975. this.$placeholder.toggle(isShow);
  5976. }
  5977. }]);
  5978. return Placeholder;
  5979. }();
  5980. // CONCATENATED MODULE: ./src/js/base/module/Buttons.js
  5981. function Buttons_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5982. function Buttons_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); } }
  5983. function Buttons_createClass(Constructor, protoProps, staticProps) { if (protoProps) Buttons_defineProperties(Constructor.prototype, protoProps); if (staticProps) Buttons_defineProperties(Constructor, staticProps); return Constructor; }
  5984. var Buttons_Buttons =
  5985. /*#__PURE__*/
  5986. function () {
  5987. function Buttons(context) {
  5988. Buttons_classCallCheck(this, Buttons);
  5989. this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
  5990. this.context = context;
  5991. this.$toolbar = context.layoutInfo.toolbar;
  5992. this.options = context.options;
  5993. this.lang = this.options.langInfo;
  5994. this.invertedKeyMap = func.invertObject(this.options.keyMap[env.isMac ? 'mac' : 'pc']);
  5995. }
  5996. Buttons_createClass(Buttons, [{
  5997. key: "representShortcut",
  5998. value: function representShortcut(editorMethod) {
  5999. var shortcut = this.invertedKeyMap[editorMethod];
  6000. if (!this.options.shortcuts || !shortcut) {
  6001. return '';
  6002. }
  6003. if (env.isMac) {
  6004. shortcut = shortcut.replace('CMD', '⌘').replace('SHIFT', '⇧');
  6005. }
  6006. shortcut = shortcut.replace('BACKSLASH', '\\').replace('SLASH', '/').replace('LEFTBRACKET', '[').replace('RIGHTBRACKET', ']');
  6007. return ' (' + shortcut + ')';
  6008. }
  6009. }, {
  6010. key: "button",
  6011. value: function button(o) {
  6012. if (!this.options.tooltip && o.tooltip) {
  6013. delete o.tooltip;
  6014. }
  6015. o.container = this.options.container;
  6016. return this.ui.button(o);
  6017. }
  6018. }, {
  6019. key: "initialize",
  6020. value: function initialize() {
  6021. this.addToolbarButtons();
  6022. this.addImagePopoverButtons();
  6023. this.addLinkPopoverButtons();
  6024. this.addTablePopoverButtons();
  6025. this.fontInstalledMap = {};
  6026. }
  6027. }, {
  6028. key: "destroy",
  6029. value: function destroy() {
  6030. delete this.fontInstalledMap;
  6031. }
  6032. }, {
  6033. key: "isFontInstalled",
  6034. value: function isFontInstalled(name) {
  6035. if (!Object.prototype.hasOwnProperty.call(this.fontInstalledMap, name)) {
  6036. this.fontInstalledMap[name] = env.isFontInstalled(name) || lists.contains(this.options.fontNamesIgnoreCheck, name);
  6037. }
  6038. return this.fontInstalledMap[name];
  6039. }
  6040. }, {
  6041. key: "isFontDeservedToAdd",
  6042. value: function isFontDeservedToAdd(name) {
  6043. name = name.toLowerCase();
  6044. return name !== '' && this.isFontInstalled(name) && env.genericFontFamilies.indexOf(name) === -1;
  6045. }
  6046. }, {
  6047. key: "colorPalette",
  6048. value: function colorPalette(className, tooltip, backColor, foreColor) {
  6049. var _this = this;
  6050. return this.ui.buttonGroup({
  6051. className: 'note-color ' + className,
  6052. children: [this.button({
  6053. className: 'note-current-color-button',
  6054. contents: this.ui.icon(this.options.icons.font + ' note-recent-color'),
  6055. tooltip: tooltip,
  6056. click: function click(e) {
  6057. var $button = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(e.currentTarget);
  6058. if (backColor && foreColor) {
  6059. _this.context.invoke('editor.color', {
  6060. backColor: $button.attr('data-backColor'),
  6061. foreColor: $button.attr('data-foreColor')
  6062. });
  6063. } else if (backColor) {
  6064. _this.context.invoke('editor.color', {
  6065. backColor: $button.attr('data-backColor')
  6066. });
  6067. } else if (foreColor) {
  6068. _this.context.invoke('editor.color', {
  6069. foreColor: $button.attr('data-foreColor')
  6070. });
  6071. }
  6072. },
  6073. callback: function callback($button) {
  6074. var $recentColor = $button.find('.note-recent-color');
  6075. if (backColor) {
  6076. $recentColor.css('background-color', _this.options.colorButton.backColor);
  6077. $button.attr('data-backColor', _this.options.colorButton.backColor);
  6078. }
  6079. if (foreColor) {
  6080. $recentColor.css('color', _this.options.colorButton.foreColor);
  6081. $button.attr('data-foreColor', _this.options.colorButton.foreColor);
  6082. } else {
  6083. $recentColor.css('color', 'transparent');
  6084. }
  6085. }
  6086. }), this.button({
  6087. className: 'dropdown-toggle',
  6088. contents: this.ui.dropdownButtonContents('', this.options),
  6089. tooltip: this.lang.color.more,
  6090. data: {
  6091. toggle: 'dropdown'
  6092. }
  6093. }), this.ui.dropdown({
  6094. items: (backColor ? ['<div class="note-palette">', '<div class="note-palette-title">' + this.lang.color.background + '</div>', '<div>', '<button type="button" class="note-color-reset btn btn-light" data-event="backColor" data-value="inherit">', this.lang.color.transparent, '</button>', '</div>', '<div class="note-holder" data-event="backColor"/>', '<div>', '<button type="button" class="note-color-select btn btn-light" data-event="openPalette" data-value="backColorPicker">', this.lang.color.cpSelect, '</button>', '<input type="color" id="backColorPicker" class="note-btn note-color-select-btn" value="' + this.options.colorButton.backColor + '" data-event="backColorPalette">', '</div>', '<div class="note-holder-custom" id="backColorPalette" data-event="backColor"/>', '</div>'].join('') : '') + (foreColor ? ['<div class="note-palette">', '<div class="note-palette-title">' + this.lang.color.foreground + '</div>', '<div>', '<button type="button" class="note-color-reset btn btn-light" data-event="removeFormat" data-value="foreColor">', this.lang.color.resetToDefault, '</button>', '</div>', '<div class="note-holder" data-event="foreColor"/>', '<div>', '<button type="button" class="note-color-select btn btn-light" data-event="openPalette" data-value="foreColorPicker">', this.lang.color.cpSelect, '</button>', '<input type="color" id="foreColorPicker" class="note-btn note-color-select-btn" value="' + this.options.colorButton.foreColor + '" data-event="foreColorPalette">', '</div>', // Fix missing Div, Commented to find easily if it's wrong
  6095. '<div class="note-holder-custom" id="foreColorPalette" data-event="foreColor"/>', '</div>'].join('') : ''),
  6096. callback: function callback($dropdown) {
  6097. $dropdown.find('.note-holder').each(function (idx, item) {
  6098. var $holder = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item);
  6099. $holder.append(_this.ui.palette({
  6100. colors: _this.options.colors,
  6101. colorsName: _this.options.colorsName,
  6102. eventName: $holder.data('event'),
  6103. container: _this.options.container,
  6104. tooltip: _this.options.tooltip
  6105. }).render());
  6106. });
  6107. /* TODO: do we have to record recent custom colors within cookies? */
  6108. var customColors = [['#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF']];
  6109. $dropdown.find('.note-holder-custom').each(function (idx, item) {
  6110. var $holder = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item);
  6111. $holder.append(_this.ui.palette({
  6112. colors: customColors,
  6113. colorsName: customColors,
  6114. eventName: $holder.data('event'),
  6115. container: _this.options.container,
  6116. tooltip: _this.options.tooltip
  6117. }).render());
  6118. });
  6119. $dropdown.find('input[type=color]').each(function (idx, item) {
  6120. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item).change(function () {
  6121. var $chip = $dropdown.find('#' + external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this).data('event')).find('.note-color-btn').first();
  6122. var color = this.value.toUpperCase();
  6123. $chip.css('background-color', color).attr('aria-label', color).attr('data-value', color).attr('data-original-title', color);
  6124. $chip.click();
  6125. });
  6126. });
  6127. },
  6128. click: function click(event) {
  6129. event.stopPropagation();
  6130. var $parent = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('.' + className).find('.note-dropdown-menu');
  6131. var $button = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(event.target);
  6132. var eventName = $button.data('event');
  6133. var value = $button.attr('data-value');
  6134. if (eventName === 'openPalette') {
  6135. var $picker = $parent.find('#' + value);
  6136. var $palette = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()($parent.find('#' + $picker.data('event')).find('.note-color-row')[0]); // Shift palette chips
  6137. var $chip = $palette.find('.note-color-btn').last().detach(); // Set chip attributes
  6138. var color = $picker.val();
  6139. $chip.css('background-color', color).attr('aria-label', color).attr('data-value', color).attr('data-original-title', color);
  6140. $palette.prepend($chip);
  6141. $picker.click();
  6142. } else {
  6143. if (lists.contains(['backColor', 'foreColor'], eventName)) {
  6144. var key = eventName === 'backColor' ? 'background-color' : 'color';
  6145. var $color = $button.closest('.note-color').find('.note-recent-color');
  6146. var $currentButton = $button.closest('.note-color').find('.note-current-color-button');
  6147. $color.css(key, value);
  6148. $currentButton.attr('data-' + eventName, value);
  6149. }
  6150. _this.context.invoke('editor.' + eventName, value);
  6151. }
  6152. }
  6153. })]
  6154. }).render();
  6155. }
  6156. }, {
  6157. key: "addToolbarButtons",
  6158. value: function addToolbarButtons() {
  6159. var _this2 = this;
  6160. this.context.memo('button.style', function () {
  6161. return _this2.ui.buttonGroup([_this2.button({
  6162. className: 'dropdown-toggle',
  6163. contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.magic), _this2.options),
  6164. tooltip: _this2.lang.style.style,
  6165. data: {
  6166. toggle: 'dropdown'
  6167. }
  6168. }), _this2.ui.dropdown({
  6169. className: 'dropdown-style',
  6170. items: _this2.options.styleTags,
  6171. title: _this2.lang.style.style,
  6172. template: function template(item) {
  6173. // TBD: need to be simplified
  6174. if (typeof item === 'string') {
  6175. item = {
  6176. tag: item,
  6177. title: Object.prototype.hasOwnProperty.call(_this2.lang.style, item) ? _this2.lang.style[item] : item
  6178. };
  6179. }
  6180. var tag = item.tag;
  6181. var title = item.title;
  6182. var style = item.style ? ' style="' + item.style + '" ' : '';
  6183. var className = item.className ? ' class="' + item.className + '"' : '';
  6184. return '<' + tag + style + className + '>' + title + '</' + tag + '>';
  6185. },
  6186. click: _this2.context.createInvokeHandler('editor.formatBlock')
  6187. })]).render();
  6188. });
  6189. var _loop = function _loop(styleIdx, styleLen) {
  6190. var item = _this2.options.styleTags[styleIdx];
  6191. _this2.context.memo('button.style.' + item, function () {
  6192. return _this2.button({
  6193. className: 'note-btn-style-' + item,
  6194. contents: '<div data-value="' + item + '">' + item.toUpperCase() + '</div>',
  6195. tooltip: _this2.lang.style[item],
  6196. click: _this2.context.createInvokeHandler('editor.formatBlock')
  6197. }).render();
  6198. });
  6199. };
  6200. for (var styleIdx = 0, styleLen = this.options.styleTags.length; styleIdx < styleLen; styleIdx++) {
  6201. _loop(styleIdx, styleLen);
  6202. }
  6203. this.context.memo('button.bold', function () {
  6204. return _this2.button({
  6205. className: 'note-btn-bold',
  6206. contents: _this2.ui.icon(_this2.options.icons.bold),
  6207. tooltip: _this2.lang.font.bold + _this2.representShortcut('bold'),
  6208. click: _this2.context.createInvokeHandlerAndUpdateState('editor.bold')
  6209. }).render();
  6210. });
  6211. this.context.memo('button.italic', function () {
  6212. return _this2.button({
  6213. className: 'note-btn-italic',
  6214. contents: _this2.ui.icon(_this2.options.icons.italic),
  6215. tooltip: _this2.lang.font.italic + _this2.representShortcut('italic'),
  6216. click: _this2.context.createInvokeHandlerAndUpdateState('editor.italic')
  6217. }).render();
  6218. });
  6219. this.context.memo('button.underline', function () {
  6220. return _this2.button({
  6221. className: 'note-btn-underline',
  6222. contents: _this2.ui.icon(_this2.options.icons.underline),
  6223. tooltip: _this2.lang.font.underline + _this2.representShortcut('underline'),
  6224. click: _this2.context.createInvokeHandlerAndUpdateState('editor.underline')
  6225. }).render();
  6226. });
  6227. this.context.memo('button.clear', function () {
  6228. return _this2.button({
  6229. contents: _this2.ui.icon(_this2.options.icons.eraser),
  6230. tooltip: _this2.lang.font.clear + _this2.representShortcut('removeFormat'),
  6231. click: _this2.context.createInvokeHandler('editor.removeFormat')
  6232. }).render();
  6233. });
  6234. this.context.memo('button.strikethrough', function () {
  6235. return _this2.button({
  6236. className: 'note-btn-strikethrough',
  6237. contents: _this2.ui.icon(_this2.options.icons.strikethrough),
  6238. tooltip: _this2.lang.font.strikethrough + _this2.representShortcut('strikethrough'),
  6239. click: _this2.context.createInvokeHandlerAndUpdateState('editor.strikethrough')
  6240. }).render();
  6241. });
  6242. this.context.memo('button.superscript', function () {
  6243. return _this2.button({
  6244. className: 'note-btn-superscript',
  6245. contents: _this2.ui.icon(_this2.options.icons.superscript),
  6246. tooltip: _this2.lang.font.superscript,
  6247. click: _this2.context.createInvokeHandlerAndUpdateState('editor.superscript')
  6248. }).render();
  6249. });
  6250. this.context.memo('button.subscript', function () {
  6251. return _this2.button({
  6252. className: 'note-btn-subscript',
  6253. contents: _this2.ui.icon(_this2.options.icons.subscript),
  6254. tooltip: _this2.lang.font.subscript,
  6255. click: _this2.context.createInvokeHandlerAndUpdateState('editor.subscript')
  6256. }).render();
  6257. });
  6258. this.context.memo('button.fontname', function () {
  6259. var styleInfo = _this2.context.invoke('editor.currentStyle');
  6260. if (_this2.options.addDefaultFonts) {
  6261. // Add 'default' fonts into the fontnames array if not exist
  6262. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(styleInfo['font-family'].split(','), function (idx, fontname) {
  6263. fontname = fontname.trim().replace(/['"]+/g, '');
  6264. if (_this2.isFontDeservedToAdd(fontname)) {
  6265. if (_this2.options.fontNames.indexOf(fontname) === -1) {
  6266. _this2.options.fontNames.push(fontname);
  6267. }
  6268. }
  6269. });
  6270. }
  6271. return _this2.ui.buttonGroup([_this2.button({
  6272. className: 'dropdown-toggle',
  6273. contents: _this2.ui.dropdownButtonContents('<span class="note-current-fontname"/>', _this2.options),
  6274. tooltip: _this2.lang.font.name,
  6275. data: {
  6276. toggle: 'dropdown'
  6277. }
  6278. }), _this2.ui.dropdownCheck({
  6279. className: 'dropdown-fontname',
  6280. checkClassName: _this2.options.icons.menuCheck,
  6281. items: _this2.options.fontNames.filter(_this2.isFontInstalled.bind(_this2)),
  6282. title: _this2.lang.font.name,
  6283. template: function template(item) {
  6284. return '<span style="font-family: ' + env.validFontName(item) + '">' + item + '</span>';
  6285. },
  6286. click: _this2.context.createInvokeHandlerAndUpdateState('editor.fontName')
  6287. })]).render();
  6288. });
  6289. this.context.memo('button.fontsize', function () {
  6290. return _this2.ui.buttonGroup([_this2.button({
  6291. className: 'dropdown-toggle',
  6292. contents: _this2.ui.dropdownButtonContents('<span class="note-current-fontsize"/>', _this2.options),
  6293. tooltip: _this2.lang.font.size,
  6294. data: {
  6295. toggle: 'dropdown'
  6296. }
  6297. }), _this2.ui.dropdownCheck({
  6298. className: 'dropdown-fontsize',
  6299. checkClassName: _this2.options.icons.menuCheck,
  6300. items: _this2.options.fontSizes,
  6301. title: _this2.lang.font.size,
  6302. click: _this2.context.createInvokeHandlerAndUpdateState('editor.fontSize')
  6303. })]).render();
  6304. });
  6305. this.context.memo('button.fontsizeunit', function () {
  6306. return _this2.ui.buttonGroup([_this2.button({
  6307. className: 'dropdown-toggle',
  6308. contents: _this2.ui.dropdownButtonContents('<span class="note-current-fontsizeunit"/>', _this2.options),
  6309. tooltip: _this2.lang.font.sizeunit,
  6310. data: {
  6311. toggle: 'dropdown'
  6312. }
  6313. }), _this2.ui.dropdownCheck({
  6314. className: 'dropdown-fontsizeunit',
  6315. checkClassName: _this2.options.icons.menuCheck,
  6316. items: _this2.options.fontSizeUnits,
  6317. title: _this2.lang.font.sizeunit,
  6318. click: _this2.context.createInvokeHandlerAndUpdateState('editor.fontSizeUnit')
  6319. })]).render();
  6320. });
  6321. this.context.memo('button.color', function () {
  6322. return _this2.colorPalette('note-color-all', _this2.lang.color.recent, true, true);
  6323. });
  6324. this.context.memo('button.forecolor', function () {
  6325. return _this2.colorPalette('note-color-fore', _this2.lang.color.foreground, false, true);
  6326. });
  6327. this.context.memo('button.backcolor', function () {
  6328. return _this2.colorPalette('note-color-back', _this2.lang.color.background, true, false);
  6329. });
  6330. this.context.memo('button.ul', function () {
  6331. return _this2.button({
  6332. contents: _this2.ui.icon(_this2.options.icons.unorderedlist),
  6333. tooltip: _this2.lang.lists.unordered + _this2.representShortcut('insertUnorderedList'),
  6334. click: _this2.context.createInvokeHandler('editor.insertUnorderedList')
  6335. }).render();
  6336. });
  6337. this.context.memo('button.ol', function () {
  6338. return _this2.button({
  6339. contents: _this2.ui.icon(_this2.options.icons.orderedlist),
  6340. tooltip: _this2.lang.lists.ordered + _this2.representShortcut('insertOrderedList'),
  6341. click: _this2.context.createInvokeHandler('editor.insertOrderedList')
  6342. }).render();
  6343. });
  6344. var justifyLeft = this.button({
  6345. contents: this.ui.icon(this.options.icons.alignLeft),
  6346. tooltip: this.lang.paragraph.left + this.representShortcut('justifyLeft'),
  6347. click: this.context.createInvokeHandler('editor.justifyLeft')
  6348. });
  6349. var justifyCenter = this.button({
  6350. contents: this.ui.icon(this.options.icons.alignCenter),
  6351. tooltip: this.lang.paragraph.center + this.representShortcut('justifyCenter'),
  6352. click: this.context.createInvokeHandler('editor.justifyCenter')
  6353. });
  6354. var justifyRight = this.button({
  6355. contents: this.ui.icon(this.options.icons.alignRight),
  6356. tooltip: this.lang.paragraph.right + this.representShortcut('justifyRight'),
  6357. click: this.context.createInvokeHandler('editor.justifyRight')
  6358. });
  6359. var justifyFull = this.button({
  6360. contents: this.ui.icon(this.options.icons.alignJustify),
  6361. tooltip: this.lang.paragraph.justify + this.representShortcut('justifyFull'),
  6362. click: this.context.createInvokeHandler('editor.justifyFull')
  6363. });
  6364. var outdent = this.button({
  6365. contents: this.ui.icon(this.options.icons.outdent),
  6366. tooltip: this.lang.paragraph.outdent + this.representShortcut('outdent'),
  6367. click: this.context.createInvokeHandler('editor.outdent')
  6368. });
  6369. var indent = this.button({
  6370. contents: this.ui.icon(this.options.icons.indent),
  6371. tooltip: this.lang.paragraph.indent + this.representShortcut('indent'),
  6372. click: this.context.createInvokeHandler('editor.indent')
  6373. });
  6374. this.context.memo('button.justifyLeft', func.invoke(justifyLeft, 'render'));
  6375. this.context.memo('button.justifyCenter', func.invoke(justifyCenter, 'render'));
  6376. this.context.memo('button.justifyRight', func.invoke(justifyRight, 'render'));
  6377. this.context.memo('button.justifyFull', func.invoke(justifyFull, 'render'));
  6378. this.context.memo('button.outdent', func.invoke(outdent, 'render'));
  6379. this.context.memo('button.indent', func.invoke(indent, 'render'));
  6380. this.context.memo('button.paragraph', function () {
  6381. return _this2.ui.buttonGroup([_this2.button({
  6382. className: 'dropdown-toggle',
  6383. contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.alignLeft), _this2.options),
  6384. tooltip: _this2.lang.paragraph.paragraph,
  6385. data: {
  6386. toggle: 'dropdown'
  6387. }
  6388. }), _this2.ui.dropdown([_this2.ui.buttonGroup({
  6389. className: 'note-align',
  6390. children: [justifyLeft, justifyCenter, justifyRight, justifyFull]
  6391. }), _this2.ui.buttonGroup({
  6392. className: 'note-list',
  6393. children: [outdent, indent]
  6394. })])]).render();
  6395. });
  6396. this.context.memo('button.height', function () {
  6397. return _this2.ui.buttonGroup([_this2.button({
  6398. className: 'dropdown-toggle',
  6399. contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.textHeight), _this2.options),
  6400. tooltip: _this2.lang.font.height,
  6401. data: {
  6402. toggle: 'dropdown'
  6403. }
  6404. }), _this2.ui.dropdownCheck({
  6405. items: _this2.options.lineHeights,
  6406. checkClassName: _this2.options.icons.menuCheck,
  6407. className: 'dropdown-line-height',
  6408. title: _this2.lang.font.height,
  6409. click: _this2.context.createInvokeHandler('editor.lineHeight')
  6410. })]).render();
  6411. });
  6412. this.context.memo('button.table', function () {
  6413. return _this2.ui.buttonGroup([_this2.button({
  6414. className: 'dropdown-toggle',
  6415. contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.table), _this2.options),
  6416. tooltip: _this2.lang.table.table,
  6417. data: {
  6418. toggle: 'dropdown'
  6419. }
  6420. }), _this2.ui.dropdown({
  6421. title: _this2.lang.table.table,
  6422. className: 'note-table',
  6423. items: ['<div class="note-dimension-picker">', '<div class="note-dimension-picker-mousecatcher" data-event="insertTable" data-value="1x1"/>', '<div class="note-dimension-picker-highlighted"/>', '<div class="note-dimension-picker-unhighlighted"/>', '</div>', '<div class="note-dimension-display">1 x 1</div>'].join('')
  6424. })], {
  6425. callback: function callback($node) {
  6426. var $catcher = $node.find('.note-dimension-picker-mousecatcher');
  6427. $catcher.css({
  6428. width: _this2.options.insertTableMaxSize.col + 'em',
  6429. height: _this2.options.insertTableMaxSize.row + 'em'
  6430. }).mousedown(_this2.context.createInvokeHandler('editor.insertTable')).on('mousemove', _this2.tableMoveHandler.bind(_this2));
  6431. }
  6432. }).render();
  6433. });
  6434. this.context.memo('button.link', function () {
  6435. return _this2.button({
  6436. contents: _this2.ui.icon(_this2.options.icons.link),
  6437. tooltip: _this2.lang.link.link + _this2.representShortcut('linkDialog.show'),
  6438. click: _this2.context.createInvokeHandler('linkDialog.show')
  6439. }).render();
  6440. });
  6441. this.context.memo('button.picture', function () {
  6442. return _this2.button({
  6443. contents: _this2.ui.icon(_this2.options.icons.picture),
  6444. tooltip: _this2.lang.image.image,
  6445. click: _this2.context.createInvokeHandler('imageDialog.show')
  6446. }).render();
  6447. });
  6448. this.context.memo('button.video', function () {
  6449. return _this2.button({
  6450. contents: _this2.ui.icon(_this2.options.icons.video),
  6451. tooltip: _this2.lang.video.video,
  6452. click: _this2.context.createInvokeHandler('videoDialog.show')
  6453. }).render();
  6454. });
  6455. this.context.memo('button.hr', function () {
  6456. return _this2.button({
  6457. contents: _this2.ui.icon(_this2.options.icons.minus),
  6458. tooltip: _this2.lang.hr.insert + _this2.representShortcut('insertHorizontalRule'),
  6459. click: _this2.context.createInvokeHandler('editor.insertHorizontalRule')
  6460. }).render();
  6461. });
  6462. this.context.memo('button.fullscreen', function () {
  6463. return _this2.button({
  6464. className: 'btn-fullscreen',
  6465. contents: _this2.ui.icon(_this2.options.icons.arrowsAlt),
  6466. tooltip: _this2.lang.options.fullscreen,
  6467. click: _this2.context.createInvokeHandler('fullscreen.toggle')
  6468. }).render();
  6469. });
  6470. this.context.memo('button.codeview', function () {
  6471. return _this2.button({
  6472. className: 'btn-codeview',
  6473. contents: _this2.ui.icon(_this2.options.icons.code),
  6474. tooltip: _this2.lang.options.codeview,
  6475. click: _this2.context.createInvokeHandler('codeview.toggle')
  6476. }).render();
  6477. });
  6478. this.context.memo('button.redo', function () {
  6479. return _this2.button({
  6480. contents: _this2.ui.icon(_this2.options.icons.redo),
  6481. tooltip: _this2.lang.history.redo + _this2.representShortcut('redo'),
  6482. click: _this2.context.createInvokeHandler('editor.redo')
  6483. }).render();
  6484. });
  6485. this.context.memo('button.undo', function () {
  6486. return _this2.button({
  6487. contents: _this2.ui.icon(_this2.options.icons.undo),
  6488. tooltip: _this2.lang.history.undo + _this2.representShortcut('undo'),
  6489. click: _this2.context.createInvokeHandler('editor.undo')
  6490. }).render();
  6491. });
  6492. this.context.memo('button.help', function () {
  6493. return _this2.button({
  6494. contents: _this2.ui.icon(_this2.options.icons.question),
  6495. tooltip: _this2.lang.options.help,
  6496. click: _this2.context.createInvokeHandler('helpDialog.show')
  6497. }).render();
  6498. });
  6499. }
  6500. /**
  6501. * image: [
  6502. * ['imageResize', ['resizeFull', 'resizeHalf', 'resizeQuarter', 'resizeNone']],
  6503. * ['float', ['floatLeft', 'floatRight', 'floatNone']],
  6504. * ['remove', ['removeMedia']],
  6505. * ],
  6506. */
  6507. }, {
  6508. key: "addImagePopoverButtons",
  6509. value: function addImagePopoverButtons() {
  6510. var _this3 = this;
  6511. // Image Size Buttons
  6512. this.context.memo('button.resizeFull', function () {
  6513. return _this3.button({
  6514. contents: '<span class="note-fontsize-10">100%</span>',
  6515. tooltip: _this3.lang.image.resizeFull,
  6516. click: _this3.context.createInvokeHandler('editor.resize', '1')
  6517. }).render();
  6518. });
  6519. this.context.memo('button.resizeHalf', function () {
  6520. return _this3.button({
  6521. contents: '<span class="note-fontsize-10">50%</span>',
  6522. tooltip: _this3.lang.image.resizeHalf,
  6523. click: _this3.context.createInvokeHandler('editor.resize', '0.5')
  6524. }).render();
  6525. });
  6526. this.context.memo('button.resizeQuarter', function () {
  6527. return _this3.button({
  6528. contents: '<span class="note-fontsize-10">25%</span>',
  6529. tooltip: _this3.lang.image.resizeQuarter,
  6530. click: _this3.context.createInvokeHandler('editor.resize', '0.25')
  6531. }).render();
  6532. });
  6533. this.context.memo('button.resizeNone', function () {
  6534. return _this3.button({
  6535. contents: _this3.ui.icon(_this3.options.icons.rollback),
  6536. tooltip: _this3.lang.image.resizeNone,
  6537. click: _this3.context.createInvokeHandler('editor.resize', '0')
  6538. }).render();
  6539. }); // Float Buttons
  6540. this.context.memo('button.floatLeft', function () {
  6541. return _this3.button({
  6542. contents: _this3.ui.icon(_this3.options.icons.floatLeft),
  6543. tooltip: _this3.lang.image.floatLeft,
  6544. click: _this3.context.createInvokeHandler('editor.floatMe', 'left')
  6545. }).render();
  6546. });
  6547. this.context.memo('button.floatRight', function () {
  6548. return _this3.button({
  6549. contents: _this3.ui.icon(_this3.options.icons.floatRight),
  6550. tooltip: _this3.lang.image.floatRight,
  6551. click: _this3.context.createInvokeHandler('editor.floatMe', 'right')
  6552. }).render();
  6553. });
  6554. this.context.memo('button.floatNone', function () {
  6555. return _this3.button({
  6556. contents: _this3.ui.icon(_this3.options.icons.rollback),
  6557. tooltip: _this3.lang.image.floatNone,
  6558. click: _this3.context.createInvokeHandler('editor.floatMe', 'none')
  6559. }).render();
  6560. }); // Remove Buttons
  6561. this.context.memo('button.removeMedia', function () {
  6562. return _this3.button({
  6563. contents: _this3.ui.icon(_this3.options.icons.trash),
  6564. tooltip: _this3.lang.image.remove,
  6565. click: _this3.context.createInvokeHandler('editor.removeMedia')
  6566. }).render();
  6567. });
  6568. }
  6569. }, {
  6570. key: "addLinkPopoverButtons",
  6571. value: function addLinkPopoverButtons() {
  6572. var _this4 = this;
  6573. this.context.memo('button.linkDialogShow', function () {
  6574. return _this4.button({
  6575. contents: _this4.ui.icon(_this4.options.icons.link),
  6576. tooltip: _this4.lang.link.edit,
  6577. click: _this4.context.createInvokeHandler('linkDialog.show')
  6578. }).render();
  6579. });
  6580. this.context.memo('button.unlink', function () {
  6581. return _this4.button({
  6582. contents: _this4.ui.icon(_this4.options.icons.unlink),
  6583. tooltip: _this4.lang.link.unlink,
  6584. click: _this4.context.createInvokeHandler('editor.unlink')
  6585. }).render();
  6586. });
  6587. }
  6588. /**
  6589. * table : [
  6590. * ['add', ['addRowDown', 'addRowUp', 'addColLeft', 'addColRight']],
  6591. * ['delete', ['deleteRow', 'deleteCol', 'deleteTable']]
  6592. * ],
  6593. */
  6594. }, {
  6595. key: "addTablePopoverButtons",
  6596. value: function addTablePopoverButtons() {
  6597. var _this5 = this;
  6598. this.context.memo('button.addRowUp', function () {
  6599. return _this5.button({
  6600. className: 'btn-md',
  6601. contents: _this5.ui.icon(_this5.options.icons.rowAbove),
  6602. tooltip: _this5.lang.table.addRowAbove,
  6603. click: _this5.context.createInvokeHandler('editor.addRow', 'top')
  6604. }).render();
  6605. });
  6606. this.context.memo('button.addRowDown', function () {
  6607. return _this5.button({
  6608. className: 'btn-md',
  6609. contents: _this5.ui.icon(_this5.options.icons.rowBelow),
  6610. tooltip: _this5.lang.table.addRowBelow,
  6611. click: _this5.context.createInvokeHandler('editor.addRow', 'bottom')
  6612. }).render();
  6613. });
  6614. this.context.memo('button.addColLeft', function () {
  6615. return _this5.button({
  6616. className: 'btn-md',
  6617. contents: _this5.ui.icon(_this5.options.icons.colBefore),
  6618. tooltip: _this5.lang.table.addColLeft,
  6619. click: _this5.context.createInvokeHandler('editor.addCol', 'left')
  6620. }).render();
  6621. });
  6622. this.context.memo('button.addColRight', function () {
  6623. return _this5.button({
  6624. className: 'btn-md',
  6625. contents: _this5.ui.icon(_this5.options.icons.colAfter),
  6626. tooltip: _this5.lang.table.addColRight,
  6627. click: _this5.context.createInvokeHandler('editor.addCol', 'right')
  6628. }).render();
  6629. });
  6630. this.context.memo('button.deleteRow', function () {
  6631. return _this5.button({
  6632. className: 'btn-md',
  6633. contents: _this5.ui.icon(_this5.options.icons.rowRemove),
  6634. tooltip: _this5.lang.table.delRow,
  6635. click: _this5.context.createInvokeHandler('editor.deleteRow')
  6636. }).render();
  6637. });
  6638. this.context.memo('button.deleteCol', function () {
  6639. return _this5.button({
  6640. className: 'btn-md',
  6641. contents: _this5.ui.icon(_this5.options.icons.colRemove),
  6642. tooltip: _this5.lang.table.delCol,
  6643. click: _this5.context.createInvokeHandler('editor.deleteCol')
  6644. }).render();
  6645. });
  6646. this.context.memo('button.deleteTable', function () {
  6647. return _this5.button({
  6648. className: 'btn-md',
  6649. contents: _this5.ui.icon(_this5.options.icons.trash),
  6650. tooltip: _this5.lang.table.delTable,
  6651. click: _this5.context.createInvokeHandler('editor.deleteTable')
  6652. }).render();
  6653. });
  6654. }
  6655. }, {
  6656. key: "build",
  6657. value: function build($container, groups) {
  6658. for (var groupIdx = 0, groupLen = groups.length; groupIdx < groupLen; groupIdx++) {
  6659. var group = groups[groupIdx];
  6660. var groupName = Array.isArray(group) ? group[0] : group;
  6661. var buttons = Array.isArray(group) ? group.length === 1 ? [group[0]] : group[1] : [group];
  6662. var $group = this.ui.buttonGroup({
  6663. className: 'note-' + groupName
  6664. }).render();
  6665. for (var idx = 0, len = buttons.length; idx < len; idx++) {
  6666. var btn = this.context.memo('button.' + buttons[idx]);
  6667. if (btn) {
  6668. $group.append(typeof btn === 'function' ? btn(this.context) : btn);
  6669. }
  6670. }
  6671. $group.appendTo($container);
  6672. }
  6673. }
  6674. /**
  6675. * @param {jQuery} [$container]
  6676. */
  6677. }, {
  6678. key: "updateCurrentStyle",
  6679. value: function updateCurrentStyle($container) {
  6680. var _this6 = this;
  6681. var $cont = $container || this.$toolbar;
  6682. var styleInfo = this.context.invoke('editor.currentStyle');
  6683. this.updateBtnStates($cont, {
  6684. '.note-btn-bold': function noteBtnBold() {
  6685. return styleInfo['font-bold'] === 'bold';
  6686. },
  6687. '.note-btn-italic': function noteBtnItalic() {
  6688. return styleInfo['font-italic'] === 'italic';
  6689. },
  6690. '.note-btn-underline': function noteBtnUnderline() {
  6691. return styleInfo['font-underline'] === 'underline';
  6692. },
  6693. '.note-btn-subscript': function noteBtnSubscript() {
  6694. return styleInfo['font-subscript'] === 'subscript';
  6695. },
  6696. '.note-btn-superscript': function noteBtnSuperscript() {
  6697. return styleInfo['font-superscript'] === 'superscript';
  6698. },
  6699. '.note-btn-strikethrough': function noteBtnStrikethrough() {
  6700. return styleInfo['font-strikethrough'] === 'strikethrough';
  6701. }
  6702. });
  6703. if (styleInfo['font-family']) {
  6704. var fontNames = styleInfo['font-family'].split(',').map(function (name) {
  6705. return name.replace(/[\'\"]/g, '').replace(/\s+$/, '').replace(/^\s+/, '');
  6706. });
  6707. var fontName = lists.find(fontNames, this.isFontInstalled.bind(this));
  6708. $cont.find('.dropdown-fontname a').each(function (idx, item) {
  6709. var $item = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item); // always compare string to avoid creating another func.
  6710. var isChecked = $item.data('value') + '' === fontName + '';
  6711. $item.toggleClass('checked', isChecked);
  6712. });
  6713. $cont.find('.note-current-fontname').text(fontName).css('font-family', fontName);
  6714. }
  6715. if (styleInfo['font-size']) {
  6716. var fontSize = styleInfo['font-size'];
  6717. $cont.find('.dropdown-fontsize a').each(function (idx, item) {
  6718. var $item = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item); // always compare with string to avoid creating another func.
  6719. var isChecked = $item.data('value') + '' === fontSize + '';
  6720. $item.toggleClass('checked', isChecked);
  6721. });
  6722. $cont.find('.note-current-fontsize').text(fontSize);
  6723. var fontSizeUnit = styleInfo['font-size-unit'];
  6724. $cont.find('.dropdown-fontsizeunit a').each(function (idx, item) {
  6725. var $item = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item);
  6726. var isChecked = $item.data('value') + '' === fontSizeUnit + '';
  6727. $item.toggleClass('checked', isChecked);
  6728. });
  6729. $cont.find('.note-current-fontsizeunit').text(fontSizeUnit);
  6730. }
  6731. if (styleInfo['line-height']) {
  6732. var lineHeight = styleInfo['line-height'];
  6733. $cont.find('.dropdown-line-height li a').each(function (idx, item) {
  6734. // always compare with string to avoid creating another func.
  6735. var isChecked = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(item).data('value') + '' === lineHeight + '';
  6736. _this6.className = isChecked ? 'checked' : '';
  6737. });
  6738. }
  6739. }
  6740. }, {
  6741. key: "updateBtnStates",
  6742. value: function updateBtnStates($container, infos) {
  6743. var _this7 = this;
  6744. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.each(infos, function (selector, pred) {
  6745. _this7.ui.toggleBtnActive($container.find(selector), pred());
  6746. });
  6747. }
  6748. }, {
  6749. key: "tableMoveHandler",
  6750. value: function tableMoveHandler(event) {
  6751. var PX_PER_EM = 18;
  6752. var $picker = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(event.target.parentNode); // target is mousecatcher
  6753. var $dimensionDisplay = $picker.next();
  6754. var $catcher = $picker.find('.note-dimension-picker-mousecatcher');
  6755. var $highlighted = $picker.find('.note-dimension-picker-highlighted');
  6756. var $unhighlighted = $picker.find('.note-dimension-picker-unhighlighted');
  6757. var posOffset; // HTML5 with jQuery - e.offsetX is undefined in Firefox
  6758. if (event.offsetX === undefined) {
  6759. var posCatcher = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(event.target).offset();
  6760. posOffset = {
  6761. x: event.pageX - posCatcher.left,
  6762. y: event.pageY - posCatcher.top
  6763. };
  6764. } else {
  6765. posOffset = {
  6766. x: event.offsetX,
  6767. y: event.offsetY
  6768. };
  6769. }
  6770. var dim = {
  6771. c: Math.ceil(posOffset.x / PX_PER_EM) || 1,
  6772. r: Math.ceil(posOffset.y / PX_PER_EM) || 1
  6773. };
  6774. $highlighted.css({
  6775. width: dim.c + 'em',
  6776. height: dim.r + 'em'
  6777. });
  6778. $catcher.data('value', dim.c + 'x' + dim.r);
  6779. if (dim.c > 3 && dim.c < this.options.insertTableMaxSize.col) {
  6780. $unhighlighted.css({
  6781. width: dim.c + 1 + 'em'
  6782. });
  6783. }
  6784. if (dim.r > 3 && dim.r < this.options.insertTableMaxSize.row) {
  6785. $unhighlighted.css({
  6786. height: dim.r + 1 + 'em'
  6787. });
  6788. }
  6789. $dimensionDisplay.html(dim.c + ' x ' + dim.r);
  6790. }
  6791. }]);
  6792. return Buttons;
  6793. }();
  6794. // CONCATENATED MODULE: ./src/js/base/module/Toolbar.js
  6795. function Toolbar_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6796. function Toolbar_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); } }
  6797. function Toolbar_createClass(Constructor, protoProps, staticProps) { if (protoProps) Toolbar_defineProperties(Constructor.prototype, protoProps); if (staticProps) Toolbar_defineProperties(Constructor, staticProps); return Constructor; }
  6798. var Toolbar_Toolbar =
  6799. /*#__PURE__*/
  6800. function () {
  6801. function Toolbar(context) {
  6802. Toolbar_classCallCheck(this, Toolbar);
  6803. this.context = context;
  6804. this.$window = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(window);
  6805. this.$document = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document);
  6806. this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
  6807. this.$note = context.layoutInfo.note;
  6808. this.$editor = context.layoutInfo.editor;
  6809. this.$toolbar = context.layoutInfo.toolbar;
  6810. this.$editable = context.layoutInfo.editable;
  6811. this.$statusbar = context.layoutInfo.statusbar;
  6812. this.options = context.options;
  6813. this.isFollowing = false;
  6814. this.followScroll = this.followScroll.bind(this);
  6815. }
  6816. Toolbar_createClass(Toolbar, [{
  6817. key: "shouldInitialize",
  6818. value: function shouldInitialize() {
  6819. return !this.options.airMode;
  6820. }
  6821. }, {
  6822. key: "initialize",
  6823. value: function initialize() {
  6824. var _this = this;
  6825. this.options.toolbar = this.options.toolbar || [];
  6826. if (!this.options.toolbar.length) {
  6827. this.$toolbar.hide();
  6828. } else {
  6829. this.context.invoke('buttons.build', this.$toolbar, this.options.toolbar);
  6830. }
  6831. if (this.options.toolbarContainer) {
  6832. this.$toolbar.appendTo(this.options.toolbarContainer);
  6833. }
  6834. this.changeContainer(false);
  6835. this.$note.on('summernote.keyup summernote.mouseup summernote.change', function () {
  6836. _this.context.invoke('buttons.updateCurrentStyle');
  6837. });
  6838. this.context.invoke('buttons.updateCurrentStyle');
  6839. if (this.options.followingToolbar) {
  6840. this.$window.on('scroll resize', this.followScroll);
  6841. }
  6842. }
  6843. }, {
  6844. key: "destroy",
  6845. value: function destroy() {
  6846. this.$toolbar.children().remove();
  6847. if (this.options.followingToolbar) {
  6848. this.$window.off('scroll resize', this.followScroll);
  6849. }
  6850. }
  6851. }, {
  6852. key: "followScroll",
  6853. value: function followScroll() {
  6854. if (this.$editor.hasClass('fullscreen')) {
  6855. return false;
  6856. }
  6857. var editorHeight = this.$editor.outerHeight();
  6858. var editorWidth = this.$editor.width();
  6859. var toolbarHeight = this.$toolbar.height();
  6860. var statusbarHeight = this.$statusbar.height(); // check if the web app is currently using another static bar
  6861. var otherBarHeight = 0;
  6862. if (this.options.otherStaticBar) {
  6863. otherBarHeight = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.otherStaticBar).outerHeight();
  6864. }
  6865. var currentOffset = this.$document.scrollTop();
  6866. var editorOffsetTop = this.$editor.offset().top;
  6867. var editorOffsetBottom = editorOffsetTop + editorHeight;
  6868. var activateOffset = editorOffsetTop - otherBarHeight;
  6869. var deactivateOffsetBottom = editorOffsetBottom - otherBarHeight - toolbarHeight - statusbarHeight;
  6870. if (!this.isFollowing && currentOffset > activateOffset && currentOffset < deactivateOffsetBottom - toolbarHeight) {
  6871. this.isFollowing = true;
  6872. this.$editable.css({
  6873. marginTop: this.$toolbar.outerHeight()
  6874. });
  6875. this.$toolbar.css({
  6876. position: 'fixed',
  6877. top: otherBarHeight,
  6878. width: editorWidth,
  6879. zIndex: 1000
  6880. });
  6881. } else if (this.isFollowing && (currentOffset < activateOffset || currentOffset > deactivateOffsetBottom)) {
  6882. this.isFollowing = false;
  6883. this.$toolbar.css({
  6884. position: 'relative',
  6885. top: 0,
  6886. width: '100%',
  6887. zIndex: 'auto'
  6888. });
  6889. this.$editable.css({
  6890. marginTop: ''
  6891. });
  6892. }
  6893. }
  6894. }, {
  6895. key: "changeContainer",
  6896. value: function changeContainer(isFullscreen) {
  6897. if (isFullscreen) {
  6898. this.$toolbar.prependTo(this.$editor);
  6899. } else {
  6900. if (this.options.toolbarContainer) {
  6901. this.$toolbar.appendTo(this.options.toolbarContainer);
  6902. }
  6903. }
  6904. if (this.options.followingToolbar) {
  6905. this.followScroll();
  6906. }
  6907. }
  6908. }, {
  6909. key: "updateFullscreen",
  6910. value: function updateFullscreen(isFullscreen) {
  6911. this.ui.toggleBtnActive(this.$toolbar.find('.btn-fullscreen'), isFullscreen);
  6912. this.changeContainer(isFullscreen);
  6913. }
  6914. }, {
  6915. key: "updateCodeview",
  6916. value: function updateCodeview(isCodeview) {
  6917. this.ui.toggleBtnActive(this.$toolbar.find('.btn-codeview'), isCodeview);
  6918. if (isCodeview) {
  6919. this.deactivate();
  6920. } else {
  6921. this.activate();
  6922. }
  6923. }
  6924. }, {
  6925. key: "activate",
  6926. value: function activate(isIncludeCodeview) {
  6927. var $btn = this.$toolbar.find('button');
  6928. if (!isIncludeCodeview) {
  6929. $btn = $btn.not('.btn-codeview').not('.btn-fullscreen');
  6930. }
  6931. this.ui.toggleBtn($btn, true);
  6932. }
  6933. }, {
  6934. key: "deactivate",
  6935. value: function deactivate(isIncludeCodeview) {
  6936. var $btn = this.$toolbar.find('button');
  6937. if (!isIncludeCodeview) {
  6938. $btn = $btn.not('.btn-codeview').not('.btn-fullscreen');
  6939. }
  6940. this.ui.toggleBtn($btn, false);
  6941. }
  6942. }]);
  6943. return Toolbar;
  6944. }();
  6945. // CONCATENATED MODULE: ./src/js/base/module/LinkDialog.js
  6946. function LinkDialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6947. function LinkDialog_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); } }
  6948. function LinkDialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) LinkDialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) LinkDialog_defineProperties(Constructor, staticProps); return Constructor; }
  6949. var LinkDialog_LinkDialog =
  6950. /*#__PURE__*/
  6951. function () {
  6952. function LinkDialog(context) {
  6953. LinkDialog_classCallCheck(this, LinkDialog);
  6954. this.context = context;
  6955. this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
  6956. this.$body = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document.body);
  6957. this.$editor = context.layoutInfo.editor;
  6958. this.options = context.options;
  6959. this.lang = this.options.langInfo;
  6960. context.memo('help.linkDialog.show', this.options.langInfo.help['linkDialog.show']);
  6961. }
  6962. LinkDialog_createClass(LinkDialog, [{
  6963. key: "initialize",
  6964. value: function initialize() {
  6965. var $container = this.options.dialogsInBody ? this.$body : this.options.container;
  6966. var body = ['<div class="form-group note-form-group">', "<label for=\"note-dialog-link-txt-".concat(this.options.id, "\" class=\"note-form-label\">").concat(this.lang.link.textToDisplay, "</label>"), "<input id=\"note-dialog-link-txt-".concat(this.options.id, "\" class=\"note-link-text form-control note-form-control note-input\" type=\"text\"/>"), '</div>', '<div class="form-group note-form-group">', "<label for=\"note-dialog-link-url-".concat(this.options.id, "\" class=\"note-form-label\">").concat(this.lang.link.url, "</label>"), "<input id=\"note-dialog-link-url-".concat(this.options.id, "\" class=\"note-link-url form-control note-form-control note-input\" type=\"text\" value=\"http://\"/>"), '</div>', !this.options.disableLinkTarget ? external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div/>').append(this.ui.checkbox({
  6967. className: 'sn-checkbox-open-in-new-window',
  6968. text: this.lang.link.openInNewWindow,
  6969. checked: true
  6970. }).render()).html() : '', external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div/>').append(this.ui.checkbox({
  6971. className: 'sn-checkbox-use-protocol',
  6972. text: this.lang.link.useProtocol,
  6973. checked: true
  6974. }).render()).html()].join('');
  6975. var buttonClass = 'btn btn-primary note-btn note-btn-primary note-link-btn';
  6976. var footer = "<input type=\"button\" href=\"#\" class=\"".concat(buttonClass, "\" value=\"").concat(this.lang.link.insert, "\" disabled>");
  6977. this.$dialog = this.ui.dialog({
  6978. className: 'link-dialog',
  6979. title: this.lang.link.insert,
  6980. fade: this.options.dialogsFade,
  6981. body: body,
  6982. footer: footer
  6983. }).render().appendTo($container);
  6984. }
  6985. }, {
  6986. key: "destroy",
  6987. value: function destroy() {
  6988. this.ui.hideDialog(this.$dialog);
  6989. this.$dialog.remove();
  6990. }
  6991. }, {
  6992. key: "bindEnterKey",
  6993. value: function bindEnterKey($input, $btn) {
  6994. $input.on('keypress', function (event) {
  6995. if (event.keyCode === core_key.code.ENTER) {
  6996. event.preventDefault();
  6997. $btn.trigger('click');
  6998. }
  6999. });
  7000. }
  7001. /**
  7002. * toggle update button
  7003. */
  7004. }, {
  7005. key: "toggleLinkBtn",
  7006. value: function toggleLinkBtn($linkBtn, $linkText, $linkUrl) {
  7007. this.ui.toggleBtn($linkBtn, $linkText.val() && $linkUrl.val());
  7008. }
  7009. /**
  7010. * Show link dialog and set event handlers on dialog controls.
  7011. *
  7012. * @param {Object} linkInfo
  7013. * @return {Promise}
  7014. */
  7015. }, {
  7016. key: "showLinkDialog",
  7017. value: function showLinkDialog(linkInfo) {
  7018. var _this = this;
  7019. return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.Deferred(function (deferred) {
  7020. var $linkText = _this.$dialog.find('.note-link-text');
  7021. var $linkUrl = _this.$dialog.find('.note-link-url');
  7022. var $linkBtn = _this.$dialog.find('.note-link-btn');
  7023. var $openInNewWindow = _this.$dialog.find('.sn-checkbox-open-in-new-window input[type=checkbox]');
  7024. var $useProtocol = _this.$dialog.find('.sn-checkbox-use-protocol input[type=checkbox]');
  7025. _this.ui.onDialogShown(_this.$dialog, function () {
  7026. _this.context.triggerEvent('dialog.shown'); // If no url was given and given text is valid URL then copy that into URL Field
  7027. if (!linkInfo.url && func.isValidUrl(linkInfo.text)) {
  7028. linkInfo.url = linkInfo.text;
  7029. }
  7030. $linkText.on('input paste propertychange', function () {
  7031. // If linktext was modified by input events,
  7032. // cloning text from linkUrl will be stopped.
  7033. linkInfo.text = $linkText.val();
  7034. _this.toggleLinkBtn($linkBtn, $linkText, $linkUrl);
  7035. }).val(linkInfo.text);
  7036. $linkUrl.on('input paste propertychange', function () {
  7037. // Display same text on `Text to display` as default
  7038. // when linktext has no text
  7039. if (!linkInfo.text) {
  7040. $linkText.val($linkUrl.val());
  7041. }
  7042. _this.toggleLinkBtn($linkBtn, $linkText, $linkUrl);
  7043. }).val(linkInfo.url);
  7044. if (!env.isSupportTouch) {
  7045. $linkUrl.trigger('focus');
  7046. }
  7047. _this.toggleLinkBtn($linkBtn, $linkText, $linkUrl);
  7048. _this.bindEnterKey($linkUrl, $linkBtn);
  7049. _this.bindEnterKey($linkText, $linkBtn);
  7050. var isNewWindowChecked = linkInfo.isNewWindow !== undefined ? linkInfo.isNewWindow : _this.context.options.linkTargetBlank;
  7051. $openInNewWindow.prop('checked', isNewWindowChecked);
  7052. var useProtocolChecked = linkInfo.url ? false : _this.context.options.useProtocol;
  7053. $useProtocol.prop('checked', useProtocolChecked);
  7054. $linkBtn.one('click', function (event) {
  7055. event.preventDefault();
  7056. deferred.resolve({
  7057. range: linkInfo.range,
  7058. url: $linkUrl.val(),
  7059. text: $linkText.val(),
  7060. isNewWindow: $openInNewWindow.is(':checked'),
  7061. checkProtocol: $useProtocol.is(':checked')
  7062. });
  7063. _this.ui.hideDialog(_this.$dialog);
  7064. });
  7065. });
  7066. _this.ui.onDialogHidden(_this.$dialog, function () {
  7067. // detach events
  7068. $linkText.off();
  7069. $linkUrl.off();
  7070. $linkBtn.off();
  7071. if (deferred.state() === 'pending') {
  7072. deferred.reject();
  7073. }
  7074. });
  7075. _this.ui.showDialog(_this.$dialog);
  7076. }).promise();
  7077. }
  7078. /**
  7079. * @param {Object} layoutInfo
  7080. */
  7081. }, {
  7082. key: "show",
  7083. value: function show() {
  7084. var _this2 = this;
  7085. var linkInfo = this.context.invoke('editor.getLinkInfo');
  7086. this.context.invoke('editor.saveRange');
  7087. this.showLinkDialog(linkInfo).then(function (linkInfo) {
  7088. _this2.context.invoke('editor.restoreRange');
  7089. _this2.context.invoke('editor.createLink', linkInfo);
  7090. }).fail(function () {
  7091. _this2.context.invoke('editor.restoreRange');
  7092. });
  7093. }
  7094. }]);
  7095. return LinkDialog;
  7096. }();
  7097. // CONCATENATED MODULE: ./src/js/base/module/LinkPopover.js
  7098. function LinkPopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7099. function LinkPopover_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); } }
  7100. function LinkPopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) LinkPopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) LinkPopover_defineProperties(Constructor, staticProps); return Constructor; }
  7101. var LinkPopover_LinkPopover =
  7102. /*#__PURE__*/
  7103. function () {
  7104. function LinkPopover(context) {
  7105. var _this = this;
  7106. LinkPopover_classCallCheck(this, LinkPopover);
  7107. this.context = context;
  7108. this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
  7109. this.options = context.options;
  7110. this.events = {
  7111. 'summernote.keyup summernote.mouseup summernote.change summernote.scroll': function summernoteKeyupSummernoteMouseupSummernoteChangeSummernoteScroll() {
  7112. _this.update();
  7113. },
  7114. 'summernote.disable summernote.dialog.shown summernote.blur': function summernoteDisableSummernoteDialogShownSummernoteBlur() {
  7115. _this.hide();
  7116. }
  7117. };
  7118. }
  7119. LinkPopover_createClass(LinkPopover, [{
  7120. key: "shouldInitialize",
  7121. value: function shouldInitialize() {
  7122. return !lists.isEmpty(this.options.popover.link);
  7123. }
  7124. }, {
  7125. key: "initialize",
  7126. value: function initialize() {
  7127. this.$popover = this.ui.popover({
  7128. className: 'note-link-popover',
  7129. callback: function callback($node) {
  7130. var $content = $node.find('.popover-content,.note-popover-content');
  7131. $content.prepend('<span><a target="_blank"></a>&nbsp;</span>');
  7132. }
  7133. }).render().appendTo(this.options.container);
  7134. var $content = this.$popover.find('.popover-content,.note-popover-content');
  7135. this.context.invoke('buttons.build', $content, this.options.popover.link);
  7136. this.$popover.on('mousedown', function (e) {
  7137. e.preventDefault();
  7138. });
  7139. }
  7140. }, {
  7141. key: "destroy",
  7142. value: function destroy() {
  7143. this.$popover.remove();
  7144. }
  7145. }, {
  7146. key: "update",
  7147. value: function update() {
  7148. // Prevent focusing on editable when invoke('code') is executed
  7149. if (!this.context.invoke('editor.hasFocus')) {
  7150. this.hide();
  7151. return;
  7152. }
  7153. var rng = this.context.invoke('editor.getLastRange');
  7154. if (rng.isCollapsed() && rng.isOnAnchor()) {
  7155. var anchor = dom.ancestor(rng.sc, dom.isAnchor);
  7156. var href = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(anchor).attr('href');
  7157. this.$popover.find('a').attr('href', href).text(href);
  7158. var pos = dom.posFromPlaceholder(anchor);
  7159. var containerOffset = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.container).offset();
  7160. pos.top -= containerOffset.top;
  7161. pos.left -= containerOffset.left;
  7162. this.$popover.css({
  7163. display: 'block',
  7164. left: pos.left,
  7165. top: pos.top
  7166. });
  7167. } else {
  7168. this.hide();
  7169. }
  7170. }
  7171. }, {
  7172. key: "hide",
  7173. value: function hide() {
  7174. this.$popover.hide();
  7175. }
  7176. }]);
  7177. return LinkPopover;
  7178. }();
  7179. // CONCATENATED MODULE: ./src/js/base/module/ImageDialog.js
  7180. function ImageDialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7181. function ImageDialog_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); } }
  7182. function ImageDialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) ImageDialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) ImageDialog_defineProperties(Constructor, staticProps); return Constructor; }
  7183. var ImageDialog_ImageDialog =
  7184. /*#__PURE__*/
  7185. function () {
  7186. function ImageDialog(context) {
  7187. ImageDialog_classCallCheck(this, ImageDialog);
  7188. this.context = context;
  7189. this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
  7190. this.$body = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document.body);
  7191. this.$editor = context.layoutInfo.editor;
  7192. this.options = context.options;
  7193. this.lang = this.options.langInfo;
  7194. }
  7195. ImageDialog_createClass(ImageDialog, [{
  7196. key: "initialize",
  7197. value: function initialize() {
  7198. var imageLimitation = '';
  7199. if (this.options.maximumImageFileSize) {
  7200. var unit = Math.floor(Math.log(this.options.maximumImageFileSize) / Math.log(1024));
  7201. var readableSize = (this.options.maximumImageFileSize / Math.pow(1024, unit)).toFixed(2) * 1 + ' ' + ' KMGTP'[unit] + 'B';
  7202. imageLimitation = "<small>".concat(this.lang.image.maximumFileSize + ' : ' + readableSize, "</small>");
  7203. }
  7204. var $container = this.options.dialogsInBody ? this.$body : this.options.container;
  7205. var body = ['<div class="form-group note-form-group note-group-select-from-files">', '<label for="note-dialog-image-file-' + this.options.id + '" class="note-form-label">' + this.lang.image.selectFromFiles + '</label>', '<input id="note-dialog-image-file-' + this.options.id + '" class="note-image-input form-control-file note-form-control note-input" ', ' type="file" name="files" accept="image/*" multiple="multiple"/>', imageLimitation, '</div>', '<div class="form-group note-group-image-url">', '<label for="note-dialog-image-url-' + this.options.id + '" class="note-form-label">' + this.lang.image.url + '</label>', '<input id="note-dialog-image-url-' + this.options.id + '" class="note-image-url form-control note-form-control note-input" type="text"/>', '</div>'].join('');
  7206. var buttonClass = 'btn btn-primary note-btn note-btn-primary note-image-btn';
  7207. var footer = "<input type=\"button\" href=\"#\" class=\"".concat(buttonClass, "\" value=\"").concat(this.lang.image.insert, "\" disabled>");
  7208. this.$dialog = this.ui.dialog({
  7209. title: this.lang.image.insert,
  7210. fade: this.options.dialogsFade,
  7211. body: body,
  7212. footer: footer
  7213. }).render().appendTo($container);
  7214. }
  7215. }, {
  7216. key: "destroy",
  7217. value: function destroy() {
  7218. this.ui.hideDialog(this.$dialog);
  7219. this.$dialog.remove();
  7220. }
  7221. }, {
  7222. key: "bindEnterKey",
  7223. value: function bindEnterKey($input, $btn) {
  7224. $input.on('keypress', function (event) {
  7225. if (event.keyCode === core_key.code.ENTER) {
  7226. event.preventDefault();
  7227. $btn.trigger('click');
  7228. }
  7229. });
  7230. }
  7231. }, {
  7232. key: "show",
  7233. value: function show() {
  7234. var _this = this;
  7235. this.context.invoke('editor.saveRange');
  7236. this.showImageDialog().then(function (data) {
  7237. // [workaround] hide dialog before restore range for IE range focus
  7238. _this.ui.hideDialog(_this.$dialog);
  7239. _this.context.invoke('editor.restoreRange');
  7240. if (typeof data === 'string') {
  7241. // image url
  7242. // If onImageLinkInsert set,
  7243. if (_this.options.callbacks.onImageLinkInsert) {
  7244. _this.context.triggerEvent('image.link.insert', data);
  7245. } else {
  7246. _this.context.invoke('editor.insertImage', data);
  7247. }
  7248. } else {
  7249. // array of files
  7250. _this.context.invoke('editor.insertImagesOrCallback', data);
  7251. }
  7252. }).fail(function () {
  7253. _this.context.invoke('editor.restoreRange');
  7254. });
  7255. }
  7256. /**
  7257. * show image dialog
  7258. *
  7259. * @param {jQuery} $dialog
  7260. * @return {Promise}
  7261. */
  7262. }, {
  7263. key: "showImageDialog",
  7264. value: function showImageDialog() {
  7265. var _this2 = this;
  7266. return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.Deferred(function (deferred) {
  7267. var $imageInput = _this2.$dialog.find('.note-image-input');
  7268. var $imageUrl = _this2.$dialog.find('.note-image-url');
  7269. var $imageBtn = _this2.$dialog.find('.note-image-btn');
  7270. _this2.ui.onDialogShown(_this2.$dialog, function () {
  7271. _this2.context.triggerEvent('dialog.shown'); // Cloning imageInput to clear element.
  7272. $imageInput.replaceWith($imageInput.clone().on('change', function (event) {
  7273. deferred.resolve(event.target.files || event.target.value);
  7274. }).val(''));
  7275. $imageUrl.on('input paste propertychange', function () {
  7276. _this2.ui.toggleBtn($imageBtn, $imageUrl.val());
  7277. }).val('');
  7278. if (!env.isSupportTouch) {
  7279. $imageUrl.trigger('focus');
  7280. }
  7281. $imageBtn.click(function (event) {
  7282. event.preventDefault();
  7283. deferred.resolve($imageUrl.val());
  7284. });
  7285. _this2.bindEnterKey($imageUrl, $imageBtn);
  7286. });
  7287. _this2.ui.onDialogHidden(_this2.$dialog, function () {
  7288. $imageInput.off();
  7289. $imageUrl.off();
  7290. $imageBtn.off();
  7291. if (deferred.state() === 'pending') {
  7292. deferred.reject();
  7293. }
  7294. });
  7295. _this2.ui.showDialog(_this2.$dialog);
  7296. });
  7297. }
  7298. }]);
  7299. return ImageDialog;
  7300. }();
  7301. // CONCATENATED MODULE: ./src/js/base/module/ImagePopover.js
  7302. function ImagePopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7303. function ImagePopover_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); } }
  7304. function ImagePopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) ImagePopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) ImagePopover_defineProperties(Constructor, staticProps); return Constructor; }
  7305. /**
  7306. * Image popover module
  7307. * mouse events that show/hide popover will be handled by Handle.js.
  7308. * Handle.js will receive the events and invoke 'imagePopover.update'.
  7309. */
  7310. var ImagePopover_ImagePopover =
  7311. /*#__PURE__*/
  7312. function () {
  7313. function ImagePopover(context) {
  7314. var _this = this;
  7315. ImagePopover_classCallCheck(this, ImagePopover);
  7316. this.context = context;
  7317. this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
  7318. this.editable = context.layoutInfo.editable[0];
  7319. this.options = context.options;
  7320. this.events = {
  7321. 'summernote.disable summernote.blur': function summernoteDisableSummernoteBlur() {
  7322. _this.hide();
  7323. }
  7324. };
  7325. }
  7326. ImagePopover_createClass(ImagePopover, [{
  7327. key: "shouldInitialize",
  7328. value: function shouldInitialize() {
  7329. return !lists.isEmpty(this.options.popover.image);
  7330. }
  7331. }, {
  7332. key: "initialize",
  7333. value: function initialize() {
  7334. this.$popover = this.ui.popover({
  7335. className: 'note-image-popover'
  7336. }).render().appendTo(this.options.container);
  7337. var $content = this.$popover.find('.popover-content,.note-popover-content');
  7338. this.context.invoke('buttons.build', $content, this.options.popover.image);
  7339. this.$popover.on('mousedown', function (e) {
  7340. e.preventDefault();
  7341. });
  7342. }
  7343. }, {
  7344. key: "destroy",
  7345. value: function destroy() {
  7346. this.$popover.remove();
  7347. }
  7348. }, {
  7349. key: "update",
  7350. value: function update(target, event) {
  7351. if (dom.isImg(target)) {
  7352. var position = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(target).offset();
  7353. var containerOffset = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.container).offset();
  7354. var pos = {};
  7355. if (this.options.popatmouse) {
  7356. pos.left = event.pageX - 20;
  7357. pos.top = event.pageY;
  7358. } else {
  7359. pos = position;
  7360. }
  7361. pos.top -= containerOffset.top;
  7362. pos.left -= containerOffset.left;
  7363. this.$popover.css({
  7364. display: 'block',
  7365. left: pos.left,
  7366. top: pos.top
  7367. });
  7368. } else {
  7369. this.hide();
  7370. }
  7371. }
  7372. }, {
  7373. key: "hide",
  7374. value: function hide() {
  7375. this.$popover.hide();
  7376. }
  7377. }]);
  7378. return ImagePopover;
  7379. }();
  7380. // CONCATENATED MODULE: ./src/js/base/module/TablePopover.js
  7381. function TablePopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7382. function TablePopover_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); } }
  7383. function TablePopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) TablePopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) TablePopover_defineProperties(Constructor, staticProps); return Constructor; }
  7384. var TablePopover_TablePopover =
  7385. /*#__PURE__*/
  7386. function () {
  7387. function TablePopover(context) {
  7388. var _this = this;
  7389. TablePopover_classCallCheck(this, TablePopover);
  7390. this.context = context;
  7391. this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
  7392. this.options = context.options;
  7393. this.events = {
  7394. 'summernote.mousedown': function summernoteMousedown(we, e) {
  7395. _this.update(e.target);
  7396. },
  7397. 'summernote.keyup summernote.scroll summernote.change': function summernoteKeyupSummernoteScrollSummernoteChange() {
  7398. _this.update();
  7399. },
  7400. 'summernote.disable summernote.blur': function summernoteDisableSummernoteBlur() {
  7401. _this.hide();
  7402. }
  7403. };
  7404. }
  7405. TablePopover_createClass(TablePopover, [{
  7406. key: "shouldInitialize",
  7407. value: function shouldInitialize() {
  7408. return !lists.isEmpty(this.options.popover.table);
  7409. }
  7410. }, {
  7411. key: "initialize",
  7412. value: function initialize() {
  7413. this.$popover = this.ui.popover({
  7414. className: 'note-table-popover'
  7415. }).render().appendTo(this.options.container);
  7416. var $content = this.$popover.find('.popover-content,.note-popover-content');
  7417. this.context.invoke('buttons.build', $content, this.options.popover.table); // [workaround] Disable Firefox's default table editor
  7418. if (env.isFF) {
  7419. document.execCommand('enableInlineTableEditing', false, false);
  7420. }
  7421. this.$popover.on('mousedown', function (e) {
  7422. e.preventDefault();
  7423. });
  7424. }
  7425. }, {
  7426. key: "destroy",
  7427. value: function destroy() {
  7428. this.$popover.remove();
  7429. }
  7430. }, {
  7431. key: "update",
  7432. value: function update(target) {
  7433. if (this.context.isDisabled()) {
  7434. return false;
  7435. }
  7436. var isCell = dom.isCell(target);
  7437. if (isCell) {
  7438. var pos = dom.posFromPlaceholder(target);
  7439. var containerOffset = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.container).offset();
  7440. pos.top -= containerOffset.top;
  7441. pos.left -= containerOffset.left;
  7442. this.$popover.css({
  7443. display: 'block',
  7444. left: pos.left,
  7445. top: pos.top
  7446. });
  7447. } else {
  7448. this.hide();
  7449. }
  7450. return isCell;
  7451. }
  7452. }, {
  7453. key: "hide",
  7454. value: function hide() {
  7455. this.$popover.hide();
  7456. }
  7457. }]);
  7458. return TablePopover;
  7459. }();
  7460. // CONCATENATED MODULE: ./src/js/base/module/VideoDialog.js
  7461. function VideoDialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7462. function VideoDialog_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); } }
  7463. function VideoDialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) VideoDialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) VideoDialog_defineProperties(Constructor, staticProps); return Constructor; }
  7464. var VideoDialog_VideoDialog =
  7465. /*#__PURE__*/
  7466. function () {
  7467. function VideoDialog(context) {
  7468. VideoDialog_classCallCheck(this, VideoDialog);
  7469. this.context = context;
  7470. this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
  7471. this.$body = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document.body);
  7472. this.$editor = context.layoutInfo.editor;
  7473. this.options = context.options;
  7474. this.lang = this.options.langInfo;
  7475. }
  7476. VideoDialog_createClass(VideoDialog, [{
  7477. key: "initialize",
  7478. value: function initialize() {
  7479. var $container = this.options.dialogsInBody ? this.$body : this.options.container;
  7480. var body = ['<div class="form-group note-form-group row-fluid">', "<label for=\"note-dialog-video-url-".concat(this.options.id, "\" class=\"note-form-label\">").concat(this.lang.video.url, " <small class=\"text-muted\">").concat(this.lang.video.providers, "</small></label>"), "<input id=\"note-dialog-video-url-".concat(this.options.id, "\" class=\"note-video-url form-control note-form-control note-input\" type=\"text\"/>"), '</div>'].join('');
  7481. var buttonClass = 'btn btn-primary note-btn note-btn-primary note-video-btn';
  7482. var footer = "<input type=\"button\" href=\"#\" class=\"".concat(buttonClass, "\" value=\"").concat(this.lang.video.insert, "\" disabled>");
  7483. this.$dialog = this.ui.dialog({
  7484. title: this.lang.video.insert,
  7485. fade: this.options.dialogsFade,
  7486. body: body,
  7487. footer: footer
  7488. }).render().appendTo($container);
  7489. }
  7490. }, {
  7491. key: "destroy",
  7492. value: function destroy() {
  7493. this.ui.hideDialog(this.$dialog);
  7494. this.$dialog.remove();
  7495. }
  7496. }, {
  7497. key: "bindEnterKey",
  7498. value: function bindEnterKey($input, $btn) {
  7499. $input.on('keypress', function (event) {
  7500. if (event.keyCode === core_key.code.ENTER) {
  7501. event.preventDefault();
  7502. $btn.trigger('click');
  7503. }
  7504. });
  7505. }
  7506. }, {
  7507. key: "createVideoNode",
  7508. value: function createVideoNode(url) {
  7509. // video url patterns(youtube, instagram, vimeo, dailymotion, youku, mp4, ogg, webm)
  7510. var ytRegExp = /\/\/(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))([\w|-]{11})(?:(?:[\?&]t=)(\S+))?$/;
  7511. var ytRegExpForStart = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/;
  7512. var ytMatch = url.match(ytRegExp);
  7513. var igRegExp = /(?:www\.|\/\/)instagram\.com\/p\/(.[a-zA-Z0-9_-]*)/;
  7514. var igMatch = url.match(igRegExp);
  7515. var vRegExp = /\/\/vine\.co\/v\/([a-zA-Z0-9]+)/;
  7516. var vMatch = url.match(vRegExp);
  7517. var vimRegExp = /\/\/(player\.)?vimeo\.com\/([a-z]*\/)*(\d+)[?]?.*/;
  7518. var vimMatch = url.match(vimRegExp);
  7519. var dmRegExp = /.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/;
  7520. var dmMatch = url.match(dmRegExp);
  7521. var youkuRegExp = /\/\/v\.youku\.com\/v_show\/id_(\w+)=*\.html/;
  7522. var youkuMatch = url.match(youkuRegExp);
  7523. var qqRegExp = /\/\/v\.qq\.com.*?vid=(.+)/;
  7524. var qqMatch = url.match(qqRegExp);
  7525. var qqRegExp2 = /\/\/v\.qq\.com\/x?\/?(page|cover).*?\/([^\/]+)\.html\??.*/;
  7526. var qqMatch2 = url.match(qqRegExp2);
  7527. var mp4RegExp = /^.+.(mp4|m4v)$/;
  7528. var mp4Match = url.match(mp4RegExp);
  7529. var oggRegExp = /^.+.(ogg|ogv)$/;
  7530. var oggMatch = url.match(oggRegExp);
  7531. var webmRegExp = /^.+.(webm)$/;
  7532. var webmMatch = url.match(webmRegExp);
  7533. var fbRegExp = /(?:www\.|\/\/)facebook\.com\/([^\/]+)\/videos\/([0-9]+)/;
  7534. var fbMatch = url.match(fbRegExp);
  7535. var $video;
  7536. if (ytMatch && ytMatch[1].length === 11) {
  7537. var youtubeId = ytMatch[1];
  7538. var start = 0;
  7539. if (typeof ytMatch[2] !== 'undefined') {
  7540. var ytMatchForStart = ytMatch[2].match(ytRegExpForStart);
  7541. if (ytMatchForStart) {
  7542. for (var n = [3600, 60, 1], i = 0, r = n.length; i < r; i++) {
  7543. start += typeof ytMatchForStart[i + 1] !== 'undefined' ? n[i] * parseInt(ytMatchForStart[i + 1], 10) : 0;
  7544. }
  7545. }
  7546. }
  7547. $video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe>').attr('frameborder', 0).attr('src', '//www.youtube.com/embed/' + youtubeId + (start > 0 ? '?start=' + start : '')).attr('width', '640').attr('height', '360');
  7548. } else if (igMatch && igMatch[0].length) {
  7549. $video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe>').attr('frameborder', 0).attr('src', 'https://instagram.com/p/' + igMatch[1] + '/embed/').attr('width', '612').attr('height', '710').attr('scrolling', 'no').attr('allowtransparency', 'true');
  7550. } else if (vMatch && vMatch[0].length) {
  7551. $video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe>').attr('frameborder', 0).attr('src', vMatch[0] + '/embed/simple').attr('width', '600').attr('height', '600').attr('class', 'vine-embed');
  7552. } else if (vimMatch && vimMatch[3].length) {
  7553. $video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen>').attr('frameborder', 0).attr('src', '//player.vimeo.com/video/' + vimMatch[3]).attr('width', '640').attr('height', '360');
  7554. } else if (dmMatch && dmMatch[2].length) {
  7555. $video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe>').attr('frameborder', 0).attr('src', '//www.dailymotion.com/embed/video/' + dmMatch[2]).attr('width', '640').attr('height', '360');
  7556. } else if (youkuMatch && youkuMatch[1].length) {
  7557. $video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen>').attr('frameborder', 0).attr('height', '498').attr('width', '510').attr('src', '//player.youku.com/embed/' + youkuMatch[1]);
  7558. } else if (qqMatch && qqMatch[1].length || qqMatch2 && qqMatch2[2].length) {
  7559. var vid = qqMatch && qqMatch[1].length ? qqMatch[1] : qqMatch2[2];
  7560. $video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen>').attr('frameborder', 0).attr('height', '310').attr('width', '500').attr('src', 'https://v.qq.com/iframe/player.html?vid=' + vid + '&amp;auto=0');
  7561. } else if (mp4Match || oggMatch || webmMatch) {
  7562. $video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<video controls>').attr('src', url).attr('width', '640').attr('height', '360');
  7563. } else if (fbMatch && fbMatch[0].length) {
  7564. $video = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<iframe>').attr('frameborder', 0).attr('src', 'https://www.facebook.com/plugins/video.php?href=' + encodeURIComponent(fbMatch[0]) + '&show_text=0&width=560').attr('width', '560').attr('height', '301').attr('scrolling', 'no').attr('allowtransparency', 'true');
  7565. } else {
  7566. // this is not a known video link. Now what, Cat? Now what?
  7567. return false;
  7568. }
  7569. $video.addClass('note-video-clip');
  7570. return $video[0];
  7571. }
  7572. }, {
  7573. key: "show",
  7574. value: function show() {
  7575. var _this = this;
  7576. var text = this.context.invoke('editor.getSelectedText');
  7577. this.context.invoke('editor.saveRange');
  7578. this.showVideoDialog(text).then(function (url) {
  7579. // [workaround] hide dialog before restore range for IE range focus
  7580. _this.ui.hideDialog(_this.$dialog);
  7581. _this.context.invoke('editor.restoreRange'); // build node
  7582. var $node = _this.createVideoNode(url);
  7583. if ($node) {
  7584. // insert video node
  7585. _this.context.invoke('editor.insertNode', $node);
  7586. }
  7587. }).fail(function () {
  7588. _this.context.invoke('editor.restoreRange');
  7589. });
  7590. }
  7591. /**
  7592. * show video dialog
  7593. *
  7594. * @param {jQuery} $dialog
  7595. * @return {Promise}
  7596. */
  7597. }, {
  7598. key: "showVideoDialog",
  7599. value: function showVideoDialog()
  7600. /* text */
  7601. {
  7602. var _this2 = this;
  7603. return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.Deferred(function (deferred) {
  7604. var $videoUrl = _this2.$dialog.find('.note-video-url');
  7605. var $videoBtn = _this2.$dialog.find('.note-video-btn');
  7606. _this2.ui.onDialogShown(_this2.$dialog, function () {
  7607. _this2.context.triggerEvent('dialog.shown');
  7608. $videoUrl.on('input paste propertychange', function () {
  7609. _this2.ui.toggleBtn($videoBtn, $videoUrl.val());
  7610. });
  7611. if (!env.isSupportTouch) {
  7612. $videoUrl.trigger('focus');
  7613. }
  7614. $videoBtn.click(function (event) {
  7615. event.preventDefault();
  7616. deferred.resolve($videoUrl.val());
  7617. });
  7618. _this2.bindEnterKey($videoUrl, $videoBtn);
  7619. });
  7620. _this2.ui.onDialogHidden(_this2.$dialog, function () {
  7621. $videoUrl.off();
  7622. $videoBtn.off();
  7623. if (deferred.state() === 'pending') {
  7624. deferred.reject();
  7625. }
  7626. });
  7627. _this2.ui.showDialog(_this2.$dialog);
  7628. });
  7629. }
  7630. }]);
  7631. return VideoDialog;
  7632. }();
  7633. // CONCATENATED MODULE: ./src/js/base/module/HelpDialog.js
  7634. function HelpDialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7635. function HelpDialog_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); } }
  7636. function HelpDialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) HelpDialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) HelpDialog_defineProperties(Constructor, staticProps); return Constructor; }
  7637. var HelpDialog_HelpDialog =
  7638. /*#__PURE__*/
  7639. function () {
  7640. function HelpDialog(context) {
  7641. HelpDialog_classCallCheck(this, HelpDialog);
  7642. this.context = context;
  7643. this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
  7644. this.$body = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document.body);
  7645. this.$editor = context.layoutInfo.editor;
  7646. this.options = context.options;
  7647. this.lang = this.options.langInfo;
  7648. }
  7649. HelpDialog_createClass(HelpDialog, [{
  7650. key: "initialize",
  7651. value: function initialize() {
  7652. var $container = this.options.dialogsInBody ? this.$body : this.options.container;
  7653. var body = ['<p class="text-center">', '<a href="http://summernote.org/" target="_blank">Summernote 0.8.16</a> · ', '<a href="https://github.com/summernote/summernote" target="_blank">Project</a> · ', '<a href="https://github.com/summernote/summernote/issues" target="_blank">Issues</a>', '</p>'].join('');
  7654. this.$dialog = this.ui.dialog({
  7655. title: this.lang.options.help,
  7656. fade: this.options.dialogsFade,
  7657. body: this.createShortcutList(),
  7658. footer: body,
  7659. callback: function callback($node) {
  7660. $node.find('.modal-body,.note-modal-body').css({
  7661. 'max-height': 300,
  7662. 'overflow': 'scroll'
  7663. });
  7664. }
  7665. }).render().appendTo($container);
  7666. }
  7667. }, {
  7668. key: "destroy",
  7669. value: function destroy() {
  7670. this.ui.hideDialog(this.$dialog);
  7671. this.$dialog.remove();
  7672. }
  7673. }, {
  7674. key: "createShortcutList",
  7675. value: function createShortcutList() {
  7676. var _this = this;
  7677. var keyMap = this.options.keyMap[env.isMac ? 'mac' : 'pc'];
  7678. return Object.keys(keyMap).map(function (key) {
  7679. var command = keyMap[key];
  7680. var $row = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div><div class="help-list-item"/></div>');
  7681. $row.append(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<label><kbd>' + key + '</kdb></label>').css({
  7682. 'width': 180,
  7683. 'margin-right': 10
  7684. })).append(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<span/>').html(_this.context.memo('help.' + command) || command));
  7685. return $row.html();
  7686. }).join('');
  7687. }
  7688. /**
  7689. * show help dialog
  7690. *
  7691. * @return {Promise}
  7692. */
  7693. }, {
  7694. key: "showHelpDialog",
  7695. value: function showHelpDialog() {
  7696. var _this2 = this;
  7697. return external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.Deferred(function (deferred) {
  7698. _this2.ui.onDialogShown(_this2.$dialog, function () {
  7699. _this2.context.triggerEvent('dialog.shown');
  7700. deferred.resolve();
  7701. });
  7702. _this2.ui.showDialog(_this2.$dialog);
  7703. }).promise();
  7704. }
  7705. }, {
  7706. key: "show",
  7707. value: function show() {
  7708. var _this3 = this;
  7709. this.context.invoke('editor.saveRange');
  7710. this.showHelpDialog().then(function () {
  7711. _this3.context.invoke('editor.restoreRange');
  7712. });
  7713. }
  7714. }]);
  7715. return HelpDialog;
  7716. }();
  7717. // CONCATENATED MODULE: ./src/js/base/module/AirPopover.js
  7718. function AirPopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7719. function AirPopover_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); } }
  7720. function AirPopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) AirPopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) AirPopover_defineProperties(Constructor, staticProps); return Constructor; }
  7721. var AIRMODE_POPOVER_X_OFFSET = -5;
  7722. var AIRMODE_POPOVER_Y_OFFSET = 5;
  7723. var AirPopover_AirPopover =
  7724. /*#__PURE__*/
  7725. function () {
  7726. function AirPopover(context) {
  7727. var _this = this;
  7728. AirPopover_classCallCheck(this, AirPopover);
  7729. this.context = context;
  7730. this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
  7731. this.options = context.options;
  7732. this.hidable = true;
  7733. this.onContextmenu = false;
  7734. this.pageX = null;
  7735. this.pageY = null;
  7736. this.events = {
  7737. 'summernote.contextmenu': function summernoteContextmenu(e) {
  7738. if (_this.options.editing) {
  7739. e.preventDefault();
  7740. e.stopPropagation();
  7741. _this.onContextmenu = true;
  7742. _this.update(true);
  7743. }
  7744. },
  7745. 'summernote.mousedown': function summernoteMousedown(we, e) {
  7746. _this.pageX = e.pageX;
  7747. _this.pageY = e.pageY;
  7748. },
  7749. 'summernote.keyup summernote.mouseup summernote.scroll': function summernoteKeyupSummernoteMouseupSummernoteScroll(we, e) {
  7750. if (_this.options.editing && !_this.onContextmenu) {
  7751. _this.pageX = e.pageX;
  7752. _this.pageY = e.pageY;
  7753. _this.update();
  7754. }
  7755. _this.onContextmenu = false;
  7756. },
  7757. 'summernote.disable summernote.change summernote.dialog.shown summernote.blur': function summernoteDisableSummernoteChangeSummernoteDialogShownSummernoteBlur() {
  7758. _this.hide();
  7759. },
  7760. 'summernote.focusout': function summernoteFocusout() {
  7761. if (!_this.$popover.is(':active,:focus')) {
  7762. _this.hide();
  7763. }
  7764. }
  7765. };
  7766. }
  7767. AirPopover_createClass(AirPopover, [{
  7768. key: "shouldInitialize",
  7769. value: function shouldInitialize() {
  7770. return this.options.airMode && !lists.isEmpty(this.options.popover.air);
  7771. }
  7772. }, {
  7773. key: "initialize",
  7774. value: function initialize() {
  7775. var _this2 = this;
  7776. this.$popover = this.ui.popover({
  7777. className: 'note-air-popover'
  7778. }).render().appendTo(this.options.container);
  7779. var $content = this.$popover.find('.popover-content');
  7780. this.context.invoke('buttons.build', $content, this.options.popover.air); // disable hiding this popover preemptively by 'summernote.blur' event.
  7781. this.$popover.on('mousedown', function () {
  7782. _this2.hidable = false;
  7783. }); // (re-)enable hiding after 'summernote.blur' has been handled (aka. ignored).
  7784. this.$popover.on('mouseup', function () {
  7785. _this2.hidable = true;
  7786. });
  7787. }
  7788. }, {
  7789. key: "destroy",
  7790. value: function destroy() {
  7791. this.$popover.remove();
  7792. }
  7793. }, {
  7794. key: "update",
  7795. value: function update(forcelyOpen) {
  7796. var styleInfo = this.context.invoke('editor.currentStyle');
  7797. if (styleInfo.range && (!styleInfo.range.isCollapsed() || forcelyOpen)) {
  7798. var rect = {
  7799. left: this.pageX,
  7800. top: this.pageY
  7801. };
  7802. var containerOffset = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.container).offset();
  7803. rect.top -= containerOffset.top;
  7804. rect.left -= containerOffset.left;
  7805. this.$popover.css({
  7806. display: 'block',
  7807. left: Math.max(rect.left, 0) + AIRMODE_POPOVER_X_OFFSET,
  7808. top: rect.top + AIRMODE_POPOVER_Y_OFFSET
  7809. });
  7810. this.context.invoke('buttons.updateCurrentStyle', this.$popover);
  7811. } else {
  7812. this.hide();
  7813. }
  7814. }
  7815. }, {
  7816. key: "hide",
  7817. value: function hide() {
  7818. if (this.hidable) {
  7819. this.$popover.hide();
  7820. }
  7821. }
  7822. }]);
  7823. return AirPopover;
  7824. }();
  7825. // CONCATENATED MODULE: ./src/js/base/module/HintPopover.js
  7826. function HintPopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7827. function HintPopover_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); } }
  7828. function HintPopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) HintPopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) HintPopover_defineProperties(Constructor, staticProps); return Constructor; }
  7829. var POPOVER_DIST = 5;
  7830. var HintPopover_HintPopover =
  7831. /*#__PURE__*/
  7832. function () {
  7833. function HintPopover(context) {
  7834. var _this = this;
  7835. HintPopover_classCallCheck(this, HintPopover);
  7836. this.context = context;
  7837. this.ui = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.ui;
  7838. this.$editable = context.layoutInfo.editable;
  7839. this.options = context.options;
  7840. this.hint = this.options.hint || [];
  7841. this.direction = this.options.hintDirection || 'bottom';
  7842. this.hints = Array.isArray(this.hint) ? this.hint : [this.hint];
  7843. this.events = {
  7844. 'summernote.keyup': function summernoteKeyup(we, e) {
  7845. if (!e.isDefaultPrevented()) {
  7846. _this.handleKeyup(e);
  7847. }
  7848. },
  7849. 'summernote.keydown': function summernoteKeydown(we, e) {
  7850. _this.handleKeydown(e);
  7851. },
  7852. 'summernote.disable summernote.dialog.shown summernote.blur': function summernoteDisableSummernoteDialogShownSummernoteBlur() {
  7853. _this.hide();
  7854. }
  7855. };
  7856. }
  7857. HintPopover_createClass(HintPopover, [{
  7858. key: "shouldInitialize",
  7859. value: function shouldInitialize() {
  7860. return this.hints.length > 0;
  7861. }
  7862. }, {
  7863. key: "initialize",
  7864. value: function initialize() {
  7865. var _this2 = this;
  7866. this.lastWordRange = null;
  7867. this.matchingWord = null;
  7868. this.$popover = this.ui.popover({
  7869. className: 'note-hint-popover',
  7870. hideArrow: true,
  7871. direction: ''
  7872. }).render().appendTo(this.options.container);
  7873. this.$popover.hide();
  7874. this.$content = this.$popover.find('.popover-content,.note-popover-content');
  7875. this.$content.on('click', '.note-hint-item', function (e) {
  7876. _this2.$content.find('.active').removeClass('active');
  7877. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(e.currentTarget).addClass('active');
  7878. _this2.replace();
  7879. });
  7880. this.$popover.on('mousedown', function (e) {
  7881. e.preventDefault();
  7882. });
  7883. }
  7884. }, {
  7885. key: "destroy",
  7886. value: function destroy() {
  7887. this.$popover.remove();
  7888. }
  7889. }, {
  7890. key: "selectItem",
  7891. value: function selectItem($item) {
  7892. this.$content.find('.active').removeClass('active');
  7893. $item.addClass('active');
  7894. this.$content[0].scrollTop = $item[0].offsetTop - this.$content.innerHeight() / 2;
  7895. }
  7896. }, {
  7897. key: "moveDown",
  7898. value: function moveDown() {
  7899. var $current = this.$content.find('.note-hint-item.active');
  7900. var $next = $current.next();
  7901. if ($next.length) {
  7902. this.selectItem($next);
  7903. } else {
  7904. var $nextGroup = $current.parent().next();
  7905. if (!$nextGroup.length) {
  7906. $nextGroup = this.$content.find('.note-hint-group').first();
  7907. }
  7908. this.selectItem($nextGroup.find('.note-hint-item').first());
  7909. }
  7910. }
  7911. }, {
  7912. key: "moveUp",
  7913. value: function moveUp() {
  7914. var $current = this.$content.find('.note-hint-item.active');
  7915. var $prev = $current.prev();
  7916. if ($prev.length) {
  7917. this.selectItem($prev);
  7918. } else {
  7919. var $prevGroup = $current.parent().prev();
  7920. if (!$prevGroup.length) {
  7921. $prevGroup = this.$content.find('.note-hint-group').last();
  7922. }
  7923. this.selectItem($prevGroup.find('.note-hint-item').last());
  7924. }
  7925. }
  7926. }, {
  7927. key: "replace",
  7928. value: function replace() {
  7929. var $item = this.$content.find('.note-hint-item.active');
  7930. if ($item.length) {
  7931. var node = this.nodeFromItem($item); // If matchingWord length = 0 -> capture OK / open hint / but as mention capture "" (\w*)
  7932. if (this.matchingWord !== null && this.matchingWord.length === 0) {
  7933. this.lastWordRange.so = this.lastWordRange.eo; // Else si > 0 and normal case -> adjust range "before" for correct position of insertion
  7934. } else if (this.matchingWord !== null && this.matchingWord.length > 0 && !this.lastWordRange.isCollapsed()) {
  7935. var rangeCompute = this.lastWordRange.eo - this.lastWordRange.so - this.matchingWord.length;
  7936. if (rangeCompute > 0) {
  7937. this.lastWordRange.so += rangeCompute;
  7938. }
  7939. }
  7940. this.lastWordRange.insertNode(node);
  7941. if (this.options.hintSelect === 'next') {
  7942. var blank = document.createTextNode('');
  7943. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(node).after(blank);
  7944. range.createFromNodeBefore(blank).select();
  7945. } else {
  7946. range.createFromNodeAfter(node).select();
  7947. }
  7948. this.lastWordRange = null;
  7949. this.hide();
  7950. this.context.invoke('editor.focus');
  7951. }
  7952. }
  7953. }, {
  7954. key: "nodeFromItem",
  7955. value: function nodeFromItem($item) {
  7956. var hint = this.hints[$item.data('index')];
  7957. var item = $item.data('item');
  7958. var node = hint.content ? hint.content(item) : item;
  7959. if (typeof node === 'string') {
  7960. node = dom.createText(node);
  7961. }
  7962. return node;
  7963. }
  7964. }, {
  7965. key: "createItemTemplates",
  7966. value: function createItemTemplates(hintIdx, items) {
  7967. var hint = this.hints[hintIdx];
  7968. return items.map(function (item
  7969. /*, idx */
  7970. ) {
  7971. var $item = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div class="note-hint-item"/>');
  7972. $item.append(hint.template ? hint.template(item) : item + '');
  7973. $item.data({
  7974. 'index': hintIdx,
  7975. 'item': item
  7976. });
  7977. return $item;
  7978. });
  7979. }
  7980. }, {
  7981. key: "handleKeydown",
  7982. value: function handleKeydown(e) {
  7983. if (!this.$popover.is(':visible')) {
  7984. return;
  7985. }
  7986. if (e.keyCode === core_key.code.ENTER) {
  7987. e.preventDefault();
  7988. this.replace();
  7989. } else if (e.keyCode === core_key.code.UP) {
  7990. e.preventDefault();
  7991. this.moveUp();
  7992. } else if (e.keyCode === core_key.code.DOWN) {
  7993. e.preventDefault();
  7994. this.moveDown();
  7995. }
  7996. }
  7997. }, {
  7998. key: "searchKeyword",
  7999. value: function searchKeyword(index, keyword, callback) {
  8000. var hint = this.hints[index];
  8001. if (hint && hint.match.test(keyword) && hint.search) {
  8002. var matches = hint.match.exec(keyword);
  8003. this.matchingWord = matches[0];
  8004. hint.search(matches[1], callback);
  8005. } else {
  8006. callback();
  8007. }
  8008. }
  8009. }, {
  8010. key: "createGroup",
  8011. value: function createGroup(idx, keyword) {
  8012. var _this3 = this;
  8013. var $group = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div class="note-hint-group note-hint-group-' + idx + '"/>');
  8014. this.searchKeyword(idx, keyword, function (items) {
  8015. items = items || [];
  8016. if (items.length) {
  8017. $group.html(_this3.createItemTemplates(idx, items));
  8018. _this3.show();
  8019. }
  8020. });
  8021. return $group;
  8022. }
  8023. }, {
  8024. key: "handleKeyup",
  8025. value: function handleKeyup(e) {
  8026. var _this4 = this;
  8027. if (!lists.contains([core_key.code.ENTER, core_key.code.UP, core_key.code.DOWN], e.keyCode)) {
  8028. var _range = this.context.invoke('editor.getLastRange');
  8029. var wordRange, keyword;
  8030. if (this.options.hintMode === 'words') {
  8031. wordRange = _range.getWordsRange(_range);
  8032. keyword = wordRange.toString();
  8033. this.hints.forEach(function (hint) {
  8034. if (hint.match.test(keyword)) {
  8035. wordRange = _range.getWordsMatchRange(hint.match);
  8036. return false;
  8037. }
  8038. });
  8039. if (!wordRange) {
  8040. this.hide();
  8041. return;
  8042. }
  8043. keyword = wordRange.toString();
  8044. } else {
  8045. wordRange = _range.getWordRange();
  8046. keyword = wordRange.toString();
  8047. }
  8048. if (this.hints.length && keyword) {
  8049. this.$content.empty();
  8050. var bnd = func.rect2bnd(lists.last(wordRange.getClientRects()));
  8051. var containerOffset = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.container).offset();
  8052. if (bnd) {
  8053. bnd.top -= containerOffset.top;
  8054. bnd.left -= containerOffset.left;
  8055. this.$popover.hide();
  8056. this.lastWordRange = wordRange;
  8057. this.hints.forEach(function (hint, idx) {
  8058. if (hint.match.test(keyword)) {
  8059. _this4.createGroup(idx, keyword).appendTo(_this4.$content);
  8060. }
  8061. }); // select first .note-hint-item
  8062. this.$content.find('.note-hint-item:first').addClass('active'); // set position for popover after group is created
  8063. if (this.direction === 'top') {
  8064. this.$popover.css({
  8065. left: bnd.left,
  8066. top: bnd.top - this.$popover.outerHeight() - POPOVER_DIST
  8067. });
  8068. } else {
  8069. this.$popover.css({
  8070. left: bnd.left,
  8071. top: bnd.top + bnd.height + POPOVER_DIST
  8072. });
  8073. }
  8074. }
  8075. } else {
  8076. this.hide();
  8077. }
  8078. }
  8079. }
  8080. }, {
  8081. key: "show",
  8082. value: function show() {
  8083. this.$popover.show();
  8084. }
  8085. }, {
  8086. key: "hide",
  8087. value: function hide() {
  8088. this.$popover.hide();
  8089. }
  8090. }]);
  8091. return HintPopover;
  8092. }();
  8093. // CONCATENATED MODULE: ./src/js/base/settings.js
  8094. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote, {
  8095. version: '0.8.16',
  8096. plugins: {},
  8097. dom: dom,
  8098. range: range,
  8099. lists: lists,
  8100. options: {
  8101. langInfo: external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.lang['en-US'],
  8102. editing: true,
  8103. modules: {
  8104. 'editor': Editor_Editor,
  8105. 'clipboard': Clipboard_Clipboard,
  8106. 'dropzone': Dropzone_Dropzone,
  8107. 'codeview': Codeview_CodeView,
  8108. 'statusbar': Statusbar_Statusbar,
  8109. 'fullscreen': Fullscreen_Fullscreen,
  8110. 'handle': Handle_Handle,
  8111. // FIXME: HintPopover must be front of autolink
  8112. // - Script error about range when Enter key is pressed on hint popover
  8113. 'hintPopover': HintPopover_HintPopover,
  8114. 'autoLink': AutoLink_AutoLink,
  8115. 'autoSync': AutoSync_AutoSync,
  8116. 'autoReplace': AutoReplace_AutoReplace,
  8117. 'placeholder': Placeholder_Placeholder,
  8118. 'buttons': Buttons_Buttons,
  8119. 'toolbar': Toolbar_Toolbar,
  8120. 'linkDialog': LinkDialog_LinkDialog,
  8121. 'linkPopover': LinkPopover_LinkPopover,
  8122. 'imageDialog': ImageDialog_ImageDialog,
  8123. 'imagePopover': ImagePopover_ImagePopover,
  8124. 'tablePopover': TablePopover_TablePopover,
  8125. 'videoDialog': VideoDialog_VideoDialog,
  8126. 'helpDialog': HelpDialog_HelpDialog,
  8127. 'airPopover': AirPopover_AirPopover
  8128. },
  8129. buttons: {},
  8130. lang: 'en-US',
  8131. followingToolbar: false,
  8132. toolbarPosition: 'top',
  8133. otherStaticBar: '',
  8134. // toolbar
  8135. toolbar: [['style', ['style']], ['font', ['bold', 'underline', 'clear']], ['fontname', ['fontname']], ['color', ['color']], ['para', ['ul', 'ol', 'paragraph']], ['table', ['table']], ['insert', ['link', 'picture', 'video']], ['view', ['fullscreen', 'codeview', 'help']]],
  8136. // popover
  8137. popatmouse: true,
  8138. popover: {
  8139. image: [['resize', ['resizeFull', 'resizeHalf', 'resizeQuarter', 'resizeNone']], ['float', ['floatLeft', 'floatRight', 'floatNone']], ['remove', ['removeMedia']]],
  8140. link: [['link', ['linkDialogShow', 'unlink']]],
  8141. table: [['add', ['addRowDown', 'addRowUp', 'addColLeft', 'addColRight']], ['delete', ['deleteRow', 'deleteCol', 'deleteTable']]],
  8142. air: [['color', ['color']], ['font', ['bold', 'underline', 'clear']], ['para', ['ul', 'paragraph']], ['table', ['table']], ['insert', ['link', 'picture']], ['view', ['fullscreen', 'codeview']]]
  8143. },
  8144. // air mode: inline editor
  8145. airMode: false,
  8146. overrideContextMenu: false,
  8147. // TBD
  8148. width: null,
  8149. height: null,
  8150. linkTargetBlank: true,
  8151. useProtocol: true,
  8152. defaultProtocol: 'http://',
  8153. focus: false,
  8154. tabDisabled: false,
  8155. tabSize: 4,
  8156. styleWithCSS: false,
  8157. shortcuts: true,
  8158. textareaAutoSync: true,
  8159. tooltip: 'auto',
  8160. container: null,
  8161. maxTextLength: 0,
  8162. blockquoteBreakingLevel: 2,
  8163. spellCheck: true,
  8164. disableGrammar: false,
  8165. placeholder: null,
  8166. inheritPlaceholder: false,
  8167. // TODO: need to be documented
  8168. recordEveryKeystroke: false,
  8169. historyLimit: 200,
  8170. // TODO: need to be documented
  8171. hintMode: 'word',
  8172. hintSelect: 'after',
  8173. hintDirection: 'bottom',
  8174. styleTags: ['p', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
  8175. fontNames: ['Arial', 'Arial Black', 'Comic Sans MS', 'Courier New', 'Helvetica Neue', 'Helvetica', 'Impact', 'Lucida Grande', 'Tahoma', 'Times New Roman', 'Verdana'],
  8176. fontNamesIgnoreCheck: [],
  8177. addDefaultFonts: true,
  8178. fontSizes: ['8', '9', '10', '11', '12', '14', '18', '24', '36'],
  8179. fontSizeUnits: ['px', 'pt'],
  8180. // pallete colors(n x n)
  8181. colors: [['#000000', '#424242', '#636363', '#9C9C94', '#CEC6CE', '#EFEFEF', '#F7F7F7', '#FFFFFF'], ['#FF0000', '#FF9C00', '#FFFF00', '#00FF00', '#00FFFF', '#0000FF', '#9C00FF', '#FF00FF'], ['#F7C6CE', '#FFE7CE', '#FFEFC6', '#D6EFD6', '#CEDEE7', '#CEE7F7', '#D6D6E7', '#E7D6DE'], ['#E79C9C', '#FFC69C', '#FFE79C', '#B5D6A5', '#A5C6CE', '#9CC6EF', '#B5A5D6', '#D6A5BD'], ['#E76363', '#F7AD6B', '#FFD663', '#94BD7B', '#73A5AD', '#6BADDE', '#8C7BC6', '#C67BA5'], ['#CE0000', '#E79439', '#EFC631', '#6BA54A', '#4A7B8C', '#3984C6', '#634AA5', '#A54A7B'], ['#9C0000', '#B56308', '#BD9400', '#397B21', '#104A5A', '#085294', '#311873', '#731842'], ['#630000', '#7B3900', '#846300', '#295218', '#083139', '#003163', '#21104A', '#4A1031']],
  8182. // http://chir.ag/projects/name-that-color/
  8183. colorsName: [['Black', 'Tundora', 'Dove Gray', 'Star Dust', 'Pale Slate', 'Gallery', 'Alabaster', 'White'], ['Red', 'Orange Peel', 'Yellow', 'Green', 'Cyan', 'Blue', 'Electric Violet', 'Magenta'], ['Azalea', 'Karry', 'Egg White', 'Zanah', 'Botticelli', 'Tropical Blue', 'Mischka', 'Twilight'], ['Tonys Pink', 'Peach Orange', 'Cream Brulee', 'Sprout', 'Casper', 'Perano', 'Cold Purple', 'Careys Pink'], ['Mandy', 'Rajah', 'Dandelion', 'Olivine', 'Gulf Stream', 'Viking', 'Blue Marguerite', 'Puce'], ['Guardsman Red', 'Fire Bush', 'Golden Dream', 'Chelsea Cucumber', 'Smalt Blue', 'Boston Blue', 'Butterfly Bush', 'Cadillac'], ['Sangria', 'Mai Tai', 'Buddha Gold', 'Forest Green', 'Eden', 'Venice Blue', 'Meteorite', 'Claret'], ['Rosewood', 'Cinnamon', 'Olive', 'Parsley', 'Tiber', 'Midnight Blue', 'Valentino', 'Loulou']],
  8184. colorButton: {
  8185. foreColor: '#000000',
  8186. backColor: '#FFFF00'
  8187. },
  8188. lineHeights: ['1.0', '1.2', '1.4', '1.5', '1.6', '1.8', '2.0', '3.0'],
  8189. tableClassName: 'table table-bordered',
  8190. insertTableMaxSize: {
  8191. col: 10,
  8192. row: 10
  8193. },
  8194. // By default, dialogs are attached in container.
  8195. dialogsInBody: false,
  8196. dialogsFade: false,
  8197. maximumImageFileSize: null,
  8198. callbacks: {
  8199. onBeforeCommand: null,
  8200. onBlur: null,
  8201. onBlurCodeview: null,
  8202. onChange: null,
  8203. onChangeCodeview: null,
  8204. onDialogShown: null,
  8205. onEnter: null,
  8206. onFocus: null,
  8207. onImageLinkInsert: null,
  8208. onImageUpload: null,
  8209. onImageUploadError: null,
  8210. onInit: null,
  8211. onKeydown: null,
  8212. onKeyup: null,
  8213. onMousedown: null,
  8214. onMouseup: null,
  8215. onPaste: null,
  8216. onScroll: null
  8217. },
  8218. codemirror: {
  8219. mode: 'text/html',
  8220. htmlMode: true,
  8221. lineNumbers: true
  8222. },
  8223. codeviewFilter: false,
  8224. codeviewFilterRegex: /<\/*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|ilayer|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|t(?:itle|extarea)|xml)[^>]*?>/gi,
  8225. codeviewIframeFilter: true,
  8226. codeviewIframeWhitelistSrc: [],
  8227. codeviewIframeWhitelistSrcBase: ['www.youtube.com', 'www.youtube-nocookie.com', 'www.facebook.com', 'vine.co', 'instagram.com', 'player.vimeo.com', 'www.dailymotion.com', 'player.youku.com', 'v.qq.com'],
  8228. keyMap: {
  8229. pc: {
  8230. 'ENTER': 'insertParagraph',
  8231. 'CTRL+Z': 'undo',
  8232. 'CTRL+Y': 'redo',
  8233. 'TAB': 'tab',
  8234. 'SHIFT+TAB': 'untab',
  8235. 'CTRL+B': 'bold',
  8236. 'CTRL+I': 'italic',
  8237. 'CTRL+U': 'underline',
  8238. 'CTRL+SHIFT+S': 'strikethrough',
  8239. 'CTRL+BACKSLASH': 'removeFormat',
  8240. 'CTRL+SHIFT+L': 'justifyLeft',
  8241. 'CTRL+SHIFT+E': 'justifyCenter',
  8242. 'CTRL+SHIFT+R': 'justifyRight',
  8243. 'CTRL+SHIFT+J': 'justifyFull',
  8244. 'CTRL+SHIFT+NUM7': 'insertUnorderedList',
  8245. 'CTRL+SHIFT+NUM8': 'insertOrderedList',
  8246. 'CTRL+LEFTBRACKET': 'outdent',
  8247. 'CTRL+RIGHTBRACKET': 'indent',
  8248. 'CTRL+NUM0': 'formatPara',
  8249. 'CTRL+NUM1': 'formatH1',
  8250. 'CTRL+NUM2': 'formatH2',
  8251. 'CTRL+NUM3': 'formatH3',
  8252. 'CTRL+NUM4': 'formatH4',
  8253. 'CTRL+NUM5': 'formatH5',
  8254. 'CTRL+NUM6': 'formatH6',
  8255. 'CTRL+ENTER': 'insertHorizontalRule',
  8256. 'CTRL+K': 'linkDialog.show'
  8257. },
  8258. mac: {
  8259. 'ENTER': 'insertParagraph',
  8260. 'CMD+Z': 'undo',
  8261. 'CMD+SHIFT+Z': 'redo',
  8262. 'TAB': 'tab',
  8263. 'SHIFT+TAB': 'untab',
  8264. 'CMD+B': 'bold',
  8265. 'CMD+I': 'italic',
  8266. 'CMD+U': 'underline',
  8267. 'CMD+SHIFT+S': 'strikethrough',
  8268. 'CMD+BACKSLASH': 'removeFormat',
  8269. 'CMD+SHIFT+L': 'justifyLeft',
  8270. 'CMD+SHIFT+E': 'justifyCenter',
  8271. 'CMD+SHIFT+R': 'justifyRight',
  8272. 'CMD+SHIFT+J': 'justifyFull',
  8273. 'CMD+SHIFT+NUM7': 'insertUnorderedList',
  8274. 'CMD+SHIFT+NUM8': 'insertOrderedList',
  8275. 'CMD+LEFTBRACKET': 'outdent',
  8276. 'CMD+RIGHTBRACKET': 'indent',
  8277. 'CMD+NUM0': 'formatPara',
  8278. 'CMD+NUM1': 'formatH1',
  8279. 'CMD+NUM2': 'formatH2',
  8280. 'CMD+NUM3': 'formatH3',
  8281. 'CMD+NUM4': 'formatH4',
  8282. 'CMD+NUM5': 'formatH5',
  8283. 'CMD+NUM6': 'formatH6',
  8284. 'CMD+ENTER': 'insertHorizontalRule',
  8285. 'CMD+K': 'linkDialog.show'
  8286. }
  8287. },
  8288. icons: {
  8289. 'align': 'note-icon-align',
  8290. 'alignCenter': 'note-icon-align-center',
  8291. 'alignJustify': 'note-icon-align-justify',
  8292. 'alignLeft': 'note-icon-align-left',
  8293. 'alignRight': 'note-icon-align-right',
  8294. 'rowBelow': 'note-icon-row-below',
  8295. 'colBefore': 'note-icon-col-before',
  8296. 'colAfter': 'note-icon-col-after',
  8297. 'rowAbove': 'note-icon-row-above',
  8298. 'rowRemove': 'note-icon-row-remove',
  8299. 'colRemove': 'note-icon-col-remove',
  8300. 'indent': 'note-icon-align-indent',
  8301. 'outdent': 'note-icon-align-outdent',
  8302. 'arrowsAlt': 'note-icon-arrows-alt',
  8303. 'bold': 'note-icon-bold',
  8304. 'caret': 'note-icon-caret',
  8305. 'circle': 'note-icon-circle',
  8306. 'close': 'note-icon-close',
  8307. 'code': 'note-icon-code',
  8308. 'eraser': 'note-icon-eraser',
  8309. 'floatLeft': 'note-icon-float-left',
  8310. 'floatRight': 'note-icon-float-right',
  8311. 'font': 'note-icon-font',
  8312. 'frame': 'note-icon-frame',
  8313. 'italic': 'note-icon-italic',
  8314. 'link': 'note-icon-link',
  8315. 'unlink': 'note-icon-chain-broken',
  8316. 'magic': 'note-icon-magic',
  8317. 'menuCheck': 'note-icon-menu-check',
  8318. 'minus': 'note-icon-minus',
  8319. 'orderedlist': 'note-icon-orderedlist',
  8320. 'pencil': 'note-icon-pencil',
  8321. 'picture': 'note-icon-picture',
  8322. 'question': 'note-icon-question',
  8323. 'redo': 'note-icon-redo',
  8324. 'rollback': 'note-icon-rollback',
  8325. 'square': 'note-icon-square',
  8326. 'strikethrough': 'note-icon-strikethrough',
  8327. 'subscript': 'note-icon-subscript',
  8328. 'superscript': 'note-icon-superscript',
  8329. 'table': 'note-icon-table',
  8330. 'textHeight': 'note-icon-text-height',
  8331. 'trash': 'note-icon-trash',
  8332. 'underline': 'note-icon-underline',
  8333. 'undo': 'note-icon-undo',
  8334. 'unorderedlist': 'note-icon-unorderedlist',
  8335. 'video': 'note-icon-video'
  8336. }
  8337. }
  8338. });
  8339. /***/ }),
  8340. /***/ 5:
  8341. /***/ (function(module, exports, __webpack_require__) {
  8342. // extracted by mini-css-extract-plugin
  8343. /***/ }),
  8344. /***/ 53:
  8345. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8346. "use strict";
  8347. __webpack_require__.r(__webpack_exports__);
  8348. // EXTERNAL MODULE: external {"root":"jQuery","commonjs2":"jquery","commonjs":"jquery","amd":"jquery"}
  8349. var external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_ = __webpack_require__(0);
  8350. var external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default = /*#__PURE__*/__webpack_require__.n(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_);
  8351. // EXTERNAL MODULE: ./src/js/base/renderer.js
  8352. var renderer = __webpack_require__(1);
  8353. // CONCATENATED MODULE: ./src/js/bs4/ui.js
  8354. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8355. var editor = renderer["a" /* default */].create('<div class="note-editor note-frame card"/>');
  8356. var toolbar = renderer["a" /* default */].create('<div class="note-toolbar card-header" role="toolbar"></div>');
  8357. var editingArea = renderer["a" /* default */].create('<div class="note-editing-area"/>');
  8358. var codable = renderer["a" /* default */].create('<textarea class="note-codable" aria-multiline="true"/>');
  8359. var editable = renderer["a" /* default */].create('<div class="note-editable card-block" contentEditable="true" role="textbox" aria-multiline="true"/>');
  8360. var statusbar = renderer["a" /* default */].create(['<output class="note-status-output" role="status" aria-live="polite"/>', '<div class="note-statusbar" role="status">', '<output class="note-status-output" aria-live="polite"></output>', '<div class="note-resizebar" aria-label="Resize">', '<div class="note-icon-bar"/>', '<div class="note-icon-bar"/>', '<div class="note-icon-bar"/>', '</div>', '</div>'].join(''));
  8361. var airEditor = renderer["a" /* default */].create('<div class="note-editor note-airframe"/>');
  8362. var airEditable = renderer["a" /* default */].create(['<div class="note-editable" contentEditable="true" role="textbox" aria-multiline="true"/>', '<output class="note-status-output" role="status" aria-live="polite"/>'].join(''));
  8363. var buttonGroup = renderer["a" /* default */].create('<div class="note-btn-group btn-group">');
  8364. var dropdown = renderer["a" /* default */].create('<div class="note-dropdown-menu dropdown-menu" role="list">', function ($node, options) {
  8365. var markup = Array.isArray(options.items) ? options.items.map(function (item) {
  8366. var value = typeof item === 'string' ? item : item.value || '';
  8367. var content = options.template ? options.template(item) : item;
  8368. var option = _typeof(item) === 'object' ? item.option : undefined;
  8369. var dataValue = 'data-value="' + value + '"';
  8370. var dataOption = option !== undefined ? ' data-option="' + option + '"' : '';
  8371. return '<a class="dropdown-item" href="#" ' + (dataValue + dataOption) + ' role="listitem" aria-label="' + value + '">' + content + '</a>';
  8372. }).join('') : options.items;
  8373. $node.html(markup).attr({
  8374. 'aria-label': options.title
  8375. });
  8376. });
  8377. var dropdownButtonContents = function dropdownButtonContents(contents) {
  8378. return contents;
  8379. };
  8380. var dropdownCheck = renderer["a" /* default */].create('<div class="note-dropdown-menu dropdown-menu note-check" role="list">', function ($node, options) {
  8381. var markup = Array.isArray(options.items) ? options.items.map(function (item) {
  8382. var value = typeof item === 'string' ? item : item.value || '';
  8383. var content = options.template ? options.template(item) : item;
  8384. return '<a class="dropdown-item" href="#" data-value="' + value + '" role="listitem" aria-label="' + item + '">' + icon(options.checkClassName) + ' ' + content + '</a>';
  8385. }).join('') : options.items;
  8386. $node.html(markup).attr({
  8387. 'aria-label': options.title
  8388. });
  8389. });
  8390. var dialog = renderer["a" /* default */].create('<div class="modal note-modal" aria-hidden="false" tabindex="-1" role="dialog"/>', function ($node, options) {
  8391. if (options.fade) {
  8392. $node.addClass('fade');
  8393. }
  8394. $node.attr({
  8395. 'aria-label': options.title
  8396. });
  8397. $node.html(['<div class="modal-dialog">', '<div class="modal-content">', options.title ? '<div class="modal-header">' + '<h4 class="modal-title">' + options.title + '</h4>' + '<button type="button" class="close" data-dismiss="modal" aria-label="Close" aria-hidden="true">&times;</button>' + '</div>' : '', '<div class="modal-body">' + options.body + '</div>', options.footer ? '<div class="modal-footer">' + options.footer + '</div>' : '', '</div>', '</div>'].join(''));
  8398. });
  8399. var popover = renderer["a" /* default */].create(['<div class="note-popover popover in">', '<div class="arrow"/>', '<div class="popover-content note-children-container"/>', '</div>'].join(''), function ($node, options) {
  8400. var direction = typeof options.direction !== 'undefined' ? options.direction : 'bottom';
  8401. $node.addClass(direction);
  8402. if (options.hideArrow) {
  8403. $node.find('.arrow').hide();
  8404. }
  8405. });
  8406. var ui_checkbox = renderer["a" /* default */].create('<div class="form-check"></div>', function ($node, options) {
  8407. $node.html(['<label class="form-check-label"' + (options.id ? ' for="note-' + options.id + '"' : '') + '>', '<input type="checkbox" class="form-check-input"' + (options.id ? ' id="note-' + options.id + '"' : ''), options.checked ? ' checked' : '', ' aria-label="' + (options.text ? options.text : '') + '"', ' aria-checked="' + (options.checked ? 'true' : 'false') + '"/>', ' ' + (options.text ? options.text : '') + '</label>'].join(''));
  8408. });
  8409. var icon = function icon(iconClassName, tagName) {
  8410. tagName = tagName || 'i';
  8411. return '<' + tagName + ' class="' + iconClassName + '"/>';
  8412. };
  8413. var ui_ui = function ui(editorOptions) {
  8414. return {
  8415. editor: editor,
  8416. toolbar: toolbar,
  8417. editingArea: editingArea,
  8418. codable: codable,
  8419. editable: editable,
  8420. statusbar: statusbar,
  8421. airEditor: airEditor,
  8422. airEditable: airEditable,
  8423. buttonGroup: buttonGroup,
  8424. dropdown: dropdown,
  8425. dropdownButtonContents: dropdownButtonContents,
  8426. dropdownCheck: dropdownCheck,
  8427. dialog: dialog,
  8428. popover: popover,
  8429. icon: icon,
  8430. checkbox: ui_checkbox,
  8431. options: editorOptions,
  8432. palette: function palette($node, options) {
  8433. return renderer["a" /* default */].create('<div class="note-color-palette"/>', function ($node, options) {
  8434. var contents = [];
  8435. for (var row = 0, rowSize = options.colors.length; row < rowSize; row++) {
  8436. var eventName = options.eventName;
  8437. var colors = options.colors[row];
  8438. var colorsName = options.colorsName[row];
  8439. var buttons = [];
  8440. for (var col = 0, colSize = colors.length; col < colSize; col++) {
  8441. var color = colors[col];
  8442. var colorName = colorsName[col];
  8443. buttons.push(['<button type="button" class="note-color-btn"', 'style="background-color:', color, '" ', 'data-event="', eventName, '" ', 'data-value="', color, '" ', 'title="', colorName, '" ', 'aria-label="', colorName, '" ', 'data-toggle="button" tabindex="-1"></button>'].join(''));
  8444. }
  8445. contents.push('<div class="note-color-row">' + buttons.join('') + '</div>');
  8446. }
  8447. $node.html(contents.join(''));
  8448. if (options.tooltip) {
  8449. $node.find('.note-color-btn').tooltip({
  8450. container: options.container || editorOptions.container,
  8451. trigger: 'hover',
  8452. placement: 'bottom'
  8453. });
  8454. }
  8455. })($node, options);
  8456. },
  8457. button: function button($node, options) {
  8458. return renderer["a" /* default */].create('<button type="button" class="note-btn btn btn-light btn-sm" tabindex="-1">', function ($node, options) {
  8459. if (options && options.tooltip) {
  8460. $node.attr({
  8461. title: options.tooltip,
  8462. 'aria-label': options.tooltip
  8463. }).tooltip({
  8464. container: options.container || editorOptions.container,
  8465. trigger: 'hover',
  8466. placement: 'bottom'
  8467. }).on('click', function (e) {
  8468. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(e.currentTarget).tooltip('hide');
  8469. });
  8470. }
  8471. })($node, options);
  8472. },
  8473. toggleBtn: function toggleBtn($btn, isEnable) {
  8474. $btn.toggleClass('disabled', !isEnable);
  8475. $btn.attr('disabled', !isEnable);
  8476. },
  8477. toggleBtnActive: function toggleBtnActive($btn, isActive) {
  8478. $btn.toggleClass('active', isActive);
  8479. },
  8480. onDialogShown: function onDialogShown($dialog, handler) {
  8481. $dialog.one('shown.bs.modal', handler);
  8482. },
  8483. onDialogHidden: function onDialogHidden($dialog, handler) {
  8484. $dialog.one('hidden.bs.modal', handler);
  8485. },
  8486. showDialog: function showDialog($dialog) {
  8487. $dialog.modal('show');
  8488. },
  8489. hideDialog: function hideDialog($dialog) {
  8490. $dialog.modal('hide');
  8491. },
  8492. createLayout: function createLayout($note) {
  8493. var $editor = (editorOptions.airMode ? airEditor([editingArea([codable(), airEditable()])]) : editorOptions.toolbarPosition === 'bottom' ? editor([editingArea([codable(), editable()]), toolbar(), statusbar()]) : editor([toolbar(), editingArea([codable(), editable()]), statusbar()])).render();
  8494. $editor.insertAfter($note);
  8495. return {
  8496. note: $note,
  8497. editor: $editor,
  8498. toolbar: $editor.find('.note-toolbar'),
  8499. editingArea: $editor.find('.note-editing-area'),
  8500. editable: $editor.find('.note-editable'),
  8501. codable: $editor.find('.note-codable'),
  8502. statusbar: $editor.find('.note-statusbar')
  8503. };
  8504. },
  8505. removeLayout: function removeLayout($note, layoutInfo) {
  8506. $note.html(layoutInfo.editable.html());
  8507. layoutInfo.editor.remove();
  8508. $note.show();
  8509. }
  8510. };
  8511. };
  8512. /* harmony default export */ var bs4_ui = (ui_ui);
  8513. // EXTERNAL MODULE: ./src/js/base/settings.js + 37 modules
  8514. var settings = __webpack_require__(3);
  8515. // EXTERNAL MODULE: ./src/styles/summernote-bs4.scss
  8516. var summernote_bs4 = __webpack_require__(5);
  8517. // CONCATENATED MODULE: ./src/js/bs4/settings.js
  8518. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote, {
  8519. ui_template: bs4_ui,
  8520. "interface": 'bs4'
  8521. });
  8522. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.summernote.options.styleTags = ['p', {
  8523. title: 'Blockquote',
  8524. tag: 'blockquote',
  8525. className: 'blockquote',
  8526. value: 'blockquote'
  8527. }, 'pre', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
  8528. /***/ })
  8529. /******/ });
  8530. });
  8531. //# sourceMappingURL=summernote-bs4.js.map