1
0

summernote-lite.js 285 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617
  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 = 50);
  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. /***/ 50:
  7469. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7470. "use strict";
  7471. __webpack_require__.r(__webpack_exports__);
  7472. // EXTERNAL MODULE: external {"root":"jQuery","commonjs2":"jquery","commonjs":"jquery","amd":"jquery"}
  7473. var external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_ = __webpack_require__(0);
  7474. var external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default = /*#__PURE__*/__webpack_require__.n(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_);
  7475. // EXTERNAL MODULE: ./src/js/base/renderer.js
  7476. var renderer = __webpack_require__(1);
  7477. // CONCATENATED MODULE: ./src/js/lite/ui/TooltipUI.js
  7478. class TooltipUI_TooltipUI {
  7479. constructor($node, options) {
  7480. this.$node = $node;
  7481. this.options = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend({}, {
  7482. title: '',
  7483. target: options.container,
  7484. trigger: 'hover focus',
  7485. placement: 'bottom'
  7486. }, options); // create tooltip node
  7487. this.$tooltip = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(['<div class="note-tooltip">', '<div class="note-tooltip-arrow"/>', '<div class="note-tooltip-content"/>', '</div>'].join('')); // define event
  7488. if (this.options.trigger !== 'manual') {
  7489. const showCallback = this.show.bind(this);
  7490. const hideCallback = this.hide.bind(this);
  7491. const toggleCallback = this.toggle.bind(this);
  7492. this.options.trigger.split(' ').forEach(function (eventName) {
  7493. if (eventName === 'hover') {
  7494. $node.off('mouseenter mouseleave');
  7495. $node.on('mouseenter', showCallback).on('mouseleave', hideCallback);
  7496. } else if (eventName === 'click') {
  7497. $node.on('click', toggleCallback);
  7498. } else if (eventName === 'focus') {
  7499. $node.on('focus', showCallback).on('blur', hideCallback);
  7500. }
  7501. });
  7502. }
  7503. }
  7504. show() {
  7505. const $node = this.$node;
  7506. const offset = $node.offset();
  7507. const targetOffset = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.target).offset();
  7508. offset.top -= targetOffset.top;
  7509. offset.left -= targetOffset.left;
  7510. const $tooltip = this.$tooltip;
  7511. const title = this.options.title || $node.attr('title') || $node.data('title');
  7512. const placement = this.options.placement || $node.data('placement');
  7513. $tooltip.addClass(placement);
  7514. $tooltip.find('.note-tooltip-content').text(title);
  7515. $tooltip.appendTo(this.options.target);
  7516. const nodeWidth = $node.outerWidth();
  7517. const nodeHeight = $node.outerHeight();
  7518. const tooltipWidth = $tooltip.outerWidth();
  7519. const tooltipHeight = $tooltip.outerHeight();
  7520. if (placement === 'bottom') {
  7521. $tooltip.css({
  7522. top: offset.top + nodeHeight,
  7523. left: offset.left + (nodeWidth / 2 - tooltipWidth / 2)
  7524. });
  7525. } else if (placement === 'top') {
  7526. $tooltip.css({
  7527. top: offset.top - tooltipHeight,
  7528. left: offset.left + (nodeWidth / 2 - tooltipWidth / 2)
  7529. });
  7530. } else if (placement === 'left') {
  7531. $tooltip.css({
  7532. top: offset.top + (nodeHeight / 2 - tooltipHeight / 2),
  7533. left: offset.left - tooltipWidth
  7534. });
  7535. } else if (placement === 'right') {
  7536. $tooltip.css({
  7537. top: offset.top + (nodeHeight / 2 - tooltipHeight / 2),
  7538. left: offset.left + nodeWidth
  7539. });
  7540. }
  7541. $tooltip.addClass('in');
  7542. }
  7543. hide() {
  7544. this.$tooltip.removeClass('in');
  7545. setTimeout(() => {
  7546. this.$tooltip.remove();
  7547. }, 200);
  7548. }
  7549. toggle() {
  7550. if (this.$tooltip.hasClass('in')) {
  7551. this.hide();
  7552. } else {
  7553. this.show();
  7554. }
  7555. }
  7556. }
  7557. /* harmony default export */ var ui_TooltipUI = (TooltipUI_TooltipUI);
  7558. // CONCATENATED MODULE: ./src/js/lite/ui/DropdownUI.js
  7559. class DropdownUI_DropdownUI {
  7560. constructor($node, options) {
  7561. this.$button = $node;
  7562. this.options = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default.a.extend({}, {
  7563. target: options.container
  7564. }, options);
  7565. this.setEvent();
  7566. }
  7567. setEvent() {
  7568. this.$button.on('click', e => {
  7569. this.toggle();
  7570. e.stopImmediatePropagation();
  7571. });
  7572. }
  7573. clear() {
  7574. var $parent = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('.note-btn-group.open');
  7575. $parent.find('.note-btn.active').removeClass('active');
  7576. $parent.removeClass('open');
  7577. }
  7578. show() {
  7579. this.$button.addClass('active');
  7580. this.$button.parent().addClass('open');
  7581. var $dropdown = this.$button.next();
  7582. var offset = $dropdown.offset();
  7583. var width = $dropdown.outerWidth();
  7584. var windowWidth = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(window).width();
  7585. var targetMarginRight = parseFloat(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this.options.target).css('margin-right'));
  7586. if (offset.left + width > windowWidth - targetMarginRight) {
  7587. $dropdown.css('margin-left', windowWidth - targetMarginRight - (offset.left + width));
  7588. } else {
  7589. $dropdown.css('margin-left', '');
  7590. }
  7591. }
  7592. hide() {
  7593. this.$button.removeClass('active');
  7594. this.$button.parent().removeClass('open');
  7595. }
  7596. toggle() {
  7597. var isOpened = this.$button.parent().hasClass('open');
  7598. this.clear();
  7599. if (isOpened) {
  7600. this.hide();
  7601. } else {
  7602. this.show();
  7603. }
  7604. }
  7605. }
  7606. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document).on('click', function (e) {
  7607. if (!external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(e.target).closest('.note-btn-group').length) {
  7608. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('.note-btn-group.open').removeClass('open');
  7609. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('.note-btn-group .note-btn.active').removeClass('active');
  7610. }
  7611. });
  7612. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(document).on('click.note-dropdown-menu', function (e) {
  7613. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(e.target).closest('.note-dropdown-menu').parent().removeClass('open');
  7614. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(e.target).closest('.note-dropdown-menu').parent().find('.note-btn.active').removeClass('active');
  7615. });
  7616. /* harmony default export */ var ui_DropdownUI = (DropdownUI_DropdownUI);
  7617. // CONCATENATED MODULE: ./src/js/lite/ui/ModalUI.js
  7618. class ModalUI_ModalUI {
  7619. constructor($node, options) {
  7620. this.$modal = $node;
  7621. this.$backdrop = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<div class="note-modal-backdrop"/>');
  7622. }
  7623. show() {
  7624. this.$backdrop.appendTo(document.body).show();
  7625. this.$modal.addClass('open').show();
  7626. this.$modal.trigger('note.modal.show');
  7627. this.$modal.off('click', '.close').on('click', '.close', this.hide.bind(this));
  7628. this.$modal.on('keydown', event => {
  7629. if (event.which === 27) {
  7630. event.preventDefault();
  7631. this.hide();
  7632. }
  7633. });
  7634. }
  7635. hide() {
  7636. this.$modal.removeClass('open').hide();
  7637. this.$backdrop.hide();
  7638. this.$modal.trigger('note.modal.hide');
  7639. this.$modal.off('keydown');
  7640. }
  7641. }
  7642. /* harmony default export */ var ui_ModalUI = (ModalUI_ModalUI);
  7643. // CONCATENATED MODULE: ./src/js/lite/ui.js
  7644. const editor = renderer["a" /* default */].create('<div class="note-editor note-frame"/>');
  7645. const toolbar = renderer["a" /* default */].create('<div class="note-toolbar" role="toolbar"/>');
  7646. const editingArea = renderer["a" /* default */].create('<div class="note-editing-area"/>');
  7647. const codable = renderer["a" /* default */].create('<textarea class="note-codable" aria-multiline="true"/>');
  7648. const editable = renderer["a" /* default */].create('<div class="note-editable" contentEditable="true" role="textbox" aria-multiline="true"/>');
  7649. const statusbar = renderer["a" /* default */].create(['<output class="note-status-output" role="status" aria-live="polite"/>', '<div class="note-statusbar" role="status">', '<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(''));
  7650. const airEditor = renderer["a" /* default */].create('<div class="note-editor note-airframe"/>');
  7651. 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(''));
  7652. const buttonGroup = renderer["a" /* default */].create('<div class="note-btn-group">');
  7653. const ui_button = renderer["a" /* default */].create('<button type="button" class="note-btn" tabindex="-1">', function ($node, options) {
  7654. // set button type
  7655. if (options && options.tooltip) {
  7656. $node.attr({
  7657. 'aria-label': options.tooltip
  7658. });
  7659. $node.data('_lite_tooltip', new ui_TooltipUI($node, {
  7660. title: options.tooltip,
  7661. container: options.container
  7662. })).on('click', e => {
  7663. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(e.currentTarget).data('_lite_tooltip').hide();
  7664. });
  7665. }
  7666. if (options.contents) {
  7667. $node.html(options.contents);
  7668. }
  7669. if (options && options.data && options.data.toggle === 'dropdown') {
  7670. $node.data('_lite_dropdown', new ui_DropdownUI($node, {
  7671. container: options.container
  7672. }));
  7673. }
  7674. });
  7675. const dropdown = renderer["a" /* default */].create('<div class="note-dropdown-menu" role="list">', function ($node, options) {
  7676. const markup = Array.isArray(options.items) ? options.items.map(function (item) {
  7677. const value = typeof item === 'string' ? item : item.value || '';
  7678. const content = options.template ? options.template(item) : item;
  7679. const $temp = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<a class="note-dropdown-item" href="#" data-value="' + value + '" role="listitem" aria-label="' + value + '"></a>');
  7680. $temp.html(content).data('item', item);
  7681. return $temp;
  7682. }) : options.items;
  7683. $node.html(markup).attr({
  7684. 'aria-label': options.title
  7685. });
  7686. $node.on('click', '> .note-dropdown-item', function (e) {
  7687. const $a = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this);
  7688. const item = $a.data('item');
  7689. const value = $a.data('value');
  7690. if (item.click) {
  7691. item.click($a);
  7692. } else if (options.itemClick) {
  7693. options.itemClick(e, item, value);
  7694. }
  7695. });
  7696. });
  7697. const dropdownCheck = renderer["a" /* default */].create('<div class="note-dropdown-menu note-check" role="list">', function ($node, options) {
  7698. const markup = Array.isArray(options.items) ? options.items.map(function (item) {
  7699. const value = typeof item === 'string' ? item : item.value || '';
  7700. const content = options.template ? options.template(item) : item;
  7701. const $temp = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()('<a class="note-dropdown-item" href="#" data-value="' + value + '" role="listitem" aria-label="' + item + '"></a>');
  7702. $temp.html([icon(options.checkClassName), ' ', content]).data('item', item);
  7703. return $temp;
  7704. }) : options.items;
  7705. $node.html(markup).attr({
  7706. 'aria-label': options.title
  7707. });
  7708. $node.on('click', '> .note-dropdown-item', function (e) {
  7709. const $a = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this);
  7710. const item = $a.data('item');
  7711. const value = $a.data('value');
  7712. if (item.click) {
  7713. item.click($a);
  7714. } else if (options.itemClick) {
  7715. options.itemClick(e, item, value);
  7716. }
  7717. });
  7718. });
  7719. const dropdownButtonContents = function (contents, options) {
  7720. return contents + ' ' + icon(options.icons.caret, 'span');
  7721. };
  7722. const dropdownButton = function (opt, callback) {
  7723. return buttonGroup([ui_button({
  7724. className: 'dropdown-toggle',
  7725. contents: opt.title + ' ' + icon('note-icon-caret'),
  7726. tooltip: opt.tooltip,
  7727. data: {
  7728. toggle: 'dropdown'
  7729. }
  7730. }), dropdown({
  7731. className: opt.className,
  7732. items: opt.items,
  7733. template: opt.template,
  7734. itemClick: opt.itemClick
  7735. })], {
  7736. callback: callback
  7737. }).render();
  7738. };
  7739. const dropdownCheckButton = function (opt, callback) {
  7740. return buttonGroup([ui_button({
  7741. className: 'dropdown-toggle',
  7742. contents: opt.title + ' ' + icon('note-icon-caret'),
  7743. tooltip: opt.tooltip,
  7744. data: {
  7745. toggle: 'dropdown'
  7746. }
  7747. }), dropdownCheck({
  7748. className: opt.className,
  7749. checkClassName: opt.checkClassName,
  7750. items: opt.items,
  7751. template: opt.template,
  7752. itemClick: opt.itemClick
  7753. })], {
  7754. callback: callback
  7755. }).render();
  7756. };
  7757. const paragraphDropdownButton = function (opt) {
  7758. return buttonGroup([ui_button({
  7759. className: 'dropdown-toggle',
  7760. contents: opt.title + ' ' + icon('note-icon-caret'),
  7761. tooltip: opt.tooltip,
  7762. data: {
  7763. toggle: 'dropdown'
  7764. }
  7765. }), dropdown([buttonGroup({
  7766. className: 'note-align',
  7767. children: opt.items[0]
  7768. }), buttonGroup({
  7769. className: 'note-list',
  7770. children: opt.items[1]
  7771. })])]).render();
  7772. };
  7773. const tableMoveHandler = function (event, col, row) {
  7774. const PX_PER_EM = 18;
  7775. const $picker = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(event.target.parentNode); // target is mousecatcher
  7776. const $dimensionDisplay = $picker.next();
  7777. const $catcher = $picker.find('.note-dimension-picker-mousecatcher');
  7778. const $highlighted = $picker.find('.note-dimension-picker-highlighted');
  7779. const $unhighlighted = $picker.find('.note-dimension-picker-unhighlighted');
  7780. let posOffset; // HTML5 with jQuery - e.offsetX is undefined in Firefox
  7781. if (event.offsetX === undefined) {
  7782. const posCatcher = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(event.target).offset();
  7783. posOffset = {
  7784. x: event.pageX - posCatcher.left,
  7785. y: event.pageY - posCatcher.top
  7786. };
  7787. } else {
  7788. posOffset = {
  7789. x: event.offsetX,
  7790. y: event.offsetY
  7791. };
  7792. }
  7793. const dim = {
  7794. c: Math.ceil(posOffset.x / PX_PER_EM) || 1,
  7795. r: Math.ceil(posOffset.y / PX_PER_EM) || 1
  7796. };
  7797. $highlighted.css({
  7798. width: dim.c + 'em',
  7799. height: dim.r + 'em'
  7800. });
  7801. $catcher.data('value', dim.c + 'x' + dim.r);
  7802. if (dim.c > 3 && dim.c < col) {
  7803. $unhighlighted.css({
  7804. width: dim.c + 1 + 'em'
  7805. });
  7806. }
  7807. if (dim.r > 3 && dim.r < row) {
  7808. $unhighlighted.css({
  7809. height: dim.r + 1 + 'em'
  7810. });
  7811. }
  7812. $dimensionDisplay.html(dim.c + ' x ' + dim.r);
  7813. };
  7814. const tableDropdownButton = function (opt) {
  7815. return buttonGroup([ui_button({
  7816. className: 'dropdown-toggle',
  7817. contents: opt.title + ' ' + icon('note-icon-caret'),
  7818. tooltip: opt.tooltip,
  7819. data: {
  7820. toggle: 'dropdown'
  7821. }
  7822. }), dropdown({
  7823. className: 'note-table',
  7824. 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('')
  7825. })], {
  7826. callback: function ($node) {
  7827. const $catcher = $node.find('.note-dimension-picker-mousecatcher');
  7828. $catcher.css({
  7829. width: opt.col + 'em',
  7830. height: opt.row + 'em'
  7831. }).mousedown(opt.itemClick).mousemove(function (e) {
  7832. tableMoveHandler(e, opt.col, opt.row);
  7833. });
  7834. }
  7835. }).render();
  7836. };
  7837. const palette = renderer["a" /* default */].create('<div class="note-color-palette"/>', function ($node, options) {
  7838. const contents = [];
  7839. for (let row = 0, rowSize = options.colors.length; row < rowSize; row++) {
  7840. const eventName = options.eventName;
  7841. const colors = options.colors[row];
  7842. const colorsName = options.colorsName[row];
  7843. const buttons = [];
  7844. for (let col = 0, colSize = colors.length; col < colSize; col++) {
  7845. const color = colors[col];
  7846. const colorName = colorsName[col];
  7847. buttons.push(['<button type="button" class="note-btn note-color-btn"', 'style="background-color:', color, '" ', 'data-event="', eventName, '" ', 'data-value="', color, '" ', 'data-title="', colorName, '" ', 'aria-label="', colorName, '" ', 'data-toggle="button" tabindex="-1"></button>'].join(''));
  7848. }
  7849. contents.push('<div class="note-color-row">' + buttons.join('') + '</div>');
  7850. }
  7851. $node.html(contents.join(''));
  7852. $node.find('.note-color-btn').each(function () {
  7853. external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this).data('_lite_tooltip', new ui_TooltipUI(external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this), {
  7854. container: options.container
  7855. }));
  7856. });
  7857. });
  7858. const colorDropdownButton = function (opt, type) {
  7859. return buttonGroup({
  7860. className: 'note-color',
  7861. children: [ui_button({
  7862. className: 'note-current-color-button',
  7863. contents: opt.title,
  7864. tooltip: opt.lang.color.recent,
  7865. click: opt.currentClick,
  7866. callback: function ($button) {
  7867. const $recentColor = $button.find('.note-recent-color');
  7868. if (type !== 'foreColor') {
  7869. $recentColor.css('background-color', '#FFFF00');
  7870. $button.attr('data-backColor', '#FFFF00');
  7871. }
  7872. }
  7873. }), ui_button({
  7874. className: 'dropdown-toggle',
  7875. contents: icon('note-icon-caret'),
  7876. tooltip: opt.lang.color.more,
  7877. data: {
  7878. toggle: 'dropdown'
  7879. }
  7880. }), dropdown({
  7881. items: ['<div>', '<div class="note-btn-group btn-background-color">', '<div class="note-palette-title">' + opt.lang.color.background + '</div>', '<div>', '<button type="button" class="note-color-reset note-btn note-btn-block" data-event="backColor" data-value="inherit">', opt.lang.color.transparent, '</button>', '</div>', '<div class="note-holder" data-event="backColor"/>', '<div class="btn-sm">', '<input type="color" id="html5bcp" class="note-btn btn-default" value="#21104A" style="width:100%;" data-value="cp">', '<button type="button" class="note-color-reset btn" data-event="backColor" data-value="cpbackColor">', opt.lang.color.cpSelect, '</button>', '</div>', '</div>', '<div class="note-btn-group btn-foreground-color">', '<div class="note-palette-title">' + opt.lang.color.foreground + '</div>', '<div>', '<button type="button" class="note-color-reset note-btn note-btn-block" data-event="removeFormat" data-value="foreColor">', opt.lang.color.resetToDefault, '</button>', '</div>', '<div class="note-holder" data-event="foreColor"/>', '<div class="btn-sm">', '<input type="color" id="html5fcp" class="note-btn btn-default" value="#21104A" style="width:100%;" data-value="cp">', '<button type="button" class="note-color-reset btn" data-event="foreColor" data-value="cpforeColor">', opt.lang.color.cpSelect, '</button>', '</div>', '</div>', '</div>'].join(''),
  7882. callback: function ($dropdown) {
  7883. $dropdown.find('.note-holder').each(function () {
  7884. const $holder = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(this);
  7885. $holder.append(palette({
  7886. colors: opt.colors,
  7887. eventName: $holder.data('event')
  7888. }).render());
  7889. });
  7890. if (type === 'fore') {
  7891. $dropdown.find('.btn-background-color').hide();
  7892. $dropdown.css({
  7893. 'min-width': '210px'
  7894. });
  7895. } else if (type === 'back') {
  7896. $dropdown.find('.btn-foreground-color').hide();
  7897. $dropdown.css({
  7898. 'min-width': '210px'
  7899. });
  7900. }
  7901. },
  7902. click: function (event) {
  7903. const $button = external_root_jQuery_commonjs2_jquery_commonjs_jquery_amd_jquery_default()(event.target);
  7904. const eventName = $button.data('event');
  7905. let value = $button.data('value');
  7906. const foreinput = document.getElementById('html5fcp').value;
  7907. const backinput = document.getElementById('html5bcp').value;
  7908. if (value === 'cp') {
  7909. event.stopPropagation();
  7910. } else if (value === 'cpbackColor') {
  7911. value = backinput;
  7912. } else if (value === 'cpforeColor') {
  7913. value = foreinput;
  7914. }
  7915. if (eventName && value) {
  7916. const key = eventName === 'backColor' ? 'background-color' : 'color';
  7917. const $color = $button.closest('.note-color').find('.note-recent-color');
  7918. const $currentButton = $button.closest('.note-color').find('.note-current-color-button');
  7919. $color.css(key, value);
  7920. $currentButton.attr('data-' + eventName, value);
  7921. if (type === 'fore') {
  7922. opt.itemClick('foreColor', value);
  7923. } else if (type === 'back') {
  7924. opt.itemClick('backColor', value);
  7925. } else {
  7926. opt.itemClick(eventName, value);
  7927. }
  7928. }
  7929. }
  7930. })]
  7931. }).render();
  7932. };
  7933. const dialog = renderer["a" /* default */].create('<div class="note-modal" aria-hidden="false" tabindex="-1" role="dialog"/>', function ($node, options) {
  7934. if (options.fade) {
  7935. $node.addClass('fade');
  7936. }
  7937. $node.attr({
  7938. 'aria-label': options.title
  7939. });
  7940. $node.html(['<div class="note-modal-content">', options.title ? '<div class="note-modal-header"><button type="button" class="close" aria-label="Close" aria-hidden="true"><i class="note-icon-close"></i></button><h4 class="note-modal-title">' + options.title + '</h4></div>' : '', '<div class="note-modal-body">' + options.body + '</div>', options.footer ? '<div class="note-modal-footer">' + options.footer + '</div>' : '', '</div>'].join(''));
  7941. $node.data('modal', new ui_ModalUI($node, options));
  7942. });
  7943. const videoDialog = function (opt) {
  7944. const body = '<div class="note-form-group">' + '<label for="note-dialog-video-url-' + opt.id + '" class="note-form-label">' + opt.lang.video.url + ' <small class="text-muted">' + opt.lang.video.providers + '</small></label>' + '<input id="note-dialog-video-url-' + opt.id + '" class="note-video-url note-input" type="text"/>' + '</div>';
  7945. const footer = ['<button type="button" href="#" class="note-btn note-btn-primary note-video-btn disabled" disabled>', opt.lang.video.insert, '</button>'].join('');
  7946. return dialog({
  7947. title: opt.lang.video.insert,
  7948. fade: opt.fade,
  7949. body: body,
  7950. footer: footer
  7951. }).render();
  7952. };
  7953. const imageDialog = function (opt) {
  7954. const body = '<div class="note-form-group note-group-select-from-files">' + '<label for="note-dialog-image-file-' + opt.id + '" class="note-form-label">' + opt.lang.image.selectFromFiles + '</label>' + '<input id="note-dialog-image-file-' + opt.id + '" class="note-note-image-input note-input" type="file" name="files" accept="image/*" multiple="multiple"/>' + opt.imageLimitation + '</div>' + '<div class="note-form-group">' + '<label for="note-dialog-image-url-' + opt.id + '" class="note-form-label">' + opt.lang.image.url + '</label>' + '<input id="note-dialog-image-url-' + opt.id + '" class="note-image-url note-input" type="text"/>' + '</div>';
  7955. const footer = ['<button href="#" type="button" class="note-btn note-btn-primary note-btn-large note-image-btn disabled" disabled>', opt.lang.image.insert, '</button>'].join('');
  7956. return dialog({
  7957. title: opt.lang.image.insert,
  7958. fade: opt.fade,
  7959. body: body,
  7960. footer: footer
  7961. }).render();
  7962. };
  7963. const linkDialog = function (opt) {
  7964. const body = '<div class="note-form-group">' + '<label for="note-dialog-link-txt-' + opt.id + '" class="note-form-label">' + opt.lang.link.textToDisplay + '</label>' + '<input id="note-dialog-link-txt-' + opt.id + '" class="note-link-text note-input" type="text"/>' + '</div>' + '<div class="note-form-group">' + '<label for="note-dialog-link-url-' + opt.id + '" class="note-form-label">' + opt.lang.link.url + '</label>' + '<input id="note-dialog-link-url-' + opt.id + '" class="note-link-url note-input" type="text" value="http://"/>' + '</div>' + (!opt.disableLinkTarget ? '<div class="checkbox"><label for="note-dialog-link-nw-' + opt.id + '"><input id="note-dialog-link-nw-' + opt.id + '" type="checkbox" checked> ' + opt.lang.link.openInNewWindow + '</label></div>' : '') + '<div class="checkbox"><label for="note-dialog-link-up-' + opt.id + '"><input id="note-dialog-link-up-' + opt.id + '" type="checkbox" checked> ' + opt.lang.link.useProtocol + '</label></div>';
  7965. const footer = ['<button href="#" type="button" class="note-btn note-btn-primary note-link-btn disabled" disabled>', opt.lang.link.insert, '</button>'].join('');
  7966. return dialog({
  7967. className: 'link-dialog',
  7968. title: opt.lang.link.insert,
  7969. fade: opt.fade,
  7970. body: body,
  7971. footer: footer
  7972. }).render();
  7973. };
  7974. const popover = renderer["a" /* default */].create(['<div class="note-popover bottom">', '<div class="note-popover-arrow"/>', '<div class="popover-content note-children-container"/>', '</div>'].join(''), function ($node, options) {
  7975. const direction = typeof options.direction !== 'undefined' ? options.direction : 'bottom';
  7976. $node.addClass(direction).hide();
  7977. if (options.hideArrow) {
  7978. $node.find('.note-popover-arrow').hide();
  7979. }
  7980. });
  7981. const ui_checkbox = renderer["a" /* default */].create('<div class="checkbox"></div>', function ($node, options) {
  7982. $node.html(['<label' + (options.id ? ' for="note-' + options.id + '"' : '') + '>', '<input role="checkbox" type="checkbox"' + (options.id ? ' id="note-' + options.id + '"' : ''), options.checked ? ' checked' : '', ' aria-checked="' + (options.checked ? 'true' : 'false') + '"/>', options.text ? options.text : '', '</label>'].join(''));
  7983. });
  7984. const icon = function (iconClassName, tagName) {
  7985. tagName = tagName || 'i';
  7986. return '<' + tagName + ' class="' + iconClassName + '"/>';
  7987. };
  7988. const ui = function (editorOptions) {
  7989. return {
  7990. editor: editor,
  7991. toolbar: toolbar,
  7992. editingArea: editingArea,
  7993. codable: codable,
  7994. editable: editable,
  7995. statusbar: statusbar,
  7996. airEditor: airEditor,
  7997. airEditable: airEditable,
  7998. buttonGroup: buttonGroup,
  7999. button: ui_button,
  8000. dropdown: dropdown,
  8001. dropdownCheck: dropdownCheck,
  8002. dropdownButton: dropdownButton,
  8003. dropdownButtonContents: dropdownButtonContents,
  8004. dropdownCheckButton: dropdownCheckButton,
  8005. paragraphDropdownButton: paragraphDropdownButton,
  8006. tableDropdownButton: tableDropdownButton,
  8007. colorDropdownButton: colorDropdownButton,
  8008. palette: palette,
  8009. dialog: dialog,
  8010. videoDialog: videoDialog,
  8011. imageDialog: imageDialog,
  8012. linkDialog: linkDialog,
  8013. popover: popover,
  8014. checkbox: ui_checkbox,
  8015. icon: icon,
  8016. options: editorOptions,
  8017. toggleBtn: function ($btn, isEnable) {
  8018. $btn.toggleClass('disabled', !isEnable);
  8019. $btn.attr('disabled', !isEnable);
  8020. },
  8021. toggleBtnActive: function ($btn, isActive) {
  8022. $btn.toggleClass('active', isActive);
  8023. },
  8024. check: function ($dom, value) {
  8025. $dom.find('.checked').removeClass('checked');
  8026. $dom.find('[data-value="' + value + '"]').addClass('checked');
  8027. },
  8028. onDialogShown: function ($dialog, handler) {
  8029. $dialog.one('note.modal.show', handler);
  8030. },
  8031. onDialogHidden: function ($dialog, handler) {
  8032. $dialog.one('note.modal.hide', handler);
  8033. },
  8034. showDialog: function ($dialog) {
  8035. $dialog.data('modal').show();
  8036. },
  8037. hideDialog: function ($dialog) {
  8038. $dialog.data('modal').hide();
  8039. },
  8040. /**
  8041. * get popover content area
  8042. *
  8043. * @param $popover
  8044. * @returns {*}
  8045. */
  8046. getPopoverContent: function ($popover) {
  8047. return $popover.find('.note-popover-content');
  8048. },
  8049. /**
  8050. * get dialog's body area
  8051. *
  8052. * @param $dialog
  8053. * @returns {*}
  8054. */
  8055. getDialogBody: function ($dialog) {
  8056. return $dialog.find('.note-modal-body');
  8057. },
  8058. createLayout: function ($note) {
  8059. const $editor = (editorOptions.airMode ? airEditor([editingArea([codable(), airEditable()])]) : editorOptions.toolbarPosition === 'bottom' ? editor([editingArea([codable(), editable()]), toolbar(), statusbar()]) : editor([toolbar(), editingArea([codable(), editable()]), statusbar()])).render();
  8060. $editor.insertAfter($note);
  8061. return {
  8062. note: $note,
  8063. editor: $editor,
  8064. toolbar: $editor.find('.note-toolbar'),
  8065. editingArea: $editor.find('.note-editing-area'),
  8066. editable: $editor.find('.note-editable'),
  8067. codable: $editor.find('.note-codable'),
  8068. statusbar: $editor.find('.note-statusbar')
  8069. };
  8070. },
  8071. removeLayout: function ($note, layoutInfo) {
  8072. $note.html(layoutInfo.editable.html());
  8073. layoutInfo.editor.remove();
  8074. $note.off('summernote'); // remove summernote custom event
  8075. $note.show();
  8076. }
  8077. };
  8078. };
  8079. /* harmony default export */ var lite_ui = (ui);
  8080. // EXTERNAL MODULE: ./src/js/base/settings.js + 37 modules
  8081. var settings = __webpack_require__(3);
  8082. // EXTERNAL MODULE: ./src/styles/summernote-lite.scss
  8083. var summernote_lite = __webpack_require__(6);
  8084. // CONCATENATED MODULE: ./src/js/lite/settings.js
  8085. 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, {
  8086. ui_template: lite_ui,
  8087. interface: 'lite'
  8088. });
  8089. /***/ }),
  8090. /***/ 6:
  8091. /***/ (function(module, exports, __webpack_require__) {
  8092. // extracted by mini-css-extract-plugin
  8093. /***/ })
  8094. /******/ });
  8095. });
  8096. //# sourceMappingURL=summernote-lite.js.map