Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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