Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

summernote.js 512KB

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