summernote-bs4.js 266 KB

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